Skip to content

Commit

Permalink
[C2HEXA] Fix false calling
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jul 11, 2024
1 parent 5fab00c commit 2629f2a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions source/toHexa/clang/clangGenerator.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ class ClangGenerator {
return Node.Block([node])
}

fun nodeToStatementNode(node ClangNode) Node? {
switch node.kind {
case ParenExpr:
return Node.Block([nodeToNode(node.inner[0])])
}
return nodeToNode(node)
}

fun nodeToNode(node ClangNode) Node? {
switch node.kind {
// Roots
Expand Down Expand Up @@ -291,7 +299,7 @@ class ClangGenerator {
result.push(nodeToNode(node))
result.push(nodeToNode(node.inner[0]))
case _:
result.push(nodeToNode(node))
result.push(nodeToStatementNode(node))
}
}

Expand All @@ -312,7 +320,7 @@ class ClangGenerator {
// TODO FORMAT `while(i`
while i < node.inner.length - (hasElse ? 1: 0) {
let ex = node.inner[i++]
body.push(nodeToNode(ex))
body.push(nodeToStatementNode(ex))
}

if hasElse {
Expand Down

0 comments on commit 2629f2a

Please sign in to comment.