Mercurial > projects > dang
annotate sema/Visitor.d @ 176:dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 24 Jul 2008 23:03:18 +0200 |
parents | 01c2c49775ef |
children | 7b274cfdc1dc |
rev | line source |
---|---|
1 | 1 module sema.Visitor; |
2 | |
3 import tango.io.Stdout; | |
4 | |
5 public | |
94
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
6 import ast.Module, |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
7 ast.Decl, |
1 | 8 ast.Stmt, |
9 ast.Exp; | |
10 | |
11 import lexer.Token; | |
12 | |
94
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
13 class Visitor(FinalT = int, ModuleT = FinalT, DeclT = ModuleT, StmtT = DeclT, ExpT = StmtT) |
1 | 14 { |
15 public: | |
101
fea8d61a2451
First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents:
99
diff
changeset
|
16 FinalT visit(Module[] modules) |
1 | 17 { |
101
fea8d61a2451
First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents:
99
diff
changeset
|
18 foreach(m ; modules) |
fea8d61a2451
First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents:
99
diff
changeset
|
19 visitModule(m); |
1 | 20 static if (is(FinalT == void)) |
21 return; | |
22 else | |
23 return FinalT.init; | |
24 } | |
25 | |
94
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
26 ModuleT visitModule(Module m) |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
27 { |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
28 foreach (decl; m.decls) |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
29 visitDecl(decl); |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
30 static if (is(ModuleT == void)) |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
31 return; |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
32 else |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
33 return ModuleT.init; |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
34 } |
48bb2287c035
Added Modules. Right now it's very simple - will grow with time and need.
Anders Johnsen <skabet@gmail.com>
parents:
83
diff
changeset
|
35 |
1 | 36 DeclT visitDecl(Decl decl) |
37 { | |
38 switch(decl.declType) | |
39 { | |
40 case DeclType.FuncDecl: | |
41 return visitFuncDecl(cast(FuncDecl)decl); | |
42 case DeclType.VarDecl: | |
43 return visitVarDecl(cast(VarDecl)decl); | |
99
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
44 case DeclType.ImportDecl: |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
45 return visitImportDecl(cast(ImportDecl)decl); |
22 | 46 case DeclType.StructDecl: |
47 return visitStructDecl(cast(StructDecl)decl); | |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
48 case DeclType.ClassDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
49 return visitClassDecl(cast(ClassDecl)decl); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
50 case DeclType.InterfaceDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
51 return visitInterfaceDecl(cast(InterfaceDecl)decl); |
1 | 52 default: |
53 throw new Exception("Unknown declaration type"); | |
54 } | |
55 } | |
56 | |
57 StmtT visitStmt(Stmt stmt) | |
58 { | |
59 switch(stmt.stmtType) | |
60 { | |
61 case StmtType.Return: | |
62 return visitReturnStmt(cast(ReturnStmt)stmt); | |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
63 case StmtType.Compound: |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
64 return visitCompoundStmt(cast(CompoundStatement)stmt); |
1 | 65 case StmtType.Decl: |
66 return visitDeclStmt(cast(DeclStmt)stmt); | |
67 case StmtType.Exp: | |
68 return visitExpStmt(cast(ExpStmt)stmt); | |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
69 case StmtType.If: |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
70 return visitIfStmt(cast(IfStmt)stmt); |
11
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
71 case StmtType.While: |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
72 return visitWhileStmt(cast(WhileStmt)stmt); |
149
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
73 case StmtType.For: |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
74 return visitForStmt(cast(ForStmt)stmt); |
36
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
75 case StmtType.Switch: |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
76 return visitSwitchStmt(cast(SwitchStmt)stmt); |
1 | 77 default: |
78 throw new Exception("Unknown statement type"); | |
79 } | |
80 } | |
81 | |
82 ExpT visitExp(Exp exp) | |
83 { | |
84 switch(exp.expType) | |
85 { | |
86 case ExpType.Binary: | |
87 return visitBinaryExp(cast(BinaryExp)exp); | |
88 case ExpType.IntegerLit: | |
89 return visitIntegerLit(cast(IntegerLit)exp); | |
90 case ExpType.Negate: | |
91 return visitNegateExp(cast(NegateExp)exp); | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
92 case ExpType.Deref: |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
93 return visitDerefExp(cast(DerefExp)exp); |
176
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
94 case ExpType.AddressOfExp: |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
95 return visitAddressOfExp(cast(AddressOfExp)exp); |
1 | 96 case ExpType.AssignExp: |
97 return visitAssignExp(cast(AssignExp)exp); | |
98 case ExpType.CallExp: | |
99 return visitCallExp(cast(CallExp)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:
63
diff
changeset
|
100 case ExpType.CastExp: |
381975d76baf
A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents:
63
diff
changeset
|
101 return visitCastExp(cast(CastExp)exp); |
1 | 102 case ExpType.Identifier: |
103 return visitIdentifier(cast(Identifier)exp); | |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
104 case ExpType.IdentifierTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
105 return visitIdentifier(cast(Identifier)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
106 case ExpType.PointerTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
107 return visitPointerTypeExp(cast(PointerTypeExp)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
108 case ExpType.StaticArrayTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
109 return visitStaticArrayTypeExp(cast(StaticArrayTypeExp)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
110 case ExpType.FunctionTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
111 return visitFunctionTypeExp(cast(FunctionTypeExp)exp); |
106
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
112 case ExpType.StringExp: |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
113 return visitStringExp(cast(StringExp)exp); |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
114 case ExpType.Index: |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
115 return visitIndexExp(cast(IndexExp)exp); |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
116 case ExpType.MemberReference: |
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
117 return visitMemberReference(cast(MemberReference)exp); |
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:
149
diff
changeset
|
118 case ExpType.NewExp: |
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:
149
diff
changeset
|
119 return visitNewExp(cast(NewExp)exp); |
1 | 120 default: |
121 throw new Exception("Unknown expression type"); | |
122 } | |
123 } | |
124 | |
125 // Declarations: | |
126 DeclT visitVarDecl(VarDecl d) | |
127 { | |
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:
55
diff
changeset
|
128 visitExp(d.varType); |
82
06dda301ea61
Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents:
81
diff
changeset
|
129 if(d.identifier) |
06dda301ea61
Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents:
81
diff
changeset
|
130 visitExp(d.identifier); |
1 | 131 if (d.init) |
132 visitExp(d.init); | |
133 | |
134 static if (is(DeclT == void)) | |
135 return; | |
136 else | |
137 return DeclT.init; | |
138 } | |
139 | |
99
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
140 DeclT visitImportDecl(ImportDecl d) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
141 { |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
142 visitIdentifier(d.name); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
143 visitIdentifier(d.aliasedName); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
144 foreach (id; d.packages) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
145 visitIdentifier(id); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
146 foreach (ids; d.explicitSymbols) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
147 { |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
148 visitIdentifier(ids[0]); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
149 visitIdentifier(ids[1]); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
150 } |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
151 |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
152 static if (is(DeclT == void)) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
153 return; |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
154 else |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
155 return DeclT.init; |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
156 } |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
157 |
1 | 158 DeclT visitFuncDecl(FuncDecl f) |
159 { | |
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:
55
diff
changeset
|
160 visitExp(f.returnType); |
1 | 161 visitExp(f.identifier); |
162 foreach (arg; f.funcArgs) | |
163 visitDecl(arg); | |
164 foreach (stmt; f.statements) | |
165 visitStmt(stmt); | |
166 | |
167 static if (is(DeclT == void)) | |
168 return; | |
169 else | |
170 return DeclT.init; | |
171 } | |
172 | |
22 | 173 DeclT visitStructDecl(StructDecl s) |
174 { | |
175 visitExp(s.identifier); | |
176 | |
102
cd066f3b539a
Parsing methods in structs - error on semantics though.
Anders Johnsen <skabet@gmail.com>
parents:
101
diff
changeset
|
177 foreach (arg; s.decls) |
22 | 178 visitDecl(arg); |
179 | |
180 static if (is(DeclT == void)) | |
181 return; | |
182 else | |
183 return DeclT.init; | |
184 } | |
185 | |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
186 DeclT visitClassDecl(ClassDecl s) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
187 { |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
188 visitExp(s.identifier); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
189 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
190 foreach (arg; s.decls) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
191 visitDecl(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
192 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
193 foreach (arg; s.baseClasses) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
194 visitExp(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
195 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
196 static if (is(DeclT == void)) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
197 return; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
198 else |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
199 return DeclT.init; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
200 } |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
201 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
202 DeclT visitInterfaceDecl(InterfaceDecl s) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
203 { |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
204 visitExp(s.identifier); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
205 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
206 foreach (arg; s.decls) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
207 visitDecl(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
208 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
209 foreach (arg; s.baseClasses) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
210 visitExp(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
211 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
212 static if (is(DeclT == void)) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
213 return; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
214 else |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
215 return DeclT.init; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
216 } |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
217 |
1 | 218 // Statements: |
219 StmtT visitReturnStmt(ReturnStmt s) | |
220 { | |
37 | 221 if (s.exp) |
222 visitExp(s.exp); | |
1 | 223 static if (is(StmtT == void)) |
224 return; | |
225 else | |
226 return StmtT.init; | |
227 } | |
228 | |
229 StmtT visitDeclStmt(DeclStmt d) | |
230 { | |
231 visitDecl(d.decl); | |
232 static if (is(StmtT == void)) | |
233 return; | |
234 else | |
235 return StmtT.init; | |
236 } | |
237 | |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
238 StmtT visitCompoundStmt(CompoundStatement c) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
239 { |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
240 foreach (stmt; c.statements) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
241 visitStmt(stmt); |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
242 static if (is(StmtT == void)) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
243 return; |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
244 else |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
245 return StmtT.init; |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
246 } |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
247 |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
248 StmtT visitIfStmt(IfStmt s) |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
249 { |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
250 visitExp(s.cond); |
45 | 251 visitStmt(s.then_body); |
252 if (s.else_body !is null) | |
253 visitStmt(s.else_body); | |
11
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
254 static if (is(StmtT == void)) |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
255 return; |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
256 else |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
257 return StmtT.init; |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
258 } |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
259 |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
260 StmtT visitWhileStmt(WhileStmt s) |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
261 { |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
262 visitExp(s.cond); |
46 | 263 visitStmt(s.whileBody); |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
264 static if (is(StmtT == void)) |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
265 return; |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
266 else |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
267 return StmtT.init; |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
268 } |
149
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
269 |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
270 StmtT visitForStmt(ForStmt s) |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
271 { |
162
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
272 if(s.init) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
273 visitStmt(s.init); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
274 if(s.cond) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
275 visitExp(s.cond); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
276 if(s.incre) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
277 visitExp(s.incre); |
149
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
278 visitStmt(s.forBody); |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
279 static if (is(StmtT == void)) |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
280 return; |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
281 else |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
282 return StmtT.init; |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
283 } |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
284 |
36
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
285 StmtT visitSwitchStmt(SwitchStmt s) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
286 { |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
287 visitExp(s.cond); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
288 foreach(stmt; s.defaultBlock) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
289 visitStmt(stmt); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
290 foreach (c; s.cases) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
291 { |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
292 foreach(lit; c.values) |
143
d76cc5cad4fc
Added partial support for switches.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
293 visitExp(lit); |
36
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
294 foreach(stmt; c.stmts) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
295 visitStmt(stmt); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
296 } |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
297 static if (is(StmtT == void)) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
298 return; |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
299 else |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
300 return StmtT.init; |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
301 } |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
302 |
1 | 303 StmtT visitExpStmt(ExpStmt s) |
304 { | |
305 visitExp(s.exp); | |
306 static if (is(StmtT == void)) | |
307 return; | |
308 else | |
309 return StmtT.init; | |
310 } | |
311 | |
312 // Expressions: | |
313 ExpT visitAssignExp(AssignExp exp) | |
314 { | |
315 visitExp(exp.identifier); | |
316 visitExp(exp.exp); | |
317 static if (is(ExpT == void)) | |
318 return; | |
319 else | |
320 return ExpT.init; | |
321 } | |
322 | |
323 ExpT visitBinaryExp(BinaryExp exp) | |
324 { | |
325 visitExp(exp.left); | |
326 visitExp(exp.right); | |
327 static if (is(ExpT == void)) | |
328 return; | |
329 else | |
330 return ExpT.init; | |
331 } | |
332 | |
333 ExpT visitCallExp(CallExp exp) | |
334 { | |
335 visitExp(exp.exp); | |
336 foreach (arg; exp.args) | |
337 visitExp(arg); | |
338 static if (is(ExpT == void)) | |
339 return; | |
340 else | |
341 return ExpT.init; | |
342 } | |
343 | |
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:
63
diff
changeset
|
344 ExpT visitCastExp(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:
63
diff
changeset
|
345 { |
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:
63
diff
changeset
|
346 visitExp(exp.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:
63
diff
changeset
|
347 visitExp(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:
63
diff
changeset
|
348 static if (is(ExpT == void)) |
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:
63
diff
changeset
|
349 return; |
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:
63
diff
changeset
|
350 else |
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:
63
diff
changeset
|
351 return ExpT.init; |
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:
63
diff
changeset
|
352 } |
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:
63
diff
changeset
|
353 |
1 | 354 ExpT visitNegateExp(NegateExp exp) |
355 { | |
356 visitExp(exp.exp); | |
357 static if (is(ExpT == void)) | |
358 return; | |
359 else | |
360 return ExpT.init; | |
361 } | |
362 | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
363 ExpT visitDerefExp(DerefExp exp) |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
364 { |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
365 visitExp(exp.exp); |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
366 static if (is(ExpT == void)) |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
367 return; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
368 else |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
369 return ExpT.init; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
370 } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
371 |
176
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
372 ExpT visitAddressOfExp(AddressOfExp exp) |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
373 { |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
374 visitExp(exp.exp); |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
375 static if (is(ExpT == void)) |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
376 return; |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
377 else |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
378 return ExpT.init; |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
379 } |
dc9bf56b7ace
Can now use & as a unary operator and take an AddressOf
Anders Johnsen <skabet@gmail.com>
parents:
172
diff
changeset
|
380 |
1 | 381 ExpT visitIntegerLit(IntegerLit exp) |
382 { | |
383 static if (is(ExpT == void)) | |
384 return; | |
385 else | |
386 return ExpT.init; | |
387 } | |
388 | |
106
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
389 ExpT visitStringExp(StringExp exp) |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
390 { |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
391 static if (is(ExpT == void)) |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
392 return; |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
393 else |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
394 return ExpT.init; |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
395 } |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
396 |
1 | 397 ExpT visitIdentifier(Identifier exp) |
398 { | |
399 static if (is(ExpT == void)) | |
400 return; | |
401 else | |
402 return ExpT.init; | |
403 } | |
28
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
404 |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
405 ExpT visitPointerTypeExp(PointerTypeExp exp) |
77
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
406 { |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
407 visitExp(exp.pointerOf); |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
408 |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
409 static if (is(ExpT == void)) |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
410 return; |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
411 else |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
412 return ExpT.init; |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
413 } |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
414 |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
415 ExpT visitStaticArrayTypeExp(StaticArrayTypeExp exp) |
81 | 416 { |
417 visitExp(exp.arrayOf); | |
418 | |
419 static if (is(ExpT == void)) | |
420 return; | |
421 else | |
422 return ExpT.init; | |
423 } | |
424 | |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
425 ExpT visitFunctionTypeExp(FunctionTypeExp exp) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
426 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
427 visitExp(exp.returnType); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
428 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
429 foreach (decl ; exp.decls) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
430 visitDecl(decl); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
431 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
432 static if (is(ExpT == void)) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
433 return; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
434 else |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
435 return ExpT.init; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
436 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
437 |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
438 ExpT visitIndexExp(IndexExp exp) |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
439 { |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
440 visitExp(exp.target); |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
441 visitExp(exp.index); |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
442 |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
443 static if (is(ExpT == void)) |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
444 return; |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
445 else |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
446 return ExpT.init; |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
447 } |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
448 |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
449 ExpT visitMemberReference(MemberReference mem) |
28
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
450 { |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
451 visitExp(mem.target); |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
452 visitExp(mem.child); |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
453 |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
454 static if (is(ExpT == void)) |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
455 return; |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
456 else |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
457 return ExpT.init; |
69464d465284
Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents:
22
diff
changeset
|
458 } |
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:
149
diff
changeset
|
459 |
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:
149
diff
changeset
|
460 ExpT visitNewExp(NewExp n) |
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:
149
diff
changeset
|
461 { |
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:
149
diff
changeset
|
462 visitExp(n.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:
149
diff
changeset
|
463 |
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:
149
diff
changeset
|
464 foreach( a ; n.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:
149
diff
changeset
|
465 visitExp(a); |
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:
149
diff
changeset
|
466 |
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:
149
diff
changeset
|
467 foreach( c ; n.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:
149
diff
changeset
|
468 visitExp(c); |
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:
149
diff
changeset
|
469 |
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:
149
diff
changeset
|
470 static if (is(ExpT == void)) |
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:
149
diff
changeset
|
471 return; |
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:
149
diff
changeset
|
472 else |
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:
149
diff
changeset
|
473 return ExpT.init; |
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:
149
diff
changeset
|
474 } |
1 | 475 } |
476 |