/// <summary> /// Java ctor /// </summary> public MethodSource(XMethodDefinition method, JavaMethodDefinition javaMethod) { if (javaMethod == null) throw new ArgumentNullException(); this.method = method; this.javaMethod = javaMethod; }
/// <summary> /// Java ctor /// </summary> public MethodSource(XMethodDefinition method, JavaMethodDefinition javaMethod) { if (javaMethod == null) { throw new ArgumentNullException(); } this.method = method; this.javaMethod = javaMethod; }
/// <summary> /// Perform name conversion /// </summary> protected virtual string GetMethodName(MethodDefinition method, DexTargetPackage targetPackage) { // Handle special names switch (method.Name) { case "<init>": case "<clinit>": return(method.Name); } // Handle regular names return(method.Name); }
/// <summary> /// Create a prototype for the given methods signature /// </summary> internal static Prototype BuildPrototype(AssemblyCompiler compiler, DexTargetPackage targetPackage, ClassDefinition declaringClass, MethodDefinition method) { var result = new Prototype(); var module = compiler.Module; result.ReturnType = method.ReturnType.GetReference(XTypeUsageFlags.ReturnType, targetPackage, module); var paramIndex = 0; foreach (var p in method.Parameters) { var dparameter = new Parameter(p.GetReference(XTypeUsageFlags.ParameterType, targetPackage, module), "p" + paramIndex++); result.Parameters.Add(dparameter); } return result; }
/// <summary> /// Add the given method to its declaring class. /// </summary> protected virtual void SetAccessFlags(DexLib.MethodDefinition dmethod, MethodDefinition method) { if (method.IsPrivate) { dmethod.IsPrivate = true; } if (method.IsProtected) { dmethod.IsProtected = true; } if (method.IsPublic) { dmethod.IsPublic = true; } if (method.DeclaringClass.IsInterface) { dmethod.IsAbstract = true; } else { if (method.IsConstructor) { dmethod.IsConstructor = true; } if (method.IsAbstract) { dmethod.IsAbstract = true; } if (method.IsStatic) { dmethod.IsStatic = true; } if (!method.IsStatic && !method.IsFinal && !method.IsConstructor && !method.IsPrivate) { dmethod.IsVirtual = true; } if (method.IsFinal || method.IsPrivate && !method.IsConstructor) { dmethod.IsFinal = true; } } }
/// <summary> /// Add the given method to its declaring class. /// </summary> protected virtual void SetAccessFlags(DexLib.MethodDefinition dmethod, MethodDefinition method) { if (method.IsPrivate) dmethod.IsPrivate = true; if (method.IsProtected) dmethod.IsProtected = true; if (method.IsPublic) dmethod.IsPublic = true; if (method.DeclaringClass.IsInterface) { dmethod.IsAbstract = true; } else { if (method.IsConstructor) dmethod.IsConstructor = true; if (method.IsAbstract) dmethod.IsAbstract = true; if (method.IsStatic) dmethod.IsStatic = true; if (!method.IsStatic && !method.IsFinal && !method.IsConstructor && !method.IsPrivate) dmethod.IsVirtual = true; if (method.IsFinal || method.IsPrivate) dmethod.IsFinal = true; } }
/// <summary> /// Create a prototype for the given methods signature /// </summary> internal static Prototype BuildPrototype(AssemblyCompiler compiler, DexTargetPackage targetPackage, ClassDefinition declaringClass, MethodDefinition method) { var result = new Prototype(); var module = compiler.Module; result.ReturnType = method.ReturnType.GetReference(XTypeUsageFlags.ReturnType, targetPackage, module); var paramIndex = 0; foreach (var p in method.Parameters) { var dparameter = new Parameter(p.GetReference(XTypeUsageFlags.ParameterType, targetPackage, module), "p" + paramIndex++); result.Parameters.Add(dparameter); } result.Freeze(); return(result); }
/// <summary> /// Default ctor /// </summary> protected MethodBuilder(AssemblyCompiler compiler, MethodDefinition method) { this.compiler = compiler; this.method = method; }
/// <summary> /// Default ctor /// </summary> public static MethodBuilder Create(AssemblyCompiler compiler, MethodDefinition method) { return(new MethodBuilder(compiler, method)); }
/// <summary> /// Default ctor /// </summary> protected MethodBuilder(AssemblyCompiler compiler, MethodDefinition method) { this.compiler = compiler; this.method = method; }
/// <summary> /// Default ctor /// </summary> public static MethodBuilder Create(AssemblyCompiler compiler, MethodDefinition method) { return new MethodBuilder(compiler, method); }
/// <summary> /// Perform name conversion /// </summary> protected virtual string GetMethodName(MethodDefinition method, DexTargetPackage targetPackage) { // Handle special names switch (method.Name) { case "<init>": case "<clinit>": return method.Name; } // Handle regular names return method.Name; }