Mercurial > projects > ddmd
comparison dmd/TypeInfoStructDeclaration.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | e8a741997ccf |
children | fa9a71a9f5a8 |
comparison
equal
deleted
inserted
replaced
173:d237b38b5858 | 174:af724d3510d7 |
---|---|
14 import dmd.Dsymbol; | 14 import dmd.Dsymbol; |
15 import dmd.ArrayTypes; | 15 import dmd.ArrayTypes; |
16 import dmd.Scope; | 16 import dmd.Scope; |
17 import dmd.LINK; | 17 import dmd.LINK; |
18 import dmd.Id; | 18 import dmd.Id; |
19 import dmd.Global; | |
19 import dmd.TypeInfoDeclaration; | 20 import dmd.TypeInfoDeclaration; |
20 import dmd.backend.dt_t; | 21 import dmd.backend.dt_t; |
21 import dmd.backend.TYM; | 22 import dmd.backend.TYM; |
22 import dmd.backend.Util; | 23 import dmd.backend.Util; |
23 import dmd.expression.Util; | 24 import dmd.expression.Util; |
27 class TypeInfoStructDeclaration : TypeInfoDeclaration | 28 class TypeInfoStructDeclaration : TypeInfoDeclaration |
28 { | 29 { |
29 this(Type tinfo) | 30 this(Type tinfo) |
30 { | 31 { |
31 super(tinfo, 0); | 32 super(tinfo, 0); |
32 type = Type.typeinfostruct.type; | 33 type = global.typeinfostruct.type; |
33 } | 34 } |
35 | |
36 static __gshared TypeFunction tftohash; | |
37 static __gshared TypeFunction tftostring; | |
34 | 38 |
35 override void toDt(dt_t** pdt) | 39 override void toDt(dt_t** pdt) |
36 { | 40 { |
37 //printf("TypeInfoStructDeclaration.toDt() '%s'\n", toChars()); | 41 //printf("TypeInfoStructDeclaration.toDt() '%s'\n", toChars()); |
38 | 42 |
39 uint offset = Type.typeinfostruct.structsize; | 43 uint offset = global.typeinfostruct.structsize; |
40 | 44 |
41 dtxoff(pdt, Type.typeinfostruct.toVtblSymbol(), 0, TYM.TYnptr); // vtbl for TypeInfo_Struct | 45 dtxoff(pdt, global.typeinfostruct.toVtblSymbol(), 0, TYM.TYnptr); // vtbl for TypeInfo_Struct |
42 dtdword(pdt, 0); // monitor | 46 dtdword(pdt, 0); // monitor |
43 | 47 |
44 assert(tinfo.ty == TY.Tstruct); | 48 assert(tinfo.ty == TY.Tstruct); |
45 | 49 |
46 TypeStruct tc = cast(TypeStruct)tinfo; | 50 TypeStruct tc = cast(TypeStruct)tinfo; |
79 FuncDeclaration fdx; | 83 FuncDeclaration fdx; |
80 TypeFunction tf; | 84 TypeFunction tf; |
81 Type ta; | 85 Type ta; |
82 Dsymbol s; | 86 Dsymbol s; |
83 | 87 |
84 static TypeFunction tftohash; | |
85 static TypeFunction tftostring; | |
86 | |
87 if (!tftohash) | 88 if (!tftohash) |
88 { | 89 { |
89 scope Scope sc = new Scope(); | 90 scope Scope sc = new Scope(); |
90 | 91 |
91 tftohash = new TypeFunction(null, Type.thash_t, 0, LINK.LINKd); | 92 tftohash = new TypeFunction(null, Type.thash_t, 0, LINK.LINKd); |
95 tftostring = new TypeFunction(null, Type.tchar.invariantOf().arrayOf(), 0, LINK.LINKd); | 96 tftostring = new TypeFunction(null, Type.tchar.invariantOf().arrayOf(), 0, LINK.LINKd); |
96 tftostring = cast(TypeFunction)tftostring.semantic(Loc(0), sc); | 97 tftostring = cast(TypeFunction)tftostring.semantic(Loc(0), sc); |
97 } | 98 } |
98 | 99 |
99 TypeFunction tfeqptr; | 100 TypeFunction tfeqptr; |
100 { | 101 { |
101 // bool opEqual(const T*) const; | 102 // bool opEqual(const T*) const; |
102 scope sc = new Scope(); | 103 scope sc = new Scope(); |
103 auto arguments = new Parameters; | 104 auto arguments = new Parameters; |
104 version (STRUCTTHISREF) { | 105 version (STRUCTTHISREF) { |
105 // arg type is ref const T | 106 // arg type is ref const T |
151 } | 152 } |
152 | 153 |
153 s = search_function(sd, Id.tohash); | 154 s = search_function(sd, Id.tohash); |
154 fdx = s ? s.isFuncDeclaration() : null; | 155 fdx = s ? s.isFuncDeclaration() : null; |
155 if (fdx) | 156 if (fdx) |
156 { | 157 { |
157 fd = fdx.overloadExactMatch(tftohash); | 158 fd = fdx.overloadExactMatch(tftohash); |
158 if (fd) | 159 if (fd) |
159 dtxoff(pdt, fd.toSymbol(), 0, TYM.TYnptr); | 160 dtxoff(pdt, fd.toSymbol(), 0, TYM.TYnptr); |
160 else | 161 else |
161 //fdx.error("must be declared as extern (D) uint toHash()"); | 162 //fdx.error("must be declared as extern (D) uint toHash()"); |
184 //fdx.error("must be declared as extern (D) int %s(%s*)", fdx.toChars(), sd.toChars()); | 185 //fdx.error("must be declared as extern (D) int %s(%s*)", fdx.toChars(), sd.toChars()); |
185 dtdword(pdt, 0); | 186 dtdword(pdt, 0); |
186 } | 187 } |
187 else | 188 else |
188 dtdword(pdt, 0); | 189 dtdword(pdt, 0); |
189 | 190 |
190 s = search_function(sd, Id.tostring); | 191 s = search_function(sd, Id.tostring); |
191 fdx = s ? s.isFuncDeclaration() : null; | 192 fdx = s ? s.isFuncDeclaration() : null; |
192 if (fdx) | 193 if (fdx) |
193 { | 194 { |
194 fd = fdx.overloadExactMatch(tftostring); | 195 fd = fdx.overloadExactMatch(tftostring); |
195 if (fd) | 196 if (fd) |
196 dtxoff(pdt, fd.toSymbol(), 0, TYM.TYnptr); | 197 dtxoff(pdt, fd.toSymbol(), 0, TYM.TYnptr); |
197 else | 198 else |
198 //fdx.error("must be declared as extern (D) char[] toString()"); | 199 //fdx.error("must be declared as extern (D) char[] toString()"); |