Mercurial > projects > ldc
annotate dmd/expression.h @ 837:331a176c1f4f
Removed error on naked, not fully complete, but I'll be doing more work on it during this Christmas, and some things do work.
Fixed taking delegate of final class method. see mini/delegate3.d.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Dec 2008 14:07:30 +0100 |
parents | 340acf1535d0 |
children | 7edce7e58ab1 |
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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
161 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
188 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
213 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
241 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
320 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
350 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
403 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
430 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
463 // LDC |
159 | 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); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
597 // LDC |
159 | 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); | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
631 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
632 // LDC |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
633 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 634 }; |
635 | |
636 // Declaration of a symbol | |
637 | |
638 struct DeclarationExp : Expression | |
639 { | |
640 Dsymbol *declaration; | |
641 | |
642 DeclarationExp(Loc loc, Dsymbol *declaration); | |
643 Expression *syntaxCopy(); | |
644 Expression *semantic(Scope *sc); | |
645 Expression *interpret(InterState *istate); | |
646 int checkSideEffect(int flag); | |
647 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
648 elem *toElem(IRState *irs); | |
649 void scanForNestedRef(Scope *sc); | |
650 | |
651 int inlineCost(InlineCostState *ics); | |
652 Expression *doInline(InlineDoState *ids); | |
653 Expression *inlineScan(InlineScanState *iss); | |
654 }; | |
655 | |
656 struct TypeidExp : Expression | |
657 { | |
658 Type *typeidType; | |
659 | |
660 TypeidExp(Loc loc, Type *typeidType); | |
661 Expression *syntaxCopy(); | |
662 Expression *semantic(Scope *sc); | |
663 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
664 }; | |
665 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
666 #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
|
667 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
|
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 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
|
670 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
|
671 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
672 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
|
673 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
|
674 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
|
675 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
|
676 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
677 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
678 |
159 | 679 struct HaltExp : Expression |
680 { | |
681 HaltExp(Loc loc); | |
682 Expression *semantic(Scope *sc); | |
683 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
684 int checkSideEffect(int flag); | |
685 | |
686 elem *toElem(IRState *irs); | |
687 }; | |
688 | |
689 struct IsExp : Expression | |
690 { | |
691 /* is(targ id tok tspec) | |
692 * is(targ id == tok2) | |
693 */ | |
694 Type *targ; | |
695 Identifier *id; // can be NULL | |
696 enum TOK tok; // ':' or '==' | |
697 Type *tspec; // can be NULL | |
698 enum TOK tok2; // 'struct', 'union', 'typedef', etc. | |
699 | |
700 IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); | |
701 Expression *syntaxCopy(); | |
702 Expression *semantic(Scope *sc); | |
703 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
704 }; | |
705 | |
706 /****************************************************************/ | |
707 | |
708 struct UnaExp : Expression | |
709 { | |
710 Expression *e1; | |
711 | |
712 UnaExp(Loc loc, enum TOK op, int size, Expression *e1); | |
713 Expression *syntaxCopy(); | |
714 Expression *semantic(Scope *sc); | |
715 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
716 Expression *optimize(int result); | |
717 void dump(int indent); | |
718 void scanForNestedRef(Scope *sc); | |
719 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *)); | |
720 | |
721 int inlineCost(InlineCostState *ics); | |
722 Expression *doInline(InlineDoState *ids); | |
723 Expression *inlineScan(InlineScanState *iss); | |
724 | |
725 Expression *op_overload(Scope *sc); // doesn't need to be virtual | |
726 }; | |
727 | |
728 struct BinExp : Expression | |
729 { | |
730 Expression *e1; | |
731 Expression *e2; | |
732 | |
733 BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
734 Expression *syntaxCopy(); | |
735 Expression *semantic(Scope *sc); | |
736 Expression *semanticp(Scope *sc); | |
737 Expression *commonSemanticAssign(Scope *sc); | |
738 Expression *commonSemanticAssignIntegral(Scope *sc); | |
739 int checkSideEffect(int flag); | |
740 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
741 Expression *scaleFactor(Scope *sc); | |
742 Expression *typeCombine(Scope *sc); | |
743 Expression *optimize(int result); | |
744 int isunsigned(); | |
745 void incompatibleTypes(); | |
746 void dump(int indent); | |
747 void scanForNestedRef(Scope *sc); | |
748 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); | |
749 Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); | |
750 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
|
751 Expression *arrayOp(Scope *sc); |
159 | 752 |
753 int inlineCost(InlineCostState *ics); | |
754 Expression *doInline(InlineDoState *ids); | |
755 Expression *inlineScan(InlineScanState *iss); | |
756 | |
757 Expression *op_overload(Scope *sc); | |
758 | |
759 elem *toElemBin(IRState *irs, int op); | |
760 }; | |
761 | |
762 struct BinAssignExp : BinExp | |
763 { | |
764 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
765 int checkSideEffect(int flag); | |
766 }; | |
767 | |
768 /****************************************************************/ | |
769 | |
770 struct CompileExp : UnaExp | |
771 { | |
772 CompileExp(Loc loc, Expression *e); | |
773 Expression *semantic(Scope *sc); | |
774 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
775 }; | |
776 | |
777 struct FileExp : UnaExp | |
778 { | |
779 FileExp(Loc loc, Expression *e); | |
780 Expression *semantic(Scope *sc); | |
781 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
782 }; | |
783 | |
784 struct AssertExp : UnaExp | |
785 { | |
786 Expression *msg; | |
787 | |
788 AssertExp(Loc loc, Expression *e, Expression *msg = NULL); | |
789 Expression *syntaxCopy(); | |
790 Expression *semantic(Scope *sc); | |
791 Expression *interpret(InterState *istate); | |
792 int checkSideEffect(int flag); | |
793 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
794 | |
795 int inlineCost(InlineCostState *ics); | |
796 Expression *doInline(InlineDoState *ids); | |
797 Expression *inlineScan(InlineScanState *iss); | |
798 | |
799 elem *toElem(IRState *irs); | |
800 }; | |
801 | |
802 struct DotIdExp : UnaExp | |
803 { | |
804 Identifier *ident; | |
805 | |
806 DotIdExp(Loc loc, Expression *e, Identifier *ident); | |
807 Expression *semantic(Scope *sc); | |
808 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
809 void dump(int i); | |
810 }; | |
811 | |
812 struct DotTemplateExp : UnaExp | |
813 { | |
814 TemplateDeclaration *td; | |
815 | |
816 DotTemplateExp(Loc loc, Expression *e, TemplateDeclaration *td); | |
817 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
818 }; | |
819 | |
820 struct DotVarExp : UnaExp | |
821 { | |
822 Declaration *var; | |
823 | |
824 DotVarExp(Loc loc, Expression *e, Declaration *var); | |
825 Expression *semantic(Scope *sc); | |
826 Expression *toLvalue(Scope *sc, Expression *e); | |
827 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
828 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
829 void dump(int indent); | |
830 elem *toElem(IRState *irs); | |
588
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
831 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
832 //LDC: since we don't convert abc.def -> *(&abc + ABC.def.offsetof) |
588
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
833 // these are needed |
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
834 Expression *optimize(int result); |
870652a9af23
Constant fold structliteral.member again.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
835 Expression *interpret(InterState *istate); |
159 | 836 }; |
837 | |
838 struct DotTemplateInstanceExp : UnaExp | |
839 { | |
840 TemplateInstance *ti; | |
841 | |
842 DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); | |
843 Expression *syntaxCopy(); | |
844 Expression *semantic(Scope *sc); | |
845 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
846 void dump(int indent); | |
847 }; | |
848 | |
849 struct DelegateExp : UnaExp | |
850 { | |
851 FuncDeclaration *func; | |
852 | |
853 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); | |
854 Expression *semantic(Scope *sc); | |
855 MATCH implicitConvTo(Type *t); | |
856 Expression *castTo(Scope *sc, Type *t); | |
857 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
858 void dump(int indent); | |
859 | |
860 int inlineCost(InlineCostState *ics); | |
861 elem *toElem(IRState *irs); | |
862 }; | |
863 | |
864 struct DotTypeExp : UnaExp | |
865 { | |
866 Dsymbol *sym; // symbol that represents a type | |
867 | |
868 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | |
869 Expression *semantic(Scope *sc); | |
870 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
871 elem *toElem(IRState *irs); | |
872 }; | |
873 | |
874 struct CallExp : UnaExp | |
875 { | |
876 Expressions *arguments; // function arguments | |
877 | |
878 CallExp(Loc loc, Expression *e, Expressions *exps); | |
879 CallExp(Loc loc, Expression *e); | |
880 CallExp(Loc loc, Expression *e, Expression *earg1); | |
881 CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); | |
882 | |
883 Expression *syntaxCopy(); | |
884 Expression *semantic(Scope *sc); | |
885 Expression *optimize(int result); | |
886 Expression *interpret(InterState *istate); | |
887 int checkSideEffect(int flag); | |
888 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
889 void dump(int indent); | |
890 elem *toElem(IRState *irs); | |
891 void scanForNestedRef(Scope *sc); | |
892 Expression *toLvalue(Scope *sc, Expression *e); | |
893 | |
894 int inlineCost(InlineCostState *ics); | |
895 Expression *doInline(InlineDoState *ids); | |
896 Expression *inlineScan(InlineScanState *iss); | |
897 }; | |
898 | |
899 struct AddrExp : UnaExp | |
900 { | |
901 AddrExp(Loc loc, Expression *e); | |
902 Expression *semantic(Scope *sc); | |
903 elem *toElem(IRState *irs); | |
904 MATCH implicitConvTo(Type *t); | |
905 Expression *castTo(Scope *sc, Type *t); | |
906 Expression *optimize(int result); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
907 // LDC |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
908 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 909 }; |
910 | |
911 struct PtrExp : UnaExp | |
912 { | |
913 PtrExp(Loc loc, Expression *e); | |
914 PtrExp(Loc loc, Expression *e, Type *t); | |
915 Expression *semantic(Scope *sc); | |
916 Expression *toLvalue(Scope *sc, Expression *e); | |
917 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
918 elem *toElem(IRState *irs); | |
919 Expression *optimize(int result); | |
920 Expression *interpret(InterState *istate); | |
921 }; | |
922 | |
923 struct NegExp : UnaExp | |
924 { | |
925 NegExp(Loc loc, Expression *e); | |
926 Expression *semantic(Scope *sc); | |
927 Expression *optimize(int result); | |
928 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
|
929 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
|
930 Expression *buildArrayLoop(Arguments *fparams); |
159 | 931 |
932 // For operator overloading | |
933 Identifier *opId(); | |
934 | |
935 elem *toElem(IRState *irs); | |
936 }; | |
937 | |
938 struct UAddExp : UnaExp | |
939 { | |
940 UAddExp(Loc loc, Expression *e); | |
941 Expression *semantic(Scope *sc); | |
942 | |
943 // For operator overloading | |
944 Identifier *opId(); | |
945 }; | |
946 | |
947 struct ComExp : UnaExp | |
948 { | |
949 ComExp(Loc loc, Expression *e); | |
950 Expression *semantic(Scope *sc); | |
951 Expression *optimize(int result); | |
952 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
|
953 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
|
954 Expression *buildArrayLoop(Arguments *fparams); |
159 | 955 |
956 // For operator overloading | |
957 Identifier *opId(); | |
958 | |
959 elem *toElem(IRState *irs); | |
960 }; | |
961 | |
962 struct NotExp : UnaExp | |
963 { | |
964 NotExp(Loc loc, Expression *e); | |
965 Expression *semantic(Scope *sc); | |
966 Expression *optimize(int result); | |
967 Expression *interpret(InterState *istate); | |
968 int isBit(); | |
969 elem *toElem(IRState *irs); | |
970 }; | |
971 | |
972 struct BoolExp : UnaExp | |
973 { | |
974 BoolExp(Loc loc, Expression *e, Type *type); | |
975 Expression *semantic(Scope *sc); | |
976 Expression *optimize(int result); | |
977 Expression *interpret(InterState *istate); | |
978 int isBit(); | |
979 elem *toElem(IRState *irs); | |
980 }; | |
981 | |
982 struct DeleteExp : UnaExp | |
983 { | |
984 DeleteExp(Loc loc, Expression *e); | |
985 Expression *semantic(Scope *sc); | |
986 Expression *checkToBoolean(); | |
987 int checkSideEffect(int flag); | |
988 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
989 elem *toElem(IRState *irs); | |
990 }; | |
991 | |
992 struct CastExp : UnaExp | |
993 { | |
994 // Possible to cast to one type while painting to another type | |
995 Type *to; // type to cast to | |
996 | |
997 CastExp(Loc loc, Expression *e, Type *t); | |
998 Expression *syntaxCopy(); | |
999 Expression *semantic(Scope *sc); | |
1000 Expression *optimize(int result); | |
1001 Expression *interpret(InterState *istate); | |
1002 int checkSideEffect(int flag); | |
1003 void checkEscape(); | |
1004 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1005 elem *toElem(IRState *irs); | |
1006 | |
1007 // For operator overloading | |
1008 Identifier *opId(); | |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1009 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1010 // LDC |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1011 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1012 }; |
1013 | |
1014 | |
1015 struct SliceExp : UnaExp | |
1016 { | |
1017 Expression *upr; // NULL if implicit 0 | |
1018 Expression *lwr; // NULL if implicit [length - 1] | |
1019 VarDeclaration *lengthVar; | |
1020 | |
1021 SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); | |
1022 Expression *syntaxCopy(); | |
1023 Expression *semantic(Scope *sc); | |
1024 void checkEscape(); | |
1025 Expression *toLvalue(Scope *sc, Expression *e); | |
1026 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1027 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1028 Expression *optimize(int result); | |
1029 Expression *interpret(InterState *istate); | |
1030 void dump(int indent); | |
1031 elem *toElem(IRState *irs); | |
1032 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
|
1033 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
|
1034 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1035 |
1036 int inlineCost(InlineCostState *ics); | |
1037 Expression *doInline(InlineDoState *ids); | |
1038 Expression *inlineScan(InlineScanState *iss); | |
1039 }; | |
1040 | |
1041 struct ArrayLengthExp : UnaExp | |
1042 { | |
1043 ArrayLengthExp(Loc loc, Expression *e1); | |
1044 Expression *semantic(Scope *sc); | |
1045 Expression *optimize(int result); | |
1046 Expression *interpret(InterState *istate); | |
1047 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1048 elem *toElem(IRState *irs); | |
1049 }; | |
1050 | |
1051 // e1[a0,a1,a2,a3,...] | |
1052 | |
1053 struct ArrayExp : UnaExp | |
1054 { | |
1055 Expressions *arguments; // Array of Expression's | |
1056 | |
1057 ArrayExp(Loc loc, Expression *e1, Expressions *arguments); | |
1058 Expression *syntaxCopy(); | |
1059 Expression *semantic(Scope *sc); | |
1060 Expression *toLvalue(Scope *sc, Expression *e); | |
1061 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1062 void scanForNestedRef(Scope *sc); | |
1063 | |
1064 // For operator overloading | |
1065 Identifier *opId(); | |
1066 | |
1067 int inlineCost(InlineCostState *ics); | |
1068 Expression *doInline(InlineDoState *ids); | |
1069 Expression *inlineScan(InlineScanState *iss); | |
1070 }; | |
1071 | |
1072 /****************************************************************/ | |
1073 | |
1074 struct DotExp : BinExp | |
1075 { | |
1076 DotExp(Loc loc, Expression *e1, Expression *e2); | |
1077 Expression *semantic(Scope *sc); | |
1078 }; | |
1079 | |
1080 struct CommaExp : BinExp | |
1081 { | |
1082 CommaExp(Loc loc, Expression *e1, Expression *e2); | |
1083 Expression *semantic(Scope *sc); | |
1084 void checkEscape(); | |
1085 Expression *toLvalue(Scope *sc, Expression *e); | |
1086 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1087 int isBool(int result); | |
1088 int checkSideEffect(int flag); | |
1089 Expression *optimize(int result); | |
1090 Expression *interpret(InterState *istate); | |
1091 elem *toElem(IRState *irs); | |
1092 }; | |
1093 | |
1094 struct IndexExp : BinExp | |
1095 { | |
1096 VarDeclaration *lengthVar; | |
1097 int modifiable; | |
1098 | |
1099 IndexExp(Loc loc, Expression *e1, Expression *e2); | |
1100 Expression *semantic(Scope *sc); | |
1101 Expression *toLvalue(Scope *sc, Expression *e); | |
1102 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1103 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1104 Expression *optimize(int result); | |
1105 Expression *interpret(InterState *istate); | |
1106 Expression *doInline(InlineDoState *ids); | |
1107 void scanForNestedRef(Scope *sc); | |
1108 | |
1109 elem *toElem(IRState *irs); | |
1110 }; | |
1111 | |
1112 /* For both i++ and i-- | |
1113 */ | |
1114 struct PostExp : BinExp | |
1115 { | |
1116 PostExp(enum TOK op, Loc loc, Expression *e); | |
1117 Expression *semantic(Scope *sc); | |
1118 Expression *interpret(InterState *istate); | |
1119 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1120 Identifier *opId(); // For operator overloading | |
1121 elem *toElem(IRState *irs); | |
1122 }; | |
1123 | |
1124 struct AssignExp : BinExp | |
1125 { int ismemset; // !=0 if setting the contents of an array | |
1126 | |
1127 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1128 Expression *semantic(Scope *sc); | |
1129 Expression *checkToBoolean(); | |
1130 Expression *interpret(InterState *istate); | |
1131 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
|
1132 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 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1134 elem *toElem(IRState *irs); |
1135 }; | |
1136 | |
1137 #define ASSIGNEXP(op) \ | |
1138 struct op##AssignExp : BinExp \ | |
1139 { \ | |
1140 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1141 Expression *semantic(Scope *sc); \ | |
1142 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
|
1143 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
|
1144 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
159 | 1145 \ |
1146 Identifier *opId(); /* For operator overloading */ \ | |
1147 \ | |
1148 elem *toElem(IRState *irs); \ | |
1149 }; | |
1150 | |
510
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) a |
159 | 1152 ASSIGNEXP(Add) |
1153 ASSIGNEXP(Min) | |
1154 ASSIGNEXP(Mul) | |
1155 ASSIGNEXP(Div) | |
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 #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
|
1161 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1162 #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
|
1163 |
159 | 1164 ASSIGNEXP(Shl) |
1165 ASSIGNEXP(Shr) | |
1166 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
|
1167 ASSIGNEXP(Cat) |
159 | 1168 |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1169 #undef X |
159 | 1170 #undef ASSIGNEXP |
1171 | |
1172 struct AddExp : BinExp | |
1173 { | |
1174 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1175 Expression *semantic(Scope *sc); | |
1176 Expression *optimize(int result); | |
1177 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
|
1178 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
|
1179 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1180 |
1181 // For operator overloading | |
1182 int isCommutative(); | |
1183 Identifier *opId(); | |
1184 Identifier *opId_r(); | |
1185 | |
1186 elem *toElem(IRState *irs); | |
1187 }; | |
1188 | |
1189 struct MinExp : BinExp | |
1190 { | |
1191 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1192 Expression *semantic(Scope *sc); | |
1193 Expression *optimize(int result); | |
1194 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
|
1195 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
|
1196 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1197 |
1198 // For operator overloading | |
1199 Identifier *opId(); | |
1200 Identifier *opId_r(); | |
1201 | |
1202 elem *toElem(IRState *irs); | |
1203 }; | |
1204 | |
1205 struct CatExp : BinExp | |
1206 { | |
1207 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1208 Expression *semantic(Scope *sc); | |
1209 Expression *optimize(int result); | |
1210 Expression *interpret(InterState *istate); | |
1211 | |
1212 // For operator overloading | |
1213 Identifier *opId(); | |
1214 Identifier *opId_r(); | |
1215 | |
1216 elem *toElem(IRState *irs); | |
1217 }; | |
1218 | |
1219 struct MulExp : BinExp | |
1220 { | |
1221 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1222 Expression *semantic(Scope *sc); | |
1223 Expression *optimize(int result); | |
1224 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
|
1225 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
|
1226 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1227 |
1228 // For operator overloading | |
1229 int isCommutative(); | |
1230 Identifier *opId(); | |
1231 Identifier *opId_r(); | |
1232 | |
1233 elem *toElem(IRState *irs); | |
1234 }; | |
1235 | |
1236 struct DivExp : BinExp | |
1237 { | |
1238 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1239 Expression *semantic(Scope *sc); | |
1240 Expression *optimize(int result); | |
1241 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
|
1242 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
|
1243 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1244 |
1245 // For operator overloading | |
1246 Identifier *opId(); | |
1247 Identifier *opId_r(); | |
1248 | |
1249 elem *toElem(IRState *irs); | |
1250 }; | |
1251 | |
1252 struct ModExp : BinExp | |
1253 { | |
1254 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1255 Expression *semantic(Scope *sc); | |
1256 Expression *optimize(int result); | |
1257 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
|
1258 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
|
1259 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1260 |
1261 // For operator overloading | |
1262 Identifier *opId(); | |
1263 Identifier *opId_r(); | |
1264 | |
1265 elem *toElem(IRState *irs); | |
1266 }; | |
1267 | |
1268 struct ShlExp : BinExp | |
1269 { | |
1270 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1271 Expression *semantic(Scope *sc); | |
1272 Expression *optimize(int result); | |
1273 Expression *interpret(InterState *istate); | |
1274 | |
1275 // For operator overloading | |
1276 Identifier *opId(); | |
1277 Identifier *opId_r(); | |
1278 | |
1279 elem *toElem(IRState *irs); | |
1280 }; | |
1281 | |
1282 struct ShrExp : BinExp | |
1283 { | |
1284 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1285 Expression *semantic(Scope *sc); | |
1286 Expression *optimize(int result); | |
1287 Expression *interpret(InterState *istate); | |
1288 | |
1289 // For operator overloading | |
1290 Identifier *opId(); | |
1291 Identifier *opId_r(); | |
1292 | |
1293 elem *toElem(IRState *irs); | |
1294 }; | |
1295 | |
1296 struct UshrExp : BinExp | |
1297 { | |
1298 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1299 Expression *semantic(Scope *sc); | |
1300 Expression *optimize(int result); | |
1301 Expression *interpret(InterState *istate); | |
1302 | |
1303 // For operator overloading | |
1304 Identifier *opId(); | |
1305 Identifier *opId_r(); | |
1306 | |
1307 elem *toElem(IRState *irs); | |
1308 }; | |
1309 | |
1310 struct AndExp : BinExp | |
1311 { | |
1312 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1313 Expression *semantic(Scope *sc); | |
1314 Expression *optimize(int result); | |
1315 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
|
1316 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
|
1317 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1318 |
1319 // For operator overloading | |
1320 int isCommutative(); | |
1321 Identifier *opId(); | |
1322 Identifier *opId_r(); | |
1323 | |
1324 elem *toElem(IRState *irs); | |
1325 }; | |
1326 | |
1327 struct OrExp : BinExp | |
1328 { | |
1329 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1330 Expression *semantic(Scope *sc); | |
1331 Expression *optimize(int result); | |
1332 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
|
1333 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
|
1334 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1335 |
1336 // For operator overloading | |
1337 int isCommutative(); | |
1338 Identifier *opId(); | |
1339 Identifier *opId_r(); | |
1340 | |
1341 elem *toElem(IRState *irs); | |
1342 }; | |
1343 | |
1344 struct XorExp : BinExp | |
1345 { | |
1346 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1347 Expression *semantic(Scope *sc); | |
1348 Expression *optimize(int result); | |
1349 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
|
1350 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
|
1351 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1352 |
1353 // For operator overloading | |
1354 int isCommutative(); | |
1355 Identifier *opId(); | |
1356 Identifier *opId_r(); | |
1357 | |
1358 elem *toElem(IRState *irs); | |
1359 }; | |
1360 | |
1361 struct OrOrExp : BinExp | |
1362 { | |
1363 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1364 Expression *semantic(Scope *sc); | |
1365 Expression *checkToBoolean(); | |
1366 int isBit(); | |
1367 Expression *optimize(int result); | |
1368 Expression *interpret(InterState *istate); | |
1369 int checkSideEffect(int flag); | |
1370 elem *toElem(IRState *irs); | |
1371 }; | |
1372 | |
1373 struct AndAndExp : BinExp | |
1374 { | |
1375 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1376 Expression *semantic(Scope *sc); | |
1377 Expression *checkToBoolean(); | |
1378 int isBit(); | |
1379 Expression *optimize(int result); | |
1380 Expression *interpret(InterState *istate); | |
1381 int checkSideEffect(int flag); | |
1382 elem *toElem(IRState *irs); | |
1383 }; | |
1384 | |
1385 struct CmpExp : BinExp | |
1386 { | |
1387 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1388 Expression *semantic(Scope *sc); | |
1389 Expression *optimize(int result); | |
1390 Expression *interpret(InterState *istate); | |
1391 int isBit(); | |
1392 | |
1393 // For operator overloading | |
1394 int isCommutative(); | |
1395 Identifier *opId(); | |
1396 | |
1397 elem *toElem(IRState *irs); | |
1398 }; | |
1399 | |
1400 struct InExp : BinExp | |
1401 { | |
1402 InExp(Loc loc, Expression *e1, Expression *e2); | |
1403 Expression *semantic(Scope *sc); | |
1404 int isBit(); | |
1405 | |
1406 // For operator overloading | |
1407 Identifier *opId(); | |
1408 Identifier *opId_r(); | |
1409 | |
1410 elem *toElem(IRState *irs); | |
1411 }; | |
1412 | |
1413 struct RemoveExp : BinExp | |
1414 { | |
1415 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1416 elem *toElem(IRState *irs); | |
1417 }; | |
1418 | |
1419 // == and != | |
1420 | |
1421 struct EqualExp : BinExp | |
1422 { | |
1423 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1424 Expression *semantic(Scope *sc); | |
1425 Expression *optimize(int result); | |
1426 Expression *interpret(InterState *istate); | |
1427 int isBit(); | |
1428 | |
1429 // For operator overloading | |
1430 int isCommutative(); | |
1431 Identifier *opId(); | |
1432 | |
1433 elem *toElem(IRState *irs); | |
1434 }; | |
1435 | |
1436 // === and !=== | |
1437 | |
1438 struct IdentityExp : BinExp | |
1439 { | |
1440 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1441 Expression *semantic(Scope *sc); | |
1442 int isBit(); | |
1443 Expression *optimize(int result); | |
1444 Expression *interpret(InterState *istate); | |
1445 elem *toElem(IRState *irs); | |
1446 }; | |
1447 | |
1448 /****************************************************************/ | |
1449 | |
1450 struct CondExp : BinExp | |
1451 { | |
1452 Expression *econd; | |
1453 | |
1454 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1455 Expression *syntaxCopy(); | |
1456 Expression *semantic(Scope *sc); | |
1457 Expression *optimize(int result); | |
1458 Expression *interpret(InterState *istate); | |
1459 void checkEscape(); | |
1460 Expression *toLvalue(Scope *sc, Expression *e); | |
1461 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1462 Expression *checkToBoolean(); | |
1463 int checkSideEffect(int flag); | |
1464 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1465 MATCH implicitConvTo(Type *t); | |
1466 Expression *castTo(Scope *sc, Type *t); | |
1467 void scanForNestedRef(Scope *sc); | |
1468 | |
1469 int inlineCost(InlineCostState *ics); | |
1470 Expression *doInline(InlineDoState *ids); | |
1471 Expression *inlineScan(InlineScanState *iss); | |
1472 | |
1473 elem *toElem(IRState *irs); | |
1474 }; | |
1475 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1476 #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
|
1477 /****************************************************************/ |
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 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
|
1480 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1481 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
|
1482 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1483 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
|
1484 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
|
1485 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1488 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
|
1489 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1490 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
|
1491 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
|
1492 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
|
1493 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1494 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1495 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
|
1496 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1497 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
|
1498 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
|
1499 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
|
1500 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1501 #endif |
159 | 1502 |
1503 /****************************************************************/ | |
1504 | |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1505 #if IN_LLVM |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1506 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1507 // this stuff is strictly LDC |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1508 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1509 struct GEPExp : UnaExp |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1510 { |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1511 unsigned index; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1512 Identifier* ident; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1513 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1514 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1515 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1516 Expression *toLvalue(Scope *sc, Expression *e); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1517 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1518 elem *toElem(IRState *irs); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1519 }; |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1520 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1521 #endif |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1522 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1523 /****************************************************************/ |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
588
diff
changeset
|
1524 |
159 | 1525 /* Special values used by the interpreter |
1526 */ | |
1527 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1528 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1529 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1530 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1531 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1532 | |
1533 Expression *expType(Type *type, Expression *e); | |
1534 | |
1535 Expression *Neg(Type *type, Expression *e1); | |
1536 Expression *Com(Type *type, Expression *e1); | |
1537 Expression *Not(Type *type, Expression *e1); | |
1538 Expression *Bool(Type *type, Expression *e1); | |
1539 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1540 Expression *ArrayLength(Type *type, Expression *e1); | |
1541 Expression *Ptr(Type *type, Expression *e1); | |
1542 | |
1543 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1544 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1545 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1546 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1547 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1548 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1549 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1550 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1551 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1552 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1553 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1554 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1555 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1556 | |
1557 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1558 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1559 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1560 | |
1561 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1562 | |
1563 #endif /* DMD_EXPRESSION_H */ |