annotate ast/Exp.d @ 83:9e90694f5da0 new_gen

Parse array indexing, and allow reading from arrays
author Anders Halager <halager@gmail.com>
date Fri, 02 May 2008 19:54:22 +0200
parents 110c7e1c4ca2
children 9375bd975730
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,
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
21 Index,
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
80
682e20aa224f Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
241 override DType type()
682e20aa224f Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
242 {
682e20aa224f Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
243 return exp.type().asPointer.pointerOf;
682e20aa224f Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
244 }
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
245
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
246 public Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
247 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
248
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
249 class IntegerLit : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
250 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
251 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
252 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
253 super(ExpType.IntegerLit);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
254 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
255 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
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
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
258 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
259 {
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
260 return name;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
261 }
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
262 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
263 {
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
264 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
265 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
266
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
267 override DType type() { return DType.Int; }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
268
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
269
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
270
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
271 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
272 char[] name;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
273 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
274
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
275 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
276 {
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(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
278 {
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
279 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
280 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
281 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
282 }
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
283 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
284 {
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
285 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
286 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
287 }
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
288
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
289 override DType type()
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 if (myType)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
292 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
293
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
294 DStruct st = cast(DStruct)target.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
295 assert(st, "Only structs have members");
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
296 if (auto t = st.typeOf(child.token.get))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
297 myType = t;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
298 // no error reporting here
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
299 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
300
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
301 return myType;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
302 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
303
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 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
305 Exp target;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
306 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
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
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
309 class IndexExp : 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
310 {
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
311 this(Exp target, Exp index)
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
312 {
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
313 super(ExpType.Index);
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
314 this.target = target;
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
315 this.index = index;
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
316 }
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
317
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
318 override DType type()
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
319 {
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
320 assert(target.type().isArray(), "Can only index arrays");
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
321 DArray array = target.type().asArray();
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
322 return array.arrayOf;
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
323 }
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
324
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
325 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
326 {
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
327 target = target.simplify;
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
328 index = index.simplify;
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
329 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
330 }
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
331
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
332 Exp target;
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
333 Exp index;
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
334 }
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
335
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
336 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
337 {
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 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
339 {
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 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
341 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
342 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
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
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 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
346 {
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 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
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
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 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
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 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
353 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
354 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
355 }
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
356
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
357 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
358 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
359 }
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
360
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
361 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
362 {
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 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
364 {
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 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
366 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
367 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
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 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
371 {
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 81
diff changeset
372 return pointerOf.type.getPointerTo();
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
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
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
375 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
376 }
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 72
diff changeset
377
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
378 class ArrayIdentifier : Identifier
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
379 {
81
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 80
diff changeset
380 this(Identifier arrayOf, IntegerLit size)
72
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 super(ExpType.ArrayIdentifier);
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
383 this.arrayOf = arrayOf;
81
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 80
diff changeset
384 this.size = Integer.parse(size.get);
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 80
diff changeset
385 this.name = arrayOf.name;
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
386 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
387
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
388 override DType type()
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
389 {
81
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 80
diff changeset
390 return arrayOf.type.getAsArray(size);
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
391 }
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 Identifier arrayOf;
81
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 80
diff changeset
394 int size;
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
395
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
396 private DType myType;
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
397 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
398
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
399 class Identifier : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
400 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
401 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
402 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
403 super(ExpType.Identifier);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
404 this.token = t;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
405 name = t.get;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
406 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
407
72
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
408 protected this(ExpType t)
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
409 {
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
410 super(t);
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
411 }
628cb46ab13b First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
412
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
413 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
414 {
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
415 if (myType !is null)
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
416 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
417 myType = env.find(this).type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
418 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
419 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
420
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
421 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
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 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
424 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
425 }
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
426
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
427 char[] get()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
428 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
429 return name;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
430 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
431
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
432 hash_t toHash()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
433 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
434 return jhash(name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
435 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
436
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
437 int opCmp(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
438 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
439 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
440 return typeid(char[]).compare(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
441 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
442 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
443
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
444 int opEquals(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
445 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
446 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
447 return typeid(char[]).equals(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
448 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
449 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
450
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
451 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
452 {
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
453 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
454 }
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
455
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
456 Token token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
457 char[] name;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
458 private DType myType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
459 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
460