Mercurial > projects > dil
annotate trunk/src/dil/semantic/Pass1.d @ 713:1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Wed, 30 Jan 2008 23:23:58 +0100 |
parents | efa5fcb9aa14 |
children | 140469ecb90e |
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; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
21 import dil.Location; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
22 import dil.Information; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
23 import dil.Messages; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
24 import dil.Enums; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
25 import dil.CompilerInfo; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
26 import common; |
635 | 27 |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
28 /++ |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
29 The fist pass is the declaration pass. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
30 The basic task of this class is to traverse the parse tree, |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
31 find all kinds of declarations and add them |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
32 to the symbol tables of their respective scopes. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
33 +/ |
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. |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
38 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
39 // Attributes: |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
40 LinkageType linkageType; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
41 Protection protection; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
42 StorageClass storageClass; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
43 uint alignSize = DEFAULT_ALIGN_SIZE; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
44 |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
45 /++ |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
46 Construct a SemanticPass1 object. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
47 Params: |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
48 modul = the module to be processed. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
49 +/ |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
50 this(Module modul) |
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; |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
53 } |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
54 |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
55 /// Start semantic analysis. |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
56 void start() |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
57 { |
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
58 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
|
59 // Create module scope. |
692
d33895f679eb
Tidied up the class Scope a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
690
diff
changeset
|
60 scop = new Scope(null, modul); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
61 visit(modul.root); |
644
a0643a4d4501
Added some methods to SemanticPass1 class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
641
diff
changeset
|
62 } |
635 | 63 |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
64 void enterScope(ScopeSymbol s) |
635 | 65 { |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
66 scop = scop.enter(s); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
67 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
68 |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
69 void exitScope() |
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 scop = scop.exit(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
72 } |
635 | 73 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
74 /// Insert a symbol into the current scope. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
75 void insert(Symbol sym, Identifier* name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
76 { |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
77 auto sym2 = scop.symbol.lookup(name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
78 if (sym2) |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
79 reportSymbolConflict(sym, sym2, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
80 else |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
81 scop.symbol.insert(sym, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
82 // 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
|
83 sym.parent = scop.symbol; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
84 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
85 |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
86 /// Insert a symbol into scopeSym. |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
87 void insert(Symbol symbol, ScopeSymbol scopeSym) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
88 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
89 auto symX = scopeSym.lookup(symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
90 if (symX) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
91 reportSymbolConflict(symbol, symX, symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
92 else |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
93 scopeSym.insert(symbol, symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
94 // 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
|
95 symbol.parent = scopeSym; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
96 } |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
97 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
98 /// Insert 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
|
99 void insertOverload(Symbol sym, Identifier* name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
100 { |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
101 auto sym2 = scop.symbol.lookup(name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
102 if (sym2) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
103 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
104 if (sym2.isOverloadSet) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
105 (cast(OverloadSet)cast(void*)sym2).add(sym); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
106 else |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
107 reportSymbolConflict(sym, sym2, name); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
108 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
109 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
110 // Create a new overload set. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
111 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
|
112 // 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
|
113 sym.parent = scop.symbol; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
114 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
115 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
116 /// Report 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
|
117 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
|
118 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
119 auto loc = s2.node.begin.getErrorLocation(); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
120 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
|
121 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
|
122 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
123 |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
124 void error(Token* token, char[] formatMsg, ...) |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
125 { |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
126 if (!modul.infoMan) |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
127 return; |
675
e7811328e6c7
Made Token.getLocation() a template function and added two aliases.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
128 auto location = token.getErrorLocation(); |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
129 auto msg = Format(_arguments, _argptr, formatMsg); |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
130 modul.infoMan ~= new SemanticError(location, msg); |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
131 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
132 |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
133 |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
134 static class Deferred |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
135 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
136 Node node; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
137 ScopeSymbol symbol; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
138 // Saved attributes. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
139 LinkageType linkageType; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
140 Protection protection; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
141 StorageClass storageClass; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
142 uint alignSize; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
143 } |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
144 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
145 // List of mixin, static if, static assert and pragma(msg,...) declarations. |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
146 // Their analysis must be deferred because they entail |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
147 // evaluation of expressions. |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
148 Deferred[] deferred; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
149 |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
150 void addDeferred(Node node) |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
151 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
152 auto d = new Deferred; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
153 d.node = node; |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
154 d.symbol = scop.symbol; |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
155 d.linkageType = linkageType; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
156 d.protection = protection; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
157 d.storageClass = storageClass; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
158 d.alignSize = alignSize; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
159 deferred ~= d; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
160 } |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
161 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
162 private alias Declaration D; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
163 |
635 | 164 override |
165 { | |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
166 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
|
167 { |
696
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
692
diff
changeset
|
168 foreach (decl; d.decls) |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
692
diff
changeset
|
169 visitD(decl); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
170 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
171 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
172 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
173 D visit(IllegalDeclaration) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
174 { 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
|
175 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
176 D visit(EmptyDeclaration ed) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
177 { return ed; } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
178 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
179 D visit(ModuleDeclaration) |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
180 { return null; } |
686
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
181 |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
182 D visit(ImportDeclaration d) |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
183 { |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
184 return d; |
e8c09d13f2a5
Added class Deferred to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
185 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
186 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
187 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
|
188 { |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
189 return ad; |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
190 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
191 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
192 D visit(TypedefDeclaration td) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
193 { |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
194 return td; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
195 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
196 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
197 D visit(EnumDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
198 { |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
199 // Create the symbol. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
200 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
|
201 auto isAnonymous = d.name is null; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
202 if (isAnonymous) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
203 d.symbol.name = IdTable.genAnonEnumID(); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
204 insert(d.symbol, d.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
205 auto parentScopeSymbol = scop.symbol; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
206 enterScope(d.symbol); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
207 // Declare members. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
208 foreach (member; d.members) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
209 { |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
210 visitD(member); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
211 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
|
212 insert(member.symbol, parentScopeSymbol); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
213 member.symbol.parent = d.symbol; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
214 } |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
215 exitScope(); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
216 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
217 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
218 |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
219 D visit(EnumMemberDeclaration d) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
220 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
221 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
|
222 insert(d.symbol, d.symbol.name); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
223 return d; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
224 } |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
225 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
226 D visit(ClassDeclaration d) |
635 | 227 { |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
228 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
229 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
230 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
|
231 // Insert into current scope. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
232 if (d.tparams) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
233 insertOverload(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
234 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
235 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
|
236 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
237 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
238 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
|
239 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
240 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
241 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
242 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
243 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
|
244 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
245 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
246 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
247 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
|
248 // Insert into current scope. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
249 if (d.tparams) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
250 insertOverload(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
251 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
252 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
|
253 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
254 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
255 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
|
256 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
257 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
258 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
259 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
260 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
|
261 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
262 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
263 return d; |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
264 d.symbol = new Struct(d.name, d); |
635 | 265 // 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
|
266 if (d.name) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
267 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
268 if (d.tparams) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
269 insertOverload(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
270 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
271 insert(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
272 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
273 enterScope(d.symbol); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
274 // Continue semantic analysis. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
275 d.decls && visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
276 exitScope(); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
277 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
278 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
279 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
280 D visit(UnionDeclaration 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 if (d.symbol) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
283 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
284 d.symbol = new Union(d.name, d); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
285 // Insert into current scope. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
286 if (d.name) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
287 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
288 if (d.tparams) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
289 insertOverload(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
290 else |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
291 insert(d.symbol, d.name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
292 } |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
293 enterScope(d.symbol); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
294 // Continue semantic analysis. |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
295 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
|
296 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
297 return d; |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
298 } |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
299 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
300 D visit(ConstructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
301 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
302 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
|
303 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
304 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
305 } |
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 D visit(StaticConstructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
308 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
309 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
|
310 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
311 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
312 } |
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 D visit(DestructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
315 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
316 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
|
317 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
318 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
319 } |
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 D visit(StaticDestructorDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
322 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
323 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
|
324 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
325 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
326 } |
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 D visit(FunctionDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
329 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
330 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
|
331 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
332 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
333 } |
683
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 D visit(VariablesDeclaration vd) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
336 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
337 // Error if we are in an interface. |
692
d33895f679eb
Tidied up the class Scope a bit.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
690
diff
changeset
|
338 if (scop.symbol.isInterface) |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
339 return error(vd.begin, MSG.InterfaceCantHaveVariables), vd; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
340 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
341 // Insert variable symbols in this declaration into the symbol table. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
342 foreach (name; vd.names) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
343 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
344 auto variable = new Variable(name, protection, storageClass, linkageType, vd); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
345 vd.variables ~= variable; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
346 insert(variable, name); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
347 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
348 return vd; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
349 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
350 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
351 D visit(InvariantDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
352 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
353 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
|
354 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
355 return d; |
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 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
358 D visit(UnittestDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
359 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
360 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
|
361 insertOverload(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
362 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
363 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
364 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
365 D visit(DebugDeclaration) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
366 { return null; } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
367 D visit(VersionDeclaration) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
368 { return null; } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
369 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
370 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
|
371 { |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
372 if (d.symbol) |
641
3569c2fc6124
Fixed some return statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
636
diff
changeset
|
373 return d; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
374 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
|
375 // Insert into current scope. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
376 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
|
377 enterScope(d.symbol); |
635 | 378 // Continue semantic analysis. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
379 visitD(d.decls); |
636
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
380 exitScope(); |
15a0f37caabe
Added more visit() methods to dil.semantic.SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
381 return d; |
635 | 382 } |
383 | |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
384 D visit(NewDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
385 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
386 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
|
387 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
388 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
389 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
390 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
391 D visit(DeleteDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
392 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
393 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
|
394 insert(func, func.name); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
395 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
396 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
397 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
398 D visit(ProtectionDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
399 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
400 auto saved = protection; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
401 protection = d.prot; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
402 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
403 protection = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
404 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
405 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
406 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
407 D visit(StorageClassDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
408 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
409 auto saved = storageClass; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
410 storageClass = d.storageClass; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
411 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
412 storageClass = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
413 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
414 } |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
415 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
416 D visit(LinkageDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
417 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
418 auto saved = linkageType; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
419 linkageType = d.linkageType; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
420 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
421 linkageType = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
422 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
423 } |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
424 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
425 D visit(AlignDeclaration d) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
426 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
427 auto saved = alignSize; // Save. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
428 alignSize = d.size; // Set. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
429 visitD(d.decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
430 alignSize = saved; // Restore. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
431 return d; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
432 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
433 |
713
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
434 // Deferred declarations: |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
435 |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
436 D visit(StaticAssertDeclaration d) |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
437 { |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
438 addDeferred(d); |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
439 return d; |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
440 } |
1bfae3480fdc
Added new predefined IDs and code to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
441 |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
442 D visit(StaticIfDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
443 { |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
444 addDeferred(d); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
445 return d; |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
446 } |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
447 |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
448 D visit(MixinDeclaration d) |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
449 { |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
450 addDeferred(d); |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
451 return d; |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
452 } |
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
453 |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
454 D visit(PragmaDeclaration d) |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
455 { |
690
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
456 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
|
457 addDeferred(d); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
458 else |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
459 { |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
460 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
|
461 visitD(d.decls); |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
462 } |
eaf6444b6284
Adding pragma(msg,...) declarations to deferred list.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
686
diff
changeset
|
463 return d; |
648
4ae7b13aaac8
Moved some semantic() methods to SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
646
diff
changeset
|
464 } |
635 | 465 } // override |
466 } |