annotate dmd/SymOffExp.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 cd48cb899aee
children eb38fdcb3e62
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
1 module dmd.SymOffExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 108
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
4 import dmd.Expression;
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
5 import dmd.GlobalExpressions;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
6 import dmd.Declaration;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
7 import dmd.MATCH;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
8 import dmd.Type;
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
9 import dmd.InterState;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
10 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
11 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
12 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
13 import dmd.InlineDoState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
14 import dmd.HdrGenState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
15 import dmd.backend.dt_t;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.SymbolExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.DelegateExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.ThisExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.ErrorExp;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
23 import dmd.TY;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.TOK;
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
25 import dmd.STC;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.backend.TYM;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
30
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
31 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
32
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 class SymOffExp : SymbolExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
35 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
36
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 uint offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
39 this(Loc loc, Declaration var, uint offset, bool hasOverloads = false)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
41 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 super(loc, TOK.TOKsymoff, SymOffExp.sizeof, var, hasOverloads);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 this.offset = offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 VarDeclaration v = var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 if (v && v.needThis())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 error("need 'this' for address of %s", v.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
50 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 version(LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 printf("SymOffExp::semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 //var.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 type = var.type.pointerTo();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 VarDeclaration v = var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 v.checkNestedReference(sc, loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
63
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
64 Expression interpret(InterState istate)
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
65 {
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
66 version (LOG) {
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
67 writef("SymOffExp::interpret() %s\n", toChars());
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
68 }
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
69 if (var.isFuncDeclaration() && offset == 0)
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
70 {
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
71 return this;
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
72 }
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
73 error("Cannot interpret %s at compile time", toChars());
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
74 return EXP_CANT_INTERPRET;
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
75
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
76 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
78 override void checkEscape()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 VarDeclaration v = var.isVarDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 if (v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 {
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
83 if (!v.isDataseg() && !(v.storage_class & (STC.STCref | STC.STCout)))
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
84 { /* BUG: This should be allowed:
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
85 * void foo()
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
86 * { int a;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
87 * int* bar() { return &a; }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
88 * }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
89 */
135
af1bebfd96a4 dmd 2.038
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
90 error("escaping reference to local %s", v.toChars());
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 129
diff changeset
91 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
95 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
97 if (offset)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
98 buf.printf("(& %s+%s)", var.toChars(), offset); ///
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
99 else
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 135
diff changeset
100 buf.printf("& %s", var.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
103 override int isConst()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 return 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
108 override bool isBool(bool result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 114
diff changeset
110 return result;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
113 override Expression doInline(InlineDoState ids)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 //printf("SymOffExp.doInline(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 for (i = 0; i < ids.from.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 if (var is cast(Declaration)ids.from.data[i])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 SymOffExp se = cast(SymOffExp)copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 se.var = cast(Declaration)ids.to.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 return se;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
131 override MATCH implicitConvTo(Type t)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 printf("SymOffExp::implicitConvTo(this=%s, type=%s, t=%s)\n", toChars(), type.toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 MATCH result = type.implicitConvTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 //printf("\tresult = %d\n", result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 if (result == MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 // Look for pointers to functions where the functions are overloaded.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 FuncDeclaration f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 t = t.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 if (type.ty == Tpointer && type.nextOf().ty == Tfunction &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 (t.ty == Tpointer || t.ty == Tdelegate) && t.nextOf().ty == Tfunction)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 f = var.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 f = f.overloadExactMatch(t.nextOf());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 if ((t.ty == Tdelegate && (f.needThis() || f.isNested())) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 (t.ty == Tpointer && !(f.needThis() || f.isNested())))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 result = MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 //printf("\tresult = %d\n", result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 return result;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
167 override Expression castTo(Scope sc, Type t)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 printf("SymOffExp::castTo(this=%s, type=%s, t=%s)\n", toChars(), type.toChars(), t.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
172 if (type == t && !hasOverloads)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 Type tb = t.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 Type typeb = type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 if (tb != typeb)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 // Look for pointers to functions where the functions are overloaded.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 FuncDeclaration f;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (hasOverloads &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 typeb.ty == Tpointer && typeb.nextOf().ty == Tfunction &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 (tb.ty == Tpointer || tb.ty == Tdelegate) && tb.nextOf().ty == Tfunction)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 f = var.isFuncDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 f = f.overloadExactMatch(tb.nextOf());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 if (tb.ty == Tdelegate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 if (f.needThis() && hasThis(sc))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 e = new DelegateExp(loc, new ThisExp(loc), f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 else if (f.isNested())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 e = new DelegateExp(loc, new IntegerExp(0), f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 else if (f.needThis())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 error("no 'this' to create delegate for %s", f.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 error("cannot cast from function pointer to delegate");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 e = new ErrorExp();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 e = new SymOffExp(loc, f, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 f.tookAddressOf++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 return e;
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 e = Expression.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 e = copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 e.type = t;
73
ef02e2e203c2 Updating to dmd2.033
korDen
parents: 72
diff changeset
235 (cast(SymOffExp)e).hasOverloads = false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
240 override void scanForNestedRef(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
242 //printf("SymOffExp.scanForNestedRef(%s)\n", toChars());
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
243 VarDeclaration v = var.isVarDeclaration();
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
244 if (v)
64
4290d870944a More fixes
korDen
parents: 0
diff changeset
245 v.checkNestedReference(sc, Loc(0));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
248 override dt_t** toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 //printf("SymOffExp.toDt('%s')\n", var.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 assert(var);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 if (!(var.isDataseg() || var.isCodeseg()) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 var.needThis() ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 var.isThreadlocal()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 debug writef("SymOffExp.toDt()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 error("non-constant expression %s", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 Symbol* s = var.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 return dtxoff(pdt, s, offset, TYnptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
108
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
265
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
266 static if (false)
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
267 {
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
268 override elem* toElem(IRState* irs)
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
269 {
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
270 assert(false); // this function is #if 0'ed out in dmd
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
271 }
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 73
diff changeset
272 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274