Skip to content

Commit

Permalink
cleaned: removed old ast flag that was unused
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanfh committed Jan 20, 2024
1 parent 1b2aca0 commit 1601662
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 33 deletions.
3 changes: 0 additions & 3 deletions compiler/include/astnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions compiler/src/astnodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
22 changes: 0 additions & 22 deletions compiler/src/checker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion compiler/src/polymorph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion core/conv/conv.onyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1601662

Please sign in to comment.