mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-05 22:10:04 +02:00
@@ -53,6 +53,7 @@ Scope::Scope()
|
||||
this->parent = NULL;
|
||||
this->sw = NULL;
|
||||
this->tf = NULL;
|
||||
this->tfOfTry = NULL;
|
||||
this->sbreak = NULL;
|
||||
this->scontinue = NULL;
|
||||
this->fes = NULL;
|
||||
@@ -89,6 +90,7 @@ Scope::Scope(Scope *enclosing)
|
||||
this->sd = NULL;
|
||||
this->sw = enclosing->sw;
|
||||
this->tf = enclosing->tf;
|
||||
this->tfOfTry = enclosing->tfOfTry;
|
||||
this->sbreak = enclosing->sbreak;
|
||||
this->scontinue = enclosing->scontinue;
|
||||
this->fes = enclosing->fes;
|
||||
|
||||
@@ -44,7 +44,8 @@ struct Scope
|
||||
Dsymbol *parent; // parent to use
|
||||
LabelStatement *slabel; // enclosing labelled statement
|
||||
SwitchStatement *sw; // enclosing switch statement
|
||||
TryFinallyStatement *tf; // enclosing try finally statement
|
||||
TryFinallyStatement *tf; // enclosing try finally statement; set inside its finally block
|
||||
TryFinallyStatement *tfOfTry; // enclosing try finally statement; set inside its try block
|
||||
Statement *sbreak; // enclosing statement that supports "break"
|
||||
Statement *scontinue; // enclosing statement that supports "continue"
|
||||
ForeachStatement *fes; // if nested function for ForeachStatement, this is it
|
||||
|
||||
@@ -561,6 +561,7 @@ UnrolledLoopStatement::UnrolledLoopStatement(Loc loc, Statements *s)
|
||||
: Statement(loc)
|
||||
{
|
||||
statements = s;
|
||||
enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *UnrolledLoopStatement::syntaxCopy()
|
||||
@@ -582,6 +583,8 @@ Statement *UnrolledLoopStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("UnrolledLoopStatement::semantic(this = %p, sc = %p)\n", this, sc);
|
||||
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
sc->noctor++;
|
||||
Scope *scd = sc->push();
|
||||
scd->sbreak = this;
|
||||
@@ -771,6 +774,7 @@ WhileStatement::WhileStatement(Loc loc, Expression *c, Statement *b)
|
||||
{
|
||||
condition = c;
|
||||
body = b;
|
||||
enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *WhileStatement::syntaxCopy()
|
||||
@@ -805,6 +809,8 @@ Statement *WhileStatement::semantic(Scope *sc)
|
||||
}
|
||||
#endif
|
||||
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
condition = condition->semantic(sc);
|
||||
condition = resolveProperties(sc, condition);
|
||||
condition = condition->optimize(WANTvalue);
|
||||
@@ -870,6 +876,7 @@ DoStatement::DoStatement(Loc loc, Statement *b, Expression *c)
|
||||
{
|
||||
body = b;
|
||||
condition = c;
|
||||
enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *DoStatement::syntaxCopy()
|
||||
@@ -881,6 +888,8 @@ Statement *DoStatement::syntaxCopy()
|
||||
|
||||
Statement *DoStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
sc->noctor++;
|
||||
if (body)
|
||||
body = body->semanticScope(sc, this, this);
|
||||
@@ -943,6 +952,7 @@ ForStatement::ForStatement(Loc loc, Statement *init, Expression *condition, Expr
|
||||
this->condition = condition;
|
||||
this->increment = increment;
|
||||
this->body = body;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *ForStatement::syntaxCopy()
|
||||
@@ -962,6 +972,8 @@ Statement *ForStatement::syntaxCopy()
|
||||
|
||||
Statement *ForStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
ScopeDsymbol *sym = new ScopeDsymbol();
|
||||
sym->parent = sc->scopesym;
|
||||
sc = sc->push(sym);
|
||||
@@ -1074,6 +1086,7 @@ ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Arguments *arguments,
|
||||
this->arguments = arguments;
|
||||
this->aggr = aggr;
|
||||
this->body = body;
|
||||
this->enclosingtry = NULL;
|
||||
|
||||
this->key = NULL;
|
||||
this->value = NULL;
|
||||
@@ -1102,6 +1115,8 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||
Type *tn = NULL;
|
||||
Type *tnv = NULL;
|
||||
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
func = sc->func;
|
||||
if (func->fes)
|
||||
func = func->fes->func;
|
||||
@@ -1956,7 +1971,7 @@ SwitchStatement::SwitchStatement(Loc loc, Expression *c, Statement *b)
|
||||
cases = NULL;
|
||||
hasNoDefault = 0;
|
||||
// LLVMDC
|
||||
defaultBB = NULL;
|
||||
enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *SwitchStatement::syntaxCopy()
|
||||
@@ -1970,6 +1985,9 @@ Statement *SwitchStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("SwitchStatement::semantic(%p)\n", this);
|
||||
assert(!cases); // ensure semantic() is only run once
|
||||
|
||||
enclosingtry = sc->tfOfTry;
|
||||
|
||||
condition = condition->semantic(sc);
|
||||
condition = resolveProperties(sc, condition);
|
||||
if (condition->type->isString())
|
||||
@@ -2107,6 +2125,7 @@ CaseStatement::CaseStatement(Loc loc, Expression *exp, Statement *s)
|
||||
this->exp = exp;
|
||||
this->statement = s;
|
||||
cblock = NULL;
|
||||
bodyBB = NULL;
|
||||
}
|
||||
|
||||
Statement *CaseStatement::syntaxCopy()
|
||||
@@ -2203,6 +2222,7 @@ DefaultStatement::DefaultStatement(Loc loc, Statement *s)
|
||||
#if IN_GCC
|
||||
+ cblock = NULL;
|
||||
#endif
|
||||
bodyBB = NULL;
|
||||
}
|
||||
|
||||
Statement *DefaultStatement::syntaxCopy()
|
||||
@@ -2254,6 +2274,7 @@ GotoDefaultStatement::GotoDefaultStatement(Loc loc)
|
||||
: Statement(loc)
|
||||
{
|
||||
sw = NULL;
|
||||
enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *GotoDefaultStatement::syntaxCopy()
|
||||
@@ -2264,6 +2285,7 @@ Statement *GotoDefaultStatement::syntaxCopy()
|
||||
|
||||
Statement *GotoDefaultStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
sw = sc->sw;
|
||||
if (!sw)
|
||||
error("goto default not in switch statement");
|
||||
@@ -2287,6 +2309,8 @@ GotoCaseStatement::GotoCaseStatement(Loc loc, Expression *exp)
|
||||
{
|
||||
cs = NULL;
|
||||
this->exp = exp;
|
||||
enclosingtry = NULL;
|
||||
sw = NULL;
|
||||
}
|
||||
|
||||
Statement *GotoCaseStatement::syntaxCopy()
|
||||
@@ -2298,6 +2322,7 @@ Statement *GotoCaseStatement::syntaxCopy()
|
||||
|
||||
Statement *GotoCaseStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
if (exp)
|
||||
exp = exp->semantic(sc);
|
||||
|
||||
@@ -2305,6 +2330,7 @@ Statement *GotoCaseStatement::semantic(Scope *sc)
|
||||
error("goto case not in switch statement");
|
||||
else
|
||||
{
|
||||
sw = sc->sw;
|
||||
sc->sw->gotoCases.push(this);
|
||||
if (exp)
|
||||
{
|
||||
@@ -2355,6 +2381,7 @@ ReturnStatement::ReturnStatement(Loc loc, Expression *exp)
|
||||
: Statement(loc)
|
||||
{
|
||||
this->exp = exp;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *ReturnStatement::syntaxCopy()
|
||||
@@ -2369,6 +2396,7 @@ Statement *ReturnStatement::syntaxCopy()
|
||||
Statement *ReturnStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("ReturnStatement::semantic() %s\n", toChars());
|
||||
this->enclosingtry = sc->tfOfTry;
|
||||
|
||||
FuncDeclaration *fd = sc->parent->isFuncDeclaration();
|
||||
Scope *scx = sc;
|
||||
@@ -2629,6 +2657,7 @@ BreakStatement::BreakStatement(Loc loc, Identifier *ident)
|
||||
: Statement(loc)
|
||||
{
|
||||
this->ident = ident;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *BreakStatement::syntaxCopy()
|
||||
@@ -2639,6 +2668,7 @@ Statement *BreakStatement::syntaxCopy()
|
||||
|
||||
Statement *BreakStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
// If:
|
||||
// break Identifier;
|
||||
if (ident)
|
||||
@@ -2678,6 +2708,8 @@ Statement *BreakStatement::semantic(Scope *sc)
|
||||
error("label '%s' has no break", ident->toChars());
|
||||
if (ls->tf != sc->tf)
|
||||
error("cannot break out of finally block");
|
||||
|
||||
this->target = ls;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2719,6 +2751,7 @@ ContinueStatement::ContinueStatement(Loc loc, Identifier *ident)
|
||||
: Statement(loc)
|
||||
{
|
||||
this->ident = ident;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *ContinueStatement::syntaxCopy()
|
||||
@@ -2729,6 +2762,7 @@ Statement *ContinueStatement::syntaxCopy()
|
||||
|
||||
Statement *ContinueStatement::semantic(Scope *sc)
|
||||
{
|
||||
enclosingtry = sc->tfOfTry;
|
||||
//printf("ContinueStatement::semantic() %p\n", this);
|
||||
if (ident)
|
||||
{
|
||||
@@ -2777,6 +2811,8 @@ Statement *ContinueStatement::semantic(Scope *sc)
|
||||
error("label '%s' has no continue", ident->toChars());
|
||||
if (ls->tf != sc->tf)
|
||||
error("cannot continue out of finally block");
|
||||
|
||||
this->target = ls;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -3159,6 +3195,7 @@ TryFinallyStatement::TryFinallyStatement(Loc loc, Statement *body, Statement *fi
|
||||
{
|
||||
this->body = body;
|
||||
this->finalbody = finalbody;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *TryFinallyStatement::syntaxCopy()
|
||||
@@ -3171,7 +3208,12 @@ Statement *TryFinallyStatement::syntaxCopy()
|
||||
Statement *TryFinallyStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("TryFinallyStatement::semantic()\n");
|
||||
|
||||
enclosingtry = sc->tfOfTry;
|
||||
sc->tfOfTry = this;
|
||||
body = body->semantic(sc);
|
||||
sc->tfOfTry = enclosingtry;
|
||||
|
||||
sc = sc->push();
|
||||
sc->tf = this;
|
||||
sc->sbreak = NULL;
|
||||
@@ -3405,6 +3447,7 @@ GotoStatement::GotoStatement(Loc loc, Identifier *ident)
|
||||
this->ident = ident;
|
||||
this->label = NULL;
|
||||
this->tf = NULL;
|
||||
this->enclosingtry = NULL;
|
||||
}
|
||||
|
||||
Statement *GotoStatement::syntaxCopy()
|
||||
@@ -3418,6 +3461,7 @@ Statement *GotoStatement::semantic(Scope *sc)
|
||||
|
||||
//printf("GotoStatement::semantic()\n");
|
||||
tf = sc->tf;
|
||||
enclosingtry = sc->tfOfTry;
|
||||
label = fd->searchLabel(ident);
|
||||
if (!label->statement && sc->fes)
|
||||
{
|
||||
@@ -3461,6 +3505,7 @@ LabelStatement::LabelStatement(Loc loc, Identifier *ident, Statement *statement)
|
||||
this->ident = ident;
|
||||
this->statement = statement;
|
||||
this->tf = NULL;
|
||||
this->enclosingtry = NULL;
|
||||
this->lblock = NULL;
|
||||
this->isReturnLabel = 0;
|
||||
this->llvmBB = NULL;
|
||||
@@ -3483,6 +3528,7 @@ Statement *LabelStatement::semantic(Scope *sc)
|
||||
else
|
||||
ls->statement = this;
|
||||
tf = sc->tf;
|
||||
enclosingtry = sc->tfOfTry;
|
||||
sc = sc->push();
|
||||
sc->scopesym = sc->enclosing->scopesym;
|
||||
sc->callSuper |= CSXlabel;
|
||||
|
||||
@@ -44,9 +44,11 @@ struct AsmStatement;
|
||||
struct GotoStatement;
|
||||
struct ScopeStatement;
|
||||
struct TryCatchStatement;
|
||||
struct TryFinallyStatement;
|
||||
struct HdrGenState;
|
||||
struct InterState;
|
||||
struct CaseStatement;
|
||||
struct LabelStatement;
|
||||
|
||||
enum TOK;
|
||||
|
||||
@@ -191,6 +193,7 @@ struct CompoundStatement : Statement
|
||||
struct UnrolledLoopStatement : Statement
|
||||
{
|
||||
Statements *statements;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
UnrolledLoopStatement(Loc loc, Statements *statements);
|
||||
Statement *syntaxCopy();
|
||||
@@ -235,6 +238,7 @@ struct WhileStatement : Statement
|
||||
{
|
||||
Expression *condition;
|
||||
Statement *body;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
WhileStatement(Loc loc, Expression *c, Statement *b);
|
||||
Statement *syntaxCopy();
|
||||
@@ -256,6 +260,7 @@ struct DoStatement : Statement
|
||||
{
|
||||
Statement *body;
|
||||
Expression *condition;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
DoStatement(Loc loc, Statement *b, Expression *c);
|
||||
Statement *syntaxCopy();
|
||||
@@ -279,6 +284,7 @@ struct ForStatement : Statement
|
||||
Expression *condition;
|
||||
Expression *increment;
|
||||
Statement *body;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body);
|
||||
Statement *syntaxCopy();
|
||||
@@ -303,6 +309,7 @@ struct ForeachStatement : Statement
|
||||
Arguments *arguments; // array of Argument*'s
|
||||
Expression *aggr;
|
||||
Statement *body;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
VarDeclaration *key;
|
||||
VarDeclaration *value;
|
||||
@@ -399,6 +406,7 @@ struct SwitchStatement : Statement
|
||||
Expression *condition;
|
||||
Statement *body;
|
||||
DefaultStatement *sdefault;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
Array gotoCases; // array of unresolved GotoCaseStatement's
|
||||
Array *cases; // array of CaseStatement's
|
||||
@@ -416,9 +424,6 @@ struct SwitchStatement : Statement
|
||||
Statement *inlineScan(InlineScanState *iss);
|
||||
|
||||
void toIR(IRState *irs);
|
||||
|
||||
// LLVMDC
|
||||
llvm::BasicBlock* defaultBB;
|
||||
};
|
||||
|
||||
struct CaseStatement : Statement
|
||||
@@ -443,6 +448,9 @@ struct CaseStatement : Statement
|
||||
void toIR(IRState *irs);
|
||||
|
||||
CaseStatement* isCaseStatement() { return this; }
|
||||
|
||||
// LLVMDC
|
||||
llvm::BasicBlock* bodyBB;
|
||||
};
|
||||
|
||||
struct DefaultStatement : Statement
|
||||
@@ -464,11 +472,15 @@ struct DefaultStatement : Statement
|
||||
Statement *inlineScan(InlineScanState *iss);
|
||||
|
||||
void toIR(IRState *irs);
|
||||
|
||||
// LLVMDC
|
||||
llvm::BasicBlock* bodyBB;
|
||||
};
|
||||
|
||||
struct GotoDefaultStatement : Statement
|
||||
{
|
||||
SwitchStatement *sw;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
GotoDefaultStatement(Loc loc);
|
||||
Statement *syntaxCopy();
|
||||
@@ -484,6 +496,8 @@ struct GotoCaseStatement : Statement
|
||||
{
|
||||
Expression *exp; // NULL, or which case to goto
|
||||
CaseStatement *cs; // case statement it resolves to
|
||||
TryFinallyStatement *enclosingtry;
|
||||
SwitchStatement *sw;
|
||||
|
||||
GotoCaseStatement(Loc loc, Expression *exp);
|
||||
Statement *syntaxCopy();
|
||||
@@ -507,6 +521,7 @@ struct SwitchErrorStatement : Statement
|
||||
struct ReturnStatement : Statement
|
||||
{
|
||||
Expression *exp;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
ReturnStatement(Loc loc, Expression *exp);
|
||||
Statement *syntaxCopy();
|
||||
@@ -527,6 +542,7 @@ struct ReturnStatement : Statement
|
||||
struct BreakStatement : Statement
|
||||
{
|
||||
Identifier *ident;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
BreakStatement(Loc loc, Identifier *ident);
|
||||
Statement *syntaxCopy();
|
||||
@@ -536,11 +552,15 @@ struct BreakStatement : Statement
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
|
||||
void toIR(IRState *irs);
|
||||
|
||||
// LLVMDC: only set if ident is set: label statement to jump to
|
||||
LabelStatement *target;
|
||||
};
|
||||
|
||||
struct ContinueStatement : Statement
|
||||
{
|
||||
Identifier *ident;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
ContinueStatement(Loc loc, Identifier *ident);
|
||||
Statement *syntaxCopy();
|
||||
@@ -550,6 +570,9 @@ struct ContinueStatement : Statement
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
|
||||
void toIR(IRState *irs);
|
||||
|
||||
// LLVMDC: only set if ident is set: label statement to jump to
|
||||
LabelStatement *target;
|
||||
};
|
||||
|
||||
struct SynchronizedStatement : Statement
|
||||
@@ -629,6 +652,7 @@ struct TryFinallyStatement : Statement
|
||||
{
|
||||
Statement *body;
|
||||
Statement *finalbody;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody);
|
||||
Statement *syntaxCopy();
|
||||
@@ -695,6 +719,7 @@ struct GotoStatement : Statement
|
||||
Identifier *ident;
|
||||
LabelDsymbol *label;
|
||||
TryFinallyStatement *tf;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
|
||||
GotoStatement(Loc loc, Identifier *ident);
|
||||
Statement *syntaxCopy();
|
||||
@@ -712,6 +737,7 @@ struct LabelStatement : Statement
|
||||
Identifier *ident;
|
||||
Statement *statement;
|
||||
TryFinallyStatement *tf;
|
||||
TryFinallyStatement *enclosingtry;
|
||||
block *lblock; // back end
|
||||
int isReturnLabel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user