示例#1
0
        static void setLastInstruction(Opcode op, int pos)
        {
            EmittedInstruction previous = compiler.scopes[compiler.scopeIndex].lastInstruction;
            EmittedInstruction last     = new EmittedInstruction {
                Opcode = op, Position = pos
            };

            CompilationScope _scope = compiler.scopes[compiler.scopeIndex];

            _scope.previousInstruction           = previous;
            _scope.lastInstruction               = last;
            compiler.scopes[compiler.scopeIndex] = _scope;
        }
示例#2
0
        static void removeLastPop()
        {
            EmittedInstruction last     = compiler.scopes[compiler.scopeIndex].lastInstruction;
            EmittedInstruction previous = compiler.scopes[compiler.scopeIndex].previousInstruction;

            List <byte> old  = currentInstructions();
            List <byte> new_ = new List <byte>(last.Position + 1);

            for (int i = 0; i < last.Position; i++)
            {
                new_.Add(old[i]);
            }

            CompilationScope _scope = compiler.scopes[compiler.scopeIndex];

            _scope.instructions    = new_;
            _scope.lastInstruction = previous;
            compiler.scopes[compiler.scopeIndex] = _scope;
        }