Mercurial > projects > ldc
comparison tango/lib/compiler/llvmdc/lifetime.d @ 133:44a95ac7368a trunk
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
In particular, assertions has been fixed to include file/line info, and much more!
author | lindquist |
---|---|
date | Mon, 14 Jan 2008 05:11:54 +0100 |
parents | 1700239cab2e |
children | ce7b81fb957f |
comparison
equal
deleted
inserted
replaced
132:1700239cab2e | 133:44a95ac7368a |
---|---|
24 * distribution. | 24 * distribution. |
25 * Authors: Walter Bright, Sean Kelly, Tomas Lindquist Olsen | 25 * Authors: Walter Bright, Sean Kelly, Tomas Lindquist Olsen |
26 */ | 26 */ |
27 module lifetime; | 27 module lifetime; |
28 | 28 |
29 //debug=PRINTF; | |
30 debug=PRINTF2; | |
29 | 31 |
30 private | 32 private |
31 { | 33 { |
32 import tango.stdc.stdlib; | 34 import tango.stdc.stdlib; |
33 import tango.stdc.string; | 35 import tango.stdc.string; |
34 import tango.stdc.stdarg; | 36 import tango.stdc.stdarg; |
35 debug(PRINTF) import tango.stdc.stdio; | 37 debug(PRINTF) import tango.stdc.stdio; |
38 else debug(PRINTF2) import tango.stdc.stdio; | |
36 } | 39 } |
37 | 40 |
38 | 41 |
39 private | 42 private |
40 { | 43 { |
84 */ | 87 */ |
85 extern (C) Object _d_newclass(ClassInfo ci) | 88 extern (C) Object _d_newclass(ClassInfo ci) |
86 { | 89 { |
87 void* p; | 90 void* p; |
88 | 91 |
89 debug(PRINTF) printf("_d_newclass(ci = %p, %s)\n", ci, cast(char *)ci.name); | 92 debug(PRINTF) printf("_d_newclass(ci = %p, %s)\n", ci, cast(char *)ci.name.ptr); |
93 /+ | |
90 if (ci.flags & 1) // if COM object | 94 if (ci.flags & 1) // if COM object |
91 { /* COM objects are not garbage collected, they are reference counted | 95 { /* COM objects are not garbage collected, they are reference counted |
92 * using AddRef() and Release(). They get free'd by C's free() | 96 * using AddRef() and Release(). They get free'd by C's free() |
93 * function called by Release() when Release()'s reference count goes | 97 * function called by Release() when Release()'s reference count goes |
94 * to zero. | 98 * to zero. |
96 p = tango.stdc.stdlib.malloc(ci.init.length); | 100 p = tango.stdc.stdlib.malloc(ci.init.length); |
97 if (!p) | 101 if (!p) |
98 onOutOfMemoryError(); | 102 onOutOfMemoryError(); |
99 } | 103 } |
100 else | 104 else |
105 +/ | |
101 { | 106 { |
102 p = gc_malloc(ci.init.length, | 107 p = gc_malloc(ci.init.length, |
103 BlkAttr.FINALIZE | (ci.flags & 2 ? BlkAttr.NO_SCAN : 0)); | 108 BlkAttr.FINALIZE | (ci.flags & 2 ? BlkAttr.NO_SCAN : 0)); |
104 debug(PRINTF) printf(" p = %p\n", p); | 109 debug(PRINTF2) printf(" p = %p\n", p); |
105 } | 110 } |
106 | 111 |
107 debug(PRINTF) | 112 debug(PRINTF) |
108 { | 113 { |
109 printf("p = %p\n", p); | 114 printf("p = %p\n", p); |
117 printf("init[3] = %x\n", (cast(uint*) ci.init)[3]); | 122 printf("init[3] = %x\n", (cast(uint*) ci.init)[3]); |
118 printf("init[4] = %x\n", (cast(uint*) ci.init)[4]); | 123 printf("init[4] = %x\n", (cast(uint*) ci.init)[4]); |
119 } | 124 } |
120 | 125 |
121 // initialize it | 126 // initialize it |
122 (cast(byte*) p)[0 .. ci.init.length] = ci.init[]; | 127 // llvmdc does this inline |
128 //(cast(byte*) p)[0 .. ci.init.length] = ci.init[]; | |
123 | 129 |
124 debug(PRINTF) printf("initialization done\n"); | 130 debug(PRINTF) printf("initialization done\n"); |
125 return cast(Object) p; | 131 return cast(Object) p; |
126 } | 132 } |
127 | 133 |