public static Value TestRunVm(List <SourceFile> sources) { var rawBytecode = Utils.GetRawBytecode(sources); var bytecode = Utils.Assemble(rawBytecode); var vm = Vm.Vm.RunVm(bytecode, sources); return(vm.CheckStackTop()); }
public static Instruction[] GetBytecode(List <SourceFile> sources) { var rawBytecode = Utils.GetRawBytecode(sources); rawBytecode = Compiler.RawBytecodeOptimizations.Optimize(rawBytecode); var assembled = Utils.Assemble(rawBytecode); assembled = Compiler.AssembledBytecodeOptimizations.Optimize(assembled); Utils.SetBytecodeMd5(assembled, Utils.Md5AsString(Utils.ComputeBytecodeMd5(assembled))); return(assembled); }
public static string PrintRawBytecode(List <SourceFile> sources, bool optimize = false) { var bytecode = Utils.GetRawBytecode(sources); if (optimize) { bytecode = Compiler.RawBytecodeOptimizations.Optimize(bytecode); } Utils.DecorateByteCode(bytecode, sources); var sb = new StringBuilder(); foreach (var instruction in bytecode) { sb.Append(instruction.ToString()); } return(sb.ToString()); }