No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 

46 líneas
810 B

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