public void Print(OutputContext output, bool forceParens = false) { output.PushNode(this); if (forceParens || !output.HasParens() && NeedParens(output)) { output.Print("("); CodeGen(output); output.Print(")"); } else { CodeGen(output); } output.PopNode(); }
public override bool NeedParens(OutputContext output) { if (!output.HasParens() && output.FirstInStatement()) { return(true); } if (output.Options.Webkit) { var p = output.Parent(); if (p is AstPropAccess propAccess && propAccess.Expression == this) { return(true); } } if (output.Options.WrapIife) { var p = output.Parent(); return(p is AstCall call && call.Expression == this); } return(false); }
public override bool NeedParens(OutputContext output) { // object literal could need parens, because it would be interpreted as a block of code. return(!output.HasParens() && output.FirstInStatement()); }