@@ -224,11 +224,12 @@ trait StagedWasmEvaluator extends SAIOps {
224224 eval(rest, kont, mk, trail)(newRestCtx)
225225 })
226226 // TODO: put the cond.s to path condition
227+ ExploreTree .fillWithIfElse(cond.s)
227228 if (cond.toInt != 0 ) {
228- ExploreTree .fillWithIfElse(cond.s, true )
229+ ExploreTree .moveCursor( true )
229230 eval(thn, restK _, mkont, restK _ :: trail)(newCtx)
230231 } else {
231- ExploreTree .fillWithIfElse(cond.s.not, false )
232+ ExploreTree .moveCursor( false )
232233 eval(els, restK _, mkont, restK _ :: trail)(newCtx)
233234 }
234235 ()
@@ -239,13 +240,14 @@ trait StagedWasmEvaluator extends SAIOps {
239240 val (cond, newCtx) = Stack .pop()
240241 info(s " The br_if( ${label})'s condition is " , cond.toInt)
241242 // TODO: put the cond.s to path condition
243+ ExploreTree .fillWithIfElse(cond.s)
242244 if (cond.toInt != 0 ) {
243245 info(s " Jump to $label" )
244- ExploreTree .fillWithIfElse(cond.s, true )
246+ ExploreTree .moveCursor( true )
245247 trail(label)(newCtx)(mkont)
246248 } else {
247249 info(s " Continue " )
248- ExploreTree .fillWithIfElse(cond.s.not, false )
250+ ExploreTree .moveCursor( false )
249251 eval(rest, kont, mkont, trail)(newCtx)
250252 }
251253 ()
@@ -581,8 +583,12 @@ trait StagedWasmEvaluator extends SAIOps {
581583
582584 // Exploration tree,
583585 object ExploreTree {
584- def fillWithIfElse (s : Rep [SymVal ], branch : Boolean ): Rep [Unit ] = {
585- " tree-fill-if-else" .reflectCtrlWith[Unit ](s, branch)
586+ def fillWithIfElse (s : Rep [SymVal ]): Rep [Unit ] = {
587+ " tree-fill-if-else" .reflectCtrlWith[Unit ](s)
588+ }
589+
590+ def moveCursor (branch : Boolean ): Rep [Unit ] = {
591+ " tree-move-cursor" .reflectCtrlWith[Unit ](branch)
586592 }
587593 }
588594
@@ -898,8 +904,10 @@ trait StagedWasmCppGen extends CGenBase with CppSAICodeGenBase {
898904 shallow(lhs); emit(" >= " ); shallow(rhs)
899905 case Node (_, " num-to-int" , List (num), _) =>
900906 shallow(num); emit(" .toInt()" )
901- case Node (_, " tree-fill-if-else" , List (s, b), _) =>
902- emit(" ExploreTree.fillIfElseNode(" ); shallow(s); emit(" , " ); shallow(b); emit(" )" )
907+ case Node (_, " tree-fill-if-else" , List (s), _) =>
908+ emit(" ExploreTree.fillIfElseNode(" ); shallow(s); emit(" )" )
909+ case Node (_, " tree-move-cursor" , List (b), _) =>
910+ emit(" ExploreTree.moveCursor(" ); shallow(b); emit(" )" )
903911 case Node (_, " sym-not" , List (s), _) =>
904912 shallow(s); emit(" .negate()" )
905913 case Node (_, " dummy" , _, _) => emit(" std::monostate()" )
0 commit comments