public void ToCanonical_FullName() { var native = AstName.ParseFullName("NameSpace.Symbol%1"); var uot = native.ToCanonical(); Assert(uot, "Namespace", "Symbol", AstNameKind.Canonical, 2, "%1", "", 1); }
public void AddAlias(AstName symbolName, string alias) { var symbol = SymbolTable.FindSymbol(symbolName, AstSymbolKind.Unknown); Ast.Guard(symbol, $"No symbol for '{symbol}' was found in external module {Identifier.NativeFullName}."); symbol !.TryAddAlias(alias); }
public AstModuleExternal(AstName moduleName, AstSymbolTable?parentTable = null) : base(AstModuleLocality.External) { var symbolName = new AstSymbolName(moduleName); SymbolTable = new AstSymbolTable(symbolName.CanonicalName.FullName, parentTable); this.SetIdentifier(new AstIdentifier(symbolName, AstIdentifierKind.Module)); }
public AstModuleExternal LoadExact(string fullModuleName) { var mod = Modules.FirstOrDefault(m => m.Identifier.NativeFullName == fullModuleName); if (mod is null) { var name = AstName.ParseFullName(fullModuleName); mod = new AstModuleExternal(name, SymbolTable); Modules.Add(mod); } return(mod); }
private static void Assert(AstName uot, string ns, string symbol, AstNameKind kind, int partCount, string postfix = "", string prefix = "", int paramCount = 0) { uot.Should().NotBeNull(); uot.Kind.Should().Be(kind); uot.Namespace.Should().Be(ns); uot.Symbol.Should().Be(symbol); uot.Parts.Count().Should().Be(partCount); uot.Postfix.Should().Be(postfix); uot.Prefix.Should().Be(prefix); uot.ParameterCount.Should().Be(paramCount); }
public void GetArgumentCount_Reference() { var uot = AstName.FromExternal("Root.Namespace", "Generic;U8;U16"); Assert(uot, "Root.Namespace", "Generic", AstNameKind.External, 3, ";U8;U16", "", 2); }
public void GetArgumentCount_Defintion() { var uot = AstName.FromExternal("Root.Namespace", "Generic`3"); Assert(uot, "Root.Namespace", "Generic", AstNameKind.External, 3, "%3", "", 3); }
public void ParseFunctionTypeName_FullReturnType() { var uot = AstName.CreateUnparsed("(Str): Namespace.Symbol"); Assert(uot, "", "(Str): Namespace.Symbol", AstNameKind.Local, 1); }
public void Parse_Symbol() { var uot = AstName.ParseFullName("Symbol"); Assert(uot, "", "Symbol", AstNameKind.Local, 1); }
public void Parse_FullName() { var uot = AstName.ParseFullName("Root.Namespace.Symbol"); Assert(uot, "Root.Namespace", "Symbol", AstNameKind.Local, 3); }
public void FromCanonical_DotName() { var uot = AstName.FromLocal("Symbol.Field"); Assert(uot, "", "Symbol.Field", AstNameKind.Local, 1); }
public void FromExternal_Prefix() { var uot = AstName.FromExternal("Root.Namespace", "get_Property"); Assert(uot, "Root.Namespace", "Property", AstNameKind.External, 3, "", "get_"); }
public void FromExternal_DotName() { var uot = AstName.FromExternal("Root.Namespace", "Symbol.Field"); Assert(uot, "Root.Namespace", "Symbol.Field", AstNameKind.External, 3); }