コード例 #1
0
ファイル: vm.cs プロジェクト: drewbanas/Monkey-SPC
        public static bool ExitVM = false; // New


        public static void New(compiler.Bytecode bytecode)
        {
            Object.CompiledFunction mainFn = new Object.CompiledFunction {
                Instructions = bytecode.Instructions
            };
            Object.Closure mainClosure = new Object.Closure {
                Fn = mainFn
            };
            Frame_t mainFrame = Frame.NewFrame(mainClosure, 0);

            Frame_t[] frames = new Frame_t[MaxFrames];
            frames[0] = mainFrame;

            VM.vm = new VM_t
            {
                constants = bytecode.Constants,

                stack = new List <Object.Object>(new Object.Object[StackSize]),
                sp    = 0,

                globals = new List <Object.Object>(new Object.Object[GlobalSize]),

                frames     = frames,
                frameIndex = 1,
            };
        }
コード例 #2
0
        public static VM_t NewWithGlobalStore(compiler.Bytecode bytecode, ref List <Object.Object> s)
        {
            VM_t vm = New(bytecode);

            vm.globals = s;

            return(vm);
        }
コード例 #3
0
 public static void _SetVM(ref VM_t _vm)
 {
     vm = _vm;
 }