Mercurial > projects > dil
comparison trunk/src/dil/semantic/Interpreter.d @ 798:c24be8d4f6ab
Added documentation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 02:53:06 +0100 |
parents | 5fe89bb8cbdd |
children |
comparison
equal
deleted
inserted
replaced
797:cf2ad5df025c | 798:c24be8d4f6ab |
---|---|
16 dil.semantic.Symbols, | 16 dil.semantic.Symbols, |
17 dil.semantic.Scope, | 17 dil.semantic.Scope, |
18 dil.semantic.Types; | 18 dil.semantic.Types; |
19 import dil.Information; | 19 import dil.Information; |
20 | 20 |
21 /// Used for compile-time evaluation of expressions. | |
21 class Interpreter : Visitor | 22 class Interpreter : Visitor |
22 { | 23 { |
23 Scope scop; | 24 // Scope scop; |
24 InfoManager infoMan; | 25 InfoManager infoMan; |
25 | 26 |
26 static class Result : Expression | 27 static class Result : Expression |
27 { | 28 { |
28 override Result copy(){return null;} | 29 override Result copy(){return null;} |
34 { | 35 { |
35 NAR = new Result; | 36 NAR = new Result; |
36 NAR.type = Types.Error; | 37 NAR.type = Types.Error; |
37 } | 38 } |
38 | 39 |
39 static Expression interpret(Expression e, InfoManager infoMan, Scope scop) | 40 /// Evaluates the expression e. |
41 /// Returns: NAR or a value. | |
42 static Expression interpret(Expression e, InfoManager infoMan/+, Scope scop+/) | |
40 { | 43 { |
41 return (new Interpreter(scop, infoMan)).start(e); | 44 return (new Interpreter(/+scop,+/ infoMan)).eval(e); |
42 } | 45 } |
43 | 46 |
44 this(Scope scop, InfoManager infoMan) | 47 /// Constructs an Interpreter object. |
48 this(/+Scope scop, +/InfoManager infoMan) | |
45 { | 49 { |
46 this.scop = scop; | 50 // this.scop = scop; |
47 this.infoMan = infoMan; | 51 this.infoMan = infoMan; |
48 } | 52 } |
49 | 53 |
50 /// Start interpretation. | 54 /// Start evaluation. |
51 Expression start(Expression e) | 55 Expression eval(Expression e) |
52 { | 56 { |
53 return e; | 57 return e; |
54 } | 58 } |
55 | 59 |
60 /// Returns true if e is immutable. | |
56 bool isImmutable(Expression e) | 61 bool isImmutable(Expression e) |
57 { | 62 { |
58 switch (e.kind) | 63 switch (e.kind) |
59 { | 64 { |
60 alias NodeKind NK; | 65 alias NodeKind NK; |