diff --git a/src/script_opt/ZAM/Compile.h b/src/script_opt/ZAM/Compile.h index 071521b6a7..e1cd35bf2b 100644 --- a/src/script_opt/ZAM/Compile.h +++ b/src/script_opt/ZAM/Compile.h @@ -137,7 +137,6 @@ private: const ZAMStmt CompileCatchReturn(const CatchReturnStmt* cr); const ZAMStmt CompileStmts(const StmtList* sl); const ZAMStmt CompileInit(const InitStmt* is); - const ZAMStmt CompileWhen(const WhenStmt* ws); const ZAMStmt CompileNext() { return GenGoTo(nexts.back()); } const ZAMStmt CompileBreak() { return GenGoTo(breaks.back()); } diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index c0d756d97d..b6b09c7645 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -1845,28 +1845,6 @@ type V eval (*tiv_ptr)[z.v1].Clear(); - -op When -op1-read -type VVVV -eval auto when_body = make_intrusive(this, z.v2); - auto timeout_body = make_intrusive(this, z.v3); - ExprPtr when_cond = {NewRef{}, const_cast(z.e)}; - new trigger::Trigger(when_cond, when_body, timeout_body, frame[z.v1].double_val, f, z.v4, z.loc); - -op When -type VVVC -eval auto when_body = make_intrusive(this, z.v1); - auto timeout_body = make_intrusive(this, z.v2); - ExprPtr when_cond = {NewRef{}, const_cast(z.e)}; - new trigger::Trigger(when_cond, when_body, timeout_body, z.c.double_val, f, z.v3, z.loc); - -op When -type VV -eval auto when_body = make_intrusive(this, z.v2); - ExprPtr when_cond = {NewRef{}, const_cast(z.e)}; - new trigger::Trigger(when_cond, when_body, nullptr, -1.0, f, z.v1, z.loc); - op CheckAnyLen op1-read type Vi diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index 1e3daedee8..d35c279c38 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -63,9 +63,6 @@ const ZAMStmt ZAMCompiler::CompileStmt(const Stmt* s) case STMT_NULL: return EmptyStmt(); - case STMT_WHEN: - return CompileWhen(static_cast(s)); - case STMT_CHECK_ANY_LEN: { auto cs = static_cast(s); @@ -1125,78 +1122,4 @@ const ZAMStmt ZAMCompiler::InitTable(IDPtr id, TableType* tt, Attributes* attrs) return AddInst(z); } -const ZAMStmt ZAMCompiler::CompileWhen(const WhenStmt* ws) - { - auto cond = ws->Cond(); - auto body = ws->Body(); - auto timeout = ws->TimeoutExpr(); - auto timeout_body = ws->TimeoutBody(); - auto is_return = ws->IsReturn(); - - ZInstI z; - - if ( timeout ) - { - // Note, we fill in is_return by hand since it's already - // an int_val, doesn't need translation. - if ( timeout->Tag() == EXPR_CONST ) - { - z = GenInst(OP_WHEN_VVVC, timeout->AsConstExpr()); - z.op_type = OP_VVVC_I1_I2_I3; - z.v3 = is_return; - } - else - { - z = GenInst(OP_WHEN_VVVV, timeout->AsNameExpr()); - z.op_type = OP_VVVV_I2_I3_I4; - z.v4 = is_return; - } - } - - else - { - z = GenInst(OP_WHEN_VV); - z.op_type = OP_VV_I1_I2; - z.v1 = is_return; - } - - z.e = cond.get(); - - auto when_eval = AddInst(z); - - auto branch_past_blocks = GoToStub(); - - auto when_body = CompileStmt(body); - auto when_done = ReturnX(); - - if ( timeout ) - { - auto t_body = CompileStmt(timeout_body); - auto t_done = ReturnX(); - - if ( timeout->Tag() == EXPR_CONST ) - { - SetV1(when_eval, GoToTargetBeyond(branch_past_blocks)); - SetV2(when_eval, GoToTargetBeyond(when_done)); - } - else - { - SetV2(when_eval, GoToTargetBeyond(branch_past_blocks)); - SetV3(when_eval, GoToTargetBeyond(when_done)); - } - - SetGoTo(branch_past_blocks, GoToTargetBeyond(t_done)); - - return t_done; - } - - else - { - SetV2(when_eval, GoToTargetBeyond(branch_past_blocks)); - SetGoTo(branch_past_blocks, GoToTargetBeyond(when_done)); - - return when_done; - } - } - } // zeek::detail