annotate ast/Exp.d @ 79:81813366ef92 new_gen

branch merge
author Anders Halager <halager@gmail.com>
date Fri, 02 May 2008 16:39:04 +0200
parents ad956143dcdc 13eea2c4e60d
children 682e20aa224f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
1 module ast.Exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
2
67
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
3 import tango.text.Util;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
4 import tango.io.Stdout;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
5
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
6 import ast.Decl,
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
7 ast.Stmt;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
8
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
9 import lexer.Token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
10
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
11 import sema.SymbolTable,
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
12 sema.DType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
13
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
14 enum ExpType
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
15 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
16 Binary,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
17 Negate,
78
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
18 Deref,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
19 IntegerLit,
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
20 MemberReference,
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
21 ArrayReference,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
22 Identifier,
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
23 ArrayIdentifier,
77
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
24 PointerIdentifier,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
25 AssignExp,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
26 CallExp,
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
27 CastExp,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
28 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
29
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
30 class Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
31 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
32 this(ExpType expType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
33 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
34 this.expType = expType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
35 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
36
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
37 DType type() { return null; }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
38
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
39 ExpType expType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
40 Scope env;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
41 int stmtIndex;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
42
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
43 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
44 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
45 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
46 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
47 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
48
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
49 class CallExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
50 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51 this(Exp exp, Exp[] args)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
53 super(ExpType.CallExp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
54 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
55 this.args = args;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
56 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
57
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
58 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
59 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
60 DFunction f = cast(DFunction)exp.type();
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
61 assert(f !is null, "Can only call functions");
63
9f8131676242 Now Decl's have a DType type(), and should use varType and returnType to get the old type id
Anders Halager <halager@gmail.com>
parents: 60
diff changeset
62 return f.returnType;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
63 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
64
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
65 Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
66 Exp[] args;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
67 bool sret = false;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
68
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
69
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
70 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
71 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
72 if(auto t = cast(DStruct)type)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
73 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
74 DFunction func_t = cast(DFunction)exp.type();
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
75 assert(func_t !is null, "Calling on something that isn't a function");
63
9f8131676242 Now Decl's have a DType type(), and should use varType and returnType to get the old type id
Anders Halager <halager@gmail.com>
parents: 60
diff changeset
76 if (cast(DStruct)func_t.returnType is null)
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
77 return this;
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
78
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
79 auto call = cast(Identifier)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
80 FuncDecl f = env.parentFunction;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
81 auto i = new Identifier("temp.var");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
82 i.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
83 f.env.add(i);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
84 f.env.find(i).type = t;
62
78a6808b2e0f Added support for "%" - modulus / reminder
Anders Johnsen <skabet@gmail.com>
parents: 60
diff changeset
85 auto ty = new Identifier(t.name);
78a6808b2e0f Added support for "%" - modulus / reminder
Anders Johnsen <skabet@gmail.com>
parents: 60
diff changeset
86 auto var = new VarDecl(ty, i, null);
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
87 Exp[] args;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
88 args ~= i;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
89 args ~= this.args;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
90 auto callExp = new CallExp(exp, args);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
91 callExp.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
92 var.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
93 auto stmtVar = new DeclStmt(var);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
94 auto stmtCall = new ExpStmt(callExp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
95 Stmt[] stmts;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
96 foreach( index, s ; f.statements)
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
97 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
98 if(stmtIndex == index)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
99 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
100 stmts ~= stmtVar;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
101 stmts ~= stmtCall;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
102 }
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
103 stmts ~= s;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
104 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
105 f.statements = stmts;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
106 callExp.sret = true;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
107
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
108 return i;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
109 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
110 return this;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
111 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
112 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
113
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
114 class AssignExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
115 {
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
116 this(Exp identifier, Exp exp)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
117 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
118 super(ExpType.AssignExp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
119 this.identifier = identifier;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
120 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
121 }
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
122 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
123 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
124 identifier = identifier.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
125 exp = exp.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
126
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
127 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
128 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
129
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
130 override DType type() { return identifier.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
131
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
132 Exp identifier;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
133 Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
134 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
135
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
136 class BinaryExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
137 {
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
138 public enum Operator
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
139 {
48
b6c1dc30ca4b Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
140 Assign,
b6c1dc30ca4b Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
141
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
142 Eq, Ne,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
143
10
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
144 Lt, Le,
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
145 Gt, Ge,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
146
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
147 Add, Sub,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
148 Mul, Div, Mod,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
149 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
150
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
151 char[][] getOp = ["=","==","!=","<","<=",">",">=","+","-","*","/","%"];
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
152
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
153 this(Operator op, Exp left, Exp right)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
154 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
155 super(ExpType.Binary);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
156 this.op = op;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
157 this.left = left;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
158 this.right = right;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
159 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
160
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
161 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
162 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
163 if (myType)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
164 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
165
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
166 if (op == Operator.Eq ||
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
167 op == Operator.Ne ||
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
168 op == Operator.Lt ||
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
169 op == Operator.Le ||
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
170 op == Operator.Gt ||
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
171 op == Operator.Ge)
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
172 {
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
173 myType = DType.Bool;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
174 return myType;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
175 }
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
176
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
177 DType l = left.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
178 DType r = right.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
179 if (l is r)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
180 myType = l;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
181 else if (l.hasImplicitConversionTo(r))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
182 myType = r;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
183 else if (r.hasImplicitConversionTo(l))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
184 myType = l;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
185 else
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
186 return null;
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
187 return myType;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
188 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
189
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
190 char[] resultType()
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
191 {
10
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
192 if (op >= Operator.Eq && op <= Operator.Ge)
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
193 return "bool";
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
194 return null;
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
195 }
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
196 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
197 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
198 left = left.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
199 right = right.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
200 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
201 }
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
202
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
203 Operator op;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
204 Exp left, right;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
205 private DType myType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
206 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
207
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
208 class NegateExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
209 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
210 this(Exp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
211 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
212 super(ExpType.Negate);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
213 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
214 }
78
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
215
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
216 Exp simplify()
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
217 {
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
218 exp = exp.simplify;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
219 return this;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
220 }
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
221
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
222 override DType type() { return exp.type(); }
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
223
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
224 public Exp exp;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
225 }
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
226
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
227 class DerefExp : Exp
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
228 {
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
229 this(Exp exp)
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
230 {
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
231 super(ExpType.Deref);
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
232 this.exp = exp;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
233 }
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 72
diff changeset
234
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
235 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
236 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
237 exp = exp.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
238 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
239 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
240
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
241 override DType type() { return exp.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
242
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
243 public Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
244 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
245
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
246 class IntegerLit : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
247 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
248 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
249 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
250 super(ExpType.IntegerLit);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
251 this.token = t;
67
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
252 this.name = substitute(t.get,"_","");
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
253 }
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
254
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
255 char[] get()
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
256 {
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
257 return name;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
258 }
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
259 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
260 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
261 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
262 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
263
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
264 override DType type() { return DType.Int; }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
265
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
266
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
267
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
268 Token token;
67
3fdf20b08a81 Been working on the floating point parsing. Still a bit of work to do here.
Anders Johnsen <skabet@gmail.com>
parents: 65
diff changeset
269 char[] name;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
270 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
271
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
272 class MemberReference : Exp
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
273 {
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
274 this(Exp target, Identifier child)
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
275 {
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
276 super(ExpType.MemberReference);
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
277 this.target = target;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
278 this.child = child;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
279 }
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
280 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
281 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
282 target = target.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
283 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
284 }
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
285
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
286 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
287 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
288 if (myType)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
289 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
290
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
291 DStruct st = cast(DStruct)target.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
292 assert(st, "Only structs have members");
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
293 if (auto t = st.typeOf(child.token.get))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
294 myType = t;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
295 // no error reporting here
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
296 else assert(0, "Referencing non-existant member");
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
297
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
298 return myType;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
299 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
300
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
301 Identifier child;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
302 Exp target;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
303 private DType myType;
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
304 }
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
305
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
306 class ArrayReference : Exp
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
307 {
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
308 this(Exp target, IntegerLit pos)
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
309 {
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
310 super(ExpType.ArrayReference);
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
311 this.target = target;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
312 this.pos = pos;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
313 }
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
314
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
315 override DType type() { return target.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
316
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
317 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
318 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
319 target = target.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
320 pos.simplify;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
321 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
322 }
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
323
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
324 Exp target;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
325 IntegerLit pos;
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
326 }
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 10
diff changeset
327
68
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
328 class CastExp : Exp
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
329 {
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
330 this(Identifier castType, Exp exp)
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
331 {
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
332 super(ExpType.CastExp);
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
333 this.castType = castType;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
334 this.exp = exp;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
335 }
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
336
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
337 override DType type()
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
338 {
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
339 return env.findType(this.castType);
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
340 }
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
341
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
342 Exp simplify()
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
343 {
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
344 castType.simplify;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
345 exp.simplify;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
346 return this;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
347 }
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
348
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
349 Identifier castType;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
350 Exp exp;
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
351 }
381975d76baf A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents: 67
diff changeset
352
77
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
353 class PointerIdentifier : Identifier
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
354 {
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
355 this(Identifier pointerOf)
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
356 {
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
357 super(ExpType.PointerIdentifier);
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
358 this.pointerOf = pointerOf;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
359 this.name = pointerOf.name;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
360 }
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
361
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
362 override DType type()
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
363 {
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
364 if (myType !is null)
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
365 return myType;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
366 myType = new DPointer(pointerOf.type);
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
367 return myType;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
368 }
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
369
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
370 Identifier pointerOf;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
371
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
372 private DType myType;
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
373 }
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
374
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
375 class ArrayIdentifier : Identifier
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
376 {
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
377 this(Identifier arrayOf)
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
378 {
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
379 super(ExpType.ArrayIdentifier);
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
380 this.arrayOf = arrayOf;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
381 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
382
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
383 override DType type()
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
384 {
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
385 if (myType !is null)
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
386 return myType;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
387 myType = new DArray(arrayOf.type);
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
388 return myType;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
389 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
390
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
391 Identifier arrayOf;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
392
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
393 private DType myType;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
394 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
395
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
396 class Identifier : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
397 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
398 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
399 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
400 super(ExpType.Identifier);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
401 this.token = t;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
402 name = t.get;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
403 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
404
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
405 protected this(ExpType t)
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
406 {
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
407 super(t);
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
408 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
409
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
410 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
411 {
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
412 if (myType !is null)
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
413 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
414 myType = env.find(this).type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
415 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
416 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
417
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
418 this(char[] name)
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
419 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
420 super(ExpType.Identifier);
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
421 this.name = name;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
422 }
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
423
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
424 char[] get()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
425 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
426 return name;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
427 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
428
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
429 hash_t toHash()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
430 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
431 return jhash(name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
432 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
433
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
434 int opCmp(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
435 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
436 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
437 return typeid(char[]).compare(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
438 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
439 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
440
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
441 int opEquals(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
442 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
443 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
444 return typeid(char[]).equals(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
445 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
446 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
447
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
448 Exp simplify()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
449 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
450 return this;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
451 }
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 55
diff changeset
452
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
453 Token token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
454 char[] name;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
455 private DType myType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
456 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
457