Mercurial > projects > ddmd
comparison dmd/Type.d @ 176:fa9a71a9f5a8
Moved all the mutable globals to Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 05:22:45 +0400 |
parents | af724d3510d7 |
children | 1475fd394c9e |
comparison
equal
deleted
inserted
replaced
175:94b6033c07f3 | 176:fa9a71a9f5a8 |
---|---|
257 Type arrayof; // array of this type | 257 Type arrayof; // array of this type |
258 TypeInfoDeclaration vtinfo; // TypeInfo object for this Type | 258 TypeInfoDeclaration vtinfo; // TypeInfo object for this Type |
259 | 259 |
260 type* ctype; // for back end | 260 type* ctype; // for back end |
261 | 261 |
262 static __gshared Type basic[TY.TMAX]; | |
263 static __gshared ubyte mangleChar[TY.TMAX]; | 262 static __gshared ubyte mangleChar[TY.TMAX]; |
264 static __gshared ubyte sizeTy[TY.TMAX]; | 263 static __gshared ubyte sizeTy[TY.TMAX]; |
265 | 264 |
266 // These tables are for implicit conversion of binary ops; | 265 // These tables are for implicit conversion of binary ops; |
267 // the indices are the type of operand one, followed by operand two. | 266 // the indices are the type of operand one, followed by operand two. |
738 basic[bt] = t; | 737 basic[bt] = t; |
739 } | 738 } |
740 | 739 |
741 basic[TY.Terror] = basic[TY.Tint32]; | 740 basic[TY.Terror] = basic[TY.Tint32]; |
742 | 741 |
743 tvoidptr = tvoid.pointerTo(); | 742 global.tvoidptr = tvoid.pointerTo(); |
744 tstring = tchar.invariantOf().arrayOf(); | 743 global.tstring = tchar.invariantOf().arrayOf(); |
745 | 744 |
746 if (global.params.isX86_64) { | 745 if (global.params.isX86_64) { |
747 PTRSIZE = 8; | 746 PTRSIZE = 8; |
748 if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris) | 747 if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris) |
749 REALSIZE = 10; | 748 REALSIZE = 10; |
2501 Type t = semantic(loc, sc); | 2500 Type t = semantic(loc, sc); |
2502 *pt = t; | 2501 *pt = t; |
2503 *pe = null; | 2502 *pe = null; |
2504 *ps = null; | 2503 *ps = null; |
2505 } | 2504 } |
2506 | |
2507 static __gshared TypeInfoDeclaration internalTI[TMAX]; | |
2508 | 2505 |
2509 /******************************************* | 2506 /******************************************* |
2510 * Get a canonicalized form of the TypeInfo for use with the internal | 2507 * Get a canonicalized form of the TypeInfo for use with the internal |
2511 * runtime library routines. Canonicalized in that static arrays are | 2508 * runtime library routines. Canonicalized in that static arrays are |
2512 * represented as dynamic arrays, enums are represented by their | 2509 * represented as dynamic arrays, enums are represented by their |
2544 | 2541 |
2545 case Tfunction: | 2542 case Tfunction: |
2546 case Tdelegate: | 2543 case Tdelegate: |
2547 case Tpointer: | 2544 case Tpointer: |
2548 Linternal: | 2545 Linternal: |
2549 tid = internalTI[t.ty]; | 2546 tid = global.internalTI[t.ty]; |
2550 if (!tid) | 2547 if (!tid) |
2551 { | 2548 { |
2552 tid = new TypeInfoDeclaration(t, 1); | 2549 tid = new TypeInfoDeclaration(t, 1); |
2553 internalTI[t.ty] = tid; | 2550 global.internalTI[t.ty] = tid; |
2554 } | 2551 } |
2555 e = new VarExp(Loc(0), tid); | 2552 e = new VarExp(Loc(0), tid); |
2556 e = e.addressOf(sc); | 2553 e = e.addressOf(sc); |
2557 e.type = tid.type; // do this so we don't get redundant dereference | 2554 e.type = tid.type; // do this so we don't get redundant dereference |
2558 return e; | 2555 return e; |
2848 // For eliminating dynamic_cast | 2845 // For eliminating dynamic_cast |
2849 TypeBasic isTypeBasic() | 2846 TypeBasic isTypeBasic() |
2850 { | 2847 { |
2851 return null; | 2848 return null; |
2852 } | 2849 } |
2850 | |
2851 @property | |
2852 static ref Type[TY.TMAX] basic() | |
2853 { | |
2854 return basic; | |
2855 } | |
2853 | 2856 |
2854 static Type tvoid() | 2857 static Type tvoid() |
2855 { | 2858 { |
2856 return basic[TY.Tvoid]; | 2859 return basic[TY.Tvoid]; |
2857 } | 2860 } |
2981 static Type tindex() | 2984 static Type tindex() |
2982 { | 2985 { |
2983 return tint32; // array/ptr index | 2986 return tint32; // array/ptr index |
2984 } | 2987 } |
2985 | 2988 |
2986 static __gshared Type tvoidptr; // void* | |
2987 static __gshared Type tstring; // immutable(char)[] | |
2988 | |
2989 static Type terror() | 2989 static Type terror() |
2990 { | 2990 { |
2991 return basic[TY.Terror]; // for error recovery | 2991 return basic[TY.Terror]; // for error recovery |
2992 } | 2992 } |
2993 | 2993 |