Skip to content

Commit

Permalink
Expand macro in interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Dec 3, 2013
1 parent b8554bc commit e8ea758
Showing 1 changed file with 72 additions and 19 deletions.
91 changes: 72 additions & 19 deletions src/interpret.c
Expand Up @@ -1003,13 +1003,6 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument

/******************************** Statement ***************************/

#define START() \
if (istate->start) \
{ if (istate->start != this) \
return NULL; \
istate->start = NULL; \
}

/***********************************
* Interpret the statement.
* Returns:
Expand All @@ -1023,7 +1016,12 @@ Expression *Statement::interpret(InterState *istate)
#if LOG
printf("%s Statement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

error("Statement %s cannot be interpreted at compile time", this->toChars());
return EXP_CANT_INTERPRET;
}
Expand All @@ -1033,7 +1031,12 @@ Expression *ExpStatement::interpret(InterState *istate)
#if LOG
printf("%s ExpStatement::interpret(%s)\n", loc.toChars(), exp ? exp->toChars() : "");
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

if (exp)
{
Expression *e = exp->interpret(istate, ctfeNeedNothing);
Expand Down Expand Up @@ -1351,7 +1354,12 @@ Expression *ReturnStatement::interpret(InterState *istate)
#if LOG
printf("%s ReturnStatement::interpret(%s)\n", loc.toChars(), exp ? exp->toChars() : "");
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

if (!exp)
return EXP_VOID_INTERPRET;
assert(istate && istate->fd && istate->fd->type);
Expand Down Expand Up @@ -1412,7 +1420,12 @@ Expression *BreakStatement::interpret(InterState *istate)
#if LOG
printf("%s BreakStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

if (ident)
{
LabelDsymbol *label = istate->fd->searchLabel(ident);
Expand Down Expand Up @@ -1442,7 +1455,12 @@ Expression *ContinueStatement::interpret(InterState *istate)
#if LOG
printf("%s ContinueStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

if (ident)
{
LabelDsymbol *label = istate->fd->searchLabel(ident);
Expand Down Expand Up @@ -1706,7 +1724,12 @@ Expression *GotoStatement::interpret(InterState *istate)
#if LOG
printf("%s GotoStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

assert(label && label->statement);
istate->gotoTarget = label->statement;
return EXP_GOTO_INTERPRET;
Expand All @@ -1717,7 +1740,12 @@ Expression *GotoCaseStatement::interpret(InterState *istate)
#if LOG
printf("%s GotoCaseStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

assert(cs);
istate->gotoTarget = cs;
return EXP_GOTO_INTERPRET;
Expand All @@ -1728,7 +1756,12 @@ Expression *GotoDefaultStatement::interpret(InterState *istate)
#if LOG
printf("%s GotoDefaultStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

assert(sw && sw->sdefault);
istate->gotoTarget = sw->sdefault;
return EXP_GOTO_INTERPRET;
Expand Down Expand Up @@ -1885,7 +1918,12 @@ Expression *ThrowStatement::interpret(InterState *istate)
#if LOG
printf("%s ThrowStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

Expression *e = exp->interpret(istate);
if (exceptionOrCantInterpret(e))
return e;
Expand All @@ -1909,7 +1947,12 @@ Expression *WithStatement::interpret(InterState *istate)
if (exp->op == TOKimport || exp->op == TOKtype)
return body ? body->interpret(istate) : EXP_VOID_INTERPRET;

START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

Expression *e = exp->interpret(istate);
if (exceptionOrCantInterpret(e))
return e;
Expand Down Expand Up @@ -1947,7 +1990,12 @@ Expression *AsmStatement::interpret(InterState *istate)
#if LOG
printf("%s AsmStatement::interpret()\n", loc.toChars());
#endif
START()
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}

error("asm statements cannot be interpreted at compile time");
return EXP_CANT_INTERPRET;
}
Expand All @@ -1958,7 +2006,12 @@ Expression *ImportStatement::interpret(InterState *istate)
#if LOG
printf("ImportStatement::interpret()\n");
#endif
START();
if (istate->start)
{ if (istate->start != this)
return NULL;
istate->start = NULL;
}
;
return NULL;
}
#endif
Expand Down

0 comments on commit e8ea758

Please sign in to comment.