Mercurial > projects > ddmd
annotate dmd/backend/Symbol.d @ 69:c876339731a4
dead code removed
author | korDen |
---|---|
date | Tue, 24 Aug 2010 16:59:45 +0400 |
parents | fd4acc376c45 |
children | e28b18c23469 |
rev | line source |
---|---|
0 | 1 module dmd.backend.Symbol; |
2 | |
3 import dmd.backend.dt_t; | |
4 import dmd.backend.TYPE; | |
5 import dmd.backend.LIST; | |
6 import dmd.backend.block; | |
7 import dmd.backend.func_t; | |
8 import dmd.backend.enum_t; | |
9 import dmd.backend.elem; | |
10 import dmd.backend.struct_t; | |
11 import dmd.backend.template_t; | |
12 import dmd.backend.targ_types; | |
13 import dmd.backend.vec_t; | |
14 import dmd.backend.SYMIDX; | |
15 import dmd.backend.regm_t; | |
16 import dmd.backend.Util; | |
17 | |
18 struct Symbol | |
19 { | |
20 ushort id; | |
21 | |
22 Symbol* Sl; | |
23 Symbol* Sr; // left, right child | |
24 | |
25 Symbol *Snext; // next in threaded list | |
26 | |
27 dt_t* Sdt; // variables: initializer | |
28 type* Stype; // type of Symbol | |
29 | |
30 tym_t ty() | |
31 { | |
32 return Stype.Tty; | |
33 } | |
34 | |
35 union // variants for different Symbol types | |
36 { | |
37 enum_t* Senum; // SCenum | |
38 struct | |
39 { | |
40 func_t* Sfunc; // tyfunc | |
41 list_t Spath1; // SCfuncalias member functions: same as Spath | |
42 // and in same position | |
43 // SCadl: list of associated functions for ADL lookup | |
44 } | |
45 struct // SClabel | |
46 { | |
47 int Slabel; // TRUE if label was defined | |
48 block* Slabelblk; // label block | |
49 } | |
50 /// #define Senumlist Senum->SEenumlist | |
51 | |
52 struct // SClinkage | |
53 { | |
54 int Slinkage; // tym linkage bits | |
55 uint Smangle; | |
56 } | |
57 | |
58 struct | |
59 { | |
60 char Sbit; // SCfield: bit position of start of bit field | |
61 char Swidth; // SCfield: width in bits of bit field | |
62 targ_size_t Smemoff; // SCmember,SCfield: offset from start of struct | |
63 } | |
64 | |
65 elem* Svalue; /* SFLvalue: value of const | |
66 SFLdtorexp: for objects with destructor, | |
67 conditional expression to precede dtor call | |
68 */ | |
69 | |
70 struct_t* Sstruct; // SCstruct | |
71 template_t* Stemplate; // SCtemplate | |
72 Symbol* Simport; // SCextern: if dllimport Symbol, this is the | |
73 // Symbol it was imported from | |
74 | |
75 ubyte Spreg; // SCfastpar: register parameter is passed in | |
76 } | |
77 | |
78 Symbol* Sscope; // enclosing scope (could be struct tag, | |
79 // enclosing inline function for statics, | |
80 // or namespace) | |
81 ///#define isclassmember(s) ((s)->Sscope && (s)->Sscope->Sclass == SCstruct) | |
82 | |
83 const(char)* prettyIdent; // the symbol identifer as the user sees it | |
84 | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
85 version (ELFOBJ_OR_MACHOBJ) |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
86 { |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
87 ptrdiff_t obj_si; // Symbol index of coff or elf symbol |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
88 size_t dwarf_off; // offset into .debug section |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
89 targ_size_t code_off; // rel. offset from start of block where var is initialized |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
90 targ_size_t last_off; // last offset using var |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
91 } |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
92 version (TARGET_OSX) |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
93 { |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
94 targ_size_t Slocalgotoffset; |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
95 } |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
96 |
0 | 97 enum_SC Sclass; // storage class (SCxxxx) |
98 char Sfl; // flavor (FLxxxx) | |
99 SYMFLGS Sflags; // flag bits (SFLxxxx) | |
100 | |
101 vec_t Srange; // live range, if any | |
102 vec_t Slvreg; // when symbol is in register | |
103 targ_size_t Ssize; // tyfunc: size of function | |
104 targ_size_t Soffset; // variables: offset of Symbol in its storage class | |
105 | |
106 SYMIDX Ssymnum; // Symbol number (index into globsym.tab[]) | |
107 // SCauto,SCparameter,SCtmp,SCregpar,SCregister | |
108 | |
109 short Sseg; // segment index | |
110 | |
111 int Sweight; // usage count, the higher the number, | |
112 // the more worthwhile it is to put in | |
113 // a register | |
114 union | |
115 { | |
116 uint Sxtrnnum; // SCcomdef,SCextern,SCcomdat: external symbol # (starting from 1) | |
117 uint Stypidx; // SCstruct,SCunion,SCclass,SCenum,SCtypedef: debug info type index | |
118 | |
119 struct | |
120 { | |
121 ubyte Sreglsw; | |
122 ubyte Sregmsw; | |
123 regm_t Sregm; // mask of registers | |
124 } | |
125 } | |
126 | |
127 regm_t Sregsaved; // mask of registers not affected by this func | |
128 | |
129 char Sident[35]; // identifier string (dynamic array) | |
130 // (the size is for static Symbols) | |
131 | |
132 bool needThis() // true if symbol needs a 'this' pointer | |
133 { | |
134 assert(false); | |
135 } | |
136 } | |
137 | |
138 void dumpSymbol(Symbol* foo) | |
139 { | |
140 foreach (a, b; foo.tupleof) | |
141 { | |
142 static if (typeof(foo.tupleof[a]).stringof != "char[35u]") { | |
143 std.stdio.writeln(foo.tupleof[a].stringof, " ", cast(char*)&foo.tupleof[a] - cast(char*)foo, " = ", cast(int)foo.tupleof[a]); | |
144 //std.stdio.writeln("printf(\"", foo.tupleof[a].stringof, " %d = %d\\n\",(char*)(&", foo.tupleof[a].stringof, ")-(char*)foo, ", foo.tupleof[a].stringof, ");"); | |
145 } | |
146 } | |
147 | |
148 std.stdio.writefln("(*foo).Sclass %d = %d", (cast(char*)&foo.Sclass - cast(char*)foo), cast(int)foo.Sclass); | |
149 //std.stdio.writeln("printf(\"(*foo).Sclass %d %d\\n\", ((char*)&foo->Sclass - (char*)foo), (int)foo->Sclass);"); | |
69 | 150 } |