diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-20 11:33:53 -0600 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-26 09:11:48 -0600 |
| commit | 208098b3eb959e477a3625a8a48305ddaa1cec4f (patch) | |
| tree | 431b339a8bc36ab2eb518070c4e177ebe9f8bbd4 | |
| parent | aa1086fae37999180b485ced323d35acec7868a1 (diff) | |
| download | nimterop-208098b3eb959e477a3625a8a48305ddaa1cec4f.tar.gz nimterop-208098b3eb959e477a3625a8a48305ddaa1cec4f.zip | |
Make bitwise_expression forwards compatible
Skip syms for tmath
Skip more syms
Add casting back for cast_expression. Disable cast test on Nim < 1.0.0
Skip more syms for cast expressions on Nim < 1.0.0
| -rw-r--r-- | nimterop/exprparser.nim | 8 | ||||
| -rw-r--r-- | tests/tast2.nim | 11 | ||||
| -rw-r--r-- | tests/tmath.nim | 4 |
3 files changed, 18 insertions, 5 deletions
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index ed287a3..207d7fd 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -258,7 +258,7 @@ proc processParenthesizedExpr(exprParser: ExprParser, node: TSNode, typeofNode: result.add(exprParser.processTSNode(node[i], typeofNode)) proc processCastExpression(exprParser: ExprParser, node: TSNode, typeofNode: var PNode): PNode = - result = nkCall.newTree( + result = nkCast.newTree( exprParser.processTSNode(node[0], typeofNode), exprParser.processTSNode(node[1], typeofNode) ) @@ -455,7 +455,9 @@ proc processTSNode(exprParser: ExprParser, node: TSNode, typeofNode: var PNode): result = exprParser.processParenthesizedExpr(node, typeofNode) of "sizeof_expression": result = exprParser.processSizeofExpression(node, typeofNode) - of "bitwise_expression", "equality_expression": + # binary_expression from the new treesitter upgrade should work here + # once we upgrade + of "bitwise_expression", "equality_expression", "binary_expression": result = exprParser.processBitwiseExpression(node, typeofNode) of "math_expression": result = exprParser.processMathExpression(node, typeofNode) @@ -497,4 +499,4 @@ proc parseCExpression*(state: NimState, code: string, name = ""): PNode = result = newNode(nkNone) except Exception as e: techo "UNEXPECTED EXCEPTION: ", e.msg - result = newNode(nkNone)
\ No newline at end of file + result = newNode(nkNone) diff --git a/tests/tast2.nim b/tests/tast2.nim index d43ce9f..0b3762a 100644 --- a/tests/tast2.nim +++ b/tests/tast2.nim @@ -3,11 +3,16 @@ import macros, os, sets, strutils import nimterop/[cimport] static: + # Skip casting on lower nim compilers because + # the VM does not support it + when (NimMajor, NimMinor, NimPatch) < (1, 0, 0): + cSkipSymbol @["CASTEXPR"] cDebug() const path = currentSourcePath.parentDir() / "include" / "tast2.h" + when defined(HEADER): cDefine("HEADER") const @@ -118,7 +123,9 @@ assert BINEXPR == 5 assert BOOL == true assert MATHEXPR == -99 assert ANDEXPR == 96 -assert CASTEXPR == 34.chr + +when (NimMajor, NimMinor, NimPatch) >= (1, 0, 0): + assert CASTEXPR == 34.chr assert TRICKYSTR == "N\x1C\nfoo\x00\'\"\c\v\a\b\e\f\t\\\\?bar" assert NULLCHAR == '\0' @@ -453,4 +460,4 @@ checkPragmas(nested, pHeaderImpBy) when defined(HEADER): assert sitest1(5) == 10 - assert sitest1(10) == 20
\ No newline at end of file + assert sitest1(10) == 20 diff --git a/tests/tmath.nim b/tests/tmath.nim index 5d84700..bbf7abd 100644 --- a/tests/tmath.nim +++ b/tests/tmath.nim @@ -13,6 +13,10 @@ when defined(windows): complex = object static: + when (NimMajor, NimMinor, NimPatch) < (1, 0, 0): + cSkipSymbol @["mingw_choose_expr", "EXCEPTION_DEFINED", "COMPLEX_DEFINED", "matherr", "HUGE", "FP_ILOGB0", "FP_ILOGBNAN"] + else: + cSkipSymbol @["mingw_choose_expr", "EXCEPTION_DEFINED", "COMPLEX_DEFINED", "matherr", "HUGE"] cDebug() cDisableCaching() cAddStdDir() |
