Mercurial > projects > ldc
annotate dmd/expression.h @ 783:d268bf419a09
hgignore updates for CMake.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 22 Nov 2008 21:11:26 +0100 |
parents | eef8ac26c66c |
children | 340acf1535d0 |
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); | |
481 Expression *semantic(Scope *sc); | |
482 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
483 Expression *optimize(int result); | |
484 elem *toElem(IRState *irs); | |
485 }; | |
486 | |
487 struct ScopeExp : Expression | |
488 { | |
489 ScopeDsymbol *sds; | |
490 | |
491 ScopeExp(Loc loc, ScopeDsymbol *sds); | |
492 Expression *syntaxCopy(); | |
493 Expression *semantic(Scope *sc); | |
494 elem *toElem(IRState *irs); | |
495 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
496 }; | |
497 | |
498 struct TemplateExp : Expression | |
499 { | |
500 TemplateDeclaration *td; | |
501 | |
502 TemplateExp(Loc loc, TemplateDeclaration *td); | |
503 void rvalue(); | |
504 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
505 }; | |
506 | |
507 struct NewExp : Expression | |
508 { | |
509 /* thisexp.new(newargs) newtype(arguments) | |
510 */ | |
511 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
512 Expressions *newargs; // Array of Expression's to call new operator | |
513 Type *newtype; | |
514 Expressions *arguments; // Array of Expression's | |
515 | |
516 CtorDeclaration *member; // constructor function | |
517 NewDeclaration *allocator; // allocator function | |
518 int onstack; // allocate on stack | |
519 | |
520 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
521 Type *newtype, Expressions *arguments); | |
522 Expression *syntaxCopy(); | |
523 Expression *semantic(Scope *sc); | |
524 elem *toElem(IRState *irs); | |
525 int checkSideEffect(int flag); | |
526 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
527 void scanForNestedRef(Scope *sc); | |
528 | |
529 //int inlineCost(InlineCostState *ics); | |
530 Expression *doInline(InlineDoState *ids); | |
531 //Expression *inlineScan(InlineScanState *iss); | |
532 }; | |
533 | |
534 struct NewAnonClassExp : Expression | |
535 { | |
536 /* thisexp.new(newargs) class baseclasses { } (arguments) | |
537 */ | |
538 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
539 Expressions *newargs; // Array of Expression's to call new operator | |
540 ClassDeclaration *cd; // class being instantiated | |
541 Expressions *arguments; // Array of Expression's to call class constructor | |
542 | |
543 NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
544 ClassDeclaration *cd, Expressions *arguments); | |
545 Expression *syntaxCopy(); | |
546 Expression *semantic(Scope *sc); | |
547 int checkSideEffect(int flag); | |
548 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
549 }; | |
550 | |
551 // Offset from symbol | |
552 | |
553 struct SymOffExp : Expression | |
554 { | |
555 Declaration *var; | |
556 unsigned offset; | |
557 | |
558 SymOffExp(Loc loc, Declaration *var, unsigned offset); | |
559 Expression *semantic(Scope *sc); | |
560 void checkEscape(); | |
561 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
562 int isConst(); | |
563 int isBool(int result); | |
564 Expression *doInline(InlineDoState *ids); | |
565 MATCH implicitConvTo(Type *t); | |
566 Expression *castTo(Scope *sc, Type *t); | |
567 void scanForNestedRef(Scope *sc); | |
568 | |
569 elem *toElem(IRState *irs); | |
570 dt_t **toDt(dt_t **pdt); | |
571 }; | |
572 | |
573 // Variable | |
574 | |
575 struct VarExp : Expression | |
576 { | |
577 Declaration *var; | |
578 | |
579 VarExp(Loc loc, Declaration *var); | |
580 int equals(Object *o); | |
581 Expression *semantic(Scope *sc); | |
582 Expression *optimize(int result); | |
583 Expression *interpret(InterState *istate); | |
584 void dump(int indent); | |
585 char *toChars(); | |
586 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
587 void checkEscape(); | |
588 Expression *toLvalue(Scope *sc, Expression *e); | |
589 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
590 elem *toElem(IRState *irs); | |
591 dt_t **toDt(dt_t **pdt); | |
592 void scanForNestedRef(Scope *sc); | |
593 | |
594 int inlineCost(InlineCostState *ics); | |
595 Expression *doInline(InlineDoState *ids); | |
596 //Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
597 // LDC |
159 | 598 virtual llvm::Constant *toConstElem(IRState *irs); |
599 }; | |
600 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
601 #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
|
602 // 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
|
603 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
604 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
|
605 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
606 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
|
607 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
608 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
|
609 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
|
610 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
|
611 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
612 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
613 |
159 | 614 // Function/Delegate literal |
615 | |
616 struct FuncExp : Expression | |
617 { | |
618 FuncLiteralDeclaration *fd; | |
619 | |
620 FuncExp(Loc loc, FuncLiteralDeclaration *fd); | |
621 Expression *syntaxCopy(); | |
622 Expression *semantic(Scope *sc); | |
623 void scanForNestedRef(Scope *sc); | |
624 char *toChars(); | |
625 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
626 elem *toElem(IRState *irs); | |
627 | |
628 int inlineCost(InlineCostState *ics); | |
629 //Expression *doInline(InlineDoState *ids); | |
630 //Expression *inlineScan(InlineScanState *iss); | |
631 }; | |
632 | |
633 // Declaration of a symbol | |
634 | |
635 struct DeclarationExp : Expression | |
636 { | |
637 Dsymbol *declaration; | |
638 | |
639 DeclarationExp(Loc loc, Dsymbol *declaration); | |
640 Expression *syntaxCopy(); | |
641 Expression *semantic(Scope *sc); | |
642 Expression *interpret(InterState *istate); | |
643 int checkSideEffect(int flag); | |
644 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
645 elem *toElem(IRState *irs); | |
646 void scanForNestedRef(Scope *sc); | |
647 | |
648 int inlineCost(InlineCostState *ics); | |
649 Expression *doInline(InlineDoState *ids); | |
650 Expression *inlineScan(InlineScanState *iss); | |
651 }; | |
652 | |
653 struct TypeidExp : Expression | |
654 { | |
655 Type *typeidType; | |
656 | |
657 TypeidExp(Loc loc, Type *typeidType); | |
658 Expression *syntaxCopy(); | |
659 Expression *semantic(Scope *sc); | |
660 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
661 }; | |
662 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
663 #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
|
664 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
|
665 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
666 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
|
667 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
|
668 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 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
|
673 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
674 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
675 |
159 | 676 struct HaltExp : Expression |
677 { | |
678 HaltExp(Loc loc); | |
679 Expression *semantic(Scope *sc); | |
680 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
681 int checkSideEffect(int flag); | |
682 | |
683 elem *toElem(IRState *irs); | |
684 }; | |
685 | |
686 struct IsExp : Expression | |
687 { | |
688 /* is(targ id tok tspec) | |
689 * is(targ id == tok2) | |
690 */ | |
691 Type *targ; | |
692 Identifier *id; // can be NULL | |
693 enum TOK tok; // ':' or '==' | |
694 Type *tspec; // can be NULL | |
695 enum TOK tok2; // 'struct', 'union', 'typedef', etc. | |
696 | |
697 IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); | |
698 Expression *syntaxCopy(); | |
699 Expression *semantic(Scope *sc); | |
700 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
701 }; | |
702 | |
703 /****************************************************************/ | |
704 | |
705 struct UnaExp : Expression | |
706 { | |
707 Expression *e1; | |
708 | |
709 UnaExp(Loc loc, enum TOK op, int size, Expression *e1); | |
710 Expression *syntaxCopy(); | |
711 Expression *semantic(Scope *sc); | |
712 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
713 Expression *optimize(int result); | |
714 void dump(int indent); | |
715 void scanForNestedRef(Scope *sc); | |
716 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *)); | |
717 | |
718 int inlineCost(InlineCostState *ics); | |
719 Expression *doInline(InlineDoState *ids); | |
720 Expression *inlineScan(InlineScanState *iss); | |
721 | |
722 Expression *op_overload(Scope *sc); // doesn't need to be virtual | |
723 }; | |
724 | |
725 struct BinExp : Expression | |
726 { | |
727 Expression *e1; | |
728 Expression *e2; | |
729 | |
730 BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
731 Expression *syntaxCopy(); | |
732 Expression *semantic(Scope *sc); | |
733 Expression *semanticp(Scope *sc); | |
734 Expression *commonSemanticAssign(Scope *sc); | |
735 Expression *commonSemanticAssignIntegral(Scope *sc); | |
736 int checkSideEffect(int flag); | |
737 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
738 Expression *scaleFactor(Scope *sc); | |
739 Expression *typeCombine(Scope *sc); | |
740 Expression *optimize(int result); | |
741 int isunsigned(); | |
742 void incompatibleTypes(); | |
743 void dump(int indent); | |
744 void scanForNestedRef(Scope *sc); | |
745 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); | |
746 Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); | |
747 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
|
748 Expression *arrayOp(Scope *sc); |
159 | 749 |
750 int inlineCost(InlineCostState *ics); | |
751 Expression *doInline(InlineDoState *ids); | |
752 Expression *inlineScan(InlineScanState *iss); | |
753 | |
754 Expression *op_overload(Scope *sc); | |
755 | |
756 elem *toElemBin(IRState *irs, int op); | |
757 }; | |
758 | |
759 struct BinAssignExp : BinExp | |
760 { | |
761 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
762 int checkSideEffect(int flag); | |
763 }; | |
764 | |
765 /****************************************************************/ | |
766 | |
767 struct CompileExp : UnaExp | |
768 { | |
769 CompileExp(Loc loc, Expression *e); | |
770 Expression *semantic(Scope *sc); | |
771 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
772 }; | |
773 | |
774 struct FileExp : UnaExp | |
775 { | |
776 FileExp(Loc loc, Expression *e); | |
777 Expression *semantic(Scope *sc); | |
778 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
779 }; | |
780 | |
781 struct AssertExp : UnaExp | |
782 { | |
783 Expression *msg; | |
784 | |
785 AssertExp(Loc loc, Expression *e, Expression *msg = NULL); | |
786 Expression *syntaxCopy(); | |
787 Expression *semantic(Scope *sc); | |
788 Expression *interpret(InterState *istate); | |
789 int checkSideEffect(int flag); | |
790 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
791 | |
792 int inlineCost(InlineCostState *ics); | |
793 Expression *doInline(InlineDoState *ids); | |
794 Expression *inlineScan(InlineScanState *iss); | |
795 | |
796 elem *toElem(IRState *irs); | |
797 }; | |
798 | |
799 struct DotIdExp : UnaExp | |
800 { | |
801 Identifier *ident; | |
802 | |
803 DotIdExp(Loc loc, Expression *e, Identifier *ident); | |
804 Expression *semantic(Scope *sc); | |
805 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
806 void dump(int i); | |
807 }; | |
808 | |
809 struct DotTemplateExp : UnaExp | |
810 { | |
811 TemplateDeclaration *td; | |
812 | |
813 DotTemplateExp(Loc loc, Expression *e, TemplateDeclaration *td); | |
814 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
815 }; | |
816 | |
817 struct DotVarExp : UnaExp | |
818 { | |
819 Declaration *var; | |
820 | |
821 DotVarExp(Loc loc, Expression *e, Declaration *var); | |
822 Expression *semantic(Scope *sc); | |
823 Expression *toLvalue(Scope *sc, Expression *e); | |
824 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
825 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
826 void dump(int indent); | |
827 elem *toElem(IRState *irs); | |
588
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
828 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
829 //LDC: since we don't convert abc.def -> *(&abc + ABC.def.offsetof) |
588
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
830 // these are needed |
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
831 Expression *optimize(int result); |
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
832 Expression *interpret(InterState *istate); |
159 | 833 }; |
834 | |
835 struct DotTemplateInstanceExp : UnaExp | |
836 { | |
837 TemplateInstance *ti; | |
838 | |
839 DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); | |
840 Expression *syntaxCopy(); | |
841 Expression *semantic(Scope *sc); | |
842 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
843 void dump(int indent); | |
844 }; | |
845 | |
846 struct DelegateExp : UnaExp | |
847 { | |
848 FuncDeclaration *func; | |
849 | |
850 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); | |
851 Expression *semantic(Scope *sc); | |
852 MATCH implicitConvTo(Type *t); | |
853 Expression *castTo(Scope *sc, Type *t); | |
854 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
855 void dump(int indent); | |
856 | |
857 int inlineCost(InlineCostState *ics); | |
858 elem *toElem(IRState *irs); | |
859 }; | |
860 | |
861 struct DotTypeExp : UnaExp | |
862 { | |
863 Dsymbol *sym; // symbol that represents a type | |
864 | |
865 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | |
866 Expression *semantic(Scope *sc); | |
867 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
868 elem *toElem(IRState *irs); | |
869 }; | |
870 | |
871 struct CallExp : UnaExp | |
872 { | |
873 Expressions *arguments; // function arguments | |
874 | |
875 CallExp(Loc loc, Expression *e, Expressions *exps); | |
876 CallExp(Loc loc, Expression *e); | |
877 CallExp(Loc loc, Expression *e, Expression *earg1); | |
878 CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); | |
879 | |
880 Expression *syntaxCopy(); | |
881 Expression *semantic(Scope *sc); | |
882 Expression *optimize(int result); | |
883 Expression *interpret(InterState *istate); | |
884 int checkSideEffect(int flag); | |
885 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
886 void dump(int indent); | |
887 elem *toElem(IRState *irs); | |
888 void scanForNestedRef(Scope *sc); | |
889 Expression *toLvalue(Scope *sc, Expression *e); | |
890 | |
891 int inlineCost(InlineCostState *ics); | |
892 Expression *doInline(InlineDoState *ids); | |
893 Expression *inlineScan(InlineScanState *iss); | |
894 }; | |
895 | |
896 struct AddrExp : UnaExp | |
897 { | |
898 AddrExp(Loc loc, Expression *e); | |
899 Expression *semantic(Scope *sc); | |
900 elem *toElem(IRState *irs); | |
901 MATCH implicitConvTo(Type *t); | |
902 Expression *castTo(Scope *sc, Type *t); | |
903 Expression *optimize(int result); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
904 // LDC |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
905 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 906 }; |
907 | |
908 struct PtrExp : UnaExp | |
909 { | |
910 PtrExp(Loc loc, Expression *e); | |
911 PtrExp(Loc loc, Expression *e, Type *t); | |
912 Expression *semantic(Scope *sc); | |
913 Expression *toLvalue(Scope *sc, Expression *e); | |
914 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
915 elem *toElem(IRState *irs); | |
916 Expression *optimize(int result); | |
917 Expression *interpret(InterState *istate); | |
918 }; | |
919 | |
920 struct NegExp : UnaExp | |
921 { | |
922 NegExp(Loc loc, Expression *e); | |
923 Expression *semantic(Scope *sc); | |
924 Expression *optimize(int result); | |
925 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
|
926 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
|
927 Expression *buildArrayLoop(Arguments *fparams); |
159 | 928 |
929 // For operator overloading | |
930 Identifier *opId(); | |
931 | |
932 elem *toElem(IRState *irs); | |
933 }; | |
934 | |
935 struct UAddExp : UnaExp | |
936 { | |
937 UAddExp(Loc loc, Expression *e); | |
938 Expression *semantic(Scope *sc); | |
939 | |
940 // For operator overloading | |
941 Identifier *opId(); | |
942 }; | |
943 | |
944 struct ComExp : UnaExp | |
945 { | |
946 ComExp(Loc loc, Expression *e); | |
947 Expression *semantic(Scope *sc); | |
948 Expression *optimize(int result); | |
949 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
|
950 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
|
951 Expression *buildArrayLoop(Arguments *fparams); |
159 | 952 |
953 // For operator overloading | |
954 Identifier *opId(); | |
955 | |
956 elem *toElem(IRState *irs); | |
957 }; | |
958 | |
959 struct NotExp : UnaExp | |
960 { | |
961 NotExp(Loc loc, Expression *e); | |
962 Expression *semantic(Scope *sc); | |
963 Expression *optimize(int result); | |
964 Expression *interpret(InterState *istate); | |
965 int isBit(); | |
966 elem *toElem(IRState *irs); | |
967 }; | |
968 | |
969 struct BoolExp : UnaExp | |
970 { | |
971 BoolExp(Loc loc, Expression *e, Type *type); | |
972 Expression *semantic(Scope *sc); | |
973 Expression *optimize(int result); | |
974 Expression *interpret(InterState *istate); | |
975 int isBit(); | |
976 elem *toElem(IRState *irs); | |
977 }; | |
978 | |
979 struct DeleteExp : UnaExp | |
980 { | |
981 DeleteExp(Loc loc, Expression *e); | |
982 Expression *semantic(Scope *sc); | |
983 Expression *checkToBoolean(); | |
984 int checkSideEffect(int flag); | |
985 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
986 elem *toElem(IRState *irs); | |
987 }; | |
988 | |
989 struct CastExp : UnaExp | |
990 { | |
991 // Possible to cast to one type while painting to another type | |
992 Type *to; // type to cast to | |
993 | |
994 CastExp(Loc loc, Expression *e, Type *t); | |
995 Expression *syntaxCopy(); | |
996 Expression *semantic(Scope *sc); | |
997 Expression *optimize(int result); | |
998 Expression *interpret(InterState *istate); | |
999 int checkSideEffect(int flag); | |
1000 void checkEscape(); | |
1001 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1002 elem *toElem(IRState *irs); | |
1003 | |
1004 // For operator overloading | |
1005 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
|
1006 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1007 // LDC |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1008 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1009 }; |
1010 | |
1011 | |
1012 struct SliceExp : UnaExp | |
1013 { | |
1014 Expression *upr; // NULL if implicit 0 | |
1015 Expression *lwr; // NULL if implicit [length - 1] | |
1016 VarDeclaration *lengthVar; | |
1017 | |
1018 SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); | |
1019 Expression *syntaxCopy(); | |
1020 Expression *semantic(Scope *sc); | |
1021 void checkEscape(); | |
1022 Expression *toLvalue(Scope *sc, Expression *e); | |
1023 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1024 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1025 Expression *optimize(int result); | |
1026 Expression *interpret(InterState *istate); | |
1027 void dump(int indent); | |
1028 elem *toElem(IRState *irs); | |
1029 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
|
1030 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
|
1031 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1032 |
1033 int inlineCost(InlineCostState *ics); | |
1034 Expression *doInline(InlineDoState *ids); | |
1035 Expression *inlineScan(InlineScanState *iss); | |
1036 }; | |
1037 | |
1038 struct ArrayLengthExp : UnaExp | |
1039 { | |
1040 ArrayLengthExp(Loc loc, Expression *e1); | |
1041 Expression *semantic(Scope *sc); | |
1042 Expression *optimize(int result); | |
1043 Expression *interpret(InterState *istate); | |
1044 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1045 elem *toElem(IRState *irs); | |
1046 }; | |
1047 | |
1048 // e1[a0,a1,a2,a3,...] | |
1049 | |
1050 struct ArrayExp : UnaExp | |
1051 { | |
1052 Expressions *arguments; // Array of Expression's | |
1053 | |
1054 ArrayExp(Loc loc, Expression *e1, Expressions *arguments); | |
1055 Expression *syntaxCopy(); | |
1056 Expression *semantic(Scope *sc); | |
1057 Expression *toLvalue(Scope *sc, Expression *e); | |
1058 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1059 void scanForNestedRef(Scope *sc); | |
1060 | |
1061 // For operator overloading | |
1062 Identifier *opId(); | |
1063 | |
1064 int inlineCost(InlineCostState *ics); | |
1065 Expression *doInline(InlineDoState *ids); | |
1066 Expression *inlineScan(InlineScanState *iss); | |
1067 }; | |
1068 | |
1069 /****************************************************************/ | |
1070 | |
1071 struct DotExp : BinExp | |
1072 { | |
1073 DotExp(Loc loc, Expression *e1, Expression *e2); | |
1074 Expression *semantic(Scope *sc); | |
1075 }; | |
1076 | |
1077 struct CommaExp : BinExp | |
1078 { | |
1079 CommaExp(Loc loc, Expression *e1, Expression *e2); | |
1080 Expression *semantic(Scope *sc); | |
1081 void checkEscape(); | |
1082 Expression *toLvalue(Scope *sc, Expression *e); | |
1083 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1084 int isBool(int result); | |
1085 int checkSideEffect(int flag); | |
1086 Expression *optimize(int result); | |
1087 Expression *interpret(InterState *istate); | |
1088 elem *toElem(IRState *irs); | |
1089 }; | |
1090 | |
1091 struct IndexExp : BinExp | |
1092 { | |
1093 VarDeclaration *lengthVar; | |
1094 int modifiable; | |
1095 | |
1096 IndexExp(Loc loc, Expression *e1, Expression *e2); | |
1097 Expression *semantic(Scope *sc); | |
1098 Expression *toLvalue(Scope *sc, Expression *e); | |
1099 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1100 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1101 Expression *optimize(int result); | |
1102 Expression *interpret(InterState *istate); | |
1103 Expression *doInline(InlineDoState *ids); | |
1104 void scanForNestedRef(Scope *sc); | |
1105 | |
1106 elem *toElem(IRState *irs); | |
1107 }; | |
1108 | |
1109 /* For both i++ and i-- | |
1110 */ | |
1111 struct PostExp : BinExp | |
1112 { | |
1113 PostExp(enum TOK op, Loc loc, Expression *e); | |
1114 Expression *semantic(Scope *sc); | |
1115 Expression *interpret(InterState *istate); | |
1116 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1117 Identifier *opId(); // For operator overloading | |
1118 elem *toElem(IRState *irs); | |
1119 }; | |
1120 | |
1121 struct AssignExp : BinExp | |
1122 { int ismemset; // !=0 if setting the contents of an array | |
1123 | |
1124 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1125 Expression *semantic(Scope *sc); | |
1126 Expression *checkToBoolean(); | |
1127 Expression *interpret(InterState *istate); | |
1128 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
|
1129 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
|
1130 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1131 elem *toElem(IRState *irs); |
1132 }; | |
1133 | |
1134 #define ASSIGNEXP(op) \ | |
1135 struct op##AssignExp : BinExp \ | |
1136 { \ | |
1137 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1138 Expression *semantic(Scope *sc); \ | |
1139 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
|
1140 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
|
1141 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
159 | 1142 \ |
1143 Identifier *opId(); /* For operator overloading */ \ | |
1144 \ | |
1145 elem *toElem(IRState *irs); \ | |
1146 }; | |
1147 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1148 #define X(a) a |
159 | 1149 ASSIGNEXP(Add) |
1150 ASSIGNEXP(Min) | |
1151 ASSIGNEXP(Mul) | |
1152 ASSIGNEXP(Div) | |
1153 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
|
1154 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
|
1155 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
|
1156 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
|
1157 #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
|
1158 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1159 #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
|
1160 |
159 | 1161 ASSIGNEXP(Shl) |
1162 ASSIGNEXP(Shr) | |
1163 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
|
1164 ASSIGNEXP(Cat) |
159 | 1165 |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1166 #undef X |
159 | 1167 #undef ASSIGNEXP |
1168 | |
1169 struct AddExp : BinExp | |
1170 { | |
1171 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1172 Expression *semantic(Scope *sc); | |
1173 Expression *optimize(int result); | |
1174 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
|
1175 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
|
1176 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1177 |
1178 // For operator overloading | |
1179 int isCommutative(); | |
1180 Identifier *opId(); | |
1181 Identifier *opId_r(); | |
1182 | |
1183 elem *toElem(IRState *irs); | |
1184 }; | |
1185 | |
1186 struct MinExp : BinExp | |
1187 { | |
1188 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1189 Expression *semantic(Scope *sc); | |
1190 Expression *optimize(int result); | |
1191 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
|
1192 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
|
1193 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1194 |
1195 // For operator overloading | |
1196 Identifier *opId(); | |
1197 Identifier *opId_r(); | |
1198 | |
1199 elem *toElem(IRState *irs); | |
1200 }; | |
1201 | |
1202 struct CatExp : BinExp | |
1203 { | |
1204 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1205 Expression *semantic(Scope *sc); | |
1206 Expression *optimize(int result); | |
1207 Expression *interpret(InterState *istate); | |
1208 | |
1209 // For operator overloading | |
1210 Identifier *opId(); | |
1211 Identifier *opId_r(); | |
1212 | |
1213 elem *toElem(IRState *irs); | |
1214 }; | |
1215 | |
1216 struct MulExp : BinExp | |
1217 { | |
1218 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1219 Expression *semantic(Scope *sc); | |
1220 Expression *optimize(int result); | |
1221 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
|
1222 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
|
1223 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1224 |
1225 // For operator overloading | |
1226 int isCommutative(); | |
1227 Identifier *opId(); | |
1228 Identifier *opId_r(); | |
1229 | |
1230 elem *toElem(IRState *irs); | |
1231 }; | |
1232 | |
1233 struct DivExp : BinExp | |
1234 { | |
1235 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1236 Expression *semantic(Scope *sc); | |
1237 Expression *optimize(int result); | |
1238 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
|
1239 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
|
1240 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1241 |
1242 // For operator overloading | |
1243 Identifier *opId(); | |
1244 Identifier *opId_r(); | |
1245 | |
1246 elem *toElem(IRState *irs); | |
1247 }; | |
1248 | |
1249 struct ModExp : BinExp | |
1250 { | |
1251 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1252 Expression *semantic(Scope *sc); | |
1253 Expression *optimize(int result); | |
1254 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
|
1255 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
|
1256 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1257 |
1258 // For operator overloading | |
1259 Identifier *opId(); | |
1260 Identifier *opId_r(); | |
1261 | |
1262 elem *toElem(IRState *irs); | |
1263 }; | |
1264 | |
1265 struct ShlExp : BinExp | |
1266 { | |
1267 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1268 Expression *semantic(Scope *sc); | |
1269 Expression *optimize(int result); | |
1270 Expression *interpret(InterState *istate); | |
1271 | |
1272 // For operator overloading | |
1273 Identifier *opId(); | |
1274 Identifier *opId_r(); | |
1275 | |
1276 elem *toElem(IRState *irs); | |
1277 }; | |
1278 | |
1279 struct ShrExp : BinExp | |
1280 { | |
1281 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1282 Expression *semantic(Scope *sc); | |
1283 Expression *optimize(int result); | |
1284 Expression *interpret(InterState *istate); | |
1285 | |
1286 // For operator overloading | |
1287 Identifier *opId(); | |
1288 Identifier *opId_r(); | |
1289 | |
1290 elem *toElem(IRState *irs); | |
1291 }; | |
1292 | |
1293 struct UshrExp : BinExp | |
1294 { | |
1295 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1296 Expression *semantic(Scope *sc); | |
1297 Expression *optimize(int result); | |
1298 Expression *interpret(InterState *istate); | |
1299 | |
1300 // For operator overloading | |
1301 Identifier *opId(); | |
1302 Identifier *opId_r(); | |
1303 | |
1304 elem *toElem(IRState *irs); | |
1305 }; | |
1306 | |
1307 struct AndExp : BinExp | |
1308 { | |
1309 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1310 Expression *semantic(Scope *sc); | |
1311 Expression *optimize(int result); | |
1312 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
|
1313 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
|
1314 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1315 |
1316 // For operator overloading | |
1317 int isCommutative(); | |
1318 Identifier *opId(); | |
1319 Identifier *opId_r(); | |
1320 | |
1321 elem *toElem(IRState *irs); | |
1322 }; | |
1323 | |
1324 struct OrExp : BinExp | |
1325 { | |
1326 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1327 Expression *semantic(Scope *sc); | |
1328 Expression *optimize(int result); | |
1329 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
|
1330 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
|
1331 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1332 |
1333 // For operator overloading | |
1334 int isCommutative(); | |
1335 Identifier *opId(); | |
1336 Identifier *opId_r(); | |
1337 | |
1338 elem *toElem(IRState *irs); | |
1339 }; | |
1340 | |
1341 struct XorExp : BinExp | |
1342 { | |
1343 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1344 Expression *semantic(Scope *sc); | |
1345 Expression *optimize(int result); | |
1346 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
|
1347 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
|
1348 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1349 |
1350 // For operator overloading | |
1351 int isCommutative(); | |
1352 Identifier *opId(); | |
1353 Identifier *opId_r(); | |
1354 | |
1355 elem *toElem(IRState *irs); | |
1356 }; | |
1357 | |
1358 struct OrOrExp : BinExp | |
1359 { | |
1360 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1361 Expression *semantic(Scope *sc); | |
1362 Expression *checkToBoolean(); | |
1363 int isBit(); | |
1364 Expression *optimize(int result); | |
1365 Expression *interpret(InterState *istate); | |
1366 int checkSideEffect(int flag); | |
1367 elem *toElem(IRState *irs); | |
1368 }; | |
1369 | |
1370 struct AndAndExp : BinExp | |
1371 { | |
1372 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1373 Expression *semantic(Scope *sc); | |
1374 Expression *checkToBoolean(); | |
1375 int isBit(); | |
1376 Expression *optimize(int result); | |
1377 Expression *interpret(InterState *istate); | |
1378 int checkSideEffect(int flag); | |
1379 elem *toElem(IRState *irs); | |
1380 }; | |
1381 | |
1382 struct CmpExp : BinExp | |
1383 { | |
1384 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1385 Expression *semantic(Scope *sc); | |
1386 Expression *optimize(int result); | |
1387 Expression *interpret(InterState *istate); | |
1388 int isBit(); | |
1389 | |
1390 // For operator overloading | |
1391 int isCommutative(); | |
1392 Identifier *opId(); | |
1393 | |
1394 elem *toElem(IRState *irs); | |
1395 }; | |
1396 | |
1397 struct InExp : BinExp | |
1398 { | |
1399 InExp(Loc loc, Expression *e1, Expression *e2); | |
1400 Expression *semantic(Scope *sc); | |
1401 int isBit(); | |
1402 | |
1403 // For operator overloading | |
1404 Identifier *opId(); | |
1405 Identifier *opId_r(); | |
1406 | |
1407 elem *toElem(IRState *irs); | |
1408 }; | |
1409 | |
1410 struct RemoveExp : BinExp | |
1411 { | |
1412 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1413 elem *toElem(IRState *irs); | |
1414 }; | |
1415 | |
1416 // == and != | |
1417 | |
1418 struct EqualExp : BinExp | |
1419 { | |
1420 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1421 Expression *semantic(Scope *sc); | |
1422 Expression *optimize(int result); | |
1423 Expression *interpret(InterState *istate); | |
1424 int isBit(); | |
1425 | |
1426 // For operator overloading | |
1427 int isCommutative(); | |
1428 Identifier *opId(); | |
1429 | |
1430 elem *toElem(IRState *irs); | |
1431 }; | |
1432 | |
1433 // === and !=== | |
1434 | |
1435 struct IdentityExp : BinExp | |
1436 { | |
1437 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1438 Expression *semantic(Scope *sc); | |
1439 int isBit(); | |
1440 Expression *optimize(int result); | |
1441 Expression *interpret(InterState *istate); | |
1442 elem *toElem(IRState *irs); | |
1443 }; | |
1444 | |
1445 /****************************************************************/ | |
1446 | |
1447 struct CondExp : BinExp | |
1448 { | |
1449 Expression *econd; | |
1450 | |
1451 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1452 Expression *syntaxCopy(); | |
1453 Expression *semantic(Scope *sc); | |
1454 Expression *optimize(int result); | |
1455 Expression *interpret(InterState *istate); | |
1456 void checkEscape(); | |
1457 Expression *toLvalue(Scope *sc, Expression *e); | |
1458 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1459 Expression *checkToBoolean(); | |
1460 int checkSideEffect(int flag); | |
1461 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1462 MATCH implicitConvTo(Type *t); | |
1463 Expression *castTo(Scope *sc, Type *t); | |
1464 void scanForNestedRef(Scope *sc); | |
1465 | |
1466 int inlineCost(InlineCostState *ics); | |
1467 Expression *doInline(InlineDoState *ids); | |
1468 Expression *inlineScan(InlineScanState *iss); | |
1469 | |
1470 elem *toElem(IRState *irs); | |
1471 }; | |
1472 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1473 #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
|
1474 /****************************************************************/ |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1475 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1476 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
|
1477 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1478 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
|
1479 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1480 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
|
1481 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
|
1482 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1485 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
|
1486 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1487 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
|
1488 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
|
1489 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1492 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
|
1493 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1494 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
|
1495 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
|
1496 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
|
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 #endif |
159 | 1499 |
1500 /****************************************************************/ | |
1501 | |
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
|
1502 #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
|
1503 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1504 // 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
|
1505 |
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
|
1506 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
|
1507 { |
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 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
|
1509 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
|
1510 |
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 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
|
1512 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
|
1513 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
|
1514 |
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 elem *toElem(IRState *irs); |
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 |
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 #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
|
1519 |
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 |
159 | 1522 /* Special values used by the interpreter |
1523 */ | |
1524 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1525 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1526 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1527 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1528 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1529 | |
1530 Expression *expType(Type *type, Expression *e); | |
1531 | |
1532 Expression *Neg(Type *type, Expression *e1); | |
1533 Expression *Com(Type *type, Expression *e1); | |
1534 Expression *Not(Type *type, Expression *e1); | |
1535 Expression *Bool(Type *type, Expression *e1); | |
1536 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1537 Expression *ArrayLength(Type *type, Expression *e1); | |
1538 Expression *Ptr(Type *type, Expression *e1); | |
1539 | |
1540 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1541 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1542 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1543 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1544 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1545 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1546 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1547 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1548 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1549 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1550 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1551 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1552 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1553 | |
1554 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1555 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1556 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1557 | |
1558 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1559 | |
1560 #endif /* DMD_EXPRESSION_H */ |