Exemplo n.º 1
0
            public ClassNode(string content_class_name, string content_method_name, string content_method_descriptor
                             , int content_method_invocation_type, string lambda_class_name, string lambda_method_name
                             , string lambda_method_descriptor, StructClass classStruct)
            {
                // lambda class constructor
                this.type        = Class_Lambda;
                this.classStruct = classStruct;
                // 'parent' class containing the static function
                lambdaInformation                                = new ClassesProcessor.ClassNode.LambdaInformation();
                lambdaInformation.method_name                    = lambda_method_name;
                lambdaInformation.method_descriptor              = lambda_method_descriptor;
                lambdaInformation.content_class_name             = content_class_name;
                lambdaInformation.content_method_name            = content_method_name;
                lambdaInformation.content_method_descriptor      = content_method_descriptor;
                lambdaInformation.content_method_invocation_type = content_method_invocation_type;
                lambdaInformation.content_method_key             = InterpreterUtil.MakeUniqueKey(lambdaInformation
                                                                                                 .content_method_name, lambdaInformation.content_method_descriptor);
                anonymousClassType = new VarType(lambda_class_name, true);
                bool is_method_reference = (content_class_name != classStruct.qualifiedName);

                if (!is_method_reference)
                {
                    // content method in the same class, check synthetic flag
                    StructMethod mt = classStruct.GetMethod(content_method_name, content_method_descriptor
                                                            );
                    is_method_reference = !mt.IsSynthetic();
                }
                // if not synthetic -> method reference
                lambdaInformation.is_method_reference      = is_method_reference;
                lambdaInformation.is_content_method_static = (lambdaInformation.content_method_invocation_type
                                                              == ICodeConstants.CONSTANT_MethodHandle_REF_invokeStatic);
            }
Exemplo n.º 2
0
        private bool IsVarArgCall()
        {
            StructClass cl = DecompilerContext.GetStructContext().GetClass(classname);

            if (cl != null)
            {
                StructMethod mt = cl.GetMethod(InterpreterUtil.MakeUniqueKey(name, stringDescriptor
                                                                             ));
                if (mt != null)
                {
                    return(mt.HasModifier(ICodeConstants.Acc_Varargs));
                }
            }
            else
            {
                // TODO: tap into IDEA indices to access libraries methods details
                // try to check the class on the classpath
                MethodInfo mtd = ClasspathHelper.FindMethod(classname, name, descriptor);
                return(mtd != null && mtd.GetParameters()
                       .Any(param => Attribute.IsDefined(param, typeof(ParamArrayAttribute))));
            }
            return(false);
        }
Exemplo n.º 3
0
        private BitSet GetAmbiguousParameters()
        {
            StructClass cl = DecompilerContext.GetStructContext().GetClass(classname);

            if (cl == null)
            {
                return(Empty_Bit_Set);
            }
            // check number of matches
            List <MethodDescriptor> matches = new List <MethodDescriptor>();

            foreach (StructMethod mt in cl.GetMethods())
            {
                if (name.Equals(mt.GetName()))
                {
                    MethodDescriptor md = MethodDescriptor.ParseDescriptor(mt.GetDescriptor());
                    if ([email protected] == [email protected])
                    {
                        for (int i = 0; i < [email protected]; i++)
                        {
                            if (md.@params[i].typeFamily != descriptor.@params[i].typeFamily)
                            {
                                goto nextMethod_continue;
                            }
                        }
                        matches.Add(md);
                    }
                }
            }
            nextMethod_break    :;
            nextMethod_continue :
            if (matches.Count == 1)
            {
                return(Empty_Bit_Set);
            }
            // check if a call is unambiguous
            StructMethod mt_1 = cl.GetMethod(InterpreterUtil.MakeUniqueKey(name, stringDescriptor
                                                                           ));

            if (mt_1 != null)
            {
                MethodDescriptor md = MethodDescriptor.ParseDescriptor(mt_1.GetDescriptor());
                if ([email protected] == lstParameters.Count)
                {
                    bool exact = true;
                    for (int i = 0; i < [email protected]; i++)
                    {
                        if (!md.@params[i].Equals(lstParameters[i].GetExprType()))
                        {
                            exact = false;
                            break;
                        }
                    }
                    if (exact)
                    {
                        return(Empty_Bit_Set);
                    }
                }
            }
            // mark parameters
            BitSet ambiguous = new BitSet([email protected]);

            for (int i = 0; i < [email protected]; i++)
            {
                VarType paramType = descriptor.@params[i];
                foreach (MethodDescriptor md in matches)
                {
                    if (!paramType.Equals(md.@params[i]))
                    {
                        ambiguous.Set(i);
                        break;
                    }
                }
            }
            return(ambiguous);
        }