Allow arbitrary when statement timeout expressions

BIT-1284 #close
This commit is contained in:
Jon Siwek 2014-10-31 10:35:02 -05:00
parent 285f93b689
commit 2a181a88c5
4 changed files with 24 additions and 6 deletions

View file

@ -131,18 +131,19 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
arg_frame->SetDelayed();
}
Val* timeout = arg_timeout ? arg_timeout->ExprVal() : 0;
Val* timeout_val = arg_timeout ? arg_timeout->Eval(arg_frame) : 0;
// Make sure we don't get deleted if somebody calls a method like
// Timeout() while evaluating the trigger.
Ref(this);
if ( ! Eval() && timeout )
if ( ! Eval() && timeout_val )
{
timer = new TriggerTimer(timeout->AsInterval(), this);
timer = new TriggerTimer(timeout_val->AsInterval(), this);
timer_mgr->Add(timer);
}
Unref(timeout_val);
Unref(this);
}