From ca124ea3a659cc057d35712e5d9b4160824224af Mon Sep 17 00:00:00 2001 From: joeduffy Date: Mon, 2 Jan 2017 16:44:51 -0800 Subject: [PATCH] Add more AST lowerings for trivial kinds This includes AST lowering for DebuggerStatements and ConditionalExpressions, both of which are straightforward boilerplate mappings. --- tools/mujs/lib/compiler/transform.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/mujs/lib/compiler/transform.ts b/tools/mujs/lib/compiler/transform.ts index 3583d9f76..6e60c519b 100644 --- a/tools/mujs/lib/compiler/transform.ts +++ b/tools/mujs/lib/compiler/transform.ts @@ -392,7 +392,11 @@ function transformBlock(node: ts.Block): ast.Block { } function transformDebuggerStatement(node: ts.DebuggerStatement): ast.Statement { - return contract.failf("NYI"); + // The debugger statement in ECMAScript can be used to trip a breakpoint. We don't have the equivalent in Mu at + // the moment, so we simply produce an empty statement in its place. + return copyLocation(node, { + kind: ast.emptyStatementKind, + }); } function transformEmptyStatement(node: ts.EmptyStatement): ast.EmptyStatement { @@ -537,8 +541,13 @@ function transformClassExpression(node: ts.ClassExpression): ast.Expression { return contract.failf("NYI"); } -function transformConditionalExpression(node: ts.ConditionalExpression): ast.Expression { - return contract.failf("NYI"); +function transformConditionalExpression(node: ts.ConditionalExpression): ast.ConditionalExpression { + return copyLocation(node, { + kind: ast.conditionalExpressionKind, + condition: transformExpression(node.condition), + consequent: transformExpression(node.whenTrue), + alternate: transformExpression(node.whenFalse), + }); } function transformDeleteExpression(node: ts.DeleteExpression): ast.Expression {