Skip to content

Commit

Permalink
[Refactoring] Remove use of Expression::addressOf in glue layer
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Feb 23, 2014
1 parent 6c0cfcf commit 83b7ba1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
7 changes: 3 additions & 4 deletions src/e2ir.c
Expand Up @@ -188,10 +188,9 @@ elem *callfunc(Loc loc,

if (p->storageClass & (STCout | STCref))
{
// Convert argument to a pointer,
// use AddrExp::toElem()
Expression *ae = arg->addressOf();
ea = ae->toElem(irs);
// Convert argument to a pointer
ea = arg->toElem(irs);
ea = addressElem(ea, arg->type->pointerTo());
goto L1;
}
}
Expand Down
14 changes: 1 addition & 13 deletions src/expression.c
Expand Up @@ -2458,19 +2458,7 @@ Expression *Expression::addressOf()
{
//printf("Expression::addressOf()\n");
#ifdef DEBUG
{
Expression *e = this;
while (e->op == TOKcomma)
e = ((CommaExp *)e)->e2;

/* VarExp::isLvalue() returns false if the variable has STCtemp.
* However in glue layer, a variable with STCtemp is address-able.
* So currently we cannot directly use e->isLvalue().
*/
assert(e->op == TOKvar && ((VarExp *)e)->var->isVarDeclaration() ||
e->op == TOKerror ||
e->isLvalue());
}
assert(op == TOKerror || isLvalue());
#endif
Expression *e = new AddrExp(loc, this);
e->type = type->pointerTo();
Expand Down
4 changes: 2 additions & 2 deletions src/s2ir.c
Expand Up @@ -796,8 +796,8 @@ class S2irVisitor : public Visitor
else if (tf->isref)
{
// Reference return, so convert to a pointer
Expression *ae = s->exp->addressOf();
e = toElemDtor(ae, irs);
e = toElemDtor(s->exp, irs);
e = addressElem(e, s->exp->type->pointerTo());
}
else
{
Expand Down

0 comments on commit 83b7ba1

Please sign in to comment.