feat: a LOT of stuff (final report, examples, simulation of a single assert, move from node instances to node definitions, etc.)

This commit is contained in:
Henri Saudubray 2025-08-20 18:20:46 +02:00
parent ba5db5bd99
commit f2c545ce2c
Signed by: hms
GPG key ID: 7065F57ED8856128
49 changed files with 12377 additions and 1898 deletions

View file

@ -1,58 +1,72 @@
(* The Zelus compiler, version 2024-dev
(2025-06-4-15:49) *)
open Ztypes
type ('c, 'b, 'a) machine_17 =
{ mutable _up_16: 'c;
mutable y'_12: 'b;
mutable y_11: 'a }
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
let (ball) =
let ball_10 =
let machine_17 cstate_18 =
let machine_17_alloc _ =
cstate_18.cmax <- (+) cstate_18.cmax 2;
cstate_18.zmax <- (+) cstate_18.zmax 1;
{ _up_16 = { zin = false; zout = 1. };
y'_12 = { pos = (-1.); der = 0. };
y_11 = { pos = (-1.); der = 0. } } in
let machine_17_step self _ =
((let cindex_19 = cstate_18.cindex in
let cpos_21 = ref (cindex_19:int) in
let zindex_20 = cstate_18.zindex in
let zpos_22 = ref (zindex_20:int) in
cstate_18.cindex <- (+) cstate_18.cindex 2;
cstate_18.zindex <- (+) cstate_18.zindex 1;
(if cstate_18.major
then
for i_1 = cindex_19 to 1
do Zls.set cstate_18.dvec i_1 0. done
else
((self.y'_12.pos <- Zls.get cstate_18.cvec !cpos_21;
cpos_21 := (+) !cpos_21 1);
(self.y_11.pos <- Zls.get cstate_18.cvec !cpos_21;
cpos_21 := (+) !cpos_21 1)));
(let result_23 =
self._up_16.zout <- (~-.) self.y_11.pos;
self.y'_12.der <- (-9.81);
(let z_13 = self._up_16.zin in
let lx_15 = self.y'_12.pos in
(match z_13 with
| true ->
let v_14 = lx_15 in
self.y'_12.pos <- ( *. ) (-0.8) v_14 | _ -> () );
self.y_11.der <- self.y'_12.pos;
(self.y_11.pos, self.y'_12.pos, z_13)) in
cpos_21 := cindex_19;
(if cstate_18.major
then
(((Zls.set cstate_18.cvec !cpos_21 self.y'_12.pos;
cpos_21 := (+) !cpos_21 1);
(Zls.set cstate_18.cvec !cpos_21 self.y_11.pos;
cpos_21 := (+) !cpos_21 1));
((self._up_16.zin <- false)))
else
(((self._up_16.zin <- Zls.get_zin cstate_18.zinvec
!zpos_22;
zpos_22 := (+) !zpos_22 1));
zpos_22 := zindex_20;
((Zls.set cstate_18.zoutvec !zpos_22 self._up_16.zout;
zpos_22 := (+) !zpos_22 1));
((Zls.set cstate_18.dvec !cpos_21 self.y'_12.der;
cpos_21 := (+) !cpos_21 1);
(Zls.set cstate_18.dvec !cpos_21 self.y_11.der;
cpos_21 := (+) !cpos_21 1)))); result_23)):(float *
float *
bool)) in
let machine_17_reset self =
((self.y_11.pos <- 50.; self.y'_12.pos <- 0.):unit) in
Node { alloc = machine_17_alloc; step = machine_17_step;
reset = machine_17_reset } in
machine_17 in
ball_10