comparison trunk/src/dil/semantic/Pass2.d @ 704:ff4643a4a97c

Wrote code for SemanticPass2.visit(MixinDeclaration).
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 28 Jan 2008 18:48:02 +0100
parents c67d2c3c0b3d
children efa5fcb9aa14
comparison
equal deleted inserted replaced
703:bf10602159c1 704:ff4643a4a97c
75 return super.visit(d); 75 return super.visit(d);
76 } 76 }
77 77
78 D visit(MixinDeclaration md) 78 D visit(MixinDeclaration md)
79 { 79 {
80 /+ 80 if (md.decls)
81 if (type) 81 return md.decls;
82 return this.expr; 82 if (md.isMixinExpression)
83 // TODO: 83 {
84 auto expr = this.expr.semantic(scop); 84 md.argument = visitE(md.argument);
85 expr = expr.evaluate(); 85 auto expr = Interpreter.interpret(md.argument, modul.infoMan, scop);
86 if (expr is null) 86 if (expr is Interpreter.NAR)
87 return this; 87 return md;
88 auto strExpr = TryCast!(StringExpression)(expr); 88 auto stringExpr = expr.Is!(StringExpression);
89 if (strExpr is null) 89 if (stringExpr is null)
90 error(scop, MSG.MixinArgumentMustBeString); 90 {
91 error(md.begin, MSG.MixinArgumentMustBeString);
92 return md;
93 }
94 else
95 { // Parse the declarations in the string.
96 auto loc = md.begin.getErrorLocation();
97 auto filePath = loc.filePath;
98 auto parser = new Parser(stringExpr.getString(), filePath, modul.infoMan);
99 md.decls = parser.start();
100 }
101 }
91 else 102 else
92 { 103 {
93 auto loc = this.begin.getErrorLocation(); 104 // TODO: implement template mixin.
94 auto filePath = loc.filePath; 105 }
95 auto parser = new_ExpressionParser(strExpr.getString(), filePath, scop.infoMan); 106 return md.decls;
96 expr = parser.parse();
97 expr = expr.semantic(scop);
98 }
99 this.expr = expr;
100 this.type = expr.type;
101 return expr;
102 +/
103 return md;
104 } 107 }
105 108
106 T visit(TypeofType t) 109 T visit(TypeofType t)
107 { 110 {
108 t.e = visitE(t.e); 111 t.e = visitE(t.e);
226 return e; 229 return e;
227 } 230 }
228 231
229 E visit(RealExpression e) 232 E visit(RealExpression e)
230 { 233 {
231 if (e.type) 234 if (!e.type)
232 e.type = Types.Double; 235 e.type = Types.Double;
233 return e; 236 return e;
234 } 237 }
235 238
236 E visit(ComplexExpression e) 239 E visit(ComplexExpression e)