Changeset 360
- Timestamp:
- 08/30/08 01:32:07 (3 months ago)
- Files:
-
- branches/v2new/minid/arraylib.d (modified) (1 diff)
- branches/v2new/minid/hashlib.d (modified) (1 diff)
- branches/v2new/minid/interpreter.d (modified) (8 diffs)
- branches/v2new/minid/iolib.d (modified) (1 diff)
- branches/v2new/minid/mathlib.d (modified) (2 diffs)
- branches/v2new/minid/oslib.d (modified) (1 diff)
- branches/v2new/minid/regexplib.d (modified) (1 diff)
- branches/v2new/minid/stringlib.d (modified) (2 diffs)
- branches/v2new/minid/timelib.d (modified) (1 diff)
- branches/v2new/samples/simple.md (modified) (13 diffs)
- branches/v2new/test.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/v2new/minid/arraylib.d
r352 r360 90 90 91 91 fielda(t, -2, "array"); 92 pop(t);93 94 92 importModule(t, "array"); 93 pop(t, 3); 95 94 } 96 95 branches/v2new/minid/hashlib.d
r358 r360 65 65 66 66 fielda(t, -2, "hash"); 67 pop(t);68 69 67 importModule(t, "hash"); 70 } 71 68 pop(t, 3); 69 } 70 72 71 uword dupImpl(MDThread* t, word slot) 73 72 { branches/v2new/minid/interpreter.d
r358 r360 3693 3693 if(a.type != b.type) 3694 3694 return false; 3695 3695 3696 3696 if(a.opEquals(*b)) 3697 3697 return true; … … 3704 3704 return commonCompare(t, method, b, a) == 0; 3705 3705 } 3706 3706 3707 3707 return false; 3708 3708 } … … 4564 4564 t.getFiber().call(); 4565 4565 catch(Object o) 4566 throw o; 4566 throw o; // wut? 4567 4567 4568 4568 return t.numYields; … … 5245 5245 table.remove(container.mTable, *key); 5246 5246 } 5247 else 5247 else if(value.type != MDValue.Type.Null) 5248 5248 { 5249 5249 if(raw || !tryMM!(3, false)(t, MM.IndexAssign, container, key, value)) 5250 5250 table.set(t.vm.alloc, container.mTable, *key, *value); 5251 5251 } 5252 // otherwise, do nothing (val is null and it doesn't exist) 5252 5253 } 5253 5254 … … 5568 5569 void throwImpl(MDThread* t, MDValue* ex) 5569 5570 { 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, ": "); 5570 5574 pushDebugLoc(t); 5571 pushString(t, ": "); 5572 toStringImpl(t, *ex, true); 5575 swap(t, -3); 5573 5576 cat(t, 3); 5577 5574 5578 // dup'ing since we're removing the only MiniD reference and handing it off to D 5575 5579 auto msg = getString(t, -1).dup; … … 5636 5640 dup(t); 5637 5641 setFuncEnv(t, reg); 5638 5639 5642 auto ns = getNamespace(t, -1); 5640 5643 5641 // Call it 5644 // Call it with the name as the first param 5645 pushStringObj(t, name); 5642 5646 rawCall(t, reg, 0); 5643 5647 … … 5835 5839 assert(jump.opcode == Op.Je && jump.rd == 1, "invalid 'swcmp' jump"); 5836 5840 5837 if(switchCmpImpl(t, get(i.rs), get(i.rt)) == 0)5841 if(switchCmpImpl(t, get(i.rs), get(i.rt))) 5838 5842 t.currentAR.pc += jump.imm; 5839 5843 … … 6605 6609 if(tr.isCatch) 6606 6610 { 6607 auto base = stackBase + tr.catchVarSlot;6611 auto base = t.stackBase + tr.catchVarSlot; 6608 6612 6609 6613 t.stack[base] = t.vm.exception; branches/v2new/minid/iolib.d
r359 r360 129 129 130 130 fielda(t, -2, "io"); 131 pop(t);132 133 131 importModule(t, "io"); 132 pop(t, 3); 134 133 } 135 134 branches/v2new/minid/mathlib.d
r352 r360 96 96 97 97 fielda(t, -2, "math"); 98 pop(t);99 100 98 importModule(t, "math"); 99 pop(t, 3); 101 100 } 102 101 … … 336 335 throwException(t, "Low and high values must be different"); 337 336 338 pushInt(t, cast(mdint)(num % (hi - lo)) + lo);337 pushInt(t, (cast(uword)num % (hi - lo)) + lo); 339 338 break; 340 339 } branches/v2new/minid/oslib.d
r355 r360 66 66 67 67 fielda(t, -2, "os"); 68 pop(t);69 70 68 importModule(t, "os"); 69 pop(t, 3); 71 70 } 72 71 branches/v2new/minid/regexplib.d
r359 r360 78 78 79 79 fielda(t, -2, "regexp"); 80 pop(t);81 82 80 importModule(t, "regexp"); 81 pop(t, 3); 83 82 } 84 83 branches/v2new/minid/stringlib.d
r354 r360 80 80 81 81 fielda(t, -2, "string"); 82 pop(t);83 84 82 importModule(t, "string"); 83 pop(t, 3); 85 84 } 86 85 … … 357 356 pushString(t, piece); 358 357 num++; 359 358 360 359 if(num >= 50) 361 360 { branches/v2new/minid/timelib.d
r354 r360 82 82 83 83 fielda(t, -2, "time"); 84 pop(t);85 86 84 importModule(t, "time"); 87 } 88 85 pop(t, 3); 86 } 87 89 88 uword microTime(MDThread* t, uword numParams) 90 89 { branches/v2new/samples/simple.md
r359 r360 1 1 module samples.simple 2 2 3 4 5 3 /+ 4 /* 6 5 object BaseProp 7 6 { … … 39 38 40 39 if(oldField is null) 41 return rawGet (this, name)40 return rawGetField(this, name) 42 41 else 43 42 return oldField(with this, name) … … 50 49 51 50 if(oldFieldAssign is null) 52 rawSet (this, name, value)51 rawSetField(this, name, value) 53 52 else 54 53 return oldFieldAssign(with this, name, value) … … 150 149 // Importing stuff. 151 150 { 152 local function loadMod(name , ns)151 local function loadMod(name: string) 153 152 { 154 153 assert(name == "mod") 155 154 156 ns.x = "I'm x"157 158 ns.foo =function foo()155 global x = "I'm x" 156 157 global function foo() 159 158 writefln("foo") 160 159 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() 164 163 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 174 169 foo() 175 170 writefln(bar([5])) … … 230 225 foreach(_, k, v; forEach, {hi = 1, bye = 2}) 231 226 writefln("key: ", k, ", value: ", v) 232 227 233 228 writefln() 234 229 } … … 597 592 598 593 writefln() 599 594 600 595 foreach(k, v; test, "reverse") 601 596 writefln("test[", k, "] = ", v) … … 631 626 632 627 writefln() 633 628 634 629 foreach(k, v; "hello", "reverse") 635 630 writefln("str[", k, "] = ", v) … … 710 705 catch(e) 711 706 writefln("caught: ", e) 712 707 713 708 writefln() 714 709 } … … 729 724 foreach(i, v; array) 730 725 writefln("arr[", i, "] = ", v) 731 726 732 727 writefln() 733 728 } … … 746 741 747 742 vargs() 748 749 writefln() 750 743 writefln() 751 744 vargs(2, 3, 5, "foo", "bar") 752 753 745 writefln() 754 746 } … … 790 782 791 783 writefln() 792 784 793 785 local object A 794 786 { 795 787 mValue 796 788 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 804 794 } 805 795 … … 808 798 local a3 = A.clone(3) 809 799 810 for(s : 1 .. 4)800 for(s: 1 .. 4) 811 801 { 812 802 local ss = A.clone(s) … … 817 807 writefln(1) 818 808 break 819 809 820 810 case a2: 821 811 writefln(2) branches/v2new/test.d
r359 r360 19 19 { 20 20 importModule(t, "samples.simple"); 21 pop(t); 21 22 } 22 23 catch(MDException e)
