예제 #1
0
        static private string ContainerSetToString(HashSet <TacNode> tacNodesHash)
        {
            var s = new StringBuilder();

            s.Append("{ ");
            foreach (var tacNode in tacNodesHash)
            {
                TacNodeVarDecorator varNode = tacNode as TacNodeVarDecorator;
                s.Append(varNode.ToString().Trim() + " ");
            }
            s.Append("}");
            return(s.ToString());
        }
예제 #2
0
        static public Dictionary <ThreeAddressCode, IExpressionSetsContainer> Execute(BasicBlocks bblocks)
        {
            var resultBlocksDefUse = new Dictionary <ThreeAddressCode, IExpressionSetsContainer>();

            foreach (var bblock in bblocks)
            {
                DefUseContainer defUseContainer = new DefUseContainer();
                foreach (var line in bblock)
                {
                    if (line is TacAssignmentNode assignmentNode)
                    {
                        string leftPartIdentifier    = assignmentNode.LeftPartIdentifier;
                        TacNodeVarDecorator tacNode1 = CreateVarTacNode(leftPartIdentifier);
                        bool defAdd = false;
                        if (IsValidVariable(leftPartIdentifier) && !defUseContainer.def.Contains(tacNode1) &&
                            !defUseContainer.use.Contains(tacNode1))
                        {
                            defAdd = true;
                            defUseContainer.def.Add(tacNode1);
                        }
                        string firstOperand          = assignmentNode.FirstOperand;
                        TacNodeVarDecorator tacNode2 = CreateVarTacNode(firstOperand);
                        if (IsValidVariable(firstOperand) && (!defUseContainer.def.Contains(tacNode2) ||
                                                              (leftPartIdentifier == firstOperand && defAdd)))
                        {
                            defUseContainer.use.Add(tacNode2);
                        }
                        string secondOperand         = assignmentNode.SecondOperand;
                        TacNodeVarDecorator tacNode3 = CreateVarTacNode(secondOperand);
                        if (IsValidVariable(secondOperand) && (!defUseContainer.def.Contains(tacNode3) ||
                                                               (leftPartIdentifier == secondOperand && defAdd)))
                        {
                            defUseContainer.use.Add(tacNode3);
                        }
                    }
                }
                resultBlocksDefUse.Add(bblock, defUseContainer);
            }

            return(resultBlocksDefUse);
        }
예제 #3
0
 protected bool Equals(TacNodeVarDecorator other)
 {
     return(string.Equals(VarName, other.VarName));
 }