Mercurial > projects > dang
annotate ast/Module.d @ 150:6c5a3c0bb4fb
Make switch work again
Also added locations to statements (only filled out for switch)
Added a verification pass
Removed some comments
author | Anders Halager <halager@gmail.com> |
---|---|
date | Mon, 21 Jul 2008 20:35:03 +0200 |
parents | 6e6355fb5f0f |
children | 08f68d684047 |
rev | line source |
---|---|
95 | 1 module ast.Module; |
2 | |
129 | 3 import sema.Scope, |
150 | 4 sema.VC, |
129 | 5 sema.Symbol; |
95 | 6 |
7 import ast.Decl; | |
8 | |
9 class Module | |
10 { | |
11 this(char[] moduleName) | |
12 { | |
13 this.moduleName = moduleName; | |
14 } | |
15 | |
16 void addDecl(Decl decl) | |
17 { | |
140
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
18 switch(decl.declType) |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
19 { |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
20 case DeclType.FuncDecl: |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
21 functions ~= cast(FuncDecl)decl; |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
22 break; |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
23 case DeclType.VarDecl: |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
24 vars ~= cast(VarDecl)decl; |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
25 break; |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
26 case DeclType.StructDecl: |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
27 structs ~= cast(StructDecl)decl; |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
28 break; |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
29 case DeclType.ClassDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
30 classes ~= cast(ClassDecl)decl; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
31 break; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
32 case DeclType.InterfaceDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
33 interfaces ~= cast(InterfaceDecl)decl; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
34 break; |
140
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
35 default: |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
36 assert(0, "DeclType not implemented"); |
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
37 } |
95 | 38 decls ~= decl; |
39 } | |
40 | |
150 | 41 void verify(VC vc) |
42 { | |
43 foreach (decl; decls) | |
44 decl.verify(vc); | |
45 } | |
46 | |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
47 VarDecl[] vars; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
48 FuncDecl[] functions; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
49 StructDecl[] structs; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
50 ClassDecl[] classes; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
51 InterfaceDecl[] interfaces; |
95 | 52 Decl[] decls; |
140
927ae00bd9d2
Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents:
136
diff
changeset
|
53 |
95 | 54 char[] moduleName; |
55 Scope env; | |
129 | 56 Symbol symbol; |
136 | 57 bool outputModule = true; |
95 | 58 } |
129 | 59 |