示例#1
0
 public void Add(ClassFile classFile)
 {
     classFiles.Add(classFile);
 }
示例#2
0
        static FieldInfo FindJavaFieldProperty(KotlinFile kotlinClass, KotlinProperty property, ClassFile klass)
        {
            var possible_methods = klass.Fields.Where(field => field.Name == property.Name &&
                                                      TypesMatch(new TypeInfo(field.Descriptor, field.Descriptor), property.ReturnType, kotlinClass));

            return(possible_methods.FirstOrDefault());
        }
示例#3
0
        static MethodInfo FindJavaPropertySetter(KotlinFile kotlinClass, KotlinProperty property, ClassFile klass)
        {
            var possible_methods = klass.Methods.Where(method => string.Compare(method.GetMethodNameWithoutSuffix(), $"set{property.Name}", true) == 0 &&
                                                       property.ReturnType != null &&
                                                       method.GetParameters().Length == 1 &&
                                                       method.ReturnType.BinaryName == "V" &&
                                                       TypesMatch(method.GetParameters() [0].Type, property.ReturnType, kotlinClass));

            return(possible_methods.FirstOrDefault());
        }
示例#4
0
        static MethodInfo FindJavaMethod(KotlinFile kotlinFile, KotlinFunction function, ClassFile klass)
        {
            var possible_methods = klass.Methods.Where(method => method.Name == function.JvmName &&
                                                       method.GetFilteredParameters().Length == function.ValueParameters.Count);

            foreach (var method in possible_methods)
            {
                if (!TypesMatch(method.ReturnType, function.ReturnType, kotlinFile))
                {
                    continue;
                }

                if (!ParametersMatch(kotlinFile, method, function.ValueParameters))
                {
                    continue;
                }

                return(method);
            }

            return(null);
        }
示例#5
0
        static MethodInfo FindJavaConstructor(KotlinClass kotlinClass, KotlinConstructor constructor, ClassFile klass)
        {
            var all_constructors      = klass.Methods.Where(method => method.Name == "<init>" || method.Name == "<clinit>");
            var possible_constructors = all_constructors.Where(method => method.GetFilteredParameters().Length == constructor.ValueParameters.Count);

            foreach (var method in possible_constructors)
            {
                if (ParametersMatch(kotlinClass, method, constructor.ValueParameters))
                {
                    return(method);
                }
            }

            return(null);
        }
示例#6
0
 public bool ImplementsInterface(ClassFile classToCheck, ClassFile targetInteface)
 {
     return(classToCheck.GetInterfaces().Any(iface => targetInteface.ThisClass.Name.Value == iface.BinaryName));
 }
示例#7
0
 IEnumerable <ClassFile> GetInterfaceImplemetations(ClassFile iface, IList <ClassFile> classFiles)
 {
     return(classFiles.Where(x => ImplementsInterface(x, iface)));
 }
示例#8
0
        static MethodInfo?FindJavaPropertyGetter(KotlinFile kotlinClass, KotlinProperty property, ClassFile klass)
        {
            var possible_methods = klass.Methods.Where(method => string.Compare(method.GetMethodNameWithoutSuffix(), $"get{property.Name}", StringComparison.OrdinalIgnoreCase) == 0 &&
                                                       method.GetParameters().Length == 0 &&
                                                       property.ReturnType != null &&
                                                       TypesMatch(method.ReturnType, property.ReturnType, kotlinClass));

            return(possible_methods.FirstOrDefault());
        }