Mercurial > projects > dang
annotate sema/Visitor.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 | 0f38f1a0f06f |
children | dc9bf56b7ace |
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); |
1 | 94 case ExpType.AssignExp: |
95 return visitAssignExp(cast(AssignExp)exp); | |
96 case ExpType.CallExp: | |
97 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
|
98 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
|
99 return visitCastExp(cast(CastExp)exp); |
1 | 100 case ExpType.Identifier: |
101 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
|
102 case ExpType.IdentifierTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
103 return visitIdentifier(cast(Identifier)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
104 case ExpType.PointerTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
105 return visitPointerTypeExp(cast(PointerTypeExp)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
106 case ExpType.StaticArrayTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
107 return visitStaticArrayTypeExp(cast(StaticArrayTypeExp)exp); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
108 case ExpType.FunctionTypeExp: |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
109 return visitFunctionTypeExp(cast(FunctionTypeExp)exp); |
106
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
110 case ExpType.StringExp: |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
111 return visitStringExp(cast(StringExp)exp); |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
112 case ExpType.Index: |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
113 return visitIndexExp(cast(IndexExp)exp); |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
114 case ExpType.MemberReference: |
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
115 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
|
116 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
|
117 return visitNewExp(cast(NewExp)exp); |
1 | 118 default: |
119 throw new Exception("Unknown expression type"); | |
120 } | |
121 } | |
122 | |
123 // Declarations: | |
124 DeclT visitVarDecl(VarDecl d) | |
125 { | |
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
|
126 visitExp(d.varType); |
82
06dda301ea61
Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents:
81
diff
changeset
|
127 if(d.identifier) |
06dda301ea61
Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents:
81
diff
changeset
|
128 visitExp(d.identifier); |
1 | 129 if (d.init) |
130 visitExp(d.init); | |
131 | |
132 static if (is(DeclT == void)) | |
133 return; | |
134 else | |
135 return DeclT.init; | |
136 } | |
137 | |
99
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
138 DeclT visitImportDecl(ImportDecl d) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
139 { |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
140 visitIdentifier(d.name); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
141 visitIdentifier(d.aliasedName); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
142 foreach (id; d.packages) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
143 visitIdentifier(id); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
144 foreach (ids; d.explicitSymbols) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
145 { |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
146 visitIdentifier(ids[0]); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
147 visitIdentifier(ids[1]); |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
148 } |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
149 |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
150 static if (is(DeclT == void)) |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
151 return; |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
152 else |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
153 return DeclT.init; |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
154 } |
857f0d530789
Imports and improved module statement
Anders Halager <halager@gmail.com>
parents:
94
diff
changeset
|
155 |
1 | 156 DeclT visitFuncDecl(FuncDecl f) |
157 { | |
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
|
158 visitExp(f.returnType); |
1 | 159 visitExp(f.identifier); |
160 foreach (arg; f.funcArgs) | |
161 visitDecl(arg); | |
162 foreach (stmt; f.statements) | |
163 visitStmt(stmt); | |
164 | |
165 static if (is(DeclT == void)) | |
166 return; | |
167 else | |
168 return DeclT.init; | |
169 } | |
170 | |
22 | 171 DeclT visitStructDecl(StructDecl s) |
172 { | |
173 visitExp(s.identifier); | |
174 | |
102
cd066f3b539a
Parsing methods in structs - error on semantics though.
Anders Johnsen <skabet@gmail.com>
parents:
101
diff
changeset
|
175 foreach (arg; s.decls) |
22 | 176 visitDecl(arg); |
177 | |
178 static if (is(DeclT == void)) | |
179 return; | |
180 else | |
181 return DeclT.init; | |
182 } | |
183 | |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
184 DeclT visitClassDecl(ClassDecl s) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
185 { |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
186 visitExp(s.identifier); |
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 foreach (arg; s.decls) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
189 visitDecl(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
190 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
191 foreach (arg; s.baseClasses) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
192 visitExp(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
193 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
194 static if (is(DeclT == void)) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
195 return; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
196 else |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
197 return DeclT.init; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
198 } |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
199 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
200 DeclT visitInterfaceDecl(InterfaceDecl s) |
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 visitExp(s.identifier); |
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 foreach (arg; s.decls) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
205 visitDecl(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
206 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
207 foreach (arg; s.baseClasses) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
208 visitExp(arg); |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
209 |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
210 static if (is(DeclT == void)) |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
211 return; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
212 else |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
213 return DeclT.init; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
214 } |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
143
diff
changeset
|
215 |
1 | 216 // Statements: |
217 StmtT visitReturnStmt(ReturnStmt s) | |
218 { | |
37 | 219 if (s.exp) |
220 visitExp(s.exp); | |
1 | 221 static if (is(StmtT == void)) |
222 return; | |
223 else | |
224 return StmtT.init; | |
225 } | |
226 | |
227 StmtT visitDeclStmt(DeclStmt d) | |
228 { | |
229 visitDecl(d.decl); | |
230 static if (is(StmtT == void)) | |
231 return; | |
232 else | |
233 return StmtT.init; | |
234 } | |
235 | |
44
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
236 StmtT visitCompoundStmt(CompoundStatement c) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
237 { |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
238 foreach (stmt; c.statements) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
239 visitStmt(stmt); |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
240 static if (is(StmtT == void)) |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
241 return; |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
242 else |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
243 return StmtT.init; |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
244 } |
495188f9078e
Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents:
37
diff
changeset
|
245 |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
246 StmtT visitIfStmt(IfStmt s) |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
247 { |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
248 visitExp(s.cond); |
45 | 249 visitStmt(s.then_body); |
250 if (s.else_body !is null) | |
251 visitStmt(s.else_body); | |
11
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
252 static if (is(StmtT == void)) |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
253 return; |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
254 else |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
255 return StmtT.init; |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
256 } |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
257 |
642c6a998fd9
Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents:
5
diff
changeset
|
258 StmtT visitWhileStmt(WhileStmt s) |
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 visitExp(s.cond); |
46 | 261 visitStmt(s.whileBody); |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
262 static if (is(StmtT == void)) |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
263 return; |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
264 else |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
265 return StmtT.init; |
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
266 } |
149
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
267 |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
268 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
|
269 { |
162
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
270 if(s.init) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
271 visitStmt(s.init); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
272 if(s.cond) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
273 visitExp(s.cond); |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
274 if(s.incre) |
0f38f1a0f06f
Fixed symbol for a functions members.
Anders Johnsen <skabet@gmail.com>
parents:
158
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 return; |
393a1f47a6d2
For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents:
144
diff
changeset
|
279 else |
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 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
|
281 } |
5
2c5a8f4c254a
Added very simple if support.
Anders Halager <halager@gmail.com>
parents:
1
diff
changeset
|
282 |
36
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
283 StmtT visitSwitchStmt(SwitchStmt s) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
284 { |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
285 visitExp(s.cond); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
286 foreach(stmt; s.defaultBlock) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
287 visitStmt(stmt); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
288 foreach (c; s.cases) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
289 { |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
290 foreach(lit; c.values) |
143
d76cc5cad4fc
Added partial support for switches.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
291 visitExp(lit); |
36
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
292 foreach(stmt; c.stmts) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
293 visitStmt(stmt); |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
294 } |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
295 static if (is(StmtT == void)) |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
296 return; |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
297 else |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
298 return StmtT.init; |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
299 } |
ce17bea8e9bd
Switch statements support
Anders Halager <halager@gmail.com>
parents:
28
diff
changeset
|
300 |
1 | 301 StmtT visitExpStmt(ExpStmt s) |
302 { | |
303 visitExp(s.exp); | |
304 static if (is(StmtT == void)) | |
305 return; | |
306 else | |
307 return StmtT.init; | |
308 } | |
309 | |
310 // Expressions: | |
311 ExpT visitAssignExp(AssignExp exp) | |
312 { | |
313 visitExp(exp.identifier); | |
314 visitExp(exp.exp); | |
315 static if (is(ExpT == void)) | |
316 return; | |
317 else | |
318 return ExpT.init; | |
319 } | |
320 | |
321 ExpT visitBinaryExp(BinaryExp exp) | |
322 { | |
323 visitExp(exp.left); | |
324 visitExp(exp.right); | |
325 static if (is(ExpT == void)) | |
326 return; | |
327 else | |
328 return ExpT.init; | |
329 } | |
330 | |
331 ExpT visitCallExp(CallExp exp) | |
332 { | |
333 visitExp(exp.exp); | |
334 foreach (arg; exp.args) | |
335 visitExp(arg); | |
336 static if (is(ExpT == void)) | |
337 return; | |
338 else | |
339 return ExpT.init; | |
340 } | |
341 | |
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
|
342 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
|
343 { |
381975d76baf
A LOT of bug fixing - also implemented implicit casts. If you do a --ast-dump-code on a target with some algebra of differant types, you should now see the type casts being made. Also, Tests are again back with only switches failing...
Anders Johnsen <skabet@gmail.com>
parents:
63
diff
changeset
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 } |
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 |
1 | 352 ExpT visitNegateExp(NegateExp exp) |
353 { | |
354 visitExp(exp.exp); | |
355 static if (is(ExpT == void)) | |
356 return; | |
357 else | |
358 return ExpT.init; | |
359 } | |
360 | |
78
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
361 ExpT visitDerefExp(DerefExp exp) |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
362 { |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
363 visitExp(exp.exp); |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
364 static if (is(ExpT == void)) |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
365 return; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
366 else |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
367 return ExpT.init; |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
368 } |
ad956143dcdc
Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents:
68
diff
changeset
|
369 |
1 | 370 ExpT visitIntegerLit(IntegerLit exp) |
371 { | |
372 static if (is(ExpT == void)) | |
373 return; | |
374 else | |
375 return ExpT.init; | |
376 } | |
377 | |
106
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
378 ExpT visitStringExp(StringExp exp) |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
379 { |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
380 static if (is(ExpT == void)) |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
381 return; |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
382 else |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
383 return ExpT.init; |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
384 } |
89db676fbacb
Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
102
diff
changeset
|
385 |
1 | 386 ExpT visitIdentifier(Identifier exp) |
387 { | |
388 static if (is(ExpT == void)) | |
389 return; | |
390 else | |
391 return ExpT.init; | |
392 } | |
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
|
393 |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
394 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
|
395 { |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
396 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
|
397 |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
398 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
|
399 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
|
400 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
|
401 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
|
402 } |
13eea2c4e60d
Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents:
68
diff
changeset
|
403 |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
404 ExpT visitStaticArrayTypeExp(StaticArrayTypeExp exp) |
81 | 405 { |
406 visitExp(exp.arrayOf); | |
407 | |
408 static if (is(ExpT == void)) | |
409 return; | |
410 else | |
411 return ExpT.init; | |
412 } | |
413 | |
172
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
414 ExpT visitFunctionTypeExp(FunctionTypeExp exp) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
415 { |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
416 visitExp(exp.returnType); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
417 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
418 foreach (decl ; exp.decls) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
419 visitDecl(decl); |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
420 |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
421 static if (is(ExpT == void)) |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
422 return; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
423 else |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
424 return ExpT.init; |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
425 } |
01c2c49775ef
- Changed Parser to be more clean on type parsing.
Anders Johnsen <skabet@gmail.com>
parents:
162
diff
changeset
|
426 |
83
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
427 ExpT visitIndexExp(IndexExp exp) |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
428 { |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
429 visitExp(exp.target); |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
430 visitExp(exp.index); |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
431 |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
432 static if (is(ExpT == void)) |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
433 return; |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
434 else |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
435 return ExpT.init; |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
436 } |
9e90694f5da0
Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents:
82
diff
changeset
|
437 |
55
79cb0afafabe
Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents:
46
diff
changeset
|
438 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
|
439 { |
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
|
440 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
|
441 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
|
442 |
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
|
443 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
|
444 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
|
445 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
|
446 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
|
447 } |
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
|
448 |
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
|
449 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
|
450 { |
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
|
451 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
|
452 |
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
|
453 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
|
454 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
|
455 |
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
|
456 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
|
457 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
|
458 |
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 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
|
460 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
|
461 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
|
462 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
|
463 } |
1 | 464 } |
465 |