Change cast to gentle type cast

This commit is contained in:
Joey Yakimowich-Payne 2020-04-20 11:30:29 -06:00
commit bd3d4e42d7
3 changed files with 8 additions and 8 deletions

View file

@ -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
)

View file

@ -17,8 +17,8 @@ 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)

View file

@ -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]