Changeset 148

Show
Ignore:
Timestamp:
04/27/08 03:20:30 (4 months ago)
Author:
dan.lewis
Message:

Reverted to DMD 1.028 from DMD 2.x.
Wrote my own make bat.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.9/clean.bat

    r140 r148  
    44 
    55del bin\*.obj bin\walnut.* 
     6 
     7 
     8PAUSE 
  • branches/1.9/make.bat

    r143 r148  
    1  
    2 :: >make -debug 
    3 :: passes -debug and 
    4 :: >make -release 
    5 :: passes -release to the following line: 
    61 
    72del bin\*.obj bin\walnut.* 
    8 bud.exe -od.\bin -T.\bin\walnut source\main -O -LIBOPT/ma/co %1 
    9  
    10 :: you should be able to figure it out from there. 
     3cd source 
     4dmd -c -O -release -debug -od..\bin main.d methods.d parser.d structure.d text.d value.d 
     5cd ..\bin 
     6lib -c walnut.lib methods.obj parser.obj structure.obj text.obj value.obj 
     7dmd walnut.exe main.obj -L/ma walnut.lib 
     8PAUSE 
  • branches/1.9/source/main.d

    r143 r148  
    1616    value; 
    1717 
    18 // pragma(lib,"bin\\walnut.lib"); 
    19  
    20 enum EXIT { 
    21     SUCCESS = 0x00, 
    22     FAILURE = 0x01, 
    23 } 
    24  
    2518int main(char[][] arguments) { 
    2619     
    2720    /// Fail hard if there's no script. 
    2821    if(!arguments.length) 
    29         return EXIT.FAILURE
     22        return 1
    3023     
    3124    /// Initialize the program state 
    3225    Value global = Global_init(); 
    33     const_string path; 
     26    char[] path; 
    3427     
    3528    /// Grab the files and collect the source 
    3629    for(size_t i = 1; i < arguments.length; i++) { 
    3730        path = std.path.defaultExt(arguments[i],"nut"); 
    38         parseProgram(cast(Value) (cast(const_string) std.file.read(path) ~ '\0'), global); 
     31        parseProgram(cast(Value) (cast(char[]) std.file.read(path)), global); 
    3932    } 
    4033     
    4134    /// all done. 
    42     return EXIT.SUCCESS
     35    return 0
    4336} 
  • branches/1.9/source/methods.d

    r142 r148  
    7373} 
    7474static Value* Object_prototype_toSource(ref Value self, ref Value cc, Value[] arguments ...) { 
    75     const_string buffer = "{"; 
     75    char[] buffer = "{"; 
    7676    bool any = false; 
    7777    for(int i = 0; i < self.length; i++) { 
     
    150150} 
    151151static Value* Array_prototype_toLocaleString(ref Value self, ref Value cc, Value[] arguments ...) { 
    152     const_string r = "["; 
     152    char[] r = "["; 
    153153    char c = ','; // this character needs to be locale "list separator" 
    154154    if(self.a.length) { 
     
    163163} 
    164164static Value* Array_prototype_toSource(ref Value self, ref Value cc, Value[] arguments ...) { 
    165     const_string r = "["; 
     165    char[] r = "["; 
    166166    if(self.a.length) { 
    167167        r ~= self.a[0].toString(); 
     
    185185} 
    186186static Value* Array_prototype_join(ref Value self, ref Value cc, Value[] arguments ...) { 
    187     const_string s = TEXT._; 
     187    char[] s = TEXT._; 
    188188    if(arguments.length) 
    189189        s = arguments[0].toString(); 
    190     const_string r = self.a[0].toString(); 
     190    char[] r = self.a[0].toString(); 
    191191    for(int i = 1; i < self.a.length; i++) { 
    192192        r ~= s; 
     
    315315static Value* String_prototype_match(ref Value self, ref Value cc, Value[] arguments ...) { 
    316316    if(arguments.length && arguments[0].type == TYPE.REGEXP) { 
    317         const_string[] m = arguments[0].r.match(self.toString()); 
     317        char[][] m = arguments[0].r.match(self.toString()); 
    318318        Value[] v = []; 
    319         foreach(const_string s; m) { 
     319        foreach(char[] s; m) { 
    320320            v ~= cast(Value) s; 
    321321        } 
     
    351351        goto _no0; 
    352352    if(arguments[0].type == TYPE.REGEXP) { 
    353         const_string[] v = arguments[0].r.split(self.toString()); 
    354         foreach(const_string s; v) { 
     353        char[][] v = arguments[0].r.split(self.toString()); 
     354        foreach(char[] s; v) { 
    355355            a ~= cast(Value) s; 
    356356        } 
    357357        return &cast(Value) a; 
    358358    } 
    359     const_string sep; 
     359    char[] sep; 
    360360    sep = arguments[0].toString(); 
    361361    if(sep.length == 0) { 
     
    363363        a.length = self.s.length; 
    364364        a[i].type = TYPE.STRING; 
    365         a[i].s = self.s.idup; 
     365        a[i].s = self.s.dup; 
    366366    } 
    367367    else { 
     
    421421        s[i++] = std.uni.toUniLower(c); 
    422422    } 
    423     return &cast(Value) cast(const_string) s; 
     423    return &cast(Value) cast(char[]) s; 
    424424} 
    425425static Value* String_prototype_toUpperCase(ref Value self, ref Value cc, Value[] arguments ...) { 
     
    432432        s[i++] = std.uni.toUniUpper(c); 
    433433    } 
    434     return &cast(Value) cast(const_string) s; 
     434    return &cast(Value) cast(char[]) s; 
    435435} 
    436436 
     
    10351035    if(arguments.length) { 
    10361036        Value[] a = []; 
    1037         const_string[] m = self.r.exec(arguments[0].toString()); 
    1038         foreach(const_string s; m) { 
     1037        char[][] m = self.r.exec(arguments[0].toString()); 
     1038        foreach(char[] s; m) { 
    10391039            a ~= cast(Value) s; 
    10401040        } 
  • branches/1.9/source/parser.d

    r147 r148  
    6363uint line = 1, lineMark; 
    6464char last = 0x00; 
    65 const_char* c; 
     65char* c; 
    6666Value v; 
    6767Value context; 
     
    7272    c = &source.toString()[0]; 
    7373    context = cc; 
    74     const_char* cMark; 
    75      
    76     scope(failure) 
    77         dumpTree(v, 1, true); 
    78      
     74    char* cMark; 
     75    debug 
     76        scope(failure) 
     77            dumpTree(v, 1, true); 
    7978    while(true) { 
    8079        cMark = c; 
     
    8887    v.a = buffer; 
    8988    v.type = TYPE.STATEMENTS; 
    90     dumpTree(v, 1, false); 
     89    debug 
     90        dumpTree(v, 1, false); 
    9191} 
    9292 
    9393void parseStatement() 
    9494{ 
    95     debug printf("!%d : parseStatement()\n",c); 
     95    debug 
     96        printf("!%d : parseStatement()\n",c); 
    9697    Value[] buffer; 
    97     const_string s; 
    98     const_char* cMark; 
     98    char[] s; 
     99    char* cMark; 
    99100     
    100101    /* Block, 12.1 */ 
     
    139140    debug printf("!%d : parseExpression()\n",c); 
    140141    Value[] buffer; 
    141     const_char* cMark; 
     142    char* cMark; 
    142143    bool bFlag = false; 
    143144     
     
    250251    Note: this is called from parsePrimary, as it's picked up by virtue of starting with an [a-zA-Z_$] 
    251252*/ 
    252 bool parseKeyword(const_string s) 
     253bool parseKeyword(char[] s) 
    253254{ 
    254255    debug printf("!%d : parseKeyword()\n",c); 
    255256     
    256257    Value[] buffer; 
    257     const_char* cMark; 
     258    char* cMark; 
    258259    int i; 
    259260     
     
    586587{ 
    587588    Value[] buffer; 
    588     const_char* cMark; 
     589    char* cMark; 
    589590    debug printf("!%d : KEYVAR\n",c); 
    590591    while(true) { 
     
    610611    bool neg; 
    611612    double d; 
    612     const_char* cMark = c; 
     613    char* cMark = c; 
    613614    switch(c[0]) { 
    614615        case '\'': 
    615616        case '"': 
    616617            /* String literal. 7.8.4 page 20  */ 
    617             const_string s; 
    618             const_char* cMark2; 
     618            char[] s; 
     619            char* cMark2; 
    619620            cMark2 = c; 
    620621            for(c++; c[0] != cMark2[0]; c++) { 
     
    651652            } 
    652653            c++; 
    653             const_string s = cMark[0..(c-cMark)]; 
     654            char[] s = cMark[0..(c-cMark)]; 
    654655            cMark = c; 
    655656            while(c[0] == 'g' || c[0] == 'i' || c[0] == 'm') { 
     
    808809        case '{': 
    809810            debug printf("!%d :     ObjectLiteral Expression starting\n", c); 
    810             const_string[] b1; 
     811            char[][] b1; 
    811812            Value[] b2; 
    812813            uint len = 0; 
     
    845846            {} 
    846847            debug assert(cMark < c, TEXT._unexpected_token); 
    847             const_string s = cMark[0..(c-cMark)]; 
     848            char[] s = cMark[0..(c-cMark)]; 
    848849            if(parseKeyword(s)) 
    849850                return; 
  • branches/1.9/source/value.d

    r147 r148  
    1919alias std.date.d_time d_time; 
    2020alias std.regexp.RegExp RegExp; 
    21  
    22 version(D_Version2) { 
    23     alias const(char) const_char; 
    24     alias const(Value) const_Value; 
    25     alias const(char)[] const_string; 
    26 } else { 
    27     alias char const_char; 
    28     alias Value const_Value; 
    29     alias char[] const_string; 
    30 } 
    3121 
    3222/// TYPE can be checked at runtime to find out what the type of a Value is. 
     
    161151        struct { 
    162152            uint length; 
    163             const_string* keys; 
     153            char[]* keys; 
    164154            Value* values; 
    165155        } 
     
    169159        } 
    170160        Value[] a; 
    171         const_string s; 
     161        char[] s; 
    172162        bool b; 
    173163        int i; 
     
    182172        Object interactions 
    183173    */ 
    184     const bool opIn_r(const_string key) { 
     174    bool opIn_r(char[] key) { 
    185175        /// OPTIMIZE: linear search 
    186176        for(int i = 1; i < length; i++) { 
     
    190180        return false; 
    191181    } 
    192     const Value opIndex(const_string key) { 
     182    Value opIndex(char[] key) { 
    193183        /// OPTIMIZE: linear search 
    194         const(Value)* self = this; 
     184        Value* self = this; 
    195185        int i; 
    196186        do { 
     
    203193        return UNDEFINED; 
    204194    } 
    205     void opIndexAssign(Value v, const_string key) { 
     195    void opIndexAssign(Value v, char[] key) { 
    206196        /// OPTIMIZE: linear search 
    207197        for(int i = 1; i < length; i++) { 
     
    213203        length++; 
    214204        /// OPTIMIZE: one-at-a-time realloc 
    215         keys = cast(const_string*) std.c.stdlib.realloc(keys,length); 
     205        keys = cast(char[]*) std.c.stdlib.realloc(keys,length); 
    216206        values = cast(Value*) std.c.stdlib.realloc(values,Value.sizeof * length); 
    217207    } 
     
    251241        s[0] = x; 
    252242        Value v = void; 
    253         v.s = cast(const_string) s; 
     243        v.s = cast(char[]) s; 
    254244        v.type = TYPE.STRING; 
    255245        return v; 
    256246    } 
    257     static Value opCall(const_string x) { 
     247    static Value opCall(char[] x) { 
    258248        Value v = void; 
    259249        v.s = x; 
     
    306296        char[] s; 
    307297        s[0] = x; 
    308         this.s = cast(const_string) s; 
     298        this.s = cast(char[]) s; 
    309299        type = TYPE.STRING; 
    310300    } 
    311     void opAssign(const_string x) { 
     301    void opAssign(char[] x) { 
    312302        s = x; 
    313303        type = TYPE.STRING; 
     
    337327        artificial opCasts 
    338328    */ 
    339     const bool toBoolean() { 
     329    bool toBoolean() { 
    340330        /* ToBoolean 9.2 page 30 */ 
    341331        switch(type) { 
     
    350340        assert(0,TEXT._unexpected_token); // throw a TypeError 
    351341    } 
    352     const const_string toString() { 
     342    char[] toString() { 
    353343        /* ToString 9.8 page 35 */ 
    354344        switch(type) { 
     
    374364                    We need to get it's className, which is stored as the TEXT._x value for it's constructor in Global. 
    375365                */ 
    376                 const_string s; 
     366                char[] s; 
    377367                for(int i = 2; i < Global.length; i++) { 
    378368                    if(*this == Global.values[i]) { 
     
    397387        assert(0); // throw a TypeError 
    398388    } 
    399     const int toInteger() { 
     389    int toInteger() { 
    400390        /* ToInteger 9.4 page 34 */ 
    401391        switch(type) { 
     
    422412        assert(0); // throw a TypeError 
    423413    } 
    424     const double toDouble() { 
     414    double toDouble() { 
    425415        /* ToNumber 9.3 page 31 */ 
    426416        switch(type) { 
     
    446436        assert(0); // throw a TypeError 
    447437    } 
    448     const Value toObject() { 
     438    Value toObject() { 
    449439        /* ToObject 9.9 page 36 */ 
    450440        switch(type) {