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