comparison tango/tango/text/convert/Layout.d @ 213:7816aafeea3c trunk

[svn r229] Updated the object.d implementation to the latest Tango. Fixed a bunch of the built-in typeinfos for arrays, they did not inherit TypeInfo_Array. Applied patch to tango/text/convert/Layout.d by fvbommel, closes #47 . Cleaned up some type code. Replaced uses of llvm::Type with LLType (a typedef), same for Value and Constant. Fixed a few cases where typeinfo for user structs could be emitted multiple times, seems to still be some cases of this :/
author lindquist
date Fri, 30 May 2008 19:32:04 +0200
parents a8cd9bc1021a
children a9dae3da4e87
comparison
equal deleted inserted replaced
212:4c2689d57ba4 213:7816aafeea3c
191 public final uint convert (Sink sink, TypeInfo[] arguments, ArgList args, T[] formatStr) 191 public final uint convert (Sink sink, TypeInfo[] arguments, ArgList args, T[] formatStr)
192 { 192 {
193 assert (formatStr, "null format specifier"); 193 assert (formatStr, "null format specifier");
194 assert (arguments.length < 64, "too many args in Layout.convert"); 194 assert (arguments.length < 64, "too many args in Layout.convert");
195 195
196 version (X86_64) 196 version (LLVMDC)
197 { 197 {
198 static va_list get_va_arg(TypeInfo ti, ref va_list vp)
199 {
200 auto tisize = ti.tsize;
201 size_t size = tisize > size_t.sizeof ? size_t.sizeof : tisize;
202 va_list vptmp = cast(va_list)((cast(size_t)vp + size - 1) & ~(size - 1));
203 vp = vptmp + tisize;
204 return vptmp;
205 }
206
207 Arg[64] arglist = void;
208 foreach (i, arg; arguments)
209 {
210 arglist[i] = get_va_arg(arg, args);
211 }
212 }
213 else version (X86_64)
214 {
215 // code for x86-64 GDC
198 Arg[64] arglist = void; 216 Arg[64] arglist = void;
199 int[64] intargs = void; 217 int[64] intargs = void;
200 byte[64] byteargs = void; 218 byte[64] byteargs = void;
201 long[64] longargs = void; 219 long[64] longargs = void;
202 short[64] shortargs = void; 220 short[64] shortargs = void;
263 assert (false, "Unknown size: " ~ Integer.toString (arg.tsize)); 281 assert (false, "Unknown size: " ~ Integer.toString (arg.tsize));
264 } 282 }
265 } 283 }
266 } 284 }
267 } 285 }
268 else version (LLVMDC)
269 {
270 static va_list get_va_arg(TypeInfo ti, ref va_list vp)
271 {
272 auto tisize = ti.tsize;
273 size_t size = tisize > size_t.sizeof ? size_t.sizeof : tisize;
274 va_list vptmp = cast(va_list)((cast(size_t)vp + size - 1) & ~(size - 1));
275 vp = vptmp + tisize;
276 return vptmp;
277 }
278
279 Arg[64] arglist = void;
280 foreach (i, arg; arguments)
281 {
282 arglist[i] = get_va_arg(arg, args);
283 }
284 }
285 else 286 else
286 { 287 {
288 // code for DMD & x86 GDC (may also work on other 32-bit targets)
287 Arg[64] arglist = void; 289 Arg[64] arglist = void;
288 foreach (i, arg; arguments) 290 foreach (i, arg; arguments)
289 { 291 {
290 arglist[i] = args; 292 arglist[i] = args;
291 args += (arg.tsize + int.sizeof - 1) & ~ (int.sizeof - 1); 293 args += (arg.tsize + int.sizeof - 1) & ~ (int.sizeof - 1);