Exemplo n.º 1
0
 public void Add(ClassFile classFile)
 {
     classFiles.Add(classFile);
 }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 public bool ImplementsInterface(ClassFile classToCheck, ClassFile targetInteface)
 {
     return(classToCheck.GetInterfaces().Any(iface => targetInteface.ThisClass.Name.Value == iface.BinaryName));
 }
Exemplo n.º 7
0
 IEnumerable <ClassFile> GetInterfaceImplemetations(ClassFile iface, IList <ClassFile> classFiles)
 {
     return(classFiles.Where(x => ImplementsInterface(x, iface)));
 }
Exemplo n.º 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());
        }