Mercurial > projects > dang
annotate ast/Exp.d @ 172:01c2c49775ef
- Changed Parser to be more clean on type parsing.
- Parsing int function(int), and the like, types.(Function pointers)
- Fixed a design fault that made Symbol be wrong. Now Symbols are created with a factory with the help of types.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 24 Jul 2008 20:31:24 +0200 |
parents | 7982eb63c0eb |
children | dc9bf56b7ace |
rev | line source |
---|---|
1 | 1 module ast.Exp; |
2 | |
129 | 3 import tango.text.Util, |
4 Integer = tango.text.convert.Integer; | |
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
|
5 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
|
6 |
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 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
|
8 ast.Stmt; |
1 | 9 |
10 import lexer.Token; | |
11 | |
92
771ac63898e2
A few better parser errors plus renaming most of the sema classes to match that they do now. Some have changes a lot.
Anders Johnsen <skabet@gmail.com>
parents:
88
diff
changeset
|
12 import sema.Scope, |
129 | 13 sema.Symbol, |
58 | 14 sema.DType; |
1 | 15 |
119
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
16 import basic.LiteralParsing; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
17 |
1 | 18 enum ExpType |
19 { | |
20 Binary, | |
21 Negate, | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
22 Deref, |
1 | 23 IntegerLit, |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
48
diff
changeset
|
24 MemberReference, |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
25 Index, |
1 | 26 Identifier, |
27 AssignExp, | |
28 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
|
29 CastExp, |
104
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
30 StringExp, |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
31 NewExp, |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
32 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
33 IdentifierTypeExp, |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
34 ArrayTypeExp, |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
35 StaticArrayTypeExp, |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
36 PointerTypeExp, |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
37 FunctionTypeExp, |
1 | 38 } |
39 | |
107
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
98
diff
changeset
|
40 abstract class Exp |
1 | 41 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
42 this(ExpType expType, SLoc loc) |
1 | 43 { |
44 this.expType = expType; | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
45 this.loc = loc; |
1 | 46 } |
47 | |
129 | 48 /** |
49 Get the fully qualified name for the expression (if it can be resolved to | |
50 one) - otherwise null is returned | |
51 **/ | |
52 char[] getFQN() { return null; } | |
53 | |
54 /// The same as getFQN, except that the name is mangled | |
55 char[] getMangledFQN() { return null; } | |
56 | |
57 /** | |
58 Try to get the symbol the expression represents. | |
59 | |
60 Returns null for most expressions as they don't represent any symbol. | |
61 Identifiers and member references can have a sensible value. | |
62 **/ | |
63 Symbol getSymbol() { return null; } | |
64 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
65 /// Get the type of the expression |
110 | 66 abstract DType type(); |
58 | 67 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
68 /// Indicates which type the expression is - to avoid a lot of casts |
1 | 69 ExpType expType; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
70 |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
71 /// The environment of the expression |
1 | 72 Scope env; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
73 |
129 | 74 Symbol symbol; |
75 | |
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
|
76 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
|
77 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
78 /** |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
79 The "main" location of the expression. |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
80 What exactly this represents varies but for most things its the start |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
81 while for a binary expression its the operator. |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
82 **/ |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
83 SourceLocation loc; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
84 |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
85 /// Return the starting location of this expression |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
86 SourceLocation startLoc() { return loc; } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
87 |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
88 /// Get the full extents of the expression |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
89 SourceRange sourceRange() { return SourceRange(loc, loc + 1); } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
90 |
107
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
98
diff
changeset
|
91 /// Do some simplifications |
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
98
diff
changeset
|
92 Exp simplify() { return this; } |
1 | 93 } |
94 | |
95 class CallExp : Exp | |
96 { | |
97 this(Exp exp, Exp[] args) | |
98 { | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
99 super(ExpType.CallExp, exp.loc); |
1 | 100 this.exp = exp; |
101 this.args = args; | |
102 } | |
103 | |
58 | 104 override DType type() |
105 { | |
106 DFunction f = cast(DFunction)exp.type(); | |
59
1d6f4ad38a91
Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents:
58
diff
changeset
|
107 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
|
108 return f.returnType; |
58 | 109 } |
110 | |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
111 override CallExp simplify() |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
112 { |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
113 foreach (ref arg; args) |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
114 arg = arg.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
115 exp = exp.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
116 return this; |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
117 } |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
118 |
1 | 119 Exp exp; |
120 Exp[] args; | |
168
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
121 Symbol callSym; |
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 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
|
123 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
124 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
125 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
126 SourceRange res = exp.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
127 if (args.length > 0) |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
128 res = res + args[$ - 1].sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
129 return res; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
130 } |
1 | 131 } |
132 | |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
133 class AssignExp : BinaryExp |
1 | 134 { |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
135 this(SLoc op_loc, Operator op, Exp identifier, Exp exp) |
1 | 136 { |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
137 super(ExpType.AssignExp, op_loc, op, identifier, exp); |
1 | 138 this.identifier = identifier; |
139 this.exp = exp; | |
140 } | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
141 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
142 override AssignExp 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
|
143 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
144 identifier = identifier.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
145 exp = exp.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
|
146 |
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
|
147 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
|
148 } |
1 | 149 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
150 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
151 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
152 return identifier.sourceRange + exp.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
153 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
154 |
58 | 155 override DType type() { return identifier.type(); } |
156 | |
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
|
157 Exp identifier; |
1 | 158 Exp exp; |
159 } | |
160 | |
161 class BinaryExp : Exp | |
162 { | |
7
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
163 public enum Operator |
1 | 164 { |
48
b6c1dc30ca4b
Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents:
44
diff
changeset
|
165 Assign, |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
166 AddAssign, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
167 SubAssign, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
168 MulAssign, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
169 DivAssign, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
170 ModAssign, |
48
b6c1dc30ca4b
Only tests that dont pass now are structs and switches
Anders Halager <halager@gmail.com>
parents:
44
diff
changeset
|
171 |
7
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
172 Eq, Ne, |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
173 |
10
2f493057cf17
Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents:
7
diff
changeset
|
174 Lt, Le, |
2f493057cf17
Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents:
7
diff
changeset
|
175 Gt, Ge, |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
176 |
7
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
177 Add, Sub, |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
178 Mul, Div, Mod, |
123 | 179 |
180 LeftShift, RightShift, UnsignedRightShift, | |
125
d604152de1eb
Support shifts and binary logical operators in codegen
Anders Halager <halager@gmail.com>
parents:
123
diff
changeset
|
181 |
d604152de1eb
Support shifts and binary logical operators in codegen
Anders Halager <halager@gmail.com>
parents:
123
diff
changeset
|
182 And, Or, Xor, |
1 | 183 } |
184 | |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
185 char[][] getOp = ["=","+=","-=","*=","/=","%=","==","!=","<","<=",">",">=","+","-","*","/","%","<<",">>",">>>"]; |
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
|
186 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
187 this(SLoc op_loc, Operator op, Exp left, Exp right) |
1 | 188 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
189 super(ExpType.Binary, op_loc); |
1 | 190 this.op = op; |
191 this.left = left; | |
192 this.right = right; | |
193 } | |
194 | |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
195 protected this(ExpType e, SLoc op_loc, Operator op, Exp left, Exp right) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
196 { |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
197 super(e, op_loc); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
198 this.op = op; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
199 this.left = left; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
200 this.right = right; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
201 } |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
125
diff
changeset
|
202 |
58 | 203 override DType type() |
204 { | |
205 if (myType) | |
206 return myType; | |
207 | |
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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 { |
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
|
215 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
|
216 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
|
217 } |
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
|
218 |
58 | 219 DType l = left.type; |
220 DType r = right.type; | |
221 if (l is r) | |
222 myType = l; | |
223 else if (l.hasImplicitConversionTo(r)) | |
224 myType = r; | |
225 else if (r.hasImplicitConversionTo(l)) | |
226 myType = l; | |
227 else | |
228 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
|
229 return myType; |
58 | 230 } |
231 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
232 override SLoc startLoc() { return left.startLoc(); } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
233 |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
234 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
235 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
236 return left.sourceRange + right.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
237 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
238 |
7
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
239 char[] resultType() |
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
240 { |
10
2f493057cf17
Some support for the rest of the boolean operators
Anders Halager <halager@gmail.com>
parents:
7
diff
changeset
|
241 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
|
242 return "bool"; |
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
243 return null; |
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
244 } |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
245 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
246 override BinaryExp 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
|
247 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
248 left = left.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
249 right = right.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
|
250 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
|
251 } |
7
2ce5209f1954
Starting to work on bool support, for now == works
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
252 |
1 | 253 Operator op; |
254 Exp left, right; | |
58 | 255 private DType myType; |
1 | 256 } |
257 | |
258 class NegateExp : Exp | |
259 { | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
260 this(SLoc op, Exp exp) |
1 | 261 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
262 super(ExpType.Negate, op); |
1 | 263 this.exp = exp; |
264 } | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
265 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
266 override NegateExp simplify() |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
267 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
268 exp = exp.simplify(); |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
269 return this; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
270 } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
271 |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
272 override DType type() { return exp.type(); } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
273 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
274 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
275 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
276 return SourceRange(loc) + exp.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
277 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
278 |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
279 public Exp exp; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
280 } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
281 |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
282 class DerefExp : Exp |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
283 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
284 this(SLoc op, Exp exp) |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
285 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
286 super(ExpType.Deref, op); |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
287 this.exp = exp; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
288 } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
72
diff
changeset
|
289 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
290 override DerefExp 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
|
291 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
292 exp = exp.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
|
293 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
|
294 } |
1 | 295 |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
79
diff
changeset
|
296 override DType type() |
107
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
98
diff
changeset
|
297 { |
129 | 298 return exp.type().asPointer().pointerOf; |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
79
diff
changeset
|
299 } |
58 | 300 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
301 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
302 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
303 return SourceRange(loc) + exp.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
304 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
305 |
1 | 306 public Exp exp; |
307 } | |
308 | |
309 class IntegerLit : Exp | |
310 { | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
311 this(SLoc loc, char[] t) |
1 | 312 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
313 super(ExpType.IntegerLit, loc); |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
314 range = SourceRange(loc, loc + t.length); |
111
c658172ca8a0
Parsing basic integers and floats.
Anders Johnsen <skabet@gmail.com>
parents:
110
diff
changeset
|
315 this.name = 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
|
316 } |
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
|
317 |
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
|
318 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
|
319 { |
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
|
320 return name; |
1 | 321 } |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
322 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
323 override IntegerLit 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
|
324 { |
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 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
|
326 } |
1 | 327 |
119
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
328 override DType type() |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
329 { |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
330 switch(number.type) |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
331 { |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
332 case NumberType.Int: |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
333 return DType.Int; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
334 case NumberType.Long: |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
335 return DType.Long; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
336 case NumberType.ULong: |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
337 return DType.ULong; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
338 case NumberType.Double: |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
339 return DType.Double; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
340 case NumberType.Real: |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
341 return DType.Real; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
342 } |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
343 } |
58 | 344 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
345 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
346 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
347 return range; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
348 } |
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
|
349 |
119
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
350 Number number; |
c0b531362ca6
Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
351 |
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
|
352 char[] name; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
353 private SourceRange range; |
1 | 354 } |
355 | |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
48
diff
changeset
|
356 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
|
357 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
358 this(SLoc dot, Exp target, Identifier child) |
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
|
359 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
360 super(ExpType.MemberReference, dot); |
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
|
361 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
|
362 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
|
363 } |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
364 |
129 | 365 override char[] getFQN() |
366 { | |
367 return getSymbol().getFQN(); | |
368 } | |
369 | |
370 override char[] getMangledFQN() | |
371 { | |
372 return target.type.mangle() ~ child.getMangledFQN(); | |
373 } | |
374 | |
375 override Symbol getSymbol() | |
376 { | |
377 auto s = target.getSymbol(); | |
378 if (s !is null) | |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
379 return s.findMembers(child.get)[0]; |
129 | 380 return null; |
381 } | |
382 | |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
383 override MemberReference 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
|
384 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
385 target = target.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
|
386 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
|
387 } |
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
|
388 |
58 | 389 override DType type() |
390 { | |
391 if (myType) | |
392 return myType; | |
393 | |
162
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
394 if ( target.type.isStruct ) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
395 { |
168
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
396 Symbol st = target.getSymbol; |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
397 if (auto t = st.findMembers(child.name)) |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
398 myType = t[0].type; |
162
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
399 // else assert(0, "Referencing non-existant member"); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
400 } |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
401 else if ( target.type.isClass ) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
402 { |
168
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
403 Symbol cl = target.getSymbol; |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
404 if (auto t = cl.findMembers(child.name)) |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
405 myType = t[0].type; |
162
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
406 // else assert(0, "Referencing non-existant member"); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
407 } |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
408 else |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
409 assert(0, "Only structs and classes have members"); |
58 | 410 // no error reporting here |
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
|
411 |
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
|
412 return myType; |
58 | 413 } |
414 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
415 override SLoc startLoc() { return target.startLoc(); } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
416 |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
417 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
418 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
419 return target.sourceRange + child.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
420 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
421 |
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
|
422 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
|
423 Exp target; |
58 | 424 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
|
425 } |
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
|
426 |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
427 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
|
428 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
429 this(Exp target, SLoc left_bracket, Exp index, SLoc right_bracket) |
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
|
430 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
431 super(ExpType.Index, target.startLoc); |
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
|
432 this.target = target; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
433 this.left_bracket = left_bracket; |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
434 this.index = index; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
435 this.right_bracket = right_bracket; |
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
|
436 } |
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
|
437 |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
438 override DType type() |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
439 { |
85
9375bd975730
Allow indexing of pointers also
Anders Halager <halager@gmail.com>
parents:
83
diff
changeset
|
440 DType type = target.type(); |
136 | 441 if (type.isStaticArray()) |
442 return type.asStaticArray().arrayOf; | |
85
9375bd975730
Allow indexing of pointers also
Anders Halager <halager@gmail.com>
parents:
83
diff
changeset
|
443 else if (type.isPointer()) |
9375bd975730
Allow indexing of pointers also
Anders Halager <halager@gmail.com>
parents:
83
diff
changeset
|
444 return type.asPointer().pointerOf; |
9375bd975730
Allow indexing of pointers also
Anders Halager <halager@gmail.com>
parents:
83
diff
changeset
|
445 else assert(0, "Can only index pointers and arrays"); |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
446 } |
58 | 447 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
448 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
449 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
450 return target.sourceRange + SourceRange(right_bracket); |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
451 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
452 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
453 override IndexExp 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
|
454 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
455 target = target.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
456 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
|
457 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
|
458 } |
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
|
459 |
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
|
460 Exp target; |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
81
diff
changeset
|
461 Exp index; |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
462 SLoc left_bracket, right_bracket; |
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
|
463 } |
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
|
464 |
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
|
465 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
|
466 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
467 this(SLoc loc, Identifier castType, Exp exp) |
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
|
468 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
469 super(ExpType.CastExp, loc); |
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
|
470 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
|
471 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
|
472 } |
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
|
473 |
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
|
474 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
|
475 { |
145
a14ac9e5c858
Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents:
139
diff
changeset
|
476 return env.findType(this.castType.get); |
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
|
477 } |
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
|
478 |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
479 override CastExp simplify() |
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
|
480 { |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
481 castType = castType.simplify(); |
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
482 exp = exp.simplify(); |
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
|
483 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
|
484 } |
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
|
485 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
486 override SourceRange sourceRange() |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
487 { |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
488 return SourceRange(loc) + exp.sourceRange; |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
489 } |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
490 |
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
|
491 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
|
492 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
|
493 } |
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
|
494 |
104
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
495 class StringExp : Exp |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
496 { |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
497 this(SLoc loc, char[] str) |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
498 { |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
499 super(ExpType.StringExp, loc); |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
500 this.str = str; |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
501 } |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
502 |
160 | 503 override DType type() { return DType.Char.getAsStaticArray(data.length); } |
110 | 504 |
104
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
505 char[] str; |
160 | 506 ubyte[] data; |
104
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
507 } |
7ff4bc2accf2
Lexing more types of strings. Now all's left is to parse the string in the AST.
Anders Johnsen <skabet@gmail.com>
parents:
98
diff
changeset
|
508 |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
509 class NewExp : Exp |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
510 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
511 this(Identifier newType, Exp[] a_args, Exp[] c_args) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
512 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
513 super(ExpType.NewExp, newType.loc); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
514 this.newType = newType; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
515 this.a_args = a_args; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
516 this.c_args = c_args; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
517 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
518 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
519 override DType type() |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
520 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
521 return env.findType(this.newType.get); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
522 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
523 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
524 Exp[] a_args, c_args; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
525 Identifier newType; |
164
ba94fd563548
The symbol for the constructor a "new"-exp is calling is now stored in callSym in NewExp.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
526 Symbol callSym; |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
527 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
145
diff
changeset
|
528 |
1 | 529 class Identifier : Exp |
530 { | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
531 this(SLoc loc, char[] name) |
1 | 532 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
533 super(ExpType.Identifier, loc); |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
534 this.name = name; |
1 | 535 } |
536 | |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
537 protected this(ExpType t, SLoc loc) |
72
628cb46ab13b
First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
538 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
539 super(t, loc); |
72
628cb46ab13b
First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
540 } |
628cb46ab13b
First update on the way to Arrays! :)
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
541 |
129 | 542 override char[] getFQN() |
543 { | |
544 return name; | |
545 } | |
546 | |
547 override char[] getMangledFQN() | |
548 { | |
549 return Integer.toString(name.length) ~ name; | |
550 } | |
551 | |
552 override Symbol getSymbol() | |
553 { | |
145
a14ac9e5c858
Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents:
139
diff
changeset
|
554 if (auto decl = env.find(this.get)) |
168
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
555 if(decl.length) |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
556 return decl[$-1].sym; |
7982eb63c0eb
Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents:
164
diff
changeset
|
557 return null; |
129 | 558 } |
559 | |
58 | 560 override DType type() |
561 { | |
59
1d6f4ad38a91
Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents:
58
diff
changeset
|
562 if (myType !is null) |
58 | 563 return myType; |
129 | 564 else if (auto sym = getSymbol) |
565 myType = sym.type; | |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
111
diff
changeset
|
566 else |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
111
diff
changeset
|
567 myType = DType.Int; |
129 | 568 |
58 | 569 return myType; |
570 } | |
571 | |
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
|
572 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
|
573 { |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
86
diff
changeset
|
574 super(ExpType.Identifier, SLoc.Invalid); |
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
|
575 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
|
576 } |
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
|
577 |
1 | 578 char[] get() |
579 { | |
580 return name; | |
581 } | |
582 | |
583 hash_t toHash() | |
584 { | |
585 return jhash(name); | |
586 } | |
587 | |
588 int opCmp(Object o) | |
589 { | |
590 if (auto id = cast(Identifier)o) | |
591 return typeid(char[]).compare(&name, &id.name); | |
592 return 0; | |
593 } | |
594 | |
595 int opEquals(Object o) | |
596 { | |
597 if (auto id = cast(Identifier)o) | |
598 return typeid(char[]).equals(&name, &id.name); | |
599 return 0; | |
600 } | |
601 | |
139
a22e3663de89
Fixed up our simplify functions
Anders Halager <halager@gmail.com>
parents:
136
diff
changeset
|
602 override Identifier 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
|
603 { |
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
|
604 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
|
605 } |
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
|
606 |
93
621cedba53ea
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents:
92
diff
changeset
|
607 void setType(DType myType) |
621cedba53ea
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents:
92
diff
changeset
|
608 { |
621cedba53ea
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents:
92
diff
changeset
|
609 this.myType = myType; |
621cedba53ea
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents:
92
diff
changeset
|
610 } |
621cedba53ea
Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents:
92
diff
changeset
|
611 |
1 | 612 char[] name; |
58 | 613 private DType myType; |
1 | 614 } |
615 | |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
616 class IdentifierTypeExp : Identifier |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
617 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
618 this(SLoc loc, char[] name) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
619 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
620 super(ExpType.IdentifierTypeExp, loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
621 this.name = name; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
622 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
623 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
624 protected this(ExpType t, SLoc loc) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
625 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
626 super(t, loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
627 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
628 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
629 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
630 class PointerTypeExp : IdentifierTypeExp |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
631 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
632 this(IdentifierTypeExp pointerOf) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
633 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
634 super(ExpType.PointerTypeExp, pointerOf.loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
635 this.pointerOf = pointerOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
636 this.name = pointerOf.name; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
637 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
638 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
639 override DType type() |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
640 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
641 return pointerOf.type.getPointerTo(); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
642 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
643 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
644 Identifier pointerOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
645 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
646 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
647 class StaticArrayTypeExp : IdentifierTypeExp |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
648 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
649 this(IdentifierTypeExp arrayOf, IntegerLit size) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
650 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
651 super(ExpType.StaticArrayTypeExp, arrayOf.loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
652 this.arrayOf = arrayOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
653 this.size = Integer.parse(size.get); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
654 this.name = arrayOf.name; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
655 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
656 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
657 override DType type() |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
658 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
659 return arrayOf.type.getAsStaticArray(size); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
660 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
661 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
662 Identifier arrayOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
663 int size; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
664 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
665 private DType myType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
666 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
667 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
668 class ArrayTypeExp : IdentifierTypeExp |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
669 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
670 this(IdentifierTypeExp arrayOf) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
671 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
672 super(ExpType.ArrayTypeExp, arrayOf.loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
673 this.arrayOf = arrayOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
674 this.name = arrayOf.name; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
675 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
676 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
677 override DType type() |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
678 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
679 return arrayOf.type.getAsArray(); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
680 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
681 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
682 Identifier arrayOf; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
683 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
684 private DType myType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
685 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
686 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
687 class FunctionTypeExp : IdentifierTypeExp |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
688 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
689 this(IdentifierTypeExp returnType, VarDecl[] decls) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
690 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
691 super(ExpType.FunctionTypeExp, returnType.loc); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
692 this.returnType = returnType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
693 this.decls = decls; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
694 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
695 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
696 override DType type() |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
697 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
698 if (myType) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
699 return myType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
700 auto t = new DFunction(returnType); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
701 t.returnType = returnType.type; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
702 foreach (decl ; decls) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
703 t.params ~= decl.identifier.type; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
704 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
705 myType = t.getPointerTo; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
706 return myType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
707 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
708 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
709 VarDecl[] decls; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
710 IdentifierTypeExp returnType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
711 private DType myType; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
712 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
168
diff
changeset
|
713 |