public void constructorTest_withKindAndUri(NamespaceKind kind, string uri) { var ns = new Namespace(kind, uri); Assert.Equal(kind, ns.kind); Assert.Equal(uri, ns.uri); }
internal void Set(string prefix, string namespaceUri, NamespaceKind kind) { this.prefix = prefix; this.namespaceUri = namespaceUri; this.kind = kind; this.prevNsIndex = -1; }
internal SymbolInfo( ISymbol?symbol, ImmutableArray <ISymbol> candidateSymbols, CandidateReason candidateReason ) : this() { this.Symbol = symbol; _candidateSymbols = candidateSymbols.IsDefault ? ImmutableArray.Create <ISymbol>() : candidateSymbols; #if DEBUG const NamespaceKind NamespaceKindNamespaceGroup = (NamespaceKind)0; Debug.Assert( symbol is null || symbol.Kind != SymbolKind.Namespace || ((INamespaceSymbol)symbol).NamespaceKind != NamespaceKindNamespaceGroup ); foreach (var item in _candidateSymbols) { Debug.Assert( item.Kind != SymbolKind.Namespace || ((INamespaceSymbol)item).NamespaceKind != NamespaceKindNamespaceGroup ); } #endif this.CandidateReason = candidateReason; }
internal void Set(string prefix, string namespaceUri, NamespaceKind kind) { this.prefix = prefix; this.namespaceUri = namespaceUri; this.kind = kind; this.prevNsIndex = -1; }
private static AbcConstKind ToAbc(NamespaceKind value) { switch (value) { case NamespaceKind.Package: return(AbcConstKind.PackageNamespace); case NamespaceKind.Public: return(AbcConstKind.PublicNamespace); case NamespaceKind.Protected: return(AbcConstKind.ProtectedNamespace); case NamespaceKind.Private: return(AbcConstKind.PrivateNamespace); case NamespaceKind.Internal: return(AbcConstKind.InternalNamespace); case NamespaceKind.Explicit: return(AbcConstKind.ExplicitNamespace); case NamespaceKind.StaticProtected: return(AbcConstKind.StaticProtectedNamespace); default: throw new ArgumentOutOfRangeException("value"); } }
public ASNamespace(ASConstantPool pool, FlashReader input) : base(pool) { Kind = (NamespaceKind)input.ReadByte(); if (!Enum.IsDefined(typeof(NamespaceKind), Kind)) { throw new InvalidCastException($"Invalid namespace kind for value {Kind:0x00}."); } NameIndex = input.ReadInt30(); }
internal SymbolInfo(ISymbol symbol, ISymbol[] candidateSymbols, CandidateReason candidateReason) : this() { this.Symbol = symbol; _candidateSymbols = candidateSymbols == null ? new ISymbol[0] : candidateSymbols; #if DEBUG const NamespaceKind NamespaceKindNamespaceGroup = (NamespaceKind)0; Debug.Assert((object)symbol == null || symbol.Kind != SymbolKind.Namespace || ((INamespaceSymbol)symbol).NamespaceKind != NamespaceKindNamespaceGroup); foreach (var item in _candidateSymbols) { Debug.Assert(item.Kind != SymbolKind.Namespace || ((INamespaceSymbol)item).NamespaceKind != NamespaceKindNamespaceGroup); } #endif this.CandidateReason = candidateReason; }
/// <summary> /// Immutable namespace object. Please consider using AbcCode.CreateNamespace, which will /// keep things in their right place. /// </summary> /// <param name="kind">The kind of namespace</param> /// <param name="name">The namespace name. If this contains a prefix, it will be stripped off, /// e.g. myfile_fla:MainTimeline will become MainTimeline</param> /// <param name="prefix">A new prefix for the name</param> internal Namespace(NamespaceKind kind, string name, string prefix) { this.Kind = kind; if (prefix == null) { this.Name = name; } else { int pos = name.IndexOf(':'); if (pos >= 0) { name = name.Substring(pos); } this.Name = prefix + name; } }
/// <summary> /// Immutable namespace object. Please consider using AbcCode.CreateNamespace, which will /// keep things in their right place. /// </summary> /// <param name="kind">The kind of namespace</param> /// <param name="name">The namespace name. If this contains a prefix, it will be stripped off, /// e.g. myfile_fla:MainTimeline will become MainTimeline</param> /// <param name="prefix">A new prefix for the name</param> internal Namespace(NamespaceKind kind, string name, string prefix) { this.Kind = kind; if (prefix == null) { this.Name = name; } else { int pos = name.IndexOf(':'); if (pos >= 0) { name = name.Substring(pos); } this.Name = prefix + name; } }
/// <summary> /// Creates a new non-private namespace with the given type and name. /// </summary> /// /// <param name="kind"> /// The kind of namespace to create. This cannot be /// <see cref="NamespaceKind.PRIVATE" qualifyHint="true"/>. (To create a private namespace, use /// the <see cref="Namespace.createPrivate()" qualifyHint="true"/> method), or /// <see cref="NamespaceKind.ANY" qualifyHint="true"/> (which is reserved for the "any" /// namespace). /// </param> /// <param name="uri">The name or URI of the namespace.</param> /// /// <exception cref="AVM2Exception"> /// <list type="bullet"> /// <item> /// <description>ArgumentError #10013: The <paramref name="kind"/> argument is /// <see cref="NamespaceKind.PRIVATE" qualifyHint="true"/>.</description> /// </item> /// <item> /// <description>ArgumentError #10014: The <paramref name="kind"/> argument is /// <see cref="NamespaceKind.ANY" qualifyHint="true"/>.</description> /// </item> /// <item> /// <description>ArgumentError #10016: The <paramref name="kind"/> argument is not a valid value of the /// <see cref="NamespaceKind"/> enumeration.</description> /// </item> /// <item><description>ArgumentError #10017: The <paramref name="uri"/> argument is null.</description></item> /// </list> /// </exception> public Namespace(NamespaceKind kind, string uri) { if (kind == NamespaceKind.PRIVATE) { throw ErrorHelper.createError(ErrorCode.MARIANA__NAMESPACE_CTOR_PRIVATE); } if (kind == NamespaceKind.ANY) { throw ErrorHelper.createError(ErrorCode.MARIANA__NAMESPACE_CTOR_ANY); } if ((uint)kind > (uint)NamespaceKind.PRIVATE) { throw ErrorHelper.createError(ErrorCode.MARIANA__INVALID_NS_CATEGORY, (int)kind); } if (uri == null) { throw ErrorHelper.createError(ErrorCode.MARIANA__NAMESPACE_NULL_NAME); } this.uri = uri; this.m_kindAndId = (uint)kind; }
public string CSharpName(MetaNamespace mnamespace, NamespaceKind kind = NamespaceKind.Public, bool fullName = false) { if (mnamespace == null) { return(string.Empty); } if (!fullName) { return(mnamespace.Name); } string result = string.Empty; MetaNamespace currentNs = mnamespace; while (currentNs != null) { if (!string.IsNullOrEmpty(currentNs.Name)) { if (!string.IsNullOrEmpty(result)) { result = "." + result; } result = currentNs.Name + result; } currentNs = currentNs.Namespace; } switch (kind) { case NamespaceKind.Internal: result = result + ".Internal"; break; default: break; } return(result); }
/// <summary> /// Create a NamespaceExtent that represents a given Compilation. /// </summary> internal NamespaceExtent(CSharpCompilation compilation) { this.kind = NamespaceKind.Compilation; this.symbolOrCompilation = compilation; }
public void HandleKindHidesSpecialStringAndNamespaces() { foreach (uint virtualBit in new[] { 0U, TokenTypeIds.VirtualTokenMask }) { uint invalidStringTypeCount = 0; uint invalidNamespaceTypeCount = 0; for (uint i = 0; i <= sbyte.MaxValue; i++) { Handle handle = new Handle(virtualBit | i << TokenTypeIds.RowIdBitCount); Assert.True(handle.IsNil ^ handle.IsVirtual); Assert.Equal(virtualBit != 0, handle.IsVirtual); Assert.Equal(handle.TokenType, i << TokenTypeIds.RowIdBitCount); switch (i) { // String and namespace have two extra bits to represent their kind that are hidden from the handle type case (uint)HandleKind.String: case (uint)HandleKind.String + 1: case (uint)HandleKind.String + 2: case (uint)HandleKind.String + 3: Assert.Equal(HandleKind.String, handle.Kind); StringKind stringType = (StringKind)(i - (int)HandleKind.String); StringHandle stringHandle; try { stringHandle = (StringHandle)handle; } catch (InvalidCastException) { Assert.True(handle.TokenType > TokenTypeIds.MaxString); invalidStringTypeCount++; break; } Assert.Equal(stringType, stringHandle.StringKind); break; case (uint)HandleKind.NamespaceDefinition: case (uint)HandleKind.NamespaceDefinition + 1: case (uint)HandleKind.NamespaceDefinition + 2: case (uint)HandleKind.NamespaceDefinition + 3: Assert.Equal(HandleKind.NamespaceDefinition, handle.Kind); NamespaceKind namespaceType = (NamespaceKind)(i - (int)HandleKind.NamespaceDefinition); NamespaceDefinitionHandle namespaceHandle; try { namespaceHandle = (NamespaceDefinitionHandle)handle; } catch (InvalidCastException) { Assert.True(handle.TokenType > TokenTypeIds.MaxNamespace); invalidNamespaceTypeCount++; break; } Assert.Equal(namespaceType, namespaceHandle.NamespaceKind); break; // all other types surface token type directly. default: Assert.Equal((uint)handle.Kind, i); break; } } Assert.Equal((uint)((TokenTypeIds.String | TokenTypeIds.StringOrNamespaceKindMask) - TokenTypeIds.MaxString) >> TokenTypeIds.RowIdBitCount, invalidStringTypeCount); Assert.Equal((uint)((TokenTypeIds.Namespace | TokenTypeIds.StringOrNamespaceKindMask) - TokenTypeIds.MaxNamespace) >> TokenTypeIds.RowIdBitCount, invalidNamespaceTypeCount); } }
internal void constructorTest_withInvalidKind(NamespaceKind kind, string uri, ErrorCode errCode) { var exc = Assert.Throws <AVM2Exception>(() => new Namespace(kind, uri)); Assert.Equal(errCode, (ErrorCode)((ASError)exc.thrownValue).errorID); }
public QNameAttribute(string ns, string name, NamespaceKind kind) { Value = new QName(name, new Namespace(ns, kind)); }
/// <summary> /// Create a NamespaceExtent that represents a given Compilation. /// </summary> internal NamespaceExtent(LanguageCompilation compilation) { _kind = NamespaceKind.Compilation; _symbolOrCompilation = compilation; }
/// <summary> /// Returns true if the namespace set contains a namespace of the given kind. /// </summary> /// <param name="kind">The namespace kind to check.</param> /// <returns>True if the namespace set contains a namespace of the kind /// <paramref name="kind"/>, otherwise false.</returns> public bool contains(NamespaceKind kind) => (m_flags & (1 << (int)kind)) != 0;
/// <summary> /// /// </summary> public Namespace_info() { _Kind = NamespaceKind.Namespace; _Name = 0; }
/// <summary> /// /// </summary> /// <param name="source"></param> public void Parse(Stream source) { BinaryReader br = new BinaryReader(source); byte kindId = br.ReadByte(); if (!Enum.IsDefined(typeof(NamespaceKind), kindId)) { AbcFormatException fe = new AbcFormatException("Namespace kind 0x" + kindId.ToString("X2") + " is undefined"); Log.Error(this, fe); throw fe; } _Kind = (NamespaceKind)kindId; _Name = VariableLengthInteger.ReadU30(source); }
/// <summary> /// Create a NamespaceExtent that represents a given ModuleSymbol. /// </summary> internal NamespaceExtent(ModuleSymbol module) { this.kind = NamespaceKind.Module; this.symbolOrCompilation = module; }
/// <summary> /// Create a NamespaceExtent that represents a given AssemblySymbol. /// </summary> internal NamespaceExtent(AssemblySymbol assembly) { this.kind = NamespaceKind.Assembly; this.symbolOrCompilation = assembly; }
public Namespace(string name, NamespaceKind kind) { Name = name ?? ""; Kind = kind; }
/// <summary> /// Immutable namespace object. Please consider using AbcCode.CreateNamespace, which will /// keep things in their right place. /// </summary> /// <param name="kind">The kind of namespace</param> /// <param name="name">The namespace name</param> internal Namespace(NamespaceKind kind, string name) : this(kind, name, null) { }
private void AddNamespace(string prefix, string ns, NamespaceKind kind) { int length = ++this.nsTop; if (length == this.nsStack.Length) { Namespace[] destinationArray = new Namespace[length * 2]; Array.Copy(this.nsStack, destinationArray, length); this.nsStack = destinationArray; } this.nsStack[length].Set(prefix, ns, kind); if (this.useNsHashtable) { this.AddToNamespaceHashtable(this.nsTop); } else if (this.nsTop == 0x10) { this.nsHashtable = new Dictionary<string, int>(this.hasher); for (int i = 0; i <= this.nsTop; i++) { this.AddToNamespaceHashtable(i); } this.useNsHashtable = true; } }
private void AddNamespace(string prefix, string ns, NamespaceKind kind) { int top = ++_nsTop; if (top == _nsStack.Length) { Namespace[] newStack = new Namespace[top * 2]; Array.Copy(_nsStack, 0, newStack, 0, top); _nsStack = newStack; } _nsStack[top].Set(prefix, ns, kind); if (_useNsHashtable) { // add last AddToNamespaceHashtable(_nsTop); } else if (_nsTop == MaxNamespacesWalkCount) { // add all _nsHashtable = new Dictionary<string, int>(_hasher); for (int i = 0; i <= _nsTop; i++) { AddToNamespaceHashtable(i); } _useNsHashtable = true; } }
/// <summary> /// Immutable namespace object. Please consider using AbcCode.CreateNamespace, which will /// keep things in their right place. /// </summary> /// <param name="kind">The kind of namespace</param> /// <param name="name">The namespace name</param> internal Namespace(NamespaceKind kind, string name) : this(kind, name, null) { }
internal void constructorTest_withKindAndNullUri(NamespaceKind kind, string uri) { AssertHelper.throwsErrorWithCode(ErrorCode.MARIANA__NAMESPACE_NULL_NAME, () => new Namespace(kind, uri)); }
public NamespaceInfo(NamespaceKind kind, StringInfo name) { Kind = kind; Name = name; }