1
0

引数あり関数を呼べるようにした

This commit is contained in:
otya128
2015-06-13 20:34:19 +09:00
parent c5b2f1af67
commit f1ecd08462
3 changed files with 6 additions and 3 deletions

View File

@@ -710,6 +710,7 @@ class ReturnFunction : Code
Value bp, pc;
vm.pop(pc);
vm.pop(bp);
vm.stacki -= func.argCount;
if(func.returnExpr)
{
vm.push(retexpr);
@@ -739,9 +740,10 @@ class CallFunctionCode : Code
throw new IllegalFunctionCall();
}
//TODO:args
auto bp = vm.stacki;
vm.push(Value(vm.bp));
vm.push(Value(vm.pc));
vm.bp = vm.stacki - 2;
vm.bp = bp;
vm.pc = func.address - 1;
}
}

View File

@@ -71,7 +71,7 @@ class Function
int var = this.variable.get(name, 0);
if(var == 0)
{
this.variable[name] = var = ++variableIndex;
this.variable[name] = var = --argumentIndex;
}
else
{

View File

@@ -60,6 +60,7 @@ V[0,1]=12
?1/2
GOSUB @A
?A()
?B(1,2,3)
END
@A
?\"SUBROUTINE TEST\"
@@ -70,7 +71,7 @@ DEF A()
END
DEF B(A,B[],C)
?\"FUNCTION B\"
RETURN 0
RETURN -1
END
");
version(none) auto parser = new Parser(readText("FIZZBUZZ.TXT").to!wstring);