本文整理汇总了C#中DexTargetPackage类的典型用法代码示例。如果您正苦于以下问题:C# DexTargetPackage类的具体用法?C# DexTargetPackage怎么用?C# DexTargetPackage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DexTargetPackage类属于命名空间,在下文中一共展示了DexTargetPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMembers
/// <summary>
/// Implement the class now that all classes have been created
/// </summary>
protected override void CreateMembers(DexTargetPackage targetPackage)
{
base.CreateMembers(targetPackage);
// Build default ctor
XTypeSystem typeSystem = Compiler.Module.TypeSystem;
XSyntheticMethodDefinition ctor = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Constructor, "<init>", typeSystem.Void);
ctor.Body = CreateCtorBody();
Class.Methods.Add(ctor.GetDexMethod(Class, targetPackage));
// Build Invoke method.
XMethodDefinition sourceMethod = XType.Methods.Single(x => x.EqualsName("Invoke"));
Prototype prototype = PrototypeBuilder.BuildPrototype(Compiler, targetPackage, Class, sourceMethod);
MethodDefinition method = new MethodDefinition(Class, sourceMethod.Name, prototype) { AccessFlags = AccessFlags.Public | AccessFlags.Abstract };
Class.Methods.Add(method);
// Find xSource method
targetPackage.NameConverter.Record(sourceMethod, method);
// If void() delegate, implement java.lang.Runnable
if (sourceMethod.ReturnType.IsVoid() && (sourceMethod.Parameters.Count == 0))
{
// Implement interface
Class.Interfaces.Add(FrameworkReferences.Runnable);
// Build run method
var run = new MethodDefinition(Class, "run", new Prototype(PrimitiveType.Void)) { AccessFlags = AccessFlags.Public | AccessFlags.Final };
Class.Methods.Add(run);
run.Body = new DexLib.Instructions.MethodBody(run, 1) { IncomingArguments = 1, OutgoingArguments = 1 };
var insList = run.Body.Instructions;
var rThis = run.Body.Registers[0];
insList.Add(new DexLib.Instructions.Instruction(OpCodes.Invoke_virtual, method, rThis));
insList.Add(new DexLib.Instructions.Instruction(OpCodes.Return_void));
}
}
示例2: ImplementSuperClass
/// <summary>
/// Set the super class of the class definition.
/// </summary>
protected override void ImplementSuperClass(DexTargetPackage targetPackage)
{
// TODO: implement Generic Type Definition Classes and derive from System.Nullable`1-Marker.
//Class.SuperClass = Compiler.GetDot42InternalType("System", "Nullable`1").GetClassReference(targetPackage);
Class.SuperClass = FrameworkReferences.Object;
_underlyingBuilder.Class.NullableMarkerClass = Class;
}
示例3: GetClassReference
/// <summary>
/// Gets a class reference for the given type reference.
/// </summary>
internal static ClassReference GetClassReference(this JvmClassLib.TypeReference type, XTypeUsageFlags usageFlags, DexTargetPackage targetPackage, XModule module)
{
var classRef = type.GetReference(usageFlags, targetPackage, module) as ClassReference;
if (classRef == null)
throw new ArgumentException(string.Format("type {0} is not a class reference", type.ClassName));
return classRef;
}
示例4: AddMethodToDeclaringClass
/// <summary>
/// Add the given method to its declaring class.
/// </summary>
protected override void AddMethodToDeclaringClass(ClassDefinition declaringClass, DexLib.MethodDefinition dmethod, DexTargetPackage targetPackage)
{
var generatedCodeClass = targetPackage.GetOrCreateGeneratedCodeClass();
UpdateName(dmethod, generatedCodeClass);
dmethod.Owner = generatedCodeClass;
generatedCodeClass.Methods.Add(dmethod);
}
示例5: CreateClassDefinition
/// <summary>
/// Create the current type as class definition.
/// </summary>
protected override void CreateClassDefinition(DexTargetPackage targetPackage, ClassDefinition parent, TypeDefinition parentType, XModel.XTypeDefinition parentXType)
{
base.CreateClassDefinition(targetPackage, parent, parentType, parentXType);
Class.IsFinal = true;
Class.IsAbstract = true;
Class.IsSynthetic = true;
}
示例6: AddFieldToDeclaringClass
/// <summary>
/// Add the given field to its declaring class.
/// </summary>
protected override void AddFieldToDeclaringClass(ClassDefinition declaringClass, DexLib.FieldDefinition dfield, DexTargetPackage targetPackage)
{
var generatedCodeClass = targetPackage.GetOrCreateGeneratedCodeClass();
UpdateName(dfield, generatedCodeClass);
dfield.Owner = generatedCodeClass;
generatedCodeClass.Fields.Add(dfield);
}
示例7: Implement
public override void Implement(ClassDefinition declaringClass, DexTargetPackage targetPackage)
{
if (xField == null)
return;
dfield.Type = xField.FieldType.GetReference(targetPackage);
}
示例8: Create
/// <summary>
/// Create annotations for all included attributes
/// </summary>
public static void Create(AssemblyCompiler compiler, ICustomAttributeProvider attributeProvider,
IAnnotationProvider annotationProvider, DexTargetPackage targetPackage, bool customAttributesOnly = false)
{
if (!attributeProvider.HasCustomAttributes)
return;
var annotations = new List<Annotation>();
foreach (var attr in attributeProvider.CustomAttributes)
{
var attributeType = attr.AttributeType.Resolve();
if (!attributeType.HasIgnoreAttribute())
{
Create(compiler, attr, attributeType, annotations, targetPackage);
}
}
if (annotations.Count > 0)
{
// Create 1 IAttributes annotation
var attrsAnnotation = new Annotation { Visibility = AnnotationVisibility.Runtime };
attrsAnnotation.Type = compiler.GetDot42InternalType("IAttributes").GetClassReference(targetPackage);
attrsAnnotation.Arguments.Add(new AnnotationArgument("Attributes", annotations.ToArray()));
annotationProvider.Annotations.Add(attrsAnnotation);
}
if (!customAttributesOnly)
{
// Add annotations specified using AnnotationAttribute
foreach (var attr in attributeProvider.CustomAttributes.Where(IsAnnotationAttribute))
{
var annotationType = (TypeReference) attr.ConstructorArguments[0].Value;
var annotationClass = annotationType.GetClassReference(targetPackage, compiler.Module);
annotationProvider.Annotations.Add(new Annotation(annotationClass, AnnotationVisibility.Runtime));
}
}
}
示例9: GetReference
/// <summary>
/// Gets a Dex field reference for the given field reference.
/// </summary>
internal static FieldReference GetReference(this XFieldReference field, DexTargetPackage targetPackage)
{
if (field == null)
throw new ArgumentNullException("field");
// Resolve the field to a field definition
XFieldDefinition fieldDef;
if (field.TryResolve(out fieldDef))
{
string className;
string memberName;
string descriptor;
if (fieldDef.TryGetDexImportNames(out memberName, out descriptor, out className))
{
var prototype = PrototypeBuilder.ParseFieldType(descriptor);
return new FieldReference(new ClassReference(className), memberName, prototype);
}
// Field is in the assembly itself
// Use the mapping
return targetPackage.NameConverter.GetField(fieldDef);
}
var javaField = field as XModel.Java.XBuilder.JavaFieldReference;
if (javaField != null)
{
var prototype = PrototypeBuilder.ParseFieldType(javaField.JavaDecriptor);
return new FieldReference(new ClassReference(javaField.JavaClassName), javaField.JavaName, prototype);
}
throw new ResolveException(string.Format("Field {0} not found", field.FullName));
}
示例10: Box
/// <summary>
/// Create code to box the given source value into the given type.
/// </summary>
public static RLRange Box(this IRLBuilder builder, ISourceLocation sequencePoint, RegisterSpec source, XTypeReference type, DexTargetPackage targetPackage, IRegisterAllocator frame)
{
if (type.IsPrimitive)
{
if (type.IsByte()) builder.Add(sequencePoint, RCode.Int_to_byte, source.Register, source.Register);
else if (type.IsUInt16()) builder.Add(sequencePoint, RCode.Int_to_short, source.Register, source.Register);
// Call appropriate valueOf method
var boxedType = type.Module.TypeSystem.Object;
var r = frame.AllocateTemp(boxedType.GetReference(targetPackage));
var call = builder.Add(sequencePoint, RCode.Invoke_static, type.GetBoxValueOfMethod(), source.Registers);
var last = builder.Add(sequencePoint, RCode.Move_result_object, r);
return new RLRange(call, last, r);
}
if (type.IsGenericParameter)
{
var nop = builder.Add(sequencePoint, RCode.Nop);
return new RLRange(nop, source);
}
XTypeDefinition typeDef ;
if (type.TryResolve(out typeDef) && (typeDef.IsEnum))
{
// Call appropriate valueOf method
/*var boxedType = type.Module.TypeSystem.Object;
var r = frame.AllocateTemp(boxedType.GetReference(target, nsConverter));
var call = builder.Add(sequencePoint, RCode.Invoke_static, typeDef.GetEnumUnderlyingType().GetBoxValueOfMethod(), source.Registers);
var last = builder.Add(sequencePoint, RCode.Move_result_object, r);
return new RLRange(call, last, r);*/
}
// Just cast
var checkCast = builder.Add(sequencePoint, RCode.Check_cast, type.GetReference(targetPackage), source);
return new RLRange(checkCast, source);
}
示例11: GetReference
/// <summary>
/// Gets a class reference for the given type reference.
/// </summary>
internal static TypeReference GetReference(this JvmClassLib.TypeReference type, XTypeUsageFlags usageFlags, DexTargetPackage targetPackage, XModule module)
{
if (type == null)
throw new ArgumentNullException("type");
var xType = XBuilder.AsTypeReference(module, type, usageFlags);
return xType.GetReference(targetPackage);
}
示例12: GetReference
/// <summary>
/// Gets a class reference for the given type reference.
/// </summary>
internal static TypeReference GetReference(this Mono.Cecil.TypeReference type, DexTargetPackage targetPackage, XModule module)
{
if (type == null)
throw new ArgumentNullException("type");
var xType = XBuilder.AsTypeReference(module, type);
return xType.GetReference(targetPackage);
}
示例13: ImplementSuperClass
/// <summary>
/// Set the super class of the class definition.
/// </summary>
protected override void ImplementSuperClass(DexTargetPackage targetPackage)
{
var baseType = Type.BaseType;
if (baseType != null)
{
Class.SuperClass = (ClassReference)baseType.GetReference(targetPackage, Compiler.Module);
}
}
示例14: CreateMapping
/// <summary>
/// Initializes a mapping.
/// </summary>
public static AttributeAnnotationMapping CreateMapping(
ISourceLocation sequencePoint,
AssemblyCompiler compiler,
DexTargetPackage targetPackage,
TypeDefinition attributeType,
ClassDefinition attributeClass)
{
return new AttributeAnnotationMapping(attributeType, attributeClass);
}
示例15: CreateClassDefinition
/// <summary>
/// Create the current type as class definition.
/// </summary>
protected override void CreateClassDefinition(DexTargetPackage targetPackage, ClassDefinition parent, TypeDefinition parentType, XTypeDefinition parentXType)
{
base.CreateClassDefinition(targetPackage, parent, parentType, parentXType);
Class.AccessFlags &= ~AccessFlags.Final;
Class.IsAbstract = true;
//Class.IsInterface = true;
// Record in compiler
Compiler.Record(new DelegateType(Compiler, XType, Class, targetPackage.DexFile, targetPackage.NameConverter));
}