Changeset 360

Show
Ignore:
Timestamp:
08/30/08 01:32:07 (3 months ago)
Author:
JarrettBillingsley
Message:

Some fixes. simple.md now runs correctly all the way through!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/v2new/minid/arraylib.d

    r352 r360  
    9090 
    9191        fielda(t, -2, "array"); 
    92         pop(t); 
    93  
    9492        importModule(t, "array"); 
     93        pop(t, 3); 
    9594    } 
    9695 
  • branches/v2new/minid/hashlib.d

    r358 r360  
    6565 
    6666        fielda(t, -2, "hash"); 
    67         pop(t); 
    68  
    6967        importModule(t, "hash"); 
    70     } 
    71      
     68        pop(t, 3); 
     69    } 
     70 
    7271    uword dupImpl(MDThread* t, word slot) 
    7372    { 
  • branches/v2new/minid/interpreter.d

    r358 r360  
    36933693    if(a.type != b.type) 
    36943694        return false; 
    3695          
     3695 
    36963696    if(a.opEquals(*b)) 
    36973697        return true; 
     
    37043704            return commonCompare(t, method, b, a) == 0; 
    37053705    } 
    3706  
     3706     
    37073707    return false; 
    37083708} 
     
    45644564            t.getFiber().call(); 
    45654565        catch(Object o) 
    4566             throw o; 
     4566            throw o; // wut? 
    45674567         
    45684568        return t.numYields; 
     
    52455245            table.remove(container.mTable, *key); 
    52465246    } 
    5247     else 
     5247    else if(value.type != MDValue.Type.Null) 
    52485248    { 
    52495249        if(raw || !tryMM!(3, false)(t, MM.IndexAssign, container, key, value)) 
    52505250            table.set(t.vm.alloc, container.mTable, *key, *value); 
    52515251    } 
     5252    // otherwise, do nothing (val is null and it doesn't exist) 
    52525253} 
    52535254 
     
    55685569void throwImpl(MDThread* t, MDValue* ex) 
    55695570{ 
     5571    // doing this backwards since ex can be on the stack - don't want stack to move underneath us 
     5572    toStringImpl(t, *ex, true); 
     5573    pushString(t, ": "); 
    55705574    pushDebugLoc(t); 
    5571     pushString(t, ": "); 
    5572     toStringImpl(t, *ex, true); 
     5575    swap(t, -3); 
    55735576    cat(t, 3); 
     5577 
    55745578    // dup'ing since we're removing the only MiniD reference and handing it off to D 
    55755579    auto msg = getString(t, -1).dup; 
     
    56365640        dup(t); 
    56375641        setFuncEnv(t, reg); 
    5638          
    56395642        auto ns = getNamespace(t, -1); 
    56405643 
    5641         // Call it 
     5644        // Call it with the name as the first param 
     5645        pushStringObj(t, name); 
    56425646        rawCall(t, reg, 0); 
    56435647         
     
    58355839                    assert(jump.opcode == Op.Je && jump.rd == 1, "invalid 'swcmp' jump"); 
    58365840 
    5837                     if(switchCmpImpl(t, get(i.rs), get(i.rt)) == 0
     5841                    if(switchCmpImpl(t, get(i.rs), get(i.rt))
    58385842                        t.currentAR.pc += jump.imm; 
    58395843 
     
    66056609                if(tr.isCatch) 
    66066610                { 
    6607                     auto base = stackBase + tr.catchVarSlot; 
     6611                    auto base = t.stackBase + tr.catchVarSlot; 
    66086612 
    66096613                    t.stack[base] = t.vm.exception; 
  • branches/v2new/minid/iolib.d

    r359 r360  
    129129 
    130130        fielda(t, -2, "io"); 
    131         pop(t); 
    132  
    133131        importModule(t, "io"); 
     132        pop(t, 3); 
    134133    } 
    135134 
  • branches/v2new/minid/mathlib.d

    r352 r360  
    9696 
    9797        fielda(t, -2, "math"); 
    98         pop(t); 
    99  
    10098        importModule(t, "math"); 
     99        pop(t, 3); 
    101100    } 
    102101 
     
    336335                    throwException(t, "Low and high values must be different"); 
    337336 
    338                 pushInt(t, cast(mdint)(num % (hi - lo)) + lo); 
     337                pushInt(t, (cast(uword)num % (hi - lo)) + lo); 
    339338                break; 
    340339        } 
  • branches/v2new/minid/oslib.d

    r355 r360  
    6666         
    6767        fielda(t, -2, "os"); 
    68         pop(t); 
    69  
    7068        importModule(t, "os"); 
     69        pop(t, 3); 
    7170    } 
    7271 
  • branches/v2new/minid/regexplib.d

    r359 r360  
    7878 
    7979        fielda(t, -2, "regexp"); 
    80         pop(t); 
    81  
    8280        importModule(t, "regexp"); 
     81        pop(t, 3); 
    8382    } 
    8483 
  • branches/v2new/minid/stringlib.d

    r354 r360  
    8080         
    8181        fielda(t, -2, "string"); 
    82         pop(t); 
    83  
    8482        importModule(t, "string"); 
     83        pop(t, 3); 
    8584    } 
    8685 
     
    357356                    pushString(t, piece); 
    358357                    num++; 
    359                      
     358 
    360359                    if(num >= 50) 
    361360                    { 
  • branches/v2new/minid/timelib.d

    r354 r360  
    8282 
    8383        fielda(t, -2, "time"); 
    84         pop(t); 
    85  
    8684        importModule(t, "time"); 
    87     } 
    88      
     85        pop(t, 3); 
     86    } 
     87 
    8988    uword microTime(MDThread* t, uword numParams) 
    9089    { 
  • branches/v2new/samples/simple.md

    r359 r360  
    11module samples.simple 
    22 
    3  
    4  
    53/+ 
     4/* 
    65object BaseProp 
    76{ 
     
    3938 
    4039        if(oldField is null) 
    41             return rawGet(this, name) 
     40            return rawGetField(this, name) 
    4241        else 
    4342            return oldField(with this, name) 
     
    5049 
    5150        if(oldFieldAssign is null) 
    52             rawSet(this, name, value) 
     51            rawSetField(this, name, value) 
    5352        else 
    5453            return oldFieldAssign(with this, name, value) 
     
    150149// Importing stuff. 
    151150{ 
    152     local function loadMod(name, ns
     151    local function loadMod(name: string
    153152    { 
    154153        assert(name == "mod") 
    155154 
    156         ns.x = "I'm x" 
    157  
    158         ns.foo = function foo() 
     155        global x = "I'm x" 
     156 
     157        global function foo() 
    159158            writefln("foo") 
    160159 
    161         ns.bar = function bar(x) = x[0] 
    162  
    163         ns.baz = function baz() 
     160        global function bar(x) = x[0] 
     161 
     162        global function baz() 
    164163            writefln(x) 
    165  
    166         foreach(k, v; ns) 
    167             if(isFunction(v)) 
    168                 v.environment(ns) 
    169     } 
    170  
    171     setModuleLoader("mod", loadMod) 
    172  
    173     import mod : foo, bar 
     164    } 
     165 
     166    modules.customLoaders.mod = loadMod 
     167 
     168    import mod: foo, bar 
    174169    foo() 
    175170    writefln(bar([5])) 
     
    230225    foreach(_, k, v; forEach, {hi = 1, bye = 2}) 
    231226        writefln("key: ", k, ", value: ", v) 
    232      
     227 
    233228    writefln() 
    234229} 
     
    597592 
    598593    writefln() 
    599      
     594 
    600595    foreach(k, v; test, "reverse") 
    601596        writefln("test[", k, "] = ", v) 
     
    631626     
    632627    writefln() 
    633      
     628 
    634629    foreach(k, v; "hello", "reverse") 
    635630        writefln("str[", k, "] = ", v) 
     
    710705    catch(e) 
    711706        writefln("caught: ", e) 
    712      
     707 
    713708    writefln() 
    714709} 
     
    729724    foreach(i, v; array) 
    730725        writefln("arr[", i, "] = ", v) 
    731      
     726 
    732727    writefln() 
    733728} 
     
    746741 
    747742    vargs() 
    748      
    749     writefln() 
    750      
     743    writefln() 
    751744    vargs(2, 3, 5, "foo", "bar") 
    752      
    753745    writefln() 
    754746} 
     
    790782     
    791783    writefln() 
    792      
     784 
    793785    local object A 
    794786    { 
    795787        mValue 
    796788 
    797         function clone(value) = object : this { mValue = value } 
    798  
    799         function opCmp(other) 
    800         { 
    801             assert(other as A) 
    802             return :mValue <=> other.mValue 
    803         } 
     789        function clone(value) = 
     790            object : this { mValue = value } 
     791 
     792        function opCmp(other: A) = 
     793            :mValue <=> other.mValue 
    804794    } 
    805795 
     
    808798    local a3 = A.clone(3) 
    809799 
    810     for(s : 1 .. 4) 
     800    for(s: 1 .. 4) 
    811801    { 
    812802        local ss = A.clone(s) 
     
    817807                writefln(1) 
    818808                break 
    819      
     809 
    820810            case a2: 
    821811                writefln(2) 
  • branches/v2new/test.d

    r359 r360  
    1919    { 
    2020        importModule(t, "samples.simple"); 
     21        pop(t); 
    2122    } 
    2223    catch(MDException e)