Exemplo n.º 1
0
    public void Print(OutputContext output, bool forceParens = false)
    {
        output.PushNode(this);
        if (this is AstToplevel)
        {
            output.AddMapping(null, new Position(), true);
        }
        else
        {
            output.AddMapping(Source, Start, true);
        }

        if (forceParens || NeedParens(output))
        {
            output.Print("(");
            CodeGen(output);
            output.Print(")");
        }
        else
        {
            CodeGen(output);
        }

        output.PopNode();
    }
Exemplo n.º 2
0
    public override void CodeGen(OutputContext output)
    {
        Expression.Print(output);
        if (this is AstNew && !output.NeedConstructorParens(this))
        {
            return;
        }
        if (Expression is AstCall or AstLambda)
        {
            output.AddMapping(Expression.Source, Start, false);
        }

        if (Optional)
        {
            output.Print("?.");
        }
        output.Print("(");
        for (var i = 0u; i < Args.Count; i++)
        {
            if (i > 0)
            {
                output.Comma();
            }
            Args[i].Print(output);
        }

        output.Print(")");
    }
Exemplo n.º 3
0
        public override void CodeGen(OutputContext output)
        {
            Expression.Print(output, Expression is AstBinary && output.NeedNodeParens(Expression));
            if (output.NeedDotAfterNumber())
            {
                output.Print(".");
            }

            output.AddMapping(Expression.Source, Expression.End, false);
            output.Print(".");
            output.Print((string)Property);
        }
Exemplo n.º 4
0
        public override void CodeGen(OutputContext output)
        {
            Expression.Print(output);
            if (output.NeedDotAfterNumber())
            {
                output.Print(".");
            }

            output.Print(".");
            // the name after dot would be mapped about here.
            output.AddMapping(End);
            output.Print((string)Property);
        }
Exemplo n.º 5
0
        public void Print(OutputContext output, bool forceParens = false)
        {
            output.PushNode(this);
            output.AddMapping(Source, Start, true);
            if (forceParens || !output.HasParens() && NeedParens(output))
            {
                output.Print("(");
                CodeGen(output);
                output.Print(")");
            }
            else
            {
                CodeGen(output);
            }

            output.PopNode();
        }