diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 18:34:33 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 18:34:33 -0400 |
| commit | 3500d32db52eaf485b5cff2a26d382b37cfb85a3 (patch) | |
| tree | 7bd26c47ca1c52f837eb28abc4ac9ab184a1e130 /src | |
| parent | db882e5d63d2840b1410a2574fd12d973b7f3ee2 (diff) | |
| download | zig-3500d32db52eaf485b5cff2a26d382b37cfb85a3.tar.gz zig-3500d32db52eaf485b5cff2a26d382b37cfb85a3.zip | |
stage1: rename FnTableEntry to ZigFn
Diffstat (limited to 'src')
| -rw-r--r-- | src/all_types.hpp | 40 | ||||
| -rw-r--r-- | src/analyze.cpp | 52 | ||||
| -rw-r--r-- | src/analyze.hpp | 20 | ||||
| -rw-r--r-- | src/codegen.cpp | 22 | ||||
| -rw-r--r-- | src/ir.cpp | 96 | ||||
| -rw-r--r-- | src/ir.hpp | 4 |
6 files changed, 117 insertions, 117 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp index 9317a92d32..7b728cae99 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -20,7 +20,7 @@ struct AstNode; struct ImportTableEntry; -struct FnTableEntry; +struct ZigFn; struct Scope; struct ScopeBlock; struct ScopeFnDef; @@ -43,7 +43,7 @@ struct IrAnalyze; struct IrExecutable { ZigList<IrBasicBlock *> basic_block_list; Buf *name; - FnTableEntry *name_fn; + ZigFn *name_fn; size_t mem_slot_count; size_t next_debug_id; size_t *backward_branch_count; @@ -51,7 +51,7 @@ struct IrExecutable { bool invalid; bool is_inline; bool is_generic_instantiation; - FnTableEntry *fn_entry; + ZigFn *fn_entry; Buf *c_import_buf; AstNode *source_node; IrExecutable *parent_exec; @@ -191,7 +191,7 @@ struct ConstPtrValue { uint64_t addr; } hard_coded_addr; struct { - FnTableEntry *fn_entry; + ZigFn *fn_entry; } fn; } data; }; @@ -202,7 +202,7 @@ struct ConstErrValue { }; struct ConstBoundFnValue { - FnTableEntry *fn; + ZigFn *fn; IrInstruction *first_arg; }; @@ -345,7 +345,7 @@ struct TldVar { struct TldFn { Tld base; - FnTableEntry *fn_entry; + ZigFn *fn_entry; Buf *extern_lib_name; }; @@ -977,7 +977,7 @@ struct FnTypeParamInfo { }; struct GenericFnTypeId { - FnTableEntry *fn_entry; + ZigFn *fn_entry; ConstExprValue *params; size_t param_count; }; @@ -1080,7 +1080,7 @@ struct TypeTableEntryErrorUnion { struct TypeTableEntryErrorSet { uint32_t err_count; ErrorTableEntry **errors; - FnTableEntry *infer_fn; + ZigFn *infer_fn; }; struct TypeTableEntryEnum { @@ -1282,7 +1282,7 @@ struct FnExport { GlobalLinkageId linkage; }; -struct FnTableEntry { +struct ZigFn { LLVMValueRef llvm_value; const char *llvm_name; AstNode *proto_node; @@ -1323,8 +1323,8 @@ struct FnTableEntry { bool calls_or_awaits_errorable_fn; }; -uint32_t fn_table_entry_hash(FnTableEntry*); -bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b); +uint32_t fn_table_entry_hash(ZigFn*); +bool fn_table_entry_eql(ZigFn *a, ZigFn *b); enum BuiltinFnId { BuiltinFnIdInvalid, @@ -1567,7 +1567,7 @@ struct CodeGen { HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table; HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table; HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table; - HashMap<GenericFnTypeId *, FnTableEntry *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table; + HashMap<GenericFnTypeId *, ZigFn *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table; HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table; HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table; HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names; @@ -1672,14 +1672,14 @@ struct CodeGen { const char *linker_script; // The function definitions this module includes. - ZigList<FnTableEntry *> fn_defs; + ZigList<ZigFn *> fn_defs; size_t fn_defs_index; ZigList<TldVar *> global_vars; OutType out_type; - FnTableEntry *cur_fn; - FnTableEntry *main_fn; - FnTableEntry *panic_fn; + ZigFn *cur_fn; + ZigFn *main_fn; + ZigFn *panic_fn; LLVMValueRef cur_ret_ptr; LLVMValueRef cur_fn_val; LLVMValueRef cur_err_ret_trace_val_arg; @@ -1734,7 +1734,7 @@ struct CodeGen { const char **llvm_argv; size_t llvm_argv_len; - ZigList<FnTableEntry *> test_fns; + ZigList<ZigFn *> test_fns; ZigType *test_fn_type; bool each_lib_rpath; @@ -1766,7 +1766,7 @@ struct CodeGen { Buf cache_dir; Buf *out_h_path; - ZigList<FnTableEntry *> inline_fns; + ZigList<ZigFn *> inline_fns; ZigList<AstNode *> tld_ref_source_node_stack; ZigType *align_amt_type; @@ -1960,7 +1960,7 @@ struct ScopeCompTime { struct ScopeFnDef { Scope base; - FnTableEntry *fn_entry; + ZigFn *fn_entry; }; // This scope is created to indicate that the code in the scope @@ -2356,7 +2356,7 @@ struct IrInstructionCall { IrInstruction base; IrInstruction *fn_ref; - FnTableEntry *fn_entry; + ZigFn *fn_entry; size_t arg_count; IrInstruction **args; bool is_comptime; diff --git a/src/analyze.cpp b/src/analyze.cpp index 28dc54f11a..fbd96a872a 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -25,7 +25,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type); static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type); static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type); static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type); -static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry); +static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry); ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) { if (node->owner->c_import_node != nullptr) { @@ -171,7 +171,7 @@ ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) { return scope; } -ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry) { +ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry) { ScopeFnDef *scope = allocate<ScopeFnDef>(1); init_scope(&scope->base, ScopeIdFnDef, node, parent); scope->fn_entry = fn_entry; @@ -991,7 +991,7 @@ ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const c return entry; } -ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) { +ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry) { ZigType *fn_type = fn_entry->type_entry; assert(fn_type->id == TypeTableEntryIdFn); if (fn_type->data.fn.bound_fn_parent) @@ -1485,7 +1485,7 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { zig_unreachable(); } -ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) { +ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) { ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); buf_resize(&err_set_type->name, 0); buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name)); @@ -1501,7 +1501,7 @@ ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) { return err_set_type; } -static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) { +static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry) { assert(proto_node->type == NodeTypeFnProto); AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; Error err; @@ -3038,8 +3038,8 @@ static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, uint8_t sep) { buf_append_buf(buf, tld->name); } -FnTableEntry *create_fn_raw(FnInline inline_value) { - FnTableEntry *fn_entry = allocate<FnTableEntry>(1); +ZigFn *create_fn_raw(FnInline inline_value) { + ZigFn *fn_entry = allocate<ZigFn>(1); fn_entry->analyzed_executable.backward_branch_count = &fn_entry->prealloc_bbc; fn_entry->analyzed_executable.backward_branch_quota = default_backward_branch_quota; @@ -3050,12 +3050,12 @@ FnTableEntry *create_fn_raw(FnInline inline_value) { return fn_entry; } -FnTableEntry *create_fn(AstNode *proto_node) { +ZigFn *create_fn(AstNode *proto_node) { assert(proto_node->type == NodeTypeFnProto); AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; FnInline inline_value = fn_proto->is_inline ? FnInlineAlways : FnInlineAuto; - FnTableEntry *fn_entry = create_fn_raw(inline_value); + ZigFn *fn_entry = create_fn_raw(inline_value); fn_entry->proto_node = proto_node; fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : @@ -3081,7 +3081,7 @@ static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, ZigType *fn_t buf_ptr(&fn_type->name))); } -static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) { +static void typecheck_panic_fn(CodeGen *g, ZigFn *panic_fn) { AstNode *proto_node = panic_fn->proto_node; assert(proto_node->type == NodeTypeFnProto); ZigType *fn_type = panic_fn->type_entry; @@ -3118,7 +3118,7 @@ ZigType *get_test_fn_type(CodeGen *g) { return g->test_fn_type; } -void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) { +void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) { if (ccc) { if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) { g->have_c_main = true; @@ -3154,7 +3154,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { AstNode *fn_def_node = fn_proto->fn_def_node; - FnTableEntry *fn_table_entry = create_fn(source_node); + ZigFn *fn_table_entry = create_fn(source_node); get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); if (fn_proto->is_export) { @@ -3215,7 +3215,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { } } } else if (source_node->type == NodeTypeTestDecl) { - FnTableEntry *fn_table_entry = create_fn_raw(FnInlineAuto); + ZigFn *fn_table_entry = create_fn_raw(FnInlineAuto); get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); @@ -3750,7 +3750,7 @@ VariableTableEntry *find_variable(CodeGen *g, Scope *scope, Buf *name) { return nullptr; } -FnTableEntry *scope_fn_entry(Scope *scope) { +ZigFn *scope_fn_entry(Scope *scope) { while (scope) { if (scope->id == ScopeIdFnDef) { ScopeFnDef *fn_scope = (ScopeFnDef *)scope; @@ -3761,7 +3761,7 @@ FnTableEntry *scope_fn_entry(Scope *scope) { return nullptr; } -FnTableEntry *scope_get_fn_if_root(Scope *scope) { +ZigFn *scope_get_fn_if_root(Scope *scope) { assert(scope); scope = scope->parent; while (scope) { @@ -3981,7 +3981,7 @@ bool get_ptr_const(ZigType *type) { } } -AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) { +AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index) { if (fn_entry->param_source_nodes) return fn_entry->param_source_nodes[index]; else if (fn_entry->proto_node) @@ -3990,7 +3990,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) { return nullptr; } -static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) { +static void define_local_param_variables(CodeGen *g, ZigFn *fn_table_entry) { ZigType *fn_type = fn_table_entry->type_entry; assert(!fn_type->data.fn.is_generic); FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; @@ -4032,7 +4032,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr } bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) { - FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn; + ZigFn *infer_fn = err_set_type->data.error_set.infer_fn; if (infer_fn != nullptr) { if (infer_fn->anal_state == FnAnalStateInvalid) { return false; @@ -4052,7 +4052,7 @@ bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *sour return true; } -void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) { +void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node) { ZigType *fn_type = fn_table_entry->type_entry; assert(!fn_type->data.fn.is_generic); FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; @@ -4113,7 +4113,7 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ fn_table_entry->anal_state = FnAnalStateComplete; } -static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { +static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { assert(fn_table_entry->anal_state != FnAnalStateProbing); if (fn_table_entry->anal_state != FnAnalStateReady) return; @@ -4349,7 +4349,7 @@ void semantic_analyze(CodeGen *g) { } for (; g->fn_defs_index < g->fn_defs.length; g->fn_defs_index += 1) { - FnTableEntry *fn_entry = g->fn_defs.at(g->fn_defs_index); + ZigFn *fn_entry = g->fn_defs.at(g->fn_defs_index); analyze_fn_body(g, fn_entry); } } @@ -4602,11 +4602,11 @@ static uint32_t hash_size(size_t x) { return (uint32_t)(x % UINT32_MAX); } -uint32_t fn_table_entry_hash(FnTableEntry* value) { +uint32_t fn_table_entry_hash(ZigFn* value) { return ptr_hash(value); } -bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) { +bool fn_table_entry_eql(ZigFn *a, ZigFn *b) { return ptr_eq(a, b); } @@ -5669,7 +5669,7 @@ void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigTy return; case ConstPtrSpecialFunction: { - FnTableEntry *fn_entry = const_val->data.x_ptr.data.fn.fn_entry; + ZigFn *fn_entry = const_val->data.x_ptr.data.fn.fn_entry; buf_appendf(buf, "@ptrCast(%s, %s)", buf_ptr(&const_val->type->name), buf_ptr(&fn_entry->symbol_name)); return; } @@ -5751,7 +5751,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { { assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst); assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction); - FnTableEntry *fn_entry = const_val->data.x_ptr.data.fn.fn_entry; + ZigFn *fn_entry = const_val->data.x_ptr.data.fn.fn_entry; buf_appendf(buf, "%s", buf_ptr(&fn_entry->symbol_name)); return; } @@ -5837,7 +5837,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { } case TypeTableEntryIdBoundFn: { - FnTableEntry *fn_entry = const_val->data.x_bound_fn.fn; + ZigFn *fn_entry = const_val->data.x_bound_fn.fn; buf_appendf(buf, "(bound fn %s)", buf_ptr(&fn_entry->symbol_name)); return; } diff --git a/src/analyze.hpp b/src/analyze.hpp index 58c9636dec..38491c9e09 100644 --- a/src/analyze.hpp +++ b/src/analyze.hpp @@ -31,7 +31,7 @@ ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind AstNode *decl_node, const char *name, ContainerLayout layout); ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x); ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type); -ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry); +ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry); ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name); ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[], ZigType *field_types[], size_t field_count); @@ -77,17 +77,17 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node); void scan_import(CodeGen *g, ImportTableEntry *import); void preview_use_decl(CodeGen *g, AstNode *node); void resolve_use_decl(CodeGen *g, AstNode *node); -FnTableEntry *scope_fn_entry(Scope *scope); +ZigFn *scope_fn_entry(Scope *scope); ImportTableEntry *get_scope_import(Scope *scope); void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope); VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name, bool is_const, ConstExprValue *init_value, Tld *src_tld); ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node); -FnTableEntry *create_fn(AstNode *proto_node); -FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage); +ZigFn *create_fn(AstNode *proto_node); +ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage); void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc); -AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index); -FnTableEntry *scope_get_fn_if_root(Scope *scope); +AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index); +ZigFn *scope_get_fn_if_root(Scope *scope); bool type_requires_comptime(ZigType *type_entry); Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry); Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry); @@ -98,7 +98,7 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max); void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val); -void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node); +void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node); ScopeBlock *create_block_scope(AstNode *node, Scope *parent); ScopeDefer *create_defer_scope(AstNode *node, Scope *parent); @@ -107,7 +107,7 @@ Scope *create_var_scope(AstNode *node, Scope *parent, VariableTableEntry *var); ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent); ScopeLoop *create_loop_scope(AstNode *node, Scope *parent); ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent); -ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry); +ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry); ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import); Scope *create_comptime_scope(AstNode *node, Scope *parent); Scope *create_coro_prelude_scope(AstNode *node, Scope *parent); @@ -190,14 +190,14 @@ ZigType *get_align_amt_type(CodeGen *g); PackageTableEntry *new_anonymous_package(void); Buf *const_value_to_buffer(ConstExprValue *const_val); -void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc); +void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc); ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name); ZigType *get_ptr_to_stack_trace_type(CodeGen *g); bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node); -ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry); +ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry); uint32_t get_coro_frame_align_bytes(CodeGen *g); bool fn_type_can_fail(FnTypeId *fn_type_id); diff --git a/src/codegen.cpp b/src/codegen.cpp index caddc0e898..cfaf05bf96 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -430,7 +430,7 @@ static LLVMLinkage to_llvm_linkage(GlobalLinkageId id) { zig_unreachable(); } -static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_entry) { +static uint32_t get_err_ret_trace_arg_index(CodeGen *g, ZigFn *fn_table_entry) { if (!g->have_err_ret_tracing) { return UINT32_MAX; } @@ -446,7 +446,7 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e return first_arg_ret ? 1 : 0; } -static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { +static LLVMValueRef fn_llvm_value(CodeGen *g, ZigFn *fn_table_entry) { if (fn_table_entry->llvm_value) return fn_table_entry->llvm_value; @@ -628,7 +628,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { { assert(scope->parent); ScopeFnDef *fn_scope = (ScopeFnDef *)scope; - FnTableEntry *fn_table_entry = fn_scope->fn_entry; + ZigFn *fn_table_entry = fn_scope->fn_entry; if (!fn_table_entry->proto_node) return get_di_scope(g, scope->parent); unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ? @@ -3637,7 +3637,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); - FnTableEntry *prev_cur_fn = g->cur_fn; + ZigFn *prev_cur_fn = g->cur_fn; LLVMValueRef prev_cur_fn_val = g->cur_fn_val; LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); @@ -4635,7 +4635,7 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); - FnTableEntry *prev_cur_fn = g->cur_fn; + ZigFn *prev_cur_fn = g->cur_fn; LLVMValueRef prev_cur_fn_val = g->cur_fn_val; LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); @@ -5037,7 +5037,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, zig_unreachable(); } -static void ir_render(CodeGen *g, FnTableEntry *fn_entry) { +static void ir_render(CodeGen *g, ZigFn *fn_entry) { assert(fn_entry); IrExecutable *executable = &fn_entry->analyzed_executable; @@ -5688,7 +5688,7 @@ static void generate_error_name_table(CodeGen *g) { LLVMSetAlignment(g->err_name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(err_name_table_init))); } -static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) { +static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) { IrExecutable *executable = &fn->analyzed_executable; assert(executable->basic_block_list.length > 0); for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { @@ -5747,7 +5747,7 @@ static void report_errors_and_maybe_exit(CodeGen *g) { static void validate_inline_fns(CodeGen *g) { for (size_t i = 0; i < g->inline_fns.length; i += 1) { - FnTableEntry *fn_entry = g->inline_fns.at(i); + ZigFn *fn_entry = g->inline_fns.at(i); LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name); if (fn_val != nullptr) { add_node_error(g, fn_entry->proto_node, buf_sprintf("unable to inline function")); @@ -5864,7 +5864,7 @@ static void do_code_gen(CodeGen *g) { // Generate function definitions. for (size_t fn_i = 0; fn_i < g->fn_defs.length; fn_i += 1) { - FnTableEntry *fn_table_entry = g->fn_defs.at(fn_i); + ZigFn *fn_table_entry = g->fn_defs.at(fn_i); LLVMValueRef fn = fn_llvm_value(g, fn_table_entry); g->cur_fn = fn_table_entry; @@ -7083,7 +7083,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) { test_fn_array->data.x_array.s_none.elements = create_const_vals(g->test_fns.length); for (size_t i = 0; i < g->test_fns.length; i += 1) { - FnTableEntry *test_fn_entry = g->test_fns.at(i); + ZigFn *test_fn_entry = g->test_fns.at(i); ConstExprValue *this_val = &test_fn_array->data.x_array.s_none.elements[i]; this_val->special = ConstValSpecialStatic; @@ -7483,7 +7483,7 @@ static void gen_h_file(CodeGen *g) { Buf h_buf = BUF_INIT; buf_resize(&h_buf, 0); for (size_t fn_def_i = 0; fn_def_i < g->fn_defs.length; fn_def_i += 1) { - FnTableEntry *fn_table_entry = g->fn_defs.at(fn_def_i); + ZigFn *fn_table_entry = g->fn_defs.at(fn_def_i); if (fn_table_entry->export_list.length == 0) continue; diff --git a/src/ir.cpp b/src/ir.cpp index 95bea43dab..1d9352f9d6 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -236,7 +236,7 @@ static size_t exec_next_mem_slot(IrExecutable *exec) { return result; } -static FnTableEntry *exec_fn_entry(IrExecutable *exec) { +static ZigFn *exec_fn_entry(IrExecutable *exec) { return exec->fn_entry; } @@ -1019,7 +1019,7 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode return instruction; } -static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) { +static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); const_instruction->base.value.type = fn_entry->type_entry; const_instruction->base.value.special = ConstValSpecialStatic; @@ -1029,7 +1029,7 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode * return &const_instruction->base; } -static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) { +static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry); ir_instruction_append(irb->current_basic_block, instruction); return instruction; @@ -1062,7 +1062,7 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode } static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, - FnTableEntry *fn_entry, IrInstruction *first_arg) + ZigFn *fn_entry, IrInstruction *first_arg) { IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); @@ -1199,7 +1199,7 @@ static IrInstruction *ir_build_union_field_ptr_from(IrBuilder *irb, IrInstructio } static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *source_node, - FnTableEntry *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, + ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, IrInstruction *new_stack) { @@ -1227,7 +1227,7 @@ static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *sourc } static IrInstruction *ir_build_call_from(IrBuilder *irb, IrInstruction *old_instruction, - FnTableEntry *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, + ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, IrInstruction *new_stack) { @@ -3138,7 +3138,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { } static bool exec_is_async(IrExecutable *exec) { - FnTableEntry *fn_entry = exec_fn_entry(exec); + ZigFn *fn_entry = exec_fn_entry(exec); return fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; } @@ -3200,7 +3200,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { assert(node->type == NodeTypeReturnExpr); - FnTableEntry *fn_entry = exec_fn_entry(irb->exec); + ZigFn *fn_entry = exec_fn_entry(irb->exec); if (!fn_entry) { add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition")); return irb->codegen->invalid_instruction; @@ -3224,7 +3224,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, IrInstruction *return_value; if (expr_node) { // Temporarily set this so that if we return a type it gets the name of the function - FnTableEntry *prev_name_fn = irb->exec->name_fn; + ZigFn *prev_name_fn = irb->exec->name_fn; irb->exec->name_fn = exec_fn_entry(irb->exec); return_value = ir_gen_node(irb, expr_node, scope); irb->exec->name_fn = prev_name_fn; @@ -3403,7 +3403,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode Scope *outer_block_scope = &scope_block->base; Scope *child_scope = outer_block_scope; - FnTableEntry *fn_entry = scope_fn_entry(parent_scope); + ZigFn *fn_entry = scope_fn_entry(parent_scope); if (fn_entry && fn_entry->child_scope == parent_scope) { fn_entry->def_scope = scope_block; } @@ -5686,7 +5686,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode if (!scope->parent) return ir_build_const_import(irb, scope, node, node->owner); - FnTableEntry *fn_entry = scope_get_fn_if_root(scope); + ZigFn *fn_entry = scope_get_fn_if_root(scope); if (fn_entry) return ir_build_const_fn(irb, scope, node, fn_entry); @@ -6913,7 +6913,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n if (target_inst == irb->codegen->invalid_instruction) return irb->codegen->invalid_instruction; - FnTableEntry *fn_entry = exec_fn_entry(irb->exec); + ZigFn *fn_entry = exec_fn_entry(irb->exec); if (!fn_entry) { add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); return irb->codegen->invalid_instruction; @@ -7090,7 +7090,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) { assert(node->type == NodeTypeSuspend); - FnTableEntry *fn_entry = exec_fn_entry(irb->exec); + ZigFn *fn_entry = exec_fn_entry(irb->exec); if (!fn_entry) { add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); return irb->codegen->invalid_instruction; @@ -7379,7 +7379,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec // Entry block gets a reference because we enter it to begin. ir_ref_bb(irb->current_basic_block); - FnTableEntry *fn_entry = exec_fn_entry(irb->exec); + ZigFn *fn_entry = exec_fn_entry(irb->exec); bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; IrInstruction *coro_id; IrInstruction *u8_ptr_type; @@ -7590,7 +7590,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec return true; } -bool ir_gen_fn(CodeGen *codegen, FnTableEntry *fn_entry) { +bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { assert(fn_entry); IrExecutable *ir_executable = &fn_entry->ir_executable; @@ -9345,7 +9345,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) { if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) { - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); if (fn_entry != nullptr) { fn_entry->alloca_list.append(instruction); } @@ -9749,7 +9749,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota, - FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, + ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, IrExecutable *parent_exec) { if (expected_type != nullptr && type_is_invalid(expected_type)) @@ -9816,7 +9816,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { return const_val->data.x_type; } -static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { +static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { if (fn_value == ira->codegen->invalid_instruction) return nullptr; @@ -9996,7 +9996,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ ZigType *child_type = wanted_type->data.pointer.child_type; if (type_has_bits(child_type)) { - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry); fn_entry->alloca_list.append(new_instruction); } @@ -10046,7 +10046,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi new_instruction->value.type = ptr_type; new_instruction->value.data.rh_ptr = RuntimeHintPtrStack; if (type_has_bits(ptr_type)) { - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry); fn_entry->alloca_list.append(new_instruction); } @@ -12644,7 +12644,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec ir_build_var_decl_from(&ira->new_irb, &decl_var_instruction->base, var, var_type, nullptr, casted_init_value); - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); if (fn_entry) fn_entry->variable_list.append(var); @@ -12685,7 +12685,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor zig_unreachable(); case TypeTableEntryIdFn: { assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); - FnTableEntry *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; + ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; switch (cc) { case CallingConventionUnspecified: { @@ -12822,7 +12822,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor } static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) { - FnTableEntry *fn_entry = exec_fn_entry(exec); + ZigFn *fn_entry = exec_fn_entry(exec); return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; } @@ -12878,7 +12878,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira, } IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_instr, ImplicitAllocatorId id) { - FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); if (parent_fn_entry == nullptr) { ir_add_error(ira, source_instr, buf_sprintf("no implicit allocator available")); return ira->codegen->invalid_instruction; @@ -12913,7 +12913,7 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i zig_unreachable(); } -static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, ZigType *fn_type, +static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst) { Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME); @@ -12988,7 +12988,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, IrInstruction *arg, Scope **child_scope, size_t *next_proto_i, GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args, - FnTableEntry *impl_fn) + ZigFn *impl_fn) { AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); assert(param_decl_node->type == NodeTypeParamDecl); @@ -13067,7 +13067,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod return true; } -static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) { +static VariableTableEntry *get_fn_var_by_index(ZigFn *fn_entry, size_t index) { size_t next_var_i = 0; FnGenParamInfo *gen_param_info = fn_entry->type_entry->data.fn.gen_param_info; assert(gen_param_info != nullptr); @@ -13157,7 +13157,7 @@ no_mem_slot: } static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction, - FnTableEntry *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, + ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline) { Error err; @@ -13382,7 +13382,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr // Fork a scope of the function with known values for the parameters. Scope *parent_scope = fn_entry->fndef_scope->base.parent; - FnTableEntry *impl_fn = create_fn(fn_proto_node); + ZigFn *impl_fn = create_fn(fn_proto_node); impl_fn->param_source_nodes = allocate<AstNode *>(new_fn_arg_count); buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name); impl_fn->fndef_scope = create_fndef_scope(impl_fn->body_node, parent_scope, impl_fn); @@ -13430,7 +13430,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr bool found_first_var_arg = false; size_t first_var_arg; - FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); assert(parent_fn_entry); for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { IrInstruction *arg = call_instruction->args[call_i]->other; @@ -13605,7 +13605,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr return ir_finish_anal(ira, return_type); } - FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_type_id->return_type != nullptr); assert(parent_fn_entry != nullptr); if (fn_type_can_fail(fn_type_id)) { @@ -13734,14 +13734,14 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c ir_link_new_instruction(cast_instruction, &call_instruction->base); return ir_finish_anal(ira, cast_instruction->value.type); } else if (fn_ref->value.type->id == TypeTableEntryIdFn) { - FnTableEntry *fn_table_entry = ir_resolve_fn(ira, fn_ref); + ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); if (fn_table_entry == nullptr) return ira->codegen->builtin_types.entry_invalid; return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, fn_ref, nullptr, is_comptime, call_instruction->fn_inline); } else if (fn_ref->value.type->id == TypeTableEntryIdBoundFn) { assert(fn_ref->value.special == ConstValSpecialStatic); - FnTableEntry *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; + ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); @@ -14289,7 +14289,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle return ira->codegen->builtin_types.entry_invalid; } size_t abs_index = start + index; - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry); VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index); bool is_const = true; @@ -14509,7 +14509,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, if (tld->resolution == TldResolutionInvalid) return ira->codegen->invalid_instruction; TldFn *tld_fn = (TldFn *)tld; - FnTableEntry *fn_entry = tld_fn->fn_entry; + ZigFn *fn_entry = tld_fn->fn_entry; if (type_is_invalid(fn_entry->type_entry)) return ira->codegen->invalid_instruction; @@ -14703,7 +14703,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru case TldIdFn: { TldFn *tld_fn = (TldFn *)tld; - FnTableEntry *fn_entry = tld_fn->fn_entry; + ZigFn *fn_entry = tld_fn->fn_entry; assert(fn_entry->type_entry); if (type_is_invalid(fn_entry->type_entry)) @@ -15306,7 +15306,7 @@ static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSet if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) return ira->codegen->builtin_types.entry_invalid; - FnTableEntry *fn_entry = scope_fn_entry(instruction->base.scope); + ZigFn *fn_entry = scope_fn_entry(instruction->base.scope); if (fn_entry == nullptr) { ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function")); return ira->codegen->builtin_types.entry_invalid; @@ -15345,7 +15345,7 @@ static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, break; } else if (scope->id == ScopeIdFnDef) { ScopeFnDef *def_scope = (ScopeFnDef *)scope; - FnTableEntry *target_fn = def_scope->fn_entry; + ZigFn *target_fn = def_scope->fn_entry; assert(target_fn->def_scope != nullptr); safety_off_ptr = &target_fn->def_scope->safety_off; safety_set_node_ptr = &target_fn->def_scope->safety_set_node; @@ -15406,7 +15406,7 @@ static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, fast_math_set_node_ptr = &block_scope->fast_math_set_node; } else if (target_type->id == TypeTableEntryIdFn) { assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction); - FnTableEntry *target_fn = target_val->data.x_ptr.data.fn.fn_entry; + ZigFn *target_fn = target_val->data.x_ptr.data.fn.fn_entry; assert(target_fn->def_scope); fast_math_on_ptr = &target_fn->def_scope->fast_math_on; fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node; @@ -17023,7 +17023,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco // Skip comptime blocks and test functions. if (curr_entry->value->id != TldIdCompTime) { if (curr_entry->value->id == TldIdFn) { - FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; + ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; if (fn_entry->is_test) continue; } @@ -17049,7 +17049,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco if (curr_entry->value->id == TldIdCompTime) { continue; } else if (curr_entry->value->id == TldIdFn) { - FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; + ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; if (fn_entry->is_test) continue; } @@ -17105,7 +17105,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco // 2: Data.Fn: Data.FnDef bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2); - FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; + ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; assert(!fn_entry->is_test); AstNodeFnProto *fn_node = (AstNodeFnProto *)(fn_entry->proto_node); @@ -19276,7 +19276,7 @@ static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructi static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) { ir_build_handle_from(&ira->new_irb, &instruction->base); - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry != nullptr); return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type); } @@ -20339,7 +20339,7 @@ static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira, case TldIdFn: { TldFn *tld_fn = (TldFn *)tld; - FnTableEntry *fn_entry = tld_fn->fn_entry; + ZigFn *fn_entry = tld_fn->fn_entry; assert(fn_entry->type_entry); if (tld_fn->extern_lib_name != nullptr) { @@ -20470,7 +20470,7 @@ static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstruc return ira->codegen->builtin_types.entry_invalid; } - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); if (fn_entry == nullptr) { ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function")); return ira->codegen->builtin_types.entry_invalid; @@ -20631,7 +20631,7 @@ static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionC if (type_is_invalid(coro_mem_ptr->value.type)) return ira->codegen->builtin_types.entry_invalid; - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry != nullptr); IrInstruction *result = ir_build_coro_begin(&ira->new_irb, instruction->base.scope, instruction->base.source_node, coro_id, coro_mem_ptr); @@ -20923,7 +20923,7 @@ static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstr if (type_is_invalid(promise_result_type)) return ira->codegen->builtin_types.entry_invalid; - FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); + ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); assert(fn_entry != nullptr); if (type_can_fail(promise_result_type)) { @@ -21440,7 +21440,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ old_exec->analysis = ira; ira->codegen = codegen; - FnTableEntry *fn_entry = exec_fn_entry(old_exec); + ZigFn *fn_entry = exec_fn_entry(old_exec); bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; ira->explicit_return_type = is_async ? get_promise_type(codegen, expected_type) : expected_type; diff --git a/src/ir.hpp b/src/ir.hpp index a519ed2958..b298750dec 100644 --- a/src/ir.hpp +++ b/src/ir.hpp @@ -11,11 +11,11 @@ #include "all_types.hpp" bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable); -bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry); +bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry); IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota, - FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, + ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, IrExecutable *parent_exec); ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable, |
