annotate dmd/backend/TYPE.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 3f834bed4f13
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 25
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.backend.Srcpos;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.backend.LIST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.backend.PARAM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.backend.targ_types;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.backend.Classsym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 struct TYPE
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 ushort id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 enum IDtype = 0x1234;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 ///#define type_debug(t) assert((t)->id == IDtype)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 ///#define type_debug(t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 tym_t Tty; /* mask (TYxxx) */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 ushort Tflags; // TFxxxxx
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 version (TX86) {
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 16
diff changeset
27 version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 ///#define mTYnoret 0x010000 // function has no return
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 ///#define mTYtransu 0x010000 // transparent union
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 ///#define mTYfar16 0x010000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 ///#define mTYstdcall 0x020000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 ///#define mTYfastcall 0x040000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 ///#define mTYinterrupt 0x080000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 ///#define mTYcdecl 0x100000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 ///#define mTYpascal 0x200000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 ///#define mTYsyscall 0x400000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 ///#define mTYjava 0x800000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 16
diff changeset
41 version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 ///#define mTYTFF 0xFE0000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 ///#define mTYTFF 0xFF0000
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 ///#define TARGET_strucTYPE
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 mangle_t Tmangle; // name mangling
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 // Return name mangling of type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 ///#define type_mangle(t) ((t)->Tmangle)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 uint Tcount; // # pointing to this type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 TYPE* Tnext; // next in list
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 // TYenum: gives base type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 union
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 targ_size_t Tdim; // TYarray: # of elements in array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 elem* Tel; // TFvla: gives dimension (NULL if '*')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 PARAM* Tparamtypes; // TYfunc, TYtemplate: types of function parameters
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 Classsym* Ttag; // TYstruct,TYmemptr: tag symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 // TYenum,TYvtshape: tag symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 char* Tident; // TYident: identifier
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 version (SCPP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 TYPE* Talternate; // typtr: type of parameter before converting
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 version (MARS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 TYPE* Tkey; // typtr: key type for associative arrays
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 list_t Texcspec; // tyfunc(): list of types of exception specification
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 ushort Tstabidx; // Index into stab types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 /// TARGET_strucTYPE
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 version (SOURCE_4TYPES) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 Srcpos Tsrcpos; /* position of type definition */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 version (HTOD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 Symbol* Ttypedef; // if this type came from a typedef, this is
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 // the typedef symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 void dumpTYPE(TYPE* foo)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 foreach (a, b; foo.tupleof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 std.stdio.writeln(foo.tupleof[a].stringof, " ", cast(char*)&foo.tupleof[a] - cast(char*)foo, " = ", foo.tupleof[a]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 //std.stdio.writeln("printf(\"", foo.tupleof[a].stringof, " %d = %d\\n\",(char*)(&", foo.tupleof[a].stringof, ")-(char*)foo, ", foo.tupleof[a].stringof, ");");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 alias TYPE type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 alias type* typep_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
101 version (Windows) {
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
102 extern(C++) extern __gshared typep_t tstypes[TYM.TYMAX];
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
103 extern(C++) extern __gshared typep_t tsptr2types[TYM.TYMAX];
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
104 } else {
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
105 extern(C) extern __gshared typep_t tstypes[TYM.TYMAX];
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
106 extern(C) extern __gshared typep_t tsptr2types[TYM.TYMAX];
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
107 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 ref type* tsbool () { return tstypes[TYM.TYbool]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 ref type* tschar () { return tstypes[TYM.TYchar]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 ref type* tsschar () { return tstypes[TYM.TYschar]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 ref type* tsuchar () { return tstypes[TYM.TYuchar]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 ref type* tsshort () { return tstypes[TYM.TYshort]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 ref type* tsushort () { return tstypes[TYM.TYushort]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 ref type* tswchar_t () { return tstypes[TYM.TYwchar_t]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 ref type* tsint () { return tstypes[TYM.TYint]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 ref type* tsuns () { return tstypes[TYM.TYuint]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 ref type* tslong () { return tstypes[TYM.TYlong]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 ref type* tsulong () { return tstypes[TYM.TYulong]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 ref type* tsdchar () { return tstypes[TYM.TYdchar]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 ref type* tsllong () { return tstypes[TYM.TYllong]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 ref type* tsullong () { return tstypes[TYM.TYullong]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 ref type* tsfloat () { return tstypes[TYM.TYfloat]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 ref type* tsdouble () { return tstypes[TYM.TYdouble]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 ref type* tsreal64 () { return tstypes[TYM.TYdouble_alias]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 ref type* tsldouble () { return tstypes[TYM.TYldouble]; }
16
5c9b78899f5d Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents: 14
diff changeset
127 ref type* tsvoid () { return tstypes[TYM.TYvoid]; }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 ref type* tsifloat () { return tstypes[TYM.TYifloat]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 ref type* tsidouble () { return tstypes[TYM.TYidouble]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 ref type* tsildouble () { return tstypes[TYM.TYildouble]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 ref type* tscfloat () { return tstypes[TYM.TYcfloat]; }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 ref type* tscdouble () { return tstypes[TYM.TYcdouble]; }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
133 ref type* tscldouble () { return tstypes[TYM.TYcldouble]; }