1
0

GBOXを実装,GCLSを実装,システム変数DATE$TIME$を実装,そのほか関数を実装,TRUE/FALSEを追加,小数点リテラルを実装.

This commit is contained in:
otya128
2015-08-20 15:28:02 +09:00
parent c9d6043fe4
commit b589766d47
8 changed files with 527 additions and 78 deletions

View File

@@ -4,6 +4,7 @@ import otya.smilebasic.token;
import otya.smilebasic.error;
import otya.smilebasic.compiler;
import otya.smilebasic.petitcomputer;
import otya.smilebasic.systemvariable;
import std.uni;
import std.utf;
import std.conv;
@@ -17,6 +18,10 @@ struct VMVariable
this.index = index;
this.type = type;
}
this(int index)
{
this.index = index;
}
}
class VM
{
@@ -38,7 +43,8 @@ class VM
this.globalTable = globalTable;
foreach(wstring k, VMVariable v ; globalTable)
{
this.global[v.index] = Value(v.type);
if(v.index >= 0)
this.global[v.index] = Value(v.type);
}
this.functions = functions;
this.globalDataTable = gdt;
@@ -889,10 +895,16 @@ class CallBuiltinFunction : Code
else
{
arg = vm.stack[vm.stacki - argcount..vm.stacki];
result = vm.stack[vm.stacki - argcount..vm.stacki - argcount + outcount];//雑;
result = vm.stack[vm.stacki/* - argcount */+ 1..vm.stacki + 1/* - argcount */+ outcount];//雑;
}
func.func(vm.petitcomputer, arg, result);
vm.stacki -= func.argments.length - outcount;
vm.stacki -= func.argments.length;// - outcount;
////vm.stacki += outcount;
//vm.stacki = old;
for(int i = 0; i < result.length; i++)
{
vm.push(result[i]);
}
}
}
class IncCodeG : Code
@@ -1139,3 +1151,29 @@ class ReadCode : Code
}
}
}
class PushSystemVariable : Code
{
SystemVariable var;
this(SystemVariable var)
{
this.var = var;
}
override void execute(VM vm)
{
vm.push(var.value);
}
}
class PopSystemVariable : Code
{
SystemVariable var;
this(SystemVariable var)
{
this.var = var;
}
override void execute(VM vm)
{
Value v;
vm.pop(v);
var.value = v;
}
}