Пример #1
0
 public AstImport(string?source, Position startLoc, Position endLoc, AstString moduleName,
                  AstSymbolImport?importName, ref StructList <AstNameMapping> specifiers) : base(source, startLoc, endLoc)
 {
     ModuleName   = moduleName;
     ImportedName = importName;
     ImportedNames.TransferFrom(ref specifiers);
 }
Пример #2
0
    public override void CodeGen(OutputContext output)
    {
        string GetName(AstSymbol symbol)
        {
            return(symbol.Thedef?.MangledName ?? symbol.Thedef?.Name ?? symbol.Name);
        }

        var allowShortHand = output.Options.Ecma >= 6;
        var keyString      = Key switch
        {
            AstString str => str.Value,
            AstNumber num => num.Value.ToString("R", CultureInfo.InvariantCulture),
            AstSymbolRef _ => null,
            AstSymbol key => GetName(key),
            _ => null
        };

        if (allowShortHand &&
            Value is AstSymbol value && keyString != null &&
            GetName(value) == keyString &&
            OutputContext.IsIdentifierString(keyString) &&
            OutputContext.IsIdentifier(keyString)
            )
        {
            output.PrintPropertyName(keyString);
        }
Пример #3
0
        public void VisitString(AstString ast)
        {
            Assert.IsType <AstString>(this.expected);
            var expectedAst = (AstString)this.expected;

            Assert.Equal(expectedAst.Value, ast.Value);
        }
Пример #4
0
 public override void Transform(TreeTransformer tt)
 {
     base.Transform(tt);
     ModuleName = (AstString)tt.Transform(ModuleName);
     if (ImportedName != null)
     {
         ImportedName = (AstSymbolImport)tt.Transform(ImportedName);
     }
     tt.TransformList(ref ImportedNames);
 }
Пример #5
0
    protected void PrintGetterSetter(OutputContext output, string?type, bool @static)
    {
        if (@static)
        {
            output.Print("static");
            output.Space();
        }

        if (type != null)
        {
            output.Print(type);
            output.Space();
        }

        var keyString = Key switch
        {
            AstString str => str.Value,
            AstNumber num => num.Value.ToString("R", CultureInfo.InvariantCulture),
            AstSymbolRef => null,
            AstSymbol key => key.Name,
            _ => null
        };

        if (keyString != null)
        {
            output.PrintPropertyName(keyString);
        }
        else
        {
            output.Print("[");
            Key.Print(output);
            output.Print("]");
        }

        ((AstLambda)Value).DoPrint(output, true);
    }
}
Пример #6
0
 AstImport(string?source, Position startLoc, Position endLoc, AstString moduleName,
           AstSymbolImport?importName) : base(source, startLoc, endLoc)
 {
     ModuleName   = moduleName;
     ImportedName = importName;
 }
Пример #7
0
 public void VisitString(AstString ast) => IncrementCallCount(nameof(VisitString));
        public static TrsString Convert(this AstString astIn)
        {
            var token = astIn.StringContent;

            return(new TrsString(token.TokenString, astIn));
        }
        public SemanticAtom Visit(AstString n)
        {
            var t = new UtilizedType(Primitive.String.Name, n.Location);

            return(t);
        }
Пример #10
0
 public void Visit(AstString n)
 {
     throw new NotImplementedException();
 }
Пример #11
0
 public TrsString(string value, AstString source)
 {
     Value     = value;
     AstSource = source;
 }
Пример #12
0
 public void Visit(AstString n)
 {
     Helpers.WriteColor("String", ConsoleColor.DarkCyan, ConsoleColor.Black);
 }
Пример #13
0
 public void Visit(AstString n)
 {
     Helpers.WriteLine($"{_tab}{n.Text} [{n.Location.StartLine}, {n.Location.StartColumn}]");
 }
 public SemanticAtom Visit(AstString n)
 {
     return(Primitive.String);
 }