Mercurial > projects > dil
changeset 696:c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 24 Jan 2008 19:09:48 +0100 |
parents | 170ddcdc9711 |
children | b0732f766ba0 |
files | trunk/src/dil/ast/Declarations.d trunk/src/dil/ast/DefaultVisitor.d trunk/src/dil/semantic/Pass1.d trunk/src/dil/semantic/Pass2.d |
diffstat | 4 files changed, 28 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/dil/ast/Declarations.d Tue Jan 22 23:23:03 2008 +0100 +++ b/trunk/src/dil/ast/Declarations.d Thu Jan 24 19:09:48 2008 +0100 @@ -32,6 +32,11 @@ { addChildren(ds.children); } + + Declaration[] decls() + { + return cast(Declaration[])this.children; + } } /// Single semicolon.
--- a/trunk/src/dil/ast/DefaultVisitor.d Tue Jan 22 23:23:03 2008 +0100 +++ b/trunk/src/dil/ast/DefaultVisitor.d Thu Jan 24 19:09:48 2008 +0100 @@ -29,13 +29,12 @@ { alias T D; static if (is(D == CompoundDeclaration)) - foreach (node; d.children) - visitN(node); + foreach (decl; d.decls) + visitD(decl); //EmptyDeclaration, //IllegalDeclaration, //ModuleDeclaration have no subnodes. static if (is(D == AliasDeclaration) || - is(D == AliasDeclaration) || is(D == TypedefDeclaration)) visitD(d.decl); static if (is(D == EnumDeclaration))
--- a/trunk/src/dil/semantic/Pass1.d Tue Jan 22 23:23:03 2008 +0100 +++ b/trunk/src/dil/semantic/Pass1.d Thu Jan 24 19:09:48 2008 +0100 @@ -153,11 +153,8 @@ { D visit(CompoundDeclaration d) { - foreach (node; d.children) - { - assert(node.category == NodeCategory.Declaration, Format("{}", node)); - visitN(node); - } + foreach (decl; d.decls) + visitD(decl); return d; }
--- a/trunk/src/dil/semantic/Pass2.d Tue Jan 22 23:23:03 2008 +0100 +++ b/trunk/src/dil/semantic/Pass2.d Thu Jan 24 19:09:48 2008 +0100 @@ -17,7 +17,8 @@ dil.semantic.Types, dil.semantic.Scope, dil.semantic.Module, - dil.semantic.Analysis; + dil.semantic.Analysis, + dil.semantic.Interpreter; import dil.parser.Parser; import dil.Location; import dil.Information; @@ -261,9 +262,9 @@ { if (me.type) return me.expr; - auto expr = visitE(me.expr); - // TODO: expr = expr.evaluate(); - if (expr is null) + me.expr = visitE(me.expr); + auto expr = Interpreter.interpret(me.expr, modul.infoMan, scop); + if (expr is Interpreter.NAR) return me; auto stringExpr = expr.Is!(StringExpression); if (stringExpr is null) @@ -281,9 +282,20 @@ return me.expr; } - E visit(ImportExpression e) + E visit(ImportExpression ie) { - return e; + if (ie.type) + return ie.expr; + ie.expr = visitE(ie.expr); + auto expr = Interpreter.interpret(ie.expr, modul.infoMan, scop); + if (expr is Interpreter.NAR) + return ie; + auto stringExpr = expr.Is!(StringExpression); + //if (stringExpr is null) + // error(me.begin, MSG.ImportArgumentMustBeString); + // TODO: load file + //ie.expr = new StringExpression(loadImportFile(stringExpr.getString())); + return ie.expr; } } -} \ No newline at end of file +}