Exemplo n.º 1
0
        /// <nodoc />
        public InterfaceDeclaration(
            SymbolAtom name,
            IReadOnlyList <TypeParameter> typeParameters,
            IReadOnlyList <NamedTypeReference> extendedTypes,
            IReadOnlyList <Expression> decorators,
            ObjectType body,
            DeclarationFlags modifier,
            LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(typeParameters != null);
            Contract.RequiresForAll(typeParameters, p => p != null);
            Contract.Requires(extendedTypes != null);
            Contract.RequiresForAll(extendedTypes, t => t != null);
            Contract.Requires(decorators != null);
            Contract.RequiresForAll(decorators, d => d != null);
            Contract.Requires(body != null);

            Name           = name;
            TypeParameters = typeParameters;
            ExtendedTypes  = extendedTypes;
            Body           = body;
            Decorators     = decorators;
        }
Exemplo n.º 2
0
        /// <nodoc />
        public FunctionDeclaration(
            [NotNull] IReadOnlyList <SymbolAtom> @namespace,
            SymbolAtom name,
            [NotNull] CallSignature callSignature,
            [NotNull] Statement body,
            int captures,
            int locals,
            DeclarationFlags modifier,
            LineInfo location,
            StringTable stringTable)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(callSignature != null);
            Contract.Requires(body != null);
            Contract.Requires(captures >= 0);
            Contract.Requires(locals >= 0);

            Name          = name;
            CallSignature = callSignature;
            Body          = body;
            Captures      = captures;
            Locals        = locals;

            var fullName = @namespace.ToList();

            fullName.Add(name);
            Statistic = new FunctionStatistic(fullName, callSignature, stringTable);
        }
Exemplo n.º 3
0
        public static string ToDisplayModifier(this DeclarationFlags flags)
        {
            string result = string.Empty;

            if ((flags & DeclarationFlags.Public) == DeclarationFlags.Public)
            {
                result += "public";
            }
            else if ((flags & DeclarationFlags.Export) == DeclarationFlags.Export)
            {
                result += "internal";
            }

            if ((flags & DeclarationFlags.Obsolete) == DeclarationFlags.Obsolete)
            {
                if (string.IsNullOrEmpty(result))
                {
                    result += "obsolete";
                }
                else
                {
                    result += ".obsolete";
                }
            }

            return(result);
        }
Exemplo n.º 4
0
 protected Declaration(string name, bool merge, string parentPropertyToAddTo)
 {
     this.name = name;
     if (merge)
     {
         this.flags |= DeclarationFlags.Merge;
     }
     this.parentPropertyToAddTo = parentPropertyToAddTo;
 }
Exemplo n.º 5
0
        public static string GetModifierAsSuffix(this DeclarationFlags flags)
        {
            var modifier = flags.ToDisplayModifier();

            if (!string.IsNullOrEmpty(modifier))
            {
                return(string.Concat(".", modifier));
            }

            return(modifier);
        }
Exemplo n.º 6
0
        /// <nodoc />
        public EnumMemberDeclaration(SymbolAtom name, Expression expression, DeclarationFlags modifier, IReadOnlyList <Expression> decorators, LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(decorators != null);
            Contract.RequiresForAll(decorators, d => d != null);

            Name       = name;
            Expression = expression;
            Decorators = decorators;
        }
Exemplo n.º 7
0
        /// <nodoc />
        protected ImportOrExportDeclaration(
            ImportOrExportClause importOrExportClause,
            Expression pathSpecifier,
            DeclarationFlags modifier,
            LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(importOrExportClause != null);

            ImportOrExportClause = importOrExportClause;
            PathSpecifier        = pathSpecifier;
        }
Exemplo n.º 8
0
        /// <nodoc />
        public VarDeclaration(
            SymbolAtom name,
            Type type,
            Expression initializer,
            DeclarationFlags modifier,
            LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);

            Name        = name;
            Type        = type;
            Initializer = initializer;
        }
Exemplo n.º 9
0
        /// <nodoc />
        public EnumDeclaration(
            SymbolAtom name,
            IReadOnlyList <EnumMemberDeclaration> enumMemberDeclarations,
            IReadOnlyList <Expression> decorators,
            DeclarationFlags modifier,
            LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(enumMemberDeclarations != null);
            Contract.RequiresForAll(enumMemberDeclarations, e => e != null);
            Contract.Requires(decorators != null);
            Contract.RequiresForAll(decorators, e => e != null);

            Name = name;
            EnumMemberDeclarations = enumMemberDeclarations;
            Decorators             = decorators;
        }
Exemplo n.º 10
0
        private void AnalyzeInterfaceMembers(NodeArray <ITypeElement> elements, bool registerPropertyNames)
        {
            foreach (var interfaceMember in elements.AsStructEnumerable())
            {
                var property = interfaceMember.As <IPropertySignature>();
                if (property != null)
                {
                    if (registerPropertyNames)
                    {
                        // Registering property name
                        bool             isOptional = property.QuestionToken.HasValue;
                        DeclarationFlags modifiers  = GetModifiers(property, isOptional);
                        AddOrCreateDeclarationSymbol(SymbolKind.InterfaceMemberDeclaration, property.Name.Text, modifiers);
                    }

                    // Registering property type
                    AnalyzeTypeReference(property.Type);

                    AnalyzeDecorators(interfaceMember);
                }

                var method = interfaceMember.As <IMethodSignature>();
                if (method != null)
                {
                    if (registerPropertyNames)
                    {
                        // Registering method name
                        var typeElement = method.TryCast <ITypeElement>();
                        if (typeElement != null)
                        {
                            bool             isOptional = typeElement.QuestionToken.HasValue;
                            DeclarationFlags modifiers  = GetModifiers(property, isOptional);
                            AddOrCreateDeclarationSymbol(SymbolKind.InterfaceMemberDeclaration, method.Name.Text, modifiers);
                        }
                    }

                    AnalyzeTypeParameters(method.TypeParameters);

                    AnalyzeDecorators(method);
                }
            }
        }
Exemplo n.º 11
0
        /// <nodoc />
        public TypeAliasDeclaration(SymbolAtom name, IReadOnlyList <TypeParameter> typeParameters, Type type, DeclarationFlags modifier, LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(type != null);
            Contract.Requires(typeParameters != null);

            Name           = name;
            Type           = type;
            TypeParameters = typeParameters;
        }
Exemplo n.º 12
0
        /// <nodoc />
        public ModuleDeclaration(SymbolAtom name, IReadOnlyList <Declaration> declarations, DeclarationFlags modifier, LineInfo location)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(declarations != null);
            Contract.RequiresForAll(declarations, d => d != null);

            Name         = name;
            Declarations = declarations;
        }
Exemplo n.º 13
0
        /// <nodoc/>
        public ImportDeclaration(ImportOrExportClause importOrExportClause, Expression pathSpecifier, Expression qualifier, IReadOnlyList <Expression> decorators, DeclarationFlags modifier, LineInfo location)
            : base(importOrExportClause, pathSpecifier, modifier, location)
        {
            Contract.Requires(importOrExportClause != null);
            Contract.Requires(pathSpecifier != null);
            Contract.Requires(decorators != null);
            Contract.RequiresForAll(decorators, d => d != null);

            Qualifier  = qualifier;
            Decorators = decorators;
        }
Exemplo n.º 14
0
        private void AnalyzeTopLevelVariableDeclarations(IVariableDeclarationList source, DeclarationFlags modifiers, int idx)
        {
            foreach (var declaration in source.Declarations.AsStructEnumerable())
            {
                if (modifiers == DeclarationFlags.None)
                {
                    AddOrCreateReferencedSymbol(SymbolKind.VariableDeclaration, declaration.Name.GetText(), modifiers);
                }
                else
                {
                    AddOrCreateDeclarationSymbol(SymbolKind.VariableDeclaration, declaration.Name.GetText(), modifiers);
                }

                if (declaration.Initializer != null)
                {
                    AnalyzeExpression(declaration.Initializer, idx, saveIdentifierOnStack: false);
                }

                AnalyzeTypeReference(declaration.Type);
            }
        }
Exemplo n.º 15
0
 /// <nodoc />
 protected Declaration(DeserializationContext context, LineInfo location)
     : base(location)
 {
     Modifier = ReadModifier(context.Reader);
 }
Exemplo n.º 16
0
 /// <nodoc />
 protected Declaration(DeclarationFlags modifier, LineInfo location)
     : base(location)
 {
     Modifier = modifier;
 }