From 305d90583e5dc7a8dde012c982047df9dee21f8e Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 17 Apr 2020 06:53:41 -0600 Subject: Add proper binary casting --- nimterop/exprparser.nim | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index 9570788..1f72a9a 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -144,8 +144,18 @@ proc processShiftExpression*(exprParser: ExprParser, node: TSNode): PNode = else: raise newException(ExprParseError, &"Unsupported shift symbol \"{shiftSym}\"") - result.add exprParser.processTSNode(left) - result.add exprParser.processTSNode(right) + let + leftNode = exprParser.processTSNode(left) + rightNode = exprParser.processTSNode(right) + + result.add leftNode + result.add nkCast.newTree( + nkCall.newTree( + exprParser.state.getIdent("typeof"), + leftNode + ), + rightNode + ) proc processParenthesizedExpr*(exprParser: ExprParser, node: TSNode): PNode = result = newNode(nkPar) @@ -193,8 +203,18 @@ proc processBitwiseExpression*(exprParser: ExprParser, node: TSNode): PNode = raise newException(ExprParseError, &"Unsupported binary symbol \"{binarySym}\"") result.add exprParser.state.getIdent(nimSym) - result.add exprParser.processTSNode(left) - result.add exprParser.processTSNode(right) + let + leftNode = exprParser.processTSNode(left) + rightNode = exprParser.processTSNode(right) + + result.add leftNode + result.add nkCast.newTree( + nkCall.newTree( + exprParser.state.getIdent("typeof"), + leftNode + ), + rightNode + ) elif node.len() == 1: result = newNode(nkPar) -- cgit v1.2.3