annotate dmd/ScopeDsymbol.d @ 79:43073c7c7769

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