Copying and printing the copy

This commit is contained in:
Krzosa Karol
2023-03-31 22:44:11 +02:00
parent e70d544029
commit b6835d0f6a
5 changed files with 26 additions and 9 deletions

View File

@@ -93,6 +93,7 @@ void core__stringify(Ast *ast) {
Ast_Scope *n = (Ast_Scope *)ast;
global_indent += 1;
genln("@%u", n->di);
For(n->decls) {
genln("");
core__stringify(it);
@@ -109,11 +110,12 @@ void core__stringify(Ast *ast) {
case AST_IDENT: {
Ast_Atom *n = (Ast_Atom *)ast;
gen("%Q", n->intern_val);
gen("%Q@%u", n->intern_val, n->di);
} break;
case AST_VALUE: {
Ast_Atom *n = (Ast_Atom *)ast;
gen("@%Q", n->pos->string);
Ast_Atom *n = (Ast_Atom *)ast; //@todo: proper value
gen("%Q@%u", n->pos->string, n->di);
} break;
case AST_INDEX: {
@@ -121,13 +123,13 @@ void core__stringify(Ast *ast) {
core__stringify(n->expr);
gen("[");
core__stringify(n->index);
gen("]");
gen("]@%u", n->di);
} break;
case AST_UNARY: {
Ast_Unary *n = (Ast_Unary *)ast;
gen("%Q", n->pos->string);
core__stringify(n->expr);
gen("%Q@%u", n->pos->string, n->di);
} break;
case AST_BINARY: {
@@ -135,6 +137,7 @@ void core__stringify(Ast *ast) {
core__stringify(n->left);
gen("%Q", n->pos->string);
core__stringify(n->right);
gen("@%u", n->di);
} break;
case AST_CALL_ITEM: {
@@ -148,7 +151,7 @@ void core__stringify(Ast *ast) {
gen(" = ");
}
core__stringify(n->item);
gen("@%u", n->di);
} break;
case AST_CALL: {
@@ -160,6 +163,7 @@ void core__stringify(Ast *ast) {
if (!n->exprs.is_last(&it)) gen(",");
}
gen(")");
gen("@%u", n->di);
} break;
case AST_COMPOUND: {
Ast_Call *n = (Ast_Call *)ast;
@@ -174,6 +178,7 @@ void core__stringify(Ast *ast) {
}
global_indent -= 1;
genln("}");
gen("@%u", n->di);
} break;
case AST_TYPE_OF:
@@ -200,6 +205,7 @@ void core__stringify(Ast *ast) {
gen("(");
core__stringify(n->expr);
gen(")");
gen("@%u", n->di);
} break;
case AST_SWITCH: {
@@ -210,6 +216,7 @@ void core__stringify(Ast *ast) {
core__stringify(it);
}
core__stringify(n->default_scope);
gen("@%u", n->di);
} break;
case AST_SWITCH_CASE: {
@@ -219,6 +226,7 @@ void core__stringify(Ast *ast) {
core__stringify(it);
}
core__stringify(n->scope);
gen("@%u", n->di);
} break;
case AST_VAR_UNPACK: {
@@ -233,10 +241,12 @@ void core__stringify(Ast *ast) {
case AST_PASS: {
genln("pass");
gen("@%u", ast->di);
} break;
case AST_BREAK: {
genln("break");
gen("@%u", ast->di);
} break;
case AST_NAMESPACE: {