Пример #1
0
        private void EvaluateInstuction(Instruction instruction, MetaMidRepresentationOperationFactory operationFactory,
                                        HashSet <int> labelList, CrRuntimeLibrary crRuntime)
        {
            var opcodeStr = instruction.OpCode.ToString();
            var offset    = 0;

            if (instruction.Operand is Instruction)
            {
                offset = ((Instruction)(instruction.Operand)).Offset;
            }
            if (labelList.Contains(instruction.Offset))
            {
                operationFactory.SetLabel(instruction.Offset);
            }
            if (operationFactory.SkipInstruction(instruction.Offset))
            {
                return;
            }
            var opcodeValue = instruction.OpCode.Value;

            operationFactory.AddCommentInstruction(instruction.ToString());
            if (HandleCalls(instruction, operationFactory, opcodeValue, crRuntime))
            {
                return;
            }

            if (HandleStores(opcodeStr, instruction, operationFactory))
            {
                return;
            }
            if (HandleLoads(opcodeStr, instruction, operationFactory))
            {
                return;
            }
            if (HandleOperators(opcodeStr, operationFactory))
            {
                return;
            }

            if (HandleBranching(opcodeStr, offset, operationFactory))
            {
                return;
            }

            if (HandleExtraInstructions(instruction, operationFactory, opcodeStr))
            {
                return;
            }
            throw new InvalidOperationException(String.Format("Unknown instruction: {0}", instruction));
        }