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