Skip to content

Commit

Permalink
Merge pull request #3316 from yebblies/iasmsemantic
Browse files Browse the repository at this point in the history
[DDMD] Move AsmStatement::semantic into a free function
  • Loading branch information
9rnsr committed Feb 21, 2014
2 parents a71d132 + e1491c1 commit c23840c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/iasm.c
Expand Up @@ -4682,13 +4682,13 @@ regm_t iasm_regs(block *bp)

/************************ AsmStatement ***************************************/

Statement *AsmStatement::semantic(Scope *sc)
Statement* asmSemantic(AsmStatement *s, Scope *sc)
{
//printf("AsmStatement::semantic()\n");

assert(sc->func);
if (sc->func->setUnsafe())
error("inline assembler not allowed in @safe function %s", sc->func->toChars());
s->error("inline assembler not allowed in @safe function %s", sc->func->toChars());

OP *o;
OPND *o1 = NULL,*o2 = NULL, *o3 = NULL, *o4 = NULL;
Expand All @@ -4700,12 +4700,12 @@ Statement *AsmStatement::semantic(Scope *sc)

assert(fd);

if (!tokens)
if (!s->tokens)
return NULL;

memset(&asmstate, 0, sizeof(asmstate));

asmstate.statement = this;
asmstate.statement = s;
asmstate.sc = sc;

#if 0 // don't use bReturnax anymore, and will fail anyway if we use return type inference
Expand All @@ -4730,24 +4730,24 @@ Statement *AsmStatement::semantic(Scope *sc)
asmstate.psLocalsize = Dsymbol::create(Id::__LOCAL_SIZE);
}

asmstate.loc = loc;
asmstate.loc = s->loc;

asmtok = tokens;
asmtok = s->tokens;
asm_token_trans(asmtok);

try
{
switch (tok_value)
{
case ASMTKnaked:
naked = TRUE;
s->naked = TRUE;
sc->func->naked = TRUE;
asm_token();
break;

case ASMTKeven:
asm_token();
asmalign = 2;
s->asmalign = 2;
break;

case TOKalign:
Expand All @@ -4758,7 +4758,7 @@ Statement *AsmStatement::semantic(Scope *sc)
if (ispow2(align) == -1)
asmerr(EM_align, align); // power of 2 expected
else
asmalign = align;
s->asmalign = align;
break;
}

Expand Down Expand Up @@ -4789,11 +4789,11 @@ Statement *AsmStatement::semantic(Scope *sc)
switch (asmstate.ucItype)
{
case ITdata:
asmcode = asm_db_parse(o);
s->asmcode = asm_db_parse(o);
goto AFTER_EMIT;

case ITaddr:
asmcode = asm_da_parse(o);
s->asmcode = asm_da_parse(o);
goto AFTER_EMIT;
}
}
Expand Down Expand Up @@ -4849,7 +4849,7 @@ Statement *AsmStatement::semantic(Scope *sc)
usNumops = 1;
}
#endif
asmcode = asm_emit(loc, usNumops, ptb, o, o1, o2, o3, o4);
s->asmcode = asm_emit(s->loc, usNumops, ptb, o, o1, o2, o3, o4);
break;

default:
Expand Down Expand Up @@ -4885,12 +4885,12 @@ Statement *AsmStatement::semantic(Scope *sc)
}
}
//return asmstate.bReturnax;
return this;
return s;
}

#else

Statement* AsmStatement::semantic(Scope *sc)
Statement* asmSemantic(AsmStatement *s, Scope *sc)
{
assert(0);
return NULL;
Expand Down
7 changes: 6 additions & 1 deletion src/statement.h
Expand Up @@ -765,6 +765,8 @@ class LabelDsymbol : public Dsymbol
void accept(Visitor *v) { v->visit(this); }
};

Statement* asmSemantic(AsmStatement *s, Scope *sc);

class AsmStatement : public Statement
{
public:
Expand All @@ -777,7 +779,10 @@ class AsmStatement : public Statement

AsmStatement(Loc loc, Token *tokens);
Statement *syntaxCopy();
Statement *semantic(Scope *sc);
Statement *semantic(Scope *sc)
{
return asmSemantic(this, sc);
}
int blockExit(bool mustNotThrow);

void accept(Visitor *v) { v->visit(this); }
Expand Down

0 comments on commit c23840c

Please sign in to comment.