From ec8b5f99da331001e4689604b0b80f62522401a3 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Tue, 4 Oct 2022 18:39:56 -0700 Subject: [PATCH] Interpreter: Add more detail for unsupported expressions --- .../serenityos/jakt/comptime/Interpreter.kt | 24 +++++++++---------- .../jakt/comptime/ShowComptimeValueAction.kt | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/org/serenityos/jakt/comptime/Interpreter.kt b/src/main/kotlin/org/serenityos/jakt/comptime/Interpreter.kt index 21d335d..56218c6 100644 --- a/src/main/kotlin/org/serenityos/jakt/comptime/Interpreter.kt +++ b/src/main/kotlin/org/serenityos/jakt/comptime/Interpreter.kt @@ -66,9 +66,9 @@ class Interpreter(element: JaktPsiElement) { return when (element) { /*** EXPRESSIONS ***/ - is JaktMatchExpression -> TODO() - is JaktTryExpression -> TODO() - is JaktLambdaExpression -> TODO() + is JaktMatchExpression -> TODO("comptime match expressions") + is JaktTryExpression -> TODO("comptime try expressions") + is JaktLambdaExpression -> TODO("comptime lambdas") is JaktAssignmentBinaryExpression -> { val binaryOp = when { element.plusEquals != null -> BinaryOperator.Add @@ -145,8 +145,8 @@ class Interpreter(element: JaktPsiElement) { ExecutionResult.Normal(VoidValue) } - is JaktThisExpression -> TODO() - is JaktFieldAccessExpression -> TODO() + is JaktThisExpression -> TODO("comptime this expressions") + is JaktFieldAccessExpression -> TODO("comptime field access") is JaktRangeExpression -> { val (startExpr, endExpr) = when { element.expressionList.size == 2 -> element.expressionList[0] to element.expressionList[1] @@ -229,9 +229,9 @@ class Interpreter(element: JaktPsiElement) { else -> BinaryOperator.Modulo }, ) - is JaktCastExpression -> TODO() - is JaktIsExpression -> TODO() - is JaktUnaryExpression -> TODO() + is JaktCastExpression -> TODO("comptime casts") + is JaktIsExpression -> TODO("comptime is expressions") + is JaktUnaryExpression -> TODO("comptime unary expressions") is JaktBooleanLiteral -> ExecutionResult.Normal(BoolValue(element.trueKeyword != null)) is JaktNumericLiteral -> { element.binaryLiteral?.let { @@ -424,9 +424,9 @@ class Interpreter(element: JaktPsiElement) { ExecutionResult.Normal(VoidValue) } - is JaktWhileStatement -> TODO() - is JaktLoopStatement -> TODO() - is JaktForStatement -> TODO() + is JaktWhileStatement -> TODO("comptime while statements") + is JaktLoopStatement -> TODO("comptime loop statements") + is JaktForStatement -> TODO("comptime for statements") is JaktVariableDeclarationStatement -> { if (element.parenOpen != null) { error( @@ -440,7 +440,7 @@ class Interpreter(element: JaktPsiElement) { ExecutionResult.Normal(VoidValue) } - is JaktGuardStatement -> TODO() + is JaktGuardStatement -> TODO("comptime guard statements") is JaktYieldStatement -> ExecutionResult.Yield(evaluateNonYield(element.expression) { return it }) is JaktBreakStatement -> ExecutionResult.Break is JaktContinueStatement -> ExecutionResult.Continue diff --git a/src/main/kotlin/org/serenityos/jakt/comptime/ShowComptimeValueAction.kt b/src/main/kotlin/org/serenityos/jakt/comptime/ShowComptimeValueAction.kt index cc34c95..addff86 100644 --- a/src/main/kotlin/org/serenityos/jakt/comptime/ShowComptimeValueAction.kt +++ b/src/main/kotlin/org/serenityos/jakt/comptime/ShowComptimeValueAction.kt @@ -60,7 +60,6 @@ class ShowComptimeValueAction : AnAction() { private val AnActionEvent.element: PsiElement? get() { - // TODO: CommonDataKeys.PSI_ELEMENT? val file = dataContext.getData(CommonDataKeys.PSI_FILE) ?: return null val editor = dataContext.getData(CommonDataKeys.EDITOR) ?: return null return file.findElementAt(editor.caretModel.offset)