Mercurial > projects > ldc
comparison dmd/expression.h @ 1151:3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
- Eliminated the DLRValue DValue.
- Implemented proactive handling of l-value CastExpS.
- Minor tweak in runtime memory.d .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 05:00:43 +0100 |
parents | 1860414bf3b7 |
children | 521dd1626d76 |
comparison
equal
deleted
inserted
replaced
1150:2a687353c84d | 1151:3cf0066e6faf |
---|---|
44 struct InterState; | 44 struct InterState; |
45 struct OverloadSet; | 45 struct OverloadSet; |
46 | 46 |
47 enum TOK; | 47 enum TOK; |
48 | 48 |
49 #if IN_DMD | |
49 // Back end | 50 // Back end |
50 struct IRState; | 51 struct IRState; |
51 | 52 |
52 #if IN_DMD | |
53 struct dt_t; | 53 struct dt_t; |
54 struct elem; | 54 struct elem; |
55 struct Symbol; // back end symbol | 55 struct Symbol; // back end symbol |
56 #endif | 56 #endif |
57 | 57 |
58 #ifdef IN_GCC | 58 #ifdef IN_GCC |
59 union tree_node; typedef union tree_node elem; | 59 union tree_node; typedef union tree_node elem; |
60 #endif | 60 #endif |
61 | 61 |
62 #if IN_LLVM | 62 #if IN_LLVM |
63 struct IRState; | |
63 struct DValue; | 64 struct DValue; |
64 typedef DValue elem; | 65 namespace llvm { |
65 | |
66 namespace llvm | |
67 { | |
68 class Constant; | 66 class Constant; |
69 class ConstantInt; | 67 class ConstantInt; |
70 } | 68 } |
71 #endif | 69 #endif |
72 | 70 |
158 | 156 |
159 // For array ops | 157 // For array ops |
160 virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments); | 158 virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
161 virtual Expression *buildArrayLoop(Arguments *fparams); | 159 virtual Expression *buildArrayLoop(Arguments *fparams); |
162 | 160 |
161 #if IN_DMD | |
163 // Back end | 162 // Back end |
164 virtual elem *toElem(IRState *irs); | 163 virtual elem *toElem(IRState *irs); |
165 #if IN_DMD | |
166 virtual dt_t **toDt(dt_t **pdt); | 164 virtual dt_t **toDt(dt_t **pdt); |
167 #elif IN_LLVM | 165 #endif |
168 // LDC | 166 |
167 #if IN_LLVM | |
168 virtual DValue* toElem(IRState* irs); | |
169 virtual llvm::Constant *toConstElem(IRState *irs); | 169 virtual llvm::Constant *toConstElem(IRState *irs); |
170 virtual void cacheLvalue(IRState* irs); | |
171 | |
172 llvm::Value* cachedLvalue; | |
170 #endif | 173 #endif |
171 }; | 174 }; |
172 | 175 |
173 struct IntegerExp : Expression | 176 struct IntegerExp : Expression |
174 { | 177 { |
189 int isBool(int result); | 192 int isBool(int result); |
190 MATCH implicitConvTo(Type *t); | 193 MATCH implicitConvTo(Type *t); |
191 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 194 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
192 void toMangleBuffer(OutBuffer *buf); | 195 void toMangleBuffer(OutBuffer *buf); |
193 Expression *toLvalue(Scope *sc, Expression *e); | 196 Expression *toLvalue(Scope *sc, Expression *e); |
194 elem *toElem(IRState *irs); | 197 #if IN_DMD |
195 #if IN_DMD | 198 elem *toElem(IRState *irs); |
196 dt_t **toDt(dt_t **pdt); | 199 dt_t **toDt(dt_t **pdt); |
197 #elif IN_LLVM | 200 #elif IN_LLVM |
198 // LDC | 201 DValue* toElem(IRState* irs); |
199 virtual llvm::Constant *toConstElem(IRState *irs); | 202 llvm::Constant *toConstElem(IRState *irs); |
200 #endif | 203 #endif |
201 }; | 204 }; |
202 | 205 |
203 struct RealExp : Expression | 206 struct RealExp : Expression |
204 { | 207 { |
217 Expression *castTo(Scope *sc, Type *t); | 220 Expression *castTo(Scope *sc, Type *t); |
218 int isConst(); | 221 int isConst(); |
219 int isBool(int result); | 222 int isBool(int result); |
220 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 223 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
221 void toMangleBuffer(OutBuffer *buf); | 224 void toMangleBuffer(OutBuffer *buf); |
222 elem *toElem(IRState *irs); | 225 #if IN_DMD |
223 #if IN_DMD | 226 elem *toElem(IRState *irs); |
224 dt_t **toDt(dt_t **pdt); | 227 dt_t **toDt(dt_t **pdt); |
225 #elif IN_LLVM | 228 #elif IN_LLVM |
226 // LDC | 229 DValue* toElem(IRState* irs); |
227 virtual llvm::Constant *toConstElem(IRState *irs); | 230 llvm::Constant *toConstElem(IRState *irs); |
228 #endif | 231 #endif |
229 }; | 232 }; |
230 | 233 |
231 struct ComplexExp : Expression | 234 struct ComplexExp : Expression |
232 { | 235 { |
248 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 251 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
249 void toMangleBuffer(OutBuffer *buf); | 252 void toMangleBuffer(OutBuffer *buf); |
250 #ifdef _DH | 253 #ifdef _DH |
251 OutBuffer hexp; | 254 OutBuffer hexp; |
252 #endif | 255 #endif |
253 elem *toElem(IRState *irs); | 256 #if IN_DMD |
254 #if IN_DMD | 257 elem *toElem(IRState *irs); |
255 dt_t **toDt(dt_t **pdt); | 258 dt_t **toDt(dt_t **pdt); |
256 #elif IN_LLVM | 259 #elif IN_LLVM |
257 // LDC | 260 DValue* toElem(IRState* irs); |
258 virtual llvm::Constant *toConstElem(IRState *irs); | 261 llvm::Constant *toConstElem(IRState *irs); |
259 #endif | 262 #endif |
260 }; | 263 }; |
261 | 264 |
262 struct IdentifierExp : Expression | 265 struct IdentifierExp : Expression |
263 { | 266 { |
303 | 306 |
304 int inlineCost(InlineCostState *ics); | 307 int inlineCost(InlineCostState *ics); |
305 Expression *doInline(InlineDoState *ids); | 308 Expression *doInline(InlineDoState *ids); |
306 //Expression *inlineScan(InlineScanState *iss); | 309 //Expression *inlineScan(InlineScanState *iss); |
307 | 310 |
308 elem *toElem(IRState *irs); | 311 #if IN_DMD |
312 elem *toElem(IRState *irs); | |
313 #endif | |
314 | |
315 #if IN_LLVM | |
316 DValue* toElem(IRState* irs); | |
317 #endif | |
309 }; | 318 }; |
310 | 319 |
311 struct SuperExp : ThisExp | 320 struct SuperExp : ThisExp |
312 { | 321 { |
313 SuperExp(Loc loc); | 322 SuperExp(Loc loc); |
330 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 339 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
331 void toMangleBuffer(OutBuffer *buf); | 340 void toMangleBuffer(OutBuffer *buf); |
332 MATCH implicitConvTo(Type *t); | 341 MATCH implicitConvTo(Type *t); |
333 Expression *castTo(Scope *sc, Type *t); | 342 Expression *castTo(Scope *sc, Type *t); |
334 Expression *interpret(InterState *istate); | 343 Expression *interpret(InterState *istate); |
335 elem *toElem(IRState *irs); | 344 #if IN_DMD |
336 #if IN_DMD | 345 elem *toElem(IRState *irs); |
337 dt_t **toDt(dt_t **pdt); | 346 dt_t **toDt(dt_t **pdt); |
338 #elif IN_LLVM | 347 #elif IN_LLVM |
339 // LDC | 348 DValue* toElem(IRState* irs); |
340 virtual llvm::Constant *toConstElem(IRState *irs); | 349 llvm::Constant *toConstElem(IRState *irs); |
341 #endif | 350 #endif |
342 }; | 351 }; |
343 | 352 |
344 struct StringExp : Expression | 353 struct StringExp : Expression |
345 { | 354 { |
363 int compare(Object *obj); | 372 int compare(Object *obj); |
364 int isBool(int result); | 373 int isBool(int result); |
365 unsigned charAt(size_t i); | 374 unsigned charAt(size_t i); |
366 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 375 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
367 void toMangleBuffer(OutBuffer *buf); | 376 void toMangleBuffer(OutBuffer *buf); |
368 elem *toElem(IRState *irs); | 377 #if IN_DMD |
369 #if IN_DMD | 378 elem *toElem(IRState *irs); |
370 dt_t **toDt(dt_t **pdt); | 379 dt_t **toDt(dt_t **pdt); |
371 #elif IN_LLVM | 380 #elif IN_LLVM |
372 // LDC | 381 DValue* toElem(IRState* irs); |
373 virtual llvm::Constant *toConstElem(IRState *irs); | 382 llvm::Constant *toConstElem(IRState *irs); |
374 #endif | 383 #endif |
375 }; | 384 }; |
376 | 385 |
377 // Tuple | 386 // Tuple |
378 | 387 |
390 void checkEscape(); | 399 void checkEscape(); |
391 int checkSideEffect(int flag); | 400 int checkSideEffect(int flag); |
392 Expression *optimize(int result); | 401 Expression *optimize(int result); |
393 Expression *interpret(InterState *istate); | 402 Expression *interpret(InterState *istate); |
394 Expression *castTo(Scope *sc, Type *t); | 403 Expression *castTo(Scope *sc, Type *t); |
395 elem *toElem(IRState *irs); | 404 #if IN_DMD |
405 elem *toElem(IRState *irs); | |
406 #endif | |
396 | 407 |
397 int inlineCost(InlineCostState *ics); | 408 int inlineCost(InlineCostState *ics); |
398 Expression *doInline(InlineDoState *ids); | 409 Expression *doInline(InlineDoState *ids); |
399 Expression *inlineScan(InlineScanState *iss); | 410 Expression *inlineScan(InlineScanState *iss); |
411 | |
412 #if IN_LLVM | |
413 DValue* toElem(IRState* irs); | |
414 #endif | |
400 }; | 415 }; |
401 | 416 |
402 struct ArrayLiteralExp : Expression | 417 struct ArrayLiteralExp : Expression |
403 { | 418 { |
404 Expressions *elements; | 419 Expressions *elements; |
407 ArrayLiteralExp(Loc loc, Expression *e); | 422 ArrayLiteralExp(Loc loc, Expression *e); |
408 | 423 |
409 Expression *syntaxCopy(); | 424 Expression *syntaxCopy(); |
410 Expression *semantic(Scope *sc); | 425 Expression *semantic(Scope *sc); |
411 int isBool(int result); | 426 int isBool(int result); |
412 elem *toElem(IRState *irs); | |
413 int checkSideEffect(int flag); | 427 int checkSideEffect(int flag); |
414 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 428 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
415 void toMangleBuffer(OutBuffer *buf); | 429 void toMangleBuffer(OutBuffer *buf); |
416 void scanForNestedRef(Scope *sc); | 430 void scanForNestedRef(Scope *sc); |
417 Expression *optimize(int result); | 431 Expression *optimize(int result); |
418 Expression *interpret(InterState *istate); | 432 Expression *interpret(InterState *istate); |
419 MATCH implicitConvTo(Type *t); | 433 MATCH implicitConvTo(Type *t); |
420 Expression *castTo(Scope *sc, Type *t); | 434 Expression *castTo(Scope *sc, Type *t); |
421 #if IN_DMD | |
422 dt_t **toDt(dt_t **pdt); | |
423 #elif IN_LLVM | |
424 // LDC | |
425 virtual llvm::Constant *toConstElem(IRState *irs); | |
426 #endif | |
427 | 435 |
428 int inlineCost(InlineCostState *ics); | 436 int inlineCost(InlineCostState *ics); |
429 Expression *doInline(InlineDoState *ids); | 437 Expression *doInline(InlineDoState *ids); |
430 Expression *inlineScan(InlineScanState *iss); | 438 Expression *inlineScan(InlineScanState *iss); |
439 | |
440 #if IN_DMD | |
441 elem *toElem(IRState *irs); | |
442 dt_t **toDt(dt_t **pdt); | |
443 #elif IN_LLVM | |
444 DValue* toElem(IRState* irs); | |
445 llvm::Constant *toConstElem(IRState *irs); | |
446 #endif | |
431 }; | 447 }; |
432 | 448 |
433 struct AssocArrayLiteralExp : Expression | 449 struct AssocArrayLiteralExp : Expression |
434 { | 450 { |
435 Expressions *keys; | 451 Expressions *keys; |
438 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); | 454 AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); |
439 | 455 |
440 Expression *syntaxCopy(); | 456 Expression *syntaxCopy(); |
441 Expression *semantic(Scope *sc); | 457 Expression *semantic(Scope *sc); |
442 int isBool(int result); | 458 int isBool(int result); |
443 elem *toElem(IRState *irs); | 459 #if IN_DMD |
460 elem *toElem(IRState *irs); | |
461 #endif | |
444 int checkSideEffect(int flag); | 462 int checkSideEffect(int flag); |
445 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 463 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
446 void toMangleBuffer(OutBuffer *buf); | 464 void toMangleBuffer(OutBuffer *buf); |
447 void scanForNestedRef(Scope *sc); | 465 void scanForNestedRef(Scope *sc); |
448 Expression *optimize(int result); | 466 Expression *optimize(int result); |
451 Expression *castTo(Scope *sc, Type *t); | 469 Expression *castTo(Scope *sc, Type *t); |
452 | 470 |
453 int inlineCost(InlineCostState *ics); | 471 int inlineCost(InlineCostState *ics); |
454 Expression *doInline(InlineDoState *ids); | 472 Expression *doInline(InlineDoState *ids); |
455 Expression *inlineScan(InlineScanState *iss); | 473 Expression *inlineScan(InlineScanState *iss); |
456 #if IN_LLVM | 474 |
457 // LDC | 475 #if IN_LLVM |
458 virtual llvm::Constant *toConstElem(IRState *irs); | 476 DValue* toElem(IRState* irs); |
477 llvm::Constant *toConstElem(IRState *irs); | |
459 #endif | 478 #endif |
460 }; | 479 }; |
461 | 480 |
462 struct StructLiteralExp : Expression | 481 struct StructLiteralExp : Expression |
463 { | 482 { |
475 | 494 |
476 Expression *syntaxCopy(); | 495 Expression *syntaxCopy(); |
477 Expression *semantic(Scope *sc); | 496 Expression *semantic(Scope *sc); |
478 Expression *getField(Type *type, unsigned offset); | 497 Expression *getField(Type *type, unsigned offset); |
479 int getFieldIndex(Type *type, unsigned offset); | 498 int getFieldIndex(Type *type, unsigned offset); |
480 elem *toElem(IRState *irs); | |
481 int checkSideEffect(int flag); | 499 int checkSideEffect(int flag); |
482 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 500 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
483 void toMangleBuffer(OutBuffer *buf); | 501 void toMangleBuffer(OutBuffer *buf); |
484 void scanForNestedRef(Scope *sc); | 502 void scanForNestedRef(Scope *sc); |
485 Expression *optimize(int result); | 503 Expression *optimize(int result); |
486 Expression *interpret(InterState *istate); | 504 Expression *interpret(InterState *istate); |
487 #if IN_DMD | |
488 dt_t **toDt(dt_t **pdt); | |
489 #elif IN_LLVM | |
490 // LDC | |
491 virtual llvm::Constant *toConstElem(IRState *irs); | |
492 #endif | |
493 Expression *toLvalue(Scope *sc, Expression *e); | 505 Expression *toLvalue(Scope *sc, Expression *e); |
494 | 506 |
495 int inlineCost(InlineCostState *ics); | 507 int inlineCost(InlineCostState *ics); |
496 Expression *doInline(InlineDoState *ids); | 508 Expression *doInline(InlineDoState *ids); |
497 Expression *inlineScan(InlineScanState *iss); | 509 Expression *inlineScan(InlineScanState *iss); |
498 | 510 |
511 #if IN_DMD | |
512 elem *toElem(IRState *irs); | |
513 dt_t **toDt(dt_t **pdt); | |
514 #elif IN_LLVM | |
515 DValue* toElem(IRState* irs); | |
516 llvm::Constant *toConstElem(IRState *irs); | |
517 #endif | |
499 }; | 518 }; |
500 | 519 |
501 struct TypeDotIdExp : Expression | 520 struct TypeDotIdExp : Expression |
502 { | 521 { |
503 Identifier *ident; | 522 Identifier *ident; |
504 | 523 |
505 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); | 524 TypeDotIdExp(Loc loc, Type *type, Identifier *ident); |
506 Expression *syntaxCopy(); | 525 Expression *syntaxCopy(); |
507 Expression *semantic(Scope *sc); | 526 Expression *semantic(Scope *sc); |
508 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 527 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
509 elem *toElem(IRState *irs); | 528 #if IN_DMD |
529 elem *toElem(IRState *irs); | |
530 #endif | |
531 | |
532 #if IN_LLVM | |
533 DValue* toElem(IRState* irs); | |
534 #endif | |
510 }; | 535 }; |
511 | 536 |
512 struct TypeExp : Expression | 537 struct TypeExp : Expression |
513 { | 538 { |
514 TypeExp(Loc loc, Type *type); | 539 TypeExp(Loc loc, Type *type); |
515 Expression *syntaxCopy(); | 540 Expression *syntaxCopy(); |
516 Expression *semantic(Scope *sc); | 541 Expression *semantic(Scope *sc); |
517 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 542 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
518 Expression *optimize(int result); | 543 Expression *optimize(int result); |
519 elem *toElem(IRState *irs); | 544 #if IN_DMD |
545 elem *toElem(IRState *irs); | |
546 #endif | |
547 | |
548 #if IN_LLVM | |
549 DValue* toElem(IRState* irs); | |
550 #endif | |
520 }; | 551 }; |
521 | 552 |
522 struct ScopeExp : Expression | 553 struct ScopeExp : Expression |
523 { | 554 { |
524 ScopeDsymbol *sds; | 555 ScopeDsymbol *sds; |
525 | 556 |
526 ScopeExp(Loc loc, ScopeDsymbol *sds); | 557 ScopeExp(Loc loc, ScopeDsymbol *sds); |
527 Expression *syntaxCopy(); | 558 Expression *syntaxCopy(); |
528 Expression *semantic(Scope *sc); | 559 Expression *semantic(Scope *sc); |
529 elem *toElem(IRState *irs); | 560 #if IN_DMD |
530 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 561 elem *toElem(IRState *irs); |
562 #endif | |
563 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
564 | |
565 #if IN_LLVM | |
566 DValue* toElem(IRState* irs); | |
567 #endif | |
531 }; | 568 }; |
532 | 569 |
533 struct TemplateExp : Expression | 570 struct TemplateExp : Expression |
534 { | 571 { |
535 TemplateDeclaration *td; | 572 TemplateDeclaration *td; |
554 | 591 |
555 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, | 592 NewExp(Loc loc, Expression *thisexp, Expressions *newargs, |
556 Type *newtype, Expressions *arguments); | 593 Type *newtype, Expressions *arguments); |
557 Expression *syntaxCopy(); | 594 Expression *syntaxCopy(); |
558 Expression *semantic(Scope *sc); | 595 Expression *semantic(Scope *sc); |
559 elem *toElem(IRState *irs); | 596 #if IN_DMD |
597 elem *toElem(IRState *irs); | |
598 #endif | |
560 int checkSideEffect(int flag); | 599 int checkSideEffect(int flag); |
561 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 600 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
562 void scanForNestedRef(Scope *sc); | 601 void scanForNestedRef(Scope *sc); |
563 | 602 |
564 //int inlineCost(InlineCostState *ics); | 603 //int inlineCost(InlineCostState *ics); |
565 Expression *doInline(InlineDoState *ids); | 604 Expression *doInline(InlineDoState *ids); |
566 //Expression *inlineScan(InlineScanState *iss); | 605 //Expression *inlineScan(InlineScanState *iss); |
606 | |
607 #if IN_LLVM | |
608 DValue* toElem(IRState* irs); | |
609 #endif | |
567 }; | 610 }; |
568 | 611 |
569 struct NewAnonClassExp : Expression | 612 struct NewAnonClassExp : Expression |
570 { | 613 { |
571 /* thisexp.new(newargs) class baseclasses { } (arguments) | 614 /* thisexp.new(newargs) class baseclasses { } (arguments) |
599 Expression *doInline(InlineDoState *ids); | 642 Expression *doInline(InlineDoState *ids); |
600 MATCH implicitConvTo(Type *t); | 643 MATCH implicitConvTo(Type *t); |
601 Expression *castTo(Scope *sc, Type *t); | 644 Expression *castTo(Scope *sc, Type *t); |
602 void scanForNestedRef(Scope *sc); | 645 void scanForNestedRef(Scope *sc); |
603 | 646 |
604 elem *toElem(IRState *irs); | 647 #if IN_DMD |
605 #if IN_DMD | 648 elem *toElem(IRState *irs); |
606 dt_t **toDt(dt_t **pdt); | 649 dt_t **toDt(dt_t **pdt); |
650 #endif | |
651 | |
652 #if IN_LLVM | |
653 DValue* toElem(IRState* irs); | |
607 #endif | 654 #endif |
608 }; | 655 }; |
609 | 656 |
610 // Variable | 657 // Variable |
611 | 658 |
622 char *toChars(); | 669 char *toChars(); |
623 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 670 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
624 void checkEscape(); | 671 void checkEscape(); |
625 Expression *toLvalue(Scope *sc, Expression *e); | 672 Expression *toLvalue(Scope *sc, Expression *e); |
626 Expression *modifiableLvalue(Scope *sc, Expression *e); | 673 Expression *modifiableLvalue(Scope *sc, Expression *e); |
627 elem *toElem(IRState *irs); | 674 #if IN_DMD |
628 #if IN_DMD | 675 elem *toElem(IRState *irs); |
629 dt_t **toDt(dt_t **pdt); | 676 dt_t **toDt(dt_t **pdt); |
630 #elif IN_LLVM | |
631 // LDC | |
632 virtual llvm::Constant *toConstElem(IRState *irs); | |
633 #endif | 677 #endif |
634 void scanForNestedRef(Scope *sc); | 678 void scanForNestedRef(Scope *sc); |
635 | 679 |
636 int inlineCost(InlineCostState *ics); | 680 int inlineCost(InlineCostState *ics); |
637 Expression *doInline(InlineDoState *ids); | 681 Expression *doInline(InlineDoState *ids); |
638 //Expression *inlineScan(InlineScanState *iss); | 682 //Expression *inlineScan(InlineScanState *iss); |
683 | |
684 #if IN_LLVM | |
685 DValue* toElem(IRState* irs); | |
686 llvm::Constant *toConstElem(IRState *irs); | |
687 void cacheLvalue(IRState* irs); | |
688 #endif | |
639 }; | 689 }; |
640 | 690 |
641 #if DMDV2 | 691 #if DMDV2 |
642 // Overload Set | 692 // Overload Set |
643 | 693 |
661 Expression *syntaxCopy(); | 711 Expression *syntaxCopy(); |
662 Expression *semantic(Scope *sc); | 712 Expression *semantic(Scope *sc); |
663 void scanForNestedRef(Scope *sc); | 713 void scanForNestedRef(Scope *sc); |
664 char *toChars(); | 714 char *toChars(); |
665 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 715 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
666 elem *toElem(IRState *irs); | 716 #if IN_DMD |
717 elem *toElem(IRState *irs); | |
718 #endif | |
667 | 719 |
668 int inlineCost(InlineCostState *ics); | 720 int inlineCost(InlineCostState *ics); |
669 //Expression *doInline(InlineDoState *ids); | 721 //Expression *doInline(InlineDoState *ids); |
670 //Expression *inlineScan(InlineScanState *iss); | 722 //Expression *inlineScan(InlineScanState *iss); |
671 | 723 |
672 // LDC | 724 #if IN_LLVM |
673 virtual llvm::Constant *toConstElem(IRState *irs); | 725 DValue* toElem(IRState* irs); |
726 llvm::Constant *toConstElem(IRState *irs); | |
727 #endif | |
674 }; | 728 }; |
675 | 729 |
676 // Declaration of a symbol | 730 // Declaration of a symbol |
677 | 731 |
678 struct DeclarationExp : Expression | 732 struct DeclarationExp : Expression |
683 Expression *syntaxCopy(); | 737 Expression *syntaxCopy(); |
684 Expression *semantic(Scope *sc); | 738 Expression *semantic(Scope *sc); |
685 Expression *interpret(InterState *istate); | 739 Expression *interpret(InterState *istate); |
686 int checkSideEffect(int flag); | 740 int checkSideEffect(int flag); |
687 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 741 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
688 elem *toElem(IRState *irs); | 742 #if IN_DMD |
743 elem *toElem(IRState *irs); | |
744 #endif | |
689 void scanForNestedRef(Scope *sc); | 745 void scanForNestedRef(Scope *sc); |
690 | 746 |
691 int inlineCost(InlineCostState *ics); | 747 int inlineCost(InlineCostState *ics); |
692 Expression *doInline(InlineDoState *ids); | 748 Expression *doInline(InlineDoState *ids); |
693 Expression *inlineScan(InlineScanState *iss); | 749 Expression *inlineScan(InlineScanState *iss); |
750 | |
751 #if IN_LLVM | |
752 DValue* toElem(IRState* irs); | |
753 #endif | |
694 }; | 754 }; |
695 | 755 |
696 struct TypeidExp : Expression | 756 struct TypeidExp : Expression |
697 { | 757 { |
698 Type *typeidType; | 758 Type *typeidType; |
721 HaltExp(Loc loc); | 781 HaltExp(Loc loc); |
722 Expression *semantic(Scope *sc); | 782 Expression *semantic(Scope *sc); |
723 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 783 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
724 int checkSideEffect(int flag); | 784 int checkSideEffect(int flag); |
725 | 785 |
726 elem *toElem(IRState *irs); | 786 #if IN_DMD |
787 elem *toElem(IRState *irs); | |
788 #endif | |
789 | |
790 #if IN_LLVM | |
791 DValue* toElem(IRState* irs); | |
792 #endif | |
727 }; | 793 }; |
728 | 794 |
729 struct IsExp : Expression | 795 struct IsExp : Expression |
730 { | 796 { |
731 /* is(targ id tok tspec) | 797 /* is(targ id tok tspec) |
794 Expression *doInline(InlineDoState *ids); | 860 Expression *doInline(InlineDoState *ids); |
795 Expression *inlineScan(InlineScanState *iss); | 861 Expression *inlineScan(InlineScanState *iss); |
796 | 862 |
797 Expression *op_overload(Scope *sc); | 863 Expression *op_overload(Scope *sc); |
798 | 864 |
865 #if IN_DMD | |
799 elem *toElemBin(IRState *irs, int op); | 866 elem *toElemBin(IRState *irs, int op); |
867 #endif | |
800 }; | 868 }; |
801 | 869 |
802 struct BinAssignExp : BinExp | 870 struct BinAssignExp : BinExp |
803 { | 871 { |
804 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); | 872 BinAssignExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); |
834 | 902 |
835 int inlineCost(InlineCostState *ics); | 903 int inlineCost(InlineCostState *ics); |
836 Expression *doInline(InlineDoState *ids); | 904 Expression *doInline(InlineDoState *ids); |
837 Expression *inlineScan(InlineScanState *iss); | 905 Expression *inlineScan(InlineScanState *iss); |
838 | 906 |
839 elem *toElem(IRState *irs); | 907 #if IN_DMD |
908 elem *toElem(IRState *irs); | |
909 #endif | |
910 | |
911 #if IN_LLVM | |
912 DValue* toElem(IRState* irs); | |
913 #endif | |
840 }; | 914 }; |
841 | 915 |
842 struct DotIdExp : UnaExp | 916 struct DotIdExp : UnaExp |
843 { | 917 { |
844 Identifier *ident; | 918 Identifier *ident; |
867 Expression *modifiableLvalue(Scope *sc, Expression *e); | 941 Expression *modifiableLvalue(Scope *sc, Expression *e); |
868 Expression *optimize(int result); | 942 Expression *optimize(int result); |
869 Expression *interpret(InterState *istate); | 943 Expression *interpret(InterState *istate); |
870 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 944 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
871 void dump(int indent); | 945 void dump(int indent); |
872 elem *toElem(IRState *irs); | 946 #if IN_DMD |
947 elem *toElem(IRState *irs); | |
948 #endif | |
949 | |
950 #if IN_LLVM | |
951 DValue* toElem(IRState* irs); | |
952 void cacheLvalue(IRState* irs); | |
953 #endif | |
873 }; | 954 }; |
874 | 955 |
875 struct DotTemplateInstanceExp : UnaExp | 956 struct DotTemplateInstanceExp : UnaExp |
876 { | 957 { |
877 TemplateInstance *ti; | 958 TemplateInstance *ti; |
893 Expression *castTo(Scope *sc, Type *t); | 974 Expression *castTo(Scope *sc, Type *t); |
894 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 975 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
895 void dump(int indent); | 976 void dump(int indent); |
896 | 977 |
897 int inlineCost(InlineCostState *ics); | 978 int inlineCost(InlineCostState *ics); |
898 elem *toElem(IRState *irs); | 979 #if IN_DMD |
980 elem *toElem(IRState *irs); | |
981 #endif | |
982 | |
983 #if IN_LLVM | |
984 DValue* toElem(IRState* irs); | |
985 #endif | |
899 }; | 986 }; |
900 | 987 |
901 struct DotTypeExp : UnaExp | 988 struct DotTypeExp : UnaExp |
902 { | 989 { |
903 Dsymbol *sym; // symbol that represents a type | 990 Dsymbol *sym; // symbol that represents a type |
904 | 991 |
905 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); | 992 DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); |
906 Expression *semantic(Scope *sc); | 993 Expression *semantic(Scope *sc); |
907 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 994 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
908 elem *toElem(IRState *irs); | 995 #if IN_DMD |
996 elem *toElem(IRState *irs); | |
997 #endif | |
998 | |
999 #if IN_LLVM | |
1000 DValue* toElem(IRState* irs); | |
1001 #endif | |
909 }; | 1002 }; |
910 | 1003 |
911 struct CallExp : UnaExp | 1004 struct CallExp : UnaExp |
912 { | 1005 { |
913 Expressions *arguments; // function arguments | 1006 Expressions *arguments; // function arguments |
922 Expression *optimize(int result); | 1015 Expression *optimize(int result); |
923 Expression *interpret(InterState *istate); | 1016 Expression *interpret(InterState *istate); |
924 int checkSideEffect(int flag); | 1017 int checkSideEffect(int flag); |
925 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1018 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
926 void dump(int indent); | 1019 void dump(int indent); |
927 elem *toElem(IRState *irs); | 1020 #if IN_DMD |
1021 elem *toElem(IRState *irs); | |
1022 #endif | |
928 void scanForNestedRef(Scope *sc); | 1023 void scanForNestedRef(Scope *sc); |
929 Expression *toLvalue(Scope *sc, Expression *e); | 1024 Expression *toLvalue(Scope *sc, Expression *e); |
930 | 1025 |
931 int inlineCost(InlineCostState *ics); | 1026 int inlineCost(InlineCostState *ics); |
932 Expression *doInline(InlineDoState *ids); | 1027 Expression *doInline(InlineDoState *ids); |
933 Expression *inlineScan(InlineScanState *iss); | 1028 Expression *inlineScan(InlineScanState *iss); |
1029 | |
1030 #if IN_LLVM | |
1031 DValue* toElem(IRState* irs); | |
1032 #endif | |
934 }; | 1033 }; |
935 | 1034 |
936 struct AddrExp : UnaExp | 1035 struct AddrExp : UnaExp |
937 { | 1036 { |
938 AddrExp(Loc loc, Expression *e); | 1037 AddrExp(Loc loc, Expression *e); |
939 Expression *semantic(Scope *sc); | 1038 Expression *semantic(Scope *sc); |
940 elem *toElem(IRState *irs); | 1039 #if IN_DMD |
1040 elem *toElem(IRState *irs); | |
1041 #endif | |
941 MATCH implicitConvTo(Type *t); | 1042 MATCH implicitConvTo(Type *t); |
942 Expression *castTo(Scope *sc, Type *t); | 1043 Expression *castTo(Scope *sc, Type *t); |
943 Expression *optimize(int result); | 1044 Expression *optimize(int result); |
944 // LDC | 1045 |
945 virtual llvm::Constant *toConstElem(IRState *irs); | 1046 #if IN_LLVM |
1047 DValue* toElem(IRState* irs); | |
1048 llvm::Constant *toConstElem(IRState *irs); | |
1049 #endif | |
946 }; | 1050 }; |
947 | 1051 |
948 struct PtrExp : UnaExp | 1052 struct PtrExp : UnaExp |
949 { | 1053 { |
950 PtrExp(Loc loc, Expression *e); | 1054 PtrExp(Loc loc, Expression *e); |
951 PtrExp(Loc loc, Expression *e, Type *t); | 1055 PtrExp(Loc loc, Expression *e, Type *t); |
952 Expression *semantic(Scope *sc); | 1056 Expression *semantic(Scope *sc); |
953 Expression *toLvalue(Scope *sc, Expression *e); | 1057 Expression *toLvalue(Scope *sc, Expression *e); |
954 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1058 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
955 elem *toElem(IRState *irs); | 1059 #if IN_DMD |
956 Expression *optimize(int result); | 1060 elem *toElem(IRState *irs); |
957 Expression *interpret(InterState *istate); | 1061 #endif |
1062 Expression *optimize(int result); | |
1063 Expression *interpret(InterState *istate); | |
1064 | |
1065 #if IN_LLVM | |
1066 DValue* toElem(IRState* irs); | |
1067 void cacheLvalue(IRState* irs); | |
1068 #endif | |
958 }; | 1069 }; |
959 | 1070 |
960 struct NegExp : UnaExp | 1071 struct NegExp : UnaExp |
961 { | 1072 { |
962 NegExp(Loc loc, Expression *e); | 1073 NegExp(Loc loc, Expression *e); |
967 Expression *buildArrayLoop(Arguments *fparams); | 1078 Expression *buildArrayLoop(Arguments *fparams); |
968 | 1079 |
969 // For operator overloading | 1080 // For operator overloading |
970 Identifier *opId(); | 1081 Identifier *opId(); |
971 | 1082 |
972 elem *toElem(IRState *irs); | 1083 #if IN_DMD |
1084 elem *toElem(IRState *irs); | |
1085 #endif | |
1086 | |
1087 #if IN_LLVM | |
1088 DValue* toElem(IRState* irs); | |
1089 #endif | |
973 }; | 1090 }; |
974 | 1091 |
975 struct UAddExp : UnaExp | 1092 struct UAddExp : UnaExp |
976 { | 1093 { |
977 UAddExp(Loc loc, Expression *e); | 1094 UAddExp(Loc loc, Expression *e); |
991 Expression *buildArrayLoop(Arguments *fparams); | 1108 Expression *buildArrayLoop(Arguments *fparams); |
992 | 1109 |
993 // For operator overloading | 1110 // For operator overloading |
994 Identifier *opId(); | 1111 Identifier *opId(); |
995 | 1112 |
996 elem *toElem(IRState *irs); | 1113 #if IN_DMD |
1114 elem *toElem(IRState *irs); | |
1115 #endif | |
1116 | |
1117 #if IN_LLVM | |
1118 DValue* toElem(IRState* irs); | |
1119 #endif | |
997 }; | 1120 }; |
998 | 1121 |
999 struct NotExp : UnaExp | 1122 struct NotExp : UnaExp |
1000 { | 1123 { |
1001 NotExp(Loc loc, Expression *e); | 1124 NotExp(Loc loc, Expression *e); |
1002 Expression *semantic(Scope *sc); | 1125 Expression *semantic(Scope *sc); |
1003 Expression *optimize(int result); | 1126 Expression *optimize(int result); |
1004 Expression *interpret(InterState *istate); | 1127 Expression *interpret(InterState *istate); |
1005 int isBit(); | 1128 int isBit(); |
1006 elem *toElem(IRState *irs); | 1129 #if IN_DMD |
1130 elem *toElem(IRState *irs); | |
1131 #endif | |
1132 | |
1133 #if IN_LLVM | |
1134 DValue* toElem(IRState* irs); | |
1135 #endif | |
1007 }; | 1136 }; |
1008 | 1137 |
1009 struct BoolExp : UnaExp | 1138 struct BoolExp : UnaExp |
1010 { | 1139 { |
1011 BoolExp(Loc loc, Expression *e, Type *type); | 1140 BoolExp(Loc loc, Expression *e, Type *type); |
1012 Expression *semantic(Scope *sc); | 1141 Expression *semantic(Scope *sc); |
1013 Expression *optimize(int result); | 1142 Expression *optimize(int result); |
1014 Expression *interpret(InterState *istate); | 1143 Expression *interpret(InterState *istate); |
1015 int isBit(); | 1144 int isBit(); |
1016 elem *toElem(IRState *irs); | 1145 #if IN_DMD |
1146 elem *toElem(IRState *irs); | |
1147 #endif | |
1148 | |
1149 #if IN_LLVM | |
1150 DValue* toElem(IRState* irs); | |
1151 #endif | |
1017 }; | 1152 }; |
1018 | 1153 |
1019 struct DeleteExp : UnaExp | 1154 struct DeleteExp : UnaExp |
1020 { | 1155 { |
1021 DeleteExp(Loc loc, Expression *e); | 1156 DeleteExp(Loc loc, Expression *e); |
1022 Expression *semantic(Scope *sc); | 1157 Expression *semantic(Scope *sc); |
1023 Expression *checkToBoolean(); | 1158 Expression *checkToBoolean(); |
1024 int checkSideEffect(int flag); | 1159 int checkSideEffect(int flag); |
1025 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1160 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1026 elem *toElem(IRState *irs); | 1161 #if IN_DMD |
1162 elem *toElem(IRState *irs); | |
1163 #endif | |
1164 | |
1165 #if IN_LLVM | |
1166 DValue* toElem(IRState* irs); | |
1167 #endif | |
1027 }; | 1168 }; |
1028 | 1169 |
1029 struct CastExp : UnaExp | 1170 struct CastExp : UnaExp |
1030 { | 1171 { |
1031 // Possible to cast to one type while painting to another type | 1172 // Possible to cast to one type while painting to another type |
1037 Expression *optimize(int result); | 1178 Expression *optimize(int result); |
1038 Expression *interpret(InterState *istate); | 1179 Expression *interpret(InterState *istate); |
1039 int checkSideEffect(int flag); | 1180 int checkSideEffect(int flag); |
1040 void checkEscape(); | 1181 void checkEscape(); |
1041 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1182 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1042 elem *toElem(IRState *irs); | 1183 #if IN_DMD |
1184 elem *toElem(IRState *irs); | |
1185 #endif | |
1043 | 1186 |
1044 // For operator overloading | 1187 // For operator overloading |
1045 Identifier *opId(); | 1188 Identifier *opId(); |
1046 | 1189 |
1047 // LDC | 1190 #if IN_LLVM |
1048 virtual llvm::Constant *toConstElem(IRState *irs); | 1191 DValue* toElem(IRState* irs); |
1192 llvm::Constant *toConstElem(IRState *irs); | |
1193 #endif | |
1049 }; | 1194 }; |
1050 | 1195 |
1051 | 1196 |
1052 struct SliceExp : UnaExp | 1197 struct SliceExp : UnaExp |
1053 { | 1198 { |
1063 Expression *modifiableLvalue(Scope *sc, Expression *e); | 1208 Expression *modifiableLvalue(Scope *sc, Expression *e); |
1064 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1209 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1065 Expression *optimize(int result); | 1210 Expression *optimize(int result); |
1066 Expression *interpret(InterState *istate); | 1211 Expression *interpret(InterState *istate); |
1067 void dump(int indent); | 1212 void dump(int indent); |
1068 elem *toElem(IRState *irs); | 1213 #if IN_DMD |
1214 elem *toElem(IRState *irs); | |
1215 #endif | |
1069 void scanForNestedRef(Scope *sc); | 1216 void scanForNestedRef(Scope *sc); |
1070 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); | 1217 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
1071 Expression *buildArrayLoop(Arguments *fparams); | 1218 Expression *buildArrayLoop(Arguments *fparams); |
1072 | 1219 |
1073 int inlineCost(InlineCostState *ics); | 1220 int inlineCost(InlineCostState *ics); |
1074 Expression *doInline(InlineDoState *ids); | 1221 Expression *doInline(InlineDoState *ids); |
1075 Expression *inlineScan(InlineScanState *iss); | 1222 Expression *inlineScan(InlineScanState *iss); |
1076 | 1223 |
1077 // LDC | 1224 #if IN_LLVM |
1078 virtual llvm::Constant *toConstElem(IRState *irs); | 1225 DValue* toElem(IRState* irs); |
1226 llvm::Constant *toConstElem(IRState *irs); | |
1227 #endif | |
1079 }; | 1228 }; |
1080 | 1229 |
1081 struct ArrayLengthExp : UnaExp | 1230 struct ArrayLengthExp : UnaExp |
1082 { | 1231 { |
1083 ArrayLengthExp(Loc loc, Expression *e1); | 1232 ArrayLengthExp(Loc loc, Expression *e1); |
1084 Expression *semantic(Scope *sc); | 1233 Expression *semantic(Scope *sc); |
1085 Expression *optimize(int result); | 1234 Expression *optimize(int result); |
1086 Expression *interpret(InterState *istate); | 1235 Expression *interpret(InterState *istate); |
1087 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1236 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1088 elem *toElem(IRState *irs); | 1237 #if IN_DMD |
1238 elem *toElem(IRState *irs); | |
1239 #endif | |
1240 | |
1241 #if IN_LLVM | |
1242 DValue* toElem(IRState* irs); | |
1243 #endif | |
1089 }; | 1244 }; |
1090 | 1245 |
1091 // e1[a0,a1,a2,a3,...] | 1246 // e1[a0,a1,a2,a3,...] |
1092 | 1247 |
1093 struct ArrayExp : UnaExp | 1248 struct ArrayExp : UnaExp |
1126 Expression *modifiableLvalue(Scope *sc, Expression *e); | 1281 Expression *modifiableLvalue(Scope *sc, Expression *e); |
1127 int isBool(int result); | 1282 int isBool(int result); |
1128 int checkSideEffect(int flag); | 1283 int checkSideEffect(int flag); |
1129 Expression *optimize(int result); | 1284 Expression *optimize(int result); |
1130 Expression *interpret(InterState *istate); | 1285 Expression *interpret(InterState *istate); |
1131 elem *toElem(IRState *irs); | 1286 #if IN_DMD |
1287 elem *toElem(IRState *irs); | |
1288 #endif | |
1289 | |
1290 #if IN_LLVM | |
1291 DValue* toElem(IRState* irs); | |
1292 #endif | |
1132 }; | 1293 }; |
1133 | 1294 |
1134 struct IndexExp : BinExp | 1295 struct IndexExp : BinExp |
1135 { | 1296 { |
1136 VarDeclaration *lengthVar; | 1297 VarDeclaration *lengthVar; |
1144 Expression *optimize(int result); | 1305 Expression *optimize(int result); |
1145 Expression *interpret(InterState *istate); | 1306 Expression *interpret(InterState *istate); |
1146 Expression *doInline(InlineDoState *ids); | 1307 Expression *doInline(InlineDoState *ids); |
1147 void scanForNestedRef(Scope *sc); | 1308 void scanForNestedRef(Scope *sc); |
1148 | 1309 |
1149 elem *toElem(IRState *irs); | 1310 #if IN_DMD |
1150 // LDC | 1311 elem *toElem(IRState *irs); |
1151 virtual llvm::Constant *toConstElem(IRState *irs); | 1312 #elif IN_LLVM |
1313 DValue* toElem(IRState* irs); | |
1314 llvm::Constant *toConstElem(IRState *irs); | |
1315 void cacheLvalue(IRState* irs); | |
1316 #endif | |
1152 }; | 1317 }; |
1153 | 1318 |
1154 /* For both i++ and i-- | 1319 /* For both i++ and i-- |
1155 */ | 1320 */ |
1156 struct PostExp : BinExp | 1321 struct PostExp : BinExp |
1158 PostExp(enum TOK op, Loc loc, Expression *e); | 1323 PostExp(enum TOK op, Loc loc, Expression *e); |
1159 Expression *semantic(Scope *sc); | 1324 Expression *semantic(Scope *sc); |
1160 Expression *interpret(InterState *istate); | 1325 Expression *interpret(InterState *istate); |
1161 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1326 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1162 Identifier *opId(); // For operator overloading | 1327 Identifier *opId(); // For operator overloading |
1163 elem *toElem(IRState *irs); | 1328 #if IN_DMD |
1329 elem *toElem(IRState *irs); | |
1330 #endif | |
1331 | |
1332 #if IN_LLVM | |
1333 DValue* toElem(IRState* irs); | |
1334 #endif | |
1164 }; | 1335 }; |
1165 | 1336 |
1166 struct AssignExp : BinExp | 1337 struct AssignExp : BinExp |
1167 { int ismemset; // !=0 if setting the contents of an array | 1338 { int ismemset; // !=0 if setting the contents of an array |
1168 | 1339 |
1171 Expression *checkToBoolean(); | 1342 Expression *checkToBoolean(); |
1172 Expression *interpret(InterState *istate); | 1343 Expression *interpret(InterState *istate); |
1173 Identifier *opId(); // For operator overloading | 1344 Identifier *opId(); // For operator overloading |
1174 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); | 1345 void buildArrayIdent(OutBuffer *buf, Expressions *arguments); |
1175 Expression *buildArrayLoop(Arguments *fparams); | 1346 Expression *buildArrayLoop(Arguments *fparams); |
1176 elem *toElem(IRState *irs); | 1347 #if IN_DMD |
1177 }; | 1348 elem *toElem(IRState *irs); |
1349 #endif | |
1350 | |
1351 #if IN_LLVM | |
1352 DValue* toElem(IRState* irs); | |
1353 #endif | |
1354 }; | |
1355 | |
1356 #if IN_DMD | |
1357 #define ASSIGNEXP_TOELEM elem *toElem(IRState *irs); | |
1358 #elif IN_LLVM | |
1359 #define ASSIGNEXP_TOELEM DValue* toElem(IRState *irs); | |
1360 #else | |
1361 #define ASSIGNEXP_TOELEM | |
1362 #endif | |
1178 | 1363 |
1179 #define ASSIGNEXP(op) \ | 1364 #define ASSIGNEXP(op) \ |
1180 struct op##AssignExp : BinExp \ | 1365 struct op##AssignExp : BinExp \ |
1181 { \ | 1366 { \ |
1182 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ | 1367 op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ |
1185 X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \ | 1370 X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \ |
1186 X(Expression *buildArrayLoop(Arguments *fparams);) \ | 1371 X(Expression *buildArrayLoop(Arguments *fparams);) \ |
1187 \ | 1372 \ |
1188 Identifier *opId(); /* For operator overloading */ \ | 1373 Identifier *opId(); /* For operator overloading */ \ |
1189 \ | 1374 \ |
1190 elem *toElem(IRState *irs); \ | 1375 ASSIGNEXP_TOELEM \ |
1191 }; | 1376 }; |
1192 | 1377 |
1193 #define X(a) a | 1378 #define X(a) a |
1194 ASSIGNEXP(Add) | 1379 ASSIGNEXP(Add) |
1195 ASSIGNEXP(Min) | 1380 ASSIGNEXP(Min) |
1208 ASSIGNEXP(Ushr) | 1393 ASSIGNEXP(Ushr) |
1209 ASSIGNEXP(Cat) | 1394 ASSIGNEXP(Cat) |
1210 | 1395 |
1211 #undef X | 1396 #undef X |
1212 #undef ASSIGNEXP | 1397 #undef ASSIGNEXP |
1398 #undef ASSIGNEXP_TOELEM | |
1213 | 1399 |
1214 struct AddExp : BinExp | 1400 struct AddExp : BinExp |
1215 { | 1401 { |
1216 AddExp(Loc loc, Expression *e1, Expression *e2); | 1402 AddExp(Loc loc, Expression *e1, Expression *e2); |
1217 Expression *semantic(Scope *sc); | 1403 Expression *semantic(Scope *sc); |
1223 // For operator overloading | 1409 // For operator overloading |
1224 int isCommutative(); | 1410 int isCommutative(); |
1225 Identifier *opId(); | 1411 Identifier *opId(); |
1226 Identifier *opId_r(); | 1412 Identifier *opId_r(); |
1227 | 1413 |
1228 elem *toElem(IRState *irs); | 1414 #if IN_DMD |
1415 elem *toElem(IRState *irs); | |
1416 #endif | |
1417 | |
1418 #if IN_LLVM | |
1419 DValue* toElem(IRState* irs); | |
1420 #endif | |
1229 }; | 1421 }; |
1230 | 1422 |
1231 struct MinExp : BinExp | 1423 struct MinExp : BinExp |
1232 { | 1424 { |
1233 MinExp(Loc loc, Expression *e1, Expression *e2); | 1425 MinExp(Loc loc, Expression *e1, Expression *e2); |
1239 | 1431 |
1240 // For operator overloading | 1432 // For operator overloading |
1241 Identifier *opId(); | 1433 Identifier *opId(); |
1242 Identifier *opId_r(); | 1434 Identifier *opId_r(); |
1243 | 1435 |
1244 elem *toElem(IRState *irs); | 1436 #if IN_DMD |
1437 elem *toElem(IRState *irs); | |
1438 #endif | |
1439 | |
1440 #if IN_LLVM | |
1441 DValue* toElem(IRState* irs); | |
1442 #endif | |
1245 }; | 1443 }; |
1246 | 1444 |
1247 struct CatExp : BinExp | 1445 struct CatExp : BinExp |
1248 { | 1446 { |
1249 CatExp(Loc loc, Expression *e1, Expression *e2); | 1447 CatExp(Loc loc, Expression *e1, Expression *e2); |
1253 | 1451 |
1254 // For operator overloading | 1452 // For operator overloading |
1255 Identifier *opId(); | 1453 Identifier *opId(); |
1256 Identifier *opId_r(); | 1454 Identifier *opId_r(); |
1257 | 1455 |
1258 elem *toElem(IRState *irs); | 1456 #if IN_DMD |
1457 elem *toElem(IRState *irs); | |
1458 #endif | |
1459 | |
1460 #if IN_LLVM | |
1461 DValue* toElem(IRState* irs); | |
1462 #endif | |
1259 }; | 1463 }; |
1260 | 1464 |
1261 struct MulExp : BinExp | 1465 struct MulExp : BinExp |
1262 { | 1466 { |
1263 MulExp(Loc loc, Expression *e1, Expression *e2); | 1467 MulExp(Loc loc, Expression *e1, Expression *e2); |
1270 // For operator overloading | 1474 // For operator overloading |
1271 int isCommutative(); | 1475 int isCommutative(); |
1272 Identifier *opId(); | 1476 Identifier *opId(); |
1273 Identifier *opId_r(); | 1477 Identifier *opId_r(); |
1274 | 1478 |
1275 elem *toElem(IRState *irs); | 1479 #if IN_DMD |
1480 elem *toElem(IRState *irs); | |
1481 #endif | |
1482 | |
1483 #if IN_LLVM | |
1484 DValue* toElem(IRState* irs); | |
1485 #endif | |
1276 }; | 1486 }; |
1277 | 1487 |
1278 struct DivExp : BinExp | 1488 struct DivExp : BinExp |
1279 { | 1489 { |
1280 DivExp(Loc loc, Expression *e1, Expression *e2); | 1490 DivExp(Loc loc, Expression *e1, Expression *e2); |
1286 | 1496 |
1287 // For operator overloading | 1497 // For operator overloading |
1288 Identifier *opId(); | 1498 Identifier *opId(); |
1289 Identifier *opId_r(); | 1499 Identifier *opId_r(); |
1290 | 1500 |
1291 elem *toElem(IRState *irs); | 1501 #if IN_DMD |
1502 elem *toElem(IRState *irs); | |
1503 #endif | |
1504 | |
1505 #if IN_LLVM | |
1506 DValue* toElem(IRState* irs); | |
1507 #endif | |
1292 }; | 1508 }; |
1293 | 1509 |
1294 struct ModExp : BinExp | 1510 struct ModExp : BinExp |
1295 { | 1511 { |
1296 ModExp(Loc loc, Expression *e1, Expression *e2); | 1512 ModExp(Loc loc, Expression *e1, Expression *e2); |
1302 | 1518 |
1303 // For operator overloading | 1519 // For operator overloading |
1304 Identifier *opId(); | 1520 Identifier *opId(); |
1305 Identifier *opId_r(); | 1521 Identifier *opId_r(); |
1306 | 1522 |
1307 elem *toElem(IRState *irs); | 1523 #if IN_DMD |
1524 elem *toElem(IRState *irs); | |
1525 #endif | |
1526 | |
1527 #if IN_LLVM | |
1528 DValue* toElem(IRState* irs); | |
1529 #endif | |
1308 }; | 1530 }; |
1309 | 1531 |
1310 struct ShlExp : BinExp | 1532 struct ShlExp : BinExp |
1311 { | 1533 { |
1312 ShlExp(Loc loc, Expression *e1, Expression *e2); | 1534 ShlExp(Loc loc, Expression *e1, Expression *e2); |
1316 | 1538 |
1317 // For operator overloading | 1539 // For operator overloading |
1318 Identifier *opId(); | 1540 Identifier *opId(); |
1319 Identifier *opId_r(); | 1541 Identifier *opId_r(); |
1320 | 1542 |
1321 elem *toElem(IRState *irs); | 1543 #if IN_DMD |
1544 elem *toElem(IRState *irs); | |
1545 #endif | |
1546 | |
1547 #if IN_LLVM | |
1548 DValue* toElem(IRState* irs); | |
1549 #endif | |
1322 }; | 1550 }; |
1323 | 1551 |
1324 struct ShrExp : BinExp | 1552 struct ShrExp : BinExp |
1325 { | 1553 { |
1326 ShrExp(Loc loc, Expression *e1, Expression *e2); | 1554 ShrExp(Loc loc, Expression *e1, Expression *e2); |
1330 | 1558 |
1331 // For operator overloading | 1559 // For operator overloading |
1332 Identifier *opId(); | 1560 Identifier *opId(); |
1333 Identifier *opId_r(); | 1561 Identifier *opId_r(); |
1334 | 1562 |
1335 elem *toElem(IRState *irs); | 1563 #if IN_DMD |
1564 elem *toElem(IRState *irs); | |
1565 #endif | |
1566 | |
1567 #if IN_LLVM | |
1568 DValue* toElem(IRState* irs); | |
1569 #endif | |
1336 }; | 1570 }; |
1337 | 1571 |
1338 struct UshrExp : BinExp | 1572 struct UshrExp : BinExp |
1339 { | 1573 { |
1340 UshrExp(Loc loc, Expression *e1, Expression *e2); | 1574 UshrExp(Loc loc, Expression *e1, Expression *e2); |
1344 | 1578 |
1345 // For operator overloading | 1579 // For operator overloading |
1346 Identifier *opId(); | 1580 Identifier *opId(); |
1347 Identifier *opId_r(); | 1581 Identifier *opId_r(); |
1348 | 1582 |
1349 elem *toElem(IRState *irs); | 1583 #if IN_DMD |
1584 elem *toElem(IRState *irs); | |
1585 #endif | |
1586 | |
1587 #if IN_LLVM | |
1588 DValue* toElem(IRState* irs); | |
1589 #endif | |
1350 }; | 1590 }; |
1351 | 1591 |
1352 struct AndExp : BinExp | 1592 struct AndExp : BinExp |
1353 { | 1593 { |
1354 AndExp(Loc loc, Expression *e1, Expression *e2); | 1594 AndExp(Loc loc, Expression *e1, Expression *e2); |
1361 // For operator overloading | 1601 // For operator overloading |
1362 int isCommutative(); | 1602 int isCommutative(); |
1363 Identifier *opId(); | 1603 Identifier *opId(); |
1364 Identifier *opId_r(); | 1604 Identifier *opId_r(); |
1365 | 1605 |
1366 elem *toElem(IRState *irs); | 1606 #if IN_DMD |
1607 elem *toElem(IRState *irs); | |
1608 #endif | |
1609 | |
1610 #if IN_LLVM | |
1611 DValue* toElem(IRState* irs); | |
1612 #endif | |
1367 }; | 1613 }; |
1368 | 1614 |
1369 struct OrExp : BinExp | 1615 struct OrExp : BinExp |
1370 { | 1616 { |
1371 OrExp(Loc loc, Expression *e1, Expression *e2); | 1617 OrExp(Loc loc, Expression *e1, Expression *e2); |
1378 // For operator overloading | 1624 // For operator overloading |
1379 int isCommutative(); | 1625 int isCommutative(); |
1380 Identifier *opId(); | 1626 Identifier *opId(); |
1381 Identifier *opId_r(); | 1627 Identifier *opId_r(); |
1382 | 1628 |
1383 elem *toElem(IRState *irs); | 1629 #if IN_DMD |
1630 elem *toElem(IRState *irs); | |
1631 #endif | |
1632 | |
1633 #if IN_LLVM | |
1634 DValue* toElem(IRState* irs); | |
1635 #endif | |
1384 }; | 1636 }; |
1385 | 1637 |
1386 struct XorExp : BinExp | 1638 struct XorExp : BinExp |
1387 { | 1639 { |
1388 XorExp(Loc loc, Expression *e1, Expression *e2); | 1640 XorExp(Loc loc, Expression *e1, Expression *e2); |
1395 // For operator overloading | 1647 // For operator overloading |
1396 int isCommutative(); | 1648 int isCommutative(); |
1397 Identifier *opId(); | 1649 Identifier *opId(); |
1398 Identifier *opId_r(); | 1650 Identifier *opId_r(); |
1399 | 1651 |
1400 elem *toElem(IRState *irs); | 1652 #if IN_DMD |
1653 elem *toElem(IRState *irs); | |
1654 #endif | |
1655 | |
1656 #if IN_LLVM | |
1657 DValue* toElem(IRState* irs); | |
1658 #endif | |
1401 }; | 1659 }; |
1402 | 1660 |
1403 struct OrOrExp : BinExp | 1661 struct OrOrExp : BinExp |
1404 { | 1662 { |
1405 OrOrExp(Loc loc, Expression *e1, Expression *e2); | 1663 OrOrExp(Loc loc, Expression *e1, Expression *e2); |
1407 Expression *checkToBoolean(); | 1665 Expression *checkToBoolean(); |
1408 int isBit(); | 1666 int isBit(); |
1409 Expression *optimize(int result); | 1667 Expression *optimize(int result); |
1410 Expression *interpret(InterState *istate); | 1668 Expression *interpret(InterState *istate); |
1411 int checkSideEffect(int flag); | 1669 int checkSideEffect(int flag); |
1412 elem *toElem(IRState *irs); | 1670 #if IN_DMD |
1671 elem *toElem(IRState *irs); | |
1672 #endif | |
1673 | |
1674 #if IN_LLVM | |
1675 DValue* toElem(IRState* irs); | |
1676 #endif | |
1413 }; | 1677 }; |
1414 | 1678 |
1415 struct AndAndExp : BinExp | 1679 struct AndAndExp : BinExp |
1416 { | 1680 { |
1417 AndAndExp(Loc loc, Expression *e1, Expression *e2); | 1681 AndAndExp(Loc loc, Expression *e1, Expression *e2); |
1419 Expression *checkToBoolean(); | 1683 Expression *checkToBoolean(); |
1420 int isBit(); | 1684 int isBit(); |
1421 Expression *optimize(int result); | 1685 Expression *optimize(int result); |
1422 Expression *interpret(InterState *istate); | 1686 Expression *interpret(InterState *istate); |
1423 int checkSideEffect(int flag); | 1687 int checkSideEffect(int flag); |
1424 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 | |
1425 }; | 1695 }; |
1426 | 1696 |
1427 struct CmpExp : BinExp | 1697 struct CmpExp : BinExp |
1428 { | 1698 { |
1429 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | 1699 CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); |
1434 | 1704 |
1435 // For operator overloading | 1705 // For operator overloading |
1436 int isCommutative(); | 1706 int isCommutative(); |
1437 Identifier *opId(); | 1707 Identifier *opId(); |
1438 | 1708 |
1439 elem *toElem(IRState *irs); | 1709 #if IN_DMD |
1710 elem *toElem(IRState *irs); | |
1711 #endif | |
1712 | |
1713 #if IN_LLVM | |
1714 DValue* toElem(IRState* irs); | |
1715 #endif | |
1440 }; | 1716 }; |
1441 | 1717 |
1442 struct InExp : BinExp | 1718 struct InExp : BinExp |
1443 { | 1719 { |
1444 InExp(Loc loc, Expression *e1, Expression *e2); | 1720 InExp(Loc loc, Expression *e1, Expression *e2); |
1447 | 1723 |
1448 // For operator overloading | 1724 // For operator overloading |
1449 Identifier *opId(); | 1725 Identifier *opId(); |
1450 Identifier *opId_r(); | 1726 Identifier *opId_r(); |
1451 | 1727 |
1452 elem *toElem(IRState *irs); | 1728 #if IN_DMD |
1729 elem *toElem(IRState *irs); | |
1730 #endif | |
1731 | |
1732 #if IN_LLVM | |
1733 DValue* toElem(IRState* irs); | |
1734 #endif | |
1453 }; | 1735 }; |
1454 | 1736 |
1455 struct RemoveExp : BinExp | 1737 struct RemoveExp : BinExp |
1456 { | 1738 { |
1457 RemoveExp(Loc loc, Expression *e1, Expression *e2); | 1739 RemoveExp(Loc loc, Expression *e1, Expression *e2); |
1458 elem *toElem(IRState *irs); | 1740 #if IN_DMD |
1741 elem *toElem(IRState *irs); | |
1742 #endif | |
1743 | |
1744 #if IN_LLVM | |
1745 DValue* toElem(IRState* irs); | |
1746 #endif | |
1459 }; | 1747 }; |
1460 | 1748 |
1461 // == and != | 1749 // == and != |
1462 | 1750 |
1463 struct EqualExp : BinExp | 1751 struct EqualExp : BinExp |
1470 | 1758 |
1471 // For operator overloading | 1759 // For operator overloading |
1472 int isCommutative(); | 1760 int isCommutative(); |
1473 Identifier *opId(); | 1761 Identifier *opId(); |
1474 | 1762 |
1475 elem *toElem(IRState *irs); | 1763 #if IN_DMD |
1764 elem *toElem(IRState *irs); | |
1765 #endif | |
1766 | |
1767 #if IN_LLVM | |
1768 DValue* toElem(IRState* irs); | |
1769 #endif | |
1476 }; | 1770 }; |
1477 | 1771 |
1478 // === and !=== | 1772 // === and !=== |
1479 | 1773 |
1480 struct IdentityExp : BinExp | 1774 struct IdentityExp : BinExp |
1482 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); | 1776 IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); |
1483 Expression *semantic(Scope *sc); | 1777 Expression *semantic(Scope *sc); |
1484 int isBit(); | 1778 int isBit(); |
1485 Expression *optimize(int result); | 1779 Expression *optimize(int result); |
1486 Expression *interpret(InterState *istate); | 1780 Expression *interpret(InterState *istate); |
1487 elem *toElem(IRState *irs); | 1781 #if IN_DMD |
1782 elem *toElem(IRState *irs); | |
1783 #endif | |
1784 | |
1785 #if IN_LLVM | |
1786 DValue* toElem(IRState* irs); | |
1787 #endif | |
1488 }; | 1788 }; |
1489 | 1789 |
1490 /****************************************************************/ | 1790 /****************************************************************/ |
1491 | 1791 |
1492 struct CondExp : BinExp | 1792 struct CondExp : BinExp |
1510 | 1810 |
1511 int inlineCost(InlineCostState *ics); | 1811 int inlineCost(InlineCostState *ics); |
1512 Expression *doInline(InlineDoState *ids); | 1812 Expression *doInline(InlineDoState *ids); |
1513 Expression *inlineScan(InlineScanState *iss); | 1813 Expression *inlineScan(InlineScanState *iss); |
1514 | 1814 |
1515 elem *toElem(IRState *irs); | 1815 #if IN_DMD |
1816 elem *toElem(IRState *irs); | |
1817 #endif | |
1818 | |
1819 #if IN_LLVM | |
1820 DValue* toElem(IRState* irs); | |
1821 #endif | |
1516 }; | 1822 }; |
1517 | 1823 |
1518 #if DMDV2 | 1824 #if DMDV2 |
1519 /****************************************************************/ | 1825 /****************************************************************/ |
1520 | 1826 |
1555 | 1861 |
1556 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx); | 1862 GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx); |
1557 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 1863 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
1558 Expression *toLvalue(Scope *sc, Expression *e); | 1864 Expression *toLvalue(Scope *sc, Expression *e); |
1559 | 1865 |
1560 elem *toElem(IRState *irs); | 1866 #if IN_DMD |
1867 elem *toElem(IRState *irs); | |
1868 #elif IN_LLVM | |
1869 DValue* toElem(IRState* irs); | |
1561 llvm::Constant *toConstElem(IRState *irs); | 1870 llvm::Constant *toConstElem(IRState *irs); |
1871 #endif | |
1562 }; | 1872 }; |
1563 | 1873 |
1564 #endif | 1874 #endif |
1565 | 1875 |
1566 /****************************************************************/ | 1876 /****************************************************************/ |