diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-05-05 14:47:42 -0600 |
|---|---|---|
| committer | genotrance <dev@genotrance.com> | 2020-05-06 11:08:07 -0500 |
| commit | 87eef11ec17713c0eb6f5f17c419216efde79fa8 (patch) | |
| tree | 2a3defad3401115bedde7f18f547e7a66c30094a | |
| parent | 3fe6e51780d9d5c789d83060793643c7d9c1ca8d (diff) | |
| download | nimterop-87eef11ec17713c0eb6f5f17c419216efde79fa8.tar.gz nimterop-87eef11ec17713c0eb6f5f17c419216efde79fa8.zip | |
Fix pointer issue and test
| -rw-r--r-- | nimterop/exprparser.nim | 10 | ||||
| -rw-r--r-- | tests/include/tast2.h | 1 | ||||
| -rw-r--r-- | tests/tast2.nim | 2 |
3 files changed, 12 insertions, 1 deletions
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index e68c0b1..e85310a 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -548,7 +548,15 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode = # Input -> true, false # Output -> true, false result = gState.parseString(node.val) - of "type_descriptor", "sized_type_specifier": + of "type_descriptor": + let pointerDecl = node.anyChildInTree("abstract_pointer_declarator") + if pointerDecl.isNil: + result = gState.processTSNode(node[0], typeofNode) + else: + result = nkPtrTy.newTree( + gState.processTSNode(node[0], typeofNode) + ) + of "sized_type_specifier", "primitive_type", "type_identifier": # Input -> int, unsigned int, long int, etc # Output -> cint, cuint, clong, etc let ty = getType(node.val) diff --git a/tests/include/tast2.h b/tests/include/tast2.h index 2ddb58e..c7b85c7 100644 --- a/tests/include/tast2.h +++ b/tests/include/tast2.h @@ -20,6 +20,7 @@ extern "C" { #define COERCE 645635634896ull + 35436 #define COERCE2 645635634896 + 35436ul #define BINEXPR ~(-(1u << !-1)) ^ (10 >> 1) +#define POINTEREXPR (int*)0 #define BOOL true #define MATHEXPR (1 + 2/3*20 - 100) #define ANDEXPR (100 & 11000) diff --git a/tests/tast2.nim b/tests/tast2.nim index 54b89e5..4254a9d 100644 --- a/tests/tast2.nim +++ b/tests/tast2.nim @@ -150,6 +150,8 @@ assert SHL1 == (1.uint shl 1) assert SHL2 == (1.uint shl 2) assert SHL3 == (1.uint shl 3) +assert typeof(POINTEREXPR) is (ptr cint) + assert ALLSHL == (SHL1 or SHL2 or SHL3) assert A0 is object |
