comparison trunk/src/dil/semantic/Pass2.d @ 708:3a4c7d444467

Added method interpret() to class SemanticPass2.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 29 Jan 2008 15:57:03 +0100
parents efa5fcb9aa14
children 4f971f6382c7
comparison
equal deleted inserted replaced
707:efa5fcb9aa14 708:3a4c7d444467
54 void exitScope() 54 void exitScope()
55 { 55 {
56 scop = scop.exit(); 56 scop = scop.exit();
57 } 57 }
58 58
59 Expression interpret(Expression e)
60 {
61 return Interpreter.interpret(e, modul.infoMan, scop);
62 }
63
59 void error(Token* token, char[] formatMsg, ...) 64 void error(Token* token, char[] formatMsg, ...)
60 { 65 {
61 auto location = token.getErrorLocation(); 66 auto location = token.getErrorLocation();
62 auto msg = Format(_arguments, _argptr, formatMsg); 67 auto msg = Format(_arguments, _argptr, formatMsg);
63 modul.infoMan ~= new SemanticError(location, msg); 68 modul.infoMan ~= new SemanticError(location, msg);
91 { 96 {
92 Expression finalValue; 97 Expression finalValue;
93 if (member.value) 98 if (member.value)
94 { 99 {
95 member.value = visitE(member.value); 100 member.value = visitE(member.value);
96 finalValue = Interpreter.interpret(member.value, modul.infoMan, scop); 101 finalValue = interpret(member.value);
97 if (finalValue is Interpreter.NAR) 102 if (finalValue is Interpreter.NAR)
98 continue; 103 continue;
99 } 104 }
100 //else 105 //else
101 // TODO: increment a number variable and assign that to value. 106 // TODO: increment a number variable and assign that to value.
110 if (md.decls) 115 if (md.decls)
111 return md.decls; 116 return md.decls;
112 if (md.isMixinExpression) 117 if (md.isMixinExpression)
113 { 118 {
114 md.argument = visitE(md.argument); 119 md.argument = visitE(md.argument);
115 auto expr = Interpreter.interpret(md.argument, modul.infoMan, scop); 120 auto expr = interpret(md.argument);
116 if (expr is Interpreter.NAR) 121 if (expr is Interpreter.NAR)
117 return md; 122 return md;
118 auto stringExpr = expr.Is!(StringExpression); 123 auto stringExpr = expr.Is!(StringExpression);
119 if (stringExpr is null) 124 if (stringExpr is null)
120 { 125 {
294 E visit(MixinExpression me) 299 E visit(MixinExpression me)
295 { 300 {
296 if (me.type) 301 if (me.type)
297 return me.expr; 302 return me.expr;
298 me.expr = visitE(me.expr); 303 me.expr = visitE(me.expr);
299 auto expr = Interpreter.interpret(me.expr, modul.infoMan, scop); 304 auto expr = interpret(me.expr);
300 if (expr is Interpreter.NAR) 305 if (expr is Interpreter.NAR)
301 return me; 306 return me;
302 auto stringExpr = expr.Is!(StringExpression); 307 auto stringExpr = expr.Is!(StringExpression);
303 if (stringExpr is null) 308 if (stringExpr is null)
304 error(me.begin, MSG.MixinArgumentMustBeString); 309 error(me.begin, MSG.MixinArgumentMustBeString);
318 E visit(ImportExpression ie) 323 E visit(ImportExpression ie)
319 { 324 {
320 if (ie.type) 325 if (ie.type)
321 return ie.expr; 326 return ie.expr;
322 ie.expr = visitE(ie.expr); 327 ie.expr = visitE(ie.expr);
323 auto expr = Interpreter.interpret(ie.expr, modul.infoMan, scop); 328 auto expr = interpret(ie.expr);
324 if (expr is Interpreter.NAR) 329 if (expr is Interpreter.NAR)
325 return ie; 330 return ie;
326 auto stringExpr = expr.Is!(StringExpression); 331 auto stringExpr = expr.Is!(StringExpression);
327 //if (stringExpr is null) 332 //if (stringExpr is null)
328 // error(me.begin, MSG.ImportArgumentMustBeString); 333 // error(me.begin, MSG.ImportArgumentMustBeString);