您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 

45 行
782 B

using System;
using System.Collections.Generic;
using System.Text;
namespace SuperBASIC
{
class Runtime
{
float register;
internal Library lib;
Bytecode code;
public Runtime(Library library)
{
lib = library;
}
public void OpenFile(string path)
{
code = new Parser(this).ParseFile(path);
}
public void Run()
{
for(int idx = 0; idx < code.bytecode.Count;)
{
int opcode = code.bytecode[idx].GetOperand();
int arity = lib.arities[opcode];
IFunction op = lib.functions[opcode];
var args = code.bytecode.GetRange(idx + 1, arity);
SetRegister(op.Apply(args));
idx += arity + 1;
}
}
internal void SetRegister(float value)
{
register = value;
}
internal float GetRegister()
{
return register;
}
}
}