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