annotate ast/Exp.d @ 60:2451f0904bf6 new_gen

Dumping Ast with AstPrinter is now possible again! :)
author Anders Johnsen <skabet@gmail.com>
date Tue, 29 Apr 2008 15:00:11 +0200
parents 1d6f4ad38a91
children 78a6808b2e0f 9f8131676242
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
3 import tango.text.Util : jhash;
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,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
18 IntegerLit,
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
19 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
20 ArrayLookup,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
21 Identifier,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
22 AssignExp,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
23 CallExp,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
24 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
25
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
26 class Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
27 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
28 this(ExpType expType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
29 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
30 this.expType = expType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
31 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
32
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
33 DType type() { return null; }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
34
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
35 ExpType expType;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
36 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
37 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
38
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
39 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
40 {
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 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
42 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
43 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
44
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
45 class CallExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
46 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
47 this(Exp exp, Exp[] args)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
48 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
49 super(ExpType.CallExp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
50 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51 this.args = args;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
53
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
54 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
55 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
56 DFunction f = cast(DFunction)exp.type();
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
57 assert(f !is null, "Can only call functions");
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
58 return f.return_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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
61 Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
62 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
63 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
64
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
65
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
66 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
67 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
68 if(auto t = cast(DStruct)type)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
69 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
70 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
71 assert(func_t !is null, "Calling on something that isn't a function");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
72 if (cast(DStruct)func_t.return_type is null)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
73 return this;
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
74
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
75 auto call = cast(Identifier)exp;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
76 FuncDecl f = env.parentFunction;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
77 auto i = new Identifier("temp.var");
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
78 i.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
79 f.env.add(i);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
80 f.env.find(i).type = t;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
81 auto var = new VarDecl(new Identifier(t.name), i, null);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
82 Exp[] args;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
83 args ~= i;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
84 args ~= this.args;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
85 auto callExp = new CallExp(exp, args);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
86 callExp.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
87 // auto ass = new AssignExp(i, callExp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
88 var.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
89 // ass.env = f.env;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
90 auto stmtVar = new DeclStmt(var);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
91 auto stmtCall = new ExpStmt(callExp);
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
92 Stmt[] stmts;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
93 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
94 {
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
95 if(stmtIndex == index)
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
96 {
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
97 stmts ~= stmtVar;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
98 stmts ~= stmtCall;
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 ~= 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
101 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
102 f.statements = stmts;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
103 callExp.sret = true;
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
104
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
105 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
106 }
60
2451f0904bf6 Dumping Ast with AstPrinter is now possible again! :)
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
107 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
108 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
109 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
110
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
111 class AssignExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
112 {
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
113 this(Exp identifier, Exp exp)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
114 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
115 super(ExpType.AssignExp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
116 this.identifier = identifier;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
117 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
118 }
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
119 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
120 {
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
121 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
122 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
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 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
125 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
126
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
127 override DType type() { return identifier.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
128
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
129 Exp identifier;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
130 Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
131 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
132
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
133 class BinaryExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
134 {
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
135 public enum Operator
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
136 {
48
b6c1dc30ca4b Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
137 Assign,
b6c1dc30ca4b Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
138
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
139 Eq, Ne,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
140
10
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
141 Lt, Le,
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
142 Gt, Ge,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
143
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
144 Add, Sub,
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
145 Mul, Div, Mod,
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
146 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
147
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
148 this(Operator op, Exp left, Exp right)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
149 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
150 super(ExpType.Binary);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
151 this.op = op;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
152 this.left = left;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
153 this.right = right;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
154 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
155
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
156 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
157 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
158 if (myType)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
159 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
160
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
161 DType l = left.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
162 DType r = right.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
163 if (l is r)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
164 myType = l;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
165 else if (l.hasImplicitConversionTo(r))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
166 myType = r;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
167 else if (r.hasImplicitConversionTo(l))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
168 myType = l;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
169 else
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
170 return null;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
171 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
172
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
173 char[] resultType()
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
174 {
10
2f493057cf17 Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents: 7
diff changeset
175 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
176 return "bool";
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
177 return null;
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
178 }
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
179 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
180 {
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
181 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
182 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
183 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
184 }
7
2ce5209f1954 Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
185
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
186 Operator op;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
187 Exp left, right;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
188 private DType myType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
189 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
190
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
191 class NegateExp : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
192 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
193 this(Exp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
194 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
195 super(ExpType.Negate);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
196 this.exp = exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
197 }
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
198 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
199 {
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 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
201 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
202 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
203
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
204 override DType type() { return exp.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
205
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
206 public Exp exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
207 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
208
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
209 class IntegerLit : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
210 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
211 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
212 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
213 super(ExpType.IntegerLit);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
214 this.token = t;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
215 }
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
216 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
217 {
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
218 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
219 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
220
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
221 override DType type() { return DType.Int; }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
222
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
223 Token token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
224 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
225
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
226 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
227 {
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
228 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
229 {
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 48
diff changeset
230 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
231 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
232 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
233 }
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
234 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
235 {
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 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
237 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
238 }
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
239
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
240 override DType type()
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
241 {
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
242 if (myType)
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
243 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
244
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
245 DStruct st = cast(DStruct)target.type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
246 assert(st, "Only structs have members");
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
247 if (auto t = st.typeOf(child.token.get))
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
248 myType = t;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
249 // no error reporting here
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
250 else assert(0, "Referencing non-existant member");
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
251 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
252
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
253 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
254 Exp target;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
255 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
256 }
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
257
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
258 class ArrayLookup : Exp
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
259 {
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
260 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
261 {
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
262 super(ExpType.ArrayLookup);
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
263 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
264 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
265 }
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
266
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
267 override DType type() { return target.type(); }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
268
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
269 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
270 {
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
271 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
272 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
273 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
274 }
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
275
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 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
277 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
278 }
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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
280 class Identifier : Exp
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
281 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
282 this(Token t)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
283 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
284 super(ExpType.Identifier);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
285 this.token = t;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
286 name = t.get;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
287 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
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 {
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 58
diff changeset
291 if (myType !is null)
58
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 myType = env.find(this).type;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
294 return myType;
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
295 }
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
296
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
297 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
298 {
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
299 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
300 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
301 }
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
302
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
303 char[] get()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
304 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
305 return name;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
306 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
307
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
308 hash_t toHash()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
309 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
310 return jhash(name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
311 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
312
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
313 int opCmp(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
314 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
315 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
316 return typeid(char[]).compare(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
317 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
318 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
319
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
320 int opEquals(Object o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
321 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
322 if (auto id = cast(Identifier)o)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
323 return typeid(char[]).equals(&name, &id.name);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
324 return 0;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
325 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
326
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
327 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
328 {
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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
332 Token token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
333 char[] name;
58
fc62c5296a1c Add types to our Exp
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
334 private DType myType;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
335 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
336