public void InferTypes()
        {
            V_0 = (new GreedyTypeInferer(this.context, this.offsetToExpression)).InferTypes();
            V_1 = new ClassHierarchyBuilder(this.offsetToExpression, this.context.get_MethodContext().get_ControlFlowGraph().get_OffsetToInstruction(), this.context);
            this.inferenceGraph = V_1.BuildHierarchy(V_0);
            this.MergeConnectedComponents();
            this.RemoveTransitiveEdges();
            this.ProcessSingleConstraints();
            V_2 = null;
            V_4 = this.inferenceGraph.GetEnumerator();
            try
            {
                while (V_4.MoveNext())
                {
                    V_5 = V_4.get_Current();
                    if (!V_5.get_IsHardNode() || !String.op_Equality(V_5.get_NodeType().get_FullName(), "System.Object"))
                    {
                        continue;
                    }
                    V_2 = V_5;
                    goto Label0;
                }
            }
            finally
            {
                if (V_4 != null)
                {
                    V_4.Dispose();
                }
            }
Label0:
            V_3 = new List <ClassHierarchyNode>();
            V_3.Add(V_2);
            V_4 = this.inferenceGraph.GetEnumerator();
            try
            {
                while (V_4.MoveNext())
                {
                    V_6 = V_4.get_Current();
                    if (V_6.get_IsHardNode())
                    {
                        continue;
                    }
                    V_3.Add(V_6);
                }
            }
            finally
            {
                if (V_4 != null)
                {
                    V_4.Dispose();
                }
            }
            this.MergeNodes(V_3);
            this.InferIntegerTypes(V_0);
            this.AddCasts();
            return;
        }
Example #2
0
 protected ClassHierarchyNode GetUseExpressionTypeNode(Instruction instruction, VariableReference variable)
 {
     V_0 = instruction.get_OpCode().get_Code();
     if (V_0 == 112)
     {
         return(this.GetTypeNode(instruction.get_Operand() as TypeReference));
     }
     if (ClassHierarchyBuilder.IsConditionalBranch(V_0))
     {
         return(this.GetTypeNode(this.typeSystem.get_Boolean()));
     }
     if (V_0 == 68)
     {
         return(this.GetTypeNode(this.typeSystem.get_UInt32()));
     }
     V_1 = this.offsetToExpression.get_Item(instruction.get_Offset());
     return(this.GetUseExpressionTypeNode(V_1, variable));
 }
        /// <summary>
        /// The entry point of the class. After this method ends, all variables will be typed.
        /// </summary>
        public void InferTypes()
        {
            ///This method realises the first step of the 3-stage algorithm described in <see cref="Efficient Inference of Static Types for Java Bytecode.pdf" />.
            ///All variables that are left without type after it are given type "System.Object" and casts are introduced as needed.

            GreedyTypeInferer gti = new GreedyTypeInferer(context, offsetToExpression);
            var resolvedVariables = gti.InferTypes();

            ClassHierarchyBuilder chb = new ClassHierarchyBuilder(offsetToExpression, context.MethodContext.ControlFlowGraph.OffsetToInstruction, context);

            this.inferenceGraph = chb.BuildHierarchy(resolvedVariables);

            MergeConnectedComponents();
            RemoveTransitiveEdges();
            ProcessSingleConstraints();

            ClassHierarchyNode objectNode = null;

            foreach (ClassHierarchyNode node in inferenceGraph)
            {
                if (node.IsHardNode && node.NodeType.FullName == "System.Object")
                {
                    objectNode = node;
                    break;
                }
            }
            List <ClassHierarchyNode> allSoftNodes = new List <ClassHierarchyNode>();

            allSoftNodes.Add(objectNode);
            foreach (ClassHierarchyNode node in inferenceGraph)
            {
                if (!node.IsHardNode)
                {
                    allSoftNodes.Add(node);
                }
            }
            MergeNodes(allSoftNodes);

            InferIntegerTypes(resolvedVariables);

            this.AddCasts();
        }
        /// <summary>
        /// The entry point of the class. After this method ends, all variables will be typed.
        /// </summary>
        public void InferTypes()
        {
            ///This method realises the first step of the 3-stage algorithm described in <see cref="Efficient Inference of Static Types for Java Bytecode.pdf" />.
            ///All variables that are left without type after it are given type "System.Object" and casts are introduced as needed.

            GreedyTypeInferer gti = new GreedyTypeInferer(context, offsetToExpression);
            var resolvedVariables = gti.InferTypes();

            ClassHierarchyBuilder chb = new ClassHierarchyBuilder(offsetToExpression, context.MethodContext.ControlFlowGraph.OffsetToInstruction, context);
            this.inferenceGraph = chb.BuildHierarchy(resolvedVariables);

            MergeConnectedComponents();
            RemoveTransitiveEdges();
            ProcessSingleConstraints();

            ClassHierarchyNode objectNode = null;
            foreach (ClassHierarchyNode node in inferenceGraph)
            {
                if (node.IsHardNode && node.NodeType.FullName == "System.Object")
                {
                    objectNode = node;
                    break;
                }
            }
            List<ClassHierarchyNode> allSoftNodes = new List<ClassHierarchyNode>();
            allSoftNodes.Add(objectNode);
            foreach (ClassHierarchyNode node in inferenceGraph)
            {
                if (!node.IsHardNode)
                {
                    allSoftNodes.Add(node);
                }
            }
            MergeNodes(allSoftNodes);

            InferIntegerTypes(resolvedVariables);

            this.AddCasts();
        }