예제 #1
0
        protected TypeInfo ConstructTypeInformation(TypeIdentifier identifier, TypeDefinition type, Dictionary <TypeIdentifier, TypeDefinition> moreTypes)
        {
            var moduleInfo = GetModuleInformation(type.Module);

            TypeInfo baseType = null, declaringType = null;

            if (type.BaseType != null)
            {
                baseType = GetExisting(type.BaseType);
                if (baseType == null)
                {
                    throw new InvalidOperationException(String.Format(
                                                            "Missing type info for base type '{0}' of type '{1}'",
                                                            type.BaseType, type
                                                            ));
                }
            }

            if (type.DeclaringType != null)
            {
                declaringType = GetExisting(type.DeclaringType);
                if (declaringType == null)
                {
                    throw new InvalidOperationException(String.Format(
                                                            "Missing type info for declaring type '{0}' of type '{1}'",
                                                            type.DeclaringType, type
                                                            ));
                }
            }

            var result = new TypeInfo(this, moduleInfo, type, declaringType, baseType, identifier);

            Action <TypeReference> addType = (tr) => {
                if (tr == null)
                {
                    return;
                }

                var td = TypeUtil.GetTypeDefinition(tr);
                if (td == null)
                {
                    return;
                }

                var _identifier = new TypeIdentifier(td);
                if (_identifier.Equals(identifier))
                {
                    return;
                }
                else if (moreTypes.ContainsKey(_identifier))
                {
                    return;
                }

                moreTypes[_identifier] = td;
            };

            foreach (var member in result.Members.Values)
            {
                addType(member.ReturnType);

                var method = member as Internal.MethodInfo;
                if (method != null)
                {
                    foreach (var p in method.Member.Parameters)
                    {
                        addType(p.ParameterType);
                    }
                }
            }

            return(result);
        }
 public virtual bool EmitTypeDeclarationHeader(DecompilerContext context, IAstEmitter astEmitter, TypeDefinition typedef, TypeInfo typeInfo)
 {
     return(false);
 }
        public override bool EmitTypeDeclarationHeader(DecompilerContext context, IAstEmitter astEmitter, TypeDefinition typedef, TypeInfo typeInfo)
        {
            if (!DefinitelyTypedUtilities.IsTypePublic(typedef))
            {
                return(true);
            }

            Formatter.EmitInsideNamespace(typedef, false, isTopLevel => {
                Formatter.WriteRaw("namespace");
                Formatter.Space();
                Formatter.Identifier(DefinitelyTypedUtilities.GetClassName(typedef));
                Formatter.OpenBrace();
                EmitClassInstance(typedef);
                EmitClassInOutType(typedef);
                EmitClassStatic(typedef);
                EmitClassFactory(typedef);
                Formatter.CloseBrace();
            });

            Formatter.NewLine();

            return(true);
        }
        public override bool EmitTypeDeclarationHeader(DecompilerContext context, IAstEmitter astEmitter, TypeDefinition typedef, TypeInfo typeInfo)
        {
            if (!DefinitelyTypedUtilities.IsTypePublic(typedef))
            {
                return(true);
            }

            Formatter.EmitInsideNamespace(typedef, true, isTopLevel => {
                if (isTopLevel)
                {
                    Formatter.WriteRaw("export");
                    Formatter.Space();
                    Formatter.WriteRaw("declare");
                    Formatter.Space();
                }

                Formatter.WriteRaw("let");
                Formatter.Space();

                Formatter.Identifier(DefinitelyTypedUtilities.GetClassName(typedef));
                Formatter.Space();
                Formatter.WriteRaw(":");
                Formatter.Space();

                Formatter.Identifier("$this");
                Formatter.Dot();

                foreach (var part in DefinitelyTypedUtilities.GetFullNamespace(typedef))
                {
                    Formatter.Identifier(part);
                    Formatter.Dot();
                }

                Formatter.Identifier(DefinitelyTypedUtilities.GetClassName(typedef));
                Formatter.Dot();
                Formatter.Identifier("Factory");
                Formatter.Semicolon();
            });

            return(true);
        }
 public virtual void EmitInterfaceList(TypeInfo typeInfo, IAstEmitter astEmitter, JSRawOutputIdentifier dollar)
 {
 }
 public virtual void BeginEmitTypeDefinition(IAstEmitter astEmitter, TypeDefinition typedef, TypeInfo typeInfo, TypeReference baseClass)
 {
 }