Exemplo n.º 1
0
        public void EmitDeferredInstructions()
        {
            if (!_outputEnabled)
            {
                return;
            }

            foreach (MethodInstruction instruction in _deferredInstructions)
            {
                switch (instruction.OpCode)
                {
                case MethodOpCode.Assign:
                    _emitter.Store((IrisType)instruction.Operand);
                    break;

                case MethodOpCode.BranchCond:
                    _emitter.BranchCondition(instruction.Condition, (int)instruction.Operand);
                    break;

                case MethodOpCode.BranchFalse:
                    _emitter.BranchFalse((int)instruction.Operand);
                    break;

                case MethodOpCode.BranchTrue:
                    _emitter.BranchTrue((int)instruction.Operand);
                    break;

                case MethodOpCode.Call:
                    _emitter.Call((Symbol)instruction.Operand);
                    break;

                case MethodOpCode.Goto:
                    _emitter.Goto((int)instruction.Operand);
                    break;

                case MethodOpCode.Label:
                    _emitter.Label((int)instruction.Operand);
                    break;

                case MethodOpCode.Load:
                    _emitter.Load((IrisType)instruction.Operand);
                    break;

                case MethodOpCode.LoadElem:
                    _emitter.LoadElement((IrisType)instruction.Operand);
                    break;

                case MethodOpCode.LoadElemA:
                    _emitter.LoadElementAddress((IrisType)instruction.Operand);
                    break;

                case MethodOpCode.Operator:
                    _emitter.Operator((Operator)instruction.Operand);
                    break;

                case MethodOpCode.Dup:
                    _emitter.Dup();
                    break;

                case MethodOpCode.Pop:
                    _emitter.Pop();
                    break;

                case MethodOpCode.PushArg:
                    _emitter.PushArgument((int)instruction.Operand);
                    break;

                case MethodOpCode.PushArgA:
                    _emitter.PushArgumentAddress((int)instruction.Operand);
                    break;

                case MethodOpCode.PushInt:
                    _emitter.PushIntConst((int)instruction.Operand);
                    break;

                case MethodOpCode.PushGbl:
                    _emitter.PushGlobal((Symbol)instruction.Operand);
                    break;

                case MethodOpCode.PushGblA:
                    _emitter.PushGlobalAddress((Symbol)instruction.Operand);
                    break;

                case MethodOpCode.PushLoc:
                    _emitter.PushLocal((int)instruction.Operand);
                    break;

                case MethodOpCode.PushLocA:
                    _emitter.PushLocalAddress((int)instruction.Operand);
                    break;

                case MethodOpCode.PushString:
                    _emitter.PushString((string)instruction.Operand);
                    break;

                case MethodOpCode.StoreArg:
                    _emitter.StoreArgument((int)instruction.Operand);
                    break;

                case MethodOpCode.StoreElem:
                    _emitter.StoreElement((IrisType)instruction.Operand);
                    break;

                case MethodOpCode.StoreGbl:
                    _emitter.StoreGlobal((Symbol)instruction.Operand);
                    break;

                case MethodOpCode.StoreLoc:
                    _emitter.StoreLocal((int)instruction.Operand);
                    break;

                default:
                    throw new InvalidOperationException("Unknown opcode.  Missing case?");
                }
            }

            _deferredInstructions.Clear();
        }