Mercurial > projects > ldc
annotate dmd/expression.h @ 1137:45d73f0a9b43
Automated merge with http://hg.dsource.org/projects/ldc
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 24 Mar 2009 14:34:16 +0100 |
parents | b30fe7e1dbb9 |
children | 1860414bf3b7 |
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); | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
876
diff
changeset
|
81 int arrayExpressionCanThrow(Expressions *exps); |
159 | 82 |
83 struct Expression : Object | |
84 { | |
85 Loc loc; // file location | |
86 enum TOK op; // handy to minimize use of dynamic_cast | |
87 Type *type; // !=NULL means that semantic() has been run | |
88 int size; // # of bytes in Expression so we can copy() it | |
89 | |
90 Expression(Loc loc, enum TOK op, int size); | |
91 Expression *copy(); | |
92 virtual Expression *syntaxCopy(); | |
93 virtual Expression *semantic(Scope *sc); | |
94 | |
95 int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression() | |
96 | |
97 void print(); | |
98 char *toChars(); | |
99 virtual void dump(int indent); | |
100 void error(const char *format, ...); | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
876
diff
changeset
|
101 void warning(const char *format, ...); |
159 | 102 virtual void rvalue(); |
103 | |
104 static Expression *combine(Expression *e1, Expression *e2); | |
105 static Expressions *arraySyntaxCopy(Expressions *exps); | |
106 | |
107 virtual integer_t toInteger(); | |
108 virtual uinteger_t toUInteger(); | |
109 virtual real_t toReal(); | |
110 virtual real_t toImaginary(); | |
111 virtual complex_t toComplex(); | |
112 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
113 virtual void toMangleBuffer(OutBuffer *buf); | |
114 virtual Expression *toLvalue(Scope *sc, Expression *e); | |
115 virtual Expression *modifiableLvalue(Scope *sc, Expression *e); | |
116 Expression *implicitCastTo(Scope *sc, Type *t); | |
117 virtual MATCH implicitConvTo(Type *t); | |
118 virtual Expression *castTo(Scope *sc, Type *t); | |
119 virtual void checkEscape(); | |
120 void checkScalar(); | |
121 void checkNoBool(); | |
122 Expression *checkIntegral(); | |
123 Expression *checkArithmetic(); | |
124 void checkDeprecated(Scope *sc, Dsymbol *s); | |
125 virtual Expression *checkToBoolean(); | |
126 Expression *checkToPointer(); | |
127 Expression *addressOf(Scope *sc); | |
128 Expression *deref(); | |
129 Expression *integralPromotions(Scope *sc); | |
130 | |
131 Expression *toDelegate(Scope *sc, Type *t); | |
132 virtual void scanForNestedRef(Scope *sc); | |
133 | |
134 virtual Expression *optimize(int result); | |
135 #define WANTflags 1 | |
136 #define WANTvalue 2 | |
137 #define WANTinterpret 4 | |
138 | |
139 virtual Expression *interpret(InterState *istate); | |
140 | |
141 virtual int isConst(); | |
142 virtual int isBool(int result); | |
143 virtual int isBit(); | |
144 virtual int checkSideEffect(int flag); | |
336 | 145 virtual int canThrow(); |
159 | 146 |
147 virtual int inlineCost(InlineCostState *ics); | |
148 virtual Expression *doInline(InlineDoState *ids); | |
149 virtual Expression *inlineScan(InlineScanState *iss); | |
150 | |
151 // For operator overloading | |
152 virtual int isCommutative(); | |
153 virtual Identifier *opId(); | |
154 virtual Identifier *opId_r(); | |
155 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
156 // 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
|
157 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
|
158 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
|
159 |
159 | 160 // Back end |
161 virtual elem *toElem(IRState *irs); | |
162 virtual dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
163 // LDC |
159 | 164 virtual llvm::Constant *toConstElem(IRState *irs); |
165 }; | |
166 | |
167 struct IntegerExp : Expression | |
168 { | |
169 integer_t value; | |
170 | |
171 IntegerExp(Loc loc, integer_t value, Type *type); | |
172 IntegerExp(integer_t value); | |
173 int equals(Object *o); | |
174 Expression *semantic(Scope *sc); | |
175 Expression *interpret(InterState *istate); | |
176 char *toChars(); | |
177 void dump(int indent); | |
178 integer_t toInteger(); | |
179 real_t toReal(); | |
180 real_t toImaginary(); | |
181 complex_t toComplex(); | |
182 int isConst(); | |
183 int isBool(int result); | |
184 MATCH implicitConvTo(Type *t); | |
185 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
186 void toMangleBuffer(OutBuffer *buf); | |
187 Expression *toLvalue(Scope *sc, Expression *e); | |
188 elem *toElem(IRState *irs); | |
189 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
190 // LDC |
159 | 191 virtual llvm::Constant *toConstElem(IRState *irs); |
192 }; | |
193 | |
194 struct RealExp : Expression | |
195 { | |
196 real_t value; | |
197 | |
198 RealExp(Loc loc, real_t value, Type *type); | |
199 int equals(Object *o); | |
200 Expression *semantic(Scope *sc); | |
201 Expression *interpret(InterState *istate); | |
202 char *toChars(); | |
203 integer_t toInteger(); | |
204 uinteger_t toUInteger(); | |
205 real_t toReal(); | |
206 real_t toImaginary(); | |
207 complex_t toComplex(); | |
208 Expression *castTo(Scope *sc, Type *t); | |
209 int isConst(); | |
210 int isBool(int result); | |
211 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
212 void toMangleBuffer(OutBuffer *buf); | |
213 elem *toElem(IRState *irs); | |
214 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
215 // LDC |
159 | 216 virtual llvm::Constant *toConstElem(IRState *irs); |
217 }; | |
218 | |
219 struct ComplexExp : Expression | |
220 { | |
221 complex_t value; | |
222 | |
223 ComplexExp(Loc loc, complex_t value, Type *type); | |
224 int equals(Object *o); | |
225 Expression *semantic(Scope *sc); | |
226 Expression *interpret(InterState *istate); | |
227 char *toChars(); | |
228 integer_t toInteger(); | |
229 uinteger_t toUInteger(); | |
230 real_t toReal(); | |
231 real_t toImaginary(); | |
232 complex_t toComplex(); | |
233 Expression *castTo(Scope *sc, Type *t); | |
234 int isConst(); | |
235 int isBool(int result); | |
236 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
237 void toMangleBuffer(OutBuffer *buf); | |
238 #ifdef _DH | |
239 OutBuffer hexp; | |
240 #endif | |
241 elem *toElem(IRState *irs); | |
242 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
243 // LDC |
159 | 244 virtual llvm::Constant *toConstElem(IRState *irs); |
245 }; | |
246 | |
247 struct IdentifierExp : Expression | |
248 { | |
249 Identifier *ident; | |
250 Declaration *var; | |
251 | |
252 IdentifierExp(Loc loc, Identifier *ident); | |
253 IdentifierExp(Loc loc, Declaration *var); | |
254 Expression *semantic(Scope *sc); | |
255 char *toChars(); | |
256 void dump(int indent); | |
257 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
258 Expression *toLvalue(Scope *sc, Expression *e); | |
259 }; | |
260 | |
261 struct DollarExp : IdentifierExp | |
262 { | |
263 DollarExp(Loc loc); | |
264 }; | |
265 | |
266 struct DsymbolExp : Expression | |
267 { | |
268 Dsymbol *s; | |
269 | |
270 DsymbolExp(Loc loc, Dsymbol *s); | |
271 Expression *semantic(Scope *sc); | |
272 char *toChars(); | |
273 void dump(int indent); | |
274 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
275 Expression *toLvalue(Scope *sc, Expression *e); | |
276 }; | |
277 | |
278 struct ThisExp : Expression | |
279 { | |
280 Declaration *var; | |
281 | |
282 ThisExp(Loc loc); | |
283 Expression *semantic(Scope *sc); | |
284 int isBool(int result); | |
285 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
286 Expression *toLvalue(Scope *sc, Expression *e); | |
287 void scanForNestedRef(Scope *sc); | |
288 | |
289 int inlineCost(InlineCostState *ics); | |
290 Expression *doInline(InlineDoState *ids); | |
291 //Expression *inlineScan(InlineScanState *iss); | |
292 | |
293 elem *toElem(IRState *irs); | |
294 }; | |
295 | |
296 struct SuperExp : ThisExp | |
297 { | |
298 SuperExp(Loc loc); | |
299 Expression *semantic(Scope *sc); | |
300 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
301 void scanForNestedRef(Scope *sc); | |
302 | |
303 int inlineCost(InlineCostState *ics); | |
304 Expression *doInline(InlineDoState *ids); | |
305 //Expression *inlineScan(InlineScanState *iss); | |
306 }; | |
307 | |
308 struct NullExp : Expression | |
309 { | |
310 unsigned char committed; // !=0 if type is committed | |
311 | |
312 NullExp(Loc loc); | |
313 Expression *semantic(Scope *sc); | |
314 int isBool(int result); | |
315 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
316 void toMangleBuffer(OutBuffer *buf); | |
317 MATCH implicitConvTo(Type *t); | |
318 Expression *castTo(Scope *sc, Type *t); | |
319 Expression *interpret(InterState *istate); | |
320 elem *toElem(IRState *irs); | |
321 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
322 // LDC |
159 | 323 virtual llvm::Constant *toConstElem(IRState *irs); |
324 }; | |
325 | |
326 struct StringExp : Expression | |
327 { | |
328 void *string; // char, wchar, or dchar data | |
329 size_t len; // number of chars, wchars, or dchars | |
330 unsigned char sz; // 1: char, 2: wchar, 4: dchar | |
331 unsigned char committed; // !=0 if type is committed | |
332 unsigned char postfix; // 'c', 'w', 'd' | |
333 | |
334 StringExp(Loc loc, char *s); | |
335 StringExp(Loc loc, void *s, size_t len); | |
336 StringExp(Loc loc, void *s, size_t len, unsigned char postfix); | |
337 //Expression *syntaxCopy(); | |
338 int equals(Object *o); | |
339 char *toChars(); | |
340 Expression *semantic(Scope *sc); | |
341 Expression *interpret(InterState *istate); | |
342 StringExp *toUTF8(Scope *sc); | |
343 MATCH implicitConvTo(Type *t); | |
344 Expression *castTo(Scope *sc, Type *t); | |
345 int compare(Object *obj); | |
346 int isBool(int result); | |
347 unsigned charAt(size_t i); | |
348 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
349 void toMangleBuffer(OutBuffer *buf); | |
350 elem *toElem(IRState *irs); | |
351 dt_t **toDt(dt_t **pdt); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
352 // LDC |
159 | 353 virtual llvm::Constant *toConstElem(IRState *irs); |
354 }; | |
355 | |
356 // Tuple | |
357 | |
358 struct TupleExp : Expression | |
359 { | |
360 Expressions *exps; | |
361 | |
362 TupleExp(Loc loc, Expressions *exps); | |
363 TupleExp(Loc loc, TupleDeclaration *tup); | |
364 Expression *syntaxCopy(); | |
365 int equals(Object *o); | |
366 Expression *semantic(Scope *sc); | |
367 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
368 void scanForNestedRef(Scope *sc); | |
369 void checkEscape(); | |
370 int checkSideEffect(int flag); | |
371 Expression *optimize(int result); | |
372 Expression *interpret(InterState *istate); | |
373 Expression *castTo(Scope *sc, Type *t); | |
374 elem *toElem(IRState *irs); | |
375 | |
376 int inlineCost(InlineCostState *ics); | |
377 Expression *doInline(InlineDoState *ids); | |
378 Expression *inlineScan(InlineScanState *iss); | |
379 }; | |
380 | |
381 struct ArrayLiteralExp : Expression | |
382 { | |
383 Expressions *elements; | |
384 | |
385 ArrayLiteralExp(Loc loc, Expressions *elements); | |
386 ArrayLiteralExp(Loc loc, Expression *e); | |
387 | |
388 Expression *syntaxCopy(); | |
389 Expression *semantic(Scope *sc); | |
390 int isBool(int result); | |
391 elem *toElem(IRState *irs); | |
392 int checkSideEffect(int flag); | |
393 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
394 void toMangleBuffer(OutBuffer *buf); | |
395 void scanForNestedRef(Scope *sc); | |
396 Expression *optimize(int result); | |
397 Expression *interpret(InterState *istate); | |
398 MATCH implicitConvTo(Type *t); | |
399 Expression *castTo(Scope *sc, Type *t); | |
400 dt_t **toDt(dt_t **pdt); | |
401 | |
402 int inlineCost(InlineCostState *ics); | |
403 Expression *doInline(InlineDoState *ids); | |
404 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
405 // LDC |
159 | 406 virtual llvm::Constant *toConstElem(IRState *irs); |
407 }; | |
408 | |
409 struct AssocArrayLiteralExp : Expression | |
410 { | |
411 Expressions *keys; | |
412 Expressions *values; | |
413 | |
414 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); | |
415 | |
416 Expression *syntaxCopy(); | |
417 Expression *semantic(Scope *sc); | |
418 int isBool(int result); | |
419 elem *toElem(IRState *irs); | |
420 int checkSideEffect(int flag); | |
421 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
422 void toMangleBuffer(OutBuffer *buf); | |
423 void scanForNestedRef(Scope *sc); | |
424 Expression *optimize(int result); | |
425 Expression *interpret(InterState *istate); | |
426 MATCH implicitConvTo(Type *t); | |
427 Expression *castTo(Scope *sc, Type *t); | |
428 | |
429 int inlineCost(InlineCostState *ics); | |
430 Expression *doInline(InlineDoState *ids); | |
431 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
432 // LDC |
159 | 433 virtual llvm::Constant *toConstElem(IRState *irs); |
434 }; | |
435 | |
436 struct StructLiteralExp : Expression | |
437 { | |
438 StructDeclaration *sd; // which aggregate this is for | |
439 Expressions *elements; // parallels sd->fields[] with | |
440 // NULL entries for fields to skip | |
441 | |
442 Symbol *sym; // back end symbol to initialize with literal | |
443 size_t soffset; // offset from start of s | |
444 int fillHoles; // fill alignment 'holes' with zero | |
445 | |
446 StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements); | |
447 | |
448 Expression *syntaxCopy(); | |
449 Expression *semantic(Scope *sc); | |
450 Expression *getField(Type *type, unsigned offset); | |
451 int getFieldIndex(Type *type, unsigned offset); | |
452 elem *toElem(IRState *irs); | |
453 int checkSideEffect(int flag); | |
454 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
455 void toMangleBuffer(OutBuffer *buf); | |
456 void scanForNestedRef(Scope *sc); | |
457 Expression *optimize(int result); | |
458 Expression *interpret(InterState *istate); | |
459 dt_t **toDt(dt_t **pdt); | |
460 Expression *toLvalue(Scope *sc, Expression *e); | |
461 | |
462 int inlineCost(InlineCostState *ics); | |
463 Expression *doInline(InlineDoState *ids); | |
464 Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
465 // LDC |
159 | 466 virtual llvm::Constant *toConstElem(IRState *irs); |
467 }; | |
468 | |
469 struct TypeDotIdExp : Expression | |
470 { | |
471 Identifier *ident; | |
472 | |
473 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); | |
474 Expression *syntaxCopy(); | |
475 Expression *semantic(Scope *sc); | |
476 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
477 elem *toElem(IRState *irs); | |
478 }; | |
479 | |
480 struct TypeExp : Expression | |
481 { | |
482 TypeExp(Loc loc, Type *type); | |
876
27a379f288bf
Merged DMD 1.039
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
483 Expression *syntaxCopy(); |
159 | 484 Expression *semantic(Scope *sc); |
485 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
486 Expression *optimize(int result); | |
487 elem *toElem(IRState *irs); | |
488 }; | |
489 | |
490 struct ScopeExp : Expression | |
491 { | |
492 ScopeDsymbol *sds; | |
493 | |
494 ScopeExp(Loc loc, ScopeDsymbol *sds); | |
495 Expression *syntaxCopy(); | |
496 Expression *semantic(Scope *sc); | |
497 elem *toElem(IRState *irs); | |
498 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
499 }; | |
500 | |
501 struct TemplateExp : Expression | |
502 { | |
503 TemplateDeclaration *td; | |
504 | |
505 TemplateExp(Loc loc, TemplateDeclaration *td); | |
506 void rvalue(); | |
507 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
508 }; | |
509 | |
510 struct NewExp : Expression | |
511 { | |
512 /* thisexp.new(newargs) newtype(arguments) | |
513 */ | |
514 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
515 Expressions *newargs; // Array of Expression's to call new operator | |
516 Type *newtype; | |
517 Expressions *arguments; // Array of Expression's | |
518 | |
519 CtorDeclaration *member; // constructor function | |
520 NewDeclaration *allocator; // allocator function | |
521 int onstack; // allocate on stack | |
522 | |
523 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
524 Type *newtype, Expressions *arguments); | |
525 Expression *syntaxCopy(); | |
526 Expression *semantic(Scope *sc); | |
527 elem *toElem(IRState *irs); | |
528 int checkSideEffect(int flag); | |
529 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
530 void scanForNestedRef(Scope *sc); | |
531 | |
532 //int inlineCost(InlineCostState *ics); | |
533 Expression *doInline(InlineDoState *ids); | |
534 //Expression *inlineScan(InlineScanState *iss); | |
535 }; | |
536 | |
537 struct NewAnonClassExp : Expression | |
538 { | |
539 /* thisexp.new(newargs) class baseclasses { } (arguments) | |
540 */ | |
541 Expression *thisexp; // if !NULL, 'this' for class being allocated | |
542 Expressions *newargs; // Array of Expression's to call new operator | |
543 ClassDeclaration *cd; // class being instantiated | |
544 Expressions *arguments; // Array of Expression's to call class constructor | |
545 | |
546 NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs, | |
547 ClassDeclaration *cd, Expressions *arguments); | |
548 Expression *syntaxCopy(); | |
549 Expression *semantic(Scope *sc); | |
550 int checkSideEffect(int flag); | |
551 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
552 }; | |
553 | |
554 // Offset from symbol | |
555 | |
556 struct SymOffExp : Expression | |
557 { | |
558 Declaration *var; | |
559 unsigned offset; | |
560 | |
561 SymOffExp(Loc loc, Declaration *var, unsigned offset); | |
562 Expression *semantic(Scope *sc); | |
563 void checkEscape(); | |
564 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
565 int isConst(); | |
566 int isBool(int result); | |
567 Expression *doInline(InlineDoState *ids); | |
568 MATCH implicitConvTo(Type *t); | |
569 Expression *castTo(Scope *sc, Type *t); | |
570 void scanForNestedRef(Scope *sc); | |
571 | |
572 elem *toElem(IRState *irs); | |
573 dt_t **toDt(dt_t **pdt); | |
574 }; | |
575 | |
576 // Variable | |
577 | |
578 struct VarExp : Expression | |
579 { | |
580 Declaration *var; | |
581 | |
582 VarExp(Loc loc, Declaration *var); | |
583 int equals(Object *o); | |
584 Expression *semantic(Scope *sc); | |
585 Expression *optimize(int result); | |
586 Expression *interpret(InterState *istate); | |
587 void dump(int indent); | |
588 char *toChars(); | |
589 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
590 void checkEscape(); | |
591 Expression *toLvalue(Scope *sc, Expression *e); | |
592 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
593 elem *toElem(IRState *irs); | |
594 dt_t **toDt(dt_t **pdt); | |
595 void scanForNestedRef(Scope *sc); | |
596 | |
597 int inlineCost(InlineCostState *ics); | |
598 Expression *doInline(InlineDoState *ids); | |
599 //Expression *inlineScan(InlineScanState *iss); | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
600 // LDC |
159 | 601 virtual llvm::Constant *toConstElem(IRState *irs); |
602 }; | |
603 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
604 #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
|
605 // 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
|
606 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
607 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
|
608 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
609 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
|
610 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
615 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
616 |
159 | 617 // Function/Delegate literal |
618 | |
619 struct FuncExp : Expression | |
620 { | |
621 FuncLiteralDeclaration *fd; | |
622 | |
623 FuncExp(Loc loc, FuncLiteralDeclaration *fd); | |
624 Expression *syntaxCopy(); | |
625 Expression *semantic(Scope *sc); | |
626 void scanForNestedRef(Scope *sc); | |
627 char *toChars(); | |
628 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
629 elem *toElem(IRState *irs); | |
630 | |
631 int inlineCost(InlineCostState *ics); | |
632 //Expression *doInline(InlineDoState *ids); | |
633 //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
|
634 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
635 // LDC |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
636 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 637 }; |
638 | |
639 // Declaration of a symbol | |
640 | |
641 struct DeclarationExp : Expression | |
642 { | |
643 Dsymbol *declaration; | |
644 | |
645 DeclarationExp(Loc loc, Dsymbol *declaration); | |
646 Expression *syntaxCopy(); | |
647 Expression *semantic(Scope *sc); | |
648 Expression *interpret(InterState *istate); | |
649 int checkSideEffect(int flag); | |
650 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
651 elem *toElem(IRState *irs); | |
652 void scanForNestedRef(Scope *sc); | |
653 | |
654 int inlineCost(InlineCostState *ics); | |
655 Expression *doInline(InlineDoState *ids); | |
656 Expression *inlineScan(InlineScanState *iss); | |
657 }; | |
658 | |
659 struct TypeidExp : Expression | |
660 { | |
661 Type *typeidType; | |
662 | |
663 TypeidExp(Loc loc, Type *typeidType); | |
664 Expression *syntaxCopy(); | |
665 Expression *semantic(Scope *sc); | |
666 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
667 }; | |
668 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
669 #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
|
670 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
|
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 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
|
673 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
|
674 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
675 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
|
676 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
|
677 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
|
678 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
|
679 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
680 #endif |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
681 |
159 | 682 struct HaltExp : Expression |
683 { | |
684 HaltExp(Loc loc); | |
685 Expression *semantic(Scope *sc); | |
686 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
687 int checkSideEffect(int flag); | |
688 | |
689 elem *toElem(IRState *irs); | |
690 }; | |
691 | |
692 struct IsExp : Expression | |
693 { | |
694 /* is(targ id tok tspec) | |
695 * is(targ id == tok2) | |
696 */ | |
697 Type *targ; | |
698 Identifier *id; // can be NULL | |
699 enum TOK tok; // ':' or '==' | |
700 Type *tspec; // can be NULL | |
701 enum TOK tok2; // 'struct', 'union', 'typedef', etc. | |
702 | |
703 IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); | |
704 Expression *syntaxCopy(); | |
705 Expression *semantic(Scope *sc); | |
706 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
707 }; | |
708 | |
709 /****************************************************************/ | |
710 | |
711 struct UnaExp : Expression | |
712 { | |
713 Expression *e1; | |
714 | |
715 UnaExp(Loc loc, enum TOK op, int size, Expression *e1); | |
716 Expression *syntaxCopy(); | |
717 Expression *semantic(Scope *sc); | |
718 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
719 Expression *optimize(int result); | |
720 void dump(int indent); | |
721 void scanForNestedRef(Scope *sc); | |
722 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *)); | |
723 | |
724 int inlineCost(InlineCostState *ics); | |
725 Expression *doInline(InlineDoState *ids); | |
726 Expression *inlineScan(InlineScanState *iss); | |
727 | |
728 Expression *op_overload(Scope *sc); // doesn't need to be virtual | |
729 }; | |
730 | |
731 struct BinExp : Expression | |
732 { | |
733 Expression *e1; | |
734 Expression *e2; | |
735 | |
736 BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
737 Expression *syntaxCopy(); | |
738 Expression *semantic(Scope *sc); | |
739 Expression *semanticp(Scope *sc); | |
740 Expression *commonSemanticAssign(Scope *sc); | |
741 Expression *commonSemanticAssignIntegral(Scope *sc); | |
742 int checkSideEffect(int flag); | |
743 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
744 Expression *scaleFactor(Scope *sc); | |
745 Expression *typeCombine(Scope *sc); | |
746 Expression *optimize(int result); | |
747 int isunsigned(); | |
748 void incompatibleTypes(); | |
749 void dump(int indent); | |
750 void scanForNestedRef(Scope *sc); | |
751 Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); | |
752 Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); | |
753 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
|
754 Expression *arrayOp(Scope *sc); |
159 | 755 |
756 int inlineCost(InlineCostState *ics); | |
757 Expression *doInline(InlineDoState *ids); | |
758 Expression *inlineScan(InlineScanState *iss); | |
759 | |
760 Expression *op_overload(Scope *sc); | |
761 | |
762 elem *toElemBin(IRState *irs, int op); | |
763 }; | |
764 | |
765 struct BinAssignExp : BinExp | |
766 { | |
767 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | |
768 int checkSideEffect(int flag); | |
769 }; | |
770 | |
771 /****************************************************************/ | |
772 | |
773 struct CompileExp : UnaExp | |
774 { | |
775 CompileExp(Loc loc, Expression *e); | |
776 Expression *semantic(Scope *sc); | |
777 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
778 }; | |
779 | |
780 struct FileExp : UnaExp | |
781 { | |
782 FileExp(Loc loc, Expression *e); | |
783 Expression *semantic(Scope *sc); | |
784 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
785 }; | |
786 | |
787 struct AssertExp : UnaExp | |
788 { | |
789 Expression *msg; | |
790 | |
791 AssertExp(Loc loc, Expression *e, Expression *msg = NULL); | |
792 Expression *syntaxCopy(); | |
793 Expression *semantic(Scope *sc); | |
794 Expression *interpret(InterState *istate); | |
795 int checkSideEffect(int flag); | |
796 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
797 | |
798 int inlineCost(InlineCostState *ics); | |
799 Expression *doInline(InlineDoState *ids); | |
800 Expression *inlineScan(InlineScanState *iss); | |
801 | |
802 elem *toElem(IRState *irs); | |
803 }; | |
804 | |
805 struct DotIdExp : UnaExp | |
806 { | |
807 Identifier *ident; | |
808 | |
809 DotIdExp(Loc loc, Expression *e, Identifier *ident); | |
810 Expression *semantic(Scope *sc); | |
811 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
812 void dump(int i); | |
813 }; | |
814 | |
815 struct DotTemplateExp : UnaExp | |
816 { | |
817 TemplateDeclaration *td; | |
818 | |
819 DotTemplateExp(Loc loc, Expression *e, TemplateDeclaration *td); | |
820 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
821 }; | |
822 | |
823 struct DotVarExp : UnaExp | |
824 { | |
825 Declaration *var; | |
826 | |
827 DotVarExp(Loc loc, Expression *e, Declaration *var); | |
828 Expression *semantic(Scope *sc); | |
829 Expression *toLvalue(Scope *sc, Expression *e); | |
830 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
831 Expression *optimize(int result); |
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
860
diff
changeset
|
832 Expression *interpret(InterState *istate); |
159 | 833 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
834 void dump(int indent); | |
835 elem *toElem(IRState *irs); | |
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); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1039 |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1040 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1041 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1042 }; |
1043 | |
1044 struct ArrayLengthExp : UnaExp | |
1045 { | |
1046 ArrayLengthExp(Loc loc, Expression *e1); | |
1047 Expression *semantic(Scope *sc); | |
1048 Expression *optimize(int result); | |
1049 Expression *interpret(InterState *istate); | |
1050 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1051 elem *toElem(IRState *irs); | |
1052 }; | |
1053 | |
1054 // e1[a0,a1,a2,a3,...] | |
1055 | |
1056 struct ArrayExp : UnaExp | |
1057 { | |
1058 Expressions *arguments; // Array of Expression's | |
1059 | |
1060 ArrayExp(Loc loc, Expression *e1, Expressions *arguments); | |
1061 Expression *syntaxCopy(); | |
1062 Expression *semantic(Scope *sc); | |
1063 Expression *toLvalue(Scope *sc, Expression *e); | |
1064 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1065 void scanForNestedRef(Scope *sc); | |
1066 | |
1067 // For operator overloading | |
1068 Identifier *opId(); | |
1069 | |
1070 int inlineCost(InlineCostState *ics); | |
1071 Expression *doInline(InlineDoState *ids); | |
1072 Expression *inlineScan(InlineScanState *iss); | |
1073 }; | |
1074 | |
1075 /****************************************************************/ | |
1076 | |
1077 struct DotExp : BinExp | |
1078 { | |
1079 DotExp(Loc loc, Expression *e1, Expression *e2); | |
1080 Expression *semantic(Scope *sc); | |
1081 }; | |
1082 | |
1083 struct CommaExp : BinExp | |
1084 { | |
1085 CommaExp(Loc loc, Expression *e1, Expression *e2); | |
1086 Expression *semantic(Scope *sc); | |
1087 void checkEscape(); | |
1088 Expression *toLvalue(Scope *sc, Expression *e); | |
1089 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1090 int isBool(int result); | |
1091 int checkSideEffect(int flag); | |
1092 Expression *optimize(int result); | |
1093 Expression *interpret(InterState *istate); | |
1094 elem *toElem(IRState *irs); | |
1095 }; | |
1096 | |
1097 struct IndexExp : BinExp | |
1098 { | |
1099 VarDeclaration *lengthVar; | |
1100 int modifiable; | |
1101 | |
1102 IndexExp(Loc loc, Expression *e1, Expression *e2); | |
1103 Expression *semantic(Scope *sc); | |
1104 Expression *toLvalue(Scope *sc, Expression *e); | |
1105 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1106 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1107 Expression *optimize(int result); | |
1108 Expression *interpret(InterState *istate); | |
1109 Expression *doInline(InlineDoState *ids); | |
1110 void scanForNestedRef(Scope *sc); | |
1111 | |
1112 elem *toElem(IRState *irs); | |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1113 // LDC |
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1114 virtual llvm::Constant *toConstElem(IRState *irs); |
159 | 1115 }; |
1116 | |
1117 /* For both i++ and i-- | |
1118 */ | |
1119 struct PostExp : BinExp | |
1120 { | |
1121 PostExp(enum TOK op, Loc loc, Expression *e); | |
1122 Expression *semantic(Scope *sc); | |
1123 Expression *interpret(InterState *istate); | |
1124 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1125 Identifier *opId(); // For operator overloading | |
1126 elem *toElem(IRState *irs); | |
1127 }; | |
1128 | |
1129 struct AssignExp : BinExp | |
1130 { int ismemset; // !=0 if setting the contents of an array | |
1131 | |
1132 AssignExp(Loc loc, Expression *e1, Expression *e2); | |
1133 Expression *semantic(Scope *sc); | |
1134 Expression *checkToBoolean(); | |
1135 Expression *interpret(InterState *istate); | |
1136 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
|
1137 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
|
1138 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1139 elem *toElem(IRState *irs); |
1140 }; | |
1141 | |
1142 #define ASSIGNEXP(op) \ | |
1143 struct op##AssignExp : BinExp \ | |
1144 { \ | |
1145 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | |
1146 Expression *semantic(Scope *sc); \ | |
1147 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
|
1148 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
|
1149 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
159 | 1150 \ |
1151 Identifier *opId(); /* For operator overloading */ \ | |
1152 \ | |
1153 elem *toElem(IRState *irs); \ | |
1154 }; | |
1155 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1156 #define X(a) a |
159 | 1157 ASSIGNEXP(Add) |
1158 ASSIGNEXP(Min) | |
1159 ASSIGNEXP(Mul) | |
1160 ASSIGNEXP(Div) | |
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 #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
|
1166 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1167 #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
|
1168 |
159 | 1169 ASSIGNEXP(Shl) |
1170 ASSIGNEXP(Shr) | |
1171 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
|
1172 ASSIGNEXP(Cat) |
159 | 1173 |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1174 #undef X |
159 | 1175 #undef ASSIGNEXP |
1176 | |
1177 struct AddExp : BinExp | |
1178 { | |
1179 AddExp(Loc loc, Expression *e1, Expression *e2); | |
1180 Expression *semantic(Scope *sc); | |
1181 Expression *optimize(int result); | |
1182 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
|
1183 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
|
1184 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1185 |
1186 // For operator overloading | |
1187 int isCommutative(); | |
1188 Identifier *opId(); | |
1189 Identifier *opId_r(); | |
1190 | |
1191 elem *toElem(IRState *irs); | |
1192 }; | |
1193 | |
1194 struct MinExp : BinExp | |
1195 { | |
1196 MinExp(Loc loc, Expression *e1, Expression *e2); | |
1197 Expression *semantic(Scope *sc); | |
1198 Expression *optimize(int result); | |
1199 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
|
1200 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
|
1201 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1202 |
1203 // For operator overloading | |
1204 Identifier *opId(); | |
1205 Identifier *opId_r(); | |
1206 | |
1207 elem *toElem(IRState *irs); | |
1208 }; | |
1209 | |
1210 struct CatExp : BinExp | |
1211 { | |
1212 CatExp(Loc loc, Expression *e1, Expression *e2); | |
1213 Expression *semantic(Scope *sc); | |
1214 Expression *optimize(int result); | |
1215 Expression *interpret(InterState *istate); | |
1216 | |
1217 // For operator overloading | |
1218 Identifier *opId(); | |
1219 Identifier *opId_r(); | |
1220 | |
1221 elem *toElem(IRState *irs); | |
1222 }; | |
1223 | |
1224 struct MulExp : BinExp | |
1225 { | |
1226 MulExp(Loc loc, Expression *e1, Expression *e2); | |
1227 Expression *semantic(Scope *sc); | |
1228 Expression *optimize(int result); | |
1229 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
|
1230 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
|
1231 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1232 |
1233 // For operator overloading | |
1234 int isCommutative(); | |
1235 Identifier *opId(); | |
1236 Identifier *opId_r(); | |
1237 | |
1238 elem *toElem(IRState *irs); | |
1239 }; | |
1240 | |
1241 struct DivExp : BinExp | |
1242 { | |
1243 DivExp(Loc loc, Expression *e1, Expression *e2); | |
1244 Expression *semantic(Scope *sc); | |
1245 Expression *optimize(int result); | |
1246 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
|
1247 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
|
1248 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1249 |
1250 // For operator overloading | |
1251 Identifier *opId(); | |
1252 Identifier *opId_r(); | |
1253 | |
1254 elem *toElem(IRState *irs); | |
1255 }; | |
1256 | |
1257 struct ModExp : BinExp | |
1258 { | |
1259 ModExp(Loc loc, Expression *e1, Expression *e2); | |
1260 Expression *semantic(Scope *sc); | |
1261 Expression *optimize(int result); | |
1262 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
|
1263 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
|
1264 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1265 |
1266 // For operator overloading | |
1267 Identifier *opId(); | |
1268 Identifier *opId_r(); | |
1269 | |
1270 elem *toElem(IRState *irs); | |
1271 }; | |
1272 | |
1273 struct ShlExp : BinExp | |
1274 { | |
1275 ShlExp(Loc loc, Expression *e1, Expression *e2); | |
1276 Expression *semantic(Scope *sc); | |
1277 Expression *optimize(int result); | |
1278 Expression *interpret(InterState *istate); | |
1279 | |
1280 // For operator overloading | |
1281 Identifier *opId(); | |
1282 Identifier *opId_r(); | |
1283 | |
1284 elem *toElem(IRState *irs); | |
1285 }; | |
1286 | |
1287 struct ShrExp : BinExp | |
1288 { | |
1289 ShrExp(Loc loc, Expression *e1, Expression *e2); | |
1290 Expression *semantic(Scope *sc); | |
1291 Expression *optimize(int result); | |
1292 Expression *interpret(InterState *istate); | |
1293 | |
1294 // For operator overloading | |
1295 Identifier *opId(); | |
1296 Identifier *opId_r(); | |
1297 | |
1298 elem *toElem(IRState *irs); | |
1299 }; | |
1300 | |
1301 struct UshrExp : BinExp | |
1302 { | |
1303 UshrExp(Loc loc, Expression *e1, Expression *e2); | |
1304 Expression *semantic(Scope *sc); | |
1305 Expression *optimize(int result); | |
1306 Expression *interpret(InterState *istate); | |
1307 | |
1308 // For operator overloading | |
1309 Identifier *opId(); | |
1310 Identifier *opId_r(); | |
1311 | |
1312 elem *toElem(IRState *irs); | |
1313 }; | |
1314 | |
1315 struct AndExp : BinExp | |
1316 { | |
1317 AndExp(Loc loc, Expression *e1, Expression *e2); | |
1318 Expression *semantic(Scope *sc); | |
1319 Expression *optimize(int result); | |
1320 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
|
1321 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
|
1322 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1323 |
1324 // For operator overloading | |
1325 int isCommutative(); | |
1326 Identifier *opId(); | |
1327 Identifier *opId_r(); | |
1328 | |
1329 elem *toElem(IRState *irs); | |
1330 }; | |
1331 | |
1332 struct OrExp : BinExp | |
1333 { | |
1334 OrExp(Loc loc, Expression *e1, Expression *e2); | |
1335 Expression *semantic(Scope *sc); | |
1336 Expression *optimize(int result); | |
1337 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
|
1338 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
|
1339 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1340 |
1341 // For operator overloading | |
1342 int isCommutative(); | |
1343 Identifier *opId(); | |
1344 Identifier *opId_r(); | |
1345 | |
1346 elem *toElem(IRState *irs); | |
1347 }; | |
1348 | |
1349 struct XorExp : BinExp | |
1350 { | |
1351 XorExp(Loc loc, Expression *e1, Expression *e2); | |
1352 Expression *semantic(Scope *sc); | |
1353 Expression *optimize(int result); | |
1354 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
|
1355 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
|
1356 Expression *buildArrayLoop(Arguments *fparams); |
159 | 1357 |
1358 // For operator overloading | |
1359 int isCommutative(); | |
1360 Identifier *opId(); | |
1361 Identifier *opId_r(); | |
1362 | |
1363 elem *toElem(IRState *irs); | |
1364 }; | |
1365 | |
1366 struct OrOrExp : BinExp | |
1367 { | |
1368 OrOrExp(Loc loc, Expression *e1, Expression *e2); | |
1369 Expression *semantic(Scope *sc); | |
1370 Expression *checkToBoolean(); | |
1371 int isBit(); | |
1372 Expression *optimize(int result); | |
1373 Expression *interpret(InterState *istate); | |
1374 int checkSideEffect(int flag); | |
1375 elem *toElem(IRState *irs); | |
1376 }; | |
1377 | |
1378 struct AndAndExp : BinExp | |
1379 { | |
1380 AndAndExp(Loc loc, Expression *e1, Expression *e2); | |
1381 Expression *semantic(Scope *sc); | |
1382 Expression *checkToBoolean(); | |
1383 int isBit(); | |
1384 Expression *optimize(int result); | |
1385 Expression *interpret(InterState *istate); | |
1386 int checkSideEffect(int flag); | |
1387 elem *toElem(IRState *irs); | |
1388 }; | |
1389 | |
1390 struct CmpExp : BinExp | |
1391 { | |
1392 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1393 Expression *semantic(Scope *sc); | |
1394 Expression *optimize(int result); | |
1395 Expression *interpret(InterState *istate); | |
1396 int isBit(); | |
1397 | |
1398 // For operator overloading | |
1399 int isCommutative(); | |
1400 Identifier *opId(); | |
1401 | |
1402 elem *toElem(IRState *irs); | |
1403 }; | |
1404 | |
1405 struct InExp : BinExp | |
1406 { | |
1407 InExp(Loc loc, Expression *e1, Expression *e2); | |
1408 Expression *semantic(Scope *sc); | |
1409 int isBit(); | |
1410 | |
1411 // For operator overloading | |
1412 Identifier *opId(); | |
1413 Identifier *opId_r(); | |
1414 | |
1415 elem *toElem(IRState *irs); | |
1416 }; | |
1417 | |
1418 struct RemoveExp : BinExp | |
1419 { | |
1420 RemoveExp(Loc loc, Expression *e1, Expression *e2); | |
1421 elem *toElem(IRState *irs); | |
1422 }; | |
1423 | |
1424 // == and != | |
1425 | |
1426 struct EqualExp : BinExp | |
1427 { | |
1428 EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1429 Expression *semantic(Scope *sc); | |
1430 Expression *optimize(int result); | |
1431 Expression *interpret(InterState *istate); | |
1432 int isBit(); | |
1433 | |
1434 // For operator overloading | |
1435 int isCommutative(); | |
1436 Identifier *opId(); | |
1437 | |
1438 elem *toElem(IRState *irs); | |
1439 }; | |
1440 | |
1441 // === and !=== | |
1442 | |
1443 struct IdentityExp : BinExp | |
1444 { | |
1445 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | |
1446 Expression *semantic(Scope *sc); | |
1447 int isBit(); | |
1448 Expression *optimize(int result); | |
1449 Expression *interpret(InterState *istate); | |
1450 elem *toElem(IRState *irs); | |
1451 }; | |
1452 | |
1453 /****************************************************************/ | |
1454 | |
1455 struct CondExp : BinExp | |
1456 { | |
1457 Expression *econd; | |
1458 | |
1459 CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); | |
1460 Expression *syntaxCopy(); | |
1461 Expression *semantic(Scope *sc); | |
1462 Expression *optimize(int result); | |
1463 Expression *interpret(InterState *istate); | |
1464 void checkEscape(); | |
1465 Expression *toLvalue(Scope *sc, Expression *e); | |
1466 Expression *modifiableLvalue(Scope *sc, Expression *e); | |
1467 Expression *checkToBoolean(); | |
1468 int checkSideEffect(int flag); | |
1469 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1470 MATCH implicitConvTo(Type *t); | |
1471 Expression *castTo(Scope *sc, Type *t); | |
1472 void scanForNestedRef(Scope *sc); | |
1473 | |
1474 int inlineCost(InlineCostState *ics); | |
1475 Expression *doInline(InlineDoState *ids); | |
1476 Expression *inlineScan(InlineScanState *iss); | |
1477 | |
1478 elem *toElem(IRState *irs); | |
1479 }; | |
1480 | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1481 #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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1484 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
|
1485 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1486 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
|
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 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
|
1489 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
|
1490 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1493 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
|
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 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
|
1496 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
|
1497 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
|
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 |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1500 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
|
1501 { |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1502 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
|
1503 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
|
1504 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
|
1505 }; |
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
459
diff
changeset
|
1506 #endif |
159 | 1507 |
1508 /****************************************************************/ | |
1509 | |
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 #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
|
1511 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
619
diff
changeset
|
1512 // 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
|
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 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
|
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 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
|
1517 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
|
1518 |
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 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
|
1520 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
|
1521 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
|
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 elem *toElem(IRState *irs); |
860
7edce7e58ab1
Add more toConstElem stubs to get better error messages.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1524 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
|
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 #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
|
1528 |
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
|
1529 /****************************************************************/ |
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
|
1530 |
159 | 1531 /* Special values used by the interpreter |
1532 */ | |
1533 #define EXP_CANT_INTERPRET ((Expression *)1) | |
1534 #define EXP_CONTINUE_INTERPRET ((Expression *)2) | |
1535 #define EXP_BREAK_INTERPRET ((Expression *)3) | |
1536 #define EXP_GOTO_INTERPRET ((Expression *)4) | |
1537 #define EXP_VOID_INTERPRET ((Expression *)5) | |
1538 | |
1539 Expression *expType(Type *type, Expression *e); | |
1540 | |
1541 Expression *Neg(Type *type, Expression *e1); | |
1542 Expression *Com(Type *type, Expression *e1); | |
1543 Expression *Not(Type *type, Expression *e1); | |
1544 Expression *Bool(Type *type, Expression *e1); | |
1545 Expression *Cast(Type *type, Type *to, Expression *e1); | |
1546 Expression *ArrayLength(Type *type, Expression *e1); | |
1547 Expression *Ptr(Type *type, Expression *e1); | |
1548 | |
1549 Expression *Add(Type *type, Expression *e1, Expression *e2); | |
1550 Expression *Min(Type *type, Expression *e1, Expression *e2); | |
1551 Expression *Mul(Type *type, Expression *e1, Expression *e2); | |
1552 Expression *Div(Type *type, Expression *e1, Expression *e2); | |
1553 Expression *Mod(Type *type, Expression *e1, Expression *e2); | |
1554 Expression *Shl(Type *type, Expression *e1, Expression *e2); | |
1555 Expression *Shr(Type *type, Expression *e1, Expression *e2); | |
1556 Expression *Ushr(Type *type, Expression *e1, Expression *e2); | |
1557 Expression *And(Type *type, Expression *e1, Expression *e2); | |
1558 Expression *Or(Type *type, Expression *e1, Expression *e2); | |
1559 Expression *Xor(Type *type, Expression *e1, Expression *e2); | |
1560 Expression *Index(Type *type, Expression *e1, Expression *e2); | |
1561 Expression *Cat(Type *type, Expression *e1, Expression *e2); | |
1562 | |
1563 Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1564 Expression *Cmp(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1565 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2); | |
1566 | |
1567 Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr); | |
1568 | |
1569 #endif /* DMD_EXPRESSION_H */ |