mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Wrap LDC specific code in #ifdef INLLVM / #endif
This commit is contained in:
134
dmd2/statement.c
134
dmd2/statement.c
@@ -2092,12 +2092,13 @@ Lagain:
|
||||
case Tdelegate:
|
||||
Lapply:
|
||||
{
|
||||
FuncDeclaration *fdapply;
|
||||
Expression *ec;
|
||||
Expression *e;
|
||||
TypeDelegate* dgty;
|
||||
TypeDelegate* dgty2;
|
||||
TypeDelegate* fldeTy;
|
||||
#if IN_LLVM
|
||||
FuncDeclaration *fdapply;
|
||||
TypeDelegate* dgty;
|
||||
TypeDelegate* fldeTy;
|
||||
#endif
|
||||
|
||||
if (!checkForArgTypes())
|
||||
{ body = body->semanticNoScope(sc);
|
||||
@@ -2210,6 +2211,13 @@ Lagain:
|
||||
/* Call:
|
||||
* _aaApply(aggr, keysize, flde)
|
||||
*/
|
||||
#if !IN_LLVM
|
||||
FuncDeclaration *fdapply;
|
||||
if (dim == 2)
|
||||
fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply2");
|
||||
else
|
||||
fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply");
|
||||
#else
|
||||
//LDC: Build arguments.
|
||||
static FuncDeclaration *aaApply2_fd = NULL;
|
||||
static TypeDelegate* aaApply2_dg;
|
||||
@@ -2243,6 +2251,7 @@ Lagain:
|
||||
fdapply = aaApply_fd;
|
||||
fldeTy = aaApply_dg;
|
||||
}
|
||||
#endif
|
||||
ec = new VarExp(0, fdapply);
|
||||
Expressions *exps = new Expressions();
|
||||
exps->push(aggr);
|
||||
@@ -2260,7 +2269,11 @@ Lagain:
|
||||
#endif
|
||||
exps->push(flde);
|
||||
e = new CallExp(loc, ec, exps);
|
||||
#if !IN_LLVM
|
||||
e->type = Type::tindex; // don't run semantic() on e
|
||||
#else
|
||||
e->type = Type::tint32; // don't run semantic() on e
|
||||
#endif
|
||||
}
|
||||
else if (tab->ty == Tarray || tab->ty == Tsarray)
|
||||
{
|
||||
@@ -3095,12 +3108,13 @@ Statement *PragmaStatement::semantic(Scope *sc)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if IN_LLVM
|
||||
// LDC
|
||||
else if (ident == Id::allow_inline)
|
||||
{
|
||||
sc->func->allowInlining = true;
|
||||
}
|
||||
#endif
|
||||
#if DMDV2
|
||||
else if (ident == Id::startaddress)
|
||||
{
|
||||
@@ -3220,12 +3234,14 @@ SwitchStatement::SwitchStatement(Loc loc, Expression *c, Statement *b, bool isFi
|
||||
this->body = b;
|
||||
this->isFinal = isFinal;
|
||||
sdefault = NULL;
|
||||
#if !IN_LLVM
|
||||
tf = NULL;
|
||||
#else
|
||||
enclosingScopeExit = NULL;
|
||||
#endif
|
||||
cases = NULL;
|
||||
hasNoDefault = 0;
|
||||
hasVars = 0;
|
||||
#if IN_LLVM
|
||||
enclosingScopeExit = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *SwitchStatement::syntaxCopy()
|
||||
@@ -3432,10 +3448,11 @@ CaseStatement::CaseStatement(Loc loc, Expression *exp, Statement *s)
|
||||
this->statement = s;
|
||||
index = 0;
|
||||
cblock = NULL;
|
||||
#if IN_LLVM
|
||||
bodyBB = NULL;
|
||||
llvmIdx = NULL;
|
||||
// LDC
|
||||
enclosingScopeExit = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *CaseStatement::syntaxCopy()
|
||||
@@ -3679,14 +3696,14 @@ Statement *DefaultStatement::semantic(Scope *sc)
|
||||
}
|
||||
sc->sw->sdefault = this;
|
||||
|
||||
#if IN_LLVM
|
||||
#if !IN_LLVM
|
||||
if (sc->sw->tf != sc->tf)
|
||||
error("switch and default are in different finally blocks");
|
||||
#else
|
||||
enclosingScopeExit = sc->sw->enclosingScopeExit;
|
||||
|
||||
if (sc->sw->isFinal)
|
||||
{
|
||||
error("default statement not allowed in final switch statement");
|
||||
}
|
||||
#endif
|
||||
if (sc->sw->isFinal)
|
||||
error("default statement not allowed in final switch statement");
|
||||
}
|
||||
else
|
||||
error("default not in switch statement");
|
||||
@@ -3756,7 +3773,9 @@ GotoCaseStatement::GotoCaseStatement(Loc loc, Expression *exp)
|
||||
{
|
||||
cs = NULL;
|
||||
this->exp = exp;
|
||||
#if IN_LLVM
|
||||
sw = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *GotoCaseStatement::syntaxCopy()
|
||||
@@ -3775,7 +3794,9 @@ Statement *GotoCaseStatement::semantic(Scope *sc)
|
||||
error("goto case not in switch statement");
|
||||
else
|
||||
{
|
||||
#if IN_LLVM
|
||||
sw = sc->sw;
|
||||
#endif
|
||||
sc->sw->gotoCases.push(this);
|
||||
if (exp)
|
||||
{
|
||||
@@ -3870,7 +3891,11 @@ Statement *ReturnStatement::semantic(Scope *sc)
|
||||
|
||||
if (sc->incontract || scx->incontract)
|
||||
error("return statements cannot be in contracts");
|
||||
#if !IN_LLVM
|
||||
if (sc->tf || scx->tf)
|
||||
#else
|
||||
if (sc->enclosingFinally || scx->enclosingFinally)
|
||||
#endif
|
||||
error("return statements cannot be in finally, scope(exit) or scope(success) bodies");
|
||||
|
||||
if (fd->isCtorDeclaration())
|
||||
@@ -4256,10 +4281,16 @@ Statement *BreakStatement::semantic(Scope *sc)
|
||||
|
||||
if (!s->hasBreak())
|
||||
error("label '%s' has no break", ident->toChars());
|
||||
#if !IN_LLVM
|
||||
if (ls->tf != sc->tf)
|
||||
#else
|
||||
if (ls->enclosingFinally != sc->enclosingFinally)
|
||||
#endif
|
||||
error("cannot break out of finally block");
|
||||
|
||||
#if IN_LLVM
|
||||
this->target = ls;
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -4359,10 +4390,16 @@ Statement *ContinueStatement::semantic(Scope *sc)
|
||||
|
||||
if (!s->hasContinue())
|
||||
error("label '%s' has no continue", ident->toChars());
|
||||
#if !IN_LLVM
|
||||
if (ls->tf != sc->tf)
|
||||
#else
|
||||
if (ls->enclosingFinally != sc->enclosingFinally)
|
||||
#endif
|
||||
error("cannot continue out of finally block");
|
||||
|
||||
#if IN_LLVM
|
||||
this->target = ls;
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -4407,8 +4444,9 @@ SynchronizedStatement::SynchronizedStatement(Loc loc, Expression *exp, Statement
|
||||
this->exp = exp;
|
||||
this->body = body;
|
||||
this->esync = NULL;
|
||||
// LDC
|
||||
#if IN_LLVM
|
||||
this->llsync = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
SynchronizedStatement::SynchronizedStatement(Loc loc, elem *esync, Statement *body)
|
||||
@@ -4417,8 +4455,9 @@ SynchronizedStatement::SynchronizedStatement(Loc loc, elem *esync, Statement *bo
|
||||
this->exp = NULL;
|
||||
this->body = body;
|
||||
this->esync = esync;
|
||||
// LDC
|
||||
#if IN_LLVM
|
||||
this->llsync = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *SynchronizedStatement::syntaxCopy()
|
||||
@@ -4505,7 +4544,11 @@ Statement *SynchronizedStatement::semantic(Scope *sc)
|
||||
* try { body } finally { _d_criticalexit(critsec.ptr); }
|
||||
*/
|
||||
Identifier *id = Lexer::uniqueId("__critsec");
|
||||
#if !IN_LLVM
|
||||
Type *t = new TypeSArray(Type::tint8, new IntegerExp(PTRSIZE + (global.params.is64bit ? os_critsecsize64() : os_critsecsize32())));
|
||||
#else
|
||||
Type *t = new TypeSArray(Type::tint8, new IntegerExp(PTRSIZE + os_critsecsize()));
|
||||
#endif
|
||||
VarDeclaration *tmp = new VarDeclaration(loc, t, id, NULL);
|
||||
tmp->storage_class |= STCgshared | STCstatic;
|
||||
|
||||
@@ -4546,12 +4589,16 @@ Statement *SynchronizedStatement::semantic(Scope *sc)
|
||||
#endif
|
||||
Lbody:
|
||||
if (body)
|
||||
#if IN_LLVM
|
||||
{
|
||||
Statement* oldScopeExit = sc->enclosingScopeExit;
|
||||
sc->enclosingScopeExit = this;
|
||||
#endif
|
||||
body = body->semantic(sc);
|
||||
#if IN_LLVM
|
||||
sc->enclosingScopeExit = oldScopeExit;
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -4841,7 +4888,11 @@ void Catch::semantic(Scope *sc)
|
||||
//printf("Catch::semantic(%s)\n", ident->toChars());
|
||||
|
||||
#ifndef IN_GCC
|
||||
#if !IN_LLVM
|
||||
if (sc->tf)
|
||||
#else
|
||||
if (sc->enclosingFinally)
|
||||
#endif
|
||||
{
|
||||
/* This is because the _d_local_unwind() gets the stack munged
|
||||
* up on this. The workaround is to place any try-catches into
|
||||
@@ -4930,14 +4981,20 @@ Statement *TryFinallyStatement::syntaxCopy()
|
||||
Statement *TryFinallyStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("TryFinallyStatement::semantic()\n");
|
||||
|
||||
#if IN_LLVM
|
||||
Statement* oldScopeExit = sc->enclosingScopeExit;
|
||||
sc->enclosingScopeExit = this;
|
||||
#endif
|
||||
body = body->semantic(sc);
|
||||
#if IN_LLVM
|
||||
sc->enclosingScopeExit = oldScopeExit;
|
||||
|
||||
#endif
|
||||
sc = sc->push();
|
||||
#if !IN_LLVM
|
||||
sc->tf = this;
|
||||
#else
|
||||
sc->enclosingFinally = this;
|
||||
#endif
|
||||
sc->sbreak = NULL;
|
||||
sc->scontinue = NULL; // no break or continue out of finally block
|
||||
finalbody = finalbody->semanticNoScope(sc);
|
||||
@@ -5160,12 +5217,16 @@ Statement *VolatileStatement::syntaxCopy()
|
||||
Statement *VolatileStatement::semantic(Scope *sc)
|
||||
{
|
||||
if (statement)
|
||||
#if IN_LLVM
|
||||
{
|
||||
Statement* oldScopeExit = sc->enclosingScopeExit;
|
||||
sc->enclosingScopeExit = this;
|
||||
Statement* oldScopeExit = sc->enclosingScopeExit;
|
||||
sc->enclosingScopeExit = this;
|
||||
#endif
|
||||
statement = statement->semantic(sc);
|
||||
sc->enclosingScopeExit = oldScopeExit;
|
||||
#if IN_LLVM
|
||||
sc->enclosingScopeExit = oldScopeExit;
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -5263,8 +5324,12 @@ GotoStatement::GotoStatement(Loc loc, Identifier *ident)
|
||||
{
|
||||
this->ident = ident;
|
||||
this->label = NULL;
|
||||
#if !IN_LLVM
|
||||
this->tf = NULL;
|
||||
#else
|
||||
this->enclosingFinally = NULL;
|
||||
this->enclosingScopeExit = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *GotoStatement::syntaxCopy()
|
||||
@@ -5277,9 +5342,12 @@ Statement *GotoStatement::semantic(Scope *sc)
|
||||
{ FuncDeclaration *fd = sc->parent->isFuncDeclaration();
|
||||
|
||||
//printf("GotoStatement::semantic()\n");
|
||||
#if !IN_LLVM
|
||||
tf = sc->tf;
|
||||
#else
|
||||
enclosingFinally = sc->enclosingFinally;
|
||||
enclosingScopeExit = sc->enclosingScopeExit;
|
||||
|
||||
#endif
|
||||
label = fd->searchLabel(ident);
|
||||
if (!label->statement && sc->fes)
|
||||
{
|
||||
@@ -5297,7 +5365,11 @@ Statement *GotoStatement::semantic(Scope *sc)
|
||||
sc->fes->gotos->push(s); // 'look at this later' list
|
||||
return s;
|
||||
}
|
||||
#if !IN_LLVM
|
||||
if (label->statement && label->statement->tf != sc->tf)
|
||||
#else
|
||||
if (label->statement && label->statement->enclosingFinally != sc->enclosingFinally)
|
||||
#endif
|
||||
error("cannot goto in or out of finally block");
|
||||
return this;
|
||||
}
|
||||
@@ -5324,11 +5396,17 @@ LabelStatement::LabelStatement(Loc loc, Identifier *ident, Statement *statement)
|
||||
{
|
||||
this->ident = ident;
|
||||
this->statement = statement;
|
||||
#if !IN_LLVM
|
||||
this->tf = NULL;
|
||||
#else
|
||||
this->enclosingFinally = NULL;
|
||||
this->enclosingScopeExit = NULL;
|
||||
#endif
|
||||
this->lblock = NULL;
|
||||
this->fwdrefs = NULL;
|
||||
#if IN_LLVM
|
||||
this->asmLabel = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Statement *LabelStatement::syntaxCopy()
|
||||
@@ -5347,10 +5425,12 @@ Statement *LabelStatement::semantic(Scope *sc)
|
||||
error("Label '%s' already defined", ls->toChars());
|
||||
else
|
||||
ls->statement = this;
|
||||
|
||||
#if !IN_LLVM
|
||||
tf = sc->tf;
|
||||
#else
|
||||
enclosingFinally = sc->enclosingFinally;
|
||||
enclosingScopeExit = sc->enclosingScopeExit;
|
||||
|
||||
#endif
|
||||
sc = sc->push();
|
||||
sc->scopesym = sc->enclosing->scopesym;
|
||||
sc->callSuper |= CSXlabel;
|
||||
@@ -5359,8 +5439,10 @@ Statement *LabelStatement::semantic(Scope *sc)
|
||||
statement = statement->semanticNoScope(sc);
|
||||
sc->pop();
|
||||
|
||||
#if IN_LLVM
|
||||
// LDC put in labmap
|
||||
fd->labmap[ident->toChars()] = this;
|
||||
#endif
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -5460,7 +5542,7 @@ int AsmStatement::comeFrom()
|
||||
int AsmStatement::blockExit(bool mustNotThrow)
|
||||
{
|
||||
if (mustNotThrow)
|
||||
error("asm statements are assumed to throw");
|
||||
error("asm statements are assumed to throw", toChars());
|
||||
// Assume the worst
|
||||
return BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt;
|
||||
}
|
||||
|
||||
@@ -519,7 +519,9 @@ struct SwitchStatement : Statement
|
||||
bool isFinal;
|
||||
|
||||
DefaultStatement *sdefault;
|
||||
|
||||
#if !IN_LLVM
|
||||
TryFinallyStatement *tf;
|
||||
#endif
|
||||
GotoCaseStatements gotoCases; // array of unresolved GotoCaseStatement's
|
||||
CaseStatements *cases; // array of CaseStatement's
|
||||
int hasNoDefault; // !=0 if no default statement
|
||||
@@ -884,8 +886,12 @@ struct GotoStatement : Statement
|
||||
{
|
||||
Identifier *ident;
|
||||
LabelDsymbol *label;
|
||||
#if !IN_LLVM
|
||||
TryFinallyStatement *tf;
|
||||
#else
|
||||
TryFinallyStatement *enclosingFinally;
|
||||
Statement* enclosingScopeExit;
|
||||
#endif
|
||||
|
||||
GotoStatement(Loc loc, Identifier *ident);
|
||||
Statement *syntaxCopy();
|
||||
@@ -901,8 +907,12 @@ struct LabelStatement : Statement
|
||||
{
|
||||
Identifier *ident;
|
||||
Statement *statement;
|
||||
#if !IN_LLVM
|
||||
TryFinallyStatement *tf;
|
||||
#else
|
||||
TryFinallyStatement *enclosingFinally;
|
||||
Statement* enclosingScopeExit;
|
||||
#endif
|
||||
block *lblock; // back end
|
||||
|
||||
Blocks *fwdrefs; // forward references to this LabelStatement
|
||||
@@ -988,6 +998,7 @@ struct ImportStatement : Statement
|
||||
void toIR(IRState *irs);
|
||||
};
|
||||
|
||||
#if IN_LLVM
|
||||
struct AsmBlockStatement : CompoundStatement
|
||||
{
|
||||
TryFinallyStatement* enclosingFinally;
|
||||
@@ -1007,5 +1018,6 @@ struct AsmBlockStatement : CompoundStatement
|
||||
|
||||
llvm::Value* abiret;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* DMD_STATEMENT_H */
|
||||
|
||||
Reference in New Issue
Block a user