示例#1
0
        private void MergeEquivilentPairs()
        {
            bool mergesWereDone;

            do
            {
                mergesWereDone = false;
                for (int i = 0; i < InstructionNodes.Count; i++)
                {
                    var firstInst         = InstructionNodes[i];
                    var secondInstOptions = InstructionNodes
                                            .Where(x => x != firstInst)
                                            .Where(x => x.Instruction.OpCode.Code == firstInst.Instruction.OpCode.Code)
                                            .Where(x => x.Instruction.Operand == firstInst.Instruction.Operand)
                                            .Where(x => CodeGroups.AllOpcodes.Where(y => y.StackBehaviourPop != StackBehaviour.Pop0).Select(y => y.Code)
                                                   .Contains(x.Instruction.OpCode.Code))
                                            .Where(x => !new[] { Code.Ret }.Concat(CodeGroups.CallCodes).Contains(x.Instruction.OpCode.Code));
                    var firstInstBackRelated = firstInst.DataFlowBackRelated.Where(x => x.Argument != firstInst);
                    foreach (var secondInstOption in secondInstOptions.ToArray())
                    {
                        var secondInstBackRelated = secondInstOption.DataFlowBackRelated.Where(x => x.Argument != secondInstOption);
                        if (CoupledIndexedArgList.SequenceEqualsWithIndexes(secondInstBackRelated, firstInstBackRelated) && firstInst.DataFlowBackRelated.SelfFeeding == secondInstOption.DataFlowBackRelated.SelfFeeding)
                        {
                            Console.WriteLine("merging " + firstInst.InstructionIndex + " " + secondInstOption.InstructionIndex);
                            MergeNodes(new[] { firstInst, secondInstOption });
                            mergesWereDone = true;
                            break;
                        }
                    }
                }
            } while (mergesWereDone);
        }
示例#2
0
        public void MergeInto(InstructionNode nodeToMergeInto, bool KeepOriginal)
        {
            CoupledIndexedArgList mergedNodeSameArgList = GetSameList(nodeToMergeInto);

            foreach (var arg in this.ToArray())
            {
                mergedNodeSameArgList.AddTwoWay(arg);
                if (!KeepOriginal)
                {
                    RemoveTwoWay(arg);
                }
            }
        }
示例#3
0
 public IndexedArgument(int argIndex, InstructionNode argument, CoupledIndexedArgList containingList)
 {
     ArgIndex       = argIndex;
     Argument       = argument;
     ContainingList = containingList;
 }