Example #1
0
        /// <inheritdoc />
        internal override void AddType(FullSymbol name, UniversalLocation location, QualifierSpaceId?qualifierSpaceId, out TypeOrNamespaceModuleLiteral module)
        {
            module = CreateTypeOrNamespaceModule(name, outerScope: this, location: location.AsLineInfo());

            Contract.Assert(qualifierSpaceId == null, "Only namespace support qualifier types");

            AddResolvedEntry(location.AsFilePosition(), new ResolvedEntry(name, module));
        }
Example #2
0
        /// <inheritdoc />
        internal override void AddNamespace(FullSymbol name, UniversalLocation location, QualifierSpaceId?qualifierSpaceId, out TypeOrNamespaceModuleLiteral module)
        {
            module = CreateTypeOrNamespaceModule(name, outerScope: this, location: location.AsLineInfo());

            Contract.Assert(qualifierSpaceId != null, "Qualifier type should be provided for a semantic evaluation");
            m_moduleRegistry.AddUninstantiatedModuleInfo(new UninstantiatedModuleInfo(sourceFile: null, typeOrNamespaceLiteral: module, qualifierSpaceId: qualifierSpaceId.Value));

            AddResolvedEntry(location.AsFilePosition(), new ResolvedEntry(name, module));
        }
Example #3
0
        /// <summary>
        /// Adds a namespace with a given name.
        /// </summary>
        internal virtual void AddNamespace(FullSymbol name, UniversalLocation location, QualifierSpaceId?qualifierSpaceId, out TypeOrNamespaceModuleLiteral module)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(Qualifier == QualifierValue.Unqualified);
            Contract.Assert(IsFileOrGlobal, "Current instance should be a file module or global ambient module");

            lock (m_syncRoot)
            {
                m_nsBindings = m_nsBindings ?? new NsBindingDictionary();

                if (m_nsBindings.ContainsKey(name))
                {
                    var moduleBinding = m_nsBindings[name];
                    Contract.Assert(moduleBinding.Body is TypeOrNamespaceModuleLiteral);

                    module = (TypeOrNamespaceModuleLiteral)moduleBinding.Body;
                    return;
                }

                module = CreateTypeOrNamespaceModule(name, outerScope: this, location: location.AsLineInfo());

                // Module is always exported.
                m_nsBindings.Add(name, new ModuleBinding(module, Declaration.DeclarationFlags.Export, location.AsLineInfo()));
            }
        }