mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
simplified ZAM instructions for executing "assert" statements
This commit is contained in:
parent
14b59192ba
commit
4b6cec4cd8
2 changed files with 14 additions and 16 deletions
|
@ -348,22 +348,20 @@ eval static auto assertion_result_hook = id::find_func("assertion_result");
|
||||||
$$ = ! $1 || run_result_hook;
|
$$ = ! $1 || run_result_hook;
|
||||||
|
|
||||||
op Report-Assert
|
op Report-Assert
|
||||||
# Operands are (1) result from Should-Report-Assert, (2) assertion value,
|
# Operands are (1) assertion value, (2) description of the condition
|
||||||
# (3) description of the condition (always a constant).
|
# (always a constant).
|
||||||
op1-read
|
op1-read
|
||||||
classes VVC
|
classes VC
|
||||||
op-types I I S
|
op-types I S
|
||||||
eval if ( $$ )
|
eval {
|
||||||
{
|
|
||||||
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
|
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
|
||||||
report_assert($1, $2->ToStdString(), msg_val, Z_LOC->Loc());
|
report_assert($$, $1->ToStdString(), msg_val, Z_LOC->Loc());
|
||||||
}
|
}
|
||||||
|
|
||||||
op Report-Assert-With-Message
|
op Report-Assert-With-Message
|
||||||
# The same, but with an additional operand being the associated message
|
# The same, but with an additional operand being the associated message
|
||||||
# (as a variable, so it comes in $2 rather than $3).
|
# (as a variable, so it comes in $1 rather than $2).
|
||||||
op1-read
|
op1-read
|
||||||
classes VVVC
|
classes VVC
|
||||||
op-types I I S S
|
op-types I S S
|
||||||
eval if ( $$ )
|
eval report_assert($$, $2->ToStdString(), {NewRef{}, $1}, Z_LOC->Loc());
|
||||||
report_assert($1, $3->ToStdString(), {NewRef{}, $2}, Z_LOC->Loc());
|
|
||||||
|
|
|
@ -1083,10 +1083,10 @@ const ZAMStmt ZAMCompiler::CompileAssert(const AssertStmt* as) {
|
||||||
else
|
else
|
||||||
msg_slot = FrameSlot(msg->AsNameExpr());
|
msg_slot = FrameSlot(msg->AsNameExpr());
|
||||||
|
|
||||||
z = ZInstI(OP_REPORT_ASSERT_WITH_MESSAGE_VVVC, decision_slot, cond_slot, msg_slot, cond_desc_e.get());
|
z = ZInstI(OP_REPORT_ASSERT_WITH_MESSAGE_VVC, cond_slot, msg_slot, cond_desc_e.get());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
z = ZInstI(OP_REPORT_ASSERT_VVC, decision_slot, cond_slot, cond_desc_e.get());
|
z = ZInstI(OP_REPORT_ASSERT_VC, cond_slot, cond_desc_e.get());
|
||||||
|
|
||||||
auto end_inst = AddInst(z);
|
auto end_inst = AddInst(z);
|
||||||
AddCFT(insts1.back(), CFT_BLOCK_END);
|
AddCFT(insts1.back(), CFT_BLOCK_END);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue