diff --git a/org.lflang/src/org/lflang/generator/rust/RustReactorEmitter.kt b/org.lflang/src/org/lflang/generator/rust/RustReactorEmitter.kt index 37aaa94515..dd2156172b 100644 --- a/org.lflang/src/org/lflang/generator/rust/RustReactorEmitter.kt +++ b/org.lflang/src/org/lflang/generator/rust/RustReactorEmitter.kt @@ -283,7 +283,7 @@ ${" | "..declareChildConnections()} if (n.isShutdown) this += "__assembler.declare_triggers($rsRuntime::assembly::TriggerId::SHUTDOWN, ${n.invokerId})?;" this += n.uses.map { trigger -> "__assembler.declare_uses(${n.invokerId}, __self.${trigger.rustFieldName}.get_id())?;" } - this += n.effects.filterIsInstance().map { port -> + this += n.effects.filterIsInstance().map { port -> if (port.isMultiport) { "__assembler.effects_bank(${n.invokerId}, &__self.${port.rustFieldName})?;" } else { diff --git a/test/Rust/src/DependencyThroughChildPort.lf b/test/Rust/src/DependencyThroughChildPort.lf new file mode 100644 index 0000000000..0e708cf878 --- /dev/null +++ b/test/Rust/src/DependencyThroughChildPort.lf @@ -0,0 +1,44 @@ +target Rust + +reactor Destination { + input x: u32 + input y: u32 + + state exec_count: u32 + + reaction(x, y) {= + let tag = ctx.get_tag(); + println!( + "Time since start: {}, microstep: {}", + tag.offset_from_t0.as_nanos(), + tag.microstep, + ); + + if tag == tag!(T0) { + assert!(ctx.is_present(x)); + assert_eq!(self.exec_count, 0); + } else { + assert_tag_is!(ctx, (T0, 1)); + assert!(ctx.is_present(y)); + assert_eq!(self.exec_count, 1); + } + self.exec_count += 1; + =} + + reaction(shutdown) {= + assert!(self.exec_count == 2, "reaction was not executed twice"); + println!("success"); + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + ctx.set(d__x, 1); + ctx.schedule(repeat, Asap); + =} + + reaction(repeat) -> d.y {= ctx.set(d__y, 1); =} +} diff --git a/test/Rust/src/README.md b/test/Rust/src/README.md index d272323595..5d09ad52eb 100644 --- a/test/Rust/src/README.md +++ b/test/Rust/src/README.md @@ -21,6 +21,7 @@ This is not exhaustive. Ideally each of those bullet points would have a test ca - dependencies can be declared... - [x] all test files: on ports of this reactor - [x] `DependencyOnChildPort.lf`: on ports of a child reactor + - [x] `DependencyThroughChildPort.lf`: on ports of a child, triggers child reactions - [x] all test files: on an action - [x] trigger dependencies - [x] all test files: trigger dependencies trigger reactions