Mercurial > projects > dil
annotate trunk/src/dil/semantic/Pass1.d @ 798:c24be8d4f6ab
Added documentation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 02:53:06 +0100 |
parents | 47c5099562c7 |
children |
rev | line source |
---|---|
635 | 1 /++ |
2 Author: Aziz Köksal | |
3 License: GPL3 | |
4 +/ | |
5 module dil.semantic.Pass1; | |
6 | |
7 import dil.ast.Visitor; | |
8 import dil.ast.Node, | |
9 dil.ast.Declarations, | |
10 dil.ast.Expressions, | |
11 dil.ast.Statements, | |
12 dil.ast.Types, | |
13 dil.ast.Parameters; | |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
14 import dil.lexer.IdTable; |
635 | 15 import dil.semantic.Symbol, |
16 dil.semantic.Symbols, | |
645
89ee7802c978
Moved semantic() methods of expressions to class SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
644
diff
changeset
|
17 dil.semantic.Types, |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
18 dil.semantic.Scope, |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
19 dil.semantic.Module, |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
20 dil.semantic.Analysis; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
21 import dil.Compilation; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
22 import dil.Location; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
23 import dil.Information; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
24 import dil.Messages; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
25 import dil.Enums; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
26 import dil.CompilerInfo; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
27 import common; |
635 | 28 |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
29 /// The first pass is the declaration pass. |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
30 /// |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
31 /// The basic task of this class is to traverse the parse tree, |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
32 /// find all kinds of declarations and add them |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
33 /// to the symbol tables of their respective scopes. |
635 | 34 class SemanticPass1 : Visitor |
35 { | |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
36 Scope scop; /// The current scope. |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
37 Module modul; /// The module to be semantically checked. |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
38 CompilationContext context; /// The compilation context. |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
39 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
40 // Attributes: |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
41 LinkageType linkageType; /// Current linkage type. |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
42 Protection protection; /// Current protection attribute. |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
43 StorageClass storageClass; /// Current storage classes. |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
44 uint alignSize; /// Current align size. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
45 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
46 /// Constructs a SemanticPass1 object. |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
47 /// Params: |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
48 /// modul = the module to be processed. |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
49 /// context = the compilation context. |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
50 this(Module modul, CompilationContext context) |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
51 { |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
52 this.modul = modul; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
53 this.context = new CompilationContext(context); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
54 this.alignSize = context.structAlign; |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
55 } |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
56 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
57 /// Starts processing the module. |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
58 void start() |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
59 { |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
60 assert(modul.root !is null); |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
61 // Create module scope. |
692
d33895f679eb
Tidied up the class Scope a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
690
diff
changeset
|
62 scop = new Scope(null, modul); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
63 visit(modul.root); |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
64 } |
635 | 65 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
66 /// Enters a new scope. |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
67 void enterScope(ScopeSymbol s) |
635 | 68 { |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
69 scop = scop.enter(s); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
70 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
71 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
72 /// Exits the current scope. |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
73 void exitScope() |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
74 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
75 scop = scop.exit(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
76 } |
635 | 77 |
787
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
78 /// Returns true if this is the module scope. |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
79 bool isModuleScope() |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
80 { |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
81 return scop.symbol.isModule(); |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
82 } |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
83 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
84 /// Inserts a symbol into the current scope. |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
85 void insert(Symbol symbol, Identifier* name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
86 { |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
87 auto symX = scop.symbol.lookup(name); |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
88 if (symX) |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
89 reportSymbolConflict(symbol, symX, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
90 else |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
91 scop.symbol.insert(symbol, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
92 // Set the current scope symbol as the parent. |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
93 symbol.parent = scop.symbol; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
94 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
95 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
96 /// Inserts a symbol into scopeSym. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
97 void insert(Symbol symbol, ScopeSymbol scopeSym) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
98 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
99 auto symX = scopeSym.lookup(symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
100 if (symX) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
101 reportSymbolConflict(symbol, symX, symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
102 else |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
103 scopeSym.insert(symbol, symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
104 // Set the current scope symbol as the parent. |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
105 symbol.parent = scopeSym; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
106 } |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
107 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
108 /// Inserts a symbol, overloading on the name, into the current scope. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
109 void insertOverload(Symbol sym, Identifier* name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
110 { |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
111 auto sym2 = scop.symbol.lookup(name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
112 if (sym2) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
113 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
114 if (sym2.isOverloadSet) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
115 (cast(OverloadSet)cast(void*)sym2).add(sym); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
116 else |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
117 reportSymbolConflict(sym, sym2, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
118 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
119 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
120 // Create a new overload set. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
121 scop.symbol.insert(new OverloadSet(name, sym.node), name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
122 // Set the current scope symbol as the parent. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
123 sym.parent = scop.symbol; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
124 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
125 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
126 /// Reports an error: new symbol s1 conflicts with existing symbol s2. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
127 void reportSymbolConflict(Symbol s1, Symbol s2, Identifier* name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
128 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
129 auto loc = s2.node.begin.getErrorLocation(); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
130 auto locString = Format("{}({},{})", loc.filePath, loc.lineNum, loc.colNum); |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
131 error(s1.node.begin, MSG.DeclConflictsWithDecl, name.str, locString); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
132 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
133 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
134 /// Creates an error report. |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
135 void error(Token* token, char[] formatMsg, ...) |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
136 { |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
137 if (!modul.infoMan) |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
138 return; |
675
e7811328e6c7
Made Token.getLocation() a template function and added two aliases.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
139 auto location = token.getErrorLocation(); |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
140 auto msg = Format(_arguments, _argptr, formatMsg); |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
141 modul.infoMan ~= new SemanticError(location, msg); |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
142 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
143 |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
144 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
145 /// Collects info about nodes which have to be evaluated later. |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
146 static class Deferred |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
147 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
148 Node node; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
149 ScopeSymbol symbol; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
150 // Saved attributes. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
151 LinkageType linkageType; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
152 Protection protection; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
153 StorageClass storageClass; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
154 uint alignSize; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
155 } |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
156 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
157 /// List of mixin, static if, static assert and pragma(msg,...) declarations. |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
158 /// |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
159 /// Their analysis must be deferred because they entail |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
160 /// evaluation of expressions. |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
161 Deferred[] deferred; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
162 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
163 /// Adds a deferred node to the list. |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
164 void addDeferred(Node node) |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
165 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
166 auto d = new Deferred; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
167 d.node = node; |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
168 d.symbol = scop.symbol; |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
169 d.linkageType = linkageType; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
170 d.protection = protection; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
171 d.storageClass = storageClass; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
172 d.alignSize = alignSize; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
173 deferred ~= d; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
174 } |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
175 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
787
diff
changeset
|
176 private alias Declaration D; /// A handy alias. Saves typing. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
177 |
635 | 178 override |
179 { | |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
180 D visit(CompoundDeclaration d) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
181 { |
696
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
692
diff
changeset
|
182 foreach (decl; d.decls) |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
692
diff
changeset
|
183 visitD(decl); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
184 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
185 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
186 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
187 D visit(IllegalDeclaration) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
188 { assert(0, "semantic pass on invalid AST"); return null; } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
189 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
190 D visit(EmptyDeclaration ed) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
191 { return ed; } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
192 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
193 D visit(ModuleDeclaration) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
194 { return null; } |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
195 |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
196 D visit(ImportDeclaration d) |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
197 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
198 return d; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
199 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
200 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
201 D visit(AliasDeclaration ad) |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
202 { |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
203 return ad; |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
204 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
205 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
206 D visit(TypedefDeclaration td) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
207 { |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
208 return td; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
209 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
210 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
211 D visit(EnumDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
212 { |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
213 // Create the symbol. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
214 d.symbol = new Enum(d.name, d); |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
215 auto isAnonymous = d.name is null; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
216 if (isAnonymous) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
217 d.symbol.name = IdTable.genAnonEnumID(); |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
713
diff
changeset
|
218 insert(d.symbol, d.symbol.name); |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
219 auto parentScopeSymbol = scop.symbol; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
220 enterScope(d.symbol); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
221 // Declare members. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
222 foreach (member; d.members) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
223 { |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
224 visitD(member); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
225 if (isAnonymous) // Also insert into parent scope if enum is anonymous. |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
226 insert(member.symbol, parentScopeSymbol); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
227 member.symbol.parent = d.symbol; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
228 } |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
229 exitScope(); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
230 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
231 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
232 |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
233 D visit(EnumMemberDeclaration d) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
234 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
235 d.symbol = new EnumMember(d.name, protection, storageClass, linkageType, d); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
236 insert(d.symbol, d.symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
237 return d; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
238 } |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
239 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
240 D visit(ClassDeclaration d) |
635 | 241 { |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
242 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
243 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
244 d.symbol = new Class(d.name, d); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
245 // Insert into current scope. |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
246 insert(d.symbol, d.name); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
247 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
248 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
249 d.decls && visitD(d.decls); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
250 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
251 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
252 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
253 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
254 D visit(InterfaceDeclaration d) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
255 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
256 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
257 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
258 d.symbol = new dil.semantic.Symbols.Interface(d.name, d); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
259 // Insert into current scope. |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
260 insert(d.symbol, d.name); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
261 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
262 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
263 d.decls && visitD(d.decls); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
264 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
265 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
266 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
267 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
268 D visit(StructDeclaration d) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
269 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
270 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
271 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
272 d.symbol = new Struct(d.name, d); |
635 | 273 // Insert into current scope. |
667
1ac758cd952a
Fixed a few things in DefaultVisitor.d and Pass1.d
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
655
diff
changeset
|
274 if (d.name) |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
275 insert(d.symbol, d.name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
276 enterScope(d.symbol); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
277 // Continue semantic analysis. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
278 d.decls && visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
279 exitScope(); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
280 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
281 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
282 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
283 D visit(UnionDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
284 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
285 if (d.symbol) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
286 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
287 d.symbol = new Union(d.name, d); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
288 // Insert into current scope. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
289 if (d.name) |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
290 insert(d.symbol, d.name); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
291 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
292 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
293 d.decls && visitD(d.decls); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
294 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
295 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
296 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
297 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
298 D visit(ConstructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
299 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
300 auto func = new Function(Ident.__ctor, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
301 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
302 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
303 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
304 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
305 D visit(StaticConstructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
306 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
307 auto func = new Function(Ident.__ctor, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
308 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
309 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
310 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
311 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
312 D visit(DestructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
313 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
314 auto func = new Function(Ident.__dtor, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
315 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
316 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
317 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
318 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
319 D visit(StaticDestructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
320 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
321 auto func = new Function(Ident.__dtor, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
322 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
323 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
324 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
325 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
326 D visit(FunctionDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
327 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
328 auto func = new Function(d.name, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
329 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
330 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
331 } |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
332 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
333 D visit(VariablesDeclaration vd) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
334 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
335 // Error if we are in an interface. |
783
8380fb2c765f
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
778
diff
changeset
|
336 if (scop.symbol.isInterface && !vd.isStatic) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
337 return error(vd.begin, MSG.InterfaceCantHaveVariables), vd; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
338 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
339 // Insert variable symbols in this declaration into the symbol table. |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
340 foreach (i, name; vd.names) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
341 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
342 auto variable = new Variable(name, protection, storageClass, linkageType, vd); |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
343 variable.value = vd.inits[i]; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
344 vd.variables ~= variable; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
345 insert(variable, name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
346 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
347 return vd; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
348 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
349 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
350 D visit(InvariantDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
351 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
352 auto func = new Function(Ident.__invariant, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
353 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
354 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
355 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
356 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
357 D visit(UnittestDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
358 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
359 auto func = new Function(Ident.__unittest, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
360 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
361 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
362 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
363 |
777
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
364 D visit(DebugDeclaration d) |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
365 { |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
366 if (d.isSpecification) |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
367 { |
787
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
368 if (!isModuleScope()) |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
369 error(d.begin, MSG.DebugSpecModuleLevel, d.spec.srcText); |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
370 else if (d.spec.kind == TOK.Identifier) |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
371 context.addDebugId(d.spec.ident.str); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
372 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
373 context.debugLevel = d.spec.uint_; |
777
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
374 } |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
375 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
376 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
377 if (debugBranchChoice(d.cond, context)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
378 d.compiledDecls = d.decls; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
379 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
380 d.compiledDecls = d.elseDecls; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
381 d.compiledDecls && visitD(d.compiledDecls); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
382 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
383 return d; |
777
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
384 } |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
385 |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
386 D visit(VersionDeclaration d) |
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
387 { |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
388 if (d.isSpecification) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
389 { |
787
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
390 if (!isModuleScope()) |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
391 error(d.begin, MSG.VersionSpecModuleLevel, d.spec.srcText); |
47c5099562c7
Added two semantic error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
783
diff
changeset
|
392 else if (d.spec.kind == TOK.Identifier) |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
393 context.addVersionId(d.spec.ident.str); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
394 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
395 context.versionLevel = d.spec.uint_; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
396 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
397 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
398 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
399 if (versionBranchChoice(d.cond, context)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
400 d.compiledDecls = d.decls; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
401 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
402 d.compiledDecls = d.elseDecls; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
403 d.compiledDecls && visitD(d.compiledDecls); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
404 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
777
diff
changeset
|
405 return d; |
777
9f61e8af55d5
Added module dil.Compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
406 } |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
407 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
408 D visit(TemplateDeclaration d) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
409 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
410 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
411 return d; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
412 d.symbol = new Template(d.name, d); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
413 // Insert into current scope. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
414 insertOverload(d.symbol, d.name); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
415 enterScope(d.symbol); |
635 | 416 // Continue semantic analysis. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
417 visitD(d.decls); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
418 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
419 return d; |
635 | 420 } |
421 | |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
422 D visit(NewDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
423 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
424 auto func = new Function(Ident.__new, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
425 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
426 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
427 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
428 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
429 D visit(DeleteDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
430 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
431 auto func = new Function(Ident.__delete, d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
432 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
433 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
434 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
435 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
436 D visit(ProtectionDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
437 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
438 auto saved = protection; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
439 protection = d.prot; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
440 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
441 protection = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
442 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
443 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
444 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
445 D visit(StorageClassDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
446 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
447 auto saved = storageClass; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
448 storageClass = d.storageClass; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
449 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
450 storageClass = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
451 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
452 } |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
453 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
454 D visit(LinkageDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
455 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
456 auto saved = linkageType; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
457 linkageType = d.linkageType; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
458 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
459 linkageType = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
460 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
461 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
462 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
463 D visit(AlignDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
464 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
465 auto saved = alignSize; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
466 alignSize = d.size; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
467 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
468 alignSize = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
469 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
470 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
471 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
472 // Deferred declarations: |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
473 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
474 D visit(StaticAssertDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
475 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
476 addDeferred(d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
477 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
478 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
479 |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
480 D visit(StaticIfDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
481 { |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
482 addDeferred(d); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
483 return d; |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
484 } |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
485 |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
486 D visit(MixinDeclaration d) |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
487 { |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
488 addDeferred(d); |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
489 return d; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
490 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
491 |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
492 D visit(PragmaDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
493 { |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
494 if (d.ident is Ident.msg) |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
495 addDeferred(d); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
496 else |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
497 { |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
498 pragmaSemantic(scop, d.begin, d.ident, d.args); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
499 visitD(d.decls); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
500 } |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
501 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
502 } |
635 | 503 } // override |
504 } |