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