Changeset 29
- Timestamp:
- 10/15/08 17:33:55 (4 years ago)
- Files:
-
- branches/D1.0/import/bitmanip.di (deleted)
- branches/D1.0/import/core (added)
- branches/D1.0/import/core/bitmanip.di (added)
- branches/D1.0/import/object.di (modified) (4 diffs)
- branches/D1.0/src/common (added)
- branches/D1.0/src/common/core (added)
- branches/D1.0/src/common/core/bitmanip.d (added)
- branches/D1.0/src/common/core/exception.d (added)
- branches/D1.0/src/common/core/memory.d (added)
- branches/D1.0/src/common/core/runtime.d (added)
- branches/D1.0/src/common/core/thread.d (added)
- branches/D1.0/src/common/posix.mak (added)
- branches/D1.0/src/common/stdc (added)
- branches/D1.0/src/common/stdc/errno.c (added)
- branches/D1.0/src/common/win32.mak (added)
- branches/D1.0/src/compiler/dmd/cover.d (modified) (2 diffs)
- branches/D1.0/src/compiler/dmd/deh.c (modified) (5 diffs)
- branches/D1.0/src/compiler/dmd/dmain2.d (modified) (9 diffs)
- branches/D1.0/src/compiler/dmd/lifetime.d (modified) (4 diffs)
- branches/D1.0/src/compiler/dmd/mars.h (modified) (2 diffs)
- branches/D1.0/src/compiler/dmd/object_.d (modified) (12 diffs)
- branches/D1.0/src/compiler/dmd/trace.d (modified) (1 diff)
- branches/D1.0/src/core (deleted)
- branches/D1.0/src/dmd-posix.mak (modified) (2 diffs)
- branches/D1.0/src/dmd-win32.mak (modified) (3 diffs)
- branches/D1.0/src/dmd.conf (modified) (1 diff)
- branches/D1.0/src/gc/basic/gc.d (modified) (1 diff)
- branches/D1.0/src/gc/basic/gcalloc.d (modified) (1 diff)
- branches/D1.0/src/gc/basic/gcbits.d (modified) (1 diff)
- branches/D1.0/src/gc/basic/gcstats.d (modified) (1 diff)
- branches/D1.0/src/gc/basic/gcx.d (modified) (1 diff)
- branches/D1.0/src/gc/stub/gc.d (modified) (1 diff)
- branches/D1.0/src/sc.ini (modified) (1 diff)
- trunk/import/bitmanip.di (deleted)
- trunk/import/core (added)
- trunk/import/core/bitmanip.di (added)
- trunk/import/object.di (modified) (2 diffs)
- trunk/src/common (added)
- trunk/src/common/core (added)
- trunk/src/common/core/bitmanip.d (added)
- trunk/src/common/core/exception.d (added)
- trunk/src/common/core/memory.d (added)
- trunk/src/common/core/runtime.d (added)
- trunk/src/common/core/thread.d (added)
- trunk/src/common/posix.mak (added)
- trunk/src/common/stdc (added)
- trunk/src/common/stdc/errno.c (added)
- trunk/src/common/win32.mak (added)
- trunk/src/compiler/dmd/cover.d (modified) (1 diff)
- trunk/src/compiler/dmd/deh.c (modified) (5 diffs)
- trunk/src/compiler/dmd/dmain2.d (modified) (9 diffs)
- trunk/src/compiler/dmd/lifetime.d (modified) (2 diffs)
- trunk/src/compiler/dmd/mars.h (modified) (2 diffs)
- trunk/src/compiler/dmd/object_.d (modified) (13 diffs)
- trunk/src/core (deleted)
- trunk/src/dmd-posix.mak (modified) (2 diffs)
- trunk/src/dmd-win32.mak (modified) (2 diffs)
- trunk/src/dmd.conf (modified) (1 diff)
- trunk/src/gc/basic/gc.d (modified) (1 diff)
- trunk/src/gc/basic/gcalloc.d (modified) (1 diff)
- trunk/src/gc/basic/gcbits.d (modified) (1 diff)
- trunk/src/gc/basic/gcstats.d (modified) (1 diff)
- trunk/src/gc/basic/gcx.d (modified) (1 diff)
- trunk/src/gc/stub/gc.d (modified) (1 diff)
- trunk/src/sc.ini (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/D1.0/import/object.di
r18 r29 23 23 void unlock(); 24 24 } 25 26 static Object factory(string classname); 25 27 } 26 28 … … 83 85 class TypeInfo_Enum : TypeInfo_Typedef 84 86 { 87 85 88 } 86 89 … … 157 160 void function() unitTest; 158 161 159 static int opApply( int delegate( inout ModuleInfo ));162 static int opApply(int delegate(inout ModuleInfo)); 160 163 } 161 164 162 class Exception: Object165 class Throwable : Object 163 166 { 164 167 interface TraceInfo 165 168 { 166 int opApply( int delegate( inout char[] ));169 int opApply(int delegate(inout char[])); 167 170 string toString(); 168 171 } … … 172 175 size_t line; 173 176 TraceInfo info; 174 Exceptionnext;177 Throwable next; 175 178 176 this(string msg, Exceptionnext = null);177 this(string msg, string file, size_t line, Exceptionnext = null);179 this(string msg, Throwable next = null); 180 this(string msg, string file, size_t line, Throwable next = null); 178 181 override string toString(); 179 182 } 180 183 181 alias Exception Error; 184 185 class Exception : Throwable 186 { 187 this(string msg, Throwable next = null); 188 this(string msg, string file, size_t line, Throwable next = null); 189 } 190 191 192 class Error : Throwable 193 { 194 this(string msg, Throwable next = null); 195 this(string msg, string file, size_t line, Throwable next = null); 196 } branches/D1.0/src/compiler/dmd/cover.d
r25 r29 13 13 */ 14 14 15 module rt. cover;15 module rt.cover; 16 16 17 17 private … … 24 24 import stdc.posix.unistd; 25 25 } 26 import bitmanip;26 import core.bitmanip; 27 27 import stdc.stdio; 28 28 import util.utf; branches/D1.0/src/compiler/dmd/deh.c
r8 r29 34 34 #include "mars.h" 35 35 36 extern ClassInfo D9Exception7__ClassZ; 37 38 #define _Class_9Exception D9Exception7__ClassZ 36 extern ClassInfo D6object9Throwable7__ClassZ; 37 #define _Class_9Throwable D6object9Throwable7__ClassZ; 38 39 extern ClassInfo D6object5Error7__ClassZ; 40 #define _Class_5Error D6object5Error7__ClassZ 39 41 40 42 typedef int (__pascal *fp_t)(); // function pointer in ambient memory model … … 152 154 } 153 155 else 154 ci = &_Class_9 Exception;156 ci = &_Class_9Throwable; 155 157 } 156 158 157 159 if (_d_isbaseof(ci, pcb->type)) 158 { // Matched the catch type, so we've found the handler. 160 { 161 // Matched the catch type, so we've found the handler. 159 162 int regebp; 160 163 … … 230 233 Object *_d_create_exception_object(ClassInfo *ci, char *msg) 231 234 { 232 Exception*exc;233 234 exc = ( Exception*)_d_newclass(ci);235 Throwable *exc; 236 237 exc = (Throwable *)_d_newclass(ci); 235 238 // BUG: what if _d_newclass() throws an out of memory exception? 236 239 … … 258 261 259 262 case STATUS_INTEGER_DIVIDE_BY_ZERO: 260 pti = _d_create_exception_object(&_Class_ 9Exception, "Integer Divide by Zero");263 pti = _d_create_exception_object(&_Class_5Error, "Integer Divide by Zero"); 261 264 break; 262 265 263 266 case STATUS_FLOAT_DIVIDE_BY_ZERO: 264 pti = _d_create_exception_object(&_Class_ 9Exception, "Float Divide by Zero");267 pti = _d_create_exception_object(&_Class_5Error, "Float Divide by Zero"); 265 268 break; 266 269 267 270 case STATUS_ACCESS_VIOLATION: 268 pti = _d_create_exception_object(&_Class_ 9Exception, "Access Violation");271 pti = _d_create_exception_object(&_Class_5Error, "Access Violation"); 269 272 break; 270 273 271 274 case STATUS_STACK_OVERFLOW: 272 pti = _d_create_exception_object(&_Class_ 9Exception, "Stack Overflow");275 pti = _d_create_exception_object(&_Class_5Error, "Stack Overflow"); 273 276 break; 274 277 275 278 // convert all other exception codes into a Win32Exception 276 279 default: 277 pti = _d_create_exception_object(&_Class_ 9Exception, "Win32 Exception");280 pti = _d_create_exception_object(&_Class_5Error, "Win32 Exception"); 278 281 break; 279 282 } … … 414 417 #include "mars.h" 415 418 416 extern ClassInfo D9Exception7__ClassZ; 417 418 #define _Class_9Exception D9Exception7__ClassZ 419 extern ClassInfo D6object9Throwable7__ClassZ; 420 #define _Class_9Throwable D6object9Throwable7__ClassZ; 421 422 extern ClassInfo D6object5Error7__ClassZ; 423 #define _Class_5Error D6object5Error7__ClassZ 419 424 420 425 typedef int (*fp_t)(); // function pointer in ambient memory model branches/D1.0/src/compiler/dmd/dmain2.d
r8 r29 19 19 } 20 20 21 version( Windows)21 version(Windows) 22 22 { 23 23 extern (Windows) void* LocalFree(void*); … … 43 43 * against this library. 44 44 */ 45 extern (C) void onAssertError( string file, size_t line ); 46 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ); 47 extern (C) void onArrayBoundsError( string file, size_t line ); 48 extern (C) void onSwitchError( string file, size_t line ); 45 extern (C) void onAssertError(string file, size_t line); 46 extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 47 extern (C) void onArrayBoundsError(string file, size_t line); 48 extern (C) void onHiddenFuncError(Object o); 49 extern (C) void onSwitchError(string file, size_t line); 49 50 extern (C) bool runModuleUnitTests(); 50 51 51 52 // this function is called from the utf module 52 //extern (C) void onUnicodeError( string msg, size_t idx);53 //extern (C) void onUnicodeError(string msg, size_t idx); 53 54 54 55 /*********************************** 55 56 * These are internal callbacks for various language errors. 56 57 */ 57 extern (C) void _d_assert( string file, uint line ) 58 { 59 onAssertError( file, line ); 60 } 61 62 extern (C) static void _d_assert_msg( string msg, string file, uint line ) 63 { 64 onAssertErrorMsg( file, line, msg ); 65 } 66 67 extern (C) void _d_array_bounds( string file, uint line ) 68 { 69 onArrayBoundsError( file, line ); 70 } 71 72 extern (C) void _d_switch_error( string file, uint line ) 73 { 74 onSwitchError( file, line ); 58 extern (C) void _d_assert(string file, uint line) 59 { 60 onAssertError(file, line); 61 } 62 63 extern (C) static void _d_assert_msg(string msg, string file, uint line) 64 { 65 onAssertErrorMsg(file, line, msg); 66 } 67 68 extern (C) void _d_array_bounds(string file, uint line) 69 { 70 onArrayBoundsError(file, line); 71 } 72 73 extern (C) void _d_switch_error(string file, uint line) 74 { 75 onSwitchError(file, line); 76 } 77 78 extern (C) void _d_hidden_func() 79 { 80 Object o; 81 asm 82 { 83 mov o, EAX; 84 } 85 onHiddenFuncError(o); 75 86 } 76 87 … … 93 104 } 94 105 95 alias void delegate( Exception) ExceptionHandler;96 97 extern (C) bool rt_init( ExceptionHandler dg = null)106 alias void delegate(Throwable) ExceptionHandler; 107 108 extern (C) bool rt_init(ExceptionHandler dg = null) 98 109 { 99 110 _d_criticalInit(); … … 107 118 return true; 108 119 } 109 catch ( Exception e)110 { 111 if ( dg)112 dg( e);120 catch (Throwable e) 121 { 122 if (dg) 123 dg(e); 113 124 } 114 125 catch … … 129 140 } 130 141 131 extern (C) bool rt_term( ExceptionHandler dg = null)142 extern (C) bool rt_term(ExceptionHandler dg = null) 132 143 { 133 144 try … … 139 150 return true; 140 151 } 141 catch ( Exception e)142 { 143 if ( dg)144 dg( e);152 catch (Throwable e) 153 { 154 if (dg) 155 dg(e); 145 156 } 146 157 catch … … 193 204 for (size_t i = 0, p = 0; i < wargc; i++) 194 205 { 195 int wlen = wcslen( wargs[i]);206 int wlen = wcslen(wargs[i]); 196 207 int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); 197 208 args[i] = cargp[p .. p+clen]; … … 227 238 dg(); 228 239 } 229 catch ( Exceptione)240 catch (Throwable e) 230 241 { 231 242 while (e) … … 233 244 if (e.file) 234 245 { 235 // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg);236 console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.toString)("\n");246 // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg); 247 console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n"); 237 248 } 238 249 else 239 250 { 240 // fprintf(stderr, "%.*s\n", e.toString());241 console (e.classinfo.name)(": ")(e.toString)("\n");251 // fprintf(stderr, "%.*s\n", e.toString()); 252 console (e.toString)("\n"); 242 253 } 243 254 if (e.info) branches/D1.0/src/compiler/dmd/lifetime.d
r8 r29 67 67 extern (C) BlkInfo gc_query( void* p ); 68 68 69 extern (C) void onFinalizeError( ClassInfo c, Exceptione );69 extern (C) void onFinalizeError( ClassInfo c, Throwable e ); 70 70 extern (C) void onOutOfMemoryError(); 71 71 … … 79 79 alias bool function(Object) CollectHandler; 80 80 CollectHandler collectHandler = null; 81 } 82 83 84 /** 85 * 86 */ 87 extern (C) void* _d_allocmemory(size_t sz) 88 { 89 return gc_malloc(sz); 81 90 } 82 91 … … 394 403 size_t length; 395 404 byte* data; 396 }397 398 399 /**400 *401 */402 void* _d_allocmemory(size_t nbytes)403 {404 return gc_malloc(nbytes);405 405 } 406 406 … … 500 500 _d_monitordelete(cast(Object)p, det); 501 501 } 502 catch ( Exceptione)502 catch (Throwable e) 503 503 { 504 504 onFinalizeError(**pc, e); branches/D1.0/src/compiler/dmd/mars.h
r8 r29 61 61 } ClassInfo; 62 62 63 typedef struct Exception63 typedef struct Throwable 64 64 { 65 65 Object object; … … 74 74 75 75 struct Interface *info; 76 struct Exception*next;77 } Exception;76 struct Throwable *next; 77 } Throwable; 78 78 79 79 typedef struct Array branches/D1.0/src/compiler/dmd/object_.d
r8 r29 55 55 //alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; 56 56 57 version( X86_64)57 version(X86_64) 58 58 { 59 59 alias ulong size_t; … … 125 125 void lock(); 126 126 void unlock(); 127 } 128 129 /** 130 * Create instance of class specified by classname. 131 * The class must either have no constructors or have 132 * a default constructor. 133 * Returns: 134 * null if failed 135 */ 136 static Object factory(string classname) 137 { 138 auto ci = ClassInfo.find(classname); 139 if (ci) 140 { 141 return ci.create(); 142 } 143 return null; 127 144 } 128 145 } … … 218 235 { 219 236 override hash_t toHash() 220 { hash_t hash; 237 { 238 hash_t hash; 221 239 222 240 foreach (char c; this.toString()) … … 896 914 897 915 /////////////////////////////////////////////////////////////////////////////// 898 // Exception916 // Throwable 899 917 /////////////////////////////////////////////////////////////////////////////// 900 918 901 919 902 class Exception: Object920 class Throwable : Object 903 921 { 904 922 interface TraceInfo 905 923 { 906 int opApply( int delegate(inout char[]));924 int opApply(int delegate(inout char[])); 907 925 } 908 926 … … 911 929 size_t line; 912 930 TraceInfo info; 913 Exceptionnext;914 915 this( string msg, Exception next = null)931 Throwable next; 932 933 this(string msg, Throwable next = null) 916 934 { 917 935 this.msg = msg; … … 920 938 } 921 939 922 this( string msg, string file, size_t line, Exception next = null)940 this(string msg, string file, size_t line, Throwable next = null) 923 941 { 924 942 this(msg, next); … … 930 948 override string toString() 931 949 { 932 return msg; 933 } 934 } 935 936 937 alias Exception.TraceInfo function( void* ptr = null ) TraceHandler; 950 char[10] tmp; 951 char[] buf; 952 953 for (Throwable e = this; e !is null; e = e.next) 954 { 955 if (e.file) 956 { 957 buf ~= e.classinfo.name ~ "@" ~ e.file ~ "(" ~ tmp.intToString(e.line) ~ "): " ~ e.msg; 958 } 959 else 960 { 961 buf ~= e.classinfo.name ~ ": " ~ e.msg; 962 } 963 if (e.info) 964 { 965 buf ~= "\n----------------"; 966 foreach (t; e.info) 967 buf ~= "\n" ~ t; 968 } 969 if (e.next) 970 buf ~= "\n"; 971 } 972 return cast(string) buf; 973 } 974 } 975 976 977 alias Throwable.TraceInfo function(void* ptr = null) TraceHandler; 938 978 private TraceHandler traceHandler = null; 939 979 … … 945 985 * h = The new trace handler. Set to null to use the default handler. 946 986 */ 947 extern (C) void rt_setTraceHandler( TraceHandler h)987 extern (C) void rt_setTraceHandler(TraceHandler h) 948 988 { 949 989 traceHandler = h; … … 952 992 953 993 /** 954 * This function will be called when an Exception is constructed. The994 * This function will be called when an exception is constructed. The 955 995 * user-supplied trace handler will be called if one has been supplied, 956 996 * otherwise no trace will be generated. … … 965 1005 * supplied. 966 1006 */ 967 Exception.TraceInfo traceContext( void* ptr = null)968 { 969 if ( traceHandler is null)1007 Throwable.TraceInfo traceContext(void* ptr = null) 1008 { 1009 if (traceHandler is null) 970 1010 return null; 971 return traceHandler( ptr ); 1011 return traceHandler(ptr); 1012 } 1013 1014 1015 class Exception : Throwable 1016 { 1017 this(string msg, Throwable next = null) 1018 { 1019 super(msg, next); 1020 } 1021 1022 this(string msg, string file, size_t line, Throwable next = null) 1023 { 1024 super(msg, file, line, next); 1025 } 1026 } 1027 1028 1029 class Error : Throwable 1030 { 1031 this(string msg, Throwable next = null) 1032 { 1033 super(msg, next); 1034 } 1035 1036 this(string msg, string file, size_t line, Throwable next = null) 1037 { 1038 super(msg, file, line, next); 1039 } 972 1040 } 973 1041 … … 1003 1071 void function() ictor; // module static constructor (order independent) 1004 1072 1005 static int opApply( int delegate(inout ModuleInfo) dg)1073 static int opApply(int delegate(inout ModuleInfo) dg) 1006 1074 { 1007 1075 int ret = 0; 1008 1076 1009 foreach ( m; _moduleinfo_array)1010 { 1011 ret = dg( m);1012 if ( ret)1077 foreach (m; _moduleinfo_array) 1078 { 1079 ret = dg(m); 1080 if (ret) 1013 1081 break; 1014 1082 } … … 1108 1176 { if (skip || m.flags & MIstandalone) 1109 1177 continue; 1110 throw new Exception( "Cyclic dependency in module " ~ m.name);1178 throw new Exception("Cyclic dependency in module " ~ m.name); 1111 1179 } 1112 1180 branches/D1.0/src/compiler/dmd/trace.d
r8 r29 662 662 break; 663 663 } 664 buf[i] = c ;664 buf[i] = cast(char)c; 665 665 i++; 666 666 } branches/D1.0/src/dmd-posix.mak
r16 r29 12 12 13 13 LIB_TARGET=libdruntime-dmd.a 14 LIB_MASK=libdruntime-dmd*.a 14 DUP_TARGET=libdruntime.a 15 LIB_MASK=libdruntime*.a 15 16 16 DIR_CC= ../src/core17 DIR_RT= ../src/compiler/dmd18 DIR_GC= ../src/gc/basic17 DIR_CC=common 18 DIR_RT=compiler/dmd 19 DIR_GC=gc/basic 19 20 20 21 CP=cp -f … … 48 49 make -C $(DIR_RT) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 49 50 make -C $(DIR_GC) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 50 find . -name "libphobos*.a" | xargs $(RM)51 $(RM) $(LIB_TARGET) 51 52 $(LC) $(LIB_TARGET) `find $(DIR_CC) -name "*.o" | xargs echo` 52 53 $(LC) $(LIB_TARGET) `find $(DIR_RT) -name "*.o" | xargs echo` 53 54 $(LC) $(LIB_TARGET) `find $(DIR_GC) -name "*.o" | xargs echo` 55 $(RM) $(DUP_TARGET) 56 $(CP) $(LIB_TARGET) $(DUP_TARGET) 54 57 55 58 doc : $(ALL_DOCS) branches/D1.0/src/dmd-win32.mak
r16 r29 2 2 # Designed to work with DigitalMars make 3 3 # Targets: 4 # make5 # Same as make all6 # make lib7 # Build the runtime library4 # make 5 # Same as make all 6 # make lib 7 # Build the runtime library 8 8 # make doc 9 9 # Generate documentation 10 # make clean11 # Delete unneeded files created by build process10 # make clean 11 # Delete unneeded files created by build process 12 12 13 13 LIB_TARGET=druntime-dmd.lib 14 LIB_MASK=druntime-dmd*.lib 14 DUP_TARGET=druntime.lib 15 LIB_MASK=druntime*.lib 15 16 16 DIR_CC=co re17 DIR_CC=common 17 18 DIR_RT=compiler\dmd 18 19 DIR_GC=gc\basic … … 53 54 cd .. 54 55 cd $(DIR_RT) 55 make -fwin32.mak lib 56 make -fwin32.mak lib DC=$(DC) 56 57 cd ..\.. 57 58 cd $(DIR_GC) … … 60 61 $(RM) $(LIB_TARGET) 61 62 $(LC) -c -n $(LIB_TARGET) $(LIB_CC) $(LIB_RT) $(LIB_GC) 63 $(RM) $(DUP_TARGET) 64 copy $(LIB_TARGET) $(DUP_TARGET) 62 65 63 66 doc : $(ALL_DOCS) 64 67 cd $(DIR_CC) 65 make -fwin32.mak doc 68 make -fwin32.mak doc DC=$(DC) 66 69 cd .. 67 70 cd $(DIR_RT) 68 make -fwin32.mak doc 71 make -fwin32.mak doc DC=$(DC) 69 72 cd ..\.. 70 73 cd $(DIR_GC) 71 make -fwin32.mak doc 74 make -fwin32.mak doc DC=$(DC) 72 75 cd ..\.. 73 76 branches/D1.0/src/dmd.conf
r27 r29 1 1 [Environment] 2 DFLAGS=-version=Posix "-I%HOME%/co re" "-I%HOME%/../import"2 DFLAGS=-version=Posix "-I%HOME%/common" "-I%HOME%/../import" branches/D1.0/src/gc/basic/gc.d
r8 r29 24 24 * Authors: Walter Bright, Sean Kelly 25 25 */ 26 27 module gc.gc; 26 28 27 29 private import gcx; branches/D1.0/src/gc/basic/gcalloc.d
r8 r29 25 25 */ 26 26 27 module gc.gcalloc; 28 27 29 28 30 version (Windows) branches/D1.0/src/gc/basic/gcbits.d
r8 r29 25 25 */ 26 26 27 module gc.gcbits; 28 27 29 28 30 private 29 31 { 30 import bitmanip;32 import core.bitmanip; 31 33 import stdc.string; 32 34 import stdc.stdlib; branches/D1.0/src/gc/basic/gcstats.d
r8 r29 25 25 */ 26 26 27 module gc.gcstats; 28 27 29 28 30 /** branches/D1.0/src/gc/basic/gcx.d
r8 r29 24 24 * Authors: Walter Bright, David Friedman, Sean Kelly 25 25 */ 26 27 module gc.gcx; 26 28 27 29 // D Programming Language Garbage Collector implementation branches/D1.0/src/gc/stub/gc.d
r8 r29 18 18 * Authors: Sean Kelly 19 19 */ 20 21 module gc.gc; 20 22 21 23 private import stdc.stdlib; branches/D1.0/src/sc.ini
r26 r29 4 4 [Environment] 5 5 LIB=%@P%\..\lib;\dm\lib 6 DFLAGS="-I%HOME%\co re" "-I%HOME%\..\import"6 DFLAGS="-I%HOME%\common" "-I%HOME%\..\import" 7 7 LINKCMD=%@P%\..\..\dm\bin\link.exe trunk/import/object.di
r24 r29 209 209 void function() unitTest; 210 210 211 static int opApply( int delegate( inout ModuleInfo ));212 } 213 214 class Exception: Object211 static int opApply(int delegate(inout ModuleInfo)); 212 } 213 214 class Throwable : Object 215 215 { 216 216 interface TraceInfo 217 217 { 218 int opApply( int delegate(inout char[]));218 int opApply(int delegate(inout char[])); 219 219 string toString(); 220 220 } … … 224 224 size_t line; 225 225 TraceInfo info; 226 Exceptionnext;227 228 this(string msg, Exceptionnext = null);229 this(string msg, string file, size_t line, Exceptionnext = null);226 Throwable next; 227 228 this(string msg, Throwable next = null); 229 this(string msg, string file, size_t line, Throwable next = null); 230 230 override string toString(); 231 231 } 232 232 233 233 234 alias Exception Error; 234 class Exception : Throwable 235 { 236 this(string msg, Throwable next = null); 237 this(string msg, string file, size_t line, Throwable next = null); 238 } 239 240 241 class Error : Throwable 242 { 243 this(string msg, Throwable next = null); 244 this(string msg, string file, size_t line, Throwable next = null); 245 } trunk/src/compiler/dmd/cover.d
r25 r29 24 24 import stdc.posix.unistd; 25 25 } 26 import bitmanip;26 import core.bitmanip; 27 27 import stdc.stdio; 28 28 import util.utf; trunk/src/compiler/dmd/deh.c
r5 r29 34 34 #include "mars.h" 35 35 36 extern ClassInfo D9Exception7__ClassZ; 37 38 #define _Class_9Exception D9Exception7__ClassZ 36 extern ClassInfo D6object9Throwable7__ClassZ; 37 #define _Class_9Throwable D6object9Throwable7__ClassZ; 38 39 extern ClassInfo D6object5Error7__ClassZ; 40 #define _Class_5Error D6object5Error7__ClassZ 39 41 40 42 typedef int (__pascal *fp_t)(); // function pointer in ambient memory model … … 152 154 } 153 155 else 154 ci = &_Class_9 Exception;156 ci = &_Class_9Throwable; 155 157 } 156 158 157 159 if (_d_isbaseof(ci, pcb->type)) 158 { // Matched the catch type, so we've found the handler. 160 { 161 // Matched the catch type, so we've found the handler. 159 162 int regebp; 160 163 … … 230 233 Object *_d_create_exception_object(ClassInfo *ci, char *msg) 231 234 { 232 Exception*exc;233 234 exc = ( Exception*)_d_newclass(ci);235 Throwable *exc; 236 237 exc = (Throwable *)_d_newclass(ci); 235 238 // BUG: what if _d_newclass() throws an out of memory exception? 236 239 … … 258 261 259 262 case STATUS_INTEGER_DIVIDE_BY_ZERO: 260 pti = _d_create_exception_object(&_Class_ 9Exception, "Integer Divide by Zero");263 pti = _d_create_exception_object(&_Class_5Error, "Integer Divide by Zero"); 261 264 break; 262 265 263 266 case STATUS_FLOAT_DIVIDE_BY_ZERO: 264 pti = _d_create_exception_object(&_Class_ 9Exception, "Float Divide by Zero");267 pti = _d_create_exception_object(&_Class_5Error, "Float Divide by Zero"); 265 268 break; 266 269 267 270 case STATUS_ACCESS_VIOLATION: 268 pti = _d_create_exception_object(&_Class_ 9Exception, "Access Violation");271 pti = _d_create_exception_object(&_Class_5Error, "Access Violation"); 269 272 break; 270 273 271 274 case STATUS_STACK_OVERFLOW: 272 pti = _d_create_exception_object(&_Class_ 9Exception, "Stack Overflow");275 pti = _d_create_exception_object(&_Class_5Error, "Stack Overflow"); 273 276 break; 274 277 275 278 // convert all other exception codes into a Win32Exception 276 279 default: 277 pti = _d_create_exception_object(&_Class_ 9Exception, "Win32 Exception");280 pti = _d_create_exception_object(&_Class_5Error, "Win32 Exception"); 278 281 break; 279 282 } … … 414 417 #include "mars.h" 415 418 416 extern ClassInfo D9Exception7__ClassZ; 417 418 #define _Class_9Exception D9Exception7__ClassZ 419 extern ClassInfo D6object9Throwable7__ClassZ; 420 #define _Class_9Throwable D6object9Throwable7__ClassZ; 421 422 extern ClassInfo D6object5Error7__ClassZ; 423 #define _Class_5Error D6object5Error7__ClassZ 419 424 420 425 typedef int (*fp_t)(); // function pointer in ambient memory model trunk/src/compiler/dmd/dmain2.d
r28 r29 19 19 } 20 20 21 version( Windows)21 version(Windows) 22 22 { 23 23 extern (Windows) void* LocalFree(void*); … … 43 43 * against this library. 44 44 */ 45 extern (C) void onAssertError( string file, size_t line ); 46 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ); 47 extern (C) void onArrayBoundsError( string file, size_t line ); 48 extern (C) void onSwitchError( string file, size_t line ); 45 extern (C) void onAssertError(string file, size_t line); 46 extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 47 extern (C) void onArrayBoundsError(string file, size_t line); 48 extern (C) void onHiddenFuncError(Object o); 49 extern (C) void onSwitchError(string file, size_t line); 49 50 extern (C) bool runModuleUnitTests(); 50 51 51 52 // this function is called from the utf module 52 //extern (C) void onUnicodeError( string msg, size_t idx);53 //extern (C) void onUnicodeError(string msg, size_t idx); 53 54 54 55 /*********************************** 55 56 * These are internal callbacks for various language errors. 56 57 */ 57 extern (C) void _d_assert( string file, uint line ) 58 { 59 onAssertError( file, line ); 60 } 61 62 extern (C) static void _d_assert_msg( string msg, string file, uint line ) 63 { 64 onAssertErrorMsg( file, line, msg ); 65 } 66 67 extern (C) void _d_array_bounds( string file, uint line ) 68 { 69 onArrayBoundsError( file, line ); 70 } 71 72 extern (C) void _d_switch_error( string file, uint line ) 73 { 74 onSwitchError( file, line ); 75 } 76 77 /+ 58 extern (C) void _d_assert(string file, uint line) 59 { 60 onAssertError(file, line); 61 } 62 63 extern (C) static void _d_assert_msg(string msg, string file, uint line) 64 { 65 onAssertErrorMsg(file, line, msg); 66 } 67 68 extern (C) void _d_array_bounds(string file, uint line) 69 { 70 onArrayBoundsError(file, line); 71 } 72 73 extern (C) void _d_switch_error(string file, uint line) 74 { 75 onSwitchError(file, line); 76 } 77 78 78 extern (C) void _d_hidden_func() 79 79 { 80 // TODO: Figure out what to do with this routine 81 // it's in exception.d for the moment 82 } 83 +/ 80 Object o; 81 asm 82 { 83 mov o, EAX; 84 } 85 onHiddenFuncError(o); 86 } 84 87 85 88 bool _d_isHalting = false; … … 101 104 } 102 105 103 alias void delegate( Exception) ExceptionHandler;104 105 extern (C) bool rt_init( ExceptionHandler dg = null)106 alias void delegate(Throwable) ExceptionHandler; 107 108 extern (C) bool rt_init(ExceptionHandler dg = null) 106 109 { 107 110 _d_criticalInit(); … … 115 118 return true; 116 119 } 117 catch ( Exception e)118 { 119 if ( dg)120 dg( e);120 catch (Throwable e) 121 { 122 if (dg) 123 dg(e); 121 124 } 122 125 catch … … 137 140 } 138 141 139 extern (C) bool rt_term( ExceptionHandler dg = null)142 extern (C) bool rt_term(ExceptionHandler dg = null) 140 143 { 141 144 try … … 147 150 return true; 148 151 } 149 catch ( Exception e)150 { 151 if ( dg)152 dg( e);152 catch (Throwable e) 153 { 154 if (dg) 155 dg(e); 153 156 } 154 157 catch … … 201 204 for (size_t i = 0, p = 0; i < wargc; i++) 202 205 { 203 int wlen = wcslen( wargs[i]);206 int wlen = wcslen(wargs[i]); 204 207 int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); 205 208 args[i] = cargp[p .. p+clen]; … … 235 238 dg(); 236 239 } 237 catch ( Exceptione)240 catch (Throwable e) 238 241 { 239 242 while (e) … … 241 244 if (e.file) 242 245 { 243 // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg);244 console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n");246 // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg); 247 console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n"); 245 248 } 246 249 else 247 250 { 248 // fprintf(stderr, "%.*s\n", e.toString());249 console (e.classinfo.name)(": ")(e.toString)("\n");251 // fprintf(stderr, "%.*s\n", e.toString()); 252 console (e.toString)("\n"); 250 253 } 251 254 if (e.info) trunk/src/compiler/dmd/lifetime.d
r19 r29 67 67 extern (C) BlkInfo gc_query( void* p ); 68 68 69 extern (C) void onFinalizeError( ClassInfo c, Exceptione );69 extern (C) void onFinalizeError( ClassInfo c, Throwable e ); 70 70 extern (C) void onOutOfMemoryError(); 71 71 … … 530 530 _d_monitordelete(cast(Object)p, det); 531 531 } 532 catch ( Exceptione)532 catch (Throwable e) 533 533 { 534 534 onFinalizeError(**pc, e); trunk/src/compiler/dmd/mars.h
r5 r29 61 61 } ClassInfo; 62 62 63 typedef struct Exception63 typedef struct Throwable 64 64 { 65 65 Object object; … … 74 74 75 75 struct Interface *info; 76 struct Exception*next;77 } Exception;76 struct Throwable *next; 77 } Throwable; 78 78 79 79 typedef struct Array trunk/src/compiler/dmd/object_.d
r28 r29 55 55 //alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; 56 56 57 version( X86_64)57 version(X86_64) 58 58 { 59 59 alias ulong size_t; … … 127 127 } 128 128 129 /** ****129 /** 130 130 * Create instance of class specified by classname. 131 131 * The class must either have no constructors or have … … 217 217 return o; 218 218 } 219 219 220 /** 220 221 * Search for all members with the name 'name'. … … 247 248 { 248 249 override hash_t toHash() 249 { hash_t hash; 250 { 251 hash_t hash; 250 252 251 253 foreach (char c; this.toString()) … … 1049 1051 1050 1052 /////////////////////////////////////////////////////////////////////////////// 1051 // Exception1053 // Throwable 1052 1054 /////////////////////////////////////////////////////////////////////////////// 1053 1055 1054 1056 1055 class Exception: Object1057 class Throwable : Object 1056 1058 { 1057 1059 interface TraceInfo 1058 1060 { 1059 int opApply( int delegate(inout char[]));1061 int opApply(int delegate(inout char[])); 1060 1062 } 1061 1063 … … 1064 1066 size_t line; 1065 1067 TraceInfo info; 1066 Exception next; 1067 char[] buffer; 1068 1069 this( string msg, Exception next = null ) 1068 Throwable next; 1069 1070 this(string msg, Throwable next = null) 1070 1071 { 1071 1072 this.msg = msg; … … 1074 1075 } 1075 1076 1076 this( string msg, string file, size_t line, Exception next = null)1077 this(string msg, string file, size_t line, Throwable next = null) 1077 1078 { 1078 1079 this(msg, next); … … 1084 1085 override string toString() 1085 1086 { 1086 if (file.length == 0 && line == 0) 1087 return msg; 1088 if (buffer.length == 0) 1089 { 1090 // Write into buffer[] the following: "file(line): msg" 1091 buffer.length = 4 + file.length + line.sizeof * 3 + msg.length; 1092 auto i = file.length; 1093 buffer[0 .. i] = file[]; 1094 buffer[i] = '('; 1095 i++; 1096 1097 auto n = line; 1098 auto j = i; 1099 do 1100 { 1101 buffer[i] = cast(char)((n % 10) + '0'); 1102 n /= 10; 1103 i++; 1104 } while (n); 1105 buffer[j .. i].reverse; 1106 buffer[i..i+3] = "): "[]; 1107 i += 3; 1108 1109 buffer[i .. i + msg.length] = msg[]; 1110 i += msg.length; 1111 1112 buffer = buffer[0 .. i]; 1113 } 1114 return cast(invariant)buffer; 1115 } 1116 } 1117 1118 1119 alias Exception.TraceInfo function( void* ptr = null ) TraceHandler; 1087 char[10] tmp; 1088 char[] buf; 1089 1090 for (Throwable e = this; e !is null; e = e.next) 1091 { 1092 if (e.file) 1093 { 1094 buf ~= e.classinfo.name ~ "@" ~ e.file ~ "(" ~ tmp.intToString(e.line) ~ "): " ~ e.msg; 1095 } 1096 else 1097 { 1098 buf ~= e.classinfo.name ~ ": " ~ e.msg; 1099 } 1100 if (e.info) 1101 { 1102 buf ~= "\n----------------"; 1103 foreach (t; e.info) 1104 buf ~= "\n" ~ t; 1105 } 1106 if (e.next) 1107 buf ~= "\n"; 1108 } 1109 return cast(string) buf; 1110 } 1111 } 1112 1113 1114 alias Throwable.TraceInfo function(void* ptr = null) TraceHandler; 1120 1115 private TraceHandler traceHandler = null; 1121 1116 … … 1127 1122 * h = The new trace handler. Set to null to use the default handler. 1128 1123 */ 1129 extern (C) void rt_setTraceHandler( TraceHandler h)1124 extern (C) void rt_setTraceHandler(TraceHandler h) 1130 1125 { 1131 1126 traceHandler = h; … … 1134 1129 1135 1130 /** 1136 * This function will be called when an Exception is constructed. The1131 * This function will be called when an exception is constructed. The 1137 1132 * user-supplied trace handler will be called if one has been supplied, 1138 1133 * otherwise no trace will be generated. … … 1147 1142 * supplied. 1148 1143 */ 1149 Exception.TraceInfo traceContext( void* ptr = null)1150 { 1151 if ( traceHandler is null)1144 Throwable.TraceInfo traceContext(void* ptr = null) 1145 { 1146 if (traceHandler is null) 1152 1147 return null; 1153 return traceHandler( ptr ); 1148 return traceHandler(ptr); 1149 } 1150 1151 1152 class Exception : Throwable 1153 { 1154 this(string msg, Throwable next = null) 1155 { 1156 super(msg, next); 1157 } 1158 1159 this(string msg, string file, size_t line, Throwable next = null) 1160 { 1161 super(msg, file, line, next); 1162 } 1163 } 1164 1165 1166 class Error : Throwable 1167 { 1168 this(string msg, Throwable next = null) 1169 { 1170 super(msg, next); 1171 } 1172 1173 this(string msg, string file, size_t line, Throwable next = null) 1174 { 1175 super(msg, file, line, next); 1176 } 1154 1177 } 1155 1178 … … 1185 1208 void function() ictor; // module static constructor (order independent) 1186 1209 1187 static int opApply( int delegate(inout ModuleInfo) dg)1210 static int opApply(int delegate(inout ModuleInfo) dg) 1188 1211 { 1189 1212 int ret = 0; 1190 1213 1191 foreach ( m; _moduleinfo_array)1192 { 1193 ret = dg( m);1194 if ( ret)1214 foreach (m; _moduleinfo_array) 1215 { 1216 ret = dg(m); 1217 if (ret) 1195 1218 break; 1196 1219 } … … 1290 1313 { if (skip || m.flags & MIstandalone) 1291 1314 continue; 1292 throw new Exception( "Cyclic dependency in module " ~ m.name);1315 throw new Exception("Cyclic dependency in module " ~ m.name); 1293 1316 } 1294 1317 trunk/src/dmd-posix.mak
r16 r29 12 12 13 13 LIB_TARGET=libdruntime-dmd.a 14 LIB_MASK=libdruntime-dmd*.a 14 DUP_TARGET=libdruntime.a 15 LIB_MASK=libdruntime*.a 15 16 16 DIR_CC= ../src/core17 DIR_RT= ../src/compiler/dmd18 DIR_GC= ../src/gc/basic17 DIR_CC=common 18 DIR_RT=compiler/dmd 19 DIR_GC=gc/basic 19 20 20 21 CP=cp -f … … 48 49 make -C $(DIR_RT) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 49 50 make -C $(DIR_GC) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 50 find . -name "libphobos*.a" | xargs $(RM)51 $(RM) $(LIB_TARGET) 51 52 $(LC) $(LIB_TARGET) `find $(DIR_CC) -name "*.o" | xargs echo` 52 53 $(LC) $(LIB_TARGET) `find $(DIR_RT) -name "*.o" | xargs echo` 53 54 $(LC) $(LIB_TARGET) `find $(DIR_GC) -name "*.o" | xargs echo` 55 $(RM) $(DUP_TARGET) 56 $(CP) $(LIB_TARGET) $(DUP_TARGET) 54 57 55 58 doc : $(ALL_DOCS) trunk/src/dmd-win32.mak
r21 r29 11 11 # Delete unneeded files created by build process 12 12 13 LIB_TARGET=druntime.lib 14 LIB_MASK=druntime.lib 13 LIB_TARGET=druntime-dmd.lib 14 DUP_TARGET=druntime.lib 15 LIB_MASK=druntime*.lib 15 16 16 DIR_CC=co re17 DIR_CC=common 17 18 DIR_RT=compiler\dmd 18 19 DIR_GC=gc\basic … … 60 61 $(RM) $(LIB_TARGET) 61 62 $(LC) -c -n $(LIB_TARGET) $(LIB_CC) $(LIB_RT) $(LIB_GC) 63 $(RM) $(DUP_TARGET) 64 copy $(LIB_TARGET) $(DUP_TARGET) 62 65 63 66 doc : $(ALL_DOCS) trunk/src/dmd.conf
r27 r29 1 1 [Environment] 2 DFLAGS=-version=Posix "-I%HOME%/co re" "-I%HOME%/../import"2 DFLAGS=-version=Posix "-I%HOME%/common" "-I%HOME%/../import" trunk/src/gc/basic/gc.d
r5 r29 24 24 * Authors: Walter Bright, Sean Kelly 25 25 */ 26 27 module gc.gc; 26 28 27 29 private import gcx; trunk/src/gc/basic/gcalloc.d
r5 r29 25 25 */ 26 26 27 module gc.gcalloc; 28 27 29 28 30 version (Windows) trunk/src/gc/basic/gcbits.d
r10 r29 25 25 */ 26 26 27 module gc.gcbits; 28 27 29 28 30 private 29 31 { 30 import bitmanip;32 import core.bitmanip; 31 33 import stdc.string; 32 34 import stdc.stdlib; trunk/src/gc/basic/gcstats.d
r5 r29 25 25 */ 26 26 27 module gc.gcstats; 28 27 29 28 30 /** trunk/src/gc/basic/gcx.d
r10 r29 24 24 * Authors: Walter Bright, David Friedman, Sean Kelly 25 25 */ 26 27 module gc.gcx; 26 28 27 29 // D Programming Language Garbage Collector implementation trunk/src/gc/stub/gc.d
r5 r29 18 18 * Authors: Sean Kelly 19 19 */ 20 21 module gc.gc; 20 22 21 23 private import stdc.stdlib; trunk/src/sc.ini
r26 r29 4 4 [Environment] 5 5 LIB=%@P%\..\lib;\dm\lib 6 DFLAGS="-I%HOME%\co re" "-I%HOME%\..\import"6 DFLAGS="-I%HOME%\common" "-I%HOME%\..\import" 7 7 LINKCMD=%@P%\..\..\dm\bin\link.exe
