Skip to content

Commit

Permalink
Remove intermediate AST StmtNode (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Jan 20, 2024
1 parent 8b5befb commit 2fd307c
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 362 deletions.
15 changes: 4 additions & 11 deletions media/test-project/test.spice
@@ -1,16 +1,9 @@
import "std/data/vector";
f<string> unusedReturnValue() {
return "unused";
}

f<int> main() {
Vector<string> v = Vector<string>();
v.pushBack("Hello");
v.pushBack("World");
v.pushBack("!");
v.pushBack("!");
v.pushBack("!");

foreach string s : v {
printf("%s\n", s);
}
unusedReturnValue();
}

/*f<int> main() {
Expand Down
9 changes: 1 addition & 8 deletions src/ast/ASTBuilder.cpp
Expand Up @@ -475,14 +475,7 @@ std::any ASTBuilder::visitSignature(SpiceParser::SignatureContext *ctx) {
return concludeNode(signatureNode);
}

std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) {
auto stmtNode = createNode<StmtNode>(ctx);

// Visit children
visitChildren(ctx);

return concludeNode(stmtNode);
}
std::any ASTBuilder::visitStmt(SpiceParser::StmtContext *ctx) { return visitChildren(ctx); }

std::any ASTBuilder::visitDeclStmt(SpiceParser::DeclStmtContext *ctx) {
auto declStmtNode = createNode<DeclStmtNode>(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ASTNodes.cpp
Expand Up @@ -511,7 +511,7 @@ bool FctCallNode::hasReturnValueReceiver() const {
node = node->parent;
}
// Also check the condition of the assign expression
return node->children.size() > 1 || !node->parent->isStmtNode();
return node->children.size() > 1 || !node->parent->isStmtLstNode();
}

bool LambdaFuncNode::returnsOnAllControlPaths(bool *overrideUnreachable) const {
Expand Down

0 comments on commit 2fd307c

Please sign in to comment.