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