authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-05 18:34:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-05 18:34:33-04:00
log3500d32db52eaf485b5cff2a26d382b37cfb85a3
tree7bd26c47ca1c52f837eb28abc4ac9ab184a1e130
parentdb882e5d63d2840b1410a2574fd12d973b7f3ee2
signaturelock-open Commit is signed but in an unrecognized format.

stage1: rename FnTableEntry to ZigFn


6 files changed, 117 insertions(+), 117 deletions(-)

src/all_types.hpp+20-20
......@@ -20,7 +20,7 @@
2020
2121struct AstNode;
2222struct ImportTableEntry;
23struct FnTableEntry;
23struct ZigFn;
2424struct Scope;
2525struct ScopeBlock;
2626struct ScopeFnDef;
......@@ -43,7 +43,7 @@ struct IrAnalyze;
4343struct IrExecutable {
4444 ZigList<IrBasicBlock *> basic_block_list;
4545 Buf *name;
46 FnTableEntry *name_fn;
46 ZigFn *name_fn;
4747 size_t mem_slot_count;
4848 size_t next_debug_id;
4949 size_t *backward_branch_count;
......@@ -51,7 +51,7 @@ struct IrExecutable {
5151 bool invalid;
5252 bool is_inline;
5353 bool is_generic_instantiation;
54 FnTableEntry *fn_entry;
54 ZigFn *fn_entry;
5555 Buf *c_import_buf;
5656 AstNode *source_node;
5757 IrExecutable *parent_exec;
......@@ -191,7 +191,7 @@ struct ConstPtrValue {
191191 uint64_t addr;
192192 } hard_coded_addr;
193193 struct {
194 FnTableEntry *fn_entry;
194 ZigFn *fn_entry;
195195 } fn;
196196 } data;
197197};
......@@ -202,7 +202,7 @@ struct ConstErrValue {
202202};
203203
204204struct ConstBoundFnValue {
205 FnTableEntry *fn;
205 ZigFn *fn;
206206 IrInstruction *first_arg;
207207};
208208
......@@ -345,7 +345,7 @@ struct TldVar {
345345struct TldFn {
346346 Tld base;
347347
348 FnTableEntry *fn_entry;
348 ZigFn *fn_entry;
349349 Buf *extern_lib_name;
350350};
351351
......@@ -977,7 +977,7 @@ struct FnTypeParamInfo {
977977};
978978
979979struct GenericFnTypeId {
980 FnTableEntry *fn_entry;
980 ZigFn *fn_entry;
981981 ConstExprValue *params;
982982 size_t param_count;
983983};
......@@ -1080,7 +1080,7 @@ struct TypeTableEntryErrorUnion {
10801080struct TypeTableEntryErrorSet {
10811081 uint32_t err_count;
10821082 ErrorTableEntry **errors;
1083 FnTableEntry *infer_fn;
1083 ZigFn *infer_fn;
10841084};
10851085
10861086struct TypeTableEntryEnum {
......@@ -1282,7 +1282,7 @@ struct FnExport {
12821282 GlobalLinkageId linkage;
12831283};
12841284
1285struct FnTableEntry {
1285struct ZigFn {
12861286 LLVMValueRef llvm_value;
12871287 const char *llvm_name;
12881288 AstNode *proto_node;
......@@ -1323,8 +1323,8 @@ struct FnTableEntry {
13231323 bool calls_or_awaits_errorable_fn;
13241324};
13251325
1326uint32_t fn_table_entry_hash(FnTableEntry*);
1327bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b);
1326uint32_t fn_table_entry_hash(ZigFn*);
1327bool fn_table_entry_eql(ZigFn *a, ZigFn *b);
13281328
13291329enum BuiltinFnId {
13301330 BuiltinFnIdInvalid,
......@@ -1567,7 +1567,7 @@ struct CodeGen {
15671567 HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table;
15681568 HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table;
15691569 HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table;
1570 HashMap<GenericFnTypeId *, FnTableEntry *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;
1570 HashMap<GenericFnTypeId *, ZigFn *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;
15711571 HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
15721572 HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table;
15731573 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names;
......@@ -1672,14 +1672,14 @@ struct CodeGen {
16721672 const char *linker_script;
16731673
16741674 // The function definitions this module includes.
1675 ZigList<FnTableEntry *> fn_defs;
1675 ZigList<ZigFn *> fn_defs;
16761676 size_t fn_defs_index;
16771677 ZigList<TldVar *> global_vars;
16781678
16791679 OutType out_type;
1680 FnTableEntry *cur_fn;
1681 FnTableEntry *main_fn;
1682 FnTableEntry *panic_fn;
1680 ZigFn *cur_fn;
1681 ZigFn *main_fn;
1682 ZigFn *panic_fn;
16831683 LLVMValueRef cur_ret_ptr;
16841684 LLVMValueRef cur_fn_val;
16851685 LLVMValueRef cur_err_ret_trace_val_arg;
......@@ -1734,7 +1734,7 @@ struct CodeGen {
17341734 const char **llvm_argv;
17351735 size_t llvm_argv_len;
17361736
1737 ZigList<FnTableEntry *> test_fns;
1737 ZigList<ZigFn *> test_fns;
17381738 ZigType *test_fn_type;
17391739
17401740 bool each_lib_rpath;
......@@ -1766,7 +1766,7 @@ struct CodeGen {
17661766 Buf cache_dir;
17671767 Buf *out_h_path;
17681768
1769 ZigList<FnTableEntry *> inline_fns;
1769 ZigList<ZigFn *> inline_fns;
17701770 ZigList<AstNode *> tld_ref_source_node_stack;
17711771
17721772 ZigType *align_amt_type;
......@@ -1960,7 +1960,7 @@ struct ScopeCompTime {
19601960struct ScopeFnDef {
19611961 Scope base;
19621962
1963 FnTableEntry *fn_entry;
1963 ZigFn *fn_entry;
19641964};
19651965
19661966// This scope is created to indicate that the code in the scope
......@@ -2356,7 +2356,7 @@ struct IrInstructionCall {
23562356 IrInstruction base;
23572357
23582358 IrInstruction *fn_ref;
2359 FnTableEntry *fn_entry;
2359 ZigFn *fn_entry;
23602360 size_t arg_count;
23612361 IrInstruction **args;
23622362 bool is_comptime;
src/analyze.cpp+26-26
......@@ -25,7 +25,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type);
2525static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type);
2626static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type);
2727static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type);
28static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);
28static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry);
2929
3030ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
3131 if (node->owner->c_import_node != nullptr) {
......@@ -171,7 +171,7 @@ ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) {
171171 return scope;
172172}
173173
174ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry) {
174ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry) {
175175 ScopeFnDef *scope = allocate<ScopeFnDef>(1);
176176 init_scope(&scope->base, ScopeIdFnDef, node, parent);
177177 scope->fn_entry = fn_entry;
......@@ -991,7 +991,7 @@ ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const c
991991 return entry;
992992}
993993
994ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) {
994ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry) {
995995 ZigType *fn_type = fn_entry->type_entry;
996996 assert(fn_type->id == TypeTableEntryIdFn);
997997 if (fn_type->data.fn.bound_fn_parent)
......@@ -1485,7 +1485,7 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) {
14851485 zig_unreachable();
14861486}
14871487
1488ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
1488ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) {
14891489 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
14901490 buf_resize(&err_set_type->name, 0);
14911491 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) {
15011501 return err_set_type;
15021502}
15031503
1504static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) {
1504static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry) {
15051505 assert(proto_node->type == NodeTypeFnProto);
15061506 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
15071507 Error err;
......@@ -3038,8 +3038,8 @@ static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, uint8_t sep) {
30383038 buf_append_buf(buf, tld->name);
30393039}
30403040
3041FnTableEntry *create_fn_raw(FnInline inline_value) {
3042 FnTableEntry *fn_entry = allocate<FnTableEntry>(1);
3041ZigFn *create_fn_raw(FnInline inline_value) {
3042 ZigFn *fn_entry = allocate<ZigFn>(1);
30433043
30443044 fn_entry->analyzed_executable.backward_branch_count = &fn_entry->prealloc_bbc;
30453045 fn_entry->analyzed_executable.backward_branch_quota = default_backward_branch_quota;
......@@ -3050,12 +3050,12 @@ FnTableEntry *create_fn_raw(FnInline inline_value) {
30503050 return fn_entry;
30513051}
30523052
3053FnTableEntry *create_fn(AstNode *proto_node) {
3053ZigFn *create_fn(AstNode *proto_node) {
30543054 assert(proto_node->type == NodeTypeFnProto);
30553055 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
30563056
30573057 FnInline inline_value = fn_proto->is_inline ? FnInlineAlways : FnInlineAuto;
3058 FnTableEntry *fn_entry = create_fn_raw(inline_value);
3058 ZigFn *fn_entry = create_fn_raw(inline_value);
30593059
30603060 fn_entry->proto_node = proto_node;
30613061 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
30813081 buf_ptr(&fn_type->name)));
30823082}
30833083
3084static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) {
3084static void typecheck_panic_fn(CodeGen *g, ZigFn *panic_fn) {
30853085 AstNode *proto_node = panic_fn->proto_node;
30863086 assert(proto_node->type == NodeTypeFnProto);
30873087 ZigType *fn_type = panic_fn->type_entry;
......@@ -3118,7 +3118,7 @@ ZigType *get_test_fn_type(CodeGen *g) {
31183118 return g->test_fn_type;
31193119}
31203120
3121void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) {
3121void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) {
31223122 if (ccc) {
31233123 if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) {
31243124 g->have_c_main = true;
......@@ -3154,7 +3154,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
31543154
31553155 AstNode *fn_def_node = fn_proto->fn_def_node;
31563156
3157 FnTableEntry *fn_table_entry = create_fn(source_node);
3157 ZigFn *fn_table_entry = create_fn(source_node);
31583158 get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_');
31593159
31603160 if (fn_proto->is_export) {
......@@ -3215,7 +3215,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
32153215 }
32163216 }
32173217 } else if (source_node->type == NodeTypeTestDecl) {
3218 FnTableEntry *fn_table_entry = create_fn_raw(FnInlineAuto);
3218 ZigFn *fn_table_entry = create_fn_raw(FnInlineAuto);
32193219
32203220 get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_');
32213221
......@@ -3750,7 +3750,7 @@ VariableTableEntry *find_variable(CodeGen *g, Scope *scope, Buf *name) {
37503750 return nullptr;
37513751}
37523752
3753FnTableEntry *scope_fn_entry(Scope *scope) {
3753ZigFn *scope_fn_entry(Scope *scope) {
37543754 while (scope) {
37553755 if (scope->id == ScopeIdFnDef) {
37563756 ScopeFnDef *fn_scope = (ScopeFnDef *)scope;
......@@ -3761,7 +3761,7 @@ FnTableEntry *scope_fn_entry(Scope *scope) {
37613761 return nullptr;
37623762}
37633763
3764FnTableEntry *scope_get_fn_if_root(Scope *scope) {
3764ZigFn *scope_get_fn_if_root(Scope *scope) {
37653765 assert(scope);
37663766 scope = scope->parent;
37673767 while (scope) {
......@@ -3981,7 +3981,7 @@ bool get_ptr_const(ZigType *type) {
39813981 }
39823982}
39833983
3984AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {
3984AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index) {
39853985 if (fn_entry->param_source_nodes)
39863986 return fn_entry->param_source_nodes[index];
39873987 else if (fn_entry->proto_node)
......@@ -3990,7 +3990,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {
39903990 return nullptr;
39913991}
39923992
3993static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) {
3993static void define_local_param_variables(CodeGen *g, ZigFn *fn_table_entry) {
39943994 ZigType *fn_type = fn_table_entry->type_entry;
39953995 assert(!fn_type->data.fn.is_generic);
39963996 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
40324032}
40334033
40344034bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) {
4035 FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;
4035 ZigFn *infer_fn = err_set_type->data.error_set.infer_fn;
40364036 if (infer_fn != nullptr) {
40374037 if (infer_fn->anal_state == FnAnalStateInvalid) {
40384038 return false;
......@@ -4052,7 +4052,7 @@ bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *sour
40524052 return true;
40534053}
40544054
4055void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) {
4055void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node) {
40564056 ZigType *fn_type = fn_table_entry->type_entry;
40574057 assert(!fn_type->data.fn.is_generic);
40584058 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
41134113 fn_table_entry->anal_state = FnAnalStateComplete;
41144114}
41154115
4116static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
4116static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) {
41174117 assert(fn_table_entry->anal_state != FnAnalStateProbing);
41184118 if (fn_table_entry->anal_state != FnAnalStateReady)
41194119 return;
......@@ -4349,7 +4349,7 @@ void semantic_analyze(CodeGen *g) {
43494349 }
43504350
43514351 for (; g->fn_defs_index < g->fn_defs.length; g->fn_defs_index += 1) {
4352 FnTableEntry *fn_entry = g->fn_defs.at(g->fn_defs_index);
4352 ZigFn *fn_entry = g->fn_defs.at(g->fn_defs_index);
43534353 analyze_fn_body(g, fn_entry);
43544354 }
43554355 }
......@@ -4602,11 +4602,11 @@ static uint32_t hash_size(size_t x) {
46024602 return (uint32_t)(x % UINT32_MAX);
46034603}
46044604
4605uint32_t fn_table_entry_hash(FnTableEntry* value) {
4605uint32_t fn_table_entry_hash(ZigFn* value) {
46064606 return ptr_hash(value);
46074607}
46084608
4609bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) {
4609bool fn_table_entry_eql(ZigFn *a, ZigFn *b) {
46104610 return ptr_eq(a, b);
46114611}
46124612
......@@ -5669,7 +5669,7 @@ void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigTy
56695669 return;
56705670 case ConstPtrSpecialFunction:
56715671 {
5672 FnTableEntry *fn_entry = const_val->data.x_ptr.data.fn.fn_entry;
5672 ZigFn *fn_entry = const_val->data.x_ptr.data.fn.fn_entry;
56735673 buf_appendf(buf, "@ptrCast(%s, %s)", buf_ptr(&const_val->type->name), buf_ptr(&fn_entry->symbol_name));
56745674 return;
56755675 }
......@@ -5751,7 +5751,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
57515751 {
57525752 assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst);
57535753 assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction);
5754 FnTableEntry *fn_entry = const_val->data.x_ptr.data.fn.fn_entry;
5754 ZigFn *fn_entry = const_val->data.x_ptr.data.fn.fn_entry;
57555755 buf_appendf(buf, "%s", buf_ptr(&fn_entry->symbol_name));
57565756 return;
57575757 }
......@@ -5837,7 +5837,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
58375837 }
58385838 case TypeTableEntryIdBoundFn:
58395839 {
5840 FnTableEntry *fn_entry = const_val->data.x_bound_fn.fn;
5840 ZigFn *fn_entry = const_val->data.x_bound_fn.fn;
58415841 buf_appendf(buf, "(bound fn %s)", buf_ptr(&fn_entry->symbol_name));
58425842 return;
58435843 }
src/analyze.hpp+10-10
......@@ -31,7 +31,7 @@ ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind
3131 AstNode *decl_node, const char *name, ContainerLayout layout);
3232ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
3333ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type);
34ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry);
34ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry);
3535ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name);
3636ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
3737 ZigType *field_types[], size_t field_count);
......@@ -77,17 +77,17 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node);
7777void scan_import(CodeGen *g, ImportTableEntry *import);
7878void preview_use_decl(CodeGen *g, AstNode *node);
7979void resolve_use_decl(CodeGen *g, AstNode *node);
80FnTableEntry *scope_fn_entry(Scope *scope);
80ZigFn *scope_fn_entry(Scope *scope);
8181ImportTableEntry *get_scope_import(Scope *scope);
8282void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope);
8383VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,
8484 bool is_const, ConstExprValue *init_value, Tld *src_tld);
8585ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
86FnTableEntry *create_fn(AstNode *proto_node);
87FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
86ZigFn *create_fn(AstNode *proto_node);
87ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
8888void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
89AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
90FnTableEntry *scope_get_fn_if_root(Scope *scope);
89AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index);
90ZigFn *scope_get_fn_if_root(Scope *scope);
9191bool type_requires_comptime(ZigType *type_entry);
9292Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry);
9393Error 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
9898void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max);
9999
100100void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val);
101void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node);
101void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node);
102102
103103ScopeBlock *create_block_scope(AstNode *node, Scope *parent);
104104ScopeDefer *create_defer_scope(AstNode *node, Scope *parent);
......@@ -107,7 +107,7 @@ Scope *create_var_scope(AstNode *node, Scope *parent, VariableTableEntry *var);
107107ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent);
108108ScopeLoop *create_loop_scope(AstNode *node, Scope *parent);
109109ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent);
110ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry);
110ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry);
111111ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import);
112112Scope *create_comptime_scope(AstNode *node, Scope *parent);
113113Scope *create_coro_prelude_scope(AstNode *node, Scope *parent);
......@@ -190,14 +190,14 @@ ZigType *get_align_amt_type(CodeGen *g);
190190PackageTableEntry *new_anonymous_package(void);
191191
192192Buf *const_value_to_buffer(ConstExprValue *const_val);
193void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc);
193void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc);
194194
195195
196196ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
197197ZigType *get_ptr_to_stack_trace_type(CodeGen *g);
198198bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node);
199199
200ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);
200ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry);
201201
202202uint32_t get_coro_frame_align_bytes(CodeGen *g);
203203bool fn_type_can_fail(FnTypeId *fn_type_id);
src/codegen.cpp+11-11
......@@ -430,7 +430,7 @@ static LLVMLinkage to_llvm_linkage(GlobalLinkageId id) {
430430 zig_unreachable();
431431}
432432
433static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_entry) {
433static uint32_t get_err_ret_trace_arg_index(CodeGen *g, ZigFn *fn_table_entry) {
434434 if (!g->have_err_ret_tracing) {
435435 return UINT32_MAX;
436436 }
......@@ -446,7 +446,7 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e
446446 return first_arg_ret ? 1 : 0;
447447}
448448
449static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
449static LLVMValueRef fn_llvm_value(CodeGen *g, ZigFn *fn_table_entry) {
450450 if (fn_table_entry->llvm_value)
451451 return fn_table_entry->llvm_value;
452452
......@@ -628,7 +628,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
628628 {
629629 assert(scope->parent);
630630 ScopeFnDef *fn_scope = (ScopeFnDef *)scope;
631 FnTableEntry *fn_table_entry = fn_scope->fn_entry;
631 ZigFn *fn_table_entry = fn_scope->fn_entry;
632632 if (!fn_table_entry->proto_node)
633633 return get_di_scope(g, scope->parent);
634634 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) {
36373637
36383638 LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder);
36393639 LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder);
3640 FnTableEntry *prev_cur_fn = g->cur_fn;
3640 ZigFn *prev_cur_fn = g->cur_fn;
36413641 LLVMValueRef prev_cur_fn_val = g->cur_fn_val;
36423642
36433643 LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry");
......@@ -4635,7 +4635,7 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f
46354635
46364636 LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder);
46374637 LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder);
4638 FnTableEntry *prev_cur_fn = g->cur_fn;
4638 ZigFn *prev_cur_fn = g->cur_fn;
46394639 LLVMValueRef prev_cur_fn_val = g->cur_fn_val;
46404640
46414641 LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry");
......@@ -5037,7 +5037,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
50375037 zig_unreachable();
50385038}
50395039
5040static void ir_render(CodeGen *g, FnTableEntry *fn_entry) {
5040static void ir_render(CodeGen *g, ZigFn *fn_entry) {
50415041 assert(fn_entry);
50425042
50435043 IrExecutable *executable = &fn_entry->analyzed_executable;
......@@ -5688,7 +5688,7 @@ static void generate_error_name_table(CodeGen *g) {
56885688 LLVMSetAlignment(g->err_name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(err_name_table_init)));
56895689}
56905690
5691static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) {
5691static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) {
56925692 IrExecutable *executable = &fn->analyzed_executable;
56935693 assert(executable->basic_block_list.length > 0);
56945694 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) {
57475747
57485748static void validate_inline_fns(CodeGen *g) {
57495749 for (size_t i = 0; i < g->inline_fns.length; i += 1) {
5750 FnTableEntry *fn_entry = g->inline_fns.at(i);
5750 ZigFn *fn_entry = g->inline_fns.at(i);
57515751 LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name);
57525752 if (fn_val != nullptr) {
57535753 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) {
58645864
58655865 // Generate function definitions.
58665866 for (size_t fn_i = 0; fn_i < g->fn_defs.length; fn_i += 1) {
5867 FnTableEntry *fn_table_entry = g->fn_defs.at(fn_i);
5867 ZigFn *fn_table_entry = g->fn_defs.at(fn_i);
58685868
58695869 LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);
58705870 g->cur_fn = fn_table_entry;
......@@ -7083,7 +7083,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
70837083 test_fn_array->data.x_array.s_none.elements = create_const_vals(g->test_fns.length);
70847084
70857085 for (size_t i = 0; i < g->test_fns.length; i += 1) {
7086 FnTableEntry *test_fn_entry = g->test_fns.at(i);
7086 ZigFn *test_fn_entry = g->test_fns.at(i);
70877087
70887088 ConstExprValue *this_val = &test_fn_array->data.x_array.s_none.elements[i];
70897089 this_val->special = ConstValSpecialStatic;
......@@ -7483,7 +7483,7 @@ static void gen_h_file(CodeGen *g) {
74837483 Buf h_buf = BUF_INIT;
74847484 buf_resize(&h_buf, 0);
74857485 for (size_t fn_def_i = 0; fn_def_i < g->fn_defs.length; fn_def_i += 1) {
7486 FnTableEntry *fn_table_entry = g->fn_defs.at(fn_def_i);
7486 ZigFn *fn_table_entry = g->fn_defs.at(fn_def_i);
74877487
74887488 if (fn_table_entry->export_list.length == 0)
74897489 continue;
src/ir.cpp+48-48
......@@ -236,7 +236,7 @@ static size_t exec_next_mem_slot(IrExecutable *exec) {
236236 return result;
237237}
238238
239static FnTableEntry *exec_fn_entry(IrExecutable *exec) {
239static ZigFn *exec_fn_entry(IrExecutable *exec) {
240240 return exec->fn_entry;
241241}
242242
......@@ -1019,7 +1019,7 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode
10191019 return instruction;
10201020}
10211021
1022static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) {
1022static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) {
10231023 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
10241024 const_instruction->base.value.type = fn_entry->type_entry;
10251025 const_instruction->base.value.special = ConstValSpecialStatic;
......@@ -1029,7 +1029,7 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *
10291029 return &const_instruction->base;
10301030}
10311031
1032static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) {
1032static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) {
10331033 IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry);
10341034 ir_instruction_append(irb->current_basic_block, instruction);
10351035 return instruction;
......@@ -1062,7 +1062,7 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode
10621062}
10631063
10641064static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node,
1065 FnTableEntry *fn_entry, IrInstruction *first_arg)
1065 ZigFn *fn_entry, IrInstruction *first_arg)
10661066{
10671067 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
10681068 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
11991199}
12001200
12011201static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *source_node,
1202 FnTableEntry *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
1202 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
12031203 bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator,
12041204 IrInstruction *new_stack)
12051205{
......@@ -1227,7 +1227,7 @@ static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *sourc
12271227}
12281228
12291229static IrInstruction *ir_build_call_from(IrBuilder *irb, IrInstruction *old_instruction,
1230 FnTableEntry *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
1230 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
12311231 bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator,
12321232 IrInstruction *new_stack)
12331233{
......@@ -3138,7 +3138,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) {
31383138}
31393139
31403140static bool exec_is_async(IrExecutable *exec) {
3141 FnTableEntry *fn_entry = exec_fn_entry(exec);
3141 ZigFn *fn_entry = exec_fn_entry(exec);
31423142 return fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync;
31433143}
31443144
......@@ -3200,7 +3200,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode
32003200static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) {
32013201 assert(node->type == NodeTypeReturnExpr);
32023202
3203 FnTableEntry *fn_entry = exec_fn_entry(irb->exec);
3203 ZigFn *fn_entry = exec_fn_entry(irb->exec);
32043204 if (!fn_entry) {
32053205 add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition"));
32063206 return irb->codegen->invalid_instruction;
......@@ -3224,7 +3224,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,
32243224 IrInstruction *return_value;
32253225 if (expr_node) {
32263226 // Temporarily set this so that if we return a type it gets the name of the function
3227 FnTableEntry *prev_name_fn = irb->exec->name_fn;
3227 ZigFn *prev_name_fn = irb->exec->name_fn;
32283228 irb->exec->name_fn = exec_fn_entry(irb->exec);
32293229 return_value = ir_gen_node(irb, expr_node, scope);
32303230 irb->exec->name_fn = prev_name_fn;
......@@ -3403,7 +3403,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
34033403 Scope *outer_block_scope = &scope_block->base;
34043404 Scope *child_scope = outer_block_scope;
34053405
3406 FnTableEntry *fn_entry = scope_fn_entry(parent_scope);
3406 ZigFn *fn_entry = scope_fn_entry(parent_scope);
34073407 if (fn_entry && fn_entry->child_scope == parent_scope) {
34083408 fn_entry->def_scope = scope_block;
34093409 }
......@@ -5686,7 +5686,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode
56865686 if (!scope->parent)
56875687 return ir_build_const_import(irb, scope, node, node->owner);
56885688
5689 FnTableEntry *fn_entry = scope_get_fn_if_root(scope);
5689 ZigFn *fn_entry = scope_get_fn_if_root(scope);
56905690 if (fn_entry)
56915691 return ir_build_const_fn(irb, scope, node, fn_entry);
56925692
......@@ -6913,7 +6913,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n
69136913 if (target_inst == irb->codegen->invalid_instruction)
69146914 return irb->codegen->invalid_instruction;
69156915
6916 FnTableEntry *fn_entry = exec_fn_entry(irb->exec);
6916 ZigFn *fn_entry = exec_fn_entry(irb->exec);
69176917 if (!fn_entry) {
69186918 add_node_error(irb->codegen, node, buf_sprintf("await outside function definition"));
69196919 return irb->codegen->invalid_instruction;
......@@ -7090,7 +7090,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n
70907090static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) {
70917091 assert(node->type == NodeTypeSuspend);
70927092
7093 FnTableEntry *fn_entry = exec_fn_entry(irb->exec);
7093 ZigFn *fn_entry = exec_fn_entry(irb->exec);
70947094 if (!fn_entry) {
70957095 add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition"));
70967096 return irb->codegen->invalid_instruction;
......@@ -7379,7 +7379,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
73797379 // Entry block gets a reference because we enter it to begin.
73807380 ir_ref_bb(irb->current_basic_block);
73817381
7382 FnTableEntry *fn_entry = exec_fn_entry(irb->exec);
7382 ZigFn *fn_entry = exec_fn_entry(irb->exec);
73837383 bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync;
73847384 IrInstruction *coro_id;
73857385 IrInstruction *u8_ptr_type;
......@@ -7590,7 +7590,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
75907590 return true;
75917591}
75927592
7593bool ir_gen_fn(CodeGen *codegen, FnTableEntry *fn_entry) {
7593bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {
75947594 assert(fn_entry);
75957595
75967596 IrExecutable *ir_executable = &fn_entry->ir_executable;
......@@ -9345,7 +9345,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
93459345
93469346static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) {
93479347 if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) {
9348 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
9348 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
93499349 if (fn_entry != nullptr) {
93509350 fn_entry->alloca_list.append(instruction);
93519351 }
......@@ -9749,7 +9749,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
97499749
97509750IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
97519751 ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
9752 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
9752 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
97539753 IrExecutable *parent_exec)
97549754{
97559755 if (expected_type != nullptr && type_is_invalid(expected_type))
......@@ -9816,7 +9816,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
98169816 return const_val->data.x_type;
98179817}
98189818
9819static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
9819static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
98209820 if (fn_value == ira->codegen->invalid_instruction)
98219821 return nullptr;
98229822
......@@ -9996,7 +9996,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
99969996
99979997 ZigType *child_type = wanted_type->data.pointer.child_type;
99989998 if (type_has_bits(child_type)) {
9999 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
9999 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
1000010000 assert(fn_entry);
1000110001 fn_entry->alloca_list.append(new_instruction);
1000210002 }
......@@ -10046,7 +10046,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
1004610046 new_instruction->value.type = ptr_type;
1004710047 new_instruction->value.data.rh_ptr = RuntimeHintPtrStack;
1004810048 if (type_has_bits(ptr_type)) {
10049 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
10049 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
1005010050 assert(fn_entry);
1005110051 fn_entry->alloca_list.append(new_instruction);
1005210052 }
......@@ -12644,7 +12644,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec
1264412644
1264512645 ir_build_var_decl_from(&ira->new_irb, &decl_var_instruction->base, var, var_type, nullptr, casted_init_value);
1264612646
12647 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
12647 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
1264812648 if (fn_entry)
1264912649 fn_entry->variable_list.append(var);
1265012650
......@@ -12685,7 +12685,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor
1268512685 zig_unreachable();
1268612686 case TypeTableEntryIdFn: {
1268712687 assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction);
12688 FnTableEntry *fn_entry = target->value.data.x_ptr.data.fn.fn_entry;
12688 ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry;
1268912689 CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc;
1269012690 switch (cc) {
1269112691 case CallingConventionUnspecified: {
......@@ -12822,7 +12822,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor
1282212822}
1282312823
1282412824static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) {
12825 FnTableEntry *fn_entry = exec_fn_entry(exec);
12825 ZigFn *fn_entry = exec_fn_entry(exec);
1282612826 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;
1282712827}
1282812828
......@@ -12878,7 +12878,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira,
1287812878}
1287912879
1288012880IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_instr, ImplicitAllocatorId id) {
12881 FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
12881 ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
1288212882 if (parent_fn_entry == nullptr) {
1288312883 ir_add_error(ira, source_instr, buf_sprintf("no implicit allocator available"));
1288412884 return ira->codegen->invalid_instruction;
......@@ -12913,7 +12913,7 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i
1291312913 zig_unreachable();
1291412914}
1291512915
12916static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, ZigType *fn_type,
12916static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, ZigFn *fn_entry, ZigType *fn_type,
1291712917 IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst)
1291812918{
1291912919 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
1298812988static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node,
1298912989 IrInstruction *arg, Scope **child_scope, size_t *next_proto_i,
1299012990 GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args,
12991 FnTableEntry *impl_fn)
12991 ZigFn *impl_fn)
1299212992{
1299312993 AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i);
1299412994 assert(param_decl_node->type == NodeTypeParamDecl);
......@@ -13067,7 +13067,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1306713067 return true;
1306813068}
1306913069
13070static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) {
13070static VariableTableEntry *get_fn_var_by_index(ZigFn *fn_entry, size_t index) {
1307113071 size_t next_var_i = 0;
1307213072 FnGenParamInfo *gen_param_info = fn_entry->type_entry->data.fn.gen_param_info;
1307313073 assert(gen_param_info != nullptr);
......@@ -13157,7 +13157,7 @@ no_mem_slot:
1315713157}
1315813158
1315913159static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction,
13160 FnTableEntry *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,
13160 ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,
1316113161 IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)
1316213162{
1316313163 Error err;
......@@ -13382,7 +13382,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr
1338213382
1338313383 // Fork a scope of the function with known values for the parameters.
1338413384 Scope *parent_scope = fn_entry->fndef_scope->base.parent;
13385 FnTableEntry *impl_fn = create_fn(fn_proto_node);
13385 ZigFn *impl_fn = create_fn(fn_proto_node);
1338613386 impl_fn->param_source_nodes = allocate<AstNode *>(new_fn_arg_count);
1338713387 buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name);
1338813388 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
1343013430 bool found_first_var_arg = false;
1343113431 size_t first_var_arg;
1343213432
13433 FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
13433 ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
1343413434 assert(parent_fn_entry);
1343513435 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
1343613436 IrInstruction *arg = call_instruction->args[call_i]->other;
......@@ -13605,7 +13605,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr
1360513605 return ir_finish_anal(ira, return_type);
1360613606 }
1360713607
13608 FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
13608 ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec);
1360913609 assert(fn_type_id->return_type != nullptr);
1361013610 assert(parent_fn_entry != nullptr);
1361113611 if (fn_type_can_fail(fn_type_id)) {
......@@ -13734,14 +13734,14 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c
1373413734 ir_link_new_instruction(cast_instruction, &call_instruction->base);
1373513735 return ir_finish_anal(ira, cast_instruction->value.type);
1373613736 } else if (fn_ref->value.type->id == TypeTableEntryIdFn) {
13737 FnTableEntry *fn_table_entry = ir_resolve_fn(ira, fn_ref);
13737 ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref);
1373813738 if (fn_table_entry == nullptr)
1373913739 return ira->codegen->builtin_types.entry_invalid;
1374013740 return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry,
1374113741 fn_ref, nullptr, is_comptime, call_instruction->fn_inline);
1374213742 } else if (fn_ref->value.type->id == TypeTableEntryIdBoundFn) {
1374313743 assert(fn_ref->value.special == ConstValSpecialStatic);
13744 FnTableEntry *fn_table_entry = fn_ref->value.data.x_bound_fn.fn;
13744 ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn;
1374513745 IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg;
1374613746 return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry,
1374713747 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
1428914289 return ira->codegen->builtin_types.entry_invalid;
1429014290 }
1429114291 size_t abs_index = start + index;
14292 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
14292 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
1429314293 assert(fn_entry);
1429414294 VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index);
1429514295 bool is_const = true;
......@@ -14509,7 +14509,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,
1450914509 if (tld->resolution == TldResolutionInvalid)
1451014510 return ira->codegen->invalid_instruction;
1451114511 TldFn *tld_fn = (TldFn *)tld;
14512 FnTableEntry *fn_entry = tld_fn->fn_entry;
14512 ZigFn *fn_entry = tld_fn->fn_entry;
1451314513 if (type_is_invalid(fn_entry->type_entry))
1451414514 return ira->codegen->invalid_instruction;
1451514515
......@@ -14703,7 +14703,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru
1470314703 case TldIdFn:
1470414704 {
1470514705 TldFn *tld_fn = (TldFn *)tld;
14706 FnTableEntry *fn_entry = tld_fn->fn_entry;
14706 ZigFn *fn_entry = tld_fn->fn_entry;
1470714707 assert(fn_entry->type_entry);
1470814708
1470914709 if (type_is_invalid(fn_entry->type_entry))
......@@ -15306,7 +15306,7 @@ static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSet
1530615306 if (!ir_resolve_bool(ira, is_cold_value, &want_cold))
1530715307 return ira->codegen->builtin_types.entry_invalid;
1530815308
15309 FnTableEntry *fn_entry = scope_fn_entry(instruction->base.scope);
15309 ZigFn *fn_entry = scope_fn_entry(instruction->base.scope);
1531015310 if (fn_entry == nullptr) {
1531115311 ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function"));
1531215312 return ira->codegen->builtin_types.entry_invalid;
......@@ -15345,7 +15345,7 @@ static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
1534515345 break;
1534615346 } else if (scope->id == ScopeIdFnDef) {
1534715347 ScopeFnDef *def_scope = (ScopeFnDef *)scope;
15348 FnTableEntry *target_fn = def_scope->fn_entry;
15348 ZigFn *target_fn = def_scope->fn_entry;
1534915349 assert(target_fn->def_scope != nullptr);
1535015350 safety_off_ptr = &target_fn->def_scope->safety_off;
1535115351 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,
1540615406 fast_math_set_node_ptr = &block_scope->fast_math_set_node;
1540715407 } else if (target_type->id == TypeTableEntryIdFn) {
1540815408 assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction);
15409 FnTableEntry *target_fn = target_val->data.x_ptr.data.fn.fn_entry;
15409 ZigFn *target_fn = target_val->data.x_ptr.data.fn.fn_entry;
1541015410 assert(target_fn->def_scope);
1541115411 fast_math_on_ptr = &target_fn->def_scope->fast_math_on;
1541215412 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
1702317023 // Skip comptime blocks and test functions.
1702417024 if (curr_entry->value->id != TldIdCompTime) {
1702517025 if (curr_entry->value->id == TldIdFn) {
17026 FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
17026 ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
1702717027 if (fn_entry->is_test)
1702817028 continue;
1702917029 }
......@@ -17049,7 +17049,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
1704917049 if (curr_entry->value->id == TldIdCompTime) {
1705017050 continue;
1705117051 } else if (curr_entry->value->id == TldIdFn) {
17052 FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
17052 ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
1705317053 if (fn_entry->is_test)
1705417054 continue;
1705517055 }
......@@ -17105,7 +17105,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
1710517105 // 2: Data.Fn: Data.FnDef
1710617106 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2);
1710717107
17108 FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
17108 ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
1710917109 assert(!fn_entry->is_test);
1711017110
1711117111 AstNodeFnProto *fn_node = (AstNodeFnProto *)(fn_entry->proto_node);
......@@ -19276,7 +19276,7 @@ static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructi
1927619276static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {
1927719277 ir_build_handle_from(&ira->new_irb, &instruction->base);
1927819278
19279 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
19279 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
1928019280 assert(fn_entry != nullptr);
1928119281 return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type);
1928219282}
......@@ -20339,7 +20339,7 @@ static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
2033920339 case TldIdFn:
2034020340 {
2034120341 TldFn *tld_fn = (TldFn *)tld;
20342 FnTableEntry *fn_entry = tld_fn->fn_entry;
20342 ZigFn *fn_entry = tld_fn->fn_entry;
2034320343 assert(fn_entry->type_entry);
2034420344
2034520345 if (tld_fn->extern_lib_name != nullptr) {
......@@ -20470,7 +20470,7 @@ static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstruc
2047020470 return ira->codegen->builtin_types.entry_invalid;
2047120471 }
2047220472
20473 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
20473 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
2047420474 if (fn_entry == nullptr) {
2047520475 ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function"));
2047620476 return ira->codegen->builtin_types.entry_invalid;
......@@ -20631,7 +20631,7 @@ static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionC
2063120631 if (type_is_invalid(coro_mem_ptr->value.type))
2063220632 return ira->codegen->builtin_types.entry_invalid;
2063320633
20634 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
20634 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
2063520635 assert(fn_entry != nullptr);
2063620636 IrInstruction *result = ir_build_coro_begin(&ira->new_irb, instruction->base.scope, instruction->base.source_node,
2063720637 coro_id, coro_mem_ptr);
......@@ -20923,7 +20923,7 @@ static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstr
2092320923 if (type_is_invalid(promise_result_type))
2092420924 return ira->codegen->builtin_types.entry_invalid;
2092520925
20926 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
20926 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
2092720927 assert(fn_entry != nullptr);
2092820928
2092920929 if (type_can_fail(promise_result_type)) {
......@@ -21440,7 +21440,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
2144021440 old_exec->analysis = ira;
2144121441 ira->codegen = codegen;
2144221442
21443 FnTableEntry *fn_entry = exec_fn_entry(old_exec);
21443 ZigFn *fn_entry = exec_fn_entry(old_exec);
2144421444 bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync;
2144521445 ira->explicit_return_type = is_async ? get_promise_type(codegen, expected_type) : expected_type;
2144621446
src/ir.hpp+2-2
......@@ -11,11 +11,11 @@
1111#include "all_types.hpp"
1212
1313bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable);
14bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry);
14bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);
1515
1616IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1717 ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
18 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
18 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
1919 IrExecutable *parent_exec);
2020
2121ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,