Skip to content

Commit

Permalink
Merge pull request #4698 from legrosbuffle/refactor-gotoexpr
Browse files Browse the repository at this point in the history
[Refactoring] Introduce CTFE::isGotoExp to make conditions more readable (mirrors isCantExp)
  • Loading branch information
9rnsr committed May 31, 2015
2 parents 5f2e55d + 1d7d222 commit 1115587
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ctfe.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CTFEExp : public Expression
static CTFEExp *gotoexp;

static bool isCantExp(Expression *e) { return e && e->op == TOKcantexp; }
static bool isGotoExp(Expression *e) { return e && e->op == TOKgoto; }
};

/****************************************************************/
Expand Down
6 changes: 3 additions & 3 deletions src/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ Expression *interpret(FuncDeclaration *fd, InterState *istate, Expressions *argu
* statement, then go recursively down the AST looking
* for that statement, then execute starting there.
*/
if (e && e->op == TOKgoto)
if (CTFEExp::isGotoExp(e))
{
istatex.start = istatex.gotoTarget; // set starting statement
istatex.gotoTarget = NULL;
Expand Down Expand Up @@ -1749,7 +1749,7 @@ class Interpreter : public Visitor
setValue(ca->var, ex->thrown);
}
e = interpret(ca->handler, istate);
if (e && e->op == TOKgoto)
if (CTFEExp::isGotoExp(e))
{
/* This is an optimization that relies on the locality of the jump target.
* If the label is in the same catch handler, the following scan
Expand Down Expand Up @@ -1900,7 +1900,7 @@ class Interpreter : public Visitor
ctfeStack.push(s->wthis);
setValue(s->wthis, e);
e = interpret(s->body, istate);
if (e && e->op == TOKgoto)
if (CTFEExp::isGotoExp(e))
{
/* This is an optimization that relies on the locality of the jump target.
* If the label is in the same WithStatement, the following scan
Expand Down

0 comments on commit 1115587

Please sign in to comment.