(* The Zelus compiler, version 2024-dev (2025-06-4-15:49) *) open Ztypes type ('e, 'd, 'c, 'b, 'a) ball = { mutable time: 'e; mutable major: 'd; mutable up: 'c; mutable y': 'b; mutable y: 'a } let ball = let machine cstate = let alloc _ = cstate.cmax <- cstate.cmax + 1; cstate.zmax <- cstate.zmax + 1; { time = -1.; major = false; up = { zin = false; zout = 1. }; y' = -1.; y = { pos = -1.; der = 0. }; } in let step self _ = let cindex = cstate.cindex in let cpos = ref cindex in let zindex = cstate.zindex in let zpos = ref zindex in cstate.cindex <- cstate.cindex + 1; cstate.zindex <- cstate.zindex + 1; self.major <- cstate.major; self.time <- cstate.time; if cstate.major then for i = cindex to 0 do Zls.set cstate.dvec i 0. done else begin self.y.pos <- Zls.get cstate.cvec !cpos; cpos := !cpos + 1 end; let result = self.up.zout <- -. self.y.pos; if self.up.zin then self.y' <- -0.8 *. self.y'; self.y.der <- self.y'; self.y.pos, self.y', self.up.zin in cpos := cindex; if cstate.major then begin Zls.set cstate.cvec !cpos self.y.pos; cpos := !cpos + 1; self.up.zin <- false end else begin self.up.zin <- Zls.get_zin cstate.zinvec !zpos; zpos := !zpos + 1 end; zpos := zindex; Zls.set cstate.zoutvec !zpos self.up.zout; zpos := !zpos + 1; Zls.set cstate.dvec !cpos self.y.der; cpos := !cpos + 1; result in let reset self = self.y.pos <- 50.; self.y' <- 0. in Node { alloc; step; reset } in machine