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