Core printing
This commit is contained in:
@@ -263,15 +263,12 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_VALUE: {
|
||||
Ast_Atom *src = (Ast_Atom *)ast;
|
||||
Ast_Atom *dst = ast_create_copy(parent_scope, Ast_Atom, ast);
|
||||
|
||||
dst->parent_scope = parent_scope;
|
||||
return dst;
|
||||
} break;
|
||||
|
||||
case AST_INDEX: {
|
||||
Ast_Index *src = (Ast_Index *)ast;
|
||||
Ast_Index *dst = ast_create_copy(parent_scope, Ast_Index, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
dst->index = (Ast_Expr *)ast_copy(src->index, parent_scope);
|
||||
return dst;
|
||||
@@ -280,7 +277,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_UNARY: {
|
||||
Ast_Unary *src = (Ast_Unary *)ast;
|
||||
Ast_Unary *dst = ast_create_copy(parent_scope, Ast_Unary, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
return dst;
|
||||
} break;
|
||||
@@ -288,7 +284,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_BINARY: {
|
||||
Ast_Binary *src = (Ast_Binary *)ast;
|
||||
Ast_Binary *dst = ast_create_copy(parent_scope, Ast_Binary, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->left = (Ast_Expr *)ast_copy(src->left, parent_scope);
|
||||
dst->right = (Ast_Expr *)ast_copy(src->right, parent_scope);
|
||||
return dst;
|
||||
@@ -297,7 +292,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_CALL_ITEM: {
|
||||
Ast_Call_Item *src = (Ast_Call_Item *)ast;
|
||||
Ast_Call_Item *dst = ast_create_copy(parent_scope, Ast_Call_Item, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->item = (Ast_Expr *)ast_copy(src->item, parent_scope);
|
||||
if (src->call_flags & CALL_INDEX) {
|
||||
dst->index = (Ast_Expr *)ast_copy(src->index, parent_scope);
|
||||
@@ -312,7 +306,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_CALL: {
|
||||
Ast_Call *src = (Ast_Call *)ast;
|
||||
Ast_Call *dst = ast_create_copy(parent_scope, Ast_Call, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->name = (Ast_Expr *)ast_copy(src->name, parent_scope);
|
||||
|
||||
dst->exprs.init(pctx->perm, src->exprs.len);
|
||||
@@ -331,7 +324,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_CONSTANT_ASSERT: {
|
||||
Ast_Builtin *src = (Ast_Builtin *)ast;
|
||||
Ast_Builtin *dst = ast_create_copy(parent_scope, Ast_Builtin, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
return dst;
|
||||
} break;
|
||||
@@ -339,7 +331,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_SWITCH: {
|
||||
Ast_Switch *src = (Ast_Switch *)ast;
|
||||
Ast_Switch *dst = ast_create_copy(parent_scope, Ast_Switch, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->value = (Ast_Expr *)ast_copy(src->value, parent_scope);
|
||||
dst->default_scope = (Ast_Scope *)ast_copy(src->default_scope, parent_scope);
|
||||
|
||||
@@ -355,7 +346,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_SWITCH_CASE: {
|
||||
Ast_Switch_Case *src = (Ast_Switch_Case *)ast;
|
||||
Ast_Switch_Case *dst = ast_create_copy(parent_scope, Ast_Switch_Case, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
|
||||
dst->scope = (Ast_Scope *)ast_copy(src->scope, parent_scope);
|
||||
dst->labels.init(pctx->perm, src->labels.len);
|
||||
@@ -369,7 +359,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_VAR_UNPACK: {
|
||||
Ast_Var_Unpack *src = (Ast_Var_Unpack *)ast;
|
||||
Ast_Var_Unpack *dst = ast_create_copy(parent_scope, Ast_Var_Unpack, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
dst->vars.init(pctx->perm, src->vars.len);
|
||||
@@ -384,7 +373,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_BREAK: {
|
||||
Ast *src = (Ast *)ast;
|
||||
Ast *dst = ast_create_copy(parent_scope, Ast, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
return dst;
|
||||
} break;
|
||||
|
||||
@@ -398,7 +386,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_VAR: {
|
||||
Ast_Decl *src = (Ast_Decl *)ast;
|
||||
Ast_Decl *dst = ast_create_copy(parent_scope, Ast_Decl, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
// dst->overload_op_info = ast_create_copy(parent_scope, Ast_Operator_Info, src->overload_op_info);
|
||||
// omitting polymorphs
|
||||
// omitting polymorph parameters
|
||||
@@ -411,7 +398,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_ARRAY: {
|
||||
Ast_Array *src = (Ast_Array *)ast;
|
||||
Ast_Array *dst = ast_create_copy(parent_scope, Ast_Array, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
return dst;
|
||||
} break;
|
||||
@@ -419,7 +405,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_FOR: {
|
||||
Ast_For *src = (Ast_For *)ast;
|
||||
Ast_For *dst = ast_create_copy(parent_scope, Ast_For, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->scope = (Ast_Scope *)ast_copy(src->scope, parent_scope);
|
||||
dst->init = (Ast_Expr *)ast_copy(src->init, parent_scope);
|
||||
dst->cond = (Ast_Expr *)ast_copy(src->cond, parent_scope);
|
||||
@@ -430,7 +415,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_IF: {
|
||||
Ast_If *src = (Ast_If *)ast;
|
||||
Ast_If *dst = ast_create_copy(parent_scope, Ast_If, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->ifs.init(pctx->perm, src->ifs.len);
|
||||
For(src->ifs) {
|
||||
auto copy = (Ast_If_Node *)ast_copy(it, parent_scope);
|
||||
@@ -443,7 +427,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_IF_NODE: {
|
||||
Ast_If_Node *src = (Ast_If_Node *)ast;
|
||||
Ast_If_Node *dst = ast_create_copy(parent_scope, Ast_If_Node, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
dst->expr = (Ast_Expr *)ast_copy(src->expr, parent_scope);
|
||||
dst->init = (Ast_Binary *)ast_copy(src->init, parent_scope);
|
||||
dst->scope = (Ast_Scope *)ast_copy(src->scope, parent_scope);
|
||||
@@ -465,7 +448,6 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope) {
|
||||
case AST_LAMBDA_EXPR: {
|
||||
Ast_Lambda *src = (Ast_Lambda *)ast;
|
||||
Ast_Lambda *dst = ast_create_copy(parent_scope, Ast_Lambda, ast);
|
||||
dst->parent_scope = parent_scope;
|
||||
|
||||
dst->args.init(pctx->perm, src->args.len);
|
||||
For(src->args) {
|
||||
|
||||
Reference in New Issue
Block a user