Minimize calling of Ast::thread_safe_file() when cloning

This commit is contained in:
gingerBill
2023-01-03 15:57:09 +00:00
parent dc317c8cd8
commit 85e390deba
+143 -141
View File
@@ -75,33 +75,35 @@ gb_internal Ast *alloc_ast_node(AstFile *f, AstKind kind) {
return node; return node;
} }
gb_internal Ast *clone_ast(Ast *node); gb_internal Ast *clone_ast(Ast *node, AstFile *f = nullptr);
gb_internal Array<Ast *> clone_ast_array(Array<Ast *> const &array) { gb_internal Array<Ast *> clone_ast_array(Array<Ast *> const &array, AstFile *f) {
Array<Ast *> result = {}; Array<Ast *> result = {};
if (array.count > 0) { if (array.count > 0) {
result = array_make<Ast *>(ast_allocator(nullptr), array.count); result = array_make<Ast *>(ast_allocator(nullptr), array.count);
for_array(i, array) { for_array(i, array) {
result[i] = clone_ast(array[i]); result[i] = clone_ast(array[i], f);
} }
} }
return result; return result;
} }
gb_internal Slice<Ast *> clone_ast_array(Slice<Ast *> const &array) { gb_internal Slice<Ast *> clone_ast_array(Slice<Ast *> const &array, AstFile *f) {
Slice<Ast *> result = {}; Slice<Ast *> result = {};
if (array.count > 0) { if (array.count > 0) {
result = slice_clone(permanent_allocator(), array); result = slice_clone(permanent_allocator(), array);
for_array(i, array) { for_array(i, array) {
result[i] = clone_ast(array[i]); result[i] = clone_ast(array[i], f);
} }
} }
return result; return result;
} }
gb_internal Ast *clone_ast(Ast *node) { gb_internal Ast *clone_ast(Ast *node, AstFile *f) {
if (node == nullptr) { if (node == nullptr) {
return nullptr; return nullptr;
} }
AstFile *f = node->thread_safe_file(); if (f == nullptr) {
f = node->thread_safe_file();
}
Ast *n = alloc_ast_node(f, node->kind); Ast *n = alloc_ast_node(f, node->kind);
gb_memmove(n, node, ast_node_size(node->kind)); gb_memmove(n, node, ast_node_size(node->kind));
@@ -118,279 +120,279 @@ gb_internal Ast *clone_ast(Ast *node) {
case Ast_BasicDirective: break; case Ast_BasicDirective: break;
case Ast_PolyType: case Ast_PolyType:
n->PolyType.type = clone_ast(n->PolyType.type); n->PolyType.type = clone_ast(n->PolyType.type, f);
n->PolyType.specialization = clone_ast(n->PolyType.specialization); n->PolyType.specialization = clone_ast(n->PolyType.specialization, f);
break; break;
case Ast_Ellipsis: case Ast_Ellipsis:
n->Ellipsis.expr = clone_ast(n->Ellipsis.expr); n->Ellipsis.expr = clone_ast(n->Ellipsis.expr, f);
break; break;
case Ast_ProcGroup: case Ast_ProcGroup:
n->ProcGroup.args = clone_ast_array(n->ProcGroup.args); n->ProcGroup.args = clone_ast_array(n->ProcGroup.args, f);
break; break;
case Ast_ProcLit: case Ast_ProcLit:
n->ProcLit.type = clone_ast(n->ProcLit.type); n->ProcLit.type = clone_ast(n->ProcLit.type, f);
n->ProcLit.body = clone_ast(n->ProcLit.body); n->ProcLit.body = clone_ast(n->ProcLit.body, f);
n->ProcLit.where_clauses = clone_ast_array(n->ProcLit.where_clauses); n->ProcLit.where_clauses = clone_ast_array(n->ProcLit.where_clauses, f);
break; break;
case Ast_CompoundLit: case Ast_CompoundLit:
n->CompoundLit.type = clone_ast(n->CompoundLit.type); n->CompoundLit.type = clone_ast(n->CompoundLit.type, f);
n->CompoundLit.elems = clone_ast_array(n->CompoundLit.elems); n->CompoundLit.elems = clone_ast_array(n->CompoundLit.elems, f);
break; break;
case Ast_BadExpr: break; case Ast_BadExpr: break;
case Ast_TagExpr: case Ast_TagExpr:
n->TagExpr.expr = clone_ast(n->TagExpr.expr); n->TagExpr.expr = clone_ast(n->TagExpr.expr, f);
break; break;
case Ast_UnaryExpr: case Ast_UnaryExpr:
n->UnaryExpr.expr = clone_ast(n->UnaryExpr.expr); n->UnaryExpr.expr = clone_ast(n->UnaryExpr.expr, f);
break; break;
case Ast_BinaryExpr: case Ast_BinaryExpr:
n->BinaryExpr.left = clone_ast(n->BinaryExpr.left); n->BinaryExpr.left = clone_ast(n->BinaryExpr.left, f);
n->BinaryExpr.right = clone_ast(n->BinaryExpr.right); n->BinaryExpr.right = clone_ast(n->BinaryExpr.right, f);
break; break;
case Ast_ParenExpr: case Ast_ParenExpr:
n->ParenExpr.expr = clone_ast(n->ParenExpr.expr); n->ParenExpr.expr = clone_ast(n->ParenExpr.expr, f);
break; break;
case Ast_SelectorExpr: case Ast_SelectorExpr:
n->SelectorExpr.expr = clone_ast(n->SelectorExpr.expr); n->SelectorExpr.expr = clone_ast(n->SelectorExpr.expr, f);
n->SelectorExpr.selector = clone_ast(n->SelectorExpr.selector); n->SelectorExpr.selector = clone_ast(n->SelectorExpr.selector, f);
break; break;
case Ast_ImplicitSelectorExpr: case Ast_ImplicitSelectorExpr:
n->ImplicitSelectorExpr.selector = clone_ast(n->ImplicitSelectorExpr.selector); n->ImplicitSelectorExpr.selector = clone_ast(n->ImplicitSelectorExpr.selector, f);
break; break;
case Ast_SelectorCallExpr: case Ast_SelectorCallExpr:
n->SelectorCallExpr.expr = clone_ast(n->SelectorCallExpr.expr); n->SelectorCallExpr.expr = clone_ast(n->SelectorCallExpr.expr, f);
n->SelectorCallExpr.call = clone_ast(n->SelectorCallExpr.call); n->SelectorCallExpr.call = clone_ast(n->SelectorCallExpr.call, f);
break; break;
case Ast_IndexExpr: case Ast_IndexExpr:
n->IndexExpr.expr = clone_ast(n->IndexExpr.expr); n->IndexExpr.expr = clone_ast(n->IndexExpr.expr, f);
n->IndexExpr.index = clone_ast(n->IndexExpr.index); n->IndexExpr.index = clone_ast(n->IndexExpr.index, f);
break; break;
case Ast_MatrixIndexExpr: case Ast_MatrixIndexExpr:
n->MatrixIndexExpr.expr = clone_ast(n->MatrixIndexExpr.expr); n->MatrixIndexExpr.expr = clone_ast(n->MatrixIndexExpr.expr, f);
n->MatrixIndexExpr.row_index = clone_ast(n->MatrixIndexExpr.row_index); n->MatrixIndexExpr.row_index = clone_ast(n->MatrixIndexExpr.row_index, f);
n->MatrixIndexExpr.column_index = clone_ast(n->MatrixIndexExpr.column_index); n->MatrixIndexExpr.column_index = clone_ast(n->MatrixIndexExpr.column_index, f);
break; break;
case Ast_DerefExpr: case Ast_DerefExpr:
n->DerefExpr.expr = clone_ast(n->DerefExpr.expr); n->DerefExpr.expr = clone_ast(n->DerefExpr.expr, f);
break; break;
case Ast_SliceExpr: case Ast_SliceExpr:
n->SliceExpr.expr = clone_ast(n->SliceExpr.expr); n->SliceExpr.expr = clone_ast(n->SliceExpr.expr, f);
n->SliceExpr.low = clone_ast(n->SliceExpr.low); n->SliceExpr.low = clone_ast(n->SliceExpr.low, f);
n->SliceExpr.high = clone_ast(n->SliceExpr.high); n->SliceExpr.high = clone_ast(n->SliceExpr.high, f);
break; break;
case Ast_CallExpr: case Ast_CallExpr:
n->CallExpr.proc = clone_ast(n->CallExpr.proc); n->CallExpr.proc = clone_ast(n->CallExpr.proc, f);
n->CallExpr.args = clone_ast_array(n->CallExpr.args); n->CallExpr.args = clone_ast_array(n->CallExpr.args, f);
break; break;
case Ast_FieldValue: case Ast_FieldValue:
n->FieldValue.field = clone_ast(n->FieldValue.field); n->FieldValue.field = clone_ast(n->FieldValue.field, f);
n->FieldValue.value = clone_ast(n->FieldValue.value); n->FieldValue.value = clone_ast(n->FieldValue.value, f);
break; break;
case Ast_EnumFieldValue: case Ast_EnumFieldValue:
n->EnumFieldValue.name = clone_ast(n->EnumFieldValue.name); n->EnumFieldValue.name = clone_ast(n->EnumFieldValue.name, f);
n->EnumFieldValue.value = clone_ast(n->EnumFieldValue.value); n->EnumFieldValue.value = clone_ast(n->EnumFieldValue.value, f);
break; break;
case Ast_TernaryIfExpr: case Ast_TernaryIfExpr:
n->TernaryIfExpr.x = clone_ast(n->TernaryIfExpr.x); n->TernaryIfExpr.x = clone_ast(n->TernaryIfExpr.x, f);
n->TernaryIfExpr.cond = clone_ast(n->TernaryIfExpr.cond); n->TernaryIfExpr.cond = clone_ast(n->TernaryIfExpr.cond, f);
n->TernaryIfExpr.y = clone_ast(n->TernaryIfExpr.y); n->TernaryIfExpr.y = clone_ast(n->TernaryIfExpr.y, f);
break; break;
case Ast_TernaryWhenExpr: case Ast_TernaryWhenExpr:
n->TernaryWhenExpr.x = clone_ast(n->TernaryWhenExpr.x); n->TernaryWhenExpr.x = clone_ast(n->TernaryWhenExpr.x, f);
n->TernaryWhenExpr.cond = clone_ast(n->TernaryWhenExpr.cond); n->TernaryWhenExpr.cond = clone_ast(n->TernaryWhenExpr.cond, f);
n->TernaryWhenExpr.y = clone_ast(n->TernaryWhenExpr.y); n->TernaryWhenExpr.y = clone_ast(n->TernaryWhenExpr.y, f);
break; break;
case Ast_OrElseExpr: case Ast_OrElseExpr:
n->OrElseExpr.x = clone_ast(n->OrElseExpr.x); n->OrElseExpr.x = clone_ast(n->OrElseExpr.x, f);
n->OrElseExpr.y = clone_ast(n->OrElseExpr.y); n->OrElseExpr.y = clone_ast(n->OrElseExpr.y, f);
break; break;
case Ast_OrReturnExpr: case Ast_OrReturnExpr:
n->OrReturnExpr.expr = clone_ast(n->OrReturnExpr.expr); n->OrReturnExpr.expr = clone_ast(n->OrReturnExpr.expr, f);
break; break;
case Ast_TypeAssertion: case Ast_TypeAssertion:
n->TypeAssertion.expr = clone_ast(n->TypeAssertion.expr); n->TypeAssertion.expr = clone_ast(n->TypeAssertion.expr, f);
n->TypeAssertion.type = clone_ast(n->TypeAssertion.type); n->TypeAssertion.type = clone_ast(n->TypeAssertion.type, f);
break; break;
case Ast_TypeCast: case Ast_TypeCast:
n->TypeCast.type = clone_ast(n->TypeCast.type); n->TypeCast.type = clone_ast(n->TypeCast.type, f);
n->TypeCast.expr = clone_ast(n->TypeCast.expr); n->TypeCast.expr = clone_ast(n->TypeCast.expr, f);
break; break;
case Ast_AutoCast: case Ast_AutoCast:
n->AutoCast.expr = clone_ast(n->AutoCast.expr); n->AutoCast.expr = clone_ast(n->AutoCast.expr, f);
break; break;
case Ast_InlineAsmExpr: case Ast_InlineAsmExpr:
n->InlineAsmExpr.param_types = clone_ast_array(n->InlineAsmExpr.param_types); n->InlineAsmExpr.param_types = clone_ast_array(n->InlineAsmExpr.param_types, f);
n->InlineAsmExpr.return_type = clone_ast(n->InlineAsmExpr.return_type); n->InlineAsmExpr.return_type = clone_ast(n->InlineAsmExpr.return_type, f);
n->InlineAsmExpr.asm_string = clone_ast(n->InlineAsmExpr.asm_string); n->InlineAsmExpr.asm_string = clone_ast(n->InlineAsmExpr.asm_string, f);
n->InlineAsmExpr.constraints_string = clone_ast(n->InlineAsmExpr.constraints_string); n->InlineAsmExpr.constraints_string = clone_ast(n->InlineAsmExpr.constraints_string, f);
break; break;
case Ast_BadStmt: break; case Ast_BadStmt: break;
case Ast_EmptyStmt: break; case Ast_EmptyStmt: break;
case Ast_ExprStmt: case Ast_ExprStmt:
n->ExprStmt.expr = clone_ast(n->ExprStmt.expr); n->ExprStmt.expr = clone_ast(n->ExprStmt.expr, f);
break; break;
case Ast_AssignStmt: case Ast_AssignStmt:
n->AssignStmt.lhs = clone_ast_array(n->AssignStmt.lhs); n->AssignStmt.lhs = clone_ast_array(n->AssignStmt.lhs, f);
n->AssignStmt.rhs = clone_ast_array(n->AssignStmt.rhs); n->AssignStmt.rhs = clone_ast_array(n->AssignStmt.rhs, f);
break; break;
case Ast_BlockStmt: case Ast_BlockStmt:
n->BlockStmt.label = clone_ast(n->BlockStmt.label); n->BlockStmt.label = clone_ast(n->BlockStmt.label, f);
n->BlockStmt.stmts = clone_ast_array(n->BlockStmt.stmts); n->BlockStmt.stmts = clone_ast_array(n->BlockStmt.stmts, f);
break; break;
case Ast_IfStmt: case Ast_IfStmt:
n->IfStmt.label = clone_ast(n->IfStmt.label); n->IfStmt.label = clone_ast(n->IfStmt.label, f);
n->IfStmt.init = clone_ast(n->IfStmt.init); n->IfStmt.init = clone_ast(n->IfStmt.init, f);
n->IfStmt.cond = clone_ast(n->IfStmt.cond); n->IfStmt.cond = clone_ast(n->IfStmt.cond, f);
n->IfStmt.body = clone_ast(n->IfStmt.body); n->IfStmt.body = clone_ast(n->IfStmt.body, f);
n->IfStmt.else_stmt = clone_ast(n->IfStmt.else_stmt); n->IfStmt.else_stmt = clone_ast(n->IfStmt.else_stmt, f);
break; break;
case Ast_WhenStmt: case Ast_WhenStmt:
n->WhenStmt.cond = clone_ast(n->WhenStmt.cond); n->WhenStmt.cond = clone_ast(n->WhenStmt.cond, f);
n->WhenStmt.body = clone_ast(n->WhenStmt.body); n->WhenStmt.body = clone_ast(n->WhenStmt.body, f);
n->WhenStmt.else_stmt = clone_ast(n->WhenStmt.else_stmt); n->WhenStmt.else_stmt = clone_ast(n->WhenStmt.else_stmt, f);
break; break;
case Ast_ReturnStmt: case Ast_ReturnStmt:
n->ReturnStmt.results = clone_ast_array(n->ReturnStmt.results); n->ReturnStmt.results = clone_ast_array(n->ReturnStmt.results, f);
break; break;
case Ast_ForStmt: case Ast_ForStmt:
n->ForStmt.label = clone_ast(n->ForStmt.label); n->ForStmt.label = clone_ast(n->ForStmt.label, f);
n->ForStmt.init = clone_ast(n->ForStmt.init); n->ForStmt.init = clone_ast(n->ForStmt.init, f);
n->ForStmt.cond = clone_ast(n->ForStmt.cond); n->ForStmt.cond = clone_ast(n->ForStmt.cond, f);
n->ForStmt.post = clone_ast(n->ForStmt.post); n->ForStmt.post = clone_ast(n->ForStmt.post, f);
n->ForStmt.body = clone_ast(n->ForStmt.body); n->ForStmt.body = clone_ast(n->ForStmt.body, f);
break; break;
case Ast_RangeStmt: case Ast_RangeStmt:
n->RangeStmt.label = clone_ast(n->RangeStmt.label); n->RangeStmt.label = clone_ast(n->RangeStmt.label, f);
n->RangeStmt.vals = clone_ast_array(n->RangeStmt.vals); n->RangeStmt.vals = clone_ast_array(n->RangeStmt.vals, f);
n->RangeStmt.expr = clone_ast(n->RangeStmt.expr); n->RangeStmt.expr = clone_ast(n->RangeStmt.expr, f);
n->RangeStmt.body = clone_ast(n->RangeStmt.body); n->RangeStmt.body = clone_ast(n->RangeStmt.body, f);
break; break;
case Ast_UnrollRangeStmt: case Ast_UnrollRangeStmt:
n->UnrollRangeStmt.val0 = clone_ast(n->UnrollRangeStmt.val0); n->UnrollRangeStmt.val0 = clone_ast(n->UnrollRangeStmt.val0, f);
n->UnrollRangeStmt.val1 = clone_ast(n->UnrollRangeStmt.val1); n->UnrollRangeStmt.val1 = clone_ast(n->UnrollRangeStmt.val1, f);
n->UnrollRangeStmt.expr = clone_ast(n->UnrollRangeStmt.expr); n->UnrollRangeStmt.expr = clone_ast(n->UnrollRangeStmt.expr, f);
n->UnrollRangeStmt.body = clone_ast(n->UnrollRangeStmt.body); n->UnrollRangeStmt.body = clone_ast(n->UnrollRangeStmt.body, f);
break; break;
case Ast_CaseClause: case Ast_CaseClause:
n->CaseClause.list = clone_ast_array(n->CaseClause.list); n->CaseClause.list = clone_ast_array(n->CaseClause.list, f);
n->CaseClause.stmts = clone_ast_array(n->CaseClause.stmts); n->CaseClause.stmts = clone_ast_array(n->CaseClause.stmts, f);
n->CaseClause.implicit_entity = nullptr; n->CaseClause.implicit_entity = nullptr;
break; break;
case Ast_SwitchStmt: case Ast_SwitchStmt:
n->SwitchStmt.label = clone_ast(n->SwitchStmt.label); n->SwitchStmt.label = clone_ast(n->SwitchStmt.label, f);
n->SwitchStmt.init = clone_ast(n->SwitchStmt.init); n->SwitchStmt.init = clone_ast(n->SwitchStmt.init, f);
n->SwitchStmt.tag = clone_ast(n->SwitchStmt.tag); n->SwitchStmt.tag = clone_ast(n->SwitchStmt.tag, f);
n->SwitchStmt.body = clone_ast(n->SwitchStmt.body); n->SwitchStmt.body = clone_ast(n->SwitchStmt.body, f);
break; break;
case Ast_TypeSwitchStmt: case Ast_TypeSwitchStmt:
n->TypeSwitchStmt.label = clone_ast(n->TypeSwitchStmt.label); n->TypeSwitchStmt.label = clone_ast(n->TypeSwitchStmt.label, f);
n->TypeSwitchStmt.tag = clone_ast(n->TypeSwitchStmt.tag); n->TypeSwitchStmt.tag = clone_ast(n->TypeSwitchStmt.tag, f);
n->TypeSwitchStmt.body = clone_ast(n->TypeSwitchStmt.body); n->TypeSwitchStmt.body = clone_ast(n->TypeSwitchStmt.body, f);
break; break;
case Ast_DeferStmt: case Ast_DeferStmt:
n->DeferStmt.stmt = clone_ast(n->DeferStmt.stmt); n->DeferStmt.stmt = clone_ast(n->DeferStmt.stmt, f);
break; break;
case Ast_BranchStmt: case Ast_BranchStmt:
n->BranchStmt.label = clone_ast(n->BranchStmt.label); n->BranchStmt.label = clone_ast(n->BranchStmt.label, f);
break; break;
case Ast_UsingStmt: case Ast_UsingStmt:
n->UsingStmt.list = clone_ast_array(n->UsingStmt.list); n->UsingStmt.list = clone_ast_array(n->UsingStmt.list, f);
break; break;
case Ast_BadDecl: break; case Ast_BadDecl: break;
case Ast_ForeignBlockDecl: case Ast_ForeignBlockDecl:
n->ForeignBlockDecl.foreign_library = clone_ast(n->ForeignBlockDecl.foreign_library); n->ForeignBlockDecl.foreign_library = clone_ast(n->ForeignBlockDecl.foreign_library, f);
n->ForeignBlockDecl.body = clone_ast(n->ForeignBlockDecl.body); n->ForeignBlockDecl.body = clone_ast(n->ForeignBlockDecl.body, f);
n->ForeignBlockDecl.attributes = clone_ast_array(n->ForeignBlockDecl.attributes); n->ForeignBlockDecl.attributes = clone_ast_array(n->ForeignBlockDecl.attributes, f);
break; break;
case Ast_Label: case Ast_Label:
n->Label.name = clone_ast(n->Label.name); n->Label.name = clone_ast(n->Label.name, f);
break; break;
case Ast_ValueDecl: case Ast_ValueDecl:
n->ValueDecl.names = clone_ast_array(n->ValueDecl.names); n->ValueDecl.names = clone_ast_array(n->ValueDecl.names, f);
n->ValueDecl.type = clone_ast(n->ValueDecl.type); n->ValueDecl.type = clone_ast(n->ValueDecl.type, f);
n->ValueDecl.values = clone_ast_array(n->ValueDecl.values); n->ValueDecl.values = clone_ast_array(n->ValueDecl.values, f);
n->ValueDecl.attributes = clone_ast_array(n->ValueDecl.attributes); n->ValueDecl.attributes = clone_ast_array(n->ValueDecl.attributes, f);
break; break;
case Ast_Attribute: case Ast_Attribute:
n->Attribute.elems = clone_ast_array(n->Attribute.elems); n->Attribute.elems = clone_ast_array(n->Attribute.elems, f);
break; break;
case Ast_Field: case Ast_Field:
n->Field.names = clone_ast_array(n->Field.names); n->Field.names = clone_ast_array(n->Field.names, f);
n->Field.type = clone_ast(n->Field.type); n->Field.type = clone_ast(n->Field.type, f);
break; break;
case Ast_FieldList: case Ast_FieldList:
n->FieldList.list = clone_ast_array(n->FieldList.list); n->FieldList.list = clone_ast_array(n->FieldList.list, f);
break; break;
case Ast_TypeidType: case Ast_TypeidType:
n->TypeidType.specialization = clone_ast(n->TypeidType.specialization); n->TypeidType.specialization = clone_ast(n->TypeidType.specialization, f);
break; break;
case Ast_HelperType: case Ast_HelperType:
n->HelperType.type = clone_ast(n->HelperType.type); n->HelperType.type = clone_ast(n->HelperType.type, f);
break; break;
case Ast_DistinctType: case Ast_DistinctType:
n->DistinctType.type = clone_ast(n->DistinctType.type); n->DistinctType.type = clone_ast(n->DistinctType.type, f);
break; break;
case Ast_ProcType: case Ast_ProcType:
n->ProcType.params = clone_ast(n->ProcType.params); n->ProcType.params = clone_ast(n->ProcType.params, f);
n->ProcType.results = clone_ast(n->ProcType.results); n->ProcType.results = clone_ast(n->ProcType.results, f);
break; break;
case Ast_RelativeType: case Ast_RelativeType:
n->RelativeType.tag = clone_ast(n->RelativeType.tag); n->RelativeType.tag = clone_ast(n->RelativeType.tag, f);
n->RelativeType.type = clone_ast(n->RelativeType.type); n->RelativeType.type = clone_ast(n->RelativeType.type, f);
break; break;
case Ast_PointerType: case Ast_PointerType:
n->PointerType.type = clone_ast(n->PointerType.type); n->PointerType.type = clone_ast(n->PointerType.type, f);
n->PointerType.tag = clone_ast(n->PointerType.tag); n->PointerType.tag = clone_ast(n->PointerType.tag, f);
break; break;
case Ast_MultiPointerType: case Ast_MultiPointerType:
n->MultiPointerType.type = clone_ast(n->MultiPointerType.type); n->MultiPointerType.type = clone_ast(n->MultiPointerType.type, f);
break; break;
case Ast_ArrayType: case Ast_ArrayType:
n->ArrayType.count = clone_ast(n->ArrayType.count); n->ArrayType.count = clone_ast(n->ArrayType.count, f);
n->ArrayType.elem = clone_ast(n->ArrayType.elem); n->ArrayType.elem = clone_ast(n->ArrayType.elem, f);
n->ArrayType.tag = clone_ast(n->ArrayType.tag); n->ArrayType.tag = clone_ast(n->ArrayType.tag, f);
break; break;
case Ast_DynamicArrayType: case Ast_DynamicArrayType:
n->DynamicArrayType.elem = clone_ast(n->DynamicArrayType.elem); n->DynamicArrayType.elem = clone_ast(n->DynamicArrayType.elem, f);
break; break;
case Ast_StructType: case Ast_StructType:
n->StructType.fields = clone_ast_array(n->StructType.fields); n->StructType.fields = clone_ast_array(n->StructType.fields, f);
n->StructType.polymorphic_params = clone_ast(n->StructType.polymorphic_params); n->StructType.polymorphic_params = clone_ast(n->StructType.polymorphic_params, f);
n->StructType.align = clone_ast(n->StructType.align); n->StructType.align = clone_ast(n->StructType.align, f);
n->StructType.where_clauses = clone_ast_array(n->StructType.where_clauses); n->StructType.where_clauses = clone_ast_array(n->StructType.where_clauses, f);
break; break;
case Ast_UnionType: case Ast_UnionType:
n->UnionType.variants = clone_ast_array(n->UnionType.variants); n->UnionType.variants = clone_ast_array(n->UnionType.variants, f);
n->UnionType.polymorphic_params = clone_ast(n->UnionType.polymorphic_params); n->UnionType.polymorphic_params = clone_ast(n->UnionType.polymorphic_params, f);
n->UnionType.where_clauses = clone_ast_array(n->UnionType.where_clauses); n->UnionType.where_clauses = clone_ast_array(n->UnionType.where_clauses, f);
break; break;
case Ast_EnumType: case Ast_EnumType:
n->EnumType.base_type = clone_ast(n->EnumType.base_type); n->EnumType.base_type = clone_ast(n->EnumType.base_type, f);
n->EnumType.fields = clone_ast_array(n->EnumType.fields); n->EnumType.fields = clone_ast_array(n->EnumType.fields, f);
break; break;
case Ast_BitSetType: case Ast_BitSetType:
n->BitSetType.elem = clone_ast(n->BitSetType.elem); n->BitSetType.elem = clone_ast(n->BitSetType.elem, f);
n->BitSetType.underlying = clone_ast(n->BitSetType.underlying); n->BitSetType.underlying = clone_ast(n->BitSetType.underlying, f);
break; break;
case Ast_MapType: case Ast_MapType:
n->MapType.count = clone_ast(n->MapType.count); n->MapType.count = clone_ast(n->MapType.count, f);
n->MapType.key = clone_ast(n->MapType.key); n->MapType.key = clone_ast(n->MapType.key, f);
n->MapType.value = clone_ast(n->MapType.value); n->MapType.value = clone_ast(n->MapType.value, f);
break; break;
case Ast_MatrixType: case Ast_MatrixType:
n->MatrixType.row_count = clone_ast(n->MatrixType.row_count); n->MatrixType.row_count = clone_ast(n->MatrixType.row_count, f);
n->MatrixType.column_count = clone_ast(n->MatrixType.column_count); n->MatrixType.column_count = clone_ast(n->MatrixType.column_count, f);
n->MatrixType.elem = clone_ast(n->MatrixType.elem); n->MatrixType.elem = clone_ast(n->MatrixType.elem, f);
break; break;
} }