Mercurial > projects > dang
annotate ast/Module.d @ 194:08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Also added support for alias.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 29 Jul 2008 13:54:44 +0200 |
parents | 6c5a3c0bb4fb |
children |
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 { | |
194
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
18 if(!decl) |
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
19 return; |
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
|
20 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
|
21 { |
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 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 break; |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
31 case DeclType.ClassDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
32 classes ~= cast(ClassDecl)decl; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
33 break; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
34 case DeclType.InterfaceDecl: |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
35 interfaces ~= cast(InterfaceDecl)decl; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
36 break; |
194
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
37 case DeclType.AliasDecl: |
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
38 aliases ~= cast(AliasDecl)decl; |
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 } |
95 | 43 decls ~= decl; |
44 } | |
45 | |
150 | 46 void verify(VC vc) |
47 { | |
48 foreach (decl; decls) | |
49 decl.verify(vc); | |
50 } | |
51 | |
144
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
52 VarDecl[] vars; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
53 FuncDecl[] functions; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
54 StructDecl[] structs; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
55 ClassDecl[] classes; |
6e6355fb5f0f
- Parsing nested attributes.
Anders Johnsen <skabet@gmail.com>
parents:
140
diff
changeset
|
56 InterfaceDecl[] interfaces; |
194
08f68d684047
Rename some files. Hopefully we can get a more iterative sema pass, that's a lot easier to "get startet with".
Anders Johnsen <skabet@gmail.com>
parents:
150
diff
changeset
|
57 AliasDecl[] aliases; |
95 | 58 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
|
59 |
95 | 60 char[] moduleName; |
61 Scope env; | |
129 | 62 Symbol symbol; |
136 | 63 bool outputModule = true; |
95 | 64 } |
129 | 65 |