annotate src/dil/semantic/Pass1.d @ 832:80eb3251e010

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