comparison dmd2/expression.h @ 1452:638d16625da2

LDC 2 compiles again.
author Robert Clipsham <robert@octarineparrot.com>
date Sat, 30 May 2009 17:23:32 +0100
parents 5e5873d847f6
children 54b3c1394d62
comparison
equal deleted inserted replaced
1423:42bd767ec5a4 1452:638d16625da2
40 struct TemplateDeclaration; 40 struct TemplateDeclaration;
41 struct ClassDeclaration; 41 struct ClassDeclaration;
42 struct HdrGenState; 42 struct HdrGenState;
43 struct BinExp; 43 struct BinExp;
44 struct InterState; 44 struct InterState;
45 #if IN_DMD
45 struct Symbol; // back end symbol 46 struct Symbol; // back end symbol
47 #endif
46 struct OverloadSet; 48 struct OverloadSet;
47 namespace llvm 49
48 { 50 enum TOK;
51
52 #if IN_DMD
53 // Back end
54 struct IRState;
55 struct dt_t;
56 #endif
57
58 #ifdef IN_GCC
59 union tree_node; typedef union tree_node elem;
60 #endif
61 #if IN_DMD
62 struct elem;
63 #endif
64
65 #if IN_LLVM
66 struct IRState;
67 struct DValue;
68 namespace llvm {
49 class Constant; 69 class Constant;
50 class ConstantInt; 70 class ConstantInt;
51 } 71 }
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 72 #endif
69 73
70 void initPrecedence(); 74 void initPrecedence();
71 75
72 Expression *resolveProperties(Scope *sc, Expression *e); 76 Expression *resolveProperties(Scope *sc, Expression *e);
73 void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d); 77 void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d);
74 Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id); 78 Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id);
75 Dsymbol *search_function(ScopeDsymbol *ad, Identifier *funcid); 79 Dsymbol *search_function(ScopeDsymbol *ad, Identifier *funcid);
76 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr); 80 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module *from);
77 void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs); 81 void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
78 void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs); 82 void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
79 void expandTuples(Expressions *exps); 83 void expandTuples(Expressions *exps);
80 FuncDeclaration *hasThis(Scope *sc); 84 FuncDeclaration *hasThis(Scope *sc);
81 Expression *fromConstInitializer(int result, Expression *e); 85 Expression *fromConstInitializer(int result, Expression *e);
90 94
91 Expression(Loc loc, enum TOK op, int size); 95 Expression(Loc loc, enum TOK op, int size);
92 Expression *copy(); 96 Expression *copy();
93 virtual Expression *syntaxCopy(); 97 virtual Expression *syntaxCopy();
94 virtual Expression *semantic(Scope *sc); 98 virtual Expression *semantic(Scope *sc);
99 Expression *trySemantic(Scope *sc);
95 100
96 int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression() 101 int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression()
97 102
98 void print(); 103 void print();
99 char *toChars(); 104 char *toChars();
100 virtual void dump(int indent); 105 virtual void dump(int indent);
101 void error(const char *format, ...); 106 void error(const char *format, ...) IS_PRINTF(2);
107 void warning(const char *format, ...) IS_PRINTF(2);
102 virtual void rvalue(); 108 virtual void rvalue();
103 109
104 static Expression *combine(Expression *e1, Expression *e2); 110 static Expression *combine(Expression *e1, Expression *e2);
105 static Expressions *arraySyntaxCopy(Expressions *exps); 111 static Expressions *arraySyntaxCopy(Expressions *exps);
106 112
107 virtual integer_t toInteger(); 113 virtual dinteger_t toInteger();
108 virtual uinteger_t toUInteger(); 114 virtual uinteger_t toUInteger();
109 virtual real_t toReal(); 115 virtual real_t toReal();
110 virtual real_t toImaginary(); 116 virtual real_t toImaginary();
111 virtual complex_t toComplex(); 117 virtual complex_t toComplex();
112 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 118 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
113 virtual void toMangleBuffer(OutBuffer *buf); 119 virtual void toMangleBuffer(OutBuffer *buf);
114 virtual int isLvalue(); 120 virtual int isLvalue();
115 virtual Expression *toLvalue(Scope *sc, Expression *e); 121 virtual Expression *toLvalue(Scope *sc, Expression *e);
116 virtual Expression *modifiableLvalue(Scope *sc, Expression *e); 122 virtual Expression *modifiableLvalue(Scope *sc, Expression *e);
117 Expression *implicitCastTo(Scope *sc, Type *t); 123 virtual Expression *implicitCastTo(Scope *sc, Type *t);
118 virtual MATCH implicitConvTo(Type *t); 124 virtual MATCH implicitConvTo(Type *t);
119 virtual Expression *castTo(Scope *sc, Type *t); 125 virtual Expression *castTo(Scope *sc, Type *t);
120 virtual void checkEscape(); 126 virtual void checkEscape();
121 void checkScalar(); 127 void checkScalar();
122 void checkNoBool(); 128 void checkNoBool();
123 Expression *checkIntegral(); 129 Expression *checkIntegral();
124 Expression *checkArithmetic(); 130 Expression *checkArithmetic();
125 void checkDeprecated(Scope *sc, Dsymbol *s); 131 void checkDeprecated(Scope *sc, Dsymbol *s);
132 void checkPurity(Scope *sc, FuncDeclaration *f);
126 virtual Expression *checkToBoolean(); 133 virtual Expression *checkToBoolean();
127 Expression *checkToPointer(); 134 Expression *checkToPointer();
128 Expression *addressOf(Scope *sc); 135 Expression *addressOf(Scope *sc);
129 Expression *deref(); 136 Expression *deref();
130 Expression *integralPromotions(Scope *sc); 137 Expression *integralPromotions(Scope *sc);
156 163
157 // For array ops 164 // For array ops
158 virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 165 virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
159 virtual Expression *buildArrayLoop(Arguments *fparams); 166 virtual Expression *buildArrayLoop(Arguments *fparams);
160 167
168 #if IN_DMD
161 // Back end 169 // Back end
162 virtual elem *toElem(IRState *irs); 170 virtual elem *toElem(IRState *irs);
163 virtual dt_t **toDt(dt_t **pdt); 171 virtual dt_t **toDt(dt_t **pdt);
164 // LDC 172 #endif
173
174 #if IN_LLVM
175 virtual DValue* toElem(IRState* irs);
165 virtual llvm::Constant *toConstElem(IRState *irs); 176 virtual llvm::Constant *toConstElem(IRState *irs);
177 virtual void cacheLvalue(IRState* irs);
178
179 llvm::Value* cachedLvalue;
180 #endif
166 }; 181 };
167 182
168 struct IntegerExp : Expression 183 struct IntegerExp : Expression
169 { 184 {
170 integer_t value; 185 dinteger_t value;
171 186
172 IntegerExp(Loc loc, integer_t value, Type *type); 187 IntegerExp(Loc loc, dinteger_t value, Type *type);
173 IntegerExp(integer_t value); 188 IntegerExp(dinteger_t value);
174 int equals(Object *o); 189 int equals(Object *o);
175 Expression *semantic(Scope *sc); 190 Expression *semantic(Scope *sc);
176 Expression *interpret(InterState *istate); 191 Expression *interpret(InterState *istate);
177 char *toChars(); 192 char *toChars();
178 void dump(int indent); 193 void dump(int indent);
179 integer_t toInteger(); 194 dinteger_t toInteger();
180 real_t toReal(); 195 real_t toReal();
181 real_t toImaginary(); 196 real_t toImaginary();
182 complex_t toComplex(); 197 complex_t toComplex();
183 int isConst(); 198 int isConst();
184 int isBool(int result); 199 int isBool(int result);
185 MATCH implicitConvTo(Type *t); 200 MATCH implicitConvTo(Type *t);
186 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 201 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
187 void toMangleBuffer(OutBuffer *buf); 202 void toMangleBuffer(OutBuffer *buf);
188 Expression *toLvalue(Scope *sc, Expression *e); 203 Expression *toLvalue(Scope *sc, Expression *e);
204 #if IN_DMD
189 elem *toElem(IRState *irs); 205 elem *toElem(IRState *irs);
190 dt_t **toDt(dt_t **pdt); 206 dt_t **toDt(dt_t **pdt);
191 // LDC 207 #elif IN_LLVM
192 virtual llvm::Constant *toConstElem(IRState *irs); 208 DValue* toElem(IRState* irs);
209 llvm::Constant *toConstElem(IRState *irs);
210 #endif
211 };
212
213 struct ErrorExp : IntegerExp
214 {
215 ErrorExp();
216
217 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
193 }; 218 };
194 219
195 struct RealExp : Expression 220 struct RealExp : Expression
196 { 221 {
197 real_t value; 222 real_t value;
199 RealExp(Loc loc, real_t value, Type *type); 224 RealExp(Loc loc, real_t value, Type *type);
200 int equals(Object *o); 225 int equals(Object *o);
201 Expression *semantic(Scope *sc); 226 Expression *semantic(Scope *sc);
202 Expression *interpret(InterState *istate); 227 Expression *interpret(InterState *istate);
203 char *toChars(); 228 char *toChars();
204 integer_t toInteger(); 229 dinteger_t toInteger();
205 uinteger_t toUInteger(); 230 uinteger_t toUInteger();
206 real_t toReal(); 231 real_t toReal();
207 real_t toImaginary(); 232 real_t toImaginary();
208 complex_t toComplex(); 233 complex_t toComplex();
209 Expression *castTo(Scope *sc, Type *t); 234 Expression *castTo(Scope *sc, Type *t);
210 int isConst(); 235 int isConst();
211 int isBool(int result); 236 int isBool(int result);
212 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 237 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
213 void toMangleBuffer(OutBuffer *buf); 238 void toMangleBuffer(OutBuffer *buf);
239 #if IN_DMD
214 elem *toElem(IRState *irs); 240 elem *toElem(IRState *irs);
215 dt_t **toDt(dt_t **pdt); 241 dt_t **toDt(dt_t **pdt);
216 // LDC 242 #elif IN_LLVM
217 virtual llvm::Constant *toConstElem(IRState *irs); 243 DValue* toElem(IRState* irs);
244 llvm::Constant *toConstElem(IRState *irs);
245 #endif
218 }; 246 };
219 247
220 struct ComplexExp : Expression 248 struct ComplexExp : Expression
221 { 249 {
222 complex_t value; 250 complex_t value;
224 ComplexExp(Loc loc, complex_t value, Type *type); 252 ComplexExp(Loc loc, complex_t value, Type *type);
225 int equals(Object *o); 253 int equals(Object *o);
226 Expression *semantic(Scope *sc); 254 Expression *semantic(Scope *sc);
227 Expression *interpret(InterState *istate); 255 Expression *interpret(InterState *istate);
228 char *toChars(); 256 char *toChars();
229 integer_t toInteger(); 257 dinteger_t toInteger();
230 uinteger_t toUInteger(); 258 uinteger_t toUInteger();
231 real_t toReal(); 259 real_t toReal();
232 real_t toImaginary(); 260 real_t toImaginary();
233 complex_t toComplex(); 261 complex_t toComplex();
234 Expression *castTo(Scope *sc, Type *t); 262 Expression *castTo(Scope *sc, Type *t);
237 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 265 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
238 void toMangleBuffer(OutBuffer *buf); 266 void toMangleBuffer(OutBuffer *buf);
239 #ifdef _DH 267 #ifdef _DH
240 OutBuffer hexp; 268 OutBuffer hexp;
241 #endif 269 #endif
270 #if IN_DMD
242 elem *toElem(IRState *irs); 271 elem *toElem(IRState *irs);
243 dt_t **toDt(dt_t **pdt); 272 dt_t **toDt(dt_t **pdt);
244 // LDC 273 #elif IN_LLVM
245 virtual llvm::Constant *toConstElem(IRState *irs); 274 DValue* toElem(IRState* irs);
275 llvm::Constant *toConstElem(IRState *irs);
276 #endif
246 }; 277 };
247 278
248 struct IdentifierExp : Expression 279 struct IdentifierExp : Expression
249 { 280 {
250 Identifier *ident; 281 Identifier *ident;
293 324
294 int inlineCost(InlineCostState *ics); 325 int inlineCost(InlineCostState *ics);
295 Expression *doInline(InlineDoState *ids); 326 Expression *doInline(InlineDoState *ids);
296 //Expression *inlineScan(InlineScanState *iss); 327 //Expression *inlineScan(InlineScanState *iss);
297 328
298 elem *toElem(IRState *irs); 329 #if IN_DMD
330 elem *toElem(IRState *irs);
331 #endif
332
333 #if IN_LLVM
334 DValue* toElem(IRState* irs);
335 #endif
299 }; 336 };
300 337
301 struct SuperExp : ThisExp 338 struct SuperExp : ThisExp
302 { 339 {
303 SuperExp(Loc loc); 340 SuperExp(Loc loc);
320 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 357 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
321 void toMangleBuffer(OutBuffer *buf); 358 void toMangleBuffer(OutBuffer *buf);
322 MATCH implicitConvTo(Type *t); 359 MATCH implicitConvTo(Type *t);
323 Expression *castTo(Scope *sc, Type *t); 360 Expression *castTo(Scope *sc, Type *t);
324 Expression *interpret(InterState *istate); 361 Expression *interpret(InterState *istate);
362 #if IN_DMD
325 elem *toElem(IRState *irs); 363 elem *toElem(IRState *irs);
326 dt_t **toDt(dt_t **pdt); 364 dt_t **toDt(dt_t **pdt);
327 // LDC 365 #elif IN_LLVM
328 virtual llvm::Constant *toConstElem(IRState *irs); 366 DValue* toElem(IRState* irs);
367 llvm::Constant *toConstElem(IRState *irs);
368 #endif
329 }; 369 };
330 370
331 struct StringExp : Expression 371 struct StringExp : Expression
332 { 372 {
333 void *string; // char, wchar, or dchar data 373 void *string; // char, wchar, or dchar data
342 //Expression *syntaxCopy(); 382 //Expression *syntaxCopy();
343 int equals(Object *o); 383 int equals(Object *o);
344 char *toChars(); 384 char *toChars();
345 Expression *semantic(Scope *sc); 385 Expression *semantic(Scope *sc);
346 Expression *interpret(InterState *istate); 386 Expression *interpret(InterState *istate);
387 size_t length();
347 StringExp *toUTF8(Scope *sc); 388 StringExp *toUTF8(Scope *sc);
389 Expression *implicitCastTo(Scope *sc, Type *t);
348 MATCH implicitConvTo(Type *t); 390 MATCH implicitConvTo(Type *t);
349 Expression *castTo(Scope *sc, Type *t); 391 Expression *castTo(Scope *sc, Type *t);
350 int compare(Object *obj); 392 int compare(Object *obj);
351 int isBool(int result); 393 int isBool(int result);
352 unsigned charAt(size_t i); 394 unsigned charAt(size_t i);
353 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 395 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
354 void toMangleBuffer(OutBuffer *buf); 396 void toMangleBuffer(OutBuffer *buf);
397 #if IN_DMD
355 elem *toElem(IRState *irs); 398 elem *toElem(IRState *irs);
356 dt_t **toDt(dt_t **pdt); 399 dt_t **toDt(dt_t **pdt);
357 // LDC 400 #elif IN_LLVM
358 virtual llvm::Constant *toConstElem(IRState *irs); 401 DValue* toElem(IRState* irs);
402 llvm::Constant *toConstElem(IRState *irs);
403 #endif
359 }; 404 };
360 405
361 // Tuple 406 // Tuple
362 407
363 struct TupleExp : Expression 408 struct TupleExp : Expression
374 void checkEscape(); 419 void checkEscape();
375 int checkSideEffect(int flag); 420 int checkSideEffect(int flag);
376 Expression *optimize(int result); 421 Expression *optimize(int result);
377 Expression *interpret(InterState *istate); 422 Expression *interpret(InterState *istate);
378 Expression *castTo(Scope *sc, Type *t); 423 Expression *castTo(Scope *sc, Type *t);
379 elem *toElem(IRState *irs); 424 #if IN_DMD
425 elem *toElem(IRState *irs);
426 #endif
380 int canThrow(); 427 int canThrow();
381 428
382 int inlineCost(InlineCostState *ics); 429 int inlineCost(InlineCostState *ics);
383 Expression *doInline(InlineDoState *ids); 430 Expression *doInline(InlineDoState *ids);
384 Expression *inlineScan(InlineScanState *iss); 431 Expression *inlineScan(InlineScanState *iss);
432
433 #if IN_LLVM
434 DValue* toElem(IRState* irs);
435 #endif
385 }; 436 };
386 437
387 struct ArrayLiteralExp : Expression 438 struct ArrayLiteralExp : Expression
388 { 439 {
389 Expressions *elements; 440 Expressions *elements;
392 ArrayLiteralExp(Loc loc, Expression *e); 443 ArrayLiteralExp(Loc loc, Expression *e);
393 444
394 Expression *syntaxCopy(); 445 Expression *syntaxCopy();
395 Expression *semantic(Scope *sc); 446 Expression *semantic(Scope *sc);
396 int isBool(int result); 447 int isBool(int result);
397 elem *toElem(IRState *irs);
398 int checkSideEffect(int flag); 448 int checkSideEffect(int flag);
399 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 449 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
400 void toMangleBuffer(OutBuffer *buf); 450 void toMangleBuffer(OutBuffer *buf);
401 void scanForNestedRef(Scope *sc); 451 void scanForNestedRef(Scope *sc);
402 Expression *optimize(int result); 452 Expression *optimize(int result);
403 Expression *interpret(InterState *istate); 453 Expression *interpret(InterState *istate);
404 MATCH implicitConvTo(Type *t); 454 MATCH implicitConvTo(Type *t);
405 Expression *castTo(Scope *sc, Type *t); 455 Expression *castTo(Scope *sc, Type *t);
406 dt_t **toDt(dt_t **pdt);
407 int canThrow(); 456 int canThrow();
408 457
409 int inlineCost(InlineCostState *ics); 458 int inlineCost(InlineCostState *ics);
410 Expression *doInline(InlineDoState *ids); 459 Expression *doInline(InlineDoState *ids);
411 Expression *inlineScan(InlineScanState *iss); 460 Expression *inlineScan(InlineScanState *iss);
412 // LDC 461
413 virtual llvm::Constant *toConstElem(IRState *irs); 462 #if IN_DMD
463 elem *toElem(IRState *irs);
464 dt_t **toDt(dt_t **pdt);
465 #elif IN_LLVM
466 DValue* toElem(IRState* irs);
467 llvm::Constant *toConstElem(IRState *irs);
468 #endif
414 }; 469 };
415 470
416 struct AssocArrayLiteralExp : Expression 471 struct AssocArrayLiteralExp : Expression
417 { 472 {
418 Expressions *keys; 473 Expressions *keys;
421 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); 476 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values);
422 477
423 Expression *syntaxCopy(); 478 Expression *syntaxCopy();
424 Expression *semantic(Scope *sc); 479 Expression *semantic(Scope *sc);
425 int isBool(int result); 480 int isBool(int result);
426 elem *toElem(IRState *irs); 481 #if IN_DMD
482 elem *toElem(IRState *irs);
483 #endif
427 int checkSideEffect(int flag); 484 int checkSideEffect(int flag);
428 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 485 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
429 void toMangleBuffer(OutBuffer *buf); 486 void toMangleBuffer(OutBuffer *buf);
430 void scanForNestedRef(Scope *sc); 487 void scanForNestedRef(Scope *sc);
431 Expression *optimize(int result); 488 Expression *optimize(int result);
435 int canThrow(); 492 int canThrow();
436 493
437 int inlineCost(InlineCostState *ics); 494 int inlineCost(InlineCostState *ics);
438 Expression *doInline(InlineDoState *ids); 495 Expression *doInline(InlineDoState *ids);
439 Expression *inlineScan(InlineScanState *iss); 496 Expression *inlineScan(InlineScanState *iss);
440 // LDC 497
441 virtual llvm::Constant *toConstElem(IRState *irs); 498 #if IN_LLVM
499 DValue* toElem(IRState* irs);
500 llvm::Constant *toConstElem(IRState *irs);
501 #endif
442 }; 502 };
443 503
444 struct StructLiteralExp : Expression 504 struct StructLiteralExp : Expression
445 { 505 {
446 StructDeclaration *sd; // which aggregate this is for 506 StructDeclaration *sd; // which aggregate this is for
447 Expressions *elements; // parallels sd->fields[] with 507 Expressions *elements; // parallels sd->fields[] with
448 // NULL entries for fields to skip 508 // NULL entries for fields to skip
449 509
510 #if IN_DMD
450 Symbol *sym; // back end symbol to initialize with literal 511 Symbol *sym; // back end symbol to initialize with literal
512 #endif
451 size_t soffset; // offset from start of s 513 size_t soffset; // offset from start of s
452 int fillHoles; // fill alignment 'holes' with zero 514 int fillHoles; // fill alignment 'holes' with zero
453 515
454 StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements); 516 StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements);
455 517
456 Expression *syntaxCopy(); 518 Expression *syntaxCopy();
457 Expression *semantic(Scope *sc); 519 Expression *semantic(Scope *sc);
458 Expression *getField(Type *type, unsigned offset); 520 Expression *getField(Type *type, unsigned offset);
459 int getFieldIndex(Type *type, unsigned offset); 521 int getFieldIndex(Type *type, unsigned offset);
460 elem *toElem(IRState *irs);
461 int checkSideEffect(int flag); 522 int checkSideEffect(int flag);
462 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 523 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
463 void toMangleBuffer(OutBuffer *buf); 524 void toMangleBuffer(OutBuffer *buf);
464 void scanForNestedRef(Scope *sc); 525 void scanForNestedRef(Scope *sc);
465 Expression *optimize(int result); 526 Expression *optimize(int result);
466 Expression *interpret(InterState *istate); 527 Expression *interpret(InterState *istate);
467 dt_t **toDt(dt_t **pdt);
468 int isLvalue(); 528 int isLvalue();
469 Expression *toLvalue(Scope *sc, Expression *e); 529 // LDC: struct literals aren't lvalues! Taking their address can lead to
530 // incorrect behavior, see LDC#218, DMD#2682
531 // Expression *toLvalue(Scope *sc, Expression *e);
470 int canThrow(); 532 int canThrow();
471 MATCH implicitConvTo(Type *t); 533 MATCH implicitConvTo(Type *t);
472 534
473 int inlineCost(InlineCostState *ics); 535 int inlineCost(InlineCostState *ics);
474 Expression *doInline(InlineDoState *ids); 536 Expression *doInline(InlineDoState *ids);
475 Expression *inlineScan(InlineScanState *iss); 537 Expression *inlineScan(InlineScanState *iss);
476 // LDC 538
477 virtual llvm::Constant *toConstElem(IRState *irs); 539 #if IN_DMD
478 }; 540 elem *toElem(IRState *irs);
479 541 dt_t **toDt(dt_t **pdt);
480 struct TypeDotIdExp : Expression 542 #elif IN_LLVM
481 { 543 DValue* toElem(IRState* irs);
482 Identifier *ident; 544 llvm::Constant *toConstElem(IRState *irs);
483 545 #endif
484 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); 546 };
485 Expression *syntaxCopy(); 547
486 Expression *semantic(Scope *sc); 548 Expression *typeDotIdExp(Loc loc, Type *type, Identifier *ident);
487 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 549 #if IN_DMD
488 elem *toElem(IRState *irs); 550 #endif
489 }; 551
552 #if IN_LLVM
553 DValue* toElem(IRState* irs);
554 #endif
490 555
491 struct TypeExp : Expression 556 struct TypeExp : Expression
492 { 557 {
493 TypeExp(Loc loc, Type *type); 558 TypeExp(Loc loc, Type *type);
494 Expression *semantic(Scope *sc); 559 Expression *syntaxCopy();
495 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 560 Expression *semantic(Scope *sc);
496 Expression *optimize(int result); 561 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
497 elem *toElem(IRState *irs); 562 Expression *optimize(int result);
563 #if IN_DMD
564 elem *toElem(IRState *irs);
565 #endif
566
567 #if IN_LLVM
568 DValue* toElem(IRState* irs);
569 #endif
498 }; 570 };
499 571
500 struct ScopeExp : Expression 572 struct ScopeExp : Expression
501 { 573 {
502 ScopeDsymbol *sds; 574 ScopeDsymbol *sds;
503 575
504 ScopeExp(Loc loc, ScopeDsymbol *sds); 576 ScopeExp(Loc loc, ScopeDsymbol *sds);
505 Expression *syntaxCopy(); 577 Expression *syntaxCopy();
506 Expression *semantic(Scope *sc); 578 Expression *semantic(Scope *sc);
507 elem *toElem(IRState *irs); 579 #if IN_DMD
508 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 580 elem *toElem(IRState *irs);
581 #endif
582 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
583
584 #if IN_LLVM
585 DValue* toElem(IRState* irs);
586 #endif
509 }; 587 };
510 588
511 struct TemplateExp : Expression 589 struct TemplateExp : Expression
512 { 590 {
513 TemplateDeclaration *td; 591 TemplateDeclaration *td;
532 610
533 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, 611 NewExp(Loc loc, Expression *thisexp, Expressions *newargs,
534 Type *newtype, Expressions *arguments); 612 Type *newtype, Expressions *arguments);
535 Expression *syntaxCopy(); 613 Expression *syntaxCopy();
536 Expression *semantic(Scope *sc); 614 Expression *semantic(Scope *sc);
537 elem *toElem(IRState *irs); 615 #if IN_DMD
616 elem *toElem(IRState *irs);
617 #endif
538 int checkSideEffect(int flag); 618 int checkSideEffect(int flag);
539 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 619 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
540 void scanForNestedRef(Scope *sc); 620 void scanForNestedRef(Scope *sc);
541 int canThrow(); 621 int canThrow();
542 622
543 //int inlineCost(InlineCostState *ics); 623 //int inlineCost(InlineCostState *ics);
544 Expression *doInline(InlineDoState *ids); 624 Expression *doInline(InlineDoState *ids);
545 //Expression *inlineScan(InlineScanState *iss); 625 //Expression *inlineScan(InlineScanState *iss);
626
627 #if IN_LLVM
628 DValue* toElem(IRState* irs);
629 #endif
546 }; 630 };
547 631
548 struct NewAnonClassExp : Expression 632 struct NewAnonClassExp : Expression
549 { 633 {
550 /* thisexp.new(newargs) class baseclasses { } (arguments) 634 /* thisexp.new(newargs) class baseclasses { } (arguments)
568 Declaration *var; 652 Declaration *var;
569 int hasOverloads; 653 int hasOverloads;
570 654
571 SymbolExp(Loc loc, enum TOK op, int size, Declaration *var, int hasOverloads); 655 SymbolExp(Loc loc, enum TOK op, int size, Declaration *var, int hasOverloads);
572 656
573 elem *toElem(IRState *irs); 657 #if IN_DMD
658 elem *toElem(IRState *irs);
659 #endif
660
661 #if IN_LLVM
662 DValue* toElem(IRState* irs);
663 #endif
574 }; 664 };
575 665
576 // Offset from symbol 666 // Offset from symbol
577 667
578 struct SymOffExp : SymbolExp 668 struct SymOffExp : SymbolExp
579 { 669 {
580 unsigned offset; 670 unsigned offset;
671 Module* m; // starting point for overload resolution
581 672
582 SymOffExp(Loc loc, Declaration *var, unsigned offset, int hasOverloads = 0); 673 SymOffExp(Loc loc, Declaration *var, unsigned offset, int hasOverloads = 0);
583 Expression *semantic(Scope *sc); 674 Expression *semantic(Scope *sc);
584 void checkEscape(); 675 void checkEscape();
585 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 676 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
588 Expression *doInline(InlineDoState *ids); 679 Expression *doInline(InlineDoState *ids);
589 MATCH implicitConvTo(Type *t); 680 MATCH implicitConvTo(Type *t);
590 Expression *castTo(Scope *sc, Type *t); 681 Expression *castTo(Scope *sc, Type *t);
591 void scanForNestedRef(Scope *sc); 682 void scanForNestedRef(Scope *sc);
592 683
684 #if IN_DMD
593 dt_t **toDt(dt_t **pdt); 685 dt_t **toDt(dt_t **pdt);
594 686 #endif
595 // LDC 687
596 elem *toElem(IRState* irs); 688 #if IN_LLVM
689 DValue* toElem(IRState* irs);
690 #endif
597 }; 691 };
598 692
599 // Variable 693 // Variable
600 694
601 struct VarExp : SymbolExp 695 struct VarExp : SymbolExp
610 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 704 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
611 void checkEscape(); 705 void checkEscape();
612 int isLvalue(); 706 int isLvalue();
613 Expression *toLvalue(Scope *sc, Expression *e); 707 Expression *toLvalue(Scope *sc, Expression *e);
614 Expression *modifiableLvalue(Scope *sc, Expression *e); 708 Expression *modifiableLvalue(Scope *sc, Expression *e);
709 #if IN_DMD
615 dt_t **toDt(dt_t **pdt); 710 dt_t **toDt(dt_t **pdt);
711 #endif
616 void scanForNestedRef(Scope *sc); 712 void scanForNestedRef(Scope *sc);
617 713
618 int inlineCost(InlineCostState *ics); 714 int inlineCost(InlineCostState *ics);
619 Expression *doInline(InlineDoState *ids); 715 Expression *doInline(InlineDoState *ids);
620 //Expression *inlineScan(InlineScanState *iss); 716 //Expression *inlineScan(InlineScanState *iss);
621 // LDC 717
622 virtual llvm::Constant *toConstElem(IRState *irs); 718 #if IN_LLVM
623 virtual elem *toElem(IRState* irs); 719 DValue* toElem(IRState* irs);
720 llvm::Constant *toConstElem(IRState *irs);
721 void cacheLvalue(IRState* irs);
722 #endif
624 }; 723 };
625 724
626 #if DMDV2 725 #if DMDV2
627 // Overload Set 726 // Overload Set
628 727
646 Expression *syntaxCopy(); 745 Expression *syntaxCopy();
647 Expression *semantic(Scope *sc); 746 Expression *semantic(Scope *sc);
648 void scanForNestedRef(Scope *sc); 747 void scanForNestedRef(Scope *sc);
649 char *toChars(); 748 char *toChars();
650 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 749 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
651 elem *toElem(IRState *irs); 750 #if IN_DMD
751 elem *toElem(IRState *irs);
752 #endif
652 753
653 int inlineCost(InlineCostState *ics); 754 int inlineCost(InlineCostState *ics);
654 //Expression *doInline(InlineDoState *ids); 755 //Expression *doInline(InlineDoState *ids);
655 //Expression *inlineScan(InlineScanState *iss); 756 //Expression *inlineScan(InlineScanState *iss);
656 757
657 // LDC 758 #if IN_LLVM
658 virtual llvm::Constant *toConstElem(IRState *irs); 759 DValue* toElem(IRState* irs);
760 llvm::Constant *toConstElem(IRState *irs);
761 #endif
659 }; 762 };
660 763
661 // Declaration of a symbol 764 // Declaration of a symbol
662 765
663 struct DeclarationExp : Expression 766 struct DeclarationExp : Expression
668 Expression *syntaxCopy(); 771 Expression *syntaxCopy();
669 Expression *semantic(Scope *sc); 772 Expression *semantic(Scope *sc);
670 Expression *interpret(InterState *istate); 773 Expression *interpret(InterState *istate);
671 int checkSideEffect(int flag); 774 int checkSideEffect(int flag);
672 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 775 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
673 elem *toElem(IRState *irs); 776 #if IN_DMD
777 elem *toElem(IRState *irs);
778 #endif
674 void scanForNestedRef(Scope *sc); 779 void scanForNestedRef(Scope *sc);
675 int canThrow(); 780 int canThrow();
676 781
677 int inlineCost(InlineCostState *ics); 782 int inlineCost(InlineCostState *ics);
678 Expression *doInline(InlineDoState *ids); 783 Expression *doInline(InlineDoState *ids);
679 Expression *inlineScan(InlineScanState *iss); 784 Expression *inlineScan(InlineScanState *iss);
785
786 #if IN_LLVM
787 DValue* toElem(IRState* irs);
788 #endif
680 }; 789 };
681 790
682 struct TypeidExp : Expression 791 struct TypeidExp : Expression
683 { 792 {
684 Type *typeidType; 793 Type *typeidType;
707 HaltExp(Loc loc); 816 HaltExp(Loc loc);
708 Expression *semantic(Scope *sc); 817 Expression *semantic(Scope *sc);
709 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 818 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
710 int checkSideEffect(int flag); 819 int checkSideEffect(int flag);
711 820
712 elem *toElem(IRState *irs); 821 #if IN_DMD
822 elem *toElem(IRState *irs);
823 #endif
824
825 #if IN_LLVM
826 DValue* toElem(IRState* irs);
827 #endif
713 }; 828 };
714 829
715 struct IsExp : Expression 830 struct IsExp : Expression
716 { 831 {
717 /* is(targ id tok tspec) 832 /* is(targ id tok tspec)
784 Expression *doInline(InlineDoState *ids); 899 Expression *doInline(InlineDoState *ids);
785 Expression *inlineScan(InlineScanState *iss); 900 Expression *inlineScan(InlineScanState *iss);
786 901
787 Expression *op_overload(Scope *sc); 902 Expression *op_overload(Scope *sc);
788 903
904 #if IN_DMD
789 elem *toElemBin(IRState *irs, int op); 905 elem *toElemBin(IRState *irs, int op);
906 #endif
790 }; 907 };
791 908
792 struct BinAssignExp : BinExp 909 struct BinAssignExp : BinExp
793 { 910 {
794 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); 911 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2);
825 942
826 int inlineCost(InlineCostState *ics); 943 int inlineCost(InlineCostState *ics);
827 Expression *doInline(InlineDoState *ids); 944 Expression *doInline(InlineDoState *ids);
828 Expression *inlineScan(InlineScanState *iss); 945 Expression *inlineScan(InlineScanState *iss);
829 946
830 elem *toElem(IRState *irs); 947 #if IN_DMD
948 elem *toElem(IRState *irs);
949 #endif
950
951 #if IN_LLVM
952 DValue* toElem(IRState* irs);
953 #endif
831 }; 954 };
832 955
833 struct DotIdExp : UnaExp 956 struct DotIdExp : UnaExp
834 { 957 {
835 Identifier *ident; 958 Identifier *ident;
856 DotVarExp(Loc loc, Expression *e, Declaration *var, int hasOverloads = 0); 979 DotVarExp(Loc loc, Expression *e, Declaration *var, int hasOverloads = 0);
857 Expression *semantic(Scope *sc); 980 Expression *semantic(Scope *sc);
858 int isLvalue(); 981 int isLvalue();
859 Expression *toLvalue(Scope *sc, Expression *e); 982 Expression *toLvalue(Scope *sc, Expression *e);
860 Expression *modifiableLvalue(Scope *sc, Expression *e); 983 Expression *modifiableLvalue(Scope *sc, Expression *e);
984 Expression *optimize(int result);
985 Expression *interpret(InterState *istate);
861 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 986 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
862 void dump(int indent); 987 void dump(int indent);
863 elem *toElem(IRState *irs); 988 #if IN_DMD
864 989 elem *toElem(IRState *irs);
865 //LDC: since we don't convert abc.def -> *(&abc + ABC.def.offsetof) 990 #endif
866 // these are needed 991
867 Expression *optimize(int result); 992 #if IN_LLVM
868 Expression *interpret(InterState *istate); 993 DValue* toElem(IRState* irs);
994 void cacheLvalue(IRState* irs);
995 #endif
869 }; 996 };
870 997
871 struct DotTemplateInstanceExp : UnaExp 998 struct DotTemplateInstanceExp : UnaExp
872 { 999 {
873 TemplateInstance *ti; 1000 TemplateInstance *ti;
880 }; 1007 };
881 1008
882 struct DelegateExp : UnaExp 1009 struct DelegateExp : UnaExp
883 { 1010 {
884 FuncDeclaration *func; 1011 FuncDeclaration *func;
1012 Module* m; // starting point for overload resolution
885 int hasOverloads; 1013 int hasOverloads;
886 1014
887 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func, int hasOverloads = 0); 1015 DelegateExp(Loc loc, Expression *e, FuncDeclaration *func, int hasOverloads = 0);
888 Expression *semantic(Scope *sc); 1016 Expression *semantic(Scope *sc);
889 MATCH implicitConvTo(Type *t); 1017 MATCH implicitConvTo(Type *t);
890 Expression *castTo(Scope *sc, Type *t); 1018 Expression *castTo(Scope *sc, Type *t);
891 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1019 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
892 void dump(int indent); 1020 void dump(int indent);
893 1021
894 int inlineCost(InlineCostState *ics); 1022 int inlineCost(InlineCostState *ics);
895 elem *toElem(IRState *irs); 1023 #if IN_DMD
1024 elem *toElem(IRState *irs);
1025 #endif
1026
1027 #if IN_LLVM
1028 DValue* toElem(IRState* irs);
1029 #endif
896 }; 1030 };
897 1031
898 struct DotTypeExp : UnaExp 1032 struct DotTypeExp : UnaExp
899 { 1033 {
900 Dsymbol *sym; // symbol that represents a type 1034 Dsymbol *sym; // symbol that represents a type
901 1035
902 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); 1036 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym);
903 Expression *semantic(Scope *sc); 1037 Expression *semantic(Scope *sc);
904 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1038 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
905 elem *toElem(IRState *irs); 1039 #if IN_DMD
1040 elem *toElem(IRState *irs);
1041 #endif
1042
1043 #if IN_LLVM
1044 DValue* toElem(IRState* irs);
1045 #endif
906 }; 1046 };
907 1047
908 struct CallExp : UnaExp 1048 struct CallExp : UnaExp
909 { 1049 {
910 Expressions *arguments; // function arguments 1050 Expressions *arguments; // function arguments
919 Expression *optimize(int result); 1059 Expression *optimize(int result);
920 Expression *interpret(InterState *istate); 1060 Expression *interpret(InterState *istate);
921 int checkSideEffect(int flag); 1061 int checkSideEffect(int flag);
922 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1062 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
923 void dump(int indent); 1063 void dump(int indent);
924 elem *toElem(IRState *irs); 1064 #if IN_DMD
1065 elem *toElem(IRState *irs);
1066 #endif
925 void scanForNestedRef(Scope *sc); 1067 void scanForNestedRef(Scope *sc);
926 int isLvalue(); 1068 int isLvalue();
927 Expression *toLvalue(Scope *sc, Expression *e); 1069 Expression *toLvalue(Scope *sc, Expression *e);
928 int canThrow(); 1070 int canThrow();
929 1071
930 int inlineCost(InlineCostState *ics); 1072 int inlineCost(InlineCostState *ics);
931 Expression *doInline(InlineDoState *ids); 1073 Expression *doInline(InlineDoState *ids);
932 Expression *inlineScan(InlineScanState *iss); 1074 Expression *inlineScan(InlineScanState *iss);
1075
1076 #if IN_LLVM
1077 DValue* toElem(IRState* irs);
1078 #endif
933 }; 1079 };
934 1080
935 struct AddrExp : UnaExp 1081 struct AddrExp : UnaExp
936 { 1082 {
1083 Module* m; // starting point for overload resolution
1084
937 AddrExp(Loc loc, Expression *e); 1085 AddrExp(Loc loc, Expression *e);
938 Expression *semantic(Scope *sc); 1086 Expression *semantic(Scope *sc);
939 elem *toElem(IRState *irs); 1087 #if IN_DMD
1088 elem *toElem(IRState *irs);
1089 #endif
940 MATCH implicitConvTo(Type *t); 1090 MATCH implicitConvTo(Type *t);
941 Expression *castTo(Scope *sc, Type *t); 1091 Expression *castTo(Scope *sc, Type *t);
942 Expression *optimize(int result); 1092 Expression *optimize(int result);
943 // LDC 1093
944 virtual llvm::Constant *toConstElem(IRState *irs); 1094 #if IN_LLVM
1095 DValue* toElem(IRState* irs);
1096 llvm::Constant *toConstElem(IRState *irs);
1097 #endif
945 }; 1098 };
946 1099
947 struct PtrExp : UnaExp 1100 struct PtrExp : UnaExp
948 { 1101 {
949 PtrExp(Loc loc, Expression *e); 1102 PtrExp(Loc loc, Expression *e);
951 Expression *semantic(Scope *sc); 1104 Expression *semantic(Scope *sc);
952 int isLvalue(); 1105 int isLvalue();
953 Expression *toLvalue(Scope *sc, Expression *e); 1106 Expression *toLvalue(Scope *sc, Expression *e);
954 Expression *modifiableLvalue(Scope *sc, Expression *e); 1107 Expression *modifiableLvalue(Scope *sc, Expression *e);
955 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1108 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
956 elem *toElem(IRState *irs); 1109 #if IN_DMD
957 Expression *optimize(int result); 1110 elem *toElem(IRState *irs);
958 Expression *interpret(InterState *istate); 1111 #endif
959 1112 Expression *optimize(int result);
960 // For operator overloading 1113 Expression *interpret(InterState *istate);
961 Identifier *opId(); 1114
1115 // For operator overloading
1116 Identifier *opId();
1117
1118 #if IN_LLVM
1119 DValue* toElem(IRState* irs);
1120 void cacheLvalue(IRState* irs);
1121 #endif
962 }; 1122 };
963 1123
964 struct NegExp : UnaExp 1124 struct NegExp : UnaExp
965 { 1125 {
966 NegExp(Loc loc, Expression *e); 1126 NegExp(Loc loc, Expression *e);
971 Expression *buildArrayLoop(Arguments *fparams); 1131 Expression *buildArrayLoop(Arguments *fparams);
972 1132
973 // For operator overloading 1133 // For operator overloading
974 Identifier *opId(); 1134 Identifier *opId();
975 1135
976 elem *toElem(IRState *irs); 1136 #if IN_DMD
1137 elem *toElem(IRState *irs);
1138 #endif
1139
1140 #if IN_LLVM
1141 DValue* toElem(IRState* irs);
1142 #endif
977 }; 1143 };
978 1144
979 struct UAddExp : UnaExp 1145 struct UAddExp : UnaExp
980 { 1146 {
981 UAddExp(Loc loc, Expression *e); 1147 UAddExp(Loc loc, Expression *e);
995 Expression *buildArrayLoop(Arguments *fparams); 1161 Expression *buildArrayLoop(Arguments *fparams);
996 1162
997 // For operator overloading 1163 // For operator overloading
998 Identifier *opId(); 1164 Identifier *opId();
999 1165
1000 elem *toElem(IRState *irs); 1166 #if IN_DMD
1167 elem *toElem(IRState *irs);
1168 #endif
1169
1170 #if IN_LLVM
1171 DValue* toElem(IRState* irs);
1172 #endif
1001 }; 1173 };
1002 1174
1003 struct NotExp : UnaExp 1175 struct NotExp : UnaExp
1004 { 1176 {
1005 NotExp(Loc loc, Expression *e); 1177 NotExp(Loc loc, Expression *e);
1006 Expression *semantic(Scope *sc); 1178 Expression *semantic(Scope *sc);
1007 Expression *optimize(int result); 1179 Expression *optimize(int result);
1008 Expression *interpret(InterState *istate); 1180 Expression *interpret(InterState *istate);
1009 int isBit(); 1181 int isBit();
1010 elem *toElem(IRState *irs); 1182 #if IN_DMD
1183 elem *toElem(IRState *irs);
1184 #endif
1185
1186 #if IN_LLVM
1187 DValue* toElem(IRState* irs);
1188 #endif
1011 }; 1189 };
1012 1190
1013 struct BoolExp : UnaExp 1191 struct BoolExp : UnaExp
1014 { 1192 {
1015 BoolExp(Loc loc, Expression *e, Type *type); 1193 BoolExp(Loc loc, Expression *e, Type *type);
1016 Expression *semantic(Scope *sc); 1194 Expression *semantic(Scope *sc);
1017 Expression *optimize(int result); 1195 Expression *optimize(int result);
1018 Expression *interpret(InterState *istate); 1196 Expression *interpret(InterState *istate);
1019 int isBit(); 1197 int isBit();
1020 elem *toElem(IRState *irs); 1198 #if IN_DMD
1199 elem *toElem(IRState *irs);
1200 #endif
1201
1202 #if IN_LLVM
1203 DValue* toElem(IRState* irs);
1204 #endif
1021 }; 1205 };
1022 1206
1023 struct DeleteExp : UnaExp 1207 struct DeleteExp : UnaExp
1024 { 1208 {
1025 DeleteExp(Loc loc, Expression *e); 1209 DeleteExp(Loc loc, Expression *e);
1026 Expression *semantic(Scope *sc); 1210 Expression *semantic(Scope *sc);
1027 Expression *checkToBoolean(); 1211 Expression *checkToBoolean();
1028 int checkSideEffect(int flag); 1212 int checkSideEffect(int flag);
1029 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1213 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1030 elem *toElem(IRState *irs); 1214 #if IN_DMD
1215 elem *toElem(IRState *irs);
1216 #endif
1217
1218 #if IN_LLVM
1219 DValue* toElem(IRState* irs);
1220 #endif
1031 }; 1221 };
1032 1222
1033 struct CastExp : UnaExp 1223 struct CastExp : UnaExp
1034 { 1224 {
1035 // Possible to cast to one type while painting to another type 1225 // Possible to cast to one type while painting to another type
1036 Type *to; // type to cast to 1226 Type *to; // type to cast to
1037 enum TOK tok; // TOKconst or TOKinvariant 1227 unsigned mod; // MODxxxxx
1038 1228
1039 CastExp(Loc loc, Expression *e, Type *t); 1229 CastExp(Loc loc, Expression *e, Type *t);
1040 CastExp(Loc loc, Expression *e, enum TOK tok); 1230 CastExp(Loc loc, Expression *e, unsigned mod);
1041 Expression *syntaxCopy(); 1231 Expression *syntaxCopy();
1042 Expression *semantic(Scope *sc); 1232 Expression *semantic(Scope *sc);
1043 Expression *optimize(int result); 1233 Expression *optimize(int result);
1044 Expression *interpret(InterState *istate); 1234 Expression *interpret(InterState *istate);
1045 int checkSideEffect(int flag); 1235 int checkSideEffect(int flag);
1046 void checkEscape(); 1236 void checkEscape();
1047 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1237 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1048 elem *toElem(IRState *irs); 1238 #if IN_DMD
1049 1239 elem *toElem(IRState *irs);
1050 // For operator overloading 1240 #endif
1051 Identifier *opId(); 1241
1052 1242 // For operator overloading
1053 // LDC 1243 Identifier *opId();
1054 virtual llvm::Constant *toConstElem(IRState *irs); 1244
1245 #if IN_LLVM
1246 DValue* toElem(IRState* irs);
1247 llvm::Constant *toConstElem(IRState *irs);
1248 #endif
1055 }; 1249 };
1056 1250
1057 1251
1058 struct SliceExp : UnaExp 1252 struct SliceExp : UnaExp
1059 { 1253 {
1070 Expression *modifiableLvalue(Scope *sc, Expression *e); 1264 Expression *modifiableLvalue(Scope *sc, Expression *e);
1071 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1265 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1072 Expression *optimize(int result); 1266 Expression *optimize(int result);
1073 Expression *interpret(InterState *istate); 1267 Expression *interpret(InterState *istate);
1074 void dump(int indent); 1268 void dump(int indent);
1075 elem *toElem(IRState *irs); 1269 #if IN_DMD
1270 elem *toElem(IRState *irs);
1271 #endif
1076 void scanForNestedRef(Scope *sc); 1272 void scanForNestedRef(Scope *sc);
1077 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 1273 void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
1078 Expression *buildArrayLoop(Arguments *fparams); 1274 Expression *buildArrayLoop(Arguments *fparams);
1079 1275
1080 int inlineCost(InlineCostState *ics); 1276 int inlineCost(InlineCostState *ics);
1081 Expression *doInline(InlineDoState *ids); 1277 Expression *doInline(InlineDoState *ids);
1082 Expression *inlineScan(InlineScanState *iss); 1278 Expression *inlineScan(InlineScanState *iss);
1083 1279
1084 // LDC 1280 #if IN_LLVM
1085 virtual llvm::Constant *toConstElem(IRState *irs); 1281 DValue* toElem(IRState* irs);
1282 llvm::Constant *toConstElem(IRState *irs);
1283 #endif
1086 }; 1284 };
1087 1285
1088 struct ArrayLengthExp : UnaExp 1286 struct ArrayLengthExp : UnaExp
1089 { 1287 {
1090 ArrayLengthExp(Loc loc, Expression *e1); 1288 ArrayLengthExp(Loc loc, Expression *e1);
1091 Expression *semantic(Scope *sc); 1289 Expression *semantic(Scope *sc);
1092 Expression *optimize(int result); 1290 Expression *optimize(int result);
1093 Expression *interpret(InterState *istate); 1291 Expression *interpret(InterState *istate);
1094 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1292 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1095 elem *toElem(IRState *irs); 1293 #if IN_DMD
1294 elem *toElem(IRState *irs);
1295 #endif
1296
1297 #if IN_LLVM
1298 DValue* toElem(IRState* irs);
1299 #endif
1096 }; 1300 };
1097 1301
1098 // e1[a0,a1,a2,a3,...] 1302 // e1[a0,a1,a2,a3,...]
1099 1303
1100 struct ArrayExp : UnaExp 1304 struct ArrayExp : UnaExp
1135 Expression *modifiableLvalue(Scope *sc, Expression *e); 1339 Expression *modifiableLvalue(Scope *sc, Expression *e);
1136 int isBool(int result); 1340 int isBool(int result);
1137 int checkSideEffect(int flag); 1341 int checkSideEffect(int flag);
1138 Expression *optimize(int result); 1342 Expression *optimize(int result);
1139 Expression *interpret(InterState *istate); 1343 Expression *interpret(InterState *istate);
1140 elem *toElem(IRState *irs); 1344 #if IN_DMD
1345 elem *toElem(IRState *irs);
1346 #endif
1347
1348 #if IN_LLVM
1349 DValue* toElem(IRState* irs);
1350 #endif
1141 }; 1351 };
1142 1352
1143 struct IndexExp : BinExp 1353 struct IndexExp : BinExp
1144 { 1354 {
1145 VarDeclaration *lengthVar; 1355 VarDeclaration *lengthVar;
1154 Expression *optimize(int result); 1364 Expression *optimize(int result);
1155 Expression *interpret(InterState *istate); 1365 Expression *interpret(InterState *istate);
1156 Expression *doInline(InlineDoState *ids); 1366 Expression *doInline(InlineDoState *ids);
1157 void scanForNestedRef(Scope *sc); 1367 void scanForNestedRef(Scope *sc);
1158 1368
1159 elem *toElem(IRState *irs); 1369 #if IN_DMD
1160 1370 elem *toElem(IRState *irs);
1161 // LDC 1371 #elif IN_LLVM
1162 virtual llvm::Constant *toConstElem(IRState *irs); 1372 DValue* toElem(IRState* irs);
1373 llvm::Constant *toConstElem(IRState *irs);
1374 void cacheLvalue(IRState* irs);
1375 #endif
1163 }; 1376 };
1164 1377
1165 /* For both i++ and i-- 1378 /* For both i++ and i--
1166 */ 1379 */
1167 struct PostExp : BinExp 1380 struct PostExp : BinExp
1169 PostExp(enum TOK op, Loc loc, Expression *e); 1382 PostExp(enum TOK op, Loc loc, Expression *e);
1170 Expression *semantic(Scope *sc); 1383 Expression *semantic(Scope *sc);
1171 Expression *interpret(InterState *istate); 1384 Expression *interpret(InterState *istate);
1172 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1385 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1173 Identifier *opId(); // For operator overloading 1386 Identifier *opId(); // For operator overloading
1174 elem *toElem(IRState *irs); 1387 #if IN_DMD
1388 elem *toElem(IRState *irs);
1389 #endif
1390
1391 #if IN_LLVM
1392 DValue* toElem(IRState* irs);
1393 #endif
1175 }; 1394 };
1176 1395
1177 struct AssignExp : BinExp 1396 struct AssignExp : BinExp
1178 { int ismemset; // !=0 if setting the contents of an array 1397 { int ismemset; // !=0 if setting the contents of an array
1179 1398
1182 Expression *checkToBoolean(); 1401 Expression *checkToBoolean();
1183 Expression *interpret(InterState *istate); 1402 Expression *interpret(InterState *istate);
1184 Identifier *opId(); // For operator overloading 1403 Identifier *opId(); // For operator overloading
1185 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 1404 void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
1186 Expression *buildArrayLoop(Arguments *fparams); 1405 Expression *buildArrayLoop(Arguments *fparams);
1187 elem *toElem(IRState *irs); 1406 #if IN_DMD
1188 }; 1407 elem *toElem(IRState *irs);
1408 #endif
1409
1410 #if IN_LLVM
1411 DValue* toElem(IRState* irs);
1412 #endif
1413 };
1414
1415 #if IN_DMD
1416 #define ASSIGNEXP_TOELEM elem *toElem(IRState *irs);
1417 #elif IN_LLVM
1418 #define ASSIGNEXP_TOELEM DValue* toElem(IRState *irs);
1419 #else
1420 #define ASSIGNEXP_TOELEM
1421 #endif
1189 1422
1190 #define ASSIGNEXP(op) \ 1423 #define ASSIGNEXP(op) \
1191 struct op##AssignExp : BinExp \ 1424 struct op##AssignExp : BinExp \
1192 { \ 1425 { \
1193 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ 1426 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \
1196 X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \ 1429 X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
1197 X(Expression *buildArrayLoop(Arguments *fparams);) \ 1430 X(Expression *buildArrayLoop(Arguments *fparams);) \
1198 \ 1431 \
1199 Identifier *opId(); /* For operator overloading */ \ 1432 Identifier *opId(); /* For operator overloading */ \
1200 \ 1433 \
1201 elem *toElem(IRState *irs); \ 1434 ASSIGNEXP_TOELEM \
1202 }; 1435 };
1203 1436
1204 #define X(a) a 1437 #define X(a) a
1205 ASSIGNEXP(Add) 1438 ASSIGNEXP(Add)
1206 ASSIGNEXP(Min) 1439 ASSIGNEXP(Min)
1219 ASSIGNEXP(Ushr) 1452 ASSIGNEXP(Ushr)
1220 ASSIGNEXP(Cat) 1453 ASSIGNEXP(Cat)
1221 1454
1222 #undef X 1455 #undef X
1223 #undef ASSIGNEXP 1456 #undef ASSIGNEXP
1457 #undef ASSIGNEXP_TOELEM
1224 1458
1225 struct AddExp : BinExp 1459 struct AddExp : BinExp
1226 { 1460 {
1227 AddExp(Loc loc, Expression *e1, Expression *e2); 1461 AddExp(Loc loc, Expression *e1, Expression *e2);
1228 Expression *semantic(Scope *sc); 1462 Expression *semantic(Scope *sc);
1234 // For operator overloading 1468 // For operator overloading
1235 int isCommutative(); 1469 int isCommutative();
1236 Identifier *opId(); 1470 Identifier *opId();
1237 Identifier *opId_r(); 1471 Identifier *opId_r();
1238 1472
1239 elem *toElem(IRState *irs); 1473 #if IN_DMD
1474 elem *toElem(IRState *irs);
1475 #endif
1476
1477 #if IN_LLVM
1478 DValue* toElem(IRState* irs);
1479 #endif
1240 }; 1480 };
1241 1481
1242 struct MinExp : BinExp 1482 struct MinExp : BinExp
1243 { 1483 {
1244 MinExp(Loc loc, Expression *e1, Expression *e2); 1484 MinExp(Loc loc, Expression *e1, Expression *e2);
1250 1490
1251 // For operator overloading 1491 // For operator overloading
1252 Identifier *opId(); 1492 Identifier *opId();
1253 Identifier *opId_r(); 1493 Identifier *opId_r();
1254 1494
1255 elem *toElem(IRState *irs); 1495 #if IN_DMD
1496 elem *toElem(IRState *irs);
1497 #endif
1498
1499 #if IN_LLVM
1500 DValue* toElem(IRState* irs);
1501 #endif
1256 }; 1502 };
1257 1503
1258 struct CatExp : BinExp 1504 struct CatExp : BinExp
1259 { 1505 {
1260 CatExp(Loc loc, Expression *e1, Expression *e2); 1506 CatExp(Loc loc, Expression *e1, Expression *e2);
1264 1510
1265 // For operator overloading 1511 // For operator overloading
1266 Identifier *opId(); 1512 Identifier *opId();
1267 Identifier *opId_r(); 1513 Identifier *opId_r();
1268 1514
1269 elem *toElem(IRState *irs); 1515 #if IN_DMD
1516 elem *toElem(IRState *irs);
1517 #endif
1518
1519 #if IN_LLVM
1520 DValue* toElem(IRState* irs);
1521 #endif
1270 }; 1522 };
1271 1523
1272 struct MulExp : BinExp 1524 struct MulExp : BinExp
1273 { 1525 {
1274 MulExp(Loc loc, Expression *e1, Expression *e2); 1526 MulExp(Loc loc, Expression *e1, Expression *e2);
1281 // For operator overloading 1533 // For operator overloading
1282 int isCommutative(); 1534 int isCommutative();
1283 Identifier *opId(); 1535 Identifier *opId();
1284 Identifier *opId_r(); 1536 Identifier *opId_r();
1285 1537
1286 elem *toElem(IRState *irs); 1538 #if IN_DMD
1539 elem *toElem(IRState *irs);
1540 #endif
1541
1542 #if IN_LLVM
1543 DValue* toElem(IRState* irs);
1544 #endif
1287 }; 1545 };
1288 1546
1289 struct DivExp : BinExp 1547 struct DivExp : BinExp
1290 { 1548 {
1291 DivExp(Loc loc, Expression *e1, Expression *e2); 1549 DivExp(Loc loc, Expression *e1, Expression *e2);
1297 1555
1298 // For operator overloading 1556 // For operator overloading
1299 Identifier *opId(); 1557 Identifier *opId();
1300 Identifier *opId_r(); 1558 Identifier *opId_r();
1301 1559
1302 elem *toElem(IRState *irs); 1560 #if IN_DMD
1561 elem *toElem(IRState *irs);
1562 #endif
1563
1564 #if IN_LLVM
1565 DValue* toElem(IRState* irs);
1566 #endif
1303 }; 1567 };
1304 1568
1305 struct ModExp : BinExp 1569 struct ModExp : BinExp
1306 { 1570 {
1307 ModExp(Loc loc, Expression *e1, Expression *e2); 1571 ModExp(Loc loc, Expression *e1, Expression *e2);
1313 1577
1314 // For operator overloading 1578 // For operator overloading
1315 Identifier *opId(); 1579 Identifier *opId();
1316 Identifier *opId_r(); 1580 Identifier *opId_r();
1317 1581
1318 elem *toElem(IRState *irs); 1582 #if IN_DMD
1583 elem *toElem(IRState *irs);
1584 #endif
1585
1586 #if IN_LLVM
1587 DValue* toElem(IRState* irs);
1588 #endif
1319 }; 1589 };
1320 1590
1321 struct ShlExp : BinExp 1591 struct ShlExp : BinExp
1322 { 1592 {
1323 ShlExp(Loc loc, Expression *e1, Expression *e2); 1593 ShlExp(Loc loc, Expression *e1, Expression *e2);
1327 1597
1328 // For operator overloading 1598 // For operator overloading
1329 Identifier *opId(); 1599 Identifier *opId();
1330 Identifier *opId_r(); 1600 Identifier *opId_r();
1331 1601
1332 elem *toElem(IRState *irs); 1602 #if IN_DMD
1603 elem *toElem(IRState *irs);
1604 #endif
1605
1606 #if IN_LLVM
1607 DValue* toElem(IRState* irs);
1608 #endif
1333 }; 1609 };
1334 1610
1335 struct ShrExp : BinExp 1611 struct ShrExp : BinExp
1336 { 1612 {
1337 ShrExp(Loc loc, Expression *e1, Expression *e2); 1613 ShrExp(Loc loc, Expression *e1, Expression *e2);
1341 1617
1342 // For operator overloading 1618 // For operator overloading
1343 Identifier *opId(); 1619 Identifier *opId();
1344 Identifier *opId_r(); 1620 Identifier *opId_r();
1345 1621
1346 elem *toElem(IRState *irs); 1622 #if IN_DMD
1623 elem *toElem(IRState *irs);
1624 #endif
1625
1626 #if IN_LLVM
1627 DValue* toElem(IRState* irs);
1628 #endif
1347 }; 1629 };
1348 1630
1349 struct UshrExp : BinExp 1631 struct UshrExp : BinExp
1350 { 1632 {
1351 UshrExp(Loc loc, Expression *e1, Expression *e2); 1633 UshrExp(Loc loc, Expression *e1, Expression *e2);
1355 1637
1356 // For operator overloading 1638 // For operator overloading
1357 Identifier *opId(); 1639 Identifier *opId();
1358 Identifier *opId_r(); 1640 Identifier *opId_r();
1359 1641
1360 elem *toElem(IRState *irs); 1642 #if IN_DMD
1643 elem *toElem(IRState *irs);
1644 #endif
1645
1646 #if IN_LLVM
1647 DValue* toElem(IRState* irs);
1648 #endif
1361 }; 1649 };
1362 1650
1363 struct AndExp : BinExp 1651 struct AndExp : BinExp
1364 { 1652 {
1365 AndExp(Loc loc, Expression *e1, Expression *e2); 1653 AndExp(Loc loc, Expression *e1, Expression *e2);
1372 // For operator overloading 1660 // For operator overloading
1373 int isCommutative(); 1661 int isCommutative();
1374 Identifier *opId(); 1662 Identifier *opId();
1375 Identifier *opId_r(); 1663 Identifier *opId_r();
1376 1664
1377 elem *toElem(IRState *irs); 1665 #if IN_DMD
1666 elem *toElem(IRState *irs);
1667 #endif
1668
1669 #if IN_LLVM
1670 DValue* toElem(IRState* irs);
1671 #endif
1378 }; 1672 };
1379 1673
1380 struct OrExp : BinExp 1674 struct OrExp : BinExp
1381 { 1675 {
1382 OrExp(Loc loc, Expression *e1, Expression *e2); 1676 OrExp(Loc loc, Expression *e1, Expression *e2);
1389 // For operator overloading 1683 // For operator overloading
1390 int isCommutative(); 1684 int isCommutative();
1391 Identifier *opId(); 1685 Identifier *opId();
1392 Identifier *opId_r(); 1686 Identifier *opId_r();
1393 1687
1394 elem *toElem(IRState *irs); 1688 #if IN_DMD
1689 elem *toElem(IRState *irs);
1690 #endif
1691
1692 #if IN_LLVM
1693 DValue* toElem(IRState* irs);
1694 #endif
1395 }; 1695 };
1396 1696
1397 struct XorExp : BinExp 1697 struct XorExp : BinExp
1398 { 1698 {
1399 XorExp(Loc loc, Expression *e1, Expression *e2); 1699 XorExp(Loc loc, Expression *e1, Expression *e2);
1406 // For operator overloading 1706 // For operator overloading
1407 int isCommutative(); 1707 int isCommutative();
1408 Identifier *opId(); 1708 Identifier *opId();
1409 Identifier *opId_r(); 1709 Identifier *opId_r();
1410 1710
1411 elem *toElem(IRState *irs); 1711 #if IN_DMD
1712 elem *toElem(IRState *irs);
1713 #endif
1714
1715 #if IN_LLVM
1716 DValue* toElem(IRState* irs);
1717 #endif
1412 }; 1718 };
1413 1719
1414 struct OrOrExp : BinExp 1720 struct OrOrExp : BinExp
1415 { 1721 {
1416 OrOrExp(Loc loc, Expression *e1, Expression *e2); 1722 OrOrExp(Loc loc, Expression *e1, Expression *e2);
1418 Expression *checkToBoolean(); 1724 Expression *checkToBoolean();
1419 int isBit(); 1725 int isBit();
1420 Expression *optimize(int result); 1726 Expression *optimize(int result);
1421 Expression *interpret(InterState *istate); 1727 Expression *interpret(InterState *istate);
1422 int checkSideEffect(int flag); 1728 int checkSideEffect(int flag);
1423 elem *toElem(IRState *irs); 1729 #if IN_DMD
1730 elem *toElem(IRState *irs);
1731 #endif
1732
1733 #if IN_LLVM
1734 DValue* toElem(IRState* irs);
1735 #endif
1424 }; 1736 };
1425 1737
1426 struct AndAndExp : BinExp 1738 struct AndAndExp : BinExp
1427 { 1739 {
1428 AndAndExp(Loc loc, Expression *e1, Expression *e2); 1740 AndAndExp(Loc loc, Expression *e1, Expression *e2);
1430 Expression *checkToBoolean(); 1742 Expression *checkToBoolean();
1431 int isBit(); 1743 int isBit();
1432 Expression *optimize(int result); 1744 Expression *optimize(int result);
1433 Expression *interpret(InterState *istate); 1745 Expression *interpret(InterState *istate);
1434 int checkSideEffect(int flag); 1746 int checkSideEffect(int flag);
1435 elem *toElem(IRState *irs); 1747 #if IN_DMD
1748 elem *toElem(IRState *irs);
1749 #endif
1750
1751 #if IN_LLVM
1752 DValue* toElem(IRState* irs);
1753 #endif
1436 }; 1754 };
1437 1755
1438 struct CmpExp : BinExp 1756 struct CmpExp : BinExp
1439 { 1757 {
1440 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); 1758 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
1445 1763
1446 // For operator overloading 1764 // For operator overloading
1447 int isCommutative(); 1765 int isCommutative();
1448 Identifier *opId(); 1766 Identifier *opId();
1449 1767
1450 elem *toElem(IRState *irs); 1768 #if IN_DMD
1769 elem *toElem(IRState *irs);
1770 #endif
1771
1772 #if IN_LLVM
1773 DValue* toElem(IRState* irs);
1774 #endif
1451 }; 1775 };
1452 1776
1453 struct InExp : BinExp 1777 struct InExp : BinExp
1454 { 1778 {
1455 InExp(Loc loc, Expression *e1, Expression *e2); 1779 InExp(Loc loc, Expression *e1, Expression *e2);
1458 1782
1459 // For operator overloading 1783 // For operator overloading
1460 Identifier *opId(); 1784 Identifier *opId();
1461 Identifier *opId_r(); 1785 Identifier *opId_r();
1462 1786
1463 elem *toElem(IRState *irs); 1787 #if IN_DMD
1788 elem *toElem(IRState *irs);
1789 #endif
1790
1791 #if IN_LLVM
1792 DValue* toElem(IRState* irs);
1793 #endif
1464 }; 1794 };
1465 1795
1466 struct RemoveExp : BinExp 1796 struct RemoveExp : BinExp
1467 { 1797 {
1468 RemoveExp(Loc loc, Expression *e1, Expression *e2); 1798 RemoveExp(Loc loc, Expression *e1, Expression *e2);
1469 elem *toElem(IRState *irs); 1799 #if IN_DMD
1800 elem *toElem(IRState *irs);
1801 #endif
1802
1803 #if IN_LLVM
1804 DValue* toElem(IRState* irs);
1805 #endif
1470 }; 1806 };
1471 1807
1472 // == and != 1808 // == and !=
1473 1809
1474 struct EqualExp : BinExp 1810 struct EqualExp : BinExp
1481 1817
1482 // For operator overloading 1818 // For operator overloading
1483 int isCommutative(); 1819 int isCommutative();
1484 Identifier *opId(); 1820 Identifier *opId();
1485 1821
1486 elem *toElem(IRState *irs); 1822 #if IN_DMD
1823 elem *toElem(IRState *irs);
1824 #endif
1825
1826 #if IN_LLVM
1827 DValue* toElem(IRState* irs);
1828 #endif
1487 }; 1829 };
1488 1830
1489 // === and !=== 1831 // === and !===
1490 1832
1491 struct IdentityExp : BinExp 1833 struct IdentityExp : BinExp
1493 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); 1835 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
1494 Expression *semantic(Scope *sc); 1836 Expression *semantic(Scope *sc);
1495 int isBit(); 1837 int isBit();
1496 Expression *optimize(int result); 1838 Expression *optimize(int result);
1497 Expression *interpret(InterState *istate); 1839 Expression *interpret(InterState *istate);
1498 elem *toElem(IRState *irs); 1840 #if IN_DMD
1841 elem *toElem(IRState *irs);
1842 #endif
1843
1844 #if IN_LLVM
1845 DValue* toElem(IRState* irs);
1846 #endif
1499 }; 1847 };
1500 1848
1501 /****************************************************************/ 1849 /****************************************************************/
1502 1850
1503 struct CondExp : BinExp 1851 struct CondExp : BinExp
1523 1871
1524 int inlineCost(InlineCostState *ics); 1872 int inlineCost(InlineCostState *ics);
1525 Expression *doInline(InlineDoState *ids); 1873 Expression *doInline(InlineDoState *ids);
1526 Expression *inlineScan(InlineScanState *iss); 1874 Expression *inlineScan(InlineScanState *iss);
1527 1875
1528 elem *toElem(IRState *irs); 1876 #if IN_DMD
1877 elem *toElem(IRState *irs);
1878 #endif
1879
1880 #if IN_LLVM
1881 DValue* toElem(IRState* irs);
1882 #endif
1529 }; 1883 };
1530 1884
1531 #if DMDV2 1885 #if DMDV2
1532 /****************************************************************/ 1886 /****************************************************************/
1533 1887
1568 1922
1569 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx); 1923 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx);
1570 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 1924 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
1571 Expression *toLvalue(Scope *sc, Expression *e); 1925 Expression *toLvalue(Scope *sc, Expression *e);
1572 1926
1573 elem *toElem(IRState *irs); 1927 DValue* toElem(IRState* irs);
1574 llvm::Constant *toConstElem(IRState *irs); 1928 llvm::Constant *toConstElem(IRState *irs);
1575 }; 1929 };
1576 1930
1577 #endif 1931 #endif
1578 1932