組み込み関数を実�
This commit is contained in:
@@ -867,8 +867,8 @@ class CallBuiltinFunction : Code
|
||||
}
|
||||
override void execute(VM vm)
|
||||
{
|
||||
Value[] arg = vm.stack[vm.stacki - argcount..vm.stacki - 1];
|
||||
Value[] result = vm.stack[vm.stacki - argcount..vm.stacki - argcount + outcount - 1];//雑;
|
||||
Value[] arg = vm.stack[vm.stacki - argcount..vm.stacki];
|
||||
Value[] result = vm.stack[vm.stacki - argcount..vm.stacki - argcount + outcount];//雑;
|
||||
func.func(vm.petitcomputer, arg, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,12 @@ class BuiltinFunction
|
||||
}
|
||||
import std.math;
|
||||
/*
|
||||
static pure double ABS(double a, double b)
|
||||
static pure double ABS(double a)
|
||||
{
|
||||
return a < 0 ? -a : a;
|
||||
}*/
|
||||
static ABS = function(double x) => abs(x);
|
||||
static double function(double) ABS = &abs!double;
|
||||
//static ABS = function double(double x) => abs(this.result == ValueType.Double ? 1 : 0);
|
||||
static void LOCATE(PetitComputer p, DefaultValue!int x, DefaultValue!int y, DefaultValue!int z)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -335,7 +335,15 @@ class Compiler
|
||||
{
|
||||
compileExpression(i, sc);
|
||||
}
|
||||
genCode(new CallFunctionCode(func.name, func.args.length));
|
||||
auto bfun = otya.smilebasic.builtinfunctions.BuiltinFunction.builtinFunctions.get(func.name, null);
|
||||
if(bfun)
|
||||
{
|
||||
genCode(new CallBuiltinFunction(bfun, func.args.length, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
genCode(new CallFunctionCode(func.name, func.args.length));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NodeType.IndexExpressions://[expr,expr,expr,expr]用
|
||||
@@ -598,7 +606,15 @@ class Compiler
|
||||
{
|
||||
compileExpression(j, s);
|
||||
}
|
||||
genCode(new CallFunctionCode(func.name, func.args.length, func.outVariable.length));
|
||||
auto bfun = otya.smilebasic.builtinfunctions.BuiltinFunction.builtinFunctions.get(func.name, null);
|
||||
if(bfun)
|
||||
{
|
||||
genCode(new CallBuiltinFunction(bfun, func.args.length, func.outVariable.length));
|
||||
}
|
||||
else
|
||||
{
|
||||
genCode(new CallFunctionCode(func.name, func.args.length, func.outVariable.length));
|
||||
}
|
||||
//TODO:OUT
|
||||
foreach_reverse(wstring var; func.outVariable)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@ int main(string[] argv)
|
||||
writeln(parser.calc());
|
||||
}
|
||||
|
||||
|
||||
version(none)
|
||||
{
|
||||
auto parser = new Parser(
|
||||
//"@A\nA=1+2+3+4\nPRINT 1+1,2+3;10-5,A:A=A*2 PRINT A
|
||||
"
|
||||
@@ -120,6 +121,7 @@ END
|
||||
{
|
||||
writeln(t);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
auto pc = new PetitComputer();
|
||||
|
||||
@@ -178,7 +178,7 @@ class PetitComputer
|
||||
GRPF.createTexture(renderer);
|
||||
//とりあえず
|
||||
auto parser = new Parser(/*readText("FIZZBUZZ.TXT").to!wstring*/"
|
||||
|
||||
?ABS(-1)
|
||||
FOR I=0 TO 10
|
||||
?I;\"!\",\"=\",FACT(I)
|
||||
NEXT
|
||||
@@ -209,7 +209,7 @@ END");
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}/*
|
||||
catch(Throwable t)
|
||||
{
|
||||
running = false;
|
||||
@@ -220,7 +220,7 @@ END");
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}*/
|
||||
elapse = SDL_GetTicks() - startTicks;
|
||||
} while(elapse <= 1000 / 60);
|
||||
SDL_Event event;
|
||||
|
||||
Reference in New Issue
Block a user