Mercurial > projects > ldc
annotate dmd/expression.h @ 932:5e3bb0c3ea8b
Fixed dstress/run/a/array_initialization_17_A.d regression. default initialized static array elements in a constant static array initializer was getting incorrect values.
Fixed minor version problem in mini/naked_asm4.d test case.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Feb 2009 23:48:47 +0100 |
parents | 27a379f288bf |
children | b30fe7e1dbb9 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
336 | 3 // Copyright (c) 1999-2008 by Digital Mars |
159 | 4 // All Rights Reserved |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_EXPRESSION_H | |
12 #define DMD_EXPRESSION_H | |
13 | |
14 #include "mars.h" | |
15 #include "identifier.h" | |
16 #include "lexer.h" | |
17 #include "arraytypes.h" | |
18 | |
19 struct Type; | |
20 struct Scope; | |
21 struct TupleDeclaration; | |
22 struct VarDeclaration; | |
23 struct FuncDeclaration; | |
24 struct FuncLiteralDeclaration; | |
25 struct Declaration; | |
26 struct CtorDeclaration; | |
27 struct NewDeclaration; | |
28 struct Dsymbol; | |
29 struct Import; | |
30 struct Module; | |
31 struct ScopeDsymbol; | |
32 struct InlineCostState; | |
33 struct InlineDoState; | |
34 struct InlineScanState; | |
35 struct Expression; | |
36 struct Declaration; | |
37 struct AggregateDeclaration; | |
38 struct StructDeclaration; | |
39 struct TemplateInstance; | |
40 struct TemplateDeclaration; | |
41 struct ClassDeclaration; | |
42 struct HdrGenState; | |
43 struct BinExp; | |
44 struct InterState; | |
45 struct Symbol; // back end symbol | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
46 struct OverloadSet; |
159 | 47 namespace llvm |
48 { | |
49 class Constant; | |
50 class ConstantInt; | |
51 } | |
52 | |
53 enum TOK; | |
54 | |
55 // Back end | |
56 struct IRState; | |
57 struct dt_t; | |
58 | |
59 #if IN_LLVM | |
60 struct DValue; | |
61 typedef DValue elem; | |
62 #else | |
63 #ifdef IN_GCC | |
64 union tree_node; typedef union tree_node elem; | |
65 #else | |
66 struct elem; | |
67 #endif | |
68 #endif | |
69 | |
70 void initPrecedence(); | |
71 | |
72 Expression *resolveProperties(Scope *sc, Expression *e); | |
73 void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d); | |
74 Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid); | |
75 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr); | |
76 void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs); | |
77 void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs); | |
78 void expandTuples(Expressions *exps); | |
79 FuncDeclaration *hasThis(Scope *sc); | |
80 Expression *fromConstInitializer(int result, Expression *e); | |
81 | |
82 struct Expression : Object | |
83 { | |
84 Loc loc; // file location | |
85 enum TOK op; // handy to minimize use of dynamic_cast | |
86 Type *type; // !=NULL means that semantic() has been run | |
87 int size; // # of bytes in Expression so we can copy() it | |
88 | |
89 Expression(Loc loc, enum TOK op, int size); | |
90 Expression *copy(); | |
91 virtual Expression *syntaxCopy(); | |
92 virtual Expression *semantic(Scope *sc); | |
93 | |
94 int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression() | |
95 | |
96 void print(); | |
97 char *toChars(); | |
98 virtual void dump(int indent); | |
99 void error(const char *format, ...); | |
100 virtual void rvalue(); | |
101 | |
102 static Expression *combine(Expression *e1, Expression *e2); | |
103 static Expressions *arraySyntaxCopy(Expressions *exps); | |
104 | |
105 virtual integer_t toInteger(); | |
106 virtual uinteger_t toUInteger(); | |
107 virtual real_t toReal(); | |
108 virtual real_t toImaginary(); | |
109 virtual complex_t toComplex(); | |
110 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
111 virtual void toMangleBuffer(OutBuffer *buf); | |
112 virtual Expression *toLvalue(Scope *sc, Expression *e); | |
113 virtual Expression *modifiableLvalue(Scope *sc, Expression *e); | |
114 Expression *implicitCastTo(Scope *sc, Type *t); | |
115 virtual MATCH implicitConvTo(Type *t); | |
116 virtual Expression *castTo(Scope *sc, Type *t); | |
117 virtual void checkEscape(); | |
118 void checkScalar(); | |
119 void checkNoBool(); | |
120 Expression *checkIntegral(); | |
121 Expression *checkArithmetic(); | |
122 void checkDeprecated(Scope *sc, Dsymbol *s); | |
123 virtual Expression *checkToBoolean(); | |
124 Expression *checkToPointer(); | |
125 Expression *addressOf(Scope *sc); | |
126 Expression *deref(); | |
127 Expression *integralPromotions(Scope *sc); | |
128 | |
129 Expression *toDelegate(Scope *sc, Type *t); | |
130 virtual void scanForNestedRef(Scope *sc); | |
131 | |
132 virtual Expression *optimize(int result); | |
133 #define WANTflags 1 | |
134 #define WANTvalue 2 | |
135 #define WANTinterpret 4 | |
136 | |
137 virtual Expression *interpret(InterState *istate); | |
138 | |
139 virtual int isConst(); | |
140 virtual int isBool(int result); | |
141 virtual int isBit(); | |
142 virtual int checkSideEffect(int flag); | |
336 | 143 virtual int canThrow(); |
159 | 144 |
145 virtual int inlineCost(InlineCostState *ics); | |
146 virtual Expression *doInline(InlineDoState *ids); | |
147 virtual Expression *inlineScan(InlineScanState *iss); | |
148 | |
149 // For operator overloading | |
150 virtual int isCommutative(); | |
151 virtual Identifier *opId(); | |
152 virtual Identifier *opId_r(); | |
153 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
154 // For array ops |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
155 virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
156 virtual Expression *buildArrayLoop(Arguments *fparams); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
157 |
159 | 158 // Back end |
159 virtual elem *toElem(IRState *irs); | |
160 virtual dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
161 // LDC |
159 | 162 virtual llvm::Constant *toConstElem(IRState *irs); |
163 }; | |
164 | |
165 struct IntegerExp : Expression | |
166 { | |
167 integer_t value; | |
168 | |
169 IntegerExp(Loc loc, integer_t value, Type *type); | |
170 IntegerExp(integer_t value); | |
171 int equals(Object *o); | |
172 Expression *semantic(Scope *sc); | |
173 Expression *interpret(InterState *istate); | |
174 char *toChars(); | |
175 void dump(int indent); | |
176 integer_t toInteger(); | |
177 real_t toReal(); | |
178 real_t toImaginary(); | |
179 complex_t toComplex(); | |
180 int isConst(); | |
181 int isBool(int result); | |
182 MATCH implicitConvTo(Type *t); | |
183 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
184 void toMangleBuffer(OutBuffer *buf); | |
185 Expression *toLvalue(Scope *sc, Expression *e); | |
186 elem *toElem(IRState *irs); | |
187 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
188 // LDC |
159 | 189 virtual llvm::Constant *toConstElem(IRState *irs); |
190 }; | |
191 | |
192 struct RealExp : Expression | |
193 { | |
194 real_t value; | |
195 | |
196 RealExp(Loc loc, real_t value, Type *type); | |
197 int equals(Object *o); | |
198 Expression *semantic(Scope *sc); | |
199 Expression *interpret(InterState *istate); | |
200 char *toChars(); | |
201 integer_t toInteger(); | |
202 uinteger_t toUInteger(); | |
203 real_t toReal(); | |
204 real_t toImaginary(); | |
205 complex_t toComplex(); | |
206 Expression *castTo(Scope *sc, Type *t); | |
207 int isConst(); | |
208 int isBool(int result); | |
209 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
210 void toMangleBuffer(OutBuffer *buf); | |
211 elem *toElem(IRState *irs); | |
212 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
213 // LDC |
159 | 214 virtual llvm::Constant *toConstElem(IRState *irs); |
215 }; | |
216 | |
217 struct ComplexExp : Expression | |
218 { | |
219 complex_t value; | |
220 | |
221 ComplexExp(Loc loc, complex_t value, Type *type); | |
222 int equals(Object *o); | |
223 Expression *semantic(Scope *sc); | |
224 Expression *interpret(InterState *istate); | |
225 char *toChars(); | |
226 integer_t toInteger(); | |
227 uinteger_t toUInteger(); | |
228 real_t toReal(); | |
229 real_t toImaginary(); | |
230 complex_t toComplex(); | |
231 Expression *castTo(Scope *sc, Type *t); | |
232 int isConst(); | |
233 int isBool(int result); | |
234 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
235 void toMangleBuffer(OutBuffer *buf); | |
236 #ifdef _DH | |
237 OutBuffer hexp; | |
238 #endif | |
239 elem *toElem(IRState *irs); | |
240 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
241 // LDC |
159 | 242 virtual llvm::Constant *toConstElem(IRState *irs); |
243 }; | |
244 | |
245 struct IdentifierExp : Expression | |
246 { | |
247 Identifier *ident; | |
248 Declaration *var; | |
249 | |
250 IdentifierExp(Loc loc, Identifier *ident); | |
251 IdentifierExp(Loc loc, Declaration *var); | |
252 Expression *semantic(Scope *sc); | |
253 char *toChars(); | |
254 void dump(int indent); | |
255 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
256 Expression *toLvalue(Scope *sc, Expression *e); | |
257 }; | |
258 | |
259 struct DollarExp : IdentifierExp | |
260 { | |
261 DollarExp(Loc loc); | |
262 }; | |
263 | |
264 struct DsymbolExp : Expression | |
265 { | |
266 Dsymbol *s; | |
267 | |
268 DsymbolExp(Loc loc, Dsymbol *s); | |
269 Expression *semantic(Scope *sc); | |
270 char *toChars(); | |
271 void dump(int indent); | |
272 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
273 Expression *toLvalue(Scope *sc, Expression *e); | |
274 }; | |
275 | |
276 struct ThisExp : Expression | |
277 { | |
278 Declaration *var; | |
279 | |
280 ThisExp(Loc loc); | |
281 Expression *semantic(Scope *sc); | |
282 int isBool(int result); | |
283 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
284 Expression *toLvalue(Scope *sc, Expression *e); | |
285 void scanForNestedRef(Scope *sc); | |
286 | |
287 int inlineCost(InlineCostState *ics); | |
288 Expression *doInline(InlineDoState *ids); | |
289 //Expression *inlineScan(InlineScanState *iss); | |
290 | |
291 elem *toElem(IRState *irs); | |
292 }; | |
293 | |
294 struct SuperExp : ThisExp | |
295 { | |
296 SuperExp(Loc loc); | |
297 Expression *semantic(Scope *sc); | |
298 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
299 void scanForNestedRef(Scope *sc); | |
300 | |
301 int inlineCost(InlineCostState *ics); | |
302 Expression *doInline(InlineDoState *ids); | |
303 //Expression *inlineScan(InlineScanState *iss); | |
304 }; | |
305 | |
306 struct NullExp : Expression | |
307 { | |
308 unsigned char committed; // !=0 if type is committed | |
309 | |
310 NullExp(Loc loc); | |
311 Expression *semantic(Scope *sc); | |
312 int isBool(int result); | |
313 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
314 void toMangleBuffer(OutBuffer *buf); | |
315 MATCH implicitConvTo(Type *t); | |
316 Expression *castTo(Scope *sc, Type *t); | |
317 Expression *interpret(InterState *istate); | |
318 elem *toElem(IRState *irs); | |
319 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
320 // LDC |
159 | 321 virtual llvm::Constant *toConstElem(IRState *irs); |
322 }; | |
323 | |
324 struct StringExp : Expression | |
325 { | |
326 void *string; // char, wchar, or dchar data | |
327 size_t len; // number of chars, wchars, or dchars | |
328 unsigned char sz; // 1: char, 2: wchar, 4: dchar | |
329 unsigned char committed; // !=0 if type is committed | |
330 unsigned char postfix; // 'c', 'w', 'd' | |
331 | |
332 StringExp(Loc loc, char *s); | |
333 StringExp(Loc loc, void *s, size_t len); | |
334 StringExp(Loc loc, void *s, size_t len, unsigned char postfix); | |
335 //Expression *syntaxCopy(); | |
336 int equals(Object *o); | |
337 char *toChars(); | |
338 Expression *semantic(Scope *sc); | |
339 Expression *interpret(InterState *istate); | |
340 StringExp *toUTF8(Scope *sc); | |
341 MATCH implicitConvTo(Type *t); | |
342 Expression *castTo(Scope *sc, Type *t); | |
343 int compare(Object *obj); | |
344 int isBool(int result); | |
345 unsigned charAt(size_t i); | |
346 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
347 void toMangleBuffer(OutBuffer *buf); | |
348 elem *toElem(IRState *irs); | |
349 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
350 // LDC |
159 | 351 virtual llvm::Constant *toConstElem(IRState *irs); |
352 }; | |
353 | |
354 // Tuple | |
355 | |
356 struct TupleExp : Expression | |
357 { | |
358 Expressions *exps; | |
359 | |
360 TupleExp(Loc loc, Expressions *exps); | |
361 TupleExp(Loc loc, TupleDeclaration *tup); | |
362 Expression *syntaxCopy(); | |
363 int equals(Object *o); | |
364 Expression *semantic(Scope *sc); | |
365 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
366 void scanForNestedRef(Scope *sc); | |
367 void checkEscape(); | |
368 int checkSideEffect(int flag); | |
369 Expression *optimize(int result); | |
370 Expression *interpret(InterState *istate); | |
371 Expression *castTo(Scope *sc, Type *t); | |
372 elem *toElem(IRState *irs); | |
373 | |
374 int inlineCost(InlineCostState *ics); | |
375 Expression *doInline(InlineDoState *ids); | |
376 Expression *inlineScan(InlineScanState *iss); | |
377 }; | |
378 | |
379 struct ArrayLiteralExp : Expression | |
380 { | |
381 Expressions *elements; | |
382 | |
383 ArrayLiteralExp(Loc loc, Expressions *elements); | |
384 ArrayLiteralExp(Loc loc, Expression *e); | |
385 | |
386 Expression *syntaxCopy(); | |
387 Expression *semantic(Scope *sc); | |
388 int isBool(int result); | |
389 elem *toElem(IRState *irs); | |
390 int checkSideEffect(int flag); | |
391 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
392 void toMangleBuffer(OutBuffer *buf); | |
393 void scanForNestedRef(Scope *sc); | |
394 Expression *optimize(int result); | |
395 Expression *interpret(InterState *istate); | |
396 MATCH implicitConvTo(Type *t); | |
397 Expression *castTo(Scope *sc, Type *t); | |
398 dt_t **toDt(dt_t **pdt); | |
399 | |
400 int inlineCost(InlineCostState *ics); | |
401 Expression *doInline(InlineDoState *ids); | |
402 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
403 // LDC |
159 | 404 virtual llvm::Constant *toConstElem(IRState *irs); |
405 }; | |
406 | |
407 struct AssocArrayLiteralExp : Expression | |
408 { | |
409 Expressions *keys; | |
410 Expressions *values; | |
411 | |
412 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); | |
413 | |
414 Expression *syntaxCopy(); | |
415 Expression *semantic(Scope *sc); | |
416 int isBool(int result); | |
417 elem *toElem(IRState *irs); | |
418 int checkSideEffect(int flag); | |
419 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
420 void toMangleBuffer(OutBuffer *buf); | |
421 void scanForNestedRef(Scope *sc); | |
422 Expression *optimize(int result); | |
423 Expression *interpret(InterState *istate); | |
424 MATCH implicitConvTo(Type *t); | |
425 Expression *castTo(Scope *sc, Type *t); | |
426 | |
427 int inlineCost(InlineCostState *ics); | |
428 Expression *doInline(InlineDoState *ids); | |
429 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
430 // LDC |
159 | 431 virtual llvm::Constant *toConstElem(IRState *irs); |
432 }; | |
433 | |
434 struct StructLiteralExp : Expression | |
435 { | |
436 StructDeclaration *sd; // which aggregate this is for | |
437 Expressions *elements; // parallels sd->fields[] with | |
438 // NULL entries for fields to skip | |
439 | |
440 Symbol *sym; // back end symbol to initialize with literal | |
441 size_t soffset; // offset from start of s | |
442 int fillHoles; // fill alignment 'holes' with zero | |
443 | |
444 StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements); | |
445 | |
446 Expression *syntaxCopy(); | |
447 Expression *semantic(Scope *sc); | |
448 Expression *getField(Type *type, unsigned offset); | |
449 int getFieldIndex(Type *type, unsigned offset); | |
450 elem *toElem(IRState *irs); | |
451 int checkSideEffect(int flag); | |
452 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
453 void toMangleBuffer(OutBuffer *buf); | |
454 void scanForNestedRef(Scope *sc); | |
455 Expression *optimize(int result); | |
456 Expression *interpret(InterState *istate); | |
457 dt_t **toDt(dt_t **pdt); | |
458 Expression *toLvalue(Scope *sc, Expression *e); | |
459 | |
460 int inlineCost(InlineCostState *ics); | |
461 Expression *doInline(InlineDoState *ids); | |
462 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
463 // LDC |
159 | 464 virtual llvm::Constant *toConstElem(IRState *irs); |
465 }; | |
466 | |
467 struct TypeDotIdExp : Expression | |
468 { | |
469 Identifier *ident; | |
470 | |
471 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); | |
472 Expression *syntaxCopy(); | |
473 Expression *semantic(Scope *sc); | |
474 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
475 elem *toElem(IRState *irs); | |
476 }; | |
477 | |
478 struct TypeExp : Expression | |
479 { | |
480 TypeExp(Loc loc, Type *type); | |
876
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
481 Expression *syntaxCopy(); |
159 | 482 Expression *semantic(Scope *sc); |
483 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
484 Expression *optimize(int result); | |
485 elem *toElem(IRState *irs); | |
486 }; | |
487 | |
488 struct ScopeExp : Expression | |
489 { | |
490 ScopeDsymbol *sds; | |
491 | |
492 ScopeExp(Loc loc, ScopeDsymbol *sds); | |
493 Expression *syntaxCopy(); | |
494 Expression *semantic(Scope *sc); | |
495 elem *toElem(IRState *irs); | |
496 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
497 }; | |
498 | |
499 struct TemplateExp : Expression | |
500 { | |
501 TemplateDeclaration *td; | |
502 | |
503 TemplateExp(Loc loc, TemplateDeclaration *td); | |
504 void rvalue(); | |
505 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
506 }; | |
507 | |
508 struct NewExp : Expression | |
509 { | |
510 /* thisexp.new(newargs) newtype(arguments) | |
511 */ | |
512 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
513 Expressions *newargs; // Array of Expression's to call new operator | |
514 Type *newtype; | |
515 Expressions *arguments; // Array of Expression's | |
516 | |
517 CtorDeclaration *member; // constructor function | |
518 NewDeclaration *allocator; // allocator function | |
519 int onstack; // allocate on stack | |
520 | |
521 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
522 Type *newtype, Expressions *arguments); | |
523 Expression *syntaxCopy(); | |
524 Expression *semantic(Scope *sc); | |
525 elem *toElem(IRState *irs); | |
526 int checkSideEffect(int flag); | |
527 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
528 void scanForNestedRef(Scope *sc); | |
529 | |
530 //int inlineCost(InlineCostState *ics); | |
531 Expression *doInline(InlineDoState *ids); | |
532 //Expression *inlineScan(InlineScanState *iss); | |
533 }; | |
534 | |
535 struct NewAnonClassExp : Expression | |
536 { | |
537 /* thisexp.new(newargs) class baseclasses { } (arguments) | |
538 */ | |
539 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
540 Expressions *newargs; // Array of Expression's to call new operator | |
541 ClassDeclaration *cd; // class being instantiated | |
542 Expressions *arguments; // Array of Expression's to call class constructor | |
543 | |
544 NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
545 ClassDeclaration *cd, Expressions *arguments); | |
546 Expression *syntaxCopy(); | |
547 Expression *semantic(Scope *sc); | |
548 int checkSideEffect(int flag); | |
549 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
550 }; | |
551 | |
552 // Offset from symbol | |
553 | |
554 struct SymOffExp : Expression | |
555 { | |
556 Declaration *var; | |
557 unsigned offset; | |
558 | |
559 SymOffExp(Loc loc, Declaration *var, unsigned offset); | |
560 Expression *semantic(Scope *sc); | |
561 void checkEscape(); | |
562 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
563 int isConst(); | |
564 int isBool(int result); | |
565 Expression *doInline(InlineDoState *ids); | |
566 MATCH implicitConvTo(Type *t); | |
567 Expression *castTo(Scope *sc, Type *t); | |
568 void scanForNestedRef(Scope *sc); | |
569 | |
570 elem *toElem(IRState *irs); | |
571 dt_t **toDt(dt_t **pdt); | |
572 }; | |
573 | |
574 // Variable | |
575 | |
576 struct VarExp : Expression | |
577 { | |
578 Declaration *var; | |
579 | |
580 VarExp(Loc loc, Declaration *var); | |
581 int equals(Object *o); | |
582 Expression *semantic(Scope *sc); | |
583 Expression *optimize(int result); | |
584 Expression *interpret(InterState *istate); | |
585 void dump(int indent); | |
586 char *toChars(); | |
587 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
588 void checkEscape(); | |
589 Expression *toLvalue(Scope *sc, Expression *e); | |
590 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
591 elem *toElem(IRState *irs); | |
592 dt_t **toDt(dt_t **pdt); | |
593 void scanForNestedRef(Scope *sc); | |
594 | |
595 int inlineCost(InlineCostState *ics); | |
596 Expression *doInline(InlineDoState *ids); | |
597 //Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
598 // LDC |
159 | 599 virtual llvm::Constant *toConstElem(IRState *irs); |
600 }; | |
601 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
602 #if DMDV2 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
603 // Overload Set |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
604 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
605 struct OverExp : Expression |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
606 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
607 OverloadSet *vars; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
608 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
609 OverExp(OverloadSet *s); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
610 int isLvalue(); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
611 Expression *toLvalue(Scope *sc, Expression *e); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
612 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
613 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
614 |
159 | 615 // Function/Delegate literal |
616 | |
617 struct FuncExp : Expression | |
618 { | |
619 FuncLiteralDeclaration *fd; | |
620 | |
621 FuncExp(Loc loc, FuncLiteralDeclaration *fd); | |
622 Expression *syntaxCopy(); | |
623 Expression *semantic(Scope *sc); | |
624 void scanForNestedRef(Scope *sc); | |
625 char *toChars(); | |
626 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
627 elem *toElem(IRState *irs); | |
628 | |
629 int inlineCost(InlineCostState *ics); | |
630 //Expression *doInline(InlineDoState *ids); | |
631 //Expression *inlineScan(InlineScanState *iss); | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
632 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
633 // LDC |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
634 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 635 }; |
636 | |
637 // Declaration of a symbol | |
638 | |
639 struct DeclarationExp : Expression | |
640 { | |
641 Dsymbol *declaration; | |
642 | |
643 DeclarationExp(Loc loc, Dsymbol *declaration); | |
644 Expression *syntaxCopy(); | |
645 Expression *semantic(Scope *sc); | |
646 Expression *interpret(InterState *istate); | |
647 int checkSideEffect(int flag); | |
648 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
649 elem *toElem(IRState *irs); | |
650 void scanForNestedRef(Scope *sc); | |
651 | |
652 int inlineCost(InlineCostState *ics); | |
653 Expression *doInline(InlineDoState *ids); | |
654 Expression *inlineScan(InlineScanState *iss); | |
655 }; | |
656 | |
657 struct TypeidExp : Expression | |
658 { | |
659 Type *typeidType; | |
660 | |
661 TypeidExp(Loc loc, Type *typeidType); | |
662 Expression *syntaxCopy(); | |
663 Expression *semantic(Scope *sc); | |
664 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
665 }; | |
666 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
667 #if DMDV2 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
668 struct TraitsExp : Expression |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
669 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
670 Identifier *ident; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
671 Objects *args; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
672 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
673 TraitsExp(Loc loc, Identifier *ident, Objects *args); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
674 Expression *syntaxCopy(); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
675 Expression *semantic(Scope *sc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
676 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
677 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
678 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
679 |
159 | 680 struct HaltExp : Expression |
681 { | |
682 HaltExp(Loc loc); | |
683 Expression *semantic(Scope *sc); | |
684 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
685 int checkSideEffect(int flag); | |
686 | |
687 elem *toElem(IRState *irs); | |
688 }; | |
689 | |
690 struct IsExp : Expression | |
691 { | |
692 /* is(targ id tok tspec) | |
693 * is(targ id == tok2) | |
694 */ | |
695 Type *targ; | |
696 Identifier *id; // can be NULL | |
697 enum TOK tok; // ':' or '==' | |
698 Type *tspec; // can be NULL | |
699 enum TOK tok2; // 'struct', 'union', 'typedef', etc. | |
700 | |
701 IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); | |
702 Expression *syntaxCopy(); | |
703 Expression *semantic(Scope *sc); | |
704 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
705 }; | |
706 | |
707 /****************************************************************/ | |
708 | |
709 struct UnaExp : Expression | |
710 { | |
711 Expression *e1; | |
712 | |
713 UnaExp(Loc loc, enum TOK op, int size, Expression *e1); | |
714 Expression *syntaxCopy(); | |
715 Expression *semantic(Scope *sc); | |
716 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
717 Expression *optimize(int result); | |
718 void dump(int indent); | |
719 void scanForNestedRef(Scope *sc); | |
720 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *)); | |
721 | |
722 int inlineCost(InlineCostState *ics); | |
723 Expression *doInline(InlineDoState *ids); | |
724 Expression *inlineScan(InlineScanState *iss); | |
725 | |
726 Expression *op_overload(Scope *sc); // doesn't need to be virtual | |
727 }; | |
728 | |
729 struct BinExp : Expression | |
730 { | |
731 Expression *e1; | |
732 Expression *e2; | |
733 | |
734 BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
735 Expression *syntaxCopy(); | |
736 Expression *semantic(Scope *sc); | |
737 Expression *semanticp(Scope *sc); | |
738 Expression *commonSemanticAssign(Scope *sc); | |
739 Expression *commonSemanticAssignIntegral(Scope *sc); | |
740 int checkSideEffect(int flag); | |
741 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
742 Expression *scaleFactor(Scope *sc); | |
743 Expression *typeCombine(Scope *sc); | |
744 Expression *optimize(int result); | |
745 int isunsigned(); | |
746 void incompatibleTypes(); | |
747 void dump(int indent); | |
748 void scanForNestedRef(Scope *sc); | |
749 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); | |
750 Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); | |
751 Expression *interpretAssignCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *), int post = 0); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
752 Expression *arrayOp(Scope *sc); |
159 | 753 |
754 int inlineCost(InlineCostState *ics); | |
755 Expression *doInline(InlineDoState *ids); | |
756 Expression *inlineScan(InlineScanState *iss); | |
757 | |
758 Expression *op_overload(Scope *sc); | |
759 | |
760 elem *toElemBin(IRState *irs, int op); | |
761 }; | |
762 | |
763 struct BinAssignExp : BinExp | |
764 { | |
765 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
766 int checkSideEffect(int flag); | |
767 }; | |
768 | |
769 /****************************************************************/ | |
770 | |
771 struct CompileExp : UnaExp | |
772 { | |
773 CompileExp(Loc loc, Expression *e); | |
774 Expression *semantic(Scope *sc); | |
775 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
776 }; | |
777 | |
778 struct FileExp : UnaExp | |
779 { | |
780 FileExp(Loc loc, Expression *e); | |
781 Expression *semantic(Scope *sc); | |
782 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
783 }; | |
784 | |
785 struct AssertExp : UnaExp | |
786 { | |
787 Expression *msg; | |
788 | |
789 AssertExp(Loc loc, Expression *e, Expression *msg = NULL); | |
790 Expression *syntaxCopy(); | |
791 Expression *semantic(Scope *sc); | |
792 Expression *interpret(InterState *istate); | |
793 int checkSideEffect(int flag); | |
794 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
795 | |
796 int inlineCost(InlineCostState *ics); | |
797 Expression *doInline(InlineDoState *ids); | |
798 Expression *inlineScan(InlineScanState *iss); | |
799 | |
800 elem *toElem(IRState *irs); | |
801 }; | |
802 | |
803 struct DotIdExp : UnaExp | |
804 { | |
805 Identifier *ident; | |
806 | |
807 DotIdExp(Loc loc, Expression *e, Identifier *ident); | |
808 Expression *semantic(Scope *sc); | |
809 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
810 void dump(int i); | |
811 }; | |
812 | |
813 struct DotTemplateExp : UnaExp | |
814 { | |
815 TemplateDeclaration *td; | |
816 | |
817 DotTemplateExp(Loc loc, Expression *e, TemplateDeclaration *td); | |
818 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
819 }; | |
820 | |
821 struct DotVarExp : UnaExp | |
822 { | |
823 Declaration *var; | |
824 | |
825 DotVarExp(Loc loc, Expression *e, Declaration *var); | |
826 Expression *semantic(Scope *sc); | |
827 Expression *toLvalue(Scope *sc, Expression *e); | |
828 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
829 Expression *optimize(int result); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
830 Expression *interpret(InterState *istate); |
159 | 831 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
832 void dump(int indent); | |
833 elem *toElem(IRState *irs); | |
834 }; | |
835 | |
836 struct DotTemplateInstanceExp : UnaExp | |
837 { | |
838 TemplateInstance *ti; | |
839 | |
840 DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); | |
841 Expression *syntaxCopy(); | |
842 Expression *semantic(Scope *sc); | |
843 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
844 void dump(int indent); | |
845 }; | |
846 | |
847 struct DelegateExp : UnaExp | |
848 { | |
849 FuncDeclaration *func; | |
850 | |
851 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); | |
852 Expression *semantic(Scope *sc); | |
853 MATCH implicitConvTo(Type *t); | |
854 Expression *castTo(Scope *sc, Type *t); | |
855 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
856 void dump(int indent); | |
857 | |
858 int inlineCost(InlineCostState *ics); | |
859 elem *toElem(IRState *irs); | |
860 }; | |
861 | |
862 struct DotTypeExp : UnaExp | |
863 { | |
864 Dsymbol *sym; // symbol that represents a type | |
865 | |
866 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | |
867 Expression *semantic(Scope *sc); | |
868 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
869 elem *toElem(IRState *irs); | |
870 }; | |
871 | |
872 struct CallExp : UnaExp | |
873 { | |
874 Expressions *arguments; // function arguments | |
875 | |
876 CallExp(Loc loc, Expression *e, Expressions *exps); | |
877 CallExp(Loc loc, Expression *e); | |
878 CallExp(Loc loc, Expression *e, Expression *earg1); | |
879 CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); | |
880 | |
881 Expression *syntaxCopy(); | |
882 Expression *semantic(Scope *sc); | |
883 Expression *optimize(int result); | |
884 Expression *interpret(InterState *istate); | |
885 int checkSideEffect(int flag); | |
886 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
887 void dump(int indent); | |
888 elem *toElem(IRState *irs); | |
889 void scanForNestedRef(Scope *sc); | |
890 Expression *toLvalue(Scope *sc, Expression *e); | |
891 | |
892 int inlineCost(InlineCostState *ics); | |
893 Expression *doInline(InlineDoState *ids); | |
894 Expression *inlineScan(InlineScanState *iss); | |
895 }; | |
896 | |
897 struct AddrExp : UnaExp | |
898 { | |
899 AddrExp(Loc loc, Expression *e); | |
900 Expression *semantic(Scope *sc); | |
901 elem *toElem(IRState *irs); | |
902 MATCH implicitConvTo(Type *t); | |
903 Expression *castTo(Scope *sc, Type *t); | |
904 Expression *optimize(int result); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
905 // LDC |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
906 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 907 }; |
908 | |
909 struct PtrExp : UnaExp | |
910 { | |
911 PtrExp(Loc loc, Expression *e); | |
912 PtrExp(Loc loc, Expression *e, Type *t); | |
913 Expression *semantic(Scope *sc); | |
914 Expression *toLvalue(Scope *sc, Expression *e); | |
915 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
916 elem *toElem(IRState *irs); | |
917 Expression *optimize(int result); | |
918 Expression *interpret(InterState *istate); | |
919 }; | |
920 | |
921 struct NegExp : UnaExp | |
922 { | |
923 NegExp(Loc loc, Expression *e); | |
924 Expression *semantic(Scope *sc); | |
925 Expression *optimize(int result); | |
926 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
927 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
928 Expression *buildArrayLoop(Arguments *fparams); |
159 | 929 |
930 // For operator overloading | |
931 Identifier *opId(); | |
932 | |
933 elem *toElem(IRState *irs); | |
934 }; | |
935 | |
936 struct UAddExp : UnaExp | |
937 { | |
938 UAddExp(Loc loc, Expression *e); | |
939 Expression *semantic(Scope *sc); | |
940 | |
941 // For operator overloading | |
942 Identifier *opId(); | |
943 }; | |
944 | |
945 struct ComExp : UnaExp | |
946 { | |
947 ComExp(Loc loc, Expression *e); | |
948 Expression *semantic(Scope *sc); | |
949 Expression *optimize(int result); | |
950 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
951 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
952 Expression *buildArrayLoop(Arguments *fparams); |
159 | 953 |
954 // For operator overloading | |
955 Identifier *opId(); | |
956 | |
957 elem *toElem(IRState *irs); | |
958 }; | |
959 | |
960 struct NotExp : UnaExp | |
961 { | |
962 NotExp(Loc loc, Expression *e); | |
963 Expression *semantic(Scope *sc); | |
964 Expression *optimize(int result); | |
965 Expression *interpret(InterState *istate); | |
966 int isBit(); | |
967 elem *toElem(IRState *irs); | |
968 }; | |
969 | |
970 struct BoolExp : UnaExp | |
971 { | |
972 BoolExp(Loc loc, Expression *e, Type *type); | |
973 Expression *semantic(Scope *sc); | |
974 Expression *optimize(int result); | |
975 Expression *interpret(InterState *istate); | |
976 int isBit(); | |
977 elem *toElem(IRState *irs); | |
978 }; | |
979 | |
980 struct DeleteExp : UnaExp | |
981 { | |
982 DeleteExp(Loc loc, Expression *e); | |
983 Expression *semantic(Scope *sc); | |
984 Expression *checkToBoolean(); | |
985 int checkSideEffect(int flag); | |
986 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
987 elem *toElem(IRState *irs); | |
988 }; | |
989 | |
990 struct CastExp : UnaExp | |
991 { | |
992 // Possible to cast to one type while painting to another type | |
993 Type *to; // type to cast to | |
994 | |
995 CastExp(Loc loc, Expression *e, Type *t); | |
996 Expression *syntaxCopy(); | |
997 Expression *semantic(Scope *sc); | |
998 Expression *optimize(int result); | |
999 Expression *interpret(InterState *istate); | |
1000 int checkSideEffect(int flag); | |
1001 void checkEscape(); | |
1002 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1003 elem *toElem(IRState *irs); | |
1004 | |
1005 // For operator overloading | |
1006 Identifier *opId(); | |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1007 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1008 // LDC |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1009 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1010 }; |
1011 | |
1012 | |
1013 struct SliceExp : UnaExp | |
1014 { | |
1015 Expression *upr; // NULL if implicit 0 | |
1016 Expression *lwr; // NULL if implicit [length - 1] | |
1017 VarDeclaration *lengthVar; | |
1018 | |
1019 SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); | |
1020 Expression *syntaxCopy(); | |
1021 Expression *semantic(Scope *sc); | |
1022 void checkEscape(); | |
1023 Expression *toLvalue(Scope *sc, Expression *e); | |
1024 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1025 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1026 Expression *optimize(int result); | |
1027 Expression *interpret(InterState *istate); | |
1028 void dump(int indent); | |
1029 elem *toElem(IRState *irs); | |
1030 void scanForNestedRef(Scope *sc); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1031 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1032 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1033 |
1034 int inlineCost(InlineCostState *ics); | |
1035 Expression *doInline(InlineDoState *ids); | |
1036 Expression *inlineScan(InlineScanState *iss); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1037 |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1038 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1039 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1040 }; |
1041 | |
1042 struct ArrayLengthExp : UnaExp | |
1043 { | |
1044 ArrayLengthExp(Loc loc, Expression *e1); | |
1045 Expression *semantic(Scope *sc); | |
1046 Expression *optimize(int result); | |
1047 Expression *interpret(InterState *istate); | |
1048 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1049 elem *toElem(IRState *irs); | |
1050 }; | |
1051 | |
1052 // e1[a0,a1,a2,a3,...] | |
1053 | |
1054 struct ArrayExp : UnaExp | |
1055 { | |
1056 Expressions *arguments; // Array of Expression's | |
1057 | |
1058 ArrayExp(Loc loc, Expression *e1, Expressions *arguments); | |
1059 Expression *syntaxCopy(); | |
1060 Expression *semantic(Scope *sc); | |
1061 Expression *toLvalue(Scope *sc, Expression *e); | |
1062 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1063 void scanForNestedRef(Scope *sc); | |
1064 | |
1065 // For operator overloading | |
1066 Identifier *opId(); | |
1067 | |
1068 int inlineCost(InlineCostState *ics); | |
1069 Expression *doInline(InlineDoState *ids); | |
1070 Expression *inlineScan(InlineScanState *iss); | |
1071 }; | |
1072 | |
1073 /****************************************************************/ | |
1074 | |
1075 struct DotExp : BinExp | |
1076 { | |
1077 DotExp(Loc loc, Expression *e1, Expression *e2); | |
1078 Expression *semantic(Scope *sc); | |
1079 }; | |
1080 | |
1081 struct CommaExp : BinExp | |
1082 { | |
1083 CommaExp(Loc loc, Expression *e1, Expression *e2); | |
1084 Expression *semantic(Scope *sc); | |
1085 void checkEscape(); | |
1086 Expression *toLvalue(Scope *sc, Expression *e); | |
1087 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1088 int isBool(int result); | |
1089 int checkSideEffect(int flag); | |
1090 Expression *optimize(int result); | |
1091 Expression *interpret(InterState *istate); | |
1092 elem *toElem(IRState *irs); | |
1093 }; | |
1094 | |
1095 struct IndexExp : BinExp | |
1096 { | |
1097 VarDeclaration *lengthVar; | |
1098 int modifiable; | |
1099 | |
1100 IndexExp(Loc loc, Expression *e1, Expression *e2); | |
1101 Expression *semantic(Scope *sc); | |
1102 Expression *toLvalue(Scope *sc, Expression *e); | |
1103 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1104 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1105 Expression *optimize(int result); | |
1106 Expression *interpret(InterState *istate); | |
1107 Expression *doInline(InlineDoState *ids); | |
1108 void scanForNestedRef(Scope *sc); | |
1109 | |
1110 elem *toElem(IRState *irs); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1111 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1112 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1113 }; |
1114 | |
1115 /* For both i++ and i-- | |
1116 */ | |
1117 struct PostExp : BinExp | |
1118 { | |
1119 PostExp(enum TOK op, Loc loc, Expression *e); | |
1120 Expression *semantic(Scope *sc); | |
1121 Expression *interpret(InterState *istate); | |
1122 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1123 Identifier *opId(); // For operator overloading | |
1124 elem *toElem(IRState *irs); | |
1125 }; | |
1126 | |
1127 struct AssignExp : BinExp | |
1128 { int ismemset; // !=0 if setting the contents of an array | |
1129 | |
1130 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1131 Expression *semantic(Scope *sc); | |
1132 Expression *checkToBoolean(); | |
1133 Expression *interpret(InterState *istate); | |
1134 Identifier *opId(); // For operator overloading | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1135 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1136 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1137 elem *toElem(IRState *irs); |
1138 }; | |
1139 | |
1140 #define ASSIGNEXP(op) \ | |
1141 struct op##AssignExp : BinExp \ | |
1142 { \ | |
1143 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1144 Expression *semantic(Scope *sc); \ | |
1145 Expression *interpret(InterState *istate); \ | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1146 X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \ |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1147 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
159 | 1148 \ |
1149 Identifier *opId(); /* For operator overloading */ \ | |
1150 \ | |
1151 elem *toElem(IRState *irs); \ | |
1152 }; | |
1153 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1154 #define X(a) a |
159 | 1155 ASSIGNEXP(Add) |
1156 ASSIGNEXP(Min) | |
1157 ASSIGNEXP(Mul) | |
1158 ASSIGNEXP(Div) | |
1159 ASSIGNEXP(Mod) | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1160 ASSIGNEXP(And) |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1161 ASSIGNEXP(Or) |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1162 ASSIGNEXP(Xor) |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1163 #undef X |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1164 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1165 #define X(a) |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1166 |
159 | 1167 ASSIGNEXP(Shl) |
1168 ASSIGNEXP(Shr) | |
1169 ASSIGNEXP(Ushr) | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1170 ASSIGNEXP(Cat) |
159 | 1171 |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1172 #undef X |
159 | 1173 #undef ASSIGNEXP |
1174 | |
1175 struct AddExp : BinExp | |
1176 { | |
1177 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1178 Expression *semantic(Scope *sc); | |
1179 Expression *optimize(int result); | |
1180 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1181 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1182 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1183 |
1184 // For operator overloading | |
1185 int isCommutative(); | |
1186 Identifier *opId(); | |
1187 Identifier *opId_r(); | |
1188 | |
1189 elem *toElem(IRState *irs); | |
1190 }; | |
1191 | |
1192 struct MinExp : BinExp | |
1193 { | |
1194 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1195 Expression *semantic(Scope *sc); | |
1196 Expression *optimize(int result); | |
1197 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1198 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1199 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1200 |
1201 // For operator overloading | |
1202 Identifier *opId(); | |
1203 Identifier *opId_r(); | |
1204 | |
1205 elem *toElem(IRState *irs); | |
1206 }; | |
1207 | |
1208 struct CatExp : BinExp | |
1209 { | |
1210 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1211 Expression *semantic(Scope *sc); | |
1212 Expression *optimize(int result); | |
1213 Expression *interpret(InterState *istate); | |
1214 | |
1215 // For operator overloading | |
1216 Identifier *opId(); | |
1217 Identifier *opId_r(); | |
1218 | |
1219 elem *toElem(IRState *irs); | |
1220 }; | |
1221 | |
1222 struct MulExp : BinExp | |
1223 { | |
1224 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1225 Expression *semantic(Scope *sc); | |
1226 Expression *optimize(int result); | |
1227 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1228 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1229 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1230 |
1231 // For operator overloading | |
1232 int isCommutative(); | |
1233 Identifier *opId(); | |
1234 Identifier *opId_r(); | |
1235 | |
1236 elem *toElem(IRState *irs); | |
1237 }; | |
1238 | |
1239 struct DivExp : BinExp | |
1240 { | |
1241 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1242 Expression *semantic(Scope *sc); | |
1243 Expression *optimize(int result); | |
1244 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1245 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1246 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1247 |
1248 // For operator overloading | |
1249 Identifier *opId(); | |
1250 Identifier *opId_r(); | |
1251 | |
1252 elem *toElem(IRState *irs); | |
1253 }; | |
1254 | |
1255 struct ModExp : BinExp | |
1256 { | |
1257 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1258 Expression *semantic(Scope *sc); | |
1259 Expression *optimize(int result); | |
1260 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1261 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1262 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1263 |
1264 // For operator overloading | |
1265 Identifier *opId(); | |
1266 Identifier *opId_r(); | |
1267 | |
1268 elem *toElem(IRState *irs); | |
1269 }; | |
1270 | |
1271 struct ShlExp : BinExp | |
1272 { | |
1273 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1274 Expression *semantic(Scope *sc); | |
1275 Expression *optimize(int result); | |
1276 Expression *interpret(InterState *istate); | |
1277 | |
1278 // For operator overloading | |
1279 Identifier *opId(); | |
1280 Identifier *opId_r(); | |
1281 | |
1282 elem *toElem(IRState *irs); | |
1283 }; | |
1284 | |
1285 struct ShrExp : BinExp | |
1286 { | |
1287 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1288 Expression *semantic(Scope *sc); | |
1289 Expression *optimize(int result); | |
1290 Expression *interpret(InterState *istate); | |
1291 | |
1292 // For operator overloading | |
1293 Identifier *opId(); | |
1294 Identifier *opId_r(); | |
1295 | |
1296 elem *toElem(IRState *irs); | |
1297 }; | |
1298 | |
1299 struct UshrExp : BinExp | |
1300 { | |
1301 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1302 Expression *semantic(Scope *sc); | |
1303 Expression *optimize(int result); | |
1304 Expression *interpret(InterState *istate); | |
1305 | |
1306 // For operator overloading | |
1307 Identifier *opId(); | |
1308 Identifier *opId_r(); | |
1309 | |
1310 elem *toElem(IRState *irs); | |
1311 }; | |
1312 | |
1313 struct AndExp : BinExp | |
1314 { | |
1315 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1316 Expression *semantic(Scope *sc); | |
1317 Expression *optimize(int result); | |
1318 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1319 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1320 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1321 |
1322 // For operator overloading | |
1323 int isCommutative(); | |
1324 Identifier *opId(); | |
1325 Identifier *opId_r(); | |
1326 | |
1327 elem *toElem(IRState *irs); | |
1328 }; | |
1329 | |
1330 struct OrExp : BinExp | |
1331 { | |
1332 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1333 Expression *semantic(Scope *sc); | |
1334 Expression *optimize(int result); | |
1335 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1336 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1337 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1338 |
1339 // For operator overloading | |
1340 int isCommutative(); | |
1341 Identifier *opId(); | |
1342 Identifier *opId_r(); | |
1343 | |
1344 elem *toElem(IRState *irs); | |
1345 }; | |
1346 | |
1347 struct XorExp : BinExp | |
1348 { | |
1349 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1350 Expression *semantic(Scope *sc); | |
1351 Expression *optimize(int result); | |
1352 Expression *interpret(InterState *istate); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1353 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1354 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1355 |
1356 // For operator overloading | |
1357 int isCommutative(); | |
1358 Identifier *opId(); | |
1359 Identifier *opId_r(); | |
1360 | |
1361 elem *toElem(IRState *irs); | |
1362 }; | |
1363 | |
1364 struct OrOrExp : BinExp | |
1365 { | |
1366 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1367 Expression *semantic(Scope *sc); | |
1368 Expression *checkToBoolean(); | |
1369 int isBit(); | |
1370 Expression *optimize(int result); | |
1371 Expression *interpret(InterState *istate); | |
1372 int checkSideEffect(int flag); | |
1373 elem *toElem(IRState *irs); | |
1374 }; | |
1375 | |
1376 struct AndAndExp : BinExp | |
1377 { | |
1378 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1379 Expression *semantic(Scope *sc); | |
1380 Expression *checkToBoolean(); | |
1381 int isBit(); | |
1382 Expression *optimize(int result); | |
1383 Expression *interpret(InterState *istate); | |
1384 int checkSideEffect(int flag); | |
1385 elem *toElem(IRState *irs); | |
1386 }; | |
1387 | |
1388 struct CmpExp : BinExp | |
1389 { | |
1390 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1391 Expression *semantic(Scope *sc); | |
1392 Expression *optimize(int result); | |
1393 Expression *interpret(InterState *istate); | |
1394 int isBit(); | |
1395 | |
1396 // For operator overloading | |
1397 int isCommutative(); | |
1398 Identifier *opId(); | |
1399 | |
1400 elem *toElem(IRState *irs); | |
1401 }; | |
1402 | |
1403 struct InExp : BinExp | |
1404 { | |
1405 InExp(Loc loc, Expression *e1, Expression *e2); | |
1406 Expression *semantic(Scope *sc); | |
1407 int isBit(); | |
1408 | |
1409 // For operator overloading | |
1410 Identifier *opId(); | |
1411 Identifier *opId_r(); | |
1412 | |
1413 elem *toElem(IRState *irs); | |
1414 }; | |
1415 | |
1416 struct RemoveExp : BinExp | |
1417 { | |
1418 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1419 elem *toElem(IRState *irs); | |
1420 }; | |
1421 | |
1422 // == and != | |
1423 | |
1424 struct EqualExp : BinExp | |
1425 { | |
1426 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1427 Expression *semantic(Scope *sc); | |
1428 Expression *optimize(int result); | |
1429 Expression *interpret(InterState *istate); | |
1430 int isBit(); | |
1431 | |
1432 // For operator overloading | |
1433 int isCommutative(); | |
1434 Identifier *opId(); | |
1435 | |
1436 elem *toElem(IRState *irs); | |
1437 }; | |
1438 | |
1439 // === and !=== | |
1440 | |
1441 struct IdentityExp : BinExp | |
1442 { | |
1443 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1444 Expression *semantic(Scope *sc); | |
1445 int isBit(); | |
1446 Expression *optimize(int result); | |
1447 Expression *interpret(InterState *istate); | |
1448 elem *toElem(IRState *irs); | |
1449 }; | |
1450 | |
1451 /****************************************************************/ | |
1452 | |
1453 struct CondExp : BinExp | |
1454 { | |
1455 Expression *econd; | |
1456 | |
1457 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1458 Expression *syntaxCopy(); | |
1459 Expression *semantic(Scope *sc); | |
1460 Expression *optimize(int result); | |
1461 Expression *interpret(InterState *istate); | |
1462 void checkEscape(); | |
1463 Expression *toLvalue(Scope *sc, Expression *e); | |
1464 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1465 Expression *checkToBoolean(); | |
1466 int checkSideEffect(int flag); | |
1467 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1468 MATCH implicitConvTo(Type *t); | |
1469 Expression *castTo(Scope *sc, Type *t); | |
1470 void scanForNestedRef(Scope *sc); | |
1471 | |
1472 int inlineCost(InlineCostState *ics); | |
1473 Expression *doInline(InlineDoState *ids); | |
1474 Expression *inlineScan(InlineScanState *iss); | |
1475 | |
1476 elem *toElem(IRState *irs); | |
1477 }; | |
1478 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1479 #if DMDV2 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1480 /****************************************************************/ |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1481 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1482 struct DefaultInitExp : Expression |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1483 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1484 enum TOK subop; // which of the derived classes this is |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1485 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1486 DefaultInitExp(Loc loc, enum TOK subop, int size); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1487 virtual Expression *resolve(Loc loc, Scope *sc) = 0; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1488 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1489 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1490 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1491 struct FileInitExp : DefaultInitExp |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1492 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1493 FileInitExp(Loc loc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1494 Expression *semantic(Scope *sc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1495 Expression *resolve(Loc loc, Scope *sc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1496 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1497 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1498 struct LineInitExp : DefaultInitExp |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1499 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1500 LineInitExp(Loc loc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1501 Expression *semantic(Scope *sc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1502 Expression *resolve(Loc loc, Scope *sc); |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1503 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1504 #endif |
159 | 1505 |
1506 /****************************************************************/ | |
1507 | |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1508 #if IN_LLVM |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1509 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1510 // this stuff is strictly LDC |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1511 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1512 struct GEPExp : UnaExp |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1513 { |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1514 unsigned index; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1515 Identifier* ident; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1516 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1517 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1518 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1519 Expression *toLvalue(Scope *sc, Expression *e); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1520 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1521 elem *toElem(IRState *irs); |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1522 llvm::Constant *toConstElem(IRState *irs); |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1523 }; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1524 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1525 #endif |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1526 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1527 /****************************************************************/ |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1528 |
159 | 1529 /* Special values used by the interpreter |
1530 */ | |
1531 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1532 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1533 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1534 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1535 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1536 | |
1537 Expression *expType(Type *type, Expression *e); | |
1538 | |
1539 Expression *Neg(Type *type, Expression *e1); | |
1540 Expression *Com(Type *type, Expression *e1); | |
1541 Expression *Not(Type *type, Expression *e1); | |
1542 Expression *Bool(Type *type, Expression *e1); | |
1543 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1544 Expression *ArrayLength(Type *type, Expression *e1); | |
1545 Expression *Ptr(Type *type, Expression *e1); | |
1546 | |
1547 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1548 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1549 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1550 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1551 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1552 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1553 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1554 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1555 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1556 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1557 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1558 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1559 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1560 | |
1561 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1562 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1563 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1564 | |
1565 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1566 | |
1567 #endif /* DMD_EXPRESSION_H */ |