• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DexTargetPackage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DexTargetPackage的典型用法代码示例。如果您正苦于以下问题:C# DexTargetPackage类的具体用法?C# DexTargetPackage怎么用?C# DexTargetPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DexTargetPackage类属于命名空间,在下文中一共展示了DexTargetPackage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
            }
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:38,代码来源:DelegateClassBuilder.cs


示例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;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:NullableMarkerClassBuilder.cs


示例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;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:Java.cs


示例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);
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:10,代码来源:DexImportMethodBuilder.cs


示例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;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:NullableMarkerClassBuilder.cs


示例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);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:DexImportFieldBuilder.cs


示例7: Implement

        public override void Implement(ClassDefinition declaringClass, DexTargetPackage targetPackage)
        {
            if (xField == null)
                return;

            dfield.Type = xField.FieldType.GetReference(targetPackage);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:7,代码来源:FieldInterlockedBuilder.cs


示例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));
         }
     }
 }
开发者ID:jakesays,项目名称:dot42,代码行数:36,代码来源:AnnotationBuilder.cs


示例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));
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:36,代码来源:XModel.cs


示例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);
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:36,代码来源:RLBuilder.cs


示例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);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:11,代码来源:Java.cs


示例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);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:11,代码来源:DotNet.cs


示例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);
     }
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:11,代码来源:NullableBaseClassBuilder.cs


示例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);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:12,代码来源:AttributeAnnotationInstanceBuilder.cs


示例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));
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:12,代码来源:DelegateClassBuilder.cs


示例16: AddGenericDefinitionAnnotationIfGeneric

        /// <summary>
        /// Create a IGnericDefinition annotation and attaches it to the given provider.
        /// TODO: this might better belong somewhere else.
        /// </summary>
        public static void AddGenericDefinitionAnnotationIfGeneric(this IAnnotationProvider provider, XTypeReference xtype, AssemblyCompiler compiler, DexTargetPackage targetPackage, bool forceTypeDefinition=false)
        {
            if (!xtype.IsGenericInstance && !xtype.IsGenericParameter)
                return;

            Annotation annotation = GetGenericDefinitionAnnotationForType(xtype, forceTypeDefinition, compiler, targetPackage);
            if(annotation != null)
                provider.Annotations.Add(annotation);
        }
开发者ID:jakesays,项目名称:dot42,代码行数:13,代码来源:DexAnnotations.cs


示例17: CreateAnnotations

        public override void CreateAnnotations(DexTargetPackage targetPackage)
        {
            base.CreateAnnotations(targetPackage);

            if (Class == null)
                return;

            bool isBaseTypeGeneric = XType.BaseType != null && (XType.BaseType.IsGenericInstance || XType.BaseType.IsGenericParameter);
            bool containsGenericInterfaces = XType.Interfaces.Any(i => i.IsGenericInstance || i.IsGenericParameter);
            bool needsFieldAnnotation = !Class.IsSynthetic && Class.Fields.Count(p => !p.IsSynthetic && !p.IsStatic) > 1;
            
            bool needsAnnotation = Class.GenericInstanceFields.Count > 0 
                                || XType.GenericParameters.Count > 0 
                                || isBaseTypeGeneric 
                                || containsGenericInterfaces 
                                || needsFieldAnnotation;

            if (!needsAnnotation) return;

            var annType = Compiler.GetDot42InternalType(InternalConstants.TypeReflectionInfoAnnotation).GetClassReference(targetPackage);
            var annotation = new Annotation(annType, AnnotationVisibility.Runtime);

            if (Class.GenericInstanceFields.Count > 0)
            {
                    annotation.Arguments.Add(new AnnotationArgument(InternalConstants.TypeReflectionInfoGenericArgumentsFields,
                                             Class.GenericInstanceFields.Select(f=>f.Name).ToArray()));
            }

            if (XType.GenericParameters.Count > 0)
                annotation.Arguments.Add(new AnnotationArgument(InternalConstants.TypeReflectionInfoGenericArgumentCountField, XType.GenericParameters.Count));

            List<Annotation> definitions= new List<Annotation>();

            if (isBaseTypeGeneric)
                definitions.Add(AssemblyCompilerExtensions.GetGenericDefinitionAnnotationForType(
                                XType.BaseType, true, Compiler, targetPackage));

            foreach (var intf in XType.Interfaces)
            {
                if(!intf.IsGenericInstance && !intf.IsGenericParameter)
                    continue;
                definitions.Add(AssemblyCompilerExtensions.GetGenericDefinitionAnnotationForType(
                                                            intf, true, Compiler, targetPackage));
            }

            if(definitions.Count > 0)
                annotation.Arguments.Add(new AnnotationArgument(InternalConstants.TypeReflectionInfoGenericDefinitionsField, definitions.ToArray()));

            if (needsFieldAnnotation)
            {
                annotation.Arguments.Add(new AnnotationArgument(InternalConstants.TypeReflectionInfoFieldsField, 
                                         Class.Fields.Where(p=>!p.IsSynthetic && !p.IsStatic).Select(p=>p.Name).ToArray()));
            }

            Class.Annotations.Add(annotation);
        }
开发者ID:jakesays,项目名称:dot42,代码行数:56,代码来源:StandardClassBuilder.cs


示例18: ImplementSuperClass

 protected override void ImplementSuperClass(DexTargetPackage targetPackage)
 {
     if (!IsDot42InternalApplication())
     {
         var dot42Internal = Compiler.GetDot42InternalType("Application");
         Class.SuperClass = dot42Internal.GetClassReference(targetPackage);
     }
     else
         base.ImplementSuperClass(targetPackage);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:AndroidAppApplicationDerivedBuilder.cs


示例19: Create

        public override void Create(ClassDefinition declaringClass, XTypeDefinition declaringType, DexTargetPackage targetPackage)
        {
            if (_baseFieldBuilder.dfield == null)
                return;

            // can't create udater for static fields.
            if (field.IsStatic)
                return;

            var updaterType = GetAtomicFieldUpdaterType(field.FieldType);
            if (updaterType == null)
                return;

            var fullUpdateTypeName = "Java.Util.Concurrent.Atomic." + updaterType;

            // create matching xField. Note: this seems to be a hack. what to do?

            var objType = new ObjectTypeReference(fullUpdateTypeName, new TypeArgument[0]);
            var javaTypeReference = new XBuilder.JavaTypeReference(Compiler.Module, objType, objType.ClassName);

            var basexField = _baseFieldBuilder.xField;
            var basedField = _baseFieldBuilder.dfield;
            var fieldName = basedField.Name + NameConstants.Atomic.FieldUpdaterPostfix;

            var xflags = XSyntheticFieldFlags.Static | XSyntheticFieldFlags.ReadOnly;

            if (basedField.IsProtected)
                xflags |= XSyntheticFieldFlags.Protected;
            if (basedField.IsPrivate)
                xflags |= XSyntheticFieldFlags.Private;


            var xAtomicField = XSyntheticFieldDefinition.Create(basexField.DeclaringType, xflags, fieldName, javaTypeReference);
            xField = xAtomicField;

            // create dfield.
            
            dfield = new DexLib.FieldDefinition
            {
                Name = fieldName,
                IsStatic = true,
                IsFinal = true,
                IsSynthetic = true,
                // same access as the original field.
                IsPublic = basedField.IsPublic,
                IsPrivate = basedField.IsPrivate,
                IsProtected = basedField.IsProtected,
            };
            
            AddFieldToDeclaringClass(declaringClass, dfield, targetPackage);

            targetPackage.NameConverter.Record(xField, dfield);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:53,代码来源:FieldInterlockedBuilder.cs


示例20: CreateMembers

        /// <summary>
        /// Implemented all fields and methods.
        /// </summary>
        protected override void CreateMembers(DexTargetPackage targetPackage)
        {
            // Create normal members
            base.CreateMembers(targetPackage);

            if(!Type.IsAbstract)
            {
                // Create annotation interface and attribute build methods
                mapping = AttributeAnnotationInstanceBuilder.CreateMapping(null, Compiler, targetPackage, Type, Class);
                Compiler.Record(Type, mapping);
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:15,代码来源:AttributeClassBuilder.cs



注:本文中的DexTargetPackage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DfareportingService类代码示例发布时间:2022-05-24
下一篇:
C# DeviceType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap