diff dmd/expression.c @ 1609:1d0220dd613a

Merge DMD r274: harmonization --- dmd/expression.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++- dmd/template.c | 41 +++++++++++++++++++++++++++++++++++ dmd/template.h | 1 + 3 files changed, 103 insertions(+), 1 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:21 -0300
parents 207a8a438dea
children 3f728445fc42
line wrap: on
line diff
--- a/dmd/expression.c	Wed Jan 06 15:18:20 2010 -0300
+++ b/dmd/expression.c	Wed Jan 06 15:18:21 2010 -0300
@@ -5895,7 +5895,66 @@
 }
 
 Expression *DotTemplateInstanceExp::semantic(Scope *sc)
-{   Dsymbol *s;
+{
+#if 1
+#if LOGSEMANTIC
+    printf("DotTemplateInstanceExp::semantic('%s')\n", toChars());
+#endif
+    Expression *eleft;
+    Expression *e = new DotIdExp(loc, e1, ti->name);
+L1:
+    e = e->semantic(sc);
+    if (e->op == TOKdottd)
+    {
+	DotTemplateExp *dte = (DotTemplateExp *)e;
+	TemplateDeclaration *td = dte->td;
+	eleft = dte->e1;
+	ti->tempdecl = td;
+	ti->semantic(sc);
+	Dsymbol *s = ti->inst->toAlias();
+	Declaration *v = s->isDeclaration();
+	if (v)
+	{   e = new DotVarExp(loc, eleft, v);
+	    e = e->semantic(sc);
+	    return e;
+	}
+	e = new ScopeExp(loc, ti);
+	e = new DotExp(loc, eleft, e);
+	e = e->semantic(sc);
+	return e;
+    }
+    else if (e->op == TOKimport)
+    {   ScopeExp *se = (ScopeExp *)e;
+	TemplateDeclaration *td = se->sds->isTemplateDeclaration();
+	if (!td)
+	{   error("%s is not a template", e->toChars());
+	    return new ErrorExp();
+	}
+	ti->tempdecl = td;
+	e = new ScopeExp(loc, ti);
+	e = e->semantic(sc);
+	return e;
+    }
+    else if (e->op == TOKdotexp)
+    {	DotExp *de = (DotExp *)e;
+
+        if (de->e2->op == TOKimport)
+        {   // This should *really* be moved to ScopeExp::semantic()
+	    ScopeExp *se = (ScopeExp *)de->e2;
+	    de->e2 = new DsymbolExp(loc, se->sds);
+	    de->e2 = de->e2->semantic(sc);
+        }
+
+        if (de->e2->op == TOKtemplate)
+        {   TemplateExp *te = (TemplateExp *) de->e2;
+	    e = new DotTemplateExp(loc,de->e1,te->td);
+        }
+	goto L1;
+    }
+    error("%s isn't a template", e->toChars());
+    return new ErrorExp();
+#else
+    Dsymbol *s;
     Dsymbol *s2;
     TemplateDeclaration *td;
     Expression *e;
@@ -6011,6 +6070,7 @@
 
 Lerr:
     return new IntegerExp(loc, 0, Type::tint32);
+#endif
 }
 
 void DotTemplateInstanceExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)