/// <summary> /// Create a dex field definition from this field. /// </summary> public DexLib.FieldDefinition GetDexField(DexLib.ClassDefinition owner, DexTargetPackage targetPackage) { if (dexField == null) { var fdef = new DexLib.FieldDefinition(owner, name, fieldType.GetReference(targetPackage)); if (IsStatic) { fdef.IsStatic = true; } if (IsPrivate) { fdef.IsPrivate = true; } else if (IsProtected) { fdef.IsProtected = true; } else { fdef.IsPublic = true; } if (IsReadOnly) { fdef.IsFinal = true; } dexField = fdef; targetPackage.NameConverter.Record(this, dexField); } return(dexField); }
/// <summary> /// Set relation to dex class. /// </summary> internal void SetDexClass(DexLib.ClassDefinition @class, DexTargetPackage targetPackage) { if (@class == null) { throw new ArgumentNullException("@class"); } if (dexType != null) { throw new InvalidOperationException("Cannot set dex class twice"); } dexType = @class; }
/// <summary> /// Create a dex method definition from this method. /// </summary> public DexLib.MethodDefinition GetDexMethod(DexLib.ClassDefinition owner, DexTargetPackage targetPackage) { if (dexMethod == null) { var prototype = new DexLib.Prototype(ReturnType.GetReference(targetPackage), parameters.Select(x => new DexLib.Parameter(x.ParameterType.GetReference(targetPackage), x.Name)).ToArray()); var mdef = new DexLib.MethodDefinition(owner, name, prototype); if (IsAbstract) { mdef.IsAbstract = true; } if (IsVirtual) { mdef.IsVirtual = true; } if (IsStatic) { mdef.IsStatic = true; } if (IsPrivate) { mdef.IsPrivate = true; } else if (IsProtected) { mdef.IsProtected = true; } else { mdef.IsPublic = true; } if (IsConstructor) { mdef.Name = IsStatic ? "<clinit>" : "<init>"; mdef.IsConstructor = true; } dexMethod = mdef; targetPackage.NameConverter.Record(this, dexMethod); } return(dexMethod); }
/// <summary> /// Generate method code /// </summary> public override void GenerateCode(DexLib.ClassDefinition declaringClass, DexTargetPackage targetPackage) { // Do nothing }
/// <summary> /// Set relation to dex class. /// </summary> internal void SetDexClass(DexLib.ClassDefinition @class, DexTargetPackage targetPackage) { if (@class == null) throw new ArgumentNullException("@class"); if (dexType != null) throw new InvalidOperationException("Cannot set dex class twice"); dexType = @class; }