Skip to content

Commit

Permalink
[Refactoring] Fix signature of the constructor in FuncExp
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed May 17, 2015
1 parent d660f7a commit 4e020d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
35 changes: 13 additions & 22 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -5508,11 +5508,17 @@ Expression *TupleExp::semantic(Scope *sc)

/******************************** FuncExp *********************************/

FuncExp::FuncExp(Loc loc, FuncLiteralDeclaration *fd, TemplateDeclaration *td)
FuncExp::FuncExp(Loc loc, Dsymbol *s)
: Expression(loc, TOKfunction, sizeof(FuncExp))
{
this->fd = fd;
this->td = td;
this->td = s->isTemplateDeclaration();
this->fd = s->isFuncLiteralDeclaration();
if (td)
{
assert(td->literal);
assert(td->members && td->members->dim == 1);
fd = (*td->members)[0]->isFuncLiteralDeclaration();
}
tok = fd->tok; // save original kind of function/delegate/(infer)
assert(fd->fbody);
}
Expand Down Expand Up @@ -5561,27 +5567,12 @@ void FuncExp::genIdent(Scope *sc)

Expression *FuncExp::syntaxCopy()
{
TemplateDeclaration *td2;
FuncLiteralDeclaration *fd2;
if (td)
{
td2 = (TemplateDeclaration *)td->syntaxCopy(NULL);
assert(td2->members->dim == 1);
fd2 = (*td2->members)[0]->isFuncLiteralDeclaration();
assert(fd2);
}
return new FuncExp(loc, td->syntaxCopy(NULL));
else if (fd->semanticRun == PASSinit)
{
td2 = NULL;
fd2 = (FuncLiteralDeclaration *)fd->syntaxCopy(NULL);
}
else
{
// Bugzilla 13481: Prevent multiple semantic analysis of lambda body.
td2 = NULL;
fd2 = fd;
}
return new FuncExp(loc, fd2, td2);
return new FuncExp(loc, fd->syntaxCopy(NULL));
else // Bugzilla 13481: Prevent multiple semantic analysis of lambda body.
return new FuncExp(loc, fd);
}

Expression *FuncExp::semantic(Scope *sc)
Expand Down
2 changes: 1 addition & 1 deletion src/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ class FuncExp : public Expression
TemplateDeclaration *td;
TOK tok;

FuncExp(Loc loc, FuncLiteralDeclaration *fd, TemplateDeclaration *td = NULL);
FuncExp(Loc loc, Dsymbol *s);
void genIdent(Scope *sc);
Expression *syntaxCopy();
Expression *semantic(Scope *sc);
Expand Down
2 changes: 1 addition & 1 deletion src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6949,7 +6949,7 @@ Expression *Parser::parsePrimaryExp()
td = new TemplateDeclaration(fd->loc, fd->ident, tpl, NULL, decldefs, false, true);
}

e = new FuncExp(loc, fd, td);
e = new FuncExp(loc, td ? (Dsymbol *)td : fd);
break;
}

Expand Down

0 comments on commit 4e020d6

Please sign in to comment.