Exemplo n.º 1
0
        public static InstructionChain FromInstructions(IInstruction instruction)
        {
            var chain = new InstructionChain();
            while (instruction != null)
            {
                chain.AssignAndIncrement(instruction);

                instruction = instruction.Next;
            }
            chain.Reset();

            return chain;
        }
Exemplo n.º 2
0
        public virtual bool Compile(IMethodContext context, InstructionChain chain)
        {
            var ins = chain.Instruction;

            Simplifier simplifier;
            if (Simplifiers.TryGetValue(ins.Code, out simplifier))
                simplifier(context, ins);
            else
            {
                // default operation
            }

            //remove jumping branches that go to the next instruction
            if (ins.Code == InstructionCode.CilBr && ins.Operand0 == ins.Next)
            {
                chain.Remove();
                return false;
            }

            return true;
        }