Mercurial > projects > dwt2
comparison base/src/java/lang/System.d @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | bbe49769ec18 |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
111:b6e9904989ed | 112:9f4c18c268b2 |
---|---|
13 static import tango.io.model.IFile; | 13 static import tango.io.model.IFile; |
14 static import tango.time.Clock; | 14 static import tango.time.Clock; |
15 static import tango.stdc.stdlib; | 15 static import tango.stdc.stdlib; |
16 } else { // Phobos | 16 } else { // Phobos |
17 static import std.c.stdlib; | 17 static import std.c.stdlib; |
18 static import std.date; | 18 static import std.datetime; |
19 static import std.path; | 19 static import std.path; |
20 } | 20 } |
21 | 21 |
22 template SimpleType(T) { | 22 template SimpleType(T) { |
23 debug{ | 23 debug{ |
27 assert(0); | 27 assert(0); |
28 } | 28 } |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 static void remove(inout T[] items, int index) { | 32 static void remove(ref T[] items, int index) { |
33 if(items.length == 0) | 33 if(items.length == 0) |
34 return; | 34 return; |
35 | 35 |
36 if(index < 0 || index >= items.length){ | 36 if(index < 0 || index >= items.length){ |
37 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); | 37 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); |
51 items = items[0 .. index]; | 51 items = items[0 .. index]; |
52 else | 52 else |
53 items = items[0 .. index] ~ items[index + 1 .. $]; | 53 items = items[0 .. index] ~ items[index + 1 .. $]; |
54 } | 54 } |
55 | 55 |
56 static void insert(inout T[] items, T item, int index = -1) { | 56 static void insert(ref T[] items, T item, int index = -1) { |
57 if(index == -1) | 57 if(index == -1) |
58 index = items.length; | 58 index = items.length; |
59 | 59 |
60 if(index < 0 || index > items.length ){ | 60 if(index < 0 || index > items.length ){ |
61 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); | 61 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 class System { | 117 class System { |
118 version(D_Version2){ | 118 static void arraycopyT(T)(T[] src, uint srcPos, T[] dest, uint destPos, uint len) { |
119 mixin("alias const(T) CT;"); | 119 if(len == 0) return; |
120 } else { // D1 | 120 |
121 static void arraycopyT(T)(T[] src, uint srcPos, T[] dest, uint destPos, uint len) { | 121 assert(src); |
122 if(len == 0) return; | 122 assert(dest); |
123 | 123 debug{validCheck(src.length - srcPos, dest.length - destPos, len);} |
124 assert(src); | 124 |
125 assert(dest); | 125 // overlapping? |
126 debug{validCheck(src.length - srcPos, dest.length - destPos, len);} | 126 if((src.ptr <= dest.ptr && src.ptr + len > dest.ptr) |
127 | 127 ||(src.ptr >= dest.ptr && src.ptr < dest.ptr + len)){ |
128 // overlapping? | 128 if( destPos < srcPos ){ |
129 if((src.ptr <= dest.ptr && src.ptr + len > dest.ptr) | 129 for(int i=0; i<len; ++i){ |
130 ||(src.ptr >= dest.ptr && src.ptr < dest.ptr + len)){ | 130 dest[destPos+i] = cast(T)src[srcPos+i]; |
131 if( destPos < srcPos ){ | 131 } |
132 for(int i=0; i<len; ++i){ | 132 } |
133 dest[destPos+i] = cast(T)src[srcPos+i]; | 133 else{ |
134 } | 134 for(int i=len-1; i>=0; --i){ |
135 } | 135 dest[destPos+i] = cast(T)src[srcPos+i]; |
136 else{ | 136 } |
137 for(int i=len-1; i>=0; --i){ | 137 } |
138 dest[destPos+i] = cast(T)src[srcPos+i]; | 138 }else{ |
139 } | 139 dest[destPos..(len+destPos)] = cast(T[])src[srcPos..(len+srcPos)]; |
140 } | |
141 }else{ | |
142 dest[destPos..(len+destPos)] = cast(T[])src[srcPos..(len+srcPos)]; | |
143 } | |
144 } | 140 } |
145 } | 141 } |
146 | 142 |
147 alias SimpleType!(int).arraycopy arraycopy; | 143 alias SimpleType!(int).arraycopy arraycopy; |
148 alias SimpleType!(byte).arraycopy arraycopy; | 144 alias SimpleType!(byte).arraycopy arraycopy; |
175 alias SimpleType!(void*[]).arraycopy arraycopy; | 171 alias SimpleType!(void*[]).arraycopy arraycopy; |
176 alias SimpleType!(void*[]).arraycopy arraycopy; | 172 alias SimpleType!(void*[]).arraycopy arraycopy; |
177 | 173 |
178 static long currentTimeMillis(){ | 174 static long currentTimeMillis(){ |
179 version(Tango) return tango.time.Clock.Clock.now().ticks() / 10000; | 175 version(Tango) return tango.time.Clock.Clock.now().ticks() / 10000; |
180 else return std.date.getUTCtime() / (std.date.TicksPerSecond/1000); | 176 else return std.datetime.Clock.currStdTime(); |
181 } | 177 } |
182 | 178 |
183 static void exit( int code ){ | 179 static void exit( int code ){ |
184 version(Tango) tango.stdc.stdlib.exit(code); | 180 version(Tango) tango.stdc.stdlib.exit(code); |
185 else std.c.stdlib.exit(code); | 181 else std.c.stdlib.exit(code); |