comparison 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
comparison
equal deleted inserted replaced
1608:679d101395e8 1609:1d0220dd613a
5893 (TemplateInstance *)ti->syntaxCopy(NULL)); 5893 (TemplateInstance *)ti->syntaxCopy(NULL));
5894 return de; 5894 return de;
5895 } 5895 }
5896 5896
5897 Expression *DotTemplateInstanceExp::semantic(Scope *sc) 5897 Expression *DotTemplateInstanceExp::semantic(Scope *sc)
5898 { Dsymbol *s; 5898 {
5899 #if 1
5900 #if LOGSEMANTIC
5901 printf("DotTemplateInstanceExp::semantic('%s')\n", toChars());
5902 #endif
5903 Expression *eleft;
5904 Expression *e = new DotIdExp(loc, e1, ti->name);
5905 L1:
5906 e = e->semantic(sc);
5907 if (e->op == TOKdottd)
5908 {
5909 DotTemplateExp *dte = (DotTemplateExp *)e;
5910 TemplateDeclaration *td = dte->td;
5911 eleft = dte->e1;
5912 ti->tempdecl = td;
5913 ti->semantic(sc);
5914 Dsymbol *s = ti->inst->toAlias();
5915 Declaration *v = s->isDeclaration();
5916 if (v)
5917 { e = new DotVarExp(loc, eleft, v);
5918 e = e->semantic(sc);
5919 return e;
5920 }
5921 e = new ScopeExp(loc, ti);
5922 e = new DotExp(loc, eleft, e);
5923 e = e->semantic(sc);
5924 return e;
5925 }
5926 else if (e->op == TOKimport)
5927 { ScopeExp *se = (ScopeExp *)e;
5928 TemplateDeclaration *td = se->sds->isTemplateDeclaration();
5929 if (!td)
5930 { error("%s is not a template", e->toChars());
5931 return new ErrorExp();
5932 }
5933 ti->tempdecl = td;
5934 e = new ScopeExp(loc, ti);
5935 e = e->semantic(sc);
5936 return e;
5937 }
5938 else if (e->op == TOKdotexp)
5939 { DotExp *de = (DotExp *)e;
5940
5941 if (de->e2->op == TOKimport)
5942 { // This should *really* be moved to ScopeExp::semantic()
5943 ScopeExp *se = (ScopeExp *)de->e2;
5944 de->e2 = new DsymbolExp(loc, se->sds);
5945 de->e2 = de->e2->semantic(sc);
5946 }
5947
5948 if (de->e2->op == TOKtemplate)
5949 { TemplateExp *te = (TemplateExp *) de->e2;
5950 e = new DotTemplateExp(loc,de->e1,te->td);
5951 }
5952 goto L1;
5953 }
5954 error("%s isn't a template", e->toChars());
5955 return new ErrorExp();
5956 #else
5957 Dsymbol *s;
5899 Dsymbol *s2; 5958 Dsymbol *s2;
5900 TemplateDeclaration *td; 5959 TemplateDeclaration *td;
5901 Expression *e; 5960 Expression *e;
5902 Identifier *id; 5961 Identifier *id;
5903 Type *t1; 5962 Type *t1;
6009 e = e->semantic(sc); 6068 e = e->semantic(sc);
6010 return e; 6069 return e;
6011 6070
6012 Lerr: 6071 Lerr:
6013 return new IntegerExp(loc, 0, Type::tint32); 6072 return new IntegerExp(loc, 0, Type::tint32);
6073 #endif
6014 } 6074 }
6015 6075
6016 void DotTemplateInstanceExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 6076 void DotTemplateInstanceExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
6017 { 6077 {
6018 expToCBuffer(buf, hgs, e1, PREC_primary); 6078 expToCBuffer(buf, hgs, e1, PREC_primary);