예제 #1
0
 /// <summary>
 /// Try to get a type definition (me or one of my nested typed) by the given full name.
 /// </summary>
 public override bool TryGet(string fullName, bool noImports, out XTypeDefinition xTypeDefinition)
 {
     if (base.TryGet(fullName, noImports, out xTypeDefinition))
     {
         return(true);
     }
     if (!noImports)
     {
         EnsureDexImportType();
         if (dexImportType != Module.TypeSystem.NoType)
         {
             if (dexImportType.FullName == fullName)
             {
                 xTypeDefinition = this;
                 return(true);
             }
         }
         EnsureJavaImportType();
         if (javaImportType.FullName == fullName)
         {
             xTypeDefinition = this;
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Create a synthetic field and add it to the given declaring type.
        /// </summary>
        public static XSyntheticTypeDefinition Create(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType)
        {
            var type = new XSyntheticTypeDefinition(module, declaringType, flags, @namespace, name, baseType);

            declaringType.Add(type);
            return(type);
        }
예제 #3
0
            /// <summary>
            /// Resolve this reference to it's definition.
            /// </summary>
            public override bool TryResolve(out XTypeDefinition type)
            {
                if (base.TryResolve(out type))
                    return true;
                switch (FullName)
                {
                    case "B":
                        return Module.TypeSystem.SByte.TryResolve(out type);
                    case "C":
                        return Module.TypeSystem.Char.TryResolve(out type);
                    case "D":
                        return Module.TypeSystem.Double.TryResolve(out type);
                    case "F":
                        return Module.TypeSystem.Float.TryResolve(out type);
                    case "I":
                        return Module.TypeSystem.Int.TryResolve(out type);
                    case "J":
                        return Module.TypeSystem.Long.TryResolve(out type);
                    case "S":
                        return Module.TypeSystem.Short.TryResolve(out type);
                    case "Z":
                        return Module.TypeSystem.Bool.TryResolve(out type);
                }

                // Try clumsy nested like classes
                if (Module.TryGetType(javaClassName, out type))
                    return true;

                return false;
            }
예제 #4
0
        private void CreateMembersTree(LibraryNode current, XTypeDefinition scope, XSharpModuleId moduleId)
        {
            if (null == scope || XSolution.IsClosing)
            {
                return;
            }


            foreach (XMemberDefinition member in scope.Members)
            {
                XSharpLibraryNode newNode = new XSharpLibraryNode(member, "", moduleId.Hierarchy, moduleId.ItemID);

                // The classes are always added to the root node, the functions to the
                // current node.
                if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None)
                {
                    current.AddNode(newNode);
                    newNode.parent = current;
                    lock (files)
                    {
                        files.Add(moduleId, newNode);
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Create the XType for this builder.
        /// </summary>
        protected override XTypeDefinition CreateXType(XTypeDefinition parentXType)
        {
            var baseType = Compiler.GetDot42InternalType("EnumInfo");

            return(XSyntheticTypeDefinition.Create(Compiler.Module, parentXType, XSyntheticTypeFlags.Private, null, ClassName,
                                                   baseType, parentXType.ScopeId + ":Info"));
        }
        /// <summary>
        /// Create a synthetic method and add it to the given declaring type.
        /// </summary>
        public static XSyntheticMethodDefinition Create(XTypeDefinition declaringType, XSyntheticMethodFlags flags, string name, string scopeId, XTypeReference returnType, params XParameter[] parameters)
        {
            var method = new XSyntheticMethodDefinition(declaringType, flags, name, scopeId, returnType, parameters);

            declaringType.Add(method);
            return(method);
        }
예제 #7
0
        /// <summary>
        /// Create a synthetic field and add it to the given declaring type.
        /// </summary>
        public static XSyntheticFieldDefinition Create(XTypeDefinition declaringType, XSyntheticFieldFlags flags, string name, XTypeReference fieldType, object initialValue = null)
        {
            var field = new XSyntheticFieldDefinition(declaringType, flags, name, fieldType, initialValue);

            declaringType.Add(field);
            return(field);
        }
        private List <XMemberDefinition> BuildMissingMembers(XTypeDefinition currentClass, System.Reflection.MemberInfo[] members)
        {
            List <XMemberDefinition> elementsToAdd = new List <XMemberDefinition>();

            //
            foreach (System.Reflection.MemberInfo member in members)
            {
                System.Reflection.MemberTypes realType = member.MemberType;
                if (realType == System.Reflection.MemberTypes.Method)
                {
                    System.Reflection.MethodInfo method = (System.Reflection.MethodInfo)member;
                    // Check for Getter/Setter
                    if ((method.Attributes & System.Reflection.MethodAttributes.SpecialName) == System.Reflection.MethodAttributes.SpecialName)
                    {
                        string getsetName = member.Name;
                        if (getsetName.StartsWith("get_") || getsetName.StartsWith("set_"))
                        {
                            // Oooppsss
                            continue;
                        }
                    }
                }
                // Now, We will have to check Parameters / Return Type
                if (!CheckForMember(currentClass, member))
                {
                    // and re-create our own prototype
                    elementsToAdd.Add(CreateMember(member, members));
                }
            }
            return(elementsToAdd);
        }
예제 #9
0
        /// <summary>
        /// Convert the given node that holds a numeric value and convert it to it's enum instance.
        /// </summary>
        private static void ConvertNumericToEnum(AstExpression node, XTypeDefinition enumType, XTypeReference enumNumericType)
        {
            // Call Enum.GetValue(enumType, value)
            var enumValue = new AstExpression(node);

            node.SetCode(enumNumericType.IsWide() ? AstCode.Long_to_enum : AstCode.Int_to_enum).SetArguments(enumValue).SetType(enumType);
            node.Operand = null;
        }
예제 #10
0
 /// <summary>
 /// Default ctor
 /// </summary>
 private XSyntheticFieldDefinition(XTypeDefinition declaringType, XSyntheticFieldFlags flags, string name, XTypeReference fieldType, object initialValue)
     : base(declaringType)
 {
     this.flags        = flags;
     this.name         = name;
     this.fieldType    = fieldType;
     this.initialValue = initialValue;
 }
예제 #11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 private XSyntheticFieldDefinition(XTypeDefinition declaringType, XSyntheticFieldFlags flags, string name, XTypeReference fieldType, object initialValue)
     : base(declaringType)
 {
     this.flags = flags;
     this.name = name;
     this.fieldType = fieldType;
     this.initialValue = initialValue;
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 private XSyntheticMethodDefinition(XTypeDefinition declaringType, XSyntheticMethodFlags flags, string name, XTypeReference returnType, params XParameter[] parameters)
     : base(declaringType)
 {
     this.flags      = flags;
     this.name       = name;
     this.returnType = returnType;
     this.parameters = parameters.ToList();
     astParameters   = parameters.Select(x => new AstParameterVariable(x)).Cast <AstVariable>().ToList();
 }
예제 #13
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ILTypeDefinition(XModule module, XTypeDefinition declaringType, TypeDefinition type)
     : base(module, declaringType, type.IsValueType, type.GenericParameters.Select(x => x.Name))
 {
     this.type = type;
     fields = new List<XFieldDefinition>(type.Fields.Count);
     methods = new List<XMethodDefinition>(type.Methods.Count);
     nested = new List<XTypeDefinition>();
     interfaces = new List<XTypeReference>();
 }
예제 #14
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public DelegateType(AssemblyCompiler compiler, XTypeDefinition delegateType, ClassDefinition interfaceClass, Dex target, NameConverter nsConverter)
        {
            this.compiler       = compiler;
            this.delegateType   = delegateType;
            this.interfaceClass = interfaceClass;

            // Build invoke prototype
            invokeMethod = delegateType.Methods.First(x => x.EqualsName("Invoke"));
        }
예제 #15
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ILTypeDefinition(XModule module, XTypeDefinition declaringType, TypeDefinition type)
     : base(module, declaringType, type.IsValueType, type.GenericParameters.Select(x => x.Name))
 {
     this.type  = type;
     fields     = new List <XFieldDefinition>(type.Fields.Count);
     methods    = new List <XMethodDefinition>(type.Methods.Count);
     nested     = new List <XTypeDefinition>();
     interfaces = new List <XTypeReference>();
 }
예제 #16
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public JavaTypeDefinition(XModule module, XTypeDefinition declaringType, ClassFile type)
     : base(module, declaringType, false, null)
 {
     this.type  = type;
     fields     = type.Fields.Select(x => new JavaFieldDefinition(this, x)).Cast <XFieldDefinition>().ToList().AsReadOnly();
     methods    = type.Methods.Select(x => new JavaMethodDefinition(this, x)).Cast <XMethodDefinition>().ToList().AsReadOnly();
     nested     = type.InnerClasses.Where(x => x.InnerClassFile.DeclaringClass == type).Select(x => new JavaTypeDefinition(module, this, x.InnerClassFile)).Cast <XTypeDefinition>().ToList().AsReadOnly();
     interfaces = new List <XTypeReference>();
 }
예제 #17
0
        /// <summary>
        /// Create a synthetic field and add it to the given declaring type.
        /// </summary>
        public static XSyntheticTypeDefinition Create(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType, string fullScopeId)
        {
            var type = new XSyntheticTypeDefinition(module, declaringType, flags, @namespace, name, baseType, fullScopeId);
            if(declaringType != null)
                declaringType.Add(type);

            module.Register(type);
            return type;
        }
예제 #18
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public JavaTypeDefinition(XModule module, XTypeDefinition declaringType, ClassFile type)
     : base(module, declaringType, false, null)
 {
     this.type = type;
     fields = type.Fields.Select(x => new JavaFieldDefinition(this, x)).Cast<XFieldDefinition>().ToList().AsReadOnly();
     methods = type.Methods.Select(x => new JavaMethodDefinition(this, x)).Cast<XMethodDefinition>().ToList().AsReadOnly();
     nested = type.InnerClasses.Where(x => x.InnerClassFile.DeclaringClass == type).Select(x => new JavaTypeDefinition(module, this, x.InnerClassFile)).Cast<XTypeDefinition>().ToList().AsReadOnly();
     interfaces = new List<XTypeReference>();
 }
예제 #19
0
        /// <summary>
        /// Get's the namespace of the given type after conversion.
        /// </summary>
        public string GetConvertedNamespace(XTypeDefinition type)
        {
            if (type.IsNested)
            {
                return(GetConvertedNamespace(type.DeclaringType));
            }
            var ns = type.Namespace;

            return(ConvertNamespace(ns));
        }
예제 #20
0
        /// <summary>
        /// Gets the struct $CopyFrom method of the given value type.
        /// Throws an exception if not found.
        /// </summary>
        private static XMethodDefinition GetCopyFromMethod(XTypeDefinition valueType)
        {
            var method = valueType.Methods.FirstOrDefault(x => !x.IsStatic && (x.Parameters.Count == 1) && (x.Name == NameConstants.Struct.CopyFromMethodName));

            if (method == null)
            {
                throw new NotImplementedException(string.Format("Value type {0} has no struct copyFrom method", valueType.FullName));
            }
            return(method);
        }
예제 #21
0
 /// <summary>
 /// Resolve this reference to it's definition.
 /// </summary>
 public override bool TryResolve(out XTypeDefinition type)
 {
     if (resolved == null)
     {
         if (!base.TryResolve(out resolved)) 
             throw new XResolutionException(this);
     }
     type = resolved;
     return true;
 }
예제 #22
0
        /// <summary>
        /// Gets the default constructor of the given value type.
        /// Throws an exception if not found.
        /// </summary>
        internal static XMethodDefinition GetDefaultValueCtor(XTypeDefinition valueType)
        {
            var defaultCtor = valueType.Methods.FirstOrDefault(x => x.IsConstructor && !x.IsStatic && (x.Parameters.Count == 0));

            if (defaultCtor == null)
            {
                throw new NotImplementedException(string.Format("Value type {0} has no default ctor", valueType.FullName));
            }
            return(defaultCtor);
        }
예제 #23
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public AstBuilder(XModule module, MethodDefinition methodDef, XTypeDefinition declaringType, bool optimize)
 {
     this.module            = module;
     typeSystem             = module.TypeSystem;
     this.methodDef         = methodDef;
     this.declaringType     = declaringType;
     this.optimize          = optimize;
     codeAttr               = methodDef.Attributes.OfType <CodeAttribute>().FirstOrDefault();
     validExceptionHandlers = (codeAttr != null) ? codeAttr.ExceptionHandlers.Where(IsValid).ToList() : null;
 }
예제 #24
0
        /// <summary>
        /// Convert a integer compare operation (bge, bgt, ble, blt) with enum argument.
        /// </summary>
        private static void ConvertICmpArgument(AstExpression node, int argIndex, XTypeDefinition enumType, AssemblyCompiler compiler)
        {
            Debug.Assert(node.Arguments.Count == 2);
            var isWide  = enumType.GetEnumUnderlyingType().IsWide();
            var module  = compiler.Module;
            var retType = isWide ? module.TypeSystem.Long : module.TypeSystem.Int;

            // Convert arguments
            ConvertNumericOpArgument(node, argIndex, enumType, isWide, retType);
        }
예제 #25
0
        /// <summary>
        /// Gets the recorded delegate type for the given .NET delegate type.
        /// </summary>
        internal DelegateType GetDelegateType(XTypeDefinition type)
        {
            DelegateType result;

            if (delegateTypes.TryGetValue(type, out result))
            {
                return(result);
            }
            throw new ArgumentException(string.Format("No delegate type found for {0}", type.FullName));
        }
예제 #26
0
        /// <summary>
        /// Create the current type as class definition.
        /// </summary>
        public virtual void Create(ClassDefinition declaringClass, XTypeDefinition declaringType, DexTargetPackage targetPackage)
        {
            // Find xfield
            xField = XBuilder.AsFieldDefinition(compiler.Module, field);

            // Create field definition
            dfield      = new Dot42.DexLib.FieldDefinition();
            dfield.Name = NameConverter.GetConvertedName(field);
            AddFieldToDeclaringClass(declaringClass, dfield, targetPackage);
            targetPackage.NameConverter.Record(xField, dfield);

            // Set access flags
            SetAccessFlags(dfield, field);

            // Give warning if static in generic class.
            // This could of cause also be handled automagically be the compiler,
            // with mixture of whats done in the Interlocked converter and whats
            // done in the GenericInstanceConverter.
            if (field.IsStatic && declaringType.IsGenericClass)
            {
                if (!field.HasSuppressMessageAttribute("StaticFieldInGenericType") &&
                    !field.DeclaringType.HasSuppressMessageAttribute("StaticFieldInGenericType"))
                {
                    string msg;
                    if (field.Name.Contains("CachedAnonymousMethodDelegate"))
                    {
                        msg = "The compiler generated a static field '{0}' in generic type '{1}'. This is not supported " +
                              "in Dot42 if the anonymous delegate accesses a generic class parameter. A workaround " +
                              "is to convert the anonymous static delegate to a normal method.\n";
                    }
                    else
                    {
                        msg = "Static field '{0}' in generic type {1}: All generic instances will share " +
                              "the same static field, contrary on how CLR operates. A workaround is to " +
                              "use ConcurrentDictionaries to access the values dependent on the type.\n";
                    }

                    msg += "You can suppress this warning with a [SuppressMessage(\"dot42\"," +
                           " \"StaticFieldInGenericType\")] attribute, either on the field or on the class.";

                    var body = field.DeclaringType.Methods.Select(m => m.Body)
                               .FirstOrDefault(m => m != null &&
                                               m.Instructions.Any(i => i.SequencePoint(m) != null));
                    if (body != null)
                    {
                        var seqPoint = body.Instructions.Select(i => i.SequencePoint(body)).First(i => i != null);
                        DLog.Warning(DContext.CompilerILConverter, seqPoint.Document.Url, seqPoint.StartColumn, seqPoint.StartLine, msg, field.Name, declaringType.FullName);
                    }
                    else
                    {
                        DLog.Warning(DContext.CompilerILConverter, msg, field.Name, declaringType.FullName);
                    }
                }
            }
        }
예제 #27
0
 /// <summary>
 /// Default ctor
 /// </summary>
 private XSyntheticTypeDefinition(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType)
     : base(module, declaringType, flags.HasFlag(XSyntheticTypeFlags.ValueType), null)
 {
     this.flags = flags;
     this.@namespace = @namespace;
     this.name = name;
     this.baseType = baseType;
     fields = new List<XFieldDefinition>();
     methods = new List<XMethodDefinition>();
     nestedTypes = new List<XTypeDefinition>();
     interfaces = new List<XTypeReference>();
 }
예제 #28
0
 /// <summary>
 /// Default ctor
 /// </summary>
 private XSyntheticTypeDefinition(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType)
     : base(module, declaringType, flags.HasFlag(XSyntheticTypeFlags.ValueType), null)
 {
     this.flags      = flags;
     this.@namespace = @namespace;
     this.name       = name;
     this.baseType   = baseType;
     fields          = new List <XFieldDefinition>();
     methods         = new List <XMethodDefinition>();
     nestedTypes     = new List <XTypeDefinition>();
     interfaces      = new List <XTypeReference>();
 }
예제 #29
0
 /// <summary>
 /// Resolve this reference to it's definition.
 /// </summary>
 public override bool TryResolve(out XTypeDefinition type)
 {
     if (resolved == null)
     {
         if (!base.TryResolve(out resolved))
         {
             throw new XResolutionException(this);
         }
     }
     type = resolved;
     return(true);
 }
예제 #30
0
 /// <summary>
 /// .NET ctor
 /// </summary>
 public DecompilerContext(XMethodDefinition currentMethod)
 {
     if (currentMethod == null)
     {
         throw new ArgumentNullException("currentMethod");
     }
     name = currentMethod.Name;
     declaringTypeName = currentMethod.DeclaringType.Name;
     declaringType     = currentMethod.DeclaringType;
     returnType        = currentMethod.ReturnType;
     currentModule     = currentMethod.Module;
 }
예제 #31
0
        /// <summary>
        /// Get's the full name of the given type after conversion.
        /// </summary>
        public string GetConvertedFullName(XTypeDefinition type)
        {
            if (type.IsNested)
            {
                var declaringTypeName = GetConvertedFullName(type.DeclaringType);
                return(declaringTypeName + Dex.NestedClassSeparator + GetConvertedName(type));
            }

            var ns = GetConvertedNamespace(type);

            return(ns + '.' + GetConvertedName(type));
        }
예제 #32
0
        /// <summary>
        /// Create a synthetic field and add it to the given declaring type.
        /// </summary>
        public static XSyntheticTypeDefinition Create(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType, string fullScopeId)
        {
            var type = new XSyntheticTypeDefinition(module, declaringType, flags, @namespace, name, baseType, fullScopeId);

            if (declaringType != null)
            {
                declaringType.Add(type);
            }

            module.Register(type);
            return(type);
        }
예제 #33
0
 /// <summary>
 /// Try to get a type definition (me or one of my nested typed) by the given full name.
 /// </summary>
 public override bool TryGet(string fullName, bool noImports, out XTypeDefinition type)
 {
     if (base.TryGet(fullName, noImports, out type))
     {
         return(true);
     }
     if (fullName == this.type.ClassName)
     {
         type = this;
         return(true);
     }
     return(false);
 }
        protected override void CreateClassDefinition(DexTargetPackage targetPackage, ClassDefinition parent,
                                                      TypeDefinition parentType,
                                                      XTypeDefinition parentXType)
        {
            base.CreateClassDefinition(targetPackage, parent, parentType, parentXType);

            if (IsDot42InternalApplication())
            {
                // FixUp Visiblility.
                Class.IsPublic    = true;
                Class.IsProtected = false;
                Class.IsPrivate   = false;
            }
        }
예제 #35
0
        public void AugmentPeekSession(IPeekSession session, IList <IPeekableItem> peekableItems)
        {
            try
            {
                XSharpModel.ModelWalker.Suspend();
                if (!string.Equals(session.RelationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
                //
                var tp = session.GetTriggerPoint(_textBuffer.CurrentSnapshot);
                if (!tp.HasValue)
                {
                    return;
                }
                //
                var    triggerPoint = tp.Value;
                IToken stopToken;
                //
                // Check if we can get the member where we are
                XMemberDefinition member           = XSharpLanguage.XSharpTokenTools.FindMember(triggerPoint.GetContainingLine().LineNumber, _file);
                XTypeDefinition   currentNamespace = XSharpLanguage.XSharpTokenTools.FindNamespace(triggerPoint.Position, _file);

                var           lineNumber = triggerPoint.GetContainingLine().LineNumber;
                var           snapshot   = _textBuffer.CurrentSnapshot;
                List <String> tokenList  = XSharpTokenTools.GetTokenList(triggerPoint.Position, lineNumber, snapshot, out stopToken, true, _file, false, member);
                // LookUp for the BaseType, reading the TokenList (From left to right)
                CompletionElement gotoElement;
                String            currentNS = "";
                if (currentNamespace != null)
                {
                    currentNS = currentNamespace.Name;
                }
                CompletionType cType = XSharpLanguage.XSharpTokenTools.RetrieveType(_file, tokenList, member, currentNS, stopToken, out gotoElement, snapshot, lineNumber, _file.Project.Dialect);
                //
                if ((gotoElement != null) && (gotoElement.IsSourceElement))
                {
                    peekableItems.Add(new XSharpDefinitionPeekItem(gotoElement.SourceElement, _peekResultFactory));
                }
            }
            catch (Exception ex)
            {
                XSettings.DisplayOutputMessage("XSharpPeekItemSource.AugmentPeekSession failed : ");
                XSettings.DisplayException(ex);
            }
            finally
            {
                ModelWalker.Resume();
            }
        }
예제 #36
0
        /// <summary>
        /// Gets a formatted full classname for the given type.
        /// </summary>
        private string FormatClassName(XTypeDefinition typeDef)
        {
            string className;

            if (typeDef.TryGetDexImportNames(out className))
            {
                return(FormatImportedClassName(className));
            }
            if (typeDef.TryGetJavaImportNames(out className))
            {
                return(FormatImportedClassName(className));
            }
            return(nsConverter.GetConvertedFullName(typeDef));
        }
예제 #37
0
        protected override XTypeDefinition CreateXType(XTypeDefinition parentXType)
        {
            var typeDef = (XBuilder.ILTypeDefinition)XBuilder.AsTypeReference(Compiler.Module, Type)
                          .Resolve();

            string name = NameConverter.GetNullableClassName(typeDef.Name);

            XSyntheticTypeFlags xflags = default(XSyntheticTypeFlags);

            return(XSyntheticTypeDefinition.Create(Compiler.Module, parentXType, xflags,
                                                   typeDef.Namespace, name,
                                                   Compiler.Module.TypeSystem.Object,
                                                   string.Join(":", Type.Scope.Name, Type.MetadataToken.ToScopeId(), "Nullable")));
        }
예제 #38
0
            /// <summary>
            /// Default ctor
            /// </summary>
            public ILTypeDefinition(XModule module, XTypeDefinition declaringType, TypeDefinition type)
                : base(module, declaringType, type.IsValueType, type.GenericParameters.Select(x => x.Name))
            {
                this.type = type;
                fields = new List<XFieldDefinition>(type.Fields.Count);
                methods = new List<XMethodDefinition>(type.Methods.Count);
                nested = new List<XTypeDefinition>();
                interfaces = new List<XTypeReference>();

                // Add nested types
                foreach (var source in type.NestedTypes/*.Where(t=>t.IsReachable) should we only consider reachables?*/)
                {
                    var nestedType = new ILTypeDefinition(Module, this, source);
                    nested.Add(nestedType);
                    module.Register(nestedType);
                }

                 methodToIdx = type.Methods.Select((m, idx) => new { m, idx }).ToDictionary(k => k.m, k => k.idx);
            }
예제 #39
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ILFieldDefinition(XTypeDefinition declaringType, FieldDefinition field)
     : base(declaringType)
 {
     this.field = field;
 }
예제 #40
0
 /// <summary>
 /// Try to get a type definition (me or one of my nested typed) by the given full name.
 /// </summary>
 public override bool TryGet(string fullName, bool noImports, out XTypeDefinition xTypeDefinition)
 {
     if (base.TryGet(fullName, noImports, out xTypeDefinition))
         return true;
     if (!noImports)
     {
         EnsureDexImportType();
         if (dexImportType != Module.TypeSystem.NoType)
         {
             if (dexImportType.FullName == fullName)
             {
                 xTypeDefinition = this;
                 return true;
             }
         }
         EnsureJavaImportType();
         if (javaImportType.FullName == fullName)
         {
             xTypeDefinition = this;
             return true;
         }
     }
     return false;
 }
예제 #41
0
 /// <summary>
 /// Default ctor
 /// </summary>
 protected XFieldDefinition(XTypeDefinition declaringType)
     : base(declaringType)
 {
 }
예제 #42
0
 /// <summary>
 /// Try to get a type definition (me or one of my nested typed) by the given full name.
 /// </summary>
 public override bool TryGet(string fullName, bool noImports, out XTypeDefinition type)
 {
     if (base.TryGet(fullName, noImports, out type))
         return true;
     if (fullName == this.type.ClassName)
     {
         type = this;
         return true;
     }
     return false;
 }
예제 #43
0
 /// <summary>
 /// Create a synthetic field and add it to the given declaring type.
 /// </summary>
 public static XSyntheticTypeDefinition Create(XModule module, XTypeDefinition declaringType, XSyntheticTypeFlags flags, string @namespace, string name, XTypeReference baseType)
 {
     var type = new XSyntheticTypeDefinition(module, declaringType, flags, @namespace, name, baseType);
     declaringType.Add(type);
     return type;
 }
예제 #44
0
 /// <summary>
 /// Resolve this reference to it's definition.
 /// </summary>
 public override bool TryResolve(out XTypeDefinition type)
 {
     type = null;
     return false;
 }
예제 #45
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public JavaMethodDefinition(XTypeDefinition declaringType, MethodDefinition method)
     : base(declaringType)
 {
     this.method = method;
 }
예제 #46
0
 /// <summary>
 /// Create a synthetic field and add it to the given declaring type.
 /// </summary>
 public static XSyntheticFieldDefinition Create(XTypeDefinition declaringType, XSyntheticFieldFlags flags, string name, XTypeReference fieldType, object initialValue = null)
 {
     var field = new XSyntheticFieldDefinition(declaringType, flags, name, fieldType, initialValue);
     declaringType.Add(field);
     return field;
 }