Mercurial > projects > dil
annotate src/dil/semantic/Symbols.d @ 820:1d06b4aed7cf
Revised code in the first pass.
Added code to handle anonymous unions and structs. Hope the idea will work.
Added type to class Aggregate and isAnonymous to some other Symbol classes.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 14 Mar 2008 15:42:08 +0100 |
parents | bcb74c9b895c |
children |
rev | line source |
---|---|
517 | 1 /++ |
2 Author: Aziz Köksal | |
3 License: GPL3 | |
4 +/ | |
590
641041912670
Moved dil.Symbols to dil.semantic.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
589
diff
changeset
|
5 module dil.semantic.Symbols; |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
6 |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
7 import dil.ast.Expression; |
589
de365ddcfbd4
Moved dil.Symbol to dil.semantic.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
584
diff
changeset
|
8 import dil.semantic.Symbol; |
591
26addda6365b
Moved dil.SymbolTable to dil.semantic.SymbolTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
590
diff
changeset
|
9 import dil.semantic.SymbolTable; |
600
041eae272362
Moved dil.Identifier to dil.lexer.Identifier.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
591
diff
changeset
|
10 import dil.semantic.Types; |
580
fa6d3c52757d
Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
573
diff
changeset
|
11 import dil.ast.Node; |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
12 import dil.lexer.IdTable; |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
13 import dil.Enums; |
517 | 14 import common; |
15 | |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
16 /// A symbol that has its own scope with a symbol table. |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
17 class ScopeSymbol : Symbol |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
18 { |
614 | 19 SymbolTable symbolTable; /// The symbol table. |
20 Symbol[] members; /// The member symbols (in lexical order.) | |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
21 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
22 this(SYM sid, Identifier* name, Node node) |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
23 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
24 super(sid, name, node); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
25 } |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
26 |
747
00f872d949ea
Added method scanCommentText() to DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
27 /// Look up name in the table. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
28 Symbol lookup(Identifier* name) |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
29 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
30 return symbolTable.lookup(name); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
31 } |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
32 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
33 /// Look up name in the table. |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
34 Symbol lookup(string name) |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
35 { |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
36 auto id = IdTable.lookup(name); |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
37 return id ? symbolTable.lookup(id) : null; |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
38 } |
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
747
diff
changeset
|
39 |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
40 /// Insert a symbol into the table. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
41 void insert(Symbol s, Identifier* name) |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
42 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
43 symbolTable.insert(s, name); |
614 | 44 members ~= s; |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
45 } |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
46 } |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
47 |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
48 /// Aggregates have function and field members. |
615
a05457530ac2
Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
614
diff
changeset
|
49 abstract class Aggregate : ScopeSymbol |
517 | 50 { |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
51 Type type; |
517 | 52 Function[] funcs; |
53 Variable[] fields; | |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
54 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
55 this(SYM sid, Identifier* name, Node node) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
56 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
57 super(sid, name, node); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
58 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
59 |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
60 override void insert(Symbol s, Identifier* ident) |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
61 { |
567
ab9f5020cd02
Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
62 if (s.isVariable) |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
63 // Append variable to fields. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
64 fields ~= cast(Variable)cast(void*)s; |
567
ab9f5020cd02
Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
65 else if (s.isFunction) |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
66 // Append function to funcs. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
67 funcs ~= cast(Function)cast(void*)s; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
68 super.insert(s, ident); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
561
diff
changeset
|
69 } |
517 | 70 } |
71 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
72 /// A class symbol. |
517 | 73 class Class : Aggregate |
74 { | |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
75 this(Identifier* name, Node classNode) |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
76 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
77 super(SYM.Class, name, classNode); |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
78 this.type = new TypeClass(this); |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
79 } |
517 | 80 } |
81 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
82 /// An interface symbol. |
561
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
83 class Interface : Aggregate |
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
84 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
85 this(Identifier* name, Node interfaceNode) |
561
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
86 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
87 super(SYM.Interface, name, interfaceNode); |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
88 this.type = new TypeClass(this); |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
89 } |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
90 } |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
91 |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
92 /// A struct symbol. |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
93 class Struct : Aggregate |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
94 { |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
95 bool isAnonymous; |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
96 this(Identifier* name, Node structNode) |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
97 { |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
98 super(SYM.Struct, name, structNode); |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
99 this.type = new TypeStruct(this); |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
100 this.isAnonymous = name is null; |
561
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
101 } |
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
102 } |
302e50e71ec2
Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
560
diff
changeset
|
103 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
104 /// A union symbol. |
517 | 105 class Union : Aggregate |
106 { | |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
107 bool isAnonymous; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
108 this(Identifier* name, Node unionNode) |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
109 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
110 super(SYM.Union, name, unionNode); |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
111 this.type = new TypeStruct(this); |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
112 this.isAnonymous = name is null; |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
113 } |
517 | 114 } |
115 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
116 /// An enum symbol. |
614 | 117 class Enum : ScopeSymbol |
118 { | |
688
839c0c61af2b
Renamed some semantic types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
119 TypeEnum type; |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
120 bool isAnonymous; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
121 this(Identifier* name, Node enumNode) |
614 | 122 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
123 super(SYM.Enum, name, enumNode); |
820
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
124 this.type = new TypeEnum(this); |
1d06b4aed7cf
Revised code in the first pass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
125 this.isAnonymous = name is null; |
614 | 126 } |
617
0749f30ef2d0
Added member 'EnumType type' to class Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
615
diff
changeset
|
127 |
688
839c0c61af2b
Renamed some semantic types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
128 void setType(TypeEnum type) |
617
0749f30ef2d0
Added member 'EnumType type' to class Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
615
diff
changeset
|
129 { |
0749f30ef2d0
Added member 'EnumType type' to class Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
615
diff
changeset
|
130 this.type = type; |
0749f30ef2d0
Added member 'EnumType type' to class Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
615
diff
changeset
|
131 } |
614 | 132 } |
133 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
134 /// A template symbol. |
623
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
135 class Template : ScopeSymbol |
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
136 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
137 this(Identifier* name, Node templateNode) |
623
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
138 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
139 super(SYM.Template, name, templateNode); |
623
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
140 } |
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
141 } |
e2cd28cfc6ae
Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
617
diff
changeset
|
142 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
143 /// A function symbol. |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
144 class Function : ScopeSymbol |
517 | 145 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
146 Protection prot; /// The protection. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
147 StorageClass stc; /// The storage classes. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
148 LinkageType linkType; /// The linkage type. |
517 | 149 |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
150 Type returnType; |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
151 Variable[] params; |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
152 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
153 this(Identifier* name, Node functionNode) |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
154 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
155 super(SYM.Function, name, functionNode); |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
156 } |
517 | 157 } |
158 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
159 /// A variable symbol. |
517 | 160 class Variable : Symbol |
161 { | |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
162 Protection prot; /// The protection. |
615
a05457530ac2
Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
614
diff
changeset
|
163 StorageClass stc; /// The storage classes. |
a05457530ac2
Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
614
diff
changeset
|
164 LinkageType linkType; /// The linkage type. |
517 | 165 |
615
a05457530ac2
Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
614
diff
changeset
|
166 Type type; /// The type of this variable. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
167 Expression value; /// The value of this variable. |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
168 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
169 this(Identifier* name, |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
170 Protection prot, StorageClass stc, LinkageType linkType, |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
171 Node variableNode) |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
172 { |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
173 super(SYM.Variable, name, variableNode); |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
174 |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
175 this.prot = prot; |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
176 this.stc = stc; |
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
177 this.linkType = linkType; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
178 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
179 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
180 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
181 /// An enum member symbol. |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
182 class EnumMember : Variable |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
183 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
184 this(Identifier* name, |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
185 Protection prot, StorageClass stc, LinkageType linkType, |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
186 Node enumMemberNode) |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
187 { |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
188 super(name, prot, stc, linkType, enumMemberNode); |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
189 this.sid = SYM.EnumMember; |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
190 } |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
191 } |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
688
diff
changeset
|
192 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
193 /// An alias symbol. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
194 class Alias : Symbol |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
195 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
196 this(Identifier* name, Node aliasNode) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
197 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
198 super(SYM.Alias, name, aliasNode); |
560
709e223a8eb9
Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
517
diff
changeset
|
199 } |
517 | 200 } |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
201 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
202 /// A list of symbols that share the same identifier. |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
203 /// |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
204 /// These can be functions, templates and aggregates with template parameter lists. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
205 class OverloadSet : Symbol |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
206 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
207 Symbol[] symbols; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
208 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
209 this(Identifier* name, Node node) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
210 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
211 super(SYM.OverloadSet, name, node); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
212 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
213 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
214 void add(Symbol s) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
215 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
216 symbols ~= s; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
217 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
623
diff
changeset
|
218 } |