annotate src/dil/semantic/Interpreter.d @ 835:451ede0105e0

Applied minor fixes and tidied some code up a bit.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 12 Aug 2008 02:59:11 +0200
parents 09a64d96967a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
1 /++
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
2 Author: Aziz Köksal
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
3 License: GPL3
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
4 +/
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
5 module dil.semantic.Interpreter;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
6
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
7 import dil.ast.Visitor;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
8 import dil.ast.Node,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
9 dil.ast.Declarations,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
10 dil.ast.Expressions,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
11 dil.ast.Statements,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
12 dil.ast.Types,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
13 dil.ast.Parameters;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
14
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
15 import dil.semantic.Symbol,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
16 dil.semantic.Symbols,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
17 dil.semantic.Scope,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
18 dil.semantic.Types;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
19 import dil.Information;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
20
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
21 /// Used for compile-time evaluation of expressions.
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
22 class Interpreter : Visitor
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
23 {
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
24 // Scope scop;
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
25 InfoManager infoMan;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
26
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
27 static class Result : Expression
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
28 {
791
5fe89bb8cbdd Implemented syntax tree copying.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 754
diff changeset
29 override Result copy(){return null;}
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
30 }
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
31
693
56100b270897 Renamed a constant in class Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 691
diff changeset
32 static const Result NAR; /// Not a Result. Similar to NAN in floating point arithmetics.
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
33
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
34 static this()
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
35 {
693
56100b270897 Renamed a constant in class Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 691
diff changeset
36 NAR = new Result;
56100b270897 Renamed a constant in class Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 691
diff changeset
37 NAR.type = Types.Error;
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
38 }
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
39
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
40 /// Evaluates the expression e.
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
41 /// Returns: NAR or a value.
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
42 static Expression interpret(Expression e, InfoManager infoMan/+, Scope scop+/)
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
43 {
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
44 return (new Interpreter(/+scop,+/ infoMan)).eval(e);
691
276e2866f5fd Added static interpret() method to Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
45 }
835
451ede0105e0 Applied minor fixes and tidied some code up a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 821
diff changeset
46
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
47 /// Executes the function at compile-time with the given arguments.
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
48 /// Returns: NAR or a value.
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
49 static Expression interpret(FunctionDeclaration fd, Expression[] args, InfoManager infoMan/+, Scope scop+/)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
50 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
51 return (new Interpreter(/+scop,+/ infoMan)).eval(fd, args);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
52 }
691
276e2866f5fd Added static interpret() method to Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
53
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
54 /// Constructs an Interpreter object.
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
55 this(/+Scope scop, +/InfoManager infoMan)
691
276e2866f5fd Added static interpret() method to Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
56 {
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
57 // this.scop = scop;
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
58 this.infoMan = infoMan;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
59 }
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
60
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
61 /// Start evaluation.
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
62 Expression eval(Expression e)
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
63 {
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
64 return e;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
65 }
835
451ede0105e0 Applied minor fixes and tidied some code up a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 821
diff changeset
66
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
67 /// Start evaluation of a function.
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
68 Expression eval(FunctionDeclaration fd, Expression[] args)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
69 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
70 // We cache this result so that we don't blindly try to reevaluate functions
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
71 // that can't be evaluated at compile time
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
72 if(fd.cantInterpret)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
73 return NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
74
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
75 // TODO: check for nested/method
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
76
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
77 // Check for invalid parameter types
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
78 if(fd.params.hasVariadic() || fd.params.hasLazy())
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
79 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
80 fd.cantInterpret = true;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
81 return NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
82 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
83
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
84 // remove me plx
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
85 assert(false);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
86 return NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
87 }
835
451ede0105e0 Applied minor fixes and tidied some code up a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 821
diff changeset
88
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
89 alias Expression E;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
90
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
91 override
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
92 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
93 E visit(CondExpression e)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
94 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
95 auto res = visitE(e.condition);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
96
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
97 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
98 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
99 if(isBool(res, true))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
100 res = visitE(e.lhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
101 else if(isBool(res, false))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
102 res = visitE(e.rhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
103 else
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
104 res = NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
105 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
106
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
107 return res;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
108 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
109
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
110 E visit(CommaExpression e)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
111 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
112 auto res = visitE(e.lhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
113
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
114 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
115 res = visitE(e.rhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
116
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
117 return res;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
118 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
119
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
120 E visit(OrOrExpression e)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
121 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
122 auto res = visitE(e.lhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
123
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
124 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
125 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
126 if(isBool(res, true))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
127 res = new IntExpression(1, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
128 else if(isBool(res, false))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
129 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
130 res = visitE(e.rhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
131
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
132 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
133 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
134 if(isBool(res, true))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
135 res = new IntExpression(1, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
136 else if(isBool(res, false))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
137 res = new IntExpression(0, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
138 else
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
139 res = NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
140 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
141 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
142 else
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
143 res = NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
144 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
145
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
146 return res;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
147 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
148
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
149 E visit(AndAndExpression e)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
150 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
151 auto res = visitE(e.lhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
152
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
153 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
154 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
155 if(isBool(res, false))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
156 res = new IntExpression(0, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
157 else if(isBool(res, true))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
158 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
159 res = visitE(e.rhs);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
160
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
161 if(res !is NAR)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
162 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
163 if(isBool(res, true))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
164 res = new IntExpression(1, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
165 else if(isBool(res, false))
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
166 res = new IntExpression(0, Types.Bool);
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
167 else
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
168 res = NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
169 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
170 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
171 else
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
172 res = NAR;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
173 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
174
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
175 return res;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
176 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
177
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
178
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
179
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
180 /*
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
181 "OrExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
182 "XorExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
183 "AndExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
184 "EqualExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
185 "IdentityExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
186 "RelExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
187 "InExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
188 "LShiftExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
189 "RShiftExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
190 "URShiftExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
191 "PlusExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
192 "MinusExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
193 "CatExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
194 "MulExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
195 "DivExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
196 "ModExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
197 "AddressExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
198 "DerefExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
199 "SignExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
200 "NotExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
201 "CompExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
202 "CallExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
203 "NewExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
204 "NewAnonClassExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
205 "DeleteExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
206 "CastExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
207 "IndexExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
208 "SliceExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
209 "ModuleScopeExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
210 "IdentifierExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
211 "SpecialTokenExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
212 "DotExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
213 "TemplateInstanceExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
214 "ThisExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
215 "SuperExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
216 "NullExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
217 "DollarExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
218 "BoolExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
219 "IntExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
220 "RealExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
221 "ComplexExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
222 "CharExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
223 "StringExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
224 "ArrayLiteralExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
225 "AArrayLiteralExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
226 "AssertExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
227 "MixinExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
228 "ImportExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
229 "TypeofExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
230 "TypeDotIdExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
231 "TypeidExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
232 "IsExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
233 "ParenExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
234 "FunctionLiteralExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
235 "TraitsExpression", // D2.0
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
236 "VoidInitExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
237 "ArrayInitExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
238 "StructInitExpression",
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
239 */
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
240 }
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
241
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 791
diff changeset
242 /// Returns true if e is immutable.
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
243 bool isImmutable(Expression e)
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
244 {
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
245 switch (e.kind)
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
246 {
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
247 alias NodeKind NK;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
248 case NK.IntExpression, NK.RealExpression,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
249 NK.ComplexExpression, NK.CharExpression,
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
250 NK.BoolExpression, NK.StringExpression,
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
251 NK.NullExpression:
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
252 return true;
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
253 default:
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
254 }
754
c7a5499faa77 Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 693
diff changeset
255 return false;
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
256 }
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
257
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
258 static bool isBool(Expression e, bool value)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
259 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
260 switch(e.kind)
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
261 {
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
262 alias NodeKind NK;
835
451ede0105e0 Applied minor fixes and tidied some code up a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 821
diff changeset
263
821
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
264 case NK.IntExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
265 auto num = (cast(IntExpression)e).number;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
266 return num ? value == true : value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
267
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
268 case NK.RealExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
269 auto num = (cast(RealExpression)e).number;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
270 return num ? value == true : value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
271
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
272 case NK.ComplexExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
273 auto num = (cast(RealExpression)e).number;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
274 return num ? value == true : value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
275
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
276 case NK.CharExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
277 auto num = (cast(CharExpression)e).value.number;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
278 return num ? value == true : value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
279
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
280 case NK.BoolExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
281 auto num = (cast(BoolExpression)e).value.number;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
282 return num ? value == true : value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
283
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
284 case NK.StringExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
285 return value == true;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
286
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
287 case NK.NullExpression:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
288 return value == false;
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
289
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
290 default:
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
291 }
09a64d96967a Started the interpreter. Made a couple changes in other parts -- CharExpression now has an IntExpression of a character type as its value member and its type is set accordingly.
Jarrett Billingsley <jarrett.billingsley@gmail.com>
parents: 806
diff changeset
292 }
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
293 }