コード例 #1
0
        public static VM_t 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;

            return(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
ファイル: vm.cs プロジェクト: drewbanas/Monkey-SPC
 public static void NewWithGlobalStore(compiler.Bytecode bytecode, ref List <Object.Object> s)
 {
     VM.New(bytecode);
     vm.globals = s;
 }