Permalink
Browse files

Merge pull request #1409 from 9rnsr/fix1528

Issue 1528 - [tdpl] overloading template and non-template functions
  • Loading branch information...
MartinNowak committed Jun 28, 2013
2 parents ce270e4 + 5b26ea3 commit fba440cc7dc1210b0450f8b01d18661ebbd0da55
@@ -102,11 +102,13 @@ struct Match
FuncDeclaration *anyf; // pick a func, any func, to use for error recovery
};

void overloadResolveX(Match *m, FuncDeclaration *f,
Type *tthis, Expressions *arguments);
void functionResolve(Match *m, FuncDeclaration *f,
Type *tthis, Expressions *arguments, Dsymbol **plast = NULL);
void templateResolve(Match *m, TemplateDeclaration *td, Loc loc, Scope *sc,
Objects *tiargs, Type *tthis, Expressions *fargs);
int overloadApply(FuncDeclaration *fstart,
int (*fp)(void *, FuncDeclaration *),
void *param);
void *param, Dsymbol **plast = NULL);

void ObjectNotFound(Identifier *id);

@@ -592,7 +594,7 @@ class FuncDeclaration : public Declaration
VarDeclaration *v_argsave; // save area for args passed in registers for variadic functions
VarDeclarations *parameters; // Array of VarDeclaration's for parameters
DsymbolTable *labtab; // statement label symbol table
Declaration *overnext; // next in overload list
Dsymbol *overnext; // next in overload list
FuncDeclaration *overnext0; // next in overload list (only used during IFTI)
Loc endloc; // location of closing curly bracket
int vtblIndex; // for member functions, index into vtbl[]
@@ -669,7 +671,7 @@ class FuncDeclaration : public Declaration
int findVtblIndex(Dsymbols *vtbl, int dim);
bool overloadInsert(Dsymbol *s);
FuncDeclaration *overloadExactMatch(Type *t);
FuncDeclaration *overloadResolve(Loc loc, Type *tthis, Expressions *arguments, int flags = 0);
TemplateDeclaration *findTemplateDeclRoot();
MATCH leastAsSpecialized(FuncDeclaration *g);
LabelDsymbol *searchLabel(Identifier *ident);
AggregateDeclaration *isThis();
@@ -591,12 +591,18 @@ Expression *searchUFCS(Scope *sc, UnaExp *ue, Identifier *ident)

if (ue->op == TOKdotti)
{
DotTemplateInstanceExp *dti = (DotTemplateInstanceExp *)ue;
TemplateDeclaration *td = s->toAlias()->isTemplateDeclaration();
Dsymbol *sx = s->toAlias();
TemplateDeclaration *td = sx->isTemplateDeclaration();
if (!td)
{ if (FuncDeclaration *fd = sx->isFuncDeclaration())
td = fd->findTemplateDeclRoot();
}
if (!td)
{ s->error(loc, "is not a template");
return new ErrorExp();
}

DotTemplateInstanceExp *dti = (DotTemplateInstanceExp *)ue;
if (!dti->ti->semanticTiargs(sc))
return new ErrorExp();
return new ScopeExp(loc, new TemplateInstance(loc, td, dti->ti->tiargs));
@@ -1736,12 +1742,12 @@ void argsToCBuffer(OutBuffer *buf, Expressions *expressions, HdrGenState *hgs)

void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs)
{
if (arguments)
{ OutBuffer argbuf;

if (arguments && arguments->dim)
{
OutBuffer argbuf;
for (size_t i = 0; i < arguments->dim; i++)
{ Expression *e = (*arguments)[i];

{
Expression *e = (*arguments)[i];
if (i)
buf->writestring(", ");
argbuf.reset();
@@ -7892,6 +7898,34 @@ Expression *DotTemplateInstanceExp::semanticY(Scope *sc, int flag)
L1:
if (e->op == TOKerror)
return e;
if (e->op == TOKdotvar)
{
DotVarExp *dve = (DotVarExp *)e;
FuncDeclaration *f = dve->var->isFuncDeclaration();
if (f)
{
TemplateDeclaration *td = f->findTemplateDeclRoot();
if (td)
{
e = new DotTemplateExp(dve->loc, dve->e1, td);
e = e->semantic(sc);
}
}
}
else if (e->op == TOKvar)
{
VarExp *ve = (VarExp *)e;
FuncDeclaration *f = ve->var->isFuncDeclaration();
if (f)
{
TemplateDeclaration *td = f->findTemplateDeclRoot();
if (td)
{
e = new ScopeExp(ve->loc, td);
e = e->semantic(sc);
}
}
}
if (e->op == TOKdottd)
{
if (ti->errors)
Oops, something went wrong.

0 comments on commit fba440c

Please sign in to comment.