Copying and printing the copy
This commit is contained in:
@@ -227,6 +227,7 @@ end_of_switch:
|
||||
|
||||
#define ast_create_copy(parent_scope, T, ast) (T *)ast__create_copy(parent_scope, sizeof(T), ast)
|
||||
Ast *ast__create_copy(Ast_Scope *parent_scope, size_t size, Ast *ast) {
|
||||
if (ast == 0) return 0;
|
||||
Ast *result = (Ast *)push_copy(pctx->perm, ast, size);
|
||||
result->parent_scope = parent_scope;
|
||||
result->di = ++pctx->unique_ids;
|
||||
@@ -242,9 +243,9 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
Ast_Scope *src = (Ast_Scope *)ast;
|
||||
Ast_Scope *dst = ast_create_copy(parent_scope, Ast_Scope, src);
|
||||
|
||||
free_all_nodes(&dst->decls);
|
||||
dst->decls = {};
|
||||
For(src->decls) {
|
||||
Ast_Decl *copy = (Ast_Decl *)ast_copy(it, dst);
|
||||
Ast_Decl *copy = (Ast_Decl *)ast_copy(it, src);
|
||||
add(pctx->perm, &dst->decls, copy);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user