@@ -110,6 +110,28 @@ void AExecutionContext::postcompile()
110110{ postcompile_ (); }
111111
112112
113+ void AExecutionContext::sync_fluent (const Reference<Fluent> &f, const Activity &context)
114+ {
115+ vector<unique_ptr<Value>> sync_exog_args;
116+ for (const unique_ptr<Expression> &arg : f.args ())
117+ sync_exog_args.emplace_back (
118+ new Value (arg->abstract_expr_semantics ().evaluate (context, history ()))
119+ );
120+
121+ sync_exog_args.emplace_back (
122+ new Value (context.target ()->senses ()->abstract_expr_semantics ().evaluate (context, history ()))
123+ );
124+
125+ backend ().sync_event (
126+ ExogEvent (
127+ context.target ()->senses ()->target ()->sync_action (),
128+ std::move (sync_exog_args)
129+ )
130+ );
131+ }
132+
133+
134+
113135
114136ExecutionContext::ExecutionContext (unique_ptr<SemanticsFactory> &&semantics, unique_ptr<PlatformBackend> &&exec_backend)
115137: AExecutionContext(std::move(semantics), std::move(exec_backend))
@@ -149,27 +171,21 @@ void ExecutionContext::run(Block &&program)
149171 backend ().start_activity (trans);
150172 else if (trans->hook () == Transition::Hook::FINISH) {
151173 shared_ptr<Activity> activity = backend ().end_activity (trans);
174+
175+ // Sync effects if necessary
176+ for (const auto &effect : trans->target ()->effects ())
177+ if (effect->fluent ()->synced ())
178+ sync_fluent (effect->fluent (), *activity);
179+
152180 if (trans->target ()->senses ()) {
153181 history ().abstract_semantics ().append_sensing_result (
154182 *activity->target ()->senses (),
155183 activity->sensing_result ().get ()
156184 );
157185
158- if (trans->target ()->senses ()->target ()->synced ()) {
159- vector<unique_ptr<Value>> sync_exog_args;
160- for (const unique_ptr<Expression> &arg : trans->target ()->senses ()->args ())
161- sync_exog_args.emplace_back (
162- new Value (arg->abstract_semantics ().evaluate (*activity, history ()))
163- );
164-
165- sync_exog_args.emplace_back (
166- trans->target ()->senses ()->abstract_semantics ().evaluate (*activity, history ());
167- );
168-
169- backend ().sync_event (
170- ExogEvent (trans->target ()->senses ())
171- );
172- }
186+ // Sync sensed fluent if necessary
187+ if (trans->target ()->senses ()->target ()->synced ())
188+ sync_fluent (*trans->target ()->senses (), *activity);
173189 }
174190 }
175191 else
0 commit comments