Exemplo n.º 1
0
 /// <summary>
 /// Java ctor
 /// </summary>
 public MethodSource(XMethodDefinition method, JavaMethodDefinition javaMethod)
 {
     if (javaMethod == null)
         throw new ArgumentNullException();
     this.method = method;
     this.javaMethod = javaMethod;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Java ctor
 /// </summary>
 public MethodSource(XMethodDefinition method, JavaMethodDefinition javaMethod)
 {
     if (javaMethod == null)
     {
         throw new ArgumentNullException();
     }
     this.method     = method;
     this.javaMethod = javaMethod;
 }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
 /// <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;
 }
Exemplo n.º 5
0
        /// <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;
                }
            }
        }
Exemplo n.º 6
0
        /// <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;
            }
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Default ctor
 /// </summary>
 protected MethodBuilder(AssemblyCompiler compiler, MethodDefinition method)
 {
     this.compiler = compiler;
     this.method   = method;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public static MethodBuilder Create(AssemblyCompiler compiler, MethodDefinition method)
 {
     return(new MethodBuilder(compiler, method));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Default ctor
 /// </summary>
 protected MethodBuilder(AssemblyCompiler compiler, MethodDefinition method)
 {
     this.compiler = compiler;
     this.method = method;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public static MethodBuilder Create(AssemblyCompiler compiler, MethodDefinition method)
 {
     return new MethodBuilder(compiler, method);
 }
Exemplo n.º 12
0
        /// <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;
        }