annotate sema/Visitor.d @ 149:393a1f47a6d2

For loops in AST and sema. Should have correct scope and such now.
author Anders Johnsen <skabet@gmail.com>
date Mon, 21 Jul 2008 21:00:20 +0200
parents 6e6355fb5f0f
children 57b0b4464a0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
1 module sema.Visitor;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
2
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
3 import tango.io.Stdout;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
4
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
8 ast.Stmt,
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
9 ast.Exp;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
10
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
11 import lexer.Token;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
14 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
20 static if (is(FinalT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
21 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
22 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
23 return FinalT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
24 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
36 DeclT visitDecl(Decl decl)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
37 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
38 switch(decl.declType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
39 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
40 case DeclType.FuncDecl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
41 return visitFuncDecl(cast(FuncDecl)decl);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
42 case DeclType.VarDecl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
46 case DeclType.StructDecl:
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52 default:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
53 throw new Exception("Unknown declaration type");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
54 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
55 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
56
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
57 StmtT visitStmt(Stmt stmt)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
58 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
59 switch(stmt.stmtType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
60 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
61 case StmtType.Return:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
65 case StmtType.Decl:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
66 return visitDeclStmt(cast(DeclStmt)stmt);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
67 case StmtType.Exp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
77 default:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
78 throw new Exception("Unknown statement type");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
79 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
80 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
81
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
82 ExpT visitExp(Exp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
83 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
84 switch(exp.expType)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
85 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
86 case ExpType.Binary:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
87 return visitBinaryExp(cast(BinaryExp)exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
88 case ExpType.IntegerLit:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
89 return visitIntegerLit(cast(IntegerLit)exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
90 case ExpType.Negate:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
94 case ExpType.AssignExp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
95 return visitAssignExp(cast(AssignExp)exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
96 case ExpType.CallExp:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
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
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
100 case ExpType.Identifier:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
101 return visitIdentifier(cast(Identifier)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
102 case ExpType.PointerIdentifier:
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
103 return visitPointerIdentifier(cast(PointerIdentifier)exp);
136
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 106
diff changeset
104 case ExpType.StaticArrayIdentifier:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 106
diff changeset
105 return visitStaticArrayIdentifier(cast(StaticArrayIdentifier)exp);
106
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
106 case ExpType.StringExp:
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
107 return visitStringExp(cast(StringExp)exp);
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
108 case ExpType.Index:
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
109 return visitIndexExp(cast(IndexExp)exp);
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 46
diff changeset
110 case ExpType.MemberReference:
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 46
diff changeset
111 return visitMemberReference(cast(MemberReference)exp);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
112 default:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
113 throw new Exception("Unknown expression type");
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
114 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
115 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
116
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
117 // Declarations:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
118 DeclT visitVarDecl(VarDecl d)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
119 {
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
120 visitExp(d.varType);
82
06dda301ea61 Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents: 81
diff changeset
121 if(d.identifier)
06dda301ea61 Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents: 81
diff changeset
122 visitExp(d.identifier);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
123 if (d.init)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
124 visitExp(d.init);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
125
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
126 static if (is(DeclT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
127 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
128 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
129 return DeclT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
130 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
131
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
132 DeclT visitImportDecl(ImportDecl d)
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
133 {
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
134 visitIdentifier(d.name);
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
135 visitIdentifier(d.aliasedName);
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
136 foreach (id; d.packages)
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
137 visitIdentifier(id);
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
138 foreach (ids; d.explicitSymbols)
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(ids[0]);
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
141 visitIdentifier(ids[1]);
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
142 }
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
143
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
144 static if (is(DeclT == void))
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
145 return;
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
146 else
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 94
diff changeset
147 return DeclT.init;
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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
150 DeclT visitFuncDecl(FuncDecl f)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
151 {
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
152 visitExp(f.returnType);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
153 visitExp(f.identifier);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
154 foreach (arg; f.funcArgs)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
155 visitDecl(arg);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
156 foreach (stmt; f.statements)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
157 visitStmt(stmt);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
158
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
159 static if (is(DeclT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
160 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
161 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
162 return DeclT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
163 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
164
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
165 DeclT visitStructDecl(StructDecl s)
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
166 {
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
167 visitExp(s.identifier);
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
168
102
cd066f3b539a Parsing methods in structs - error on semantics though.
Anders Johnsen <skabet@gmail.com>
parents: 101
diff changeset
169 foreach (arg; s.decls)
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
170 visitDecl(arg);
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
171
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
172 static if (is(DeclT == void))
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
173 return;
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
174 else
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
175 return DeclT.init;
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
176 }
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 11
diff changeset
177
144
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
178 DeclT visitClassDecl(ClassDecl s)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
179 {
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
180 visitExp(s.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
181
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
182 foreach (arg; s.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
183 visitDecl(arg);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
184
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
185 foreach (arg; s.baseClasses)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
186 visitExp(arg);
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 static if (is(DeclT == void))
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
189 return;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
190 else
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
191 return DeclT.init;
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
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
194 DeclT visitInterfaceDecl(InterfaceDecl s)
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 visitExp(s.identifier);
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
197
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
198 foreach (arg; s.decls)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
199 visitDecl(arg);
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 foreach (arg; s.baseClasses)
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
202 visitExp(arg);
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 static if (is(DeclT == void))
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
205 return;
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
206 else
6e6355fb5f0f - Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents: 143
diff changeset
207 return DeclT.init;
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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
210 // Statements:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
211 StmtT visitReturnStmt(ReturnStmt s)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
212 {
37
858b9805843d Bug-fixes
Anders Halager <halager@gmail.com>
parents: 36
diff changeset
213 if (s.exp)
858b9805843d Bug-fixes
Anders Halager <halager@gmail.com>
parents: 36
diff changeset
214 visitExp(s.exp);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
215 static if (is(StmtT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
216 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
217 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
218 return StmtT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
219 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
220
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
221 StmtT visitDeclStmt(DeclStmt d)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
222 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
223 visitDecl(d.decl);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
224 static if (is(StmtT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
225 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
226 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
227 return StmtT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
228 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
229
44
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
230 StmtT visitCompoundStmt(CompoundStatement c)
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
231 {
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
232 foreach (stmt; c.statements)
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
233 visitStmt(stmt);
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
234 static if (is(StmtT == void))
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
235 return;
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
236 else
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
237 return StmtT.init;
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
238 }
495188f9078e Big update - Moving towards a better, more seperated parser
Anders Halager <halager@gmail.com>
parents: 37
diff changeset
239
5
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
240 StmtT visitIfStmt(IfStmt s)
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
241 {
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
242 visitExp(s.cond);
45
9bc660cbdbec If statements are back
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
243 visitStmt(s.then_body);
9bc660cbdbec If statements are back
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
244 if (s.else_body !is null)
9bc660cbdbec If statements are back
Anders Halager <halager@gmail.com>
parents: 44
diff changeset
245 visitStmt(s.else_body);
11
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
246 static if (is(StmtT == void))
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
247 return;
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
248 else
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
249 return StmtT.init;
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
250 }
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
251
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
252 StmtT visitWhileStmt(WhileStmt s)
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
253 {
642c6a998fd9 Support for while statements and fixed scope for if
Anders Halager <halager@gmail.com>
parents: 5
diff changeset
254 visitExp(s.cond);
46
90fb4fdfefdd While is back
Anders Halager <halager@gmail.com>
parents: 45
diff changeset
255 visitStmt(s.whileBody);
5
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
256 static if (is(StmtT == void))
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
257 return;
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
258 else
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
259 return StmtT.init;
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
260 }
149
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
261
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
262 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
263 {
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
264 visitStmt(s.init);
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
265 visitExp(s.cond);
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
266 visitExp(s.incre);
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
267 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
268 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
269 return;
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
270 else
393a1f47a6d2 For loops in AST and sema. Should have correct scope and such now.
Anders Johnsen <skabet@gmail.com>
parents: 144
diff changeset
271 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
272 }
5
2c5a8f4c254a Added very simple if support.
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
273
36
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
274 StmtT visitSwitchStmt(SwitchStmt s)
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
275 {
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
276 visitExp(s.cond);
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
277 foreach(stmt; s.defaultBlock)
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
278 visitStmt(stmt);
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
279 foreach (c; s.cases)
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
280 {
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
281 foreach(lit; c.values)
143
d76cc5cad4fc Added partial support for switches.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
282 visitExp(lit);
36
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
283 foreach(stmt; c.stmts)
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
284 visitStmt(stmt);
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
285 }
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
286 static if (is(StmtT == void))
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
287 return;
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
288 else
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
289 return StmtT.init;
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
290 }
ce17bea8e9bd Switch statements support
Anders Halager <halager@gmail.com>
parents: 28
diff changeset
291
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
292 StmtT visitExpStmt(ExpStmt s)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
293 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
294 visitExp(s.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
295 static if (is(StmtT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
296 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
297 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
298 return StmtT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
299 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
300
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
301 // Expressions:
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
302 ExpT visitAssignExp(AssignExp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
303 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
304 visitExp(exp.identifier);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
305 visitExp(exp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
306 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
307 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
308 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
309 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
310 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
311
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
312 ExpT visitBinaryExp(BinaryExp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
313 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
314 visitExp(exp.left);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
315 visitExp(exp.right);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
316 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
317 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
318 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
319 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
320 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
321
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
322 ExpT visitCallExp(CallExp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
323 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
324 visitExp(exp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
325 foreach (arg; exp.args)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
326 visitExp(arg);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
327 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
328 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
329 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
330 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
331 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
332
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
333 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
334 {
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
335 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
336 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
337 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
338 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
339 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
340 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
341 }
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
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
343 ExpT visitNegateExp(NegateExp exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
344 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
345 visitExp(exp.exp);
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
346 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
347 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
348 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
349 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
350 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
351
78
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
352 ExpT visitDerefExp(DerefExp exp)
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
353 {
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
354 visitExp(exp.exp);
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
355 static if (is(ExpT == void))
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
356 return;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
357 else
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
358 return ExpT.init;
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
359 }
ad956143dcdc Parse and gen for dereferences
Anders Halager <halager@gmail.com>
parents: 68
diff changeset
360
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
361 ExpT visitIntegerLit(IntegerLit exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
362 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
363 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
364 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
365 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
366 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
367 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
368
106
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
369 ExpT visitStringExp(StringExp exp)
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
370 {
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
371 static if (is(ExpT == void))
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
372 return;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
373 else
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
374 return ExpT.init;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
375 }
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents: 102
diff changeset
376
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
377 ExpT visitIdentifier(Identifier exp)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
378 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
379 static if (is(ExpT == void))
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
380 return;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
381 else
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
382 return ExpT.init;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
383 }
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
384
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
385 ExpT visitPointerIdentifier(PointerIdentifier exp)
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
386 {
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
387 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
388
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
389 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
390 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
391 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
392 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
393 }
13eea2c4e60d Now able of --ast-dump-code with Pointer types and also codeGen int* x;
Anders Johnsen <skabet@gmail.com>
parents: 68
diff changeset
394
136
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 106
diff changeset
395 ExpT visitStaticArrayIdentifier(StaticArrayIdentifier exp)
81
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
396 {
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
397 visitExp(exp.arrayOf);
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
398
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
399 static if (is(ExpT == void))
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
400 return;
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
401 else
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
402 return ExpT.init;
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
403 }
110c7e1c4ca2 Now you can declare array
Anders Johnsen <skabet@gmail.com>
parents: 79
diff changeset
404
83
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
405 ExpT visitIndexExp(IndexExp exp)
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
406 {
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
407 visitExp(exp.target);
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
408 visitExp(exp.index);
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
409
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
410 static if (is(ExpT == void))
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
411 return;
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
412 else
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
413 return ExpT.init;
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
414 }
9e90694f5da0 Parse array indexing, and allow reading from arrays
Anders Halager <halager@gmail.com>
parents: 82
diff changeset
415
55
79cb0afafabe Now structs are somewhat useable to use.
Anders Johnsen <skabet@gmail.com>
parents: 46
diff changeset
416 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
417 {
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
418 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
419 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
420
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
421 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
422 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
423 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
424 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
425 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
426 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
427