public override void CodeGen(OutputContext output) { output.Print("catch"); if (Argname != null) { output.Space(); Argname.Print(output, true); } output.Space(); output.PrintBraced(this, false); }
void PrintArrowBody(OutputContext output) { if (Body.Count == 1) { var last = Body.Last; if (last.IsExpression()) { last.Print(output); return; } } output.PrintBraced(Body, false); }
public virtual void DoPrint(OutputContext output, bool noKeyword = false) { if (!noKeyword) { if (Async) { output.Print("async"); output.Space(); } output.Print("function"); if (IsGenerator) { output.Print("*"); } if (Name != null) { output.Space(); } } if (Name != null) { Name.Print(output); } else if (noKeyword && Name != null) { output.Print("["); Name.Print(output); // Computed method name output.Print("]"); } output.Print("("); for (var i = 0; i < ArgNames.Count; i++) { if (i > 0) { output.Comma(); } ArgNames[(uint)i].Print(output); } output.Print(")"); output.Space(); output.PrintBraced(this, HasUseStrictDirective); }
public override void CodeGen(OutputContext output) { output.Print("try"); output.Space(); output.PrintBraced(Body, false); if (Bcatch != null) { output.Space(); Bcatch.Print(output); } if (Bfinally != null) { output.Space(); Bfinally.Print(output); } }
public override void DoPrint(OutputContext output, bool nokeyword = false) { var parent = output.Parent(); var needsParens = parent is AstBinary || parent is AstUnary || (parent is AstCall call && this == call.Expression); if (needsParens) { output.Print("("); } if (Async) { output.Print("async"); output.Space(); } if (ArgNames.Count == 1 && ArgNames[0] is AstSymbol) { ArgNames[0].Print(output); } else { output.Print("("); for (var i = 0u; i < ArgNames.Count; i++) { if (i > 0) { output.Comma(); } ArgNames[i].Print(output); } output.Print(")"); } output.Space(); output.Print("=>"); output.Space(); output.PrintBraced(Body, false); if (needsParens) { output.Print(")"); } }
void PrintArrowBody(OutputContext output) { if (Body.Count == 1) { // We expect that only scope (function, class,...), simple statement, constants or array is valid expression // Invalid expressions are: AstBreak, AstCatch, AstConst, AstContinue, AstDwLoop, AstDebugger, // AstDefinitions, AstDo, AstEmptyStatement, AstExit, AstExport, AstFinally, AstFor, AstForIn, AstForOf, // AstIf, AstImport, AstIterationStatement, AstJump, AstLabeledStatement, AstLet, AstLoopControl, // AstReturn, AstStatementWithBody, AstSwitch, AstThrow, AstTry, AstVar, AstWhile, AstWith // At this level it should not be: AstAccessor, AstBlockStatement, AstCase, AstDefClass, AstDefault, // AstSwitchBranch, AstToplevel if (Body.Last is AstScope scope) { scope.CodeGen(output); return; } if (Body.Last is AstSimpleStatement simpleStatement) { simpleStatement.Body.Print(output); return; } if (Body.Last is AstConstant constant) { constant.CodeGen(output); return; } if (Body.Last is AstArray array) { array.CodeGen(output); return; } } output.PrintBraced(Body, false); }
public override void CodeGen(OutputContext output) { output.PrintBraced(this, false); }
public override void CodeGen(OutputContext output) { output.Print("finally"); output.Space(); output.PrintBraced(this, false); }