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