Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with child dependencies in Rust fixed #1352

Merged
merged 5 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<PortData>().map { port ->
this += n.effects.filterIsInstance<PortLike>().map { port ->
if (port.isMultiport) {
"__assembler.effects_bank(${n.invokerId}, &__self.${port.rustFieldName})?;"
} else {
Expand Down
44 changes: 44 additions & 0 deletions test/Rust/src/DependencyThroughChildPort.lf
Original file line number Diff line number Diff line change
@@ -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); =}
}
1 change: 1 addition & 0 deletions test/Rust/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down