cleaned: removed old ast flag that was unused
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 20 Jan 2024 16:24:26 +0000 (10:24 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 20 Jan 2024 16:24:26 +0000 (10:24 -0600)
compiler/include/astnodes.h
compiler/src/astnodes.c
compiler/src/builtins.c
compiler/src/checker.c
compiler/src/polymorph.h
core/conv/conv.onyx

index 3f9286e55d26e6b8b0baa96728bcfac157034d54..6ac937210d0ab0b6ad73338f22295834aea38841 100644 (file)
@@ -263,9 +263,6 @@ typedef enum AstFlags {
     Ast_Flag_Private_Package       = BH_BIT(3),
     Ast_Flag_Private_File          = BH_BIT(4),
 
-    // Function flags
-    Ast_Flag_Function_Used         = BH_BIT(5),
-
     // Expression flags
     Ast_Flag_Expr_Ignored          = BH_BIT(6),
     Ast_Flag_Address_Taken         = BH_BIT(7),
index 90efc63e12f6cebe086c1985a9fc026a1d7ff299..ea6ed878638494786f8e12793e0cfb52d29d8116 100644 (file)
@@ -709,10 +709,6 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
         if (func == NULL) return TYPE_MATCH_FAILED;
         if (func == (AstTyped *) &node_that_signals_a_yield) return TYPE_MATCH_YIELD;
 
-        // HACK: It feels like there should be a better place to flag that a procedure was definitely used.
-        if (func->kind == Ast_Kind_Function)
-            func->flags |= Ast_Flag_Function_Used;
-
         if (permanent) {
             ensure_overload_returns_correct_type(func, (AstOverloadedFunction *) node);
             *pnode = func;
index 805d32ca6ea0d90f598db454ee073850ed40a252..4f2024a3fe1106e6630c4d047b4afaa0ceb4dadb 100644 (file)
@@ -546,8 +546,6 @@ void initialize_builtins(bh_allocator a) {
         onyx_report_error((OnyxFilePos) { 0 }, Error_Critical, "'__closure_block_allocate' procedure not found.");
         return;
     }
-    // HACK
-    builtin_closure_block_allocate->flags |= Ast_Flag_Function_Used;
 
 
     builtin_link_options_type = (AstType *) symbol_raw_resolve(p->scope, "Link_Options");
index e1ba37ce1dc1b0bd71fa92da95f790fc3516c873..cb1c56a56d3545fd8dcfb98a0841e99c0ef14dd5 100644 (file)
@@ -917,7 +917,6 @@ CheckStatus check_call(AstCall** pcall) {
     if (tm == TYPE_MATCH_YIELD) YIELD(call->token->pos, "Waiting on argument type checking.");
 
     call->flags   |= Ast_Flag_Has_Been_Checked;
-    callee->flags |= Ast_Flag_Function_Used;
 
     if (call->kind == Ast_Kind_Call && call->callee->kind == Ast_Kind_Macro) {
         expand_macro(pcall, callee);
@@ -2404,7 +2403,6 @@ CheckStatus check_expression(AstTyped** pexpr) {
             if (expr->type == NULL)
                 YIELD(expr->token->pos, "Waiting for function type to be resolved.");
 
-            expr->flags |= Ast_Flag_Function_Used;
             break;
 
         case Ast_Kind_Directive_Solidify:
@@ -3001,22 +2999,6 @@ CheckStatus check_overloaded_function(AstOverloadedFunction* ofunc) {
     return Check_Success;
 }
 
-static void mark_all_functions_used_in_scope(Scope *scope) {
-    //
-    // This ensures that all procedures defined inside of a structure are
-    // not pruned and omitted from the binary. This is because a large
-    // use-case of procedures in structures is dynamically linking them
-    // using the type info data.
-    if (scope) {
-        fori (i, 0, shlen(scope->symbols)) {
-            AstNode* node = scope->symbols[i].value;
-            if (node->kind == Ast_Kind_Function) {
-                node->flags |= Ast_Flag_Function_Used;
-            }
-        }
-    }
-}
-
 CheckStatus check_meta_tags(bh_arr(AstTyped *) tags) {
     if (tags) {
         bh_arr_each(AstTyped *, meta, tags) {
@@ -3074,8 +3056,6 @@ CheckStatus check_struct(AstStructType* s_node) {
         CHECK(constraint_context, &s_node->constraints, s_node->scope, pos);
     }
 
-    mark_all_functions_used_in_scope(s_node->scope);
-
     bh_arr_each(AstStructMember *, smem, s_node->members) {
         if ((*smem)->type_node != NULL) {
             CHECK(type, &(*smem)->type_node);
@@ -3193,8 +3173,6 @@ CheckStatus check_union(AstUnionType *u_node) {
         CHECK(constraint_context, &u_node->constraints, u_node->scope, pos);
     }
 
-    mark_all_functions_used_in_scope(u_node->scope);
-
     CHECK(meta_tags, u_node->meta_tags);
 
     bh_arr_each(AstUnionVariant *, variant, u_node->variants) {
index 0e4ce20edf475fa1458952c7cfd8135107575ab3..ee3742c925da7be303faf07e1375b767982dce2d 100644 (file)
@@ -110,7 +110,6 @@ static char* build_poly_slns_unique_key(bh_arr(AstPolySolution) slns) {
 // later. It optionally can start the function header entity at the code generation state if
 // the header has already been processed.
 static b32 add_solidified_function_entities(AstSolidifiedFunction *solidified_func) {
-    solidified_func->func->flags |= Ast_Flag_Function_Used;
     solidified_func->func->flags |= Ast_Flag_From_Polymorphism;
 
     Entity func_header_entity = {
index 90f24698a961dfa1f481128bcf9c3004867832e3..7d58362737bb7cef6662ad07f058b729d18ece09 100644 (file)
@@ -1,6 +1,8 @@
 package core.conv
 
-Enable_Custom_Formatters :: true
+#if !#defined(Enable_Custom_Formatters) {
+    Enable_Custom_Formatters :: true
+}
 
 use core.string
 use core.math