annotate dmd/ScopeDsymbol.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents e3afd1303184
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.ScopeDsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 79
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Declaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.OverloadSet;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Import;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.DsymbolTable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.PROT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.expression.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
19 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
20
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
21 import std.stdio : writef;
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
22 //core.stdc.stdlib;
4
d706d958e4e8 Step 2 of restoring GC functionality.
korDen
parents: 2
diff changeset
23 import core.memory;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 class ScopeDsymbol : Dsymbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
27 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
28
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
29 Dsymbols members; // all Dsymbol's in this scope
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 DsymbolTable symtab; // members[] sorted into table
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 Array imports; // imported ScopeDsymbol's
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 PROT* prots; // array of PROT, one for each import
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
37 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 // do nothing
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 this(Identifier id)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
43 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 super(id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
47 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
49 //printf("ScopeDsymbol.syntaxCopy('%s')\n", toChars());
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
50
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
51 ScopeDsymbol sd;
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
52 if (s)
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
53 sd = cast(ScopeDsymbol)s;
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
54 else
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
55 sd = new ScopeDsymbol(ident);
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
56 sd.members = arraySyntaxCopy(members);
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
57 return sd;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
60 override Dsymbol search(Loc loc, Identifier ident, int flags)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 //printf("%s.ScopeDsymbol.search(ident='%s', flags=x%x)\n", toChars(), ident.toChars(), flags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 //if (strcmp(ident.toChars(),"c") == 0) *(char*)0=0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 // Look in symbols declared in this module
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 Dsymbol s = symtab ? symtab.lookup(ident) : null;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
67 // writef("\ts = %p, imports = %p, %d\n", s, imports, imports ? imports->dim : 0);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 //printf("\ts = '%s.%s'\n",toChars(),s.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 else if (imports)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 OverloadSet a = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 // Look in imported modules
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 for (int i = 0; i < imports.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 ScopeDsymbol ss = cast(ScopeDsymbol)imports.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 Dsymbol s2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 // If private import, don't search it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 if (flags & 1 && prots[i] == PROT.PROTprivate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 //printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss.toChars(), prots[i], ss.isModule(), ss.isImport());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 /* Don't find private members if ss is a module
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 s2 = ss.search(loc, ident, ss.isModule() ? 1 : 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 if (!s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 s = s2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 else if (s2 && s != s2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 if (s.toAlias() == s2.toAlias())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 /* After following aliases, we found the same symbol,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 * so it's not an ambiguity.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 * But if one alias is deprecated, prefer the other.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 if (s.isDeprecated())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 s = s2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 /* Two imports of the same module should be regarded as
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 * the same.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 Import i1 = s.isImport();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 Import i2 = s2.isImport();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 if (!(i1 && i2 &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 (i1.mod == i2.mod ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 (!i1.parent.isImport() && !i2.parent.isImport() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 i1.ident.equals(i2.ident))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /* If both s2 and s are overloadable (though we only
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 * need to check s once)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 if (s2.isOverloadable() && (a || s.isOverloadable()))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 { if (!a)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 a = new OverloadSet();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 /* Don't add to a[] if s2 is alias of previous sym
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 */
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 74
diff changeset
126 foreach (size_t j, Dsymbol s3; a.a)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 if (s2.toAlias() == s3.toAlias())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 if (s3.isDeprecated())
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
131 a.a[j] = s2;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 goto Lcontinue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 a.push(s2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 Lcontinue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 if (flags & 4) // if return null on ambiguity
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 if (!(flags & 2))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 ss.multiplyDefined(loc, s, s2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 /* Build special symbol if we had multiple finds
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 if (a)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 assert(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 a.push(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 s = a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 Declaration d = s.isDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 if (d && d.protection == PROT.PROTprivate && !d.parent.isTemplateMixin() && !(flags & 2))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 error("%s is private", d.toPrettyChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 void importScope(ScopeDsymbol s, PROT protection)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
170 //writef("%s.ScopeDsymbol.importScope(%s, %d)\n", toChars(), s.toChars(), protection);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 // No circular or redundant import's
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
173 if (s !is this)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 if (!imports)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 imports = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 for (int i = 0; i < imports.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 ScopeDsymbol ss = cast(ScopeDsymbol)imports.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 if (ss is s) // if already imported
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (protection > prots[i])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 prots[i] = protection; // upgrade access
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 imports.push(cast(void*)s);
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
191 prots = cast(PROT*)GC.realloc(prots, imports.dim * prots[0].sizeof);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 prots[imports.dim - 1] = protection;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
196 override int isforwardRef()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
198 return (members is null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
201 override void defineRef(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
203 ScopeDsymbol ss = s.isScopeDsymbol();
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
204 members = ss.members;
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
205 ss.members = null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 static void multiplyDefined(Loc loc, Dsymbol s1, Dsymbol s2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 printf("ScopeDsymbol::multiplyDefined()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 printf("s1 = %p, '%s' kind = '%s', parent = %s\n", s1, s1.toChars(), s1.kind(), s1.parent ? s1.parent.toChars() : "");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 printf("s2 = %p, '%s' kind = '%s', parent = %s\n", s2, s2.toChars(), s2.kind(), s2.parent ? s2.parent.toChars() : "");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 if (loc.filename)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 .error(loc, "%s at %s conflicts with %s at %s",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 s1.toPrettyChars(),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 s1.locToChars(),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 s2.toPrettyChars(),
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 s2.locToChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 s1.error(loc, "conflicts with %s %s at %s", s2.kind(), s2.toPrettyChars(), s2.locToChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 Dsymbol nameCollision(Dsymbol s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
234 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
239 version(DMDV2)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
240 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 /*******************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 * Look for member of the form:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 * const(MemberInfo)[] getMembers(string);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 * Returns NULL if not found
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 FuncDeclaration findGetMembers()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 Dsymbol s = search_function(this, Id.getmembers);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 FuncDeclaration fdx = s ? s.isFuncDeclaration() : null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 static if (false) { // Finish
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 static __gshared TypeFunction tfgetmembers;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 if (!tfgetmembers)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 Scope sc;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
257 auto arguments = new Arguments();
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
258 auto arg = new Argument(STCin, Type.tchar.constOf().arrayOf(), null, null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 arguments.push(arg);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 Type tret = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 tfgetmembers = new TypeFunction(arguments, tret, 0, LINK.LINKd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 tfgetmembers = cast(TypeFunction)tfgetmembers.semantic(0, &sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 if (fdx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 fdx = fdx.overloadExactMatch(tfgetmembers);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 if (fdx && fdx.isVirtual()) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 fdx = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 return fdx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
274 }
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
275
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
276 Dsymbol symtabInsert(Dsymbol s)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
277 {
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
278 return symtab.insert(s);
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
279 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 void emitMemberComments(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
286 version(DMDV2)
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
287 {
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
288 static size_t dim(Dsymbols members)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
292
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
293
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
294 static Dsymbol getNth(Dsymbols members, size_t nth, size_t* pn = null)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 77
diff changeset
298 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 20
diff changeset
299 override ScopeDsymbol isScopeDsymbol() { return this; }
20
1628b221808d Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
300 }