Changeset 29

Show
Ignore:
Timestamp:
10/15/08 17:33:55 (4 years ago)
Author:
sean
Message:

* Changed top-level exception class name from 'Exception' to 'Throwable'.
* Created a new class 'Exception' which derives from 'Throwable'.
* Created a new class 'Error' which derives from 'Throwable'.
* Moved core modules from the top level into a package named 'core'.
* Added onHiddenFuncError() routine to pass hidden function error handling from the runtime to core.exception.
* Renamed _d_getErrno to getErrno and moved it to src/common/stdc. The idea is that druntime may eventually generate a lib for the stdc modules, and this definition is necessary. The comparable function will have to be removed from Phobos as well.
* Moved the GC code into a package named 'gc', which is in accordance with the spec defined for druntime library integration (as yet unpublished).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/D1.0/import/object.di

    r18 r29  
    2323        void unlock(); 
    2424    } 
     25 
     26    static Object factory(string classname); 
    2527} 
    2628 
     
    8385class TypeInfo_Enum : TypeInfo_Typedef 
    8486{ 
     87 
    8588} 
    8689 
     
    157160    void function() unitTest; 
    158161 
    159     static int opApply( int delegate( inout ModuleInfo ) ); 
     162    static int opApply(int delegate(inout ModuleInfo)); 
    160163} 
    161164 
    162 class Exception : Object 
     165class Throwable : Object 
    163166{ 
    164167    interface TraceInfo 
    165168    { 
    166         int opApply( int delegate( inout char[] ) ); 
     169        int opApply(int delegate(inout char[])); 
    167170        string toString(); 
    168171    } 
     
    172175    size_t      line; 
    173176    TraceInfo   info; 
    174     Exception   next; 
     177    Throwable   next; 
    175178 
    176     this(string msg, Exception next = null); 
    177     this(string msg, string file, size_t line, Exception next = null); 
     179    this(string msg, Throwable next = null); 
     180    this(string msg, string file, size_t line, Throwable next = null); 
    178181    override string toString(); 
    179182} 
    180183 
    181 alias Exception Error; 
     184 
     185class 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 
     192class 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  
    1313 */ 
    1414 
    15 module rt. cover; 
     15module rt.cover; 
    1616 
    1717private 
     
    2424        import stdc.posix.unistd; 
    2525    } 
    26     import bitmanip; 
     26    import core.bitmanip; 
    2727    import stdc.stdio; 
    2828    import util.utf; 
  • branches/D1.0/src/compiler/dmd/deh.c

    r8 r29  
    3434#include        "mars.h" 
    3535 
    36 extern ClassInfo D9Exception7__ClassZ; 
    37  
    38 #define _Class_9Exception D9Exception7__ClassZ 
     36extern ClassInfo D6object9Throwable7__ClassZ; 
     37#define _Class_9Throwable D6object9Throwable7__ClassZ; 
     38 
     39extern ClassInfo D6object5Error7__ClassZ; 
     40#define _Class_5Error D6object5Error7__ClassZ 
    3941 
    4042typedef int (__pascal *fp_t)();   // function pointer in ambient memory model 
     
    152154                        } 
    153155                        else 
    154                             ci = &_Class_9Exception
     156                            ci = &_Class_9Throwable
    155157                    } 
    156158 
    157159                    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. 
    159162                        int regebp; 
    160163 
     
    230233Object *_d_create_exception_object(ClassInfo *ci, char *msg) 
    231234{ 
    232     Exception *exc; 
    233  
    234     exc = (Exception *)_d_newclass(ci); 
     235    Throwable *exc; 
     236 
     237    exc = (Throwable *)_d_newclass(ci); 
    235238    // BUG: what if _d_newclass() throws an out of memory exception? 
    236239 
     
    258261 
    259262        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"); 
    261264            break; 
    262265 
    263266        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"); 
    265268            break; 
    266269 
    267270        case STATUS_ACCESS_VIOLATION: 
    268             pti = _d_create_exception_object(&_Class_9Exception, "Access Violation"); 
     271            pti = _d_create_exception_object(&_Class_5Error, "Access Violation"); 
    269272            break; 
    270273 
    271274        case STATUS_STACK_OVERFLOW: 
    272             pti = _d_create_exception_object(&_Class_9Exception, "Stack Overflow"); 
     275            pti = _d_create_exception_object(&_Class_5Error, "Stack Overflow"); 
    273276            break; 
    274277 
    275278        // convert all other exception codes into a Win32Exception 
    276279        default: 
    277             pti = _d_create_exception_object(&_Class_9Exception, "Win32 Exception"); 
     280            pti = _d_create_exception_object(&_Class_5Error, "Win32 Exception"); 
    278281            break; 
    279282    } 
     
    414417#include        "mars.h" 
    415418 
    416 extern ClassInfo D9Exception7__ClassZ; 
    417  
    418 #define _Class_9Exception D9Exception7__ClassZ 
     419extern ClassInfo D6object9Throwable7__ClassZ; 
     420#define _Class_9Throwable D6object9Throwable7__ClassZ; 
     421 
     422extern ClassInfo D6object5Error7__ClassZ; 
     423#define _Class_5Error D6object5Error7__ClassZ 
    419424 
    420425typedef int (*fp_t)();   // function pointer in ambient memory model 
  • branches/D1.0/src/compiler/dmd/dmain2.d

    r8 r29  
    1919} 
    2020 
    21 version( Windows
     21version(Windows
    2222{ 
    2323    extern (Windows) void*      LocalFree(void*); 
     
    4343 * against this library. 
    4444 */ 
    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 ); 
     45extern (C) void onAssertError(string file, size_t line); 
     46extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 
     47extern (C) void onArrayBoundsError(string file, size_t line); 
     48extern (C) void onHiddenFuncError(Object o); 
     49extern (C) void onSwitchError(string file, size_t line); 
    4950extern (C) bool runModuleUnitTests(); 
    5051 
    5152// 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); 
    5354 
    5455/*********************************** 
    5556 * These are internal callbacks for various language errors. 
    5657 */ 
    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 ); 
     58extern (C) void _d_assert(string file, uint line) 
     59
     60    onAssertError(file, line); 
     61
     62 
     63extern (C) static void _d_assert_msg(string msg, string file, uint line) 
     64
     65    onAssertErrorMsg(file, line, msg); 
     66
     67 
     68extern (C) void _d_array_bounds(string file, uint line) 
     69
     70    onArrayBoundsError(file, line); 
     71
     72 
     73extern (C) void _d_switch_error(string file, uint line) 
     74
     75    onSwitchError(file, line); 
     76
     77 
     78extern (C) void _d_hidden_func() 
     79
     80    Object o; 
     81    asm 
     82    { 
     83        mov o, EAX; 
     84    } 
     85    onHiddenFuncError(o); 
    7586} 
    7687 
     
    93104} 
    94105 
    95 alias void delegate( Exception ) ExceptionHandler; 
    96  
    97 extern (C) bool rt_init( ExceptionHandler dg = null
     106alias void delegate(Throwable) ExceptionHandler; 
     107 
     108extern (C) bool rt_init(ExceptionHandler dg = null
    98109{ 
    99110    _d_criticalInit(); 
     
    107118        return true; 
    108119    } 
    109     catch( Exception e
    110     { 
    111         if( dg
    112             dg( e ); 
     120    catch (Throwable e
     121    { 
     122        if (dg
     123            dg(e); 
    113124    } 
    114125    catch 
     
    129140} 
    130141 
    131 extern (C) bool rt_term( ExceptionHandler dg = null
     142extern (C) bool rt_term(ExceptionHandler dg = null
    132143{ 
    133144    try 
     
    139150        return true; 
    140151    } 
    141     catch( Exception e
    142     { 
    143         if( dg
    144             dg( e ); 
     152    catch (Throwable e
     153    { 
     154        if (dg
     155            dg(e); 
    145156    } 
    146157    catch 
     
    193204        for (size_t i = 0, p = 0; i < wargc; i++) 
    194205        { 
    195             int wlen = wcslen( wargs[i] ); 
     206            int wlen = wcslen(wargs[i]); 
    196207            int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); 
    197208            args[i]  = cargp[p .. p+clen]; 
     
    227238                dg(); 
    228239            } 
    229             catch (Exception e) 
     240            catch (Throwable e) 
    230241            { 
    231242                while (e) 
     
    233244                    if (e.file) 
    234245                    { 
    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"); 
    237248                    } 
    238249                    else 
    239250                    { 
    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"); 
    242253                    } 
    243254                    if (e.info) 
  • branches/D1.0/src/compiler/dmd/lifetime.d

    r8 r29  
    6767    extern (C) BlkInfo gc_query( void* p ); 
    6868 
    69     extern (C) void onFinalizeError( ClassInfo c, Exception e ); 
     69    extern (C) void onFinalizeError( ClassInfo c, Throwable e ); 
    7070    extern (C) void onOutOfMemoryError(); 
    7171 
     
    7979    alias bool function(Object) CollectHandler; 
    8080    CollectHandler collectHandler = null; 
     81} 
     82 
     83 
     84/** 
     85 * 
     86 */ 
     87extern (C) void* _d_allocmemory(size_t sz) 
     88{ 
     89    return gc_malloc(sz); 
    8190} 
    8291 
     
    394403    size_t length; 
    395404    byte*  data; 
    396 } 
    397  
    398  
    399 /** 
    400  * 
    401  */ 
    402 void* _d_allocmemory(size_t nbytes) 
    403 { 
    404     return gc_malloc(nbytes); 
    405405} 
    406406 
     
    500500                    _d_monitordelete(cast(Object)p, det); 
    501501            } 
    502             catch (Exception e) 
     502            catch (Throwable e) 
    503503            { 
    504504                onFinalizeError(**pc, e); 
  • branches/D1.0/src/compiler/dmd/mars.h

    r8 r29  
    6161} ClassInfo; 
    6262 
    63 typedef struct Exception 
     63typedef struct Throwable 
    6464{ 
    6565    Object object; 
     
    7474 
    7575    struct Interface *info; 
    76     struct Exception *next; 
    77 } Exception
     76    struct Throwable *next; 
     77} Throwable
    7878 
    7979typedef struct Array 
  • branches/D1.0/src/compiler/dmd/object_.d

    r8 r29  
    5555//alias typeof(cast(void*)0 - cast(void*)0)   ptrdiff_t; 
    5656 
    57 version( X86_64
     57version(X86_64
    5858{ 
    5959    alias ulong size_t; 
     
    125125        void lock(); 
    126126        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; 
    127144    } 
    128145} 
     
    218235{ 
    219236    override hash_t toHash() 
    220     {   hash_t hash; 
     237    { 
     238        hash_t hash; 
    221239 
    222240        foreach (char c; this.toString()) 
     
    896914 
    897915/////////////////////////////////////////////////////////////////////////////// 
    898 // Exception 
     916// Throwable 
    899917/////////////////////////////////////////////////////////////////////////////// 
    900918 
    901919 
    902 class Exception : Object 
     920class Throwable : Object 
    903921{ 
    904922    interface TraceInfo 
    905923    { 
    906         int opApply( int delegate(inout char[]) ); 
     924        int opApply(int delegate(inout char[])); 
    907925    } 
    908926 
     
    911929    size_t      line; 
    912930    TraceInfo   info; 
    913     Exception   next; 
    914  
    915     this( string msg, Exception next = null
     931    Throwable   next; 
     932 
     933    this(string msg, Throwable next = null
    916934    { 
    917935        this.msg = msg; 
     
    920938    } 
    921939 
    922     this( string msg, string file, size_t line, Exception next = null
     940    this(string msg, string file, size_t line, Throwable next = null
    923941    { 
    924942        this(msg, next); 
     
    930948    override string toString() 
    931949    { 
    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 
     977alias Throwable.TraceInfo function(void* ptr = null) TraceHandler; 
    938978private TraceHandler traceHandler = null; 
    939979 
     
    945985 *  h = The new trace handler.  Set to null to use the default handler. 
    946986 */ 
    947 extern (C) void  rt_setTraceHandler( TraceHandler h
     987extern (C) void  rt_setTraceHandler(TraceHandler h
    948988{ 
    949989    traceHandler = h; 
     
    952992 
    953993/** 
    954  * This function will be called when an Exception is constructed.  The 
     994 * This function will be called when an exception is constructed.  The 
    955995 * user-supplied trace handler will be called if one has been supplied, 
    956996 * otherwise no trace will be generated. 
     
    9651005 *  supplied. 
    9661006 */ 
    967 Exception.TraceInfo traceContext( void* ptr = null
    968 { 
    969     if( traceHandler is null
     1007Throwable.TraceInfo traceContext(void* ptr = null
     1008{ 
     1009    if (traceHandler is null
    9701010        return null; 
    971     return traceHandler( ptr ); 
     1011    return traceHandler(ptr); 
     1012
     1013 
     1014 
     1015class 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 
     1029class 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    } 
    9721040} 
    9731041 
     
    10031071    void function() ictor;      // module static constructor (order independent) 
    10041072 
    1005     static int opApply( int delegate(inout ModuleInfo) dg
     1073    static int opApply(int delegate(inout ModuleInfo) dg
    10061074    { 
    10071075        int ret = 0; 
    10081076 
    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
    10131081                break; 
    10141082        } 
     
    11081176            {   if (skip || m.flags & MIstandalone) 
    11091177                    continue; 
    1110                     throw new Exception( "Cyclic dependency in module " ~ m.name ); 
     1178                    throw new Exception("Cyclic dependency in module " ~ m.name); 
    11111179            } 
    11121180 
  • branches/D1.0/src/compiler/dmd/trace.d

    r8 r29  
    662662                break; 
    663663        } 
    664         buf[i] = c
     664        buf[i] = cast(char)c
    665665        i++; 
    666666    } 
  • branches/D1.0/src/dmd-posix.mak

    r16 r29  
    1212 
    1313LIB_TARGET=libdruntime-dmd.a 
    14 LIB_MASK=libdruntime-dmd*.a 
     14DUP_TARGET=libdruntime.a 
     15LIB_MASK=libdruntime*.a 
    1516 
    16 DIR_CC=../src/core 
    17 DIR_RT=../src/compiler/dmd 
    18 DIR_GC=../src/gc/basic 
     17DIR_CC=common 
     18DIR_RT=compiler/dmd 
     19DIR_GC=gc/basic 
    1920 
    2021CP=cp -f 
     
    4849    make -C $(DIR_RT) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 
    4950    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
    5152    $(LC) $(LIB_TARGET) `find $(DIR_CC) -name "*.o" | xargs echo` 
    5253    $(LC) $(LIB_TARGET) `find $(DIR_RT) -name "*.o" | xargs echo` 
    5354    $(LC) $(LIB_TARGET) `find $(DIR_GC) -name "*.o" | xargs echo` 
     55    $(RM) $(DUP_TARGET) 
     56    $(CP) $(LIB_TARGET) $(DUP_TARGET) 
    5457 
    5558doc : $(ALL_DOCS) 
  • branches/D1.0/src/dmd-win32.mak

    r16 r29  
    22# Designed to work with DigitalMars make 
    33# Targets: 
    4 #  make 
    5 #      Same as make all 
    6 #  make lib 
    7 #      Build the runtime library 
     4#   make 
     5#       Same as make all 
     6#   make lib 
     7#       Build the runtime library 
    88#   make doc 
    99#       Generate documentation 
    10 #  make clean 
    11 #      Delete unneeded files created by build process 
     10#   make clean 
     11#       Delete unneeded files created by build process 
    1212 
    1313LIB_TARGET=druntime-dmd.lib 
    14 LIB_MASK=druntime-dmd*.lib 
     14DUP_TARGET=druntime.lib 
     15LIB_MASK=druntime*.lib 
    1516 
    16 DIR_CC=core 
     17DIR_CC=common 
    1718DIR_RT=compiler\dmd 
    1819DIR_GC=gc\basic 
     
    5354    cd .. 
    5455    cd $(DIR_RT) 
    55     make -fwin32.mak lib 
     56    make -fwin32.mak lib DC=$(DC) 
    5657    cd ..\.. 
    5758    cd $(DIR_GC) 
     
    6061    $(RM) $(LIB_TARGET) 
    6162    $(LC) -c -n $(LIB_TARGET) $(LIB_CC) $(LIB_RT) $(LIB_GC) 
     63    $(RM) $(DUP_TARGET) 
     64    copy $(LIB_TARGET) $(DUP_TARGET) 
    6265 
    6366doc : $(ALL_DOCS) 
    6467    cd $(DIR_CC) 
    65     make -fwin32.mak doc 
     68    make -fwin32.mak doc DC=$(DC) 
    6669    cd .. 
    6770    cd $(DIR_RT) 
    68     make -fwin32.mak doc 
     71    make -fwin32.mak doc DC=$(DC) 
    6972    cd ..\.. 
    7073    cd $(DIR_GC) 
    71     make -fwin32.mak doc 
     74    make -fwin32.mak doc DC=$(DC) 
    7275    cd ..\.. 
    7376 
  • branches/D1.0/src/dmd.conf

    r27 r29  
    11[Environment] 
    2 DFLAGS=-version=Posix "-I%HOME%/core" "-I%HOME%/../import" 
     2DFLAGS=-version=Posix "-I%HOME%/common" "-I%HOME%/../import" 
  • branches/D1.0/src/gc/basic/gc.d

    r8 r29  
    2424 * Authors:   Walter Bright, Sean Kelly 
    2525 */ 
     26 
     27module gc.gc; 
    2628 
    2729private import gcx; 
  • branches/D1.0/src/gc/basic/gcalloc.d

    r8 r29  
    2525 */ 
    2626 
     27module gc.gcalloc; 
     28 
    2729 
    2830version (Windows) 
  • branches/D1.0/src/gc/basic/gcbits.d

    r8 r29  
    2525 */ 
    2626 
     27module gc.gcbits; 
     28 
    2729 
    2830private 
    2931{ 
    30     import bitmanip; 
     32    import core.bitmanip; 
    3133    import stdc.string; 
    3234    import stdc.stdlib; 
  • branches/D1.0/src/gc/basic/gcstats.d

    r8 r29  
    2525 */ 
    2626 
     27module gc.gcstats; 
     28 
    2729 
    2830/** 
  • branches/D1.0/src/gc/basic/gcx.d

    r8 r29  
    2424 * Authors:   Walter Bright, David Friedman, Sean Kelly 
    2525 */ 
     26 
     27module gc.gcx; 
    2628 
    2729// D Programming Language Garbage Collector implementation 
  • branches/D1.0/src/gc/stub/gc.d

    r8 r29  
    1818 * Authors:   Sean Kelly 
    1919 */ 
     20 
     21module gc.gc; 
    2022 
    2123private import stdc.stdlib; 
  • branches/D1.0/src/sc.ini

    r26 r29  
    44[Environment] 
    55LIB=%@P%\..\lib;\dm\lib 
    6 DFLAGS="-I%HOME%\core" "-I%HOME%\..\import" 
     6DFLAGS="-I%HOME%\common" "-I%HOME%\..\import" 
    77LINKCMD=%@P%\..\..\dm\bin\link.exe 
  • trunk/import/object.di

    r24 r29  
    209209    void function() unitTest; 
    210210 
    211     static int opApply( int delegate( inout ModuleInfo ) ); 
    212 } 
    213  
    214 class Exception : Object 
     211    static int opApply(int delegate(inout ModuleInfo)); 
     212} 
     213 
     214class Throwable : Object 
    215215{ 
    216216    interface TraceInfo 
    217217    { 
    218         int opApply( int delegate(inout char[]) ); 
     218        int opApply(int delegate(inout char[])); 
    219219        string toString(); 
    220220    } 
     
    224224    size_t      line; 
    225225    TraceInfo   info; 
    226     Exception   next; 
    227  
    228     this(string msg, Exception next = null); 
    229     this(string msg, string file, size_t line, Exception next = null); 
     226    Throwable   next; 
     227 
     228    this(string msg, Throwable next = null); 
     229    this(string msg, string file, size_t line, Throwable next = null); 
    230230    override string toString(); 
    231231} 
    232232 
    233233 
    234 alias Exception Error; 
     234class 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 
     241class 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  
    2424        import stdc.posix.unistd; 
    2525    } 
    26     import bitmanip; 
     26    import core.bitmanip; 
    2727    import stdc.stdio; 
    2828    import util.utf; 
  • trunk/src/compiler/dmd/deh.c

    r5 r29  
    3434#include        "mars.h" 
    3535 
    36 extern ClassInfo D9Exception7__ClassZ; 
    37  
    38 #define _Class_9Exception D9Exception7__ClassZ 
     36extern ClassInfo D6object9Throwable7__ClassZ; 
     37#define _Class_9Throwable D6object9Throwable7__ClassZ; 
     38 
     39extern ClassInfo D6object5Error7__ClassZ; 
     40#define _Class_5Error D6object5Error7__ClassZ 
    3941 
    4042typedef int (__pascal *fp_t)();   // function pointer in ambient memory model 
     
    152154                        } 
    153155                        else 
    154                             ci = &_Class_9Exception
     156                            ci = &_Class_9Throwable
    155157                    } 
    156158 
    157159                    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. 
    159162                        int regebp; 
    160163 
     
    230233Object *_d_create_exception_object(ClassInfo *ci, char *msg) 
    231234{ 
    232     Exception *exc; 
    233  
    234     exc = (Exception *)_d_newclass(ci); 
     235    Throwable *exc; 
     236 
     237    exc = (Throwable *)_d_newclass(ci); 
    235238    // BUG: what if _d_newclass() throws an out of memory exception? 
    236239 
     
    258261 
    259262        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"); 
    261264            break; 
    262265 
    263266        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"); 
    265268            break; 
    266269 
    267270        case STATUS_ACCESS_VIOLATION: 
    268             pti = _d_create_exception_object(&_Class_9Exception, "Access Violation"); 
     271            pti = _d_create_exception_object(&_Class_5Error, "Access Violation"); 
    269272            break; 
    270273 
    271274        case STATUS_STACK_OVERFLOW: 
    272             pti = _d_create_exception_object(&_Class_9Exception, "Stack Overflow"); 
     275            pti = _d_create_exception_object(&_Class_5Error, "Stack Overflow"); 
    273276            break; 
    274277 
    275278        // convert all other exception codes into a Win32Exception 
    276279        default: 
    277             pti = _d_create_exception_object(&_Class_9Exception, "Win32 Exception"); 
     280            pti = _d_create_exception_object(&_Class_5Error, "Win32 Exception"); 
    278281            break; 
    279282    } 
     
    414417#include        "mars.h" 
    415418 
    416 extern ClassInfo D9Exception7__ClassZ; 
    417  
    418 #define _Class_9Exception D9Exception7__ClassZ 
     419extern ClassInfo D6object9Throwable7__ClassZ; 
     420#define _Class_9Throwable D6object9Throwable7__ClassZ; 
     421 
     422extern ClassInfo D6object5Error7__ClassZ; 
     423#define _Class_5Error D6object5Error7__ClassZ 
    419424 
    420425typedef int (*fp_t)();   // function pointer in ambient memory model 
  • trunk/src/compiler/dmd/dmain2.d

    r28 r29  
    1919} 
    2020 
    21 version( Windows
     21version(Windows
    2222{ 
    2323    extern (Windows) void*      LocalFree(void*); 
     
    4343 * against this library. 
    4444 */ 
    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 ); 
     45extern (C) void onAssertError(string file, size_t line); 
     46extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 
     47extern (C) void onArrayBoundsError(string file, size_t line); 
     48extern (C) void onHiddenFuncError(Object o); 
     49extern (C) void onSwitchError(string file, size_t line); 
    4950extern (C) bool runModuleUnitTests(); 
    5051 
    5152// 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); 
    5354 
    5455/*********************************** 
    5556 * These are internal callbacks for various language errors. 
    5657 */ 
    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 /+ 
     58extern (C) void _d_assert(string file, uint line) 
     59
     60    onAssertError(file, line); 
     61
     62 
     63extern (C) static void _d_assert_msg(string msg, string file, uint line) 
     64
     65    onAssertErrorMsg(file, line, msg); 
     66
     67 
     68extern (C) void _d_array_bounds(string file, uint line) 
     69
     70    onArrayBoundsError(file, line); 
     71
     72 
     73extern (C) void _d_switch_error(string file, uint line) 
     74
     75    onSwitchError(file, line); 
     76
     77 
    7878extern (C) void _d_hidden_func() 
    7979{ 
    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
    8487 
    8588bool _d_isHalting = false; 
     
    101104} 
    102105 
    103 alias void delegate( Exception ) ExceptionHandler; 
    104  
    105 extern (C) bool rt_init( ExceptionHandler dg = null
     106alias void delegate(Throwable) ExceptionHandler; 
     107 
     108extern (C) bool rt_init(ExceptionHandler dg = null
    106109{ 
    107110    _d_criticalInit(); 
     
    115118        return true; 
    116119    } 
    117     catch( Exception e
    118     { 
    119         if( dg
    120             dg( e ); 
     120    catch (Throwable e
     121    { 
     122        if (dg
     123            dg(e); 
    121124    } 
    122125    catch 
     
    137140} 
    138141 
    139 extern (C) bool rt_term( ExceptionHandler dg = null
     142extern (C) bool rt_term(ExceptionHandler dg = null
    140143{ 
    141144    try 
     
    147150        return true; 
    148151    } 
    149     catch( Exception e
    150     { 
    151         if( dg
    152             dg( e ); 
     152    catch (Throwable e
     153    { 
     154        if (dg
     155            dg(e); 
    153156    } 
    154157    catch 
     
    201204        for (size_t i = 0, p = 0; i < wargc; i++) 
    202205        { 
    203             int wlen = wcslen( wargs[i] ); 
     206            int wlen = wcslen(wargs[i]); 
    204207            int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); 
    205208            args[i]  = cargp[p .. p+clen]; 
     
    235238                dg(); 
    236239            } 
    237             catch (Exception e) 
     240            catch (Throwable e) 
    238241            { 
    239242                while (e) 
     
    241244                    if (e.file) 
    242245                    { 
    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"); 
    245248                    } 
    246249                    else 
    247250                    { 
    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"); 
    250253                    } 
    251254                    if (e.info) 
  • trunk/src/compiler/dmd/lifetime.d

    r19 r29  
    6767    extern (C) BlkInfo gc_query( void* p ); 
    6868 
    69     extern (C) void onFinalizeError( ClassInfo c, Exception e ); 
     69    extern (C) void onFinalizeError( ClassInfo c, Throwable e ); 
    7070    extern (C) void onOutOfMemoryError(); 
    7171 
     
    530530                    _d_monitordelete(cast(Object)p, det); 
    531531            } 
    532             catch (Exception e) 
     532            catch (Throwable e) 
    533533            { 
    534534                onFinalizeError(**pc, e); 
  • trunk/src/compiler/dmd/mars.h

    r5 r29  
    6161} ClassInfo; 
    6262 
    63 typedef struct Exception 
     63typedef struct Throwable 
    6464{ 
    6565    Object object; 
     
    7474 
    7575    struct Interface *info; 
    76     struct Exception *next; 
    77 } Exception
     76    struct Throwable *next; 
     77} Throwable
    7878 
    7979typedef struct Array 
  • trunk/src/compiler/dmd/object_.d

    r28 r29  
    5555//alias typeof(cast(void*)0 - cast(void*)0)   ptrdiff_t; 
    5656 
    57 version( X86_64
     57version(X86_64
    5858{ 
    5959    alias ulong size_t; 
     
    127127    } 
    128128 
    129     /****** 
     129    /** 
    130130     * Create instance of class specified by classname. 
    131131     * The class must either have no constructors or have 
     
    217217        return o; 
    218218    } 
     219 
    219220    /** 
    220221     * Search for all members with the name 'name'. 
     
    247248{ 
    248249    override hash_t toHash() 
    249     {   hash_t hash; 
     250    { 
     251        hash_t hash; 
    250252 
    251253        foreach (char c; this.toString()) 
     
    10491051 
    10501052/////////////////////////////////////////////////////////////////////////////// 
    1051 // Exception 
     1053// Throwable 
    10521054/////////////////////////////////////////////////////////////////////////////// 
    10531055 
    10541056 
    1055 class Exception : Object 
     1057class Throwable : Object 
    10561058{ 
    10571059    interface TraceInfo 
    10581060    { 
    1059         int opApply( int delegate(inout char[]) ); 
     1061        int opApply(int delegate(inout char[])); 
    10601062    } 
    10611063 
     
    10641066    size_t      line; 
    10651067    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) 
    10701071    { 
    10711072        this.msg = msg; 
     
    10741075    } 
    10751076 
    1076     this( string msg, string file, size_t line, Exception next = null
     1077    this(string msg, string file, size_t line, Throwable next = null
    10771078    { 
    10781079        this(msg, next); 
     
    10841085    override string toString() 
    10851086    { 
    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 
     1114alias Throwable.TraceInfo function(void* ptr = null) TraceHandler; 
    11201115private TraceHandler traceHandler = null; 
    11211116 
     
    11271122 *  h = The new trace handler.  Set to null to use the default handler. 
    11281123 */ 
    1129 extern (C) void  rt_setTraceHandler( TraceHandler h
     1124extern (C) void  rt_setTraceHandler(TraceHandler h
    11301125{ 
    11311126    traceHandler = h; 
     
    11341129 
    11351130/** 
    1136  * This function will be called when an Exception is constructed.  The 
     1131 * This function will be called when an exception is constructed.  The 
    11371132 * user-supplied trace handler will be called if one has been supplied, 
    11381133 * otherwise no trace will be generated. 
     
    11471142 *  supplied. 
    11481143 */ 
    1149 Exception.TraceInfo traceContext( void* ptr = null
    1150 { 
    1151     if( traceHandler is null
     1144Throwable.TraceInfo traceContext(void* ptr = null
     1145{ 
     1146    if (traceHandler is null
    11521147        return null; 
    1153     return traceHandler( ptr ); 
     1148    return traceHandler(ptr); 
     1149
     1150 
     1151 
     1152class 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 
     1166class 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    } 
    11541177} 
    11551178 
     
    11851208    void function() ictor;      // module static constructor (order independent) 
    11861209 
    1187     static int opApply( int delegate(inout ModuleInfo) dg
     1210    static int opApply(int delegate(inout ModuleInfo) dg
    11881211    { 
    11891212        int ret = 0; 
    11901213 
    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
    11951218                break; 
    11961219        } 
     
    12901313            {   if (skip || m.flags & MIstandalone) 
    12911314                    continue; 
    1292                     throw new Exception( "Cyclic dependency in module " ~ m.name ); 
     1315                    throw new Exception("Cyclic dependency in module " ~ m.name); 
    12931316            } 
    12941317 
  • trunk/src/dmd-posix.mak

    r16 r29  
    1212 
    1313LIB_TARGET=libdruntime-dmd.a 
    14 LIB_MASK=libdruntime-dmd*.a 
     14DUP_TARGET=libdruntime.a 
     15LIB_MASK=libdruntime*.a 
    1516 
    16 DIR_CC=../src/core 
    17 DIR_RT=../src/compiler/dmd 
    18 DIR_GC=../src/gc/basic 
     17DIR_CC=common 
     18DIR_RT=compiler/dmd 
     19DIR_GC=gc/basic 
    1920 
    2021CP=cp -f 
     
    4849    make -C $(DIR_RT) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" 
    4950    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
    5152    $(LC) $(LIB_TARGET) `find $(DIR_CC) -name "*.o" | xargs echo` 
    5253    $(LC) $(LIB_TARGET) `find $(DIR_RT) -name "*.o" | xargs echo` 
    5354    $(LC) $(LIB_TARGET) `find $(DIR_GC) -name "*.o" | xargs echo` 
     55    $(RM) $(DUP_TARGET) 
     56    $(CP) $(LIB_TARGET) $(DUP_TARGET) 
    5457 
    5558doc : $(ALL_DOCS) 
  • trunk/src/dmd-win32.mak

    r21 r29  
    1111#       Delete unneeded files created by build process 
    1212 
    13 LIB_TARGET=druntime.lib 
    14 LIB_MASK=druntime.lib 
     13LIB_TARGET=druntime-dmd.lib 
     14DUP_TARGET=druntime.lib 
     15LIB_MASK=druntime*.lib 
    1516 
    16 DIR_CC=core 
     17DIR_CC=common 
    1718DIR_RT=compiler\dmd 
    1819DIR_GC=gc\basic 
     
    6061    $(RM) $(LIB_TARGET) 
    6162    $(LC) -c -n $(LIB_TARGET) $(LIB_CC) $(LIB_RT) $(LIB_GC) 
     63    $(RM) $(DUP_TARGET) 
     64    copy $(LIB_TARGET) $(DUP_TARGET) 
    6265 
    6366doc : $(ALL_DOCS) 
  • trunk/src/dmd.conf

    r27 r29  
    11[Environment] 
    2 DFLAGS=-version=Posix "-I%HOME%/core" "-I%HOME%/../import" 
     2DFLAGS=-version=Posix "-I%HOME%/common" "-I%HOME%/../import" 
  • trunk/src/gc/basic/gc.d

    r5 r29  
    2424 * Authors:   Walter Bright, Sean Kelly 
    2525 */ 
     26 
     27module gc.gc; 
    2628 
    2729private import gcx; 
  • trunk/src/gc/basic/gcalloc.d

    r5 r29  
    2525 */ 
    2626 
     27module gc.gcalloc; 
     28 
    2729 
    2830version (Windows) 
  • trunk/src/gc/basic/gcbits.d

    r10 r29  
    2525 */ 
    2626 
     27module gc.gcbits; 
     28 
    2729 
    2830private 
    2931{ 
    30     import bitmanip; 
     32    import core.bitmanip; 
    3133    import stdc.string; 
    3234    import stdc.stdlib; 
  • trunk/src/gc/basic/gcstats.d

    r5 r29  
    2525 */ 
    2626 
     27module gc.gcstats; 
     28 
    2729 
    2830/** 
  • trunk/src/gc/basic/gcx.d

    r10 r29  
    2424 * Authors:   Walter Bright, David Friedman, Sean Kelly 
    2525 */ 
     26 
     27module gc.gcx; 
    2628 
    2729// D Programming Language Garbage Collector implementation 
  • trunk/src/gc/stub/gc.d

    r5 r29  
    1818 * Authors:   Sean Kelly 
    1919 */ 
     20 
     21module gc.gc; 
    2022 
    2123private import stdc.stdlib; 
  • trunk/src/sc.ini

    r26 r29  
    44[Environment] 
    55LIB=%@P%\..\lib;\dm\lib 
    6 DFLAGS="-I%HOME%\core" "-I%HOME%\..\import" 
     6DFLAGS="-I%HOME%\common" "-I%HOME%\..\import" 
    77LINKCMD=%@P%\..\..\dm\bin\link.exe