annotate dmd/TypeQualified.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents af1bebfd96a4
children b0d41ff5e0df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeQualified;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 73
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Import;
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
6 import dmd.DsymbolExp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TypeExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.DotIdExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.EnumMember;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.TupleDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TemplateInstance;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.DYNCAST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.Expression;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
25 import dmd.FuncDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 class TypeQualified : Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 Loc loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 Array idents; // array of Identifier's representing ident.ident.ident etc.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 this(TY ty, Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 135
diff changeset
35 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 super(ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 this.loc = loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 idents = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 void syntaxCopyHelper(TypeQualified t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 //printf("TypeQualified::syntaxCopyHelper(%s) %s\n", t->toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 idents.setDim(t.idents.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 for (int i = 0; i < idents.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
52
69d078c417c6 Identifier <-> TemplateInstance casts workaround
korDen
parents: 0
diff changeset
48 Object o = cast(Object)t.idents.data[i];
69d078c417c6 Identifier <-> TemplateInstance casts workaround
korDen
parents: 0
diff changeset
49 if (TemplateInstance ti = cast(TemplateInstance)o)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 {
52
69d078c417c6 Identifier <-> TemplateInstance casts workaround
korDen
parents: 0
diff changeset
51 o = ti.syntaxCopy(null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
52
69d078c417c6 Identifier <-> TemplateInstance casts workaround
korDen
parents: 0
diff changeset
54 idents.data[i] = cast(void*)o;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
52
69d078c417c6 Identifier <-> TemplateInstance casts workaround
korDen
parents: 0
diff changeset
58 void addIdent(Object ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
56
51605de93870 TupleExp.optimize
korDen
parents: 52
diff changeset
60 assert(ident !is null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 idents.push(cast(void*)ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 void toCBuffer2Helper(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 for (i = 0; i < idents.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Identifier id = cast(Identifier)idents.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 buf.writeByte('.');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (id.dyncast() == DYNCAST.DYNCAST_DSYMBOL)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 TemplateInstance ti = cast(TemplateInstance)id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 ti.toCBuffer(buf, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 buf.writestring(id.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 56
diff changeset
83 override ulong size(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 * Takes an array of Identifiers and figures out if
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 * it represents a Type or an Expression.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 * Output:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 * if expression, *pe is set
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 * if type, *pt is set
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 void resolveHelper(Loc loc, Scope sc, Dsymbol s, Dsymbol scopesym, Expression* pe, Type* pt, Dsymbol* ps)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 VarDeclaration v;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
98 FuncDeclaration fd;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 EnumMember em;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 TupleDeclaration td;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 printf("TypeQualified.resolveHelper(sc = %p, idents = '%s')\n", sc, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 if (scopesym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 printf("\tscopesym = '%s'\n", scopesym.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 *pe = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 *pt = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 *ps = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 if (s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 //printf("\t1: s = '%s' %p, kind = '%s'\n",s.toChars(), s, s.kind());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 s.checkDeprecated(loc, sc); // check for deprecated aliases
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 s = s.toAlias();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 //printf("\t2: s = '%s' %p, kind = '%s'\n",s.toChars(), s, s.kind());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 for (int i = 0; i < idents.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 {
56
51605de93870 TupleExp.optimize
korDen
parents: 52
diff changeset
119 Object o = cast(Object)idents.data[i];
51605de93870 TupleExp.optimize
korDen
parents: 52
diff changeset
120
51605de93870 TupleExp.optimize
korDen
parents: 52
diff changeset
121 Dsymbol sm = s.searchX(loc, sc, o);
51605de93870 TupleExp.optimize
korDen
parents: 52
diff changeset
122 Identifier id = cast(Identifier)o;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 //printf("\t3: s = '%s' %p, kind = '%s'\n",s.toChars(), s, s.kind());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 //printf("\tgetType = '%s'\n", s.getType().toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 if (!sm)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 v = s.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 if (v && id == Id.length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 e = v.getConstInitializer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 if (!e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 e = new VarExp(loc, v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 t = e.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 if (!t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 }
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
140 else if (v && id == Id.stringof_)
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
141 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
142 e = new DsymbolExp(loc, s, 0);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
143 do
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
144 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
145 id = cast(Identifier)idents.data[i];
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
146 e = new DotIdExp(loc, e, id);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
147 } while (++i < idents.dim);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
148 e = e.semantic(sc);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
149 *pe = e;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
150 return;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
151 }
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
152
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 t = s.getType();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if (!t && s.isDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 t = s.isDeclaration().type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 if (t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 sm = t.toDsymbol(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 if (sm)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 { sm = sm.search(loc, id, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 if (sm)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 //e = t.getProperty(loc, id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 e = new TypeExp(loc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 e = t.dotExp(sc, e, id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 i++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 L3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 for (; i < idents.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 id = cast(Identifier)idents.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 //printf("e: '%s', id: '%s', type = %p\n", e.toChars(), id.toChars(), e.type);
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
173 if (id == Id.offsetof || !e.type)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 { e = new DotIdExp(e.loc, e, id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 e = e.type.dotExp(sc, e, id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 *pe = e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 Lerror:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 error(loc, "identifier '%s' of '%s' is not defined", id.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 L2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 s = sm.toAlias();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 v = s.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
194 *pe = new VarExp(loc, v);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 }
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
197 //#if 0
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
198 // fd = s->isFuncDeclaration();
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
199 // if (fd)
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
200 // {
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
201 // *pe = new DsymbolExp(loc, fd, 1);
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
202 // return;
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
203 // }
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
204 //#endif
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 em = s.isEnumMember();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 if (em)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 // It's not a type, it's an expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 *pe = em.value.copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 Type t = s.getType();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 if (!t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 // If the symbol is an import, try looking inside the import
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 Import si;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 si = s.isImport();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 if (si)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 s = si.search(loc, s.ident, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 if (s && s != si)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 s = si;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 *ps = s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 if (t.ty == TY.Tinstance && t != this && !t.deco)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 error(loc, "forward reference to '%s'", t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 if (t != this)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 if (t.reliesOnTident())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 {
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
241 if (s.scope_)
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
242 t = t.semantic(loc, s.scope_);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
243 else
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 {
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
245 /* Attempt to find correct scope in which to evaluate t.
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
246 * Not sure if this is right or not, or if we should just
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
247 * give forward reference error if s.scope is not set.
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
248 */
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
249 for (Scope scx = sc; 1; scx = scx.enclosing)
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
250 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
251 if (!scx)
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
252 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
253 error(loc, "forward reference to '%s'", t.toChars());
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
254 return;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
255 }
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
256 if (scx.scopesym == scopesym)
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
257 {
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
258 t = t.semantic(loc, scx);
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
259 break;
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
260 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 }
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
263
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 if (t.ty == TY.Ttuple)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 *pt = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 *pt = t.merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 if (!s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 error(loc, "identifier '%s' is not defined", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 56
diff changeset
276 }