diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-20 09:08:08 -0600 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-26 09:11:43 -0600 |
| commit | aa1086fae37999180b485ced323d35acec7868a1 (patch) | |
| tree | 830a7671fc0550cd1422cad914aafb6e71808be3 | |
| parent | 173e6d625c3ea96a95580303fedd011684635cc4 (diff) | |
| download | nimterop-aa1086fae37999180b485ced323d35acec7868a1.tar.gz nimterop-aa1086fae37999180b485ced323d35acec7868a1.zip | |
Fix cast type
only run tast2 on supported compilers
Change cast to gentle type cast
Re enable tests for Nim < 1.0.0
| -rw-r--r-- | nimterop/exprparser.nim | 6 | ||||
| -rw-r--r-- | tests/include/tast2.h | 6 | ||||
| -rw-r--r-- | tests/tast2.nim | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index 183bb18..ed287a3 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -247,7 +247,7 @@ proc processShiftExpression(exprParser: ExprParser, node: TSNode, typeofNode: va let rightNode = exprParser.processTSNode(right, typeofNode) result.add leftNode - result.add nkCast.newTree( + result.add nkCall.newTree( typeofNode, rightNode ) @@ -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 = nkCast.newTree( + result = nkCall.newTree( exprParser.processTSNode(node[0], typeofNode), exprParser.processTSNode(node[1], typeofNode) ) @@ -310,7 +310,7 @@ proc processMathExpression(exprParser: ExprParser, node: TSNode, typeofNode: var let rightNode = exprParser.processTSNode(right, typeofNode) res.add leftNode - res.add nkCast.newTree( + res.add nkCall.newTree( typeofNode, rightNode ) diff --git a/tests/include/tast2.h b/tests/include/tast2.h index 3c6148a..53b4d64 100644 --- a/tests/include/tast2.h +++ b/tests/include/tast2.h @@ -17,13 +17,13 @@ extern "C" { #define SHL1 (1u << 1) #define SHL2 (1u << 2) #define SHL3 (1u << 3) -#define COERCE 645635634896ull + -35436 -#define COERCE2 645635634896 + -35436 +#define COERCE 645635634896ull + 35436 +#define COERCE2 645635634896 + 35436ul #define BINEXPR ~(-(1u << !-1)) ^ (10 >> 1) #define BOOL true #define MATHEXPR (1 + 2/3*20 - 100) #define ANDEXPR (100 & 11000) -#define CASTEXPR (int) 34 +#define CASTEXPR (char) 34 #define NULLCHAR '\0' #define OCTCHAR '\012' diff --git a/tests/tast2.nim b/tests/tast2.nim index d00552c..d43ce9f 100644 --- a/tests/tast2.nim +++ b/tests/tast2.nim @@ -111,8 +111,8 @@ assert ULLEXPR == (1234.uint64 shl 3) assert LEXPR == (1234.int32 shl 4) assert LLEXPR == (1234.int64 shl 5) -assert COERCE == 645635599460'u64 -assert COERCE2 == 645635599460'i64 +assert COERCE == 645635670332'u64 +assert COERCE2 == 645635670332'i64 assert BINEXPR == 5 assert BOOL == true @@ -297,7 +297,7 @@ var a21p: A21p a21p = addr a20 assert A22 is object -testFields(A22, "f1|f2!ptr ptr cint|array[typeof(123)(123 + cast[typeof(123)](132)), ptr cint]") +testFields(A22, "f1|f2!ptr ptr cint|array[type(123)(255), ptr cint]") checkPragmas(A22, pHeaderBy, istype = false) var a22: A22 a22.f1 = addr a15.a2[0] |
