Esempio n. 1
0
 /// <summary>
 /// Called when visiting a <see cref="ModuleSymbol" />; Override this method with specific
 /// implementation; Calling default <see cref="DefaultVisit" /> if it's not overridden
 /// </summary>
 /// <param name="symbol">The visited symbol</param>
 /// <param name="argument">Additional argument</param>
 /// <returns></returns>
 public virtual TResult VisitModule(ModuleSymbol symbol, TArgument argument)
 {
     return(DefaultVisit(symbol, argument));
 }
Esempio n. 2
0
        /// <summary>
        /// Lookup declaration for predefined symbol in this Assembly.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public override Symbol GetDeclaredSpecialSymbol(object key)
        {
#if DEBUG
            foreach (var module in this.Modules)
            {
                Debug.Assert(module.ReferencedAssemblies.Length == 0);
            }
#endif

            MetadataTypeName emittedName = default;
            Symbol           result      = null;
            if (_lazySpecialSymbols == null || !_lazySpecialSymbols.ContainsKey(key))
            {
                ModuleSymbol firstModule = this.Modules[0];
                if (key is SpecialType)
                {
                    emittedName = MetadataTypeName.FromFullName(((SpecialType)key).GetMetadataName(), useCLSCompliantNameArityEncoding: true);
                    result      = firstModule.LookupTopLevelMetadataType(ref emittedName);
                    if (result.Kind == LanguageSymbolKind.ErrorType || result.DeclaredAccessibility != Accessibility.Public)
                    {
                        result = null;
                    }
                }
                else if (key is IModelObject metaSymbol)
                {
                    foreach (var module in this.Modules)
                    {
                        if (module.TryGetSymbol(metaSymbol, out Symbol symbol))
                        {
                            result = symbol;
                            break;
                        }
                    }
                }
                if (result == null)
                {
                    foreach (var module in this.Modules)
                    {
                        var symbol = this.Language.CompilationFactory.CreateSpecialSymbol(module, key);
                        if (symbol != null)
                        {
                            result = symbol;
                            break;
                        }
                    }
                }
                if (result == null || (result.Kind != LanguageSymbolKind.ErrorType && result.DeclaredAccessibility != Accessibility.Public))
                {
                    if (key is SpecialType)
                    {
                        result = new MissingMetadataTypeSymbol.TopLevel(firstModule, ref emittedName, (SpecialType)key);
                    }
                    else
                    {
                        result = new MissingMetadataTypeSymbol.TopLevel(firstModule, string.Empty, key.ToString(), 0, false);
                    }
                }
                RegisterDeclaredSpecialSymbol(key, ref result);
            }

            return(_lazySpecialSymbols[key]);
        }
Esempio n. 3
0
 public TopLevelWithCustomErrorInfo(ModuleSymbol module, ref MetadataTypeName emittedName, DiagnosticInfo errorInfo, WellKnownType typeId)
     : base(module, ref emittedName, typeId)
 {
     Debug.Assert(errorInfo != null);
     _errorInfo = errorInfo;
 }
Esempio n. 4
0
 private TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, int typeId)
     : this(module, ref fullName, fullName.ForcedArity == -1 || fullName.ForcedArity == fullName.InferredArity)
 {
     Debug.Assert(typeId == -1 || typeId == (int)SpecialType.None || Arity == 0 || MangleName);
     _lazyTypeId = typeId;
 }
Esempio n. 5
0
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, WellKnownType wellKnownType)
     : this(module, ref fullName, (int)wellKnownType)
 {
 }
Esempio n. 6
0
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName, SpecialType specialType)
     : this(module, ref fullName, (int)specialType)
 {
 }
Esempio n. 7
0
 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName)
     : this(module, ref fullName, -1)
 {
 }