comparison dmd/mtype.h @ 1146:1860414bf3b7

* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h. * Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken. * All part of a greater cleanup scheme.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 26 Mar 2009 20:45:53 +0100
parents b30fe7e1dbb9
children dbe4af57b240
comparison
equal deleted inserted replaced
1145:40caa8207b3e 1146:1860414bf3b7
19 #include "stringtable.h" 19 #include "stringtable.h"
20 20
21 #include "arraytypes.h" 21 #include "arraytypes.h"
22 #include "expression.h" 22 #include "expression.h"
23 23
24 #if IN_LLVM
24 // llvm 25 // llvm
25 #include "../ir/irtype.h" 26 #include "../ir/irtype.h"
26 #include "../ir/irfuncty.h" 27 #include "../ir/irfuncty.h"
27 namespace llvm { class Type; } 28 namespace llvm { class Type; }
29 #endif
28 30
29 struct Scope; 31 struct Scope;
30 struct Identifier; 32 struct Identifier;
31 struct Expression; 33 struct Expression;
32 struct StructDeclaration; 34 struct StructDeclaration;
46 48
47 // Back end 49 // Back end
48 #if IN_GCC 50 #if IN_GCC
49 union tree_node; typedef union tree_node TYPE; 51 union tree_node; typedef union tree_node TYPE;
50 typedef TYPE type; 52 typedef TYPE type;
51 #else 53 #endif
54
55 #if IN_DMD
52 typedef struct TYPE type; 56 typedef struct TYPE type;
53 #endif
54 struct Symbol; 57 struct Symbol;
58 #endif
55 59
56 enum TY 60 enum TY
57 { 61 {
58 Tarray, // dynamic array 62 Tarray, // dynamic array
59 Tsarray, // static array 63 Tsarray, // static array
124 Type *pto; // merged pointer to this type 128 Type *pto; // merged pointer to this type
125 Type *rto; // reference to this type 129 Type *rto; // reference to this type
126 Type *arrayof; // array of this type 130 Type *arrayof; // array of this type
127 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type 131 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
128 132
133 #if IN_DMD
129 type *ctype; // for back end 134 type *ctype; // for back end
135 #endif
130 136
131 #define tvoid basic[Tvoid] 137 #define tvoid basic[Tvoid]
132 #define tint8 basic[Tint8] 138 #define tint8 basic[Tint8]
133 #define tuns8 basic[Tuns8] 139 #define tuns8 basic[Tuns8]
134 #define tint16 basic[Tint16] 140 #define tint16 basic[Tint16]
234 virtual Expression *getProperty(Loc loc, Identifier *ident); 240 virtual Expression *getProperty(Loc loc, Identifier *ident);
235 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 241 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
236 virtual unsigned memalign(unsigned salign); 242 virtual unsigned memalign(unsigned salign);
237 virtual Expression *defaultInit(Loc loc = 0); 243 virtual Expression *defaultInit(Loc loc = 0);
238 virtual int isZeroInit(); // if initializer is 0 244 virtual int isZeroInit(); // if initializer is 0
245 #if IN_DMD
239 virtual dt_t **toDt(dt_t **pdt); 246 virtual dt_t **toDt(dt_t **pdt);
247 #endif
240 Identifier *getTypeInfoIdent(int internal); 248 Identifier *getTypeInfoIdent(int internal);
241 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 249 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
242 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 250 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
243 Expression *getInternalTypeInfo(Scope *sc); 251 Expression *getInternalTypeInfo(Scope *sc);
244 Expression *getTypeInfo(Scope *sc); 252 Expression *getTypeInfo(Scope *sc);
251 Type *nextOf() { return next; } 259 Type *nextOf() { return next; }
252 260
253 static void error(Loc loc, const char *format, ...); 261 static void error(Loc loc, const char *format, ...);
254 static void warning(Loc loc, const char *format, ...); 262 static void warning(Loc loc, const char *format, ...);
255 263
264 #if IN_DMD
256 // For backend 265 // For backend
257 virtual unsigned totym(); 266 virtual unsigned totym();
258 virtual type *toCtype(); 267 virtual type *toCtype();
259 virtual type *toCParamtype(); 268 virtual type *toCParamtype();
260 virtual Symbol *toSymbol(); 269 virtual Symbol *toSymbol();
270 #endif
261 271
262 // For eliminating dynamic_cast 272 // For eliminating dynamic_cast
263 virtual TypeBasic *isTypeBasic(); 273 virtual TypeBasic *isTypeBasic();
264 274
275 #if IN_LLVM
265 // LDC 276 // LDC
266 IrType ir; 277 IrType ir;
278 #endif
267 }; 279 };
268 280
269 struct TypeBasic : Type 281 struct TypeBasic : Type
270 { 282 {
271 const char *dstring; 283 const char *dstring;
320 int isString(); 332 int isString();
321 int isZeroInit(); 333 int isZeroInit();
322 unsigned memalign(unsigned salign); 334 unsigned memalign(unsigned salign);
323 MATCH implicitConvTo(Type *to); 335 MATCH implicitConvTo(Type *to);
324 Expression *defaultInit(Loc loc); 336 Expression *defaultInit(Loc loc);
337 #if IN_DMD
325 dt_t **toDt(dt_t **pdt); 338 dt_t **toDt(dt_t **pdt);
326 dt_t **toDtElem(dt_t **pdt, Expression *e); 339 dt_t **toDtElem(dt_t **pdt, Expression *e);
340 #endif
327 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 341 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
328 TypeInfoDeclaration *getTypeInfoDeclaration(); 342 TypeInfoDeclaration *getTypeInfoDeclaration();
329 Expression *toExpression(); 343 Expression *toExpression();
330 int hasPointers(); 344 int hasPointers();
331 345
346 #if IN_DMD
332 type *toCtype(); 347 type *toCtype();
333 type *toCParamtype(); 348 type *toCParamtype();
349 #endif
334 }; 350 };
335 351
336 // Dynamic array, no dimension 352 // Dynamic array, no dimension
337 struct TypeDArray : TypeArray 353 struct TypeDArray : TypeArray
338 { 354 {
351 Expression *defaultInit(Loc loc); 367 Expression *defaultInit(Loc loc);
352 int builtinTypeInfo(); 368 int builtinTypeInfo();
353 TypeInfoDeclaration *getTypeInfoDeclaration(); 369 TypeInfoDeclaration *getTypeInfoDeclaration();
354 int hasPointers(); 370 int hasPointers();
355 371
356 type *toCtype(); 372 #if IN_DMD
373 type *toCtype();
374 #endif
357 }; 375 };
358 376
359 struct TypeAArray : TypeArray 377 struct TypeAArray : TypeArray
360 { 378 {
361 Type *index; // key type for type checking 379 Type *index; // key type for type checking
374 int isZeroInit(); 392 int isZeroInit();
375 int checkBoolean(); 393 int checkBoolean();
376 TypeInfoDeclaration *getTypeInfoDeclaration(); 394 TypeInfoDeclaration *getTypeInfoDeclaration();
377 int hasPointers(); 395 int hasPointers();
378 396
397 #if IN_DMD
379 // Back end 398 // Back end
380 Symbol *aaGetSymbol(const char *func, int flags); 399 Symbol *aaGetSymbol(const char *func, int flags);
381 400
382 type *toCtype(); 401 type *toCtype();
402 #endif
383 }; 403 };
384 404
385 struct TypePointer : Type 405 struct TypePointer : Type
386 { 406 {
387 TypePointer(Type *t); 407 TypePointer(Type *t);
396 Expression *defaultInit(Loc loc); 416 Expression *defaultInit(Loc loc);
397 int isZeroInit(); 417 int isZeroInit();
398 TypeInfoDeclaration *getTypeInfoDeclaration(); 418 TypeInfoDeclaration *getTypeInfoDeclaration();
399 int hasPointers(); 419 int hasPointers();
400 420
401 type *toCtype(); 421 #if IN_DMD
422 type *toCtype();
423 #endif
402 }; 424 };
403 425
404 struct TypeReference : Type 426 struct TypeReference : Type
405 { 427 {
406 TypeReference(Type *t); 428 TypeReference(Type *t);
436 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 458 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
437 TypeInfoDeclaration *getTypeInfoDeclaration(); 459 TypeInfoDeclaration *getTypeInfoDeclaration();
438 Type *reliesOnTident(); 460 Type *reliesOnTident();
439 461
440 int callMatch(Expressions *toargs); 462 int callMatch(Expressions *toargs);
441 type *toCtype(); 463 #if IN_DMD
464 type *toCtype();
465 #endif
466
442 enum RET retStyle(); 467 enum RET retStyle();
443 468
469 #if IN_DMD
444 unsigned totym(); 470 unsigned totym();
445 471 #elif IN_LLVM
446 // LDC 472 // LDC
447 IrFuncTy fty; 473 IrFuncTy fty;
474 #endif
448 }; 475 };
449 476
450 struct TypeDelegate : Type 477 struct TypeDelegate : Type
451 { 478 {
452 TypeDelegate(Type *t); 479 TypeDelegate(Type *t);
460 int checkBoolean(); 487 int checkBoolean();
461 TypeInfoDeclaration *getTypeInfoDeclaration(); 488 TypeInfoDeclaration *getTypeInfoDeclaration();
462 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 489 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
463 int hasPointers(); 490 int hasPointers();
464 491
465 type *toCtype(); 492 #if IN_DMD
493 type *toCtype();
494 #endif
466 }; 495 };
467 496
468 struct TypeQualified : Type 497 struct TypeQualified : Type
469 { 498 {
470 Loc loc; 499 Loc loc;
541 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 570 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
542 unsigned memalign(unsigned salign); 571 unsigned memalign(unsigned salign);
543 Expression *defaultInit(Loc loc); 572 Expression *defaultInit(Loc loc);
544 int isZeroInit(); 573 int isZeroInit();
545 int checkBoolean(); 574 int checkBoolean();
575 #if IN_DMD
546 dt_t **toDt(dt_t **pdt); 576 dt_t **toDt(dt_t **pdt);
547 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 577 #endif
548 TypeInfoDeclaration *getTypeInfoDeclaration(); 578 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
549 int hasPointers(); 579 TypeInfoDeclaration *getTypeInfoDeclaration();
550 580 int hasPointers();
551 type *toCtype(); 581
552 582 #if IN_DMD
583 type *toCtype();
584 #elif IN_LLVM
553 // LDC 585 // LDC
554 // cache the hasUnalignedFields check 586 // cache the hasUnalignedFields check
555 // 0 = not checked, 1 = aligned, 2 = unaligned 587 // 0 = not checked, 1 = aligned, 2 = unaligned
556 int unaligned; 588 int unaligned;
589 #endif
557 }; 590 };
558 591
559 struct TypeEnum : Type 592 struct TypeEnum : Type
560 { 593 {
561 EnumDeclaration *sym; 594 EnumDeclaration *sym;
581 int isZeroInit(); 614 int isZeroInit();
582 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 615 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
583 TypeInfoDeclaration *getTypeInfoDeclaration(); 616 TypeInfoDeclaration *getTypeInfoDeclaration();
584 int hasPointers(); 617 int hasPointers();
585 618
586 type *toCtype(); 619 #if IN_DMD
620 type *toCtype();
621 #endif
587 }; 622 };
588 623
589 struct TypeTypedef : Type 624 struct TypeTypedef : Type
590 { 625 {
591 TypedefDeclaration *sym; 626 TypedefDeclaration *sym;
612 int checkBoolean(); 647 int checkBoolean();
613 Type *toBasetype(); 648 Type *toBasetype();
614 MATCH implicitConvTo(Type *to); 649 MATCH implicitConvTo(Type *to);
615 Expression *defaultInit(Loc loc); 650 Expression *defaultInit(Loc loc);
616 int isZeroInit(); 651 int isZeroInit();
652 #if IN_DMD
617 dt_t **toDt(dt_t **pdt); 653 dt_t **toDt(dt_t **pdt);
618 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 654 #endif
619 TypeInfoDeclaration *getTypeInfoDeclaration(); 655 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
620 int hasPointers(); 656 TypeInfoDeclaration *getTypeInfoDeclaration();
621 657 int hasPointers();
658
659 #if IN_DMD
622 type *toCtype(); 660 type *toCtype();
623 type *toCParamtype(); 661 type *toCParamtype();
662 #endif
624 }; 663 };
625 664
626 struct TypeClass : Type 665 struct TypeClass : Type
627 { 666 {
628 ClassDeclaration *sym; 667 ClassDeclaration *sym;
645 int isauto(); 684 int isauto();
646 int checkBoolean(); 685 int checkBoolean();
647 TypeInfoDeclaration *getTypeInfoDeclaration(); 686 TypeInfoDeclaration *getTypeInfoDeclaration();
648 int hasPointers(); 687 int hasPointers();
649 688
689 #if IN_DMD
650 type *toCtype(); 690 type *toCtype();
651 691
652 Symbol *toSymbol(); 692 Symbol *toSymbol();
693 #endif
653 }; 694 };
654 695
655 struct TypeTuple : Type 696 struct TypeTuple : Type
656 { 697 {
657 Arguments *arguments; // types making up the tuple 698 Arguments *arguments; // types making up the tuple