{
std::map<std::string, AstNode*> backup_scope = current_scope;
std::map<std::string, AstNode::varinfo_t> variables;
+ std::vector<AstNode*> to_delete;
AstNode *block = new AstNode(AST_BLOCK);
AstNode *result = nullptr;
current_scope[stmt->str] = stmt;
block->children.erase(block->children.begin());
+ to_delete.push_back(stmt);
continue;
}
current_scope[stmt->str] = stmt;
block->children.erase(block->children.begin());
+ to_delete.push_back(stmt);
continue;
}
delete block;
current_scope = backup_scope;
+ for (auto it : to_delete) {
+ delete it;
+ }
+ to_delete.clear();
+
return result;
}