Mercurial > projects > ldc
annotate dmd/expression.h @ 875:330f999ade44
Merged DMD 1.038
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 06 Jan 2009 16:33:51 +0100 |
parents | 7edce7e58ab1 |
children | 27a379f288bf |
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); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
828 Expression *optimize(int result); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
829 Expression *interpret(InterState *istate); |
159 | 830 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
831 void dump(int indent); | |
832 elem *toElem(IRState *irs); | |
833 }; | |
834 | |
835 struct DotTemplateInstanceExp : UnaExp | |
836 { | |
837 TemplateInstance *ti; | |
838 | |
839 DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); | |
840 Expression *syntaxCopy(); | |
841 Expression *semantic(Scope *sc); | |
842 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
843 void dump(int indent); | |
844 }; | |
845 | |
846 struct DelegateExp : UnaExp | |
847 { | |
848 FuncDeclaration *func; | |
849 | |
850 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); | |
851 Expression *semantic(Scope *sc); | |
852 MATCH implicitConvTo(Type *t); | |
853 Expression *castTo(Scope *sc, Type *t); | |
854 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
855 void dump(int indent); | |
856 | |
857 int inlineCost(InlineCostState *ics); | |
858 elem *toElem(IRState *irs); | |
859 }; | |
860 | |
861 struct DotTypeExp : UnaExp | |
862 { | |
863 Dsymbol *sym; // symbol that represents a type | |
864 | |
865 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | |
866 Expression *semantic(Scope *sc); | |
867 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
868 elem *toElem(IRState *irs); | |
869 }; | |
870 | |
871 struct CallExp : UnaExp | |
872 { | |
873 Expressions *arguments; // function arguments | |
874 | |
875 CallExp(Loc loc, Expression *e, Expressions *exps); | |
876 CallExp(Loc loc, Expression *e); | |
877 CallExp(Loc loc, Expression *e, Expression *earg1); | |
878 CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); | |
879 | |
880 Expression *syntaxCopy(); | |
881 Expression *semantic(Scope *sc); | |
882 Expression *optimize(int result); | |
883 Expression *interpret(InterState *istate); | |
884 int checkSideEffect(int flag); | |
885 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
886 void dump(int indent); | |
887 elem *toElem(IRState *irs); | |
888 void scanForNestedRef(Scope *sc); | |
889 Expression *toLvalue(Scope *sc, Expression *e); | |
890 | |
891 int inlineCost(InlineCostState *ics); | |
892 Expression *doInline(InlineDoState *ids); | |
893 Expression *inlineScan(InlineScanState *iss); | |
894 }; | |
895 | |
896 struct AddrExp : UnaExp | |
897 { | |
898 AddrExp(Loc loc, Expression *e); | |
899 Expression *semantic(Scope *sc); | |
900 elem *toElem(IRState *irs); | |
901 MATCH implicitConvTo(Type *t); | |
902 Expression *castTo(Scope *sc, Type *t); | |
903 Expression *optimize(int result); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
904 // LDC |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
905 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 906 }; |
907 | |
908 struct PtrExp : UnaExp | |
909 { | |
910 PtrExp(Loc loc, Expression *e); | |
911 PtrExp(Loc loc, Expression *e, Type *t); | |
912 Expression *semantic(Scope *sc); | |
913 Expression *toLvalue(Scope *sc, Expression *e); | |
914 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
915 elem *toElem(IRState *irs); | |
916 Expression *optimize(int result); | |
917 Expression *interpret(InterState *istate); | |
918 }; | |
919 | |
920 struct NegExp : UnaExp | |
921 { | |
922 NegExp(Loc loc, Expression *e); | |
923 Expression *semantic(Scope *sc); | |
924 Expression *optimize(int result); | |
925 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
|
926 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
|
927 Expression *buildArrayLoop(Arguments *fparams); |
159 | 928 |
929 // For operator overloading | |
930 Identifier *opId(); | |
931 | |
932 elem *toElem(IRState *irs); | |
933 }; | |
934 | |
935 struct UAddExp : UnaExp | |
936 { | |
937 UAddExp(Loc loc, Expression *e); | |
938 Expression *semantic(Scope *sc); | |
939 | |
940 // For operator overloading | |
941 Identifier *opId(); | |
942 }; | |
943 | |
944 struct ComExp : UnaExp | |
945 { | |
946 ComExp(Loc loc, Expression *e); | |
947 Expression *semantic(Scope *sc); | |
948 Expression *optimize(int result); | |
949 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
|
950 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
|
951 Expression *buildArrayLoop(Arguments *fparams); |
159 | 952 |
953 // For operator overloading | |
954 Identifier *opId(); | |
955 | |
956 elem *toElem(IRState *irs); | |
957 }; | |
958 | |
959 struct NotExp : UnaExp | |
960 { | |
961 NotExp(Loc loc, Expression *e); | |
962 Expression *semantic(Scope *sc); | |
963 Expression *optimize(int result); | |
964 Expression *interpret(InterState *istate); | |
965 int isBit(); | |
966 elem *toElem(IRState *irs); | |
967 }; | |
968 | |
969 struct BoolExp : UnaExp | |
970 { | |
971 BoolExp(Loc loc, Expression *e, Type *type); | |
972 Expression *semantic(Scope *sc); | |
973 Expression *optimize(int result); | |
974 Expression *interpret(InterState *istate); | |
975 int isBit(); | |
976 elem *toElem(IRState *irs); | |
977 }; | |
978 | |
979 struct DeleteExp : UnaExp | |
980 { | |
981 DeleteExp(Loc loc, Expression *e); | |
982 Expression *semantic(Scope *sc); | |
983 Expression *checkToBoolean(); | |
984 int checkSideEffect(int flag); | |
985 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
986 elem *toElem(IRState *irs); | |
987 }; | |
988 | |
989 struct CastExp : UnaExp | |
990 { | |
991 // Possible to cast to one type while painting to another type | |
992 Type *to; // type to cast to | |
993 | |
994 CastExp(Loc loc, Expression *e, Type *t); | |
995 Expression *syntaxCopy(); | |
996 Expression *semantic(Scope *sc); | |
997 Expression *optimize(int result); | |
998 Expression *interpret(InterState *istate); | |
999 int checkSideEffect(int flag); | |
1000 void checkEscape(); | |
1001 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1002 elem *toElem(IRState *irs); | |
1003 | |
1004 // For operator overloading | |
1005 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
|
1006 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1007 // LDC |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
599
diff
changeset
|
1008 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1009 }; |
1010 | |
1011 | |
1012 struct SliceExp : UnaExp | |
1013 { | |
1014 Expression *upr; // NULL if implicit 0 | |
1015 Expression *lwr; // NULL if implicit [length - 1] | |
1016 VarDeclaration *lengthVar; | |
1017 | |
1018 SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); | |
1019 Expression *syntaxCopy(); | |
1020 Expression *semantic(Scope *sc); | |
1021 void checkEscape(); | |
1022 Expression *toLvalue(Scope *sc, Expression *e); | |
1023 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1024 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1025 Expression *optimize(int result); | |
1026 Expression *interpret(InterState *istate); | |
1027 void dump(int indent); | |
1028 elem *toElem(IRState *irs); | |
1029 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
|
1030 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
|
1031 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1032 |
1033 int inlineCost(InlineCostState *ics); | |
1034 Expression *doInline(InlineDoState *ids); | |
1035 Expression *inlineScan(InlineScanState *iss); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1036 |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1037 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1038 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 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); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1110 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1111 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1112 }; |
1113 | |
1114 /* For both i++ and i-- | |
1115 */ | |
1116 struct PostExp : BinExp | |
1117 { | |
1118 PostExp(enum TOK op, Loc loc, Expression *e); | |
1119 Expression *semantic(Scope *sc); | |
1120 Expression *interpret(InterState *istate); | |
1121 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1122 Identifier *opId(); // For operator overloading | |
1123 elem *toElem(IRState *irs); | |
1124 }; | |
1125 | |
1126 struct AssignExp : BinExp | |
1127 { int ismemset; // !=0 if setting the contents of an array | |
1128 | |
1129 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1130 Expression *semantic(Scope *sc); | |
1131 Expression *checkToBoolean(); | |
1132 Expression *interpret(InterState *istate); | |
1133 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
|
1134 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
|
1135 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1136 elem *toElem(IRState *irs); |
1137 }; | |
1138 | |
1139 #define ASSIGNEXP(op) \ | |
1140 struct op##AssignExp : BinExp \ | |
1141 { \ | |
1142 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1143 Expression *semantic(Scope *sc); \ | |
1144 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
|
1145 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
|
1146 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
159 | 1147 \ |
1148 Identifier *opId(); /* For operator overloading */ \ | |
1149 \ | |
1150 elem *toElem(IRState *irs); \ | |
1151 }; | |
1152 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1153 #define X(a) a |
159 | 1154 ASSIGNEXP(Add) |
1155 ASSIGNEXP(Min) | |
1156 ASSIGNEXP(Mul) | |
1157 ASSIGNEXP(Div) | |
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 #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
|
1163 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1164 #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
|
1165 |
159 | 1166 ASSIGNEXP(Shl) |
1167 ASSIGNEXP(Shr) | |
1168 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
|
1169 ASSIGNEXP(Cat) |
159 | 1170 |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1171 #undef X |
159 | 1172 #undef ASSIGNEXP |
1173 | |
1174 struct AddExp : BinExp | |
1175 { | |
1176 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1177 Expression *semantic(Scope *sc); | |
1178 Expression *optimize(int result); | |
1179 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
|
1180 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
|
1181 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1182 |
1183 // For operator overloading | |
1184 int isCommutative(); | |
1185 Identifier *opId(); | |
1186 Identifier *opId_r(); | |
1187 | |
1188 elem *toElem(IRState *irs); | |
1189 }; | |
1190 | |
1191 struct MinExp : BinExp | |
1192 { | |
1193 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1194 Expression *semantic(Scope *sc); | |
1195 Expression *optimize(int result); | |
1196 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
|
1197 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
|
1198 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1199 |
1200 // For operator overloading | |
1201 Identifier *opId(); | |
1202 Identifier *opId_r(); | |
1203 | |
1204 elem *toElem(IRState *irs); | |
1205 }; | |
1206 | |
1207 struct CatExp : BinExp | |
1208 { | |
1209 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1210 Expression *semantic(Scope *sc); | |
1211 Expression *optimize(int result); | |
1212 Expression *interpret(InterState *istate); | |
1213 | |
1214 // For operator overloading | |
1215 Identifier *opId(); | |
1216 Identifier *opId_r(); | |
1217 | |
1218 elem *toElem(IRState *irs); | |
1219 }; | |
1220 | |
1221 struct MulExp : BinExp | |
1222 { | |
1223 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1224 Expression *semantic(Scope *sc); | |
1225 Expression *optimize(int result); | |
1226 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
|
1227 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
|
1228 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1229 |
1230 // For operator overloading | |
1231 int isCommutative(); | |
1232 Identifier *opId(); | |
1233 Identifier *opId_r(); | |
1234 | |
1235 elem *toElem(IRState *irs); | |
1236 }; | |
1237 | |
1238 struct DivExp : BinExp | |
1239 { | |
1240 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1241 Expression *semantic(Scope *sc); | |
1242 Expression *optimize(int result); | |
1243 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
|
1244 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
|
1245 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1246 |
1247 // For operator overloading | |
1248 Identifier *opId(); | |
1249 Identifier *opId_r(); | |
1250 | |
1251 elem *toElem(IRState *irs); | |
1252 }; | |
1253 | |
1254 struct ModExp : BinExp | |
1255 { | |
1256 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1257 Expression *semantic(Scope *sc); | |
1258 Expression *optimize(int result); | |
1259 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
|
1260 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
|
1261 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1262 |
1263 // For operator overloading | |
1264 Identifier *opId(); | |
1265 Identifier *opId_r(); | |
1266 | |
1267 elem *toElem(IRState *irs); | |
1268 }; | |
1269 | |
1270 struct ShlExp : BinExp | |
1271 { | |
1272 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1273 Expression *semantic(Scope *sc); | |
1274 Expression *optimize(int result); | |
1275 Expression *interpret(InterState *istate); | |
1276 | |
1277 // For operator overloading | |
1278 Identifier *opId(); | |
1279 Identifier *opId_r(); | |
1280 | |
1281 elem *toElem(IRState *irs); | |
1282 }; | |
1283 | |
1284 struct ShrExp : BinExp | |
1285 { | |
1286 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1287 Expression *semantic(Scope *sc); | |
1288 Expression *optimize(int result); | |
1289 Expression *interpret(InterState *istate); | |
1290 | |
1291 // For operator overloading | |
1292 Identifier *opId(); | |
1293 Identifier *opId_r(); | |
1294 | |
1295 elem *toElem(IRState *irs); | |
1296 }; | |
1297 | |
1298 struct UshrExp : BinExp | |
1299 { | |
1300 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1301 Expression *semantic(Scope *sc); | |
1302 Expression *optimize(int result); | |
1303 Expression *interpret(InterState *istate); | |
1304 | |
1305 // For operator overloading | |
1306 Identifier *opId(); | |
1307 Identifier *opId_r(); | |
1308 | |
1309 elem *toElem(IRState *irs); | |
1310 }; | |
1311 | |
1312 struct AndExp : BinExp | |
1313 { | |
1314 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1315 Expression *semantic(Scope *sc); | |
1316 Expression *optimize(int result); | |
1317 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
|
1318 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
|
1319 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1320 |
1321 // For operator overloading | |
1322 int isCommutative(); | |
1323 Identifier *opId(); | |
1324 Identifier *opId_r(); | |
1325 | |
1326 elem *toElem(IRState *irs); | |
1327 }; | |
1328 | |
1329 struct OrExp : BinExp | |
1330 { | |
1331 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1332 Expression *semantic(Scope *sc); | |
1333 Expression *optimize(int result); | |
1334 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
|
1335 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
|
1336 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1337 |
1338 // For operator overloading | |
1339 int isCommutative(); | |
1340 Identifier *opId(); | |
1341 Identifier *opId_r(); | |
1342 | |
1343 elem *toElem(IRState *irs); | |
1344 }; | |
1345 | |
1346 struct XorExp : BinExp | |
1347 { | |
1348 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1349 Expression *semantic(Scope *sc); | |
1350 Expression *optimize(int result); | |
1351 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
|
1352 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
|
1353 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1354 |
1355 // For operator overloading | |
1356 int isCommutative(); | |
1357 Identifier *opId(); | |
1358 Identifier *opId_r(); | |
1359 | |
1360 elem *toElem(IRState *irs); | |
1361 }; | |
1362 | |
1363 struct OrOrExp : BinExp | |
1364 { | |
1365 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1366 Expression *semantic(Scope *sc); | |
1367 Expression *checkToBoolean(); | |
1368 int isBit(); | |
1369 Expression *optimize(int result); | |
1370 Expression *interpret(InterState *istate); | |
1371 int checkSideEffect(int flag); | |
1372 elem *toElem(IRState *irs); | |
1373 }; | |
1374 | |
1375 struct AndAndExp : BinExp | |
1376 { | |
1377 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1378 Expression *semantic(Scope *sc); | |
1379 Expression *checkToBoolean(); | |
1380 int isBit(); | |
1381 Expression *optimize(int result); | |
1382 Expression *interpret(InterState *istate); | |
1383 int checkSideEffect(int flag); | |
1384 elem *toElem(IRState *irs); | |
1385 }; | |
1386 | |
1387 struct CmpExp : BinExp | |
1388 { | |
1389 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1390 Expression *semantic(Scope *sc); | |
1391 Expression *optimize(int result); | |
1392 Expression *interpret(InterState *istate); | |
1393 int isBit(); | |
1394 | |
1395 // For operator overloading | |
1396 int isCommutative(); | |
1397 Identifier *opId(); | |
1398 | |
1399 elem *toElem(IRState *irs); | |
1400 }; | |
1401 | |
1402 struct InExp : BinExp | |
1403 { | |
1404 InExp(Loc loc, Expression *e1, Expression *e2); | |
1405 Expression *semantic(Scope *sc); | |
1406 int isBit(); | |
1407 | |
1408 // For operator overloading | |
1409 Identifier *opId(); | |
1410 Identifier *opId_r(); | |
1411 | |
1412 elem *toElem(IRState *irs); | |
1413 }; | |
1414 | |
1415 struct RemoveExp : BinExp | |
1416 { | |
1417 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1418 elem *toElem(IRState *irs); | |
1419 }; | |
1420 | |
1421 // == and != | |
1422 | |
1423 struct EqualExp : BinExp | |
1424 { | |
1425 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1426 Expression *semantic(Scope *sc); | |
1427 Expression *optimize(int result); | |
1428 Expression *interpret(InterState *istate); | |
1429 int isBit(); | |
1430 | |
1431 // For operator overloading | |
1432 int isCommutative(); | |
1433 Identifier *opId(); | |
1434 | |
1435 elem *toElem(IRState *irs); | |
1436 }; | |
1437 | |
1438 // === and !=== | |
1439 | |
1440 struct IdentityExp : BinExp | |
1441 { | |
1442 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1443 Expression *semantic(Scope *sc); | |
1444 int isBit(); | |
1445 Expression *optimize(int result); | |
1446 Expression *interpret(InterState *istate); | |
1447 elem *toElem(IRState *irs); | |
1448 }; | |
1449 | |
1450 /****************************************************************/ | |
1451 | |
1452 struct CondExp : BinExp | |
1453 { | |
1454 Expression *econd; | |
1455 | |
1456 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1457 Expression *syntaxCopy(); | |
1458 Expression *semantic(Scope *sc); | |
1459 Expression *optimize(int result); | |
1460 Expression *interpret(InterState *istate); | |
1461 void checkEscape(); | |
1462 Expression *toLvalue(Scope *sc, Expression *e); | |
1463 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1464 Expression *checkToBoolean(); | |
1465 int checkSideEffect(int flag); | |
1466 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1467 MATCH implicitConvTo(Type *t); | |
1468 Expression *castTo(Scope *sc, Type *t); | |
1469 void scanForNestedRef(Scope *sc); | |
1470 | |
1471 int inlineCost(InlineCostState *ics); | |
1472 Expression *doInline(InlineDoState *ids); | |
1473 Expression *inlineScan(InlineScanState *iss); | |
1474 | |
1475 elem *toElem(IRState *irs); | |
1476 }; | |
1477 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1478 #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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1481 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
|
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 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
|
1484 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1485 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
|
1486 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
|
1487 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1490 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
|
1491 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1492 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
|
1493 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
|
1494 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
|
1495 }; |
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 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
|
1498 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1499 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
|
1500 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
|
1501 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
|
1502 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1503 #endif |
159 | 1504 |
1505 /****************************************************************/ | |
1506 | |
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
|
1507 #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
|
1508 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1509 // 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
|
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 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
|
1512 { |
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 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
|
1514 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
|
1515 |
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 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
|
1517 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
|
1518 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
|
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 elem *toElem(IRState *irs); |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1521 llvm::Constant *toConstElem(IRState *irs); |
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
|
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 #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
|
1525 |
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
|
1526 /****************************************************************/ |
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
|
1527 |
159 | 1528 /* Special values used by the interpreter |
1529 */ | |
1530 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1531 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1532 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1533 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1534 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1535 | |
1536 Expression *expType(Type *type, Expression *e); | |
1537 | |
1538 Expression *Neg(Type *type, Expression *e1); | |
1539 Expression *Com(Type *type, Expression *e1); | |
1540 Expression *Not(Type *type, Expression *e1); | |
1541 Expression *Bool(Type *type, Expression *e1); | |
1542 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1543 Expression *ArrayLength(Type *type, Expression *e1); | |
1544 Expression *Ptr(Type *type, Expression *e1); | |
1545 | |
1546 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1547 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1548 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1549 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1550 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1551 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1552 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1553 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1554 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1555 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1556 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1557 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1558 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1559 | |
1560 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1561 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1562 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1563 | |
1564 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1565 | |
1566 #endif /* DMD_EXPRESSION_H */ |