Mercurial > projects > ldc
annotate dmd/expression.h @ 90:16e88334bba7 trunk
[svn r94] started on complex support
calling final class methods was being treated as a virtual call failing an assertion.
author | lindquist |
---|---|
date | Wed, 07 Nov 2007 03:36:07 +0100 |
parents | fd32135dca3e |
children | 70d6113eeb8c |
rev | line source |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 by Digital Mars | |
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 | |
46 | |
47 namespace llvm | |
48 { | |
40 | 49 class Constant; |
1 | 50 class ConstantInt; |
51 } | |
52 | |
53 enum TOK; | |
54 | |
55 // Back end | |
56 struct IRState; | |
57 struct dt_t; | |
58 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
40
diff
changeset
|
59 #if IN_LLVM |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
40
diff
changeset
|
60 struct DValue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
40
diff
changeset
|
61 typedef DValue elem; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
40
diff
changeset
|
62 #else |
1 | 63 #ifdef IN_GCC |
64 union tree_node; typedef union tree_node elem; | |
65 #else | |
66 struct elem; | |
67 #endif | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
40
diff
changeset
|
68 #endif |
1 | 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); | |
19 | 79 FuncDeclaration *hasThis(Scope *sc); |
80 Expression *fromConstInitializer(int result, Expression *e); | |
1 | 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 void 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); | |
143 | |
144 virtual int inlineCost(InlineCostState *ics); | |
145 virtual Expression *doInline(InlineDoState *ids); | |
146 virtual Expression *inlineScan(InlineScanState *iss); | |
147 | |
148 // For operator overloading | |
149 virtual int isCommutative(); | |
150 virtual Identifier *opId(); | |
151 virtual Identifier *opId_r(); | |
152 | |
153 // Back end | |
154 virtual elem *toElem(IRState *irs); | |
155 virtual dt_t **toDt(dt_t **pdt); | |
40 | 156 // LLVMDC |
157 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 158 }; |
159 | |
160 struct IntegerExp : Expression | |
161 { | |
162 integer_t value; | |
163 | |
164 IntegerExp(Loc loc, integer_t value, Type *type); | |
165 IntegerExp(integer_t value); | |
166 int equals(Object *o); | |
167 Expression *semantic(Scope *sc); | |
168 Expression *interpret(InterState *istate); | |
169 char *toChars(); | |
170 void dump(int indent); | |
171 integer_t toInteger(); | |
172 real_t toReal(); | |
173 real_t toImaginary(); | |
174 complex_t toComplex(); | |
175 int isConst(); | |
176 int isBool(int result); | |
177 MATCH implicitConvTo(Type *t); | |
178 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
179 void toMangleBuffer(OutBuffer *buf); | |
180 Expression *toLvalue(Scope *sc, Expression *e); | |
181 elem *toElem(IRState *irs); | |
182 dt_t **toDt(dt_t **pdt); | |
40 | 183 // LLVMDC |
184 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 185 }; |
186 | |
187 struct RealExp : Expression | |
188 { | |
189 real_t value; | |
190 | |
191 RealExp(Loc loc, real_t value, Type *type); | |
192 int equals(Object *o); | |
193 Expression *semantic(Scope *sc); | |
194 Expression *interpret(InterState *istate); | |
195 char *toChars(); | |
196 integer_t toInteger(); | |
197 uinteger_t toUInteger(); | |
198 real_t toReal(); | |
199 real_t toImaginary(); | |
200 complex_t toComplex(); | |
201 Expression *castTo(Scope *sc, Type *t); | |
202 int isConst(); | |
203 int isBool(int result); | |
204 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
205 void toMangleBuffer(OutBuffer *buf); | |
206 elem *toElem(IRState *irs); | |
207 dt_t **toDt(dt_t **pdt); | |
40 | 208 // LLVMDC |
209 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 210 }; |
211 | |
212 struct ComplexExp : Expression | |
213 { | |
214 complex_t value; | |
215 | |
216 ComplexExp(Loc loc, complex_t value, Type *type); | |
217 int equals(Object *o); | |
218 Expression *semantic(Scope *sc); | |
219 Expression *interpret(InterState *istate); | |
220 char *toChars(); | |
221 integer_t toInteger(); | |
222 uinteger_t toUInteger(); | |
223 real_t toReal(); | |
224 real_t toImaginary(); | |
225 complex_t toComplex(); | |
226 Expression *castTo(Scope *sc, Type *t); | |
227 int isConst(); | |
228 int isBool(int result); | |
229 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
230 void toMangleBuffer(OutBuffer *buf); | |
231 #ifdef _DH | |
232 OutBuffer hexp; | |
233 #endif | |
234 elem *toElem(IRState *irs); | |
235 dt_t **toDt(dt_t **pdt); | |
90 | 236 // LLVMDC |
237 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 238 }; |
239 | |
240 struct IdentifierExp : Expression | |
241 { | |
242 Identifier *ident; | |
243 Declaration *var; | |
244 | |
245 IdentifierExp(Loc loc, Identifier *ident); | |
246 IdentifierExp(Loc loc, Declaration *var); | |
247 Expression *semantic(Scope *sc); | |
248 char *toChars(); | |
249 void dump(int indent); | |
250 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
251 Expression *toLvalue(Scope *sc, Expression *e); | |
252 }; | |
253 | |
254 struct DollarExp : IdentifierExp | |
255 { | |
256 DollarExp(Loc loc); | |
257 }; | |
258 | |
259 struct DsymbolExp : Expression | |
260 { | |
261 Dsymbol *s; | |
262 | |
263 DsymbolExp(Loc loc, Dsymbol *s); | |
264 Expression *semantic(Scope *sc); | |
265 char *toChars(); | |
266 void dump(int indent); | |
267 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
268 Expression *toLvalue(Scope *sc, Expression *e); | |
269 }; | |
270 | |
271 struct ThisExp : Expression | |
272 { | |
273 Declaration *var; | |
274 | |
275 ThisExp(Loc loc); | |
276 Expression *semantic(Scope *sc); | |
277 int isBool(int result); | |
278 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
279 Expression *toLvalue(Scope *sc, Expression *e); | |
280 void scanForNestedRef(Scope *sc); | |
281 | |
282 int inlineCost(InlineCostState *ics); | |
283 Expression *doInline(InlineDoState *ids); | |
284 //Expression *inlineScan(InlineScanState *iss); | |
285 | |
286 elem *toElem(IRState *irs); | |
287 }; | |
288 | |
289 struct SuperExp : ThisExp | |
290 { | |
291 SuperExp(Loc loc); | |
292 Expression *semantic(Scope *sc); | |
293 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
294 void scanForNestedRef(Scope *sc); | |
295 | |
296 int inlineCost(InlineCostState *ics); | |
297 Expression *doInline(InlineDoState *ids); | |
298 //Expression *inlineScan(InlineScanState *iss); | |
299 }; | |
300 | |
301 struct NullExp : Expression | |
302 { | |
303 unsigned char committed; // !=0 if type is committed | |
304 | |
305 NullExp(Loc loc); | |
306 Expression *semantic(Scope *sc); | |
307 int isBool(int result); | |
308 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
309 void toMangleBuffer(OutBuffer *buf); | |
310 MATCH implicitConvTo(Type *t); | |
311 Expression *castTo(Scope *sc, Type *t); | |
312 Expression *interpret(InterState *istate); | |
313 elem *toElem(IRState *irs); | |
314 dt_t **toDt(dt_t **pdt); | |
40 | 315 // LLVMDC |
316 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 317 }; |
318 | |
319 struct StringExp : Expression | |
320 { | |
321 void *string; // char, wchar, or dchar data | |
322 size_t len; // number of chars, wchars, or dchars | |
323 unsigned char sz; // 1: char, 2: wchar, 4: dchar | |
324 unsigned char committed; // !=0 if type is committed | |
325 unsigned char postfix; // 'c', 'w', 'd' | |
326 | |
327 StringExp(Loc loc, char *s); | |
328 StringExp(Loc loc, void *s, size_t len); | |
329 StringExp(Loc loc, void *s, size_t len, unsigned char postfix); | |
330 //Expression *syntaxCopy(); | |
331 int equals(Object *o); | |
332 char *toChars(); | |
333 Expression *semantic(Scope *sc); | |
334 Expression *interpret(InterState *istate); | |
335 StringExp *toUTF8(Scope *sc); | |
336 MATCH implicitConvTo(Type *t); | |
337 Expression *castTo(Scope *sc, Type *t); | |
338 int compare(Object *obj); | |
339 int isBool(int result); | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
19
diff
changeset
|
340 unsigned charAt(size_t i); |
1 | 341 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
342 void toMangleBuffer(OutBuffer *buf); | |
343 elem *toElem(IRState *irs); | |
344 dt_t **toDt(dt_t **pdt); | |
40 | 345 // LLVMDC |
346 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 347 }; |
348 | |
349 // Tuple | |
350 | |
351 struct TupleExp : Expression | |
352 { | |
353 Expressions *exps; | |
354 | |
355 TupleExp(Loc loc, Expressions *exps); | |
356 TupleExp(Loc loc, TupleDeclaration *tup); | |
357 Expression *syntaxCopy(); | |
358 int equals(Object *o); | |
359 Expression *semantic(Scope *sc); | |
360 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
361 void scanForNestedRef(Scope *sc); | |
362 void checkEscape(); | |
363 int checkSideEffect(int flag); | |
364 Expression *optimize(int result); | |
365 Expression *interpret(InterState *istate); | |
366 Expression *castTo(Scope *sc, Type *t); | |
367 | |
368 int inlineCost(InlineCostState *ics); | |
369 Expression *doInline(InlineDoState *ids); | |
370 Expression *inlineScan(InlineScanState *iss); | |
371 }; | |
372 | |
373 struct ArrayLiteralExp : Expression | |
374 { | |
375 Expressions *elements; | |
376 | |
377 ArrayLiteralExp(Loc loc, Expressions *elements); | |
378 ArrayLiteralExp(Loc loc, Expression *e); | |
379 | |
380 Expression *syntaxCopy(); | |
381 Expression *semantic(Scope *sc); | |
382 int isBool(int result); | |
383 elem *toElem(IRState *irs); | |
384 int checkSideEffect(int flag); | |
385 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
386 void toMangleBuffer(OutBuffer *buf); | |
387 void scanForNestedRef(Scope *sc); | |
388 Expression *optimize(int result); | |
389 Expression *interpret(InterState *istate); | |
390 MATCH implicitConvTo(Type *t); | |
391 Expression *castTo(Scope *sc, Type *t); | |
392 dt_t **toDt(dt_t **pdt); | |
393 | |
394 int inlineCost(InlineCostState *ics); | |
395 Expression *doInline(InlineDoState *ids); | |
396 Expression *inlineScan(InlineScanState *iss); | |
40 | 397 // LLVMDC |
398 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 399 }; |
400 | |
401 struct AssocArrayLiteralExp : Expression | |
402 { | |
403 Expressions *keys; | |
404 Expressions *values; | |
405 | |
406 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); | |
407 | |
408 Expression *syntaxCopy(); | |
409 Expression *semantic(Scope *sc); | |
410 int isBool(int result); | |
411 elem *toElem(IRState *irs); | |
412 int checkSideEffect(int flag); | |
413 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
414 void toMangleBuffer(OutBuffer *buf); | |
415 void scanForNestedRef(Scope *sc); | |
416 Expression *optimize(int result); | |
417 Expression *interpret(InterState *istate); | |
418 MATCH implicitConvTo(Type *t); | |
419 Expression *castTo(Scope *sc, Type *t); | |
420 | |
421 int inlineCost(InlineCostState *ics); | |
422 Expression *doInline(InlineDoState *ids); | |
423 Expression *inlineScan(InlineScanState *iss); | |
40 | 424 // LLVMDC |
425 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 426 }; |
427 | |
428 struct StructLiteralExp : Expression | |
429 { | |
430 StructDeclaration *sd; // which aggregate this is for | |
431 Expressions *elements; // parallels sd->fields[] with | |
432 // NULL entries for fields to skip | |
433 | |
434 Symbol *sym; // back end symbol to initialize with literal | |
435 size_t soffset; // offset from start of s | |
436 int fillHoles; // fill alignment 'holes' with zero | |
437 | |
438 StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements); | |
439 | |
440 Expression *syntaxCopy(); | |
441 Expression *semantic(Scope *sc); | |
442 Expression *getField(Type *type, unsigned offset); | |
443 int getFieldIndex(Type *type, unsigned offset); | |
444 elem *toElem(IRState *irs); | |
445 int checkSideEffect(int flag); | |
446 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
447 void toMangleBuffer(OutBuffer *buf); | |
448 void scanForNestedRef(Scope *sc); | |
449 Expression *optimize(int result); | |
450 Expression *interpret(InterState *istate); | |
451 dt_t **toDt(dt_t **pdt); | |
452 Expression *toLvalue(Scope *sc, Expression *e); | |
453 | |
454 int inlineCost(InlineCostState *ics); | |
455 Expression *doInline(InlineDoState *ids); | |
456 Expression *inlineScan(InlineScanState *iss); | |
40 | 457 // LLVMDC |
458 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 459 }; |
460 | |
461 struct TypeDotIdExp : Expression | |
462 { | |
463 Identifier *ident; | |
464 | |
465 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); | |
466 Expression *syntaxCopy(); | |
467 Expression *semantic(Scope *sc); | |
468 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
469 elem *toElem(IRState *irs); | |
470 }; | |
471 | |
472 struct TypeExp : Expression | |
473 { | |
474 TypeExp(Loc loc, Type *type); | |
475 Expression *semantic(Scope *sc); | |
476 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
477 Expression *optimize(int result); | |
478 elem *toElem(IRState *irs); | |
479 }; | |
480 | |
481 struct ScopeExp : Expression | |
482 { | |
483 ScopeDsymbol *sds; | |
484 | |
485 ScopeExp(Loc loc, ScopeDsymbol *sds); | |
486 Expression *syntaxCopy(); | |
487 Expression *semantic(Scope *sc); | |
488 elem *toElem(IRState *irs); | |
489 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
490 }; | |
491 | |
492 struct TemplateExp : Expression | |
493 { | |
494 TemplateDeclaration *td; | |
495 | |
496 TemplateExp(Loc loc, TemplateDeclaration *td); | |
497 void rvalue(); | |
498 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
499 }; | |
500 | |
501 struct NewExp : Expression | |
502 { | |
503 /* thisexp.new(newargs) newtype(arguments) | |
504 */ | |
505 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
506 Expressions *newargs; // Array of Expression's to call new operator | |
507 Type *newtype; | |
508 Expressions *arguments; // Array of Expression's | |
509 | |
510 CtorDeclaration *member; // constructor function | |
511 NewDeclaration *allocator; // allocator function | |
512 int onstack; // allocate on stack | |
513 | |
514 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
515 Type *newtype, Expressions *arguments); | |
516 Expression *syntaxCopy(); | |
517 Expression *semantic(Scope *sc); | |
518 elem *toElem(IRState *irs); | |
519 int checkSideEffect(int flag); | |
520 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
521 void scanForNestedRef(Scope *sc); | |
522 | |
523 //int inlineCost(InlineCostState *ics); | |
524 Expression *doInline(InlineDoState *ids); | |
525 //Expression *inlineScan(InlineScanState *iss); | |
526 }; | |
527 | |
528 struct NewAnonClassExp : Expression | |
529 { | |
530 /* thisexp.new(newargs) class baseclasses { } (arguments) | |
531 */ | |
532 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
533 Expressions *newargs; // Array of Expression's to call new operator | |
534 ClassDeclaration *cd; // class being instantiated | |
535 Expressions *arguments; // Array of Expression's to call class constructor | |
536 | |
537 NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
538 ClassDeclaration *cd, Expressions *arguments); | |
539 Expression *syntaxCopy(); | |
540 Expression *semantic(Scope *sc); | |
541 int checkSideEffect(int flag); | |
542 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
543 }; | |
544 | |
545 // Offset from symbol | |
546 | |
547 struct SymOffExp : Expression | |
548 { | |
549 Declaration *var; | |
550 unsigned offset; | |
551 | |
552 SymOffExp(Loc loc, Declaration *var, unsigned offset); | |
553 Expression *semantic(Scope *sc); | |
554 void checkEscape(); | |
555 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
556 int isConst(); | |
557 int isBool(int result); | |
558 Expression *doInline(InlineDoState *ids); | |
559 MATCH implicitConvTo(Type *t); | |
560 Expression *castTo(Scope *sc, Type *t); | |
561 void scanForNestedRef(Scope *sc); | |
562 | |
563 elem *toElem(IRState *irs); | |
564 dt_t **toDt(dt_t **pdt); | |
565 }; | |
566 | |
567 // Variable | |
568 | |
569 struct VarExp : Expression | |
570 { | |
571 Declaration *var; | |
572 | |
573 VarExp(Loc loc, Declaration *var); | |
574 int equals(Object *o); | |
575 Expression *semantic(Scope *sc); | |
576 Expression *optimize(int result); | |
577 Expression *interpret(InterState *istate); | |
578 void dump(int indent); | |
579 char *toChars(); | |
580 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
581 void checkEscape(); | |
582 Expression *toLvalue(Scope *sc, Expression *e); | |
583 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
584 elem *toElem(IRState *irs); | |
585 dt_t **toDt(dt_t **pdt); | |
586 void scanForNestedRef(Scope *sc); | |
587 | |
588 int inlineCost(InlineCostState *ics); | |
589 Expression *doInline(InlineDoState *ids); | |
590 //Expression *inlineScan(InlineScanState *iss); | |
40 | 591 // LLVMDC |
592 virtual llvm::Constant *toConstElem(IRState *irs); | |
1 | 593 }; |
594 | |
595 // Function/Delegate literal | |
596 | |
597 struct FuncExp : Expression | |
598 { | |
599 FuncLiteralDeclaration *fd; | |
600 | |
601 FuncExp(Loc loc, FuncLiteralDeclaration *fd); | |
602 Expression *syntaxCopy(); | |
603 Expression *semantic(Scope *sc); | |
604 void scanForNestedRef(Scope *sc); | |
605 char *toChars(); | |
606 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
607 elem *toElem(IRState *irs); | |
608 | |
609 int inlineCost(InlineCostState *ics); | |
610 //Expression *doInline(InlineDoState *ids); | |
611 //Expression *inlineScan(InlineScanState *iss); | |
612 }; | |
613 | |
614 // Declaration of a symbol | |
615 | |
616 struct DeclarationExp : Expression | |
617 { | |
618 Dsymbol *declaration; | |
619 | |
620 DeclarationExp(Loc loc, Dsymbol *declaration); | |
621 Expression *syntaxCopy(); | |
622 Expression *semantic(Scope *sc); | |
623 Expression *interpret(InterState *istate); | |
624 int checkSideEffect(int flag); | |
625 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
626 elem *toElem(IRState *irs); | |
627 void scanForNestedRef(Scope *sc); | |
628 | |
629 int inlineCost(InlineCostState *ics); | |
630 Expression *doInline(InlineDoState *ids); | |
631 Expression *inlineScan(InlineScanState *iss); | |
632 }; | |
633 | |
634 struct TypeidExp : Expression | |
635 { | |
636 Type *typeidType; | |
637 | |
638 TypeidExp(Loc loc, Type *typeidType); | |
639 Expression *syntaxCopy(); | |
640 Expression *semantic(Scope *sc); | |
641 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
642 }; | |
643 | |
644 struct HaltExp : Expression | |
645 { | |
646 HaltExp(Loc loc); | |
647 Expression *semantic(Scope *sc); | |
648 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
649 int checkSideEffect(int flag); | |
650 | |
651 elem *toElem(IRState *irs); | |
652 }; | |
653 | |
19 | 654 struct IsExp : Expression |
1 | 655 { |
656 /* is(targ id tok tspec) | |
657 * is(targ id == tok2) | |
658 */ | |
659 Type *targ; | |
660 Identifier *id; // can be NULL | |
661 enum TOK tok; // ':' or '==' | |
662 Type *tspec; // can be NULL | |
663 enum TOK tok2; // 'struct', 'union', 'typedef', etc. | |
664 | |
19 | 665 IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); |
1 | 666 Expression *syntaxCopy(); |
667 Expression *semantic(Scope *sc); | |
668 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
669 }; | |
670 | |
671 /****************************************************************/ | |
672 | |
673 struct UnaExp : Expression | |
674 { | |
675 Expression *e1; | |
676 | |
677 UnaExp(Loc loc, enum TOK op, int size, Expression *e1); | |
678 Expression *syntaxCopy(); | |
679 Expression *semantic(Scope *sc); | |
680 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
681 Expression *optimize(int result); | |
682 void dump(int indent); | |
683 void scanForNestedRef(Scope *sc); | |
684 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *)); | |
685 | |
686 int inlineCost(InlineCostState *ics); | |
687 Expression *doInline(InlineDoState *ids); | |
688 Expression *inlineScan(InlineScanState *iss); | |
689 | |
690 Expression *op_overload(Scope *sc); // doesn't need to be virtual | |
691 }; | |
692 | |
693 struct BinExp : Expression | |
694 { | |
695 Expression *e1; | |
696 Expression *e2; | |
697 | |
698 BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
699 Expression *syntaxCopy(); | |
700 Expression *semantic(Scope *sc); | |
701 Expression *semanticp(Scope *sc); | |
702 Expression *commonSemanticAssign(Scope *sc); | |
703 Expression *commonSemanticAssignIntegral(Scope *sc); | |
704 int checkSideEffect(int flag); | |
705 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
706 Expression *scaleFactor(Scope *sc); | |
707 Expression *typeCombine(Scope *sc); | |
708 Expression *optimize(int result); | |
709 int isunsigned(); | |
710 void incompatibleTypes(); | |
711 void dump(int indent); | |
712 void scanForNestedRef(Scope *sc); | |
713 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); | |
714 Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); | |
715 Expression *interpretAssignCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *), int post = 0); | |
716 | |
717 int inlineCost(InlineCostState *ics); | |
718 Expression *doInline(InlineDoState *ids); | |
719 Expression *inlineScan(InlineScanState *iss); | |
720 | |
721 Expression *op_overload(Scope *sc); | |
722 | |
723 elem *toElemBin(IRState *irs, int op); | |
724 }; | |
725 | |
726 struct BinAssignExp : BinExp | |
727 { | |
728 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
729 int checkSideEffect(int flag); | |
730 }; | |
731 | |
732 /****************************************************************/ | |
733 | |
734 struct CompileExp : UnaExp | |
735 { | |
736 CompileExp(Loc loc, Expression *e); | |
737 Expression *semantic(Scope *sc); | |
738 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
739 }; | |
740 | |
741 struct FileExp : UnaExp | |
742 { | |
743 FileExp(Loc loc, Expression *e); | |
744 Expression *semantic(Scope *sc); | |
745 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
746 }; | |
747 | |
748 struct AssertExp : UnaExp | |
749 { | |
750 Expression *msg; | |
751 | |
752 AssertExp(Loc loc, Expression *e, Expression *msg = NULL); | |
753 Expression *syntaxCopy(); | |
754 Expression *semantic(Scope *sc); | |
755 Expression *interpret(InterState *istate); | |
756 int checkSideEffect(int flag); | |
757 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
758 | |
759 int inlineCost(InlineCostState *ics); | |
760 Expression *doInline(InlineDoState *ids); | |
761 Expression *inlineScan(InlineScanState *iss); | |
762 | |
763 elem *toElem(IRState *irs); | |
764 }; | |
765 | |
766 struct DotIdExp : UnaExp | |
767 { | |
768 Identifier *ident; | |
769 | |
770 DotIdExp(Loc loc, Expression *e, Identifier *ident); | |
771 Expression *semantic(Scope *sc); | |
772 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
773 void dump(int i); | |
774 }; | |
775 | |
776 struct DotTemplateExp : UnaExp | |
777 { | |
778 TemplateDeclaration *td; | |
779 | |
780 DotTemplateExp(Loc loc, Expression *e, TemplateDeclaration *td); | |
781 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
782 }; | |
783 | |
784 struct DotVarExp : UnaExp | |
785 { | |
786 Declaration *var; | |
787 | |
788 DotVarExp(Loc loc, Expression *e, Declaration *var); | |
789 Expression *semantic(Scope *sc); | |
790 Expression *toLvalue(Scope *sc, Expression *e); | |
791 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
792 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
793 void dump(int indent); | |
794 elem *toElem(IRState *irs); | |
795 }; | |
796 | |
797 struct DotTemplateInstanceExp : UnaExp | |
798 { | |
799 TemplateInstance *ti; | |
800 | |
801 DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); | |
802 Expression *syntaxCopy(); | |
803 Expression *semantic(Scope *sc); | |
804 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
805 void dump(int indent); | |
806 }; | |
807 | |
808 struct DelegateExp : UnaExp | |
809 { | |
810 FuncDeclaration *func; | |
811 | |
812 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); | |
813 Expression *semantic(Scope *sc); | |
814 MATCH implicitConvTo(Type *t); | |
815 Expression *castTo(Scope *sc, Type *t); | |
816 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
817 void dump(int indent); | |
818 | |
819 int inlineCost(InlineCostState *ics); | |
820 elem *toElem(IRState *irs); | |
821 }; | |
822 | |
823 struct DotTypeExp : UnaExp | |
824 { | |
825 Dsymbol *sym; // symbol that represents a type | |
826 | |
827 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | |
828 Expression *semantic(Scope *sc); | |
829 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
830 elem *toElem(IRState *irs); | |
831 }; | |
832 | |
833 struct CallExp : UnaExp | |
834 { | |
835 Expressions *arguments; // function arguments | |
836 | |
837 CallExp(Loc loc, Expression *e, Expressions *exps); | |
838 CallExp(Loc loc, Expression *e); | |
839 CallExp(Loc loc, Expression *e, Expression *earg1); | |
840 CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); | |
841 | |
842 Expression *syntaxCopy(); | |
843 Expression *semantic(Scope *sc); | |
844 Expression *optimize(int result); | |
845 Expression *interpret(InterState *istate); | |
846 int checkSideEffect(int flag); | |
847 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
848 void dump(int indent); | |
849 elem *toElem(IRState *irs); | |
850 void scanForNestedRef(Scope *sc); | |
851 Expression *toLvalue(Scope *sc, Expression *e); | |
852 | |
853 int inlineCost(InlineCostState *ics); | |
854 Expression *doInline(InlineDoState *ids); | |
855 Expression *inlineScan(InlineScanState *iss); | |
856 }; | |
857 | |
858 struct AddrExp : UnaExp | |
859 { | |
860 AddrExp(Loc loc, Expression *e); | |
861 Expression *semantic(Scope *sc); | |
862 elem *toElem(IRState *irs); | |
863 MATCH implicitConvTo(Type *t); | |
864 Expression *castTo(Scope *sc, Type *t); | |
865 Expression *optimize(int result); | |
866 }; | |
867 | |
868 struct PtrExp : UnaExp | |
869 { | |
870 PtrExp(Loc loc, Expression *e); | |
871 PtrExp(Loc loc, Expression *e, Type *t); | |
872 Expression *semantic(Scope *sc); | |
873 Expression *toLvalue(Scope *sc, Expression *e); | |
874 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
875 elem *toElem(IRState *irs); | |
876 Expression *optimize(int result); | |
877 Expression *interpret(InterState *istate); | |
878 }; | |
879 | |
880 struct NegExp : UnaExp | |
881 { | |
882 NegExp(Loc loc, Expression *e); | |
883 Expression *semantic(Scope *sc); | |
884 Expression *optimize(int result); | |
885 Expression *interpret(InterState *istate); | |
886 | |
887 // For operator overloading | |
888 Identifier *opId(); | |
889 | |
890 elem *toElem(IRState *irs); | |
891 }; | |
892 | |
893 struct UAddExp : UnaExp | |
894 { | |
895 UAddExp(Loc loc, Expression *e); | |
896 Expression *semantic(Scope *sc); | |
897 | |
898 // For operator overloading | |
899 Identifier *opId(); | |
900 }; | |
901 | |
902 struct ComExp : UnaExp | |
903 { | |
904 ComExp(Loc loc, Expression *e); | |
905 Expression *semantic(Scope *sc); | |
906 Expression *optimize(int result); | |
907 Expression *interpret(InterState *istate); | |
908 | |
909 // For operator overloading | |
910 Identifier *opId(); | |
911 | |
912 elem *toElem(IRState *irs); | |
913 }; | |
914 | |
915 struct NotExp : UnaExp | |
916 { | |
917 NotExp(Loc loc, Expression *e); | |
918 Expression *semantic(Scope *sc); | |
919 Expression *optimize(int result); | |
920 Expression *interpret(InterState *istate); | |
921 int isBit(); | |
922 elem *toElem(IRState *irs); | |
923 }; | |
924 | |
925 struct BoolExp : UnaExp | |
926 { | |
927 BoolExp(Loc loc, Expression *e, Type *type); | |
928 Expression *semantic(Scope *sc); | |
929 Expression *optimize(int result); | |
930 Expression *interpret(InterState *istate); | |
931 int isBit(); | |
932 elem *toElem(IRState *irs); | |
933 }; | |
934 | |
935 struct DeleteExp : UnaExp | |
936 { | |
937 DeleteExp(Loc loc, Expression *e); | |
938 Expression *semantic(Scope *sc); | |
939 Expression *checkToBoolean(); | |
940 int checkSideEffect(int flag); | |
941 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
942 elem *toElem(IRState *irs); | |
943 }; | |
944 | |
945 struct CastExp : UnaExp | |
946 { | |
947 // Possible to cast to one type while painting to another type | |
948 Type *to; // type to cast to | |
949 | |
950 CastExp(Loc loc, Expression *e, Type *t); | |
951 Expression *syntaxCopy(); | |
952 Expression *semantic(Scope *sc); | |
953 Expression *optimize(int result); | |
954 Expression *interpret(InterState *istate); | |
955 int checkSideEffect(int flag); | |
956 void checkEscape(); | |
957 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
958 elem *toElem(IRState *irs); | |
959 | |
960 // For operator overloading | |
961 Identifier *opId(); | |
962 }; | |
963 | |
964 | |
965 struct SliceExp : UnaExp | |
966 { | |
967 Expression *upr; // NULL if implicit 0 | |
968 Expression *lwr; // NULL if implicit [length - 1] | |
969 VarDeclaration *lengthVar; | |
970 | |
971 SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); | |
972 Expression *syntaxCopy(); | |
973 Expression *semantic(Scope *sc); | |
974 void checkEscape(); | |
975 Expression *toLvalue(Scope *sc, Expression *e); | |
976 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
977 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
978 Expression *optimize(int result); | |
979 Expression *interpret(InterState *istate); | |
980 void dump(int indent); | |
981 elem *toElem(IRState *irs); | |
982 void scanForNestedRef(Scope *sc); | |
983 | |
984 int inlineCost(InlineCostState *ics); | |
985 Expression *doInline(InlineDoState *ids); | |
986 Expression *inlineScan(InlineScanState *iss); | |
987 }; | |
988 | |
989 struct ArrayLengthExp : UnaExp | |
990 { | |
991 ArrayLengthExp(Loc loc, Expression *e1); | |
992 Expression *semantic(Scope *sc); | |
993 Expression *optimize(int result); | |
994 Expression *interpret(InterState *istate); | |
995 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
996 elem *toElem(IRState *irs); | |
997 }; | |
998 | |
999 // e1[a0,a1,a2,a3,...] | |
1000 | |
1001 struct ArrayExp : UnaExp | |
1002 { | |
1003 Expressions *arguments; // Array of Expression's | |
1004 | |
1005 ArrayExp(Loc loc, Expression *e1, Expressions *arguments); | |
1006 Expression *syntaxCopy(); | |
1007 Expression *semantic(Scope *sc); | |
1008 Expression *toLvalue(Scope *sc, Expression *e); | |
1009 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1010 void scanForNestedRef(Scope *sc); | |
1011 | |
1012 // For operator overloading | |
1013 Identifier *opId(); | |
1014 | |
1015 int inlineCost(InlineCostState *ics); | |
1016 Expression *doInline(InlineDoState *ids); | |
1017 Expression *inlineScan(InlineScanState *iss); | |
1018 }; | |
1019 | |
1020 /****************************************************************/ | |
1021 | |
1022 struct DotExp : BinExp | |
1023 { | |
1024 DotExp(Loc loc, Expression *e1, Expression *e2); | |
1025 Expression *semantic(Scope *sc); | |
1026 }; | |
1027 | |
1028 struct CommaExp : BinExp | |
1029 { | |
1030 CommaExp(Loc loc, Expression *e1, Expression *e2); | |
1031 Expression *semantic(Scope *sc); | |
1032 void checkEscape(); | |
1033 Expression *toLvalue(Scope *sc, Expression *e); | |
1034 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1035 int isBool(int result); | |
1036 int checkSideEffect(int flag); | |
1037 Expression *optimize(int result); | |
1038 Expression *interpret(InterState *istate); | |
1039 elem *toElem(IRState *irs); | |
1040 }; | |
1041 | |
1042 struct IndexExp : BinExp | |
1043 { | |
1044 VarDeclaration *lengthVar; | |
1045 int modifiable; | |
1046 | |
1047 IndexExp(Loc loc, Expression *e1, Expression *e2); | |
1048 Expression *semantic(Scope *sc); | |
1049 Expression *toLvalue(Scope *sc, Expression *e); | |
1050 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1051 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1052 Expression *optimize(int result); | |
1053 Expression *interpret(InterState *istate); | |
1054 Expression *doInline(InlineDoState *ids); | |
1055 void scanForNestedRef(Scope *sc); | |
1056 | |
1057 elem *toElem(IRState *irs); | |
1058 }; | |
1059 | |
1060 /* For both i++ and i-- | |
1061 */ | |
1062 struct PostExp : BinExp | |
1063 { | |
1064 PostExp(enum TOK op, Loc loc, Expression *e); | |
1065 Expression *semantic(Scope *sc); | |
1066 Expression *interpret(InterState *istate); | |
1067 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1068 Identifier *opId(); // For operator overloading | |
1069 elem *toElem(IRState *irs); | |
1070 }; | |
1071 | |
1072 struct AssignExp : BinExp | |
1073 { int ismemset; // !=0 if setting the contents of an array | |
1074 | |
1075 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1076 Expression *semantic(Scope *sc); | |
1077 Expression *checkToBoolean(); | |
1078 Expression *interpret(InterState *istate); | |
1079 Identifier *opId(); // For operator overloading | |
1080 elem *toElem(IRState *irs); | |
1081 }; | |
1082 | |
1083 #define ASSIGNEXP(op) \ | |
1084 struct op##AssignExp : BinExp \ | |
1085 { \ | |
1086 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1087 Expression *semantic(Scope *sc); \ | |
1088 Expression *interpret(InterState *istate); \ | |
1089 \ | |
1090 Identifier *opId(); /* For operator overloading */ \ | |
1091 \ | |
1092 elem *toElem(IRState *irs); \ | |
1093 }; | |
1094 | |
1095 ASSIGNEXP(Add) | |
1096 ASSIGNEXP(Min) | |
1097 ASSIGNEXP(Cat) | |
1098 ASSIGNEXP(Mul) | |
1099 ASSIGNEXP(Div) | |
1100 ASSIGNEXP(Mod) | |
1101 ASSIGNEXP(Shl) | |
1102 ASSIGNEXP(Shr) | |
1103 ASSIGNEXP(Ushr) | |
1104 ASSIGNEXP(And) | |
1105 ASSIGNEXP(Or) | |
1106 ASSIGNEXP(Xor) | |
1107 | |
1108 #undef ASSIGNEXP | |
1109 | |
1110 struct AddExp : BinExp | |
1111 { | |
1112 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1113 Expression *semantic(Scope *sc); | |
1114 Expression *optimize(int result); | |
1115 Expression *interpret(InterState *istate); | |
1116 | |
1117 // For operator overloading | |
1118 int isCommutative(); | |
1119 Identifier *opId(); | |
1120 Identifier *opId_r(); | |
1121 | |
1122 elem *toElem(IRState *irs); | |
1123 }; | |
1124 | |
1125 struct MinExp : BinExp | |
1126 { | |
1127 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1128 Expression *semantic(Scope *sc); | |
1129 Expression *optimize(int result); | |
1130 Expression *interpret(InterState *istate); | |
1131 | |
1132 // For operator overloading | |
1133 Identifier *opId(); | |
1134 Identifier *opId_r(); | |
1135 | |
1136 elem *toElem(IRState *irs); | |
1137 }; | |
1138 | |
1139 struct CatExp : BinExp | |
1140 { | |
1141 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1142 Expression *semantic(Scope *sc); | |
1143 Expression *optimize(int result); | |
1144 Expression *interpret(InterState *istate); | |
1145 | |
1146 // For operator overloading | |
1147 Identifier *opId(); | |
1148 Identifier *opId_r(); | |
1149 | |
1150 elem *toElem(IRState *irs); | |
1151 }; | |
1152 | |
1153 struct MulExp : BinExp | |
1154 { | |
1155 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1156 Expression *semantic(Scope *sc); | |
1157 Expression *optimize(int result); | |
1158 Expression *interpret(InterState *istate); | |
1159 | |
1160 // For operator overloading | |
1161 int isCommutative(); | |
1162 Identifier *opId(); | |
1163 Identifier *opId_r(); | |
1164 | |
1165 elem *toElem(IRState *irs); | |
1166 }; | |
1167 | |
1168 struct DivExp : BinExp | |
1169 { | |
1170 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1171 Expression *semantic(Scope *sc); | |
1172 Expression *optimize(int result); | |
1173 Expression *interpret(InterState *istate); | |
1174 | |
1175 // For operator overloading | |
1176 Identifier *opId(); | |
1177 Identifier *opId_r(); | |
1178 | |
1179 elem *toElem(IRState *irs); | |
1180 }; | |
1181 | |
1182 struct ModExp : BinExp | |
1183 { | |
1184 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1185 Expression *semantic(Scope *sc); | |
1186 Expression *optimize(int result); | |
1187 Expression *interpret(InterState *istate); | |
1188 | |
1189 // For operator overloading | |
1190 Identifier *opId(); | |
1191 Identifier *opId_r(); | |
1192 | |
1193 elem *toElem(IRState *irs); | |
1194 }; | |
1195 | |
1196 struct ShlExp : BinExp | |
1197 { | |
1198 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1199 Expression *semantic(Scope *sc); | |
1200 Expression *optimize(int result); | |
1201 Expression *interpret(InterState *istate); | |
1202 | |
1203 // For operator overloading | |
1204 Identifier *opId(); | |
1205 Identifier *opId_r(); | |
1206 | |
1207 elem *toElem(IRState *irs); | |
1208 }; | |
1209 | |
1210 struct ShrExp : BinExp | |
1211 { | |
1212 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1213 Expression *semantic(Scope *sc); | |
1214 Expression *optimize(int result); | |
1215 Expression *interpret(InterState *istate); | |
1216 | |
1217 // For operator overloading | |
1218 Identifier *opId(); | |
1219 Identifier *opId_r(); | |
1220 | |
1221 elem *toElem(IRState *irs); | |
1222 }; | |
1223 | |
1224 struct UshrExp : BinExp | |
1225 { | |
1226 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1227 Expression *semantic(Scope *sc); | |
1228 Expression *optimize(int result); | |
1229 Expression *interpret(InterState *istate); | |
1230 | |
1231 // For operator overloading | |
1232 Identifier *opId(); | |
1233 Identifier *opId_r(); | |
1234 | |
1235 elem *toElem(IRState *irs); | |
1236 }; | |
1237 | |
1238 struct AndExp : BinExp | |
1239 { | |
1240 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1241 Expression *semantic(Scope *sc); | |
1242 Expression *optimize(int result); | |
1243 Expression *interpret(InterState *istate); | |
1244 | |
1245 // For operator overloading | |
1246 int isCommutative(); | |
1247 Identifier *opId(); | |
1248 Identifier *opId_r(); | |
1249 | |
1250 elem *toElem(IRState *irs); | |
1251 }; | |
1252 | |
1253 struct OrExp : BinExp | |
1254 { | |
1255 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1256 Expression *semantic(Scope *sc); | |
1257 Expression *optimize(int result); | |
1258 Expression *interpret(InterState *istate); | |
1259 | |
1260 // For operator overloading | |
1261 int isCommutative(); | |
1262 Identifier *opId(); | |
1263 Identifier *opId_r(); | |
1264 | |
1265 elem *toElem(IRState *irs); | |
1266 }; | |
1267 | |
1268 struct XorExp : BinExp | |
1269 { | |
1270 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1271 Expression *semantic(Scope *sc); | |
1272 Expression *optimize(int result); | |
1273 Expression *interpret(InterState *istate); | |
1274 | |
1275 // For operator overloading | |
1276 int isCommutative(); | |
1277 Identifier *opId(); | |
1278 Identifier *opId_r(); | |
1279 | |
1280 elem *toElem(IRState *irs); | |
1281 }; | |
1282 | |
1283 struct OrOrExp : BinExp | |
1284 { | |
1285 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1286 Expression *semantic(Scope *sc); | |
1287 Expression *checkToBoolean(); | |
1288 int isBit(); | |
1289 Expression *optimize(int result); | |
1290 Expression *interpret(InterState *istate); | |
1291 int checkSideEffect(int flag); | |
1292 elem *toElem(IRState *irs); | |
1293 }; | |
1294 | |
1295 struct AndAndExp : BinExp | |
1296 { | |
1297 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1298 Expression *semantic(Scope *sc); | |
1299 Expression *checkToBoolean(); | |
1300 int isBit(); | |
1301 Expression *optimize(int result); | |
1302 Expression *interpret(InterState *istate); | |
1303 int checkSideEffect(int flag); | |
1304 elem *toElem(IRState *irs); | |
1305 }; | |
1306 | |
1307 struct CmpExp : BinExp | |
1308 { | |
1309 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1310 Expression *semantic(Scope *sc); | |
1311 Expression *optimize(int result); | |
1312 Expression *interpret(InterState *istate); | |
1313 int isBit(); | |
1314 | |
1315 // For operator overloading | |
1316 int isCommutative(); | |
1317 Identifier *opId(); | |
1318 | |
1319 elem *toElem(IRState *irs); | |
1320 }; | |
1321 | |
1322 struct InExp : BinExp | |
1323 { | |
1324 InExp(Loc loc, Expression *e1, Expression *e2); | |
1325 Expression *semantic(Scope *sc); | |
1326 int isBit(); | |
1327 | |
1328 // For operator overloading | |
1329 Identifier *opId(); | |
1330 Identifier *opId_r(); | |
1331 | |
1332 elem *toElem(IRState *irs); | |
1333 }; | |
1334 | |
1335 struct RemoveExp : BinExp | |
1336 { | |
1337 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1338 elem *toElem(IRState *irs); | |
1339 }; | |
1340 | |
1341 // == and != | |
1342 | |
1343 struct EqualExp : BinExp | |
1344 { | |
1345 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1346 Expression *semantic(Scope *sc); | |
1347 Expression *optimize(int result); | |
1348 Expression *interpret(InterState *istate); | |
1349 int isBit(); | |
1350 | |
1351 // For operator overloading | |
1352 int isCommutative(); | |
1353 Identifier *opId(); | |
1354 | |
1355 elem *toElem(IRState *irs); | |
1356 }; | |
1357 | |
1358 // === and !=== | |
1359 | |
1360 struct IdentityExp : BinExp | |
1361 { | |
1362 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1363 Expression *semantic(Scope *sc); | |
1364 int isBit(); | |
1365 Expression *optimize(int result); | |
1366 Expression *interpret(InterState *istate); | |
1367 elem *toElem(IRState *irs); | |
1368 }; | |
1369 | |
1370 /****************************************************************/ | |
1371 | |
1372 struct CondExp : BinExp | |
1373 { | |
1374 Expression *econd; | |
1375 | |
1376 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1377 Expression *syntaxCopy(); | |
1378 Expression *semantic(Scope *sc); | |
1379 Expression *optimize(int result); | |
1380 Expression *interpret(InterState *istate); | |
1381 void checkEscape(); | |
1382 Expression *toLvalue(Scope *sc, Expression *e); | |
1383 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1384 Expression *checkToBoolean(); | |
1385 int checkSideEffect(int flag); | |
1386 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1387 MATCH implicitConvTo(Type *t); | |
1388 Expression *castTo(Scope *sc, Type *t); | |
1389 void scanForNestedRef(Scope *sc); | |
1390 | |
1391 int inlineCost(InlineCostState *ics); | |
1392 Expression *doInline(InlineDoState *ids); | |
1393 Expression *inlineScan(InlineScanState *iss); | |
1394 | |
1395 elem *toElem(IRState *irs); | |
1396 }; | |
1397 | |
1398 | |
1399 /****************************************************************/ | |
1400 | |
1401 /* Special values used by the interpreter | |
1402 */ | |
1403 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1404 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1405 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1406 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1407 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1408 | |
1409 Expression *expType(Type *type, Expression *e); | |
1410 | |
1411 Expression *Neg(Type *type, Expression *e1); | |
1412 Expression *Com(Type *type, Expression *e1); | |
1413 Expression *Not(Type *type, Expression *e1); | |
1414 Expression *Bool(Type *type, Expression *e1); | |
1415 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1416 Expression *ArrayLength(Type *type, Expression *e1); | |
1417 Expression *Ptr(Type *type, Expression *e1); | |
1418 | |
1419 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1420 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1421 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1422 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1423 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1424 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1425 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1426 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1427 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1428 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1429 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1430 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1431 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1432 | |
1433 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1434 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1435 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1436 | |
1437 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1438 | |
1439 #endif /* DMD_EXPRESSION_H */ |