| author | |
| committer | |
| log | 3500d32db52eaf485b5cff2a26d382b37cfb85a3 |
| tree | 7bd26c47ca1c52f837eb28abc4ac9ab184a1e130 |
| parent | db882e5d63d2840b1410a2574fd12d973b7f3ee2 |
| signature |
6 files changed, 117 insertions(+), 117 deletions(-)
src/all_types.hpp+20-20| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ||
| 21 | struct AstNode; | 21 | struct AstNode; |
| 22 | struct ImportTableEntry; | 22 | struct ImportTableEntry; |
| 23 | struct FnTableEntry; | 23 | struct ZigFn; |
| 24 | struct Scope; | 24 | struct Scope; |
| 25 | struct ScopeBlock; | 25 | struct ScopeBlock; |
| 26 | struct ScopeFnDef; | 26 | struct ScopeFnDef; |
| ... | @@ -43,7 +43,7 @@ struct IrAnalyze; | ... | @@ -43,7 +43,7 @@ struct IrAnalyze; |
| 43 | struct IrExecutable { | 43 | struct IrExecutable { |
| 44 | ZigList<IrBasicBlock *> basic_block_list; | 44 | ZigList<IrBasicBlock *> basic_block_list; |
| 45 | Buf *name; | 45 | Buf *name; |
| 46 | FnTableEntry *name_fn; | 46 | ZigFn *name_fn; |
| 47 | size_t mem_slot_count; | 47 | size_t mem_slot_count; |
| 48 | size_t next_debug_id; | 48 | size_t next_debug_id; |
| 49 | size_t *backward_branch_count; | 49 | size_t *backward_branch_count; |
| ... | @@ -51,7 +51,7 @@ struct IrExecutable { | ... | @@ -51,7 +51,7 @@ struct IrExecutable { |
| 51 | bool invalid; | 51 | bool invalid; |
| 52 | bool is_inline; | 52 | bool is_inline; |
| 53 | bool is_generic_instantiation; | 53 | bool is_generic_instantiation; |
| 54 | FnTableEntry *fn_entry; | 54 | ZigFn *fn_entry; |
| 55 | Buf *c_import_buf; | 55 | Buf *c_import_buf; |
| 56 | AstNode *source_node; | 56 | AstNode *source_node; |
| 57 | IrExecutable *parent_exec; | 57 | IrExecutable *parent_exec; |
| ... | @@ -191,7 +191,7 @@ struct ConstPtrValue { | ... | @@ -191,7 +191,7 @@ struct ConstPtrValue { |
| 191 | uint64_t addr; | 191 | uint64_t addr; |
| 192 | } hard_coded_addr; | 192 | } hard_coded_addr; |
| 193 | struct { | 193 | struct { |
| 194 | FnTableEntry *fn_entry; | 194 | ZigFn *fn_entry; |
| 195 | } fn; | 195 | } fn; |
| 196 | } data; | 196 | } data; |
| 197 | }; | 197 | }; |
| ... | @@ -202,7 +202,7 @@ struct ConstErrValue { | ... | @@ -202,7 +202,7 @@ struct ConstErrValue { |
| 202 | }; | 202 | }; |
| 203 | 203 | ||
| 204 | struct ConstBoundFnValue { | 204 | struct ConstBoundFnValue { |
| 205 | FnTableEntry *fn; | 205 | ZigFn *fn; |
| 206 | IrInstruction *first_arg; | 206 | IrInstruction *first_arg; |
| 207 | }; | 207 | }; |
| 208 | 208 | ||
| ... | @@ -345,7 +345,7 @@ struct TldVar { | ... | @@ -345,7 +345,7 @@ struct TldVar { |
| 345 | struct TldFn { | 345 | struct TldFn { |
| 346 | Tld base; | 346 | Tld base; |
| 347 | 347 | ||
| 348 | FnTableEntry *fn_entry; | 348 | ZigFn *fn_entry; |
| 349 | Buf *extern_lib_name; | 349 | Buf *extern_lib_name; |
| 350 | }; | 350 | }; |
| 351 | 351 | ||
| ... | @@ -977,7 +977,7 @@ struct FnTypeParamInfo { | ... | @@ -977,7 +977,7 @@ struct FnTypeParamInfo { |
| 977 | }; | 977 | }; |
| 978 | 978 | ||
| 979 | struct GenericFnTypeId { | 979 | struct GenericFnTypeId { |
| 980 | FnTableEntry *fn_entry; | 980 | ZigFn *fn_entry; |
| 981 | ConstExprValue *params; | 981 | ConstExprValue *params; |
| 982 | size_t param_count; | 982 | size_t param_count; |
| 983 | }; | 983 | }; |
| ... | @@ -1080,7 +1080,7 @@ struct TypeTableEntryErrorUnion { | ... | @@ -1080,7 +1080,7 @@ struct TypeTableEntryErrorUnion { |
| 1080 | struct TypeTableEntryErrorSet { | 1080 | struct TypeTableEntryErrorSet { |
| 1081 | uint32_t err_count; | 1081 | uint32_t err_count; |
| 1082 | ErrorTableEntry **errors; | 1082 | ErrorTableEntry **errors; |
| 1083 | FnTableEntry *infer_fn; | 1083 | ZigFn *infer_fn; |
| 1084 | }; | 1084 | }; |
| 1085 | 1085 | ||
| 1086 | struct TypeTableEntryEnum { | 1086 | struct TypeTableEntryEnum { |
| ... | @@ -1282,7 +1282,7 @@ struct FnExport { | ... | @@ -1282,7 +1282,7 @@ struct FnExport { |
| 1282 | GlobalLinkageId linkage; | 1282 | GlobalLinkageId linkage; |
| 1283 | }; | 1283 | }; |
| 1284 | 1284 | ||
| 1285 | struct FnTableEntry { | 1285 | struct ZigFn { |
| 1286 | LLVMValueRef llvm_value; | 1286 | LLVMValueRef llvm_value; |
| 1287 | const char *llvm_name; | 1287 | const char *llvm_name; |
| 1288 | AstNode *proto_node; | 1288 | AstNode *proto_node; |
| ... | @@ -1323,8 +1323,8 @@ struct FnTableEntry { | ... | @@ -1323,8 +1323,8 @@ struct FnTableEntry { |
| 1323 | bool calls_or_awaits_errorable_fn; | 1323 | bool calls_or_awaits_errorable_fn; |
| 1324 | }; | 1324 | }; |
| 1325 | 1325 | ||
| 1326 | uint32_t fn_table_entry_hash(FnTableEntry*); | 1326 | uint32_t fn_table_entry_hash(ZigFn*); |
| 1327 | bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b); | 1327 | bool fn_table_entry_eql(ZigFn *a, ZigFn *b); |
| 1328 | 1328 | ||
| 1329 | enum BuiltinFnId { | 1329 | enum BuiltinFnId { |
| 1330 | BuiltinFnIdInvalid, | 1330 | BuiltinFnIdInvalid, |
| ... | @@ -1567,7 +1567,7 @@ struct CodeGen { | ... | @@ -1567,7 +1567,7 @@ struct CodeGen { |
| 1567 | HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table; | 1567 | HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table; |
| 1568 | HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table; | 1568 | HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table; |
| 1569 | HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table; | 1569 | 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; |
| 1571 | HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table; | 1571 | HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table; |
| 1572 | HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table; | 1572 | HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table; |
| 1573 | HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names; | 1573 | HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names; |
| ... | @@ -1672,14 +1672,14 @@ struct CodeGen { | ... | @@ -1672,14 +1672,14 @@ struct CodeGen { |
| 1672 | const char *linker_script; | 1672 | const char *linker_script; |
| 1673 | 1673 | ||
| 1674 | // The function definitions this module includes. | 1674 | // The function definitions this module includes. |
| 1675 | ZigList<FnTableEntry *> fn_defs; | 1675 | ZigList<ZigFn *> fn_defs; |
| 1676 | size_t fn_defs_index; | 1676 | size_t fn_defs_index; |
| 1677 | ZigList<TldVar *> global_vars; | 1677 | ZigList<TldVar *> global_vars; |
| 1678 | 1678 | ||
| 1679 | OutType out_type; | 1679 | OutType out_type; |
| 1680 | FnTableEntry *cur_fn; | 1680 | ZigFn *cur_fn; |
| 1681 | FnTableEntry *main_fn; | 1681 | ZigFn *main_fn; |
| 1682 | FnTableEntry *panic_fn; | 1682 | ZigFn *panic_fn; |
| 1683 | LLVMValueRef cur_ret_ptr; | 1683 | LLVMValueRef cur_ret_ptr; |
| 1684 | LLVMValueRef cur_fn_val; | 1684 | LLVMValueRef cur_fn_val; |
| 1685 | LLVMValueRef cur_err_ret_trace_val_arg; | 1685 | LLVMValueRef cur_err_ret_trace_val_arg; |
| ... | @@ -1734,7 +1734,7 @@ struct CodeGen { | ... | @@ -1734,7 +1734,7 @@ struct CodeGen { |
| 1734 | const char **llvm_argv; | 1734 | const char **llvm_argv; |
| 1735 | size_t llvm_argv_len; | 1735 | size_t llvm_argv_len; |
| 1736 | 1736 | ||
| 1737 | ZigList<FnTableEntry *> test_fns; | 1737 | ZigList<ZigFn *> test_fns; |
| 1738 | ZigType *test_fn_type; | 1738 | ZigType *test_fn_type; |
| 1739 | 1739 | ||
| 1740 | bool each_lib_rpath; | 1740 | bool each_lib_rpath; |
| ... | @@ -1766,7 +1766,7 @@ struct CodeGen { | ... | @@ -1766,7 +1766,7 @@ struct CodeGen { |
| 1766 | Buf cache_dir; | 1766 | Buf cache_dir; |
| 1767 | Buf *out_h_path; | 1767 | Buf *out_h_path; |
| 1768 | 1768 | ||
| 1769 | ZigList<FnTableEntry *> inline_fns; | 1769 | ZigList<ZigFn *> inline_fns; |
| 1770 | ZigList<AstNode *> tld_ref_source_node_stack; | 1770 | ZigList<AstNode *> tld_ref_source_node_stack; |
| 1771 | 1771 | ||
| 1772 | ZigType *align_amt_type; | 1772 | ZigType *align_amt_type; |
| ... | @@ -1960,7 +1960,7 @@ struct ScopeCompTime { | ... | @@ -1960,7 +1960,7 @@ struct ScopeCompTime { |
| 1960 | struct ScopeFnDef { | 1960 | struct ScopeFnDef { |
| 1961 | Scope base; | 1961 | Scope base; |
| 1962 | 1962 | ||
| 1963 | FnTableEntry *fn_entry; | 1963 | ZigFn *fn_entry; |
| 1964 | }; | 1964 | }; |
| 1965 | 1965 | ||
| 1966 | // This scope is created to indicate that the code in the scope | 1966 | // This scope is created to indicate that the code in the scope |
| ... | @@ -2356,7 +2356,7 @@ struct IrInstructionCall { | ... | @@ -2356,7 +2356,7 @@ struct IrInstructionCall { |
| 2356 | IrInstruction base; | 2356 | IrInstruction base; |
| 2357 | 2357 | ||
| 2358 | IrInstruction *fn_ref; | 2358 | IrInstruction *fn_ref; |
| 2359 | FnTableEntry *fn_entry; | 2359 | ZigFn *fn_entry; |
| 2360 | size_t arg_count; | 2360 | size_t arg_count; |
| 2361 | IrInstruction **args; | 2361 | IrInstruction **args; |
| 2362 | bool is_comptime; | 2362 | bool is_comptime; |
src/analyze.cpp+26-26| ... | @@ -25,7 +25,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type); | ... | @@ -25,7 +25,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type); |
| 25 | static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type); | 25 | static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type); |
| 26 | static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type); | 26 | static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type); |
| 27 | static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type); | 27 | static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type); |
| 28 | static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry); | 28 | static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry); |
| 29 | 29 | ||
| 30 | ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) { | 30 | ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) { |
| 31 | if (node->owner->c_import_node != nullptr) { | 31 | if (node->owner->c_import_node != nullptr) { |
| ... | @@ -171,7 +171,7 @@ ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) { | ... | @@ -171,7 +171,7 @@ ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) { |
| 171 | return scope; | 171 | return scope; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry) { | 174 | ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry) { |
| 175 | ScopeFnDef *scope = allocate<ScopeFnDef>(1); | 175 | ScopeFnDef *scope = allocate<ScopeFnDef>(1); |
| 176 | init_scope(&scope->base, ScopeIdFnDef, node, parent); | 176 | init_scope(&scope->base, ScopeIdFnDef, node, parent); |
| 177 | scope->fn_entry = fn_entry; | 177 | scope->fn_entry = fn_entry; |
| ... | @@ -991,7 +991,7 @@ ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const c | ... | @@ -991,7 +991,7 @@ ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const c |
| 991 | return entry; | 991 | return entry; |
| 992 | } | 992 | } |
| 993 | 993 | ||
| 994 | ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) { | 994 | ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry) { |
| 995 | ZigType *fn_type = fn_entry->type_entry; | 995 | ZigType *fn_type = fn_entry->type_entry; |
| 996 | assert(fn_type->id == TypeTableEntryIdFn); | 996 | assert(fn_type->id == TypeTableEntryIdFn); |
| 997 | if (fn_type->data.fn.bound_fn_parent) | 997 | if (fn_type->data.fn.bound_fn_parent) |
| ... | @@ -1485,7 +1485,7 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { | ... | @@ -1485,7 +1485,7 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { |
| 1485 | zig_unreachable(); | 1485 | zig_unreachable(); |
| 1486 | } | 1486 | } |
| 1487 | 1487 | ||
| 1488 | ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) { | 1488 | ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) { |
| 1489 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); | 1489 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); |
| 1490 | buf_resize(&err_set_type->name, 0); | 1490 | buf_resize(&err_set_type->name, 0); |
| 1491 | buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name)); | 1491 | 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) { | ... | @@ -1501,7 +1501,7 @@ ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) { |
| 1501 | return err_set_type; | 1501 | return err_set_type; |
| 1502 | } | 1502 | } |
| 1503 | 1503 | ||
| 1504 | static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) { | 1504 | static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry) { |
| 1505 | assert(proto_node->type == NodeTypeFnProto); | 1505 | assert(proto_node->type == NodeTypeFnProto); |
| 1506 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; | 1506 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; |
| 1507 | Error err; | 1507 | Error err; |
| ... | @@ -3038,8 +3038,8 @@ static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, uint8_t sep) { | ... | @@ -3038,8 +3038,8 @@ static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, uint8_t sep) { |
| 3038 | buf_append_buf(buf, tld->name); | 3038 | buf_append_buf(buf, tld->name); |
| 3039 | } | 3039 | } |
| 3040 | 3040 | ||
| 3041 | FnTableEntry *create_fn_raw(FnInline inline_value) { | 3041 | ZigFn *create_fn_raw(FnInline inline_value) { |
| 3042 | FnTableEntry *fn_entry = allocate<FnTableEntry>(1); | 3042 | ZigFn *fn_entry = allocate<ZigFn>(1); |
| 3043 | 3043 | ||
| 3044 | fn_entry->analyzed_executable.backward_branch_count = &fn_entry->prealloc_bbc; | 3044 | fn_entry->analyzed_executable.backward_branch_count = &fn_entry->prealloc_bbc; |
| 3045 | fn_entry->analyzed_executable.backward_branch_quota = default_backward_branch_quota; | 3045 | fn_entry->analyzed_executable.backward_branch_quota = default_backward_branch_quota; |
| ... | @@ -3050,12 +3050,12 @@ FnTableEntry *create_fn_raw(FnInline inline_value) { | ... | @@ -3050,12 +3050,12 @@ FnTableEntry *create_fn_raw(FnInline inline_value) { |
| 3050 | return fn_entry; | 3050 | return fn_entry; |
| 3051 | } | 3051 | } |
| 3052 | 3052 | ||
| 3053 | FnTableEntry *create_fn(AstNode *proto_node) { | 3053 | ZigFn *create_fn(AstNode *proto_node) { |
| 3054 | assert(proto_node->type == NodeTypeFnProto); | 3054 | assert(proto_node->type == NodeTypeFnProto); |
| 3055 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; | 3055 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; |
| 3056 | 3056 | ||
| 3057 | FnInline inline_value = fn_proto->is_inline ? FnInlineAlways : FnInlineAuto; | 3057 | 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); |
| 3059 | 3059 | ||
| 3060 | fn_entry->proto_node = proto_node; | 3060 | fn_entry->proto_node = proto_node; |
| 3061 | fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : | 3061 | 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 | ... | @@ -3081,7 +3081,7 @@ static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, ZigType *fn_t |
| 3081 | buf_ptr(&fn_type->name))); | 3081 | buf_ptr(&fn_type->name))); |
| 3082 | } | 3082 | } |
| 3083 | 3083 | ||
| 3084 | static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) { | 3084 | static void typecheck_panic_fn(CodeGen *g, ZigFn *panic_fn) { |
| 3085 | AstNode *proto_node = panic_fn->proto_node; | 3085 | AstNode *proto_node = panic_fn->proto_node; |
| 3086 | assert(proto_node->type == NodeTypeFnProto); | 3086 | assert(proto_node->type == NodeTypeFnProto); |
| 3087 | ZigType *fn_type = panic_fn->type_entry; | 3087 | ZigType *fn_type = panic_fn->type_entry; |
| ... | @@ -3118,7 +3118,7 @@ ZigType *get_test_fn_type(CodeGen *g) { | ... | @@ -3118,7 +3118,7 @@ ZigType *get_test_fn_type(CodeGen *g) { |
| 3118 | return g->test_fn_type; | 3118 | return g->test_fn_type; |
| 3119 | } | 3119 | } |
| 3120 | 3120 | ||
| 3121 | void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) { | 3121 | void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) { |
| 3122 | if (ccc) { | 3122 | if (ccc) { |
| 3123 | if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) { | 3123 | if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) { |
| 3124 | g->have_c_main = true; | 3124 | g->have_c_main = true; |
| ... | @@ -3154,7 +3154,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { | ... | @@ -3154,7 +3154,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3154 | 3154 | ||
| 3155 | AstNode *fn_def_node = fn_proto->fn_def_node; | 3155 | AstNode *fn_def_node = fn_proto->fn_def_node; |
| 3156 | 3156 | ||
| 3157 | FnTableEntry *fn_table_entry = create_fn(source_node); | 3157 | ZigFn *fn_table_entry = create_fn(source_node); |
| 3158 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); | 3158 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); |
| 3159 | 3159 | ||
| 3160 | if (fn_proto->is_export) { | 3160 | if (fn_proto->is_export) { |
| ... | @@ -3215,7 +3215,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { | ... | @@ -3215,7 +3215,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3215 | } | 3215 | } |
| 3216 | } | 3216 | } |
| 3217 | } else if (source_node->type == NodeTypeTestDecl) { | 3217 | } else if (source_node->type == NodeTypeTestDecl) { |
| 3218 | FnTableEntry *fn_table_entry = create_fn_raw(FnInlineAuto); | 3218 | ZigFn *fn_table_entry = create_fn_raw(FnInlineAuto); |
| 3219 | 3219 | ||
| 3220 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); | 3220 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); |
| 3221 | 3221 | ||
| ... | @@ -3750,7 +3750,7 @@ VariableTableEntry *find_variable(CodeGen *g, Scope *scope, Buf *name) { | ... | @@ -3750,7 +3750,7 @@ VariableTableEntry *find_variable(CodeGen *g, Scope *scope, Buf *name) { |
| 3750 | return nullptr; | 3750 | return nullptr; |
| 3751 | } | 3751 | } |
| 3752 | 3752 | ||
| 3753 | FnTableEntry *scope_fn_entry(Scope *scope) { | 3753 | ZigFn *scope_fn_entry(Scope *scope) { |
| 3754 | while (scope) { | 3754 | while (scope) { |
| 3755 | if (scope->id == ScopeIdFnDef) { | 3755 | if (scope->id == ScopeIdFnDef) { |
| 3756 | ScopeFnDef *fn_scope = (ScopeFnDef *)scope; | 3756 | ScopeFnDef *fn_scope = (ScopeFnDef *)scope; |
| ... | @@ -3761,7 +3761,7 @@ FnTableEntry *scope_fn_entry(Scope *scope) { | ... | @@ -3761,7 +3761,7 @@ FnTableEntry *scope_fn_entry(Scope *scope) { |
| 3761 | return nullptr; | 3761 | return nullptr; |
| 3762 | } | 3762 | } |
| 3763 | 3763 | ||
| 3764 | FnTableEntry *scope_get_fn_if_root(Scope *scope) { | 3764 | ZigFn *scope_get_fn_if_root(Scope *scope) { |
| 3765 | assert(scope); | 3765 | assert(scope); |
| 3766 | scope = scope->parent; | 3766 | scope = scope->parent; |
| 3767 | while (scope) { | 3767 | while (scope) { |
| ... | @@ -3981,7 +3981,7 @@ bool get_ptr_const(ZigType *type) { | ... | @@ -3981,7 +3981,7 @@ bool get_ptr_const(ZigType *type) { |
| 3981 | } | 3981 | } |
| 3982 | } | 3982 | } |
| 3983 | 3983 | ||
| 3984 | AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) { | 3984 | AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index) { |
| 3985 | if (fn_entry->param_source_nodes) | 3985 | if (fn_entry->param_source_nodes) |
| 3986 | return fn_entry->param_source_nodes[index]; | 3986 | return fn_entry->param_source_nodes[index]; |
| 3987 | else if (fn_entry->proto_node) | 3987 | else if (fn_entry->proto_node) |
| ... | @@ -3990,7 +3990,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) { | ... | @@ -3990,7 +3990,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) { |
| 3990 | return nullptr; | 3990 | return nullptr; |
| 3991 | } | 3991 | } |
| 3992 | 3992 | ||
| 3993 | static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) { | 3993 | static void define_local_param_variables(CodeGen *g, ZigFn *fn_table_entry) { |
| 3994 | ZigType *fn_type = fn_table_entry->type_entry; | 3994 | ZigType *fn_type = fn_table_entry->type_entry; |
| 3995 | assert(!fn_type->data.fn.is_generic); | 3995 | assert(!fn_type->data.fn.is_generic); |
| 3996 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 3996 | 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 | ... | @@ -4032,7 +4032,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr |
| 4032 | } | 4032 | } |
| 4033 | 4033 | ||
| 4034 | bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) { | 4034 | bool 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; |
| 4036 | if (infer_fn != nullptr) { | 4036 | if (infer_fn != nullptr) { |
| 4037 | if (infer_fn->anal_state == FnAnalStateInvalid) { | 4037 | if (infer_fn->anal_state == FnAnalStateInvalid) { |
| 4038 | return false; | 4038 | return false; |
| ... | @@ -4052,7 +4052,7 @@ bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *sour | ... | @@ -4052,7 +4052,7 @@ bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *sour |
| 4052 | return true; | 4052 | return true; |
| 4053 | } | 4053 | } |
| 4054 | 4054 | ||
| 4055 | void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) { | 4055 | void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node) { |
| 4056 | ZigType *fn_type = fn_table_entry->type_entry; | 4056 | ZigType *fn_type = fn_table_entry->type_entry; |
| 4057 | assert(!fn_type->data.fn.is_generic); | 4057 | assert(!fn_type->data.fn.is_generic); |
| 4058 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 4058 | 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 | ... | @@ -4113,7 +4113,7 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ |
| 4113 | fn_table_entry->anal_state = FnAnalStateComplete; | 4113 | fn_table_entry->anal_state = FnAnalStateComplete; |
| 4114 | } | 4114 | } |
| 4115 | 4115 | ||
| 4116 | static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { | 4116 | static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { |
| 4117 | assert(fn_table_entry->anal_state != FnAnalStateProbing); | 4117 | assert(fn_table_entry->anal_state != FnAnalStateProbing); |
| 4118 | if (fn_table_entry->anal_state != FnAnalStateReady) | 4118 | if (fn_table_entry->anal_state != FnAnalStateReady) |
| 4119 | return; | 4119 | return; |
| ... | @@ -4349,7 +4349,7 @@ void semantic_analyze(CodeGen *g) { | ... | @@ -4349,7 +4349,7 @@ void semantic_analyze(CodeGen *g) { |
| 4349 | } | 4349 | } |
| 4350 | 4350 | ||
| 4351 | for (; g->fn_defs_index < g->fn_defs.length; g->fn_defs_index += 1) { | 4351 | 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); |
| 4353 | analyze_fn_body(g, fn_entry); | 4353 | analyze_fn_body(g, fn_entry); |
| 4354 | } | 4354 | } |
| 4355 | } | 4355 | } |
| ... | @@ -4602,11 +4602,11 @@ static uint32_t hash_size(size_t x) { | ... | @@ -4602,11 +4602,11 @@ static uint32_t hash_size(size_t x) { |
| 4602 | return (uint32_t)(x % UINT32_MAX); | 4602 | return (uint32_t)(x % UINT32_MAX); |
| 4603 | } | 4603 | } |
| 4604 | 4604 | ||
| 4605 | uint32_t fn_table_entry_hash(FnTableEntry* value) { | 4605 | uint32_t fn_table_entry_hash(ZigFn* value) { |
| 4606 | return ptr_hash(value); | 4606 | return ptr_hash(value); |
| 4607 | } | 4607 | } |
| 4608 | 4608 | ||
| 4609 | bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) { | 4609 | bool fn_table_entry_eql(ZigFn *a, ZigFn *b) { |
| 4610 | return ptr_eq(a, b); | 4610 | return ptr_eq(a, b); |
| 4611 | } | 4611 | } |
| 4612 | 4612 | ||
| ... | @@ -5669,7 +5669,7 @@ void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigTy | ... | @@ -5669,7 +5669,7 @@ void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigTy |
| 5669 | return; | 5669 | return; |
| 5670 | case ConstPtrSpecialFunction: | 5670 | case ConstPtrSpecialFunction: |
| 5671 | { | 5671 | { |
| 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; |
| 5673 | buf_appendf(buf, "@ptrCast(%s, %s)", buf_ptr(&const_val->type->name), buf_ptr(&fn_entry->symbol_name)); | 5673 | buf_appendf(buf, "@ptrCast(%s, %s)", buf_ptr(&const_val->type->name), buf_ptr(&fn_entry->symbol_name)); |
| 5674 | return; | 5674 | return; |
| 5675 | } | 5675 | } |
| ... | @@ -5751,7 +5751,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { | ... | @@ -5751,7 +5751,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { |
| 5751 | { | 5751 | { |
| 5752 | assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst); | 5752 | assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst); |
| 5753 | assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction); | 5753 | 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; |
| 5755 | buf_appendf(buf, "%s", buf_ptr(&fn_entry->symbol_name)); | 5755 | buf_appendf(buf, "%s", buf_ptr(&fn_entry->symbol_name)); |
| 5756 | return; | 5756 | return; |
| 5757 | } | 5757 | } |
| ... | @@ -5837,7 +5837,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { | ... | @@ -5837,7 +5837,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { |
| 5837 | } | 5837 | } |
| 5838 | case TypeTableEntryIdBoundFn: | 5838 | case TypeTableEntryIdBoundFn: |
| 5839 | { | 5839 | { |
| 5840 | FnTableEntry *fn_entry = const_val->data.x_bound_fn.fn; | 5840 | ZigFn *fn_entry = const_val->data.x_bound_fn.fn; |
| 5841 | buf_appendf(buf, "(bound fn %s)", buf_ptr(&fn_entry->symbol_name)); | 5841 | buf_appendf(buf, "(bound fn %s)", buf_ptr(&fn_entry->symbol_name)); |
| 5842 | return; | 5842 | return; |
| 5843 | } | 5843 | } |
src/analyze.hpp+10-10| ... | @@ -31,7 +31,7 @@ ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind | ... | @@ -31,7 +31,7 @@ ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind |
| 31 | AstNode *decl_node, const char *name, ContainerLayout layout); | 31 | AstNode *decl_node, const char *name, ContainerLayout layout); |
| 32 | ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x); | 32 | ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x); |
| 33 | ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type); | 33 | ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type); |
| 34 | ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry); | 34 | ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry); |
| 35 | ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name); | 35 | ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name); |
| 36 | ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[], | 36 | ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[], |
| 37 | ZigType *field_types[], size_t field_count); | 37 | ZigType *field_types[], size_t field_count); |
| ... | @@ -77,17 +77,17 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node); | ... | @@ -77,17 +77,17 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node); |
| 77 | void scan_import(CodeGen *g, ImportTableEntry *import); | 77 | void scan_import(CodeGen *g, ImportTableEntry *import); |
| 78 | void preview_use_decl(CodeGen *g, AstNode *node); | 78 | void preview_use_decl(CodeGen *g, AstNode *node); |
| 79 | void resolve_use_decl(CodeGen *g, AstNode *node); | 79 | void resolve_use_decl(CodeGen *g, AstNode *node); |
| 80 | FnTableEntry *scope_fn_entry(Scope *scope); | 80 | ZigFn *scope_fn_entry(Scope *scope); |
| 81 | ImportTableEntry *get_scope_import(Scope *scope); | 81 | ImportTableEntry *get_scope_import(Scope *scope); |
| 82 | void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope); | 82 | void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope); |
| 83 | VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name, | 83 | VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name, |
| 84 | bool is_const, ConstExprValue *init_value, Tld *src_tld); | 84 | bool is_const, ConstExprValue *init_value, Tld *src_tld); |
| 85 | ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node); | 85 | ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node); |
| 86 | FnTableEntry *create_fn(AstNode *proto_node); | 86 | ZigFn *create_fn(AstNode *proto_node); |
| 87 | FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage); | 87 | ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage); |
| 88 | void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc); | 88 | void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc); |
| 89 | AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index); | 89 | AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index); |
| 90 | FnTableEntry *scope_get_fn_if_root(Scope *scope); | 90 | ZigFn *scope_get_fn_if_root(Scope *scope); |
| 91 | bool type_requires_comptime(ZigType *type_entry); | 91 | bool type_requires_comptime(ZigType *type_entry); |
| 92 | Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry); | 92 | Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry); |
| 93 | Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry); | 93 | 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 | ... | @@ -98,7 +98,7 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v |
| 98 | void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max); | 98 | void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max); |
| 99 | 99 | ||
| 100 | void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val); | 100 | void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val); |
| 101 | void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node); | 101 | void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node); |
| 102 | 102 | ||
| 103 | ScopeBlock *create_block_scope(AstNode *node, Scope *parent); | 103 | ScopeBlock *create_block_scope(AstNode *node, Scope *parent); |
| 104 | ScopeDefer *create_defer_scope(AstNode *node, Scope *parent); | 104 | ScopeDefer *create_defer_scope(AstNode *node, Scope *parent); |
| ... | @@ -107,7 +107,7 @@ Scope *create_var_scope(AstNode *node, Scope *parent, VariableTableEntry *var); | ... | @@ -107,7 +107,7 @@ Scope *create_var_scope(AstNode *node, Scope *parent, VariableTableEntry *var); |
| 107 | ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent); | 107 | ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent); |
| 108 | ScopeLoop *create_loop_scope(AstNode *node, Scope *parent); | 108 | ScopeLoop *create_loop_scope(AstNode *node, Scope *parent); |
| 109 | ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent); | 109 | ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent); |
| 110 | ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry); | 110 | ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, ZigFn *fn_entry); |
| 111 | ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import); | 111 | ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import); |
| 112 | Scope *create_comptime_scope(AstNode *node, Scope *parent); | 112 | Scope *create_comptime_scope(AstNode *node, Scope *parent); |
| 113 | Scope *create_coro_prelude_scope(AstNode *node, Scope *parent); | 113 | Scope *create_coro_prelude_scope(AstNode *node, Scope *parent); |
| ... | @@ -190,14 +190,14 @@ ZigType *get_align_amt_type(CodeGen *g); | ... | @@ -190,14 +190,14 @@ ZigType *get_align_amt_type(CodeGen *g); |
| 190 | PackageTableEntry *new_anonymous_package(void); | 190 | PackageTableEntry *new_anonymous_package(void); |
| 191 | 191 | ||
| 192 | Buf *const_value_to_buffer(ConstExprValue *const_val); | 192 | Buf *const_value_to_buffer(ConstExprValue *const_val); |
| 193 | void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc); | 193 | void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc); |
| 194 | 194 | ||
| 195 | 195 | ||
| 196 | ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name); | 196 | ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name); |
| 197 | ZigType *get_ptr_to_stack_trace_type(CodeGen *g); | 197 | ZigType *get_ptr_to_stack_trace_type(CodeGen *g); |
| 198 | bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node); | 198 | bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node); |
| 199 | 199 | ||
| 200 | ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry); | 200 | ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry); |
| 201 | 201 | ||
| 202 | uint32_t get_coro_frame_align_bytes(CodeGen *g); | 202 | uint32_t get_coro_frame_align_bytes(CodeGen *g); |
| 203 | bool fn_type_can_fail(FnTypeId *fn_type_id); | 203 | bool fn_type_can_fail(FnTypeId *fn_type_id); |
src/codegen.cpp+11-11| ... | @@ -430,7 +430,7 @@ static LLVMLinkage to_llvm_linkage(GlobalLinkageId id) { | ... | @@ -430,7 +430,7 @@ static LLVMLinkage to_llvm_linkage(GlobalLinkageId id) { |
| 430 | zig_unreachable(); | 430 | zig_unreachable(); |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_entry) { | 433 | static uint32_t get_err_ret_trace_arg_index(CodeGen *g, ZigFn *fn_table_entry) { |
| 434 | if (!g->have_err_ret_tracing) { | 434 | if (!g->have_err_ret_tracing) { |
| 435 | return UINT32_MAX; | 435 | return UINT32_MAX; |
| 436 | } | 436 | } |
| ... | @@ -446,7 +446,7 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e | ... | @@ -446,7 +446,7 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e |
| 446 | return first_arg_ret ? 1 : 0; | 446 | return first_arg_ret ? 1 : 0; |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { | 449 | static LLVMValueRef fn_llvm_value(CodeGen *g, ZigFn *fn_table_entry) { |
| 450 | if (fn_table_entry->llvm_value) | 450 | if (fn_table_entry->llvm_value) |
| 451 | return fn_table_entry->llvm_value; | 451 | return fn_table_entry->llvm_value; |
| 452 | 452 | ||
| ... | @@ -628,7 +628,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { | ... | @@ -628,7 +628,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { |
| 628 | { | 628 | { |
| 629 | assert(scope->parent); | 629 | assert(scope->parent); |
| 630 | ScopeFnDef *fn_scope = (ScopeFnDef *)scope; | 630 | ScopeFnDef *fn_scope = (ScopeFnDef *)scope; |
| 631 | FnTableEntry *fn_table_entry = fn_scope->fn_entry; | 631 | ZigFn *fn_table_entry = fn_scope->fn_entry; |
| 632 | if (!fn_table_entry->proto_node) | 632 | if (!fn_table_entry->proto_node) |
| 633 | return get_di_scope(g, scope->parent); | 633 | return get_di_scope(g, scope->parent); |
| 634 | unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ? | 634 | 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) { | ... | @@ -3637,7 +3637,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { |
| 3637 | 3637 | ||
| 3638 | LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); | 3638 | LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); |
| 3639 | LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); | 3639 | LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); |
| 3640 | FnTableEntry *prev_cur_fn = g->cur_fn; | 3640 | ZigFn *prev_cur_fn = g->cur_fn; |
| 3641 | LLVMValueRef prev_cur_fn_val = g->cur_fn_val; | 3641 | LLVMValueRef prev_cur_fn_val = g->cur_fn_val; |
| 3642 | 3642 | ||
| 3643 | LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); | 3643 | LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); |
| ... | @@ -4635,7 +4635,7 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f | ... | @@ -4635,7 +4635,7 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f |
| 4635 | 4635 | ||
| 4636 | LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); | 4636 | LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); |
| 4637 | LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); | 4637 | LLVMValueRef prev_debug_location = LLVMGetCurrentDebugLocation(g->builder); |
| 4638 | FnTableEntry *prev_cur_fn = g->cur_fn; | 4638 | ZigFn *prev_cur_fn = g->cur_fn; |
| 4639 | LLVMValueRef prev_cur_fn_val = g->cur_fn_val; | 4639 | LLVMValueRef prev_cur_fn_val = g->cur_fn_val; |
| 4640 | 4640 | ||
| 4641 | LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); | 4641 | LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); |
| ... | @@ -5037,7 +5037,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, | ... | @@ -5037,7 +5037,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, |
| 5037 | zig_unreachable(); | 5037 | zig_unreachable(); |
| 5038 | } | 5038 | } |
| 5039 | 5039 | ||
| 5040 | static void ir_render(CodeGen *g, FnTableEntry *fn_entry) { | 5040 | static void ir_render(CodeGen *g, ZigFn *fn_entry) { |
| 5041 | assert(fn_entry); | 5041 | assert(fn_entry); |
| 5042 | 5042 | ||
| 5043 | IrExecutable *executable = &fn_entry->analyzed_executable; | 5043 | IrExecutable *executable = &fn_entry->analyzed_executable; |
| ... | @@ -5688,7 +5688,7 @@ static void generate_error_name_table(CodeGen *g) { | ... | @@ -5688,7 +5688,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 5688 | LLVMSetAlignment(g->err_name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(err_name_table_init))); | 5688 | LLVMSetAlignment(g->err_name_table, LLVMABIAlignmentOfType(g->target_data_ref, LLVMTypeOf(err_name_table_init))); |
| 5689 | } | 5689 | } |
| 5690 | 5690 | ||
| 5691 | static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) { | 5691 | static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) { |
| 5692 | IrExecutable *executable = &fn->analyzed_executable; | 5692 | IrExecutable *executable = &fn->analyzed_executable; |
| 5693 | assert(executable->basic_block_list.length > 0); | 5693 | assert(executable->basic_block_list.length > 0); |
| 5694 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { | 5694 | 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) { | ... | @@ -5747,7 +5747,7 @@ static void report_errors_and_maybe_exit(CodeGen *g) { |
| 5747 | 5747 | ||
| 5748 | static void validate_inline_fns(CodeGen *g) { | 5748 | static void validate_inline_fns(CodeGen *g) { |
| 5749 | for (size_t i = 0; i < g->inline_fns.length; i += 1) { | 5749 | 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); |
| 5751 | LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name); | 5751 | LLVMValueRef fn_val = LLVMGetNamedFunction(g->module, fn_entry->llvm_name); |
| 5752 | if (fn_val != nullptr) { | 5752 | if (fn_val != nullptr) { |
| 5753 | add_node_error(g, fn_entry->proto_node, buf_sprintf("unable to inline function")); | 5753 | 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) { | ... | @@ -5864,7 +5864,7 @@ static void do_code_gen(CodeGen *g) { |
| 5864 | 5864 | ||
| 5865 | // Generate function definitions. | 5865 | // Generate function definitions. |
| 5866 | for (size_t fn_i = 0; fn_i < g->fn_defs.length; fn_i += 1) { | 5866 | 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); |
| 5868 | 5868 | ||
| 5869 | LLVMValueRef fn = fn_llvm_value(g, fn_table_entry); | 5869 | LLVMValueRef fn = fn_llvm_value(g, fn_table_entry); |
| 5870 | g->cur_fn = fn_table_entry; | 5870 | g->cur_fn = fn_table_entry; |
| ... | @@ -7083,7 +7083,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) { | ... | @@ -7083,7 +7083,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) { |
| 7083 | test_fn_array->data.x_array.s_none.elements = create_const_vals(g->test_fns.length); | 7083 | test_fn_array->data.x_array.s_none.elements = create_const_vals(g->test_fns.length); |
| 7084 | 7084 | ||
| 7085 | for (size_t i = 0; i < g->test_fns.length; i += 1) { | 7085 | 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); |
| 7087 | 7087 | ||
| 7088 | ConstExprValue *this_val = &test_fn_array->data.x_array.s_none.elements[i]; | 7088 | ConstExprValue *this_val = &test_fn_array->data.x_array.s_none.elements[i]; |
| 7089 | this_val->special = ConstValSpecialStatic; | 7089 | this_val->special = ConstValSpecialStatic; |
| ... | @@ -7483,7 +7483,7 @@ static void gen_h_file(CodeGen *g) { | ... | @@ -7483,7 +7483,7 @@ static void gen_h_file(CodeGen *g) { |
| 7483 | Buf h_buf = BUF_INIT; | 7483 | Buf h_buf = BUF_INIT; |
| 7484 | buf_resize(&h_buf, 0); | 7484 | buf_resize(&h_buf, 0); |
| 7485 | for (size_t fn_def_i = 0; fn_def_i < g->fn_defs.length; fn_def_i += 1) { | 7485 | 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); |
| 7487 | 7487 | ||
| 7488 | if (fn_table_entry->export_list.length == 0) | 7488 | if (fn_table_entry->export_list.length == 0) |
| 7489 | continue; | 7489 | continue; |
src/ir.cpp+48-48| ... | @@ -236,7 +236,7 @@ static size_t exec_next_mem_slot(IrExecutable *exec) { | ... | @@ -236,7 +236,7 @@ static size_t exec_next_mem_slot(IrExecutable *exec) { |
| 236 | return result; | 236 | return result; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | static FnTableEntry *exec_fn_entry(IrExecutable *exec) { | 239 | static ZigFn *exec_fn_entry(IrExecutable *exec) { |
| 240 | return exec->fn_entry; | 240 | return exec->fn_entry; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| ... | @@ -1019,7 +1019,7 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1019,7 +1019,7 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode |
| 1019 | return instruction; | 1019 | return instruction; |
| 1020 | } | 1020 | } |
| 1021 | 1021 | ||
| 1022 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) { | 1022 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { |
| 1023 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1023 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1024 | const_instruction->base.value.type = fn_entry->type_entry; | 1024 | const_instruction->base.value.type = fn_entry->type_entry; |
| 1025 | const_instruction->base.value.special = ConstValSpecialStatic; | 1025 | const_instruction->base.value.special = ConstValSpecialStatic; |
| ... | @@ -1029,7 +1029,7 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1029,7 +1029,7 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode * |
| 1029 | return &const_instruction->base; | 1029 | return &const_instruction->base; |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, FnTableEntry *fn_entry) { | 1032 | static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { |
| 1033 | IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry); | 1033 | IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry); |
| 1034 | ir_instruction_append(irb->current_basic_block, instruction); | 1034 | ir_instruction_append(irb->current_basic_block, instruction); |
| 1035 | return instruction; | 1035 | return instruction; |
| ... | @@ -1062,7 +1062,7 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1062,7 +1062,7 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode |
| 1062 | } | 1062 | } |
| 1063 | 1063 | ||
| 1064 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1064 | static 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) |
| 1066 | { | 1066 | { |
| 1067 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1067 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1068 | const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); | 1068 | 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 | ... | @@ -1199,7 +1199,7 @@ static IrInstruction *ir_build_union_field_ptr_from(IrBuilder *irb, IrInstructio |
| 1199 | } | 1199 | } |
| 1200 | 1200 | ||
| 1201 | static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1201 | static 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, |
| 1203 | bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, | 1203 | bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, |
| 1204 | IrInstruction *new_stack) | 1204 | IrInstruction *new_stack) |
| 1205 | { | 1205 | { |
| ... | @@ -1227,7 +1227,7 @@ static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *sourc | ... | @@ -1227,7 +1227,7 @@ static IrInstruction *ir_build_call(IrBuilder *irb, Scope *scope, AstNode *sourc |
| 1227 | } | 1227 | } |
| 1228 | 1228 | ||
| 1229 | static IrInstruction *ir_build_call_from(IrBuilder *irb, IrInstruction *old_instruction, | 1229 | static 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, |
| 1231 | bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, | 1231 | bool is_comptime, FnInline fn_inline, bool is_async, IrInstruction *async_allocator, |
| 1232 | IrInstruction *new_stack) | 1232 | IrInstruction *new_stack) |
| 1233 | { | 1233 | { |
| ... | @@ -3138,7 +3138,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { | ... | @@ -3138,7 +3138,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { |
| 3138 | } | 3138 | } |
| 3139 | 3139 | ||
| 3140 | static bool exec_is_async(IrExecutable *exec) { | 3140 | static bool exec_is_async(IrExecutable *exec) { |
| 3141 | FnTableEntry *fn_entry = exec_fn_entry(exec); | 3141 | ZigFn *fn_entry = exec_fn_entry(exec); |
| 3142 | return fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; | 3142 | return fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; |
| 3143 | } | 3143 | } |
| 3144 | 3144 | ||
| ... | @@ -3200,7 +3200,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3200,7 +3200,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode |
| 3200 | static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { | 3200 | static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { |
| 3201 | assert(node->type == NodeTypeReturnExpr); | 3201 | assert(node->type == NodeTypeReturnExpr); |
| 3202 | 3202 | ||
| 3203 | FnTableEntry *fn_entry = exec_fn_entry(irb->exec); | 3203 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 3204 | if (!fn_entry) { | 3204 | if (!fn_entry) { |
| 3205 | add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition")); | 3205 | add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition")); |
| 3206 | return irb->codegen->invalid_instruction; | 3206 | return irb->codegen->invalid_instruction; |
| ... | @@ -3224,7 +3224,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -3224,7 +3224,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 3224 | IrInstruction *return_value; | 3224 | IrInstruction *return_value; |
| 3225 | if (expr_node) { | 3225 | if (expr_node) { |
| 3226 | // Temporarily set this so that if we return a type it gets the name of the function | 3226 | // 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; |
| 3228 | irb->exec->name_fn = exec_fn_entry(irb->exec); | 3228 | irb->exec->name_fn = exec_fn_entry(irb->exec); |
| 3229 | return_value = ir_gen_node(irb, expr_node, scope); | 3229 | return_value = ir_gen_node(irb, expr_node, scope); |
| 3230 | irb->exec->name_fn = prev_name_fn; | 3230 | irb->exec->name_fn = prev_name_fn; |
| ... | @@ -3403,7 +3403,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -3403,7 +3403,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 3403 | Scope *outer_block_scope = &scope_block->base; | 3403 | Scope *outer_block_scope = &scope_block->base; |
| 3404 | Scope *child_scope = outer_block_scope; | 3404 | Scope *child_scope = outer_block_scope; |
| 3405 | 3405 | ||
| 3406 | FnTableEntry *fn_entry = scope_fn_entry(parent_scope); | 3406 | ZigFn *fn_entry = scope_fn_entry(parent_scope); |
| 3407 | if (fn_entry && fn_entry->child_scope == parent_scope) { | 3407 | if (fn_entry && fn_entry->child_scope == parent_scope) { |
| 3408 | fn_entry->def_scope = scope_block; | 3408 | fn_entry->def_scope = scope_block; |
| 3409 | } | 3409 | } |
| ... | @@ -5686,7 +5686,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -5686,7 +5686,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode |
| 5686 | if (!scope->parent) | 5686 | if (!scope->parent) |
| 5687 | return ir_build_const_import(irb, scope, node, node->owner); | 5687 | return ir_build_const_import(irb, scope, node, node->owner); |
| 5688 | 5688 | ||
| 5689 | FnTableEntry *fn_entry = scope_get_fn_if_root(scope); | 5689 | ZigFn *fn_entry = scope_get_fn_if_root(scope); |
| 5690 | if (fn_entry) | 5690 | if (fn_entry) |
| 5691 | return ir_build_const_fn(irb, scope, node, fn_entry); | 5691 | return ir_build_const_fn(irb, scope, node, fn_entry); |
| 5692 | 5692 | ||
| ... | @@ -6913,7 +6913,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6913,7 +6913,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6913 | if (target_inst == irb->codegen->invalid_instruction) | 6913 | if (target_inst == irb->codegen->invalid_instruction) |
| 6914 | return irb->codegen->invalid_instruction; | 6914 | return irb->codegen->invalid_instruction; |
| 6915 | 6915 | ||
| 6916 | FnTableEntry *fn_entry = exec_fn_entry(irb->exec); | 6916 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 6917 | if (!fn_entry) { | 6917 | if (!fn_entry) { |
| 6918 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); | 6918 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); |
| 6919 | return irb->codegen->invalid_instruction; | 6919 | return irb->codegen->invalid_instruction; |
| ... | @@ -7090,7 +7090,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7090,7 +7090,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7090 | static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 7090 | static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) { |
| 7091 | assert(node->type == NodeTypeSuspend); | 7091 | assert(node->type == NodeTypeSuspend); |
| 7092 | 7092 | ||
| 7093 | FnTableEntry *fn_entry = exec_fn_entry(irb->exec); | 7093 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 7094 | if (!fn_entry) { | 7094 | if (!fn_entry) { |
| 7095 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); | 7095 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); |
| 7096 | return irb->codegen->invalid_instruction; | 7096 | return irb->codegen->invalid_instruction; |
| ... | @@ -7379,7 +7379,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -7379,7 +7379,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 7379 | // Entry block gets a reference because we enter it to begin. | 7379 | // Entry block gets a reference because we enter it to begin. |
| 7380 | ir_ref_bb(irb->current_basic_block); | 7380 | ir_ref_bb(irb->current_basic_block); |
| 7381 | 7381 | ||
| 7382 | FnTableEntry *fn_entry = exec_fn_entry(irb->exec); | 7382 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 7383 | bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; | 7383 | bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; |
| 7384 | IrInstruction *coro_id; | 7384 | IrInstruction *coro_id; |
| 7385 | IrInstruction *u8_ptr_type; | 7385 | IrInstruction *u8_ptr_type; |
| ... | @@ -7590,7 +7590,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -7590,7 +7590,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 7590 | return true; | 7590 | return true; |
| 7591 | } | 7591 | } |
| 7592 | 7592 | ||
| 7593 | bool ir_gen_fn(CodeGen *codegen, FnTableEntry *fn_entry) { | 7593 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 7594 | assert(fn_entry); | 7594 | assert(fn_entry); |
| 7595 | 7595 | ||
| 7596 | IrExecutable *ir_executable = &fn_entry->ir_executable; | 7596 | IrExecutable *ir_executable = &fn_entry->ir_executable; |
| ... | @@ -9345,7 +9345,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9345,7 +9345,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9345 | 9345 | ||
| 9346 | static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) { | 9346 | static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) { |
| 9347 | if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) { | 9347 | 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); |
| 9349 | if (fn_entry != nullptr) { | 9349 | if (fn_entry != nullptr) { |
| 9350 | fn_entry->alloca_list.append(instruction); | 9350 | fn_entry->alloca_list.append(instruction); |
| 9351 | } | 9351 | } |
| ... | @@ -9749,7 +9749,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un | ... | @@ -9749,7 +9749,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un |
| 9749 | 9749 | ||
| 9750 | IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 9750 | IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 9751 | ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota, | 9751 | 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, |
| 9753 | IrExecutable *parent_exec) | 9753 | IrExecutable *parent_exec) |
| 9754 | { | 9754 | { |
| 9755 | if (expected_type != nullptr && type_is_invalid(expected_type)) | 9755 | if (expected_type != nullptr && type_is_invalid(expected_type)) |
| ... | @@ -9816,7 +9816,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -9816,7 +9816,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 9816 | return const_val->data.x_type; | 9816 | return const_val->data.x_type; |
| 9817 | } | 9817 | } |
| 9818 | 9818 | ||
| 9819 | static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | 9819 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 9820 | if (fn_value == ira->codegen->invalid_instruction) | 9820 | if (fn_value == ira->codegen->invalid_instruction) |
| 9821 | return nullptr; | 9821 | return nullptr; |
| 9822 | 9822 | ||
| ... | @@ -9996,7 +9996,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -9996,7 +9996,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ |
| 9996 | 9996 | ||
| 9997 | ZigType *child_type = wanted_type->data.pointer.child_type; | 9997 | ZigType *child_type = wanted_type->data.pointer.child_type; |
| 9998 | if (type_has_bits(child_type)) { | 9998 | 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); |
| 10000 | assert(fn_entry); | 10000 | assert(fn_entry); |
| 10001 | fn_entry->alloca_list.append(new_instruction); | 10001 | fn_entry->alloca_list.append(new_instruction); |
| 10002 | } | 10002 | } |
| ... | @@ -10046,7 +10046,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -10046,7 +10046,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 10046 | new_instruction->value.type = ptr_type; | 10046 | new_instruction->value.type = ptr_type; |
| 10047 | new_instruction->value.data.rh_ptr = RuntimeHintPtrStack; | 10047 | new_instruction->value.data.rh_ptr = RuntimeHintPtrStack; |
| 10048 | if (type_has_bits(ptr_type)) { | 10048 | 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); |
| 10050 | assert(fn_entry); | 10050 | assert(fn_entry); |
| 10051 | fn_entry->alloca_list.append(new_instruction); | 10051 | fn_entry->alloca_list.append(new_instruction); |
| 10052 | } | 10052 | } |
| ... | @@ -12644,7 +12644,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec | ... | @@ -12644,7 +12644,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec |
| 12644 | 12644 | ||
| 12645 | ir_build_var_decl_from(&ira->new_irb, &decl_var_instruction->base, var, var_type, nullptr, casted_init_value); | 12645 | ir_build_var_decl_from(&ira->new_irb, &decl_var_instruction->base, var, var_type, nullptr, casted_init_value); |
| 12646 | 12646 | ||
| 12647 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 12647 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 12648 | if (fn_entry) | 12648 | if (fn_entry) |
| 12649 | fn_entry->variable_list.append(var); | 12649 | fn_entry->variable_list.append(var); |
| 12650 | 12650 | ||
| ... | @@ -12685,7 +12685,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12685,7 +12685,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12685 | zig_unreachable(); | 12685 | zig_unreachable(); |
| 12686 | case TypeTableEntryIdFn: { | 12686 | case TypeTableEntryIdFn: { |
| 12687 | assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); | 12687 | 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; |
| 12689 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 12689 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| 12690 | switch (cc) { | 12690 | switch (cc) { |
| 12691 | case CallingConventionUnspecified: { | 12691 | case CallingConventionUnspecified: { |
| ... | @@ -12822,7 +12822,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12822,7 +12822,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12822 | } | 12822 | } |
| 12823 | 12823 | ||
| 12824 | static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) { | 12824 | static 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); |
| 12826 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; | 12826 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; |
| 12827 | } | 12827 | } |
| 12828 | 12828 | ||
| ... | @@ -12878,7 +12878,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -12878,7 +12878,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 12878 | } | 12878 | } |
| 12879 | 12879 | ||
| 12880 | IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_instr, ImplicitAllocatorId id) { | 12880 | IrInstruction *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); |
| 12882 | if (parent_fn_entry == nullptr) { | 12882 | if (parent_fn_entry == nullptr) { |
| 12883 | ir_add_error(ira, source_instr, buf_sprintf("no implicit allocator available")); | 12883 | ir_add_error(ira, source_instr, buf_sprintf("no implicit allocator available")); |
| 12884 | return ira->codegen->invalid_instruction; | 12884 | return ira->codegen->invalid_instruction; |
| ... | @@ -12913,7 +12913,7 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -12913,7 +12913,7 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i |
| 12913 | zig_unreachable(); | 12913 | zig_unreachable(); |
| 12914 | } | 12914 | } |
| 12915 | 12915 | ||
| 12916 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, ZigType *fn_type, | 12916 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, ZigFn *fn_entry, ZigType *fn_type, |
| 12917 | IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst) | 12917 | IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst) |
| 12918 | { | 12918 | { |
| 12919 | Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME); | 12919 | 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 | ... | @@ -12988,7 +12988,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 12988 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 12988 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 12989 | IrInstruction *arg, Scope **child_scope, size_t *next_proto_i, | 12989 | IrInstruction *arg, Scope **child_scope, size_t *next_proto_i, |
| 12990 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args, | 12990 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args, |
| 12991 | FnTableEntry *impl_fn) | 12991 | ZigFn *impl_fn) |
| 12992 | { | 12992 | { |
| 12993 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); | 12993 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 12994 | assert(param_decl_node->type == NodeTypeParamDecl); | 12994 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | @@ -13067,7 +13067,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -13067,7 +13067,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 13067 | return true; | 13067 | return true; |
| 13068 | } | 13068 | } |
| 13069 | 13069 | ||
| 13070 | static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) { | 13070 | static VariableTableEntry *get_fn_var_by_index(ZigFn *fn_entry, size_t index) { |
| 13071 | size_t next_var_i = 0; | 13071 | size_t next_var_i = 0; |
| 13072 | FnGenParamInfo *gen_param_info = fn_entry->type_entry->data.fn.gen_param_info; | 13072 | FnGenParamInfo *gen_param_info = fn_entry->type_entry->data.fn.gen_param_info; |
| 13073 | assert(gen_param_info != nullptr); | 13073 | assert(gen_param_info != nullptr); |
| ... | @@ -13157,7 +13157,7 @@ no_mem_slot: | ... | @@ -13157,7 +13157,7 @@ no_mem_slot: |
| 13157 | } | 13157 | } |
| 13158 | 13158 | ||
| 13159 | static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction, | 13159 | static 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, |
| 13161 | IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline) | 13161 | IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline) |
| 13162 | { | 13162 | { |
| 13163 | Error err; | 13163 | Error err; |
| ... | @@ -13382,7 +13382,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13382,7 +13382,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13382 | 13382 | ||
| 13383 | // Fork a scope of the function with known values for the parameters. | 13383 | // Fork a scope of the function with known values for the parameters. |
| 13384 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; | 13384 | 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); |
| 13386 | impl_fn->param_source_nodes = allocate<AstNode *>(new_fn_arg_count); | 13386 | impl_fn->param_source_nodes = allocate<AstNode *>(new_fn_arg_count); |
| 13387 | buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name); | 13387 | buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name); |
| 13388 | impl_fn->fndef_scope = create_fndef_scope(impl_fn->body_node, parent_scope, impl_fn); | 13388 | 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 | ... | @@ -13430,7 +13430,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13430 | bool found_first_var_arg = false; | 13430 | bool found_first_var_arg = false; |
| 13431 | size_t first_var_arg; | 13431 | size_t first_var_arg; |
| 13432 | 13432 | ||
| 13433 | FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 13433 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 13434 | assert(parent_fn_entry); | 13434 | assert(parent_fn_entry); |
| 13435 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 13435 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 13436 | IrInstruction *arg = call_instruction->args[call_i]->other; | 13436 | IrInstruction *arg = call_instruction->args[call_i]->other; |
| ... | @@ -13605,7 +13605,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13605,7 +13605,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13605 | return ir_finish_anal(ira, return_type); | 13605 | return ir_finish_anal(ira, return_type); |
| 13606 | } | 13606 | } |
| 13607 | 13607 | ||
| 13608 | FnTableEntry *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 13608 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 13609 | assert(fn_type_id->return_type != nullptr); | 13609 | assert(fn_type_id->return_type != nullptr); |
| 13610 | assert(parent_fn_entry != nullptr); | 13610 | assert(parent_fn_entry != nullptr); |
| 13611 | if (fn_type_can_fail(fn_type_id)) { | 13611 | if (fn_type_can_fail(fn_type_id)) { |
| ... | @@ -13734,14 +13734,14 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -13734,14 +13734,14 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c |
| 13734 | ir_link_new_instruction(cast_instruction, &call_instruction->base); | 13734 | ir_link_new_instruction(cast_instruction, &call_instruction->base); |
| 13735 | return ir_finish_anal(ira, cast_instruction->value.type); | 13735 | return ir_finish_anal(ira, cast_instruction->value.type); |
| 13736 | } else if (fn_ref->value.type->id == TypeTableEntryIdFn) { | 13736 | } 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); |
| 13738 | if (fn_table_entry == nullptr) | 13738 | if (fn_table_entry == nullptr) |
| 13739 | return ira->codegen->builtin_types.entry_invalid; | 13739 | return ira->codegen->builtin_types.entry_invalid; |
| 13740 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 13740 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 13741 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); | 13741 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); |
| 13742 | } else if (fn_ref->value.type->id == TypeTableEntryIdBoundFn) { | 13742 | } else if (fn_ref->value.type->id == TypeTableEntryIdBoundFn) { |
| 13743 | assert(fn_ref->value.special == ConstValSpecialStatic); | 13743 | 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; |
| 13745 | IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; | 13745 | IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; |
| 13746 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 13746 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 13747 | fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); | 13747 | 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 | ... | @@ -14289,7 +14289,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14289 | return ira->codegen->builtin_types.entry_invalid; | 14289 | return ira->codegen->builtin_types.entry_invalid; |
| 14290 | } | 14290 | } |
| 14291 | size_t abs_index = start + index; | 14291 | 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); |
| 14293 | assert(fn_entry); | 14293 | assert(fn_entry); |
| 14294 | VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index); | 14294 | VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index); |
| 14295 | bool is_const = true; | 14295 | bool is_const = true; |
| ... | @@ -14509,7 +14509,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -14509,7 +14509,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 14509 | if (tld->resolution == TldResolutionInvalid) | 14509 | if (tld->resolution == TldResolutionInvalid) |
| 14510 | return ira->codegen->invalid_instruction; | 14510 | return ira->codegen->invalid_instruction; |
| 14511 | TldFn *tld_fn = (TldFn *)tld; | 14511 | TldFn *tld_fn = (TldFn *)tld; |
| 14512 | FnTableEntry *fn_entry = tld_fn->fn_entry; | 14512 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 14513 | if (type_is_invalid(fn_entry->type_entry)) | 14513 | if (type_is_invalid(fn_entry->type_entry)) |
| 14514 | return ira->codegen->invalid_instruction; | 14514 | return ira->codegen->invalid_instruction; |
| 14515 | 14515 | ||
| ... | @@ -14703,7 +14703,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru | ... | @@ -14703,7 +14703,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru |
| 14703 | case TldIdFn: | 14703 | case TldIdFn: |
| 14704 | { | 14704 | { |
| 14705 | TldFn *tld_fn = (TldFn *)tld; | 14705 | TldFn *tld_fn = (TldFn *)tld; |
| 14706 | FnTableEntry *fn_entry = tld_fn->fn_entry; | 14706 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 14707 | assert(fn_entry->type_entry); | 14707 | assert(fn_entry->type_entry); |
| 14708 | 14708 | ||
| 14709 | if (type_is_invalid(fn_entry->type_entry)) | 14709 | if (type_is_invalid(fn_entry->type_entry)) |
| ... | @@ -15306,7 +15306,7 @@ static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSet | ... | @@ -15306,7 +15306,7 @@ static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSet |
| 15306 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) | 15306 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) |
| 15307 | return ira->codegen->builtin_types.entry_invalid; | 15307 | return ira->codegen->builtin_types.entry_invalid; |
| 15308 | 15308 | ||
| 15309 | FnTableEntry *fn_entry = scope_fn_entry(instruction->base.scope); | 15309 | ZigFn *fn_entry = scope_fn_entry(instruction->base.scope); |
| 15310 | if (fn_entry == nullptr) { | 15310 | if (fn_entry == nullptr) { |
| 15311 | ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function")); | 15311 | ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function")); |
| 15312 | return ira->codegen->builtin_types.entry_invalid; | 15312 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15345,7 +15345,7 @@ static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | ... | @@ -15345,7 +15345,7 @@ static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 15345 | break; | 15345 | break; |
| 15346 | } else if (scope->id == ScopeIdFnDef) { | 15346 | } else if (scope->id == ScopeIdFnDef) { |
| 15347 | ScopeFnDef *def_scope = (ScopeFnDef *)scope; | 15347 | ScopeFnDef *def_scope = (ScopeFnDef *)scope; |
| 15348 | FnTableEntry *target_fn = def_scope->fn_entry; | 15348 | ZigFn *target_fn = def_scope->fn_entry; |
| 15349 | assert(target_fn->def_scope != nullptr); | 15349 | assert(target_fn->def_scope != nullptr); |
| 15350 | safety_off_ptr = &target_fn->def_scope->safety_off; | 15350 | safety_off_ptr = &target_fn->def_scope->safety_off; |
| 15351 | safety_set_node_ptr = &target_fn->def_scope->safety_set_node; | 15351 | 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, | ... | @@ -15406,7 +15406,7 @@ static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 15406 | fast_math_set_node_ptr = &block_scope->fast_math_set_node; | 15406 | fast_math_set_node_ptr = &block_scope->fast_math_set_node; |
| 15407 | } else if (target_type->id == TypeTableEntryIdFn) { | 15407 | } else if (target_type->id == TypeTableEntryIdFn) { |
| 15408 | assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction); | 15408 | 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; |
| 15410 | assert(target_fn->def_scope); | 15410 | assert(target_fn->def_scope); |
| 15411 | fast_math_on_ptr = &target_fn->def_scope->fast_math_on; | 15411 | fast_math_on_ptr = &target_fn->def_scope->fast_math_on; |
| 15412 | fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node; | 15412 | 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 | ... | @@ -17023,7 +17023,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco |
| 17023 | // Skip comptime blocks and test functions. | 17023 | // Skip comptime blocks and test functions. |
| 17024 | if (curr_entry->value->id != TldIdCompTime) { | 17024 | if (curr_entry->value->id != TldIdCompTime) { |
| 17025 | if (curr_entry->value->id == TldIdFn) { | 17025 | 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; |
| 17027 | if (fn_entry->is_test) | 17027 | if (fn_entry->is_test) |
| 17028 | continue; | 17028 | continue; |
| 17029 | } | 17029 | } |
| ... | @@ -17049,7 +17049,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco | ... | @@ -17049,7 +17049,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco |
| 17049 | if (curr_entry->value->id == TldIdCompTime) { | 17049 | if (curr_entry->value->id == TldIdCompTime) { |
| 17050 | continue; | 17050 | continue; |
| 17051 | } else if (curr_entry->value->id == TldIdFn) { | 17051 | } 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; |
| 17053 | if (fn_entry->is_test) | 17053 | if (fn_entry->is_test) |
| 17054 | continue; | 17054 | continue; |
| 17055 | } | 17055 | } |
| ... | @@ -17105,7 +17105,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco | ... | @@ -17105,7 +17105,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco |
| 17105 | // 2: Data.Fn: Data.FnDef | 17105 | // 2: Data.Fn: Data.FnDef |
| 17106 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2); | 17106 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2); |
| 17107 | 17107 | ||
| 17108 | FnTableEntry *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; | 17108 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; |
| 17109 | assert(!fn_entry->is_test); | 17109 | assert(!fn_entry->is_test); |
| 17110 | 17110 | ||
| 17111 | AstNodeFnProto *fn_node = (AstNodeFnProto *)(fn_entry->proto_node); | 17111 | AstNodeFnProto *fn_node = (AstNodeFnProto *)(fn_entry->proto_node); |
| ... | @@ -19276,7 +19276,7 @@ static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructi | ... | @@ -19276,7 +19276,7 @@ static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructi |
| 19276 | static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) { | 19276 | static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) { |
| 19277 | ir_build_handle_from(&ira->new_irb, &instruction->base); | 19277 | ir_build_handle_from(&ira->new_irb, &instruction->base); |
| 19278 | 19278 | ||
| 19279 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 19279 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 19280 | assert(fn_entry != nullptr); | 19280 | assert(fn_entry != nullptr); |
| 19281 | return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type); | 19281 | return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type); |
| 19282 | } | 19282 | } |
| ... | @@ -20339,7 +20339,7 @@ static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | ... | @@ -20339,7 +20339,7 @@ static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 20339 | case TldIdFn: | 20339 | case TldIdFn: |
| 20340 | { | 20340 | { |
| 20341 | TldFn *tld_fn = (TldFn *)tld; | 20341 | TldFn *tld_fn = (TldFn *)tld; |
| 20342 | FnTableEntry *fn_entry = tld_fn->fn_entry; | 20342 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 20343 | assert(fn_entry->type_entry); | 20343 | assert(fn_entry->type_entry); |
| 20344 | 20344 | ||
| 20345 | if (tld_fn->extern_lib_name != nullptr) { | 20345 | if (tld_fn->extern_lib_name != nullptr) { |
| ... | @@ -20470,7 +20470,7 @@ static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstruc | ... | @@ -20470,7 +20470,7 @@ static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstruc |
| 20470 | return ira->codegen->builtin_types.entry_invalid; | 20470 | return ira->codegen->builtin_types.entry_invalid; |
| 20471 | } | 20471 | } |
| 20472 | 20472 | ||
| 20473 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 20473 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 20474 | if (fn_entry == nullptr) { | 20474 | if (fn_entry == nullptr) { |
| 20475 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function")); | 20475 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function")); |
| 20476 | return ira->codegen->builtin_types.entry_invalid; | 20476 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -20631,7 +20631,7 @@ static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionC | ... | @@ -20631,7 +20631,7 @@ static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionC |
| 20631 | if (type_is_invalid(coro_mem_ptr->value.type)) | 20631 | if (type_is_invalid(coro_mem_ptr->value.type)) |
| 20632 | return ira->codegen->builtin_types.entry_invalid; | 20632 | return ira->codegen->builtin_types.entry_invalid; |
| 20633 | 20633 | ||
| 20634 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 20634 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 20635 | assert(fn_entry != nullptr); | 20635 | assert(fn_entry != nullptr); |
| 20636 | IrInstruction *result = ir_build_coro_begin(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 20636 | IrInstruction *result = ir_build_coro_begin(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 20637 | coro_id, coro_mem_ptr); | 20637 | coro_id, coro_mem_ptr); |
| ... | @@ -20923,7 +20923,7 @@ static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstr | ... | @@ -20923,7 +20923,7 @@ static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstr |
| 20923 | if (type_is_invalid(promise_result_type)) | 20923 | if (type_is_invalid(promise_result_type)) |
| 20924 | return ira->codegen->builtin_types.entry_invalid; | 20924 | return ira->codegen->builtin_types.entry_invalid; |
| 20925 | 20925 | ||
| 20926 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 20926 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 20927 | assert(fn_entry != nullptr); | 20927 | assert(fn_entry != nullptr); |
| 20928 | 20928 | ||
| 20929 | if (type_can_fail(promise_result_type)) { | 20929 | if (type_can_fail(promise_result_type)) { |
| ... | @@ -21440,7 +21440,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -21440,7 +21440,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 21440 | old_exec->analysis = ira; | 21440 | old_exec->analysis = ira; |
| 21441 | ira->codegen = codegen; | 21441 | ira->codegen = codegen; |
| 21442 | 21442 | ||
| 21443 | FnTableEntry *fn_entry = exec_fn_entry(old_exec); | 21443 | ZigFn *fn_entry = exec_fn_entry(old_exec); |
| 21444 | bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; | 21444 | bool is_async = fn_entry != nullptr && fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync; |
| 21445 | ira->explicit_return_type = is_async ? get_promise_type(codegen, expected_type) : expected_type; | 21445 | ira->explicit_return_type = is_async ? get_promise_type(codegen, expected_type) : expected_type; |
| 21446 | 21446 |
src/ir.hpp+2-2| ... | @@ -11,11 +11,11 @@ | ... | @@ -11,11 +11,11 @@ |
| 11 | #include "all_types.hpp" | 11 | #include "all_types.hpp" |
| 12 | 12 | ||
| 13 | bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable); | 13 | bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable); |
| 14 | bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry); | 14 | bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry); |
| 15 | 15 | ||
| 16 | IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 16 | IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 17 | ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota, | 17 | 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, |
| 19 | IrExecutable *parent_exec); | 19 | IrExecutable *parent_exec); |
| 20 | 20 | ||
| 21 | ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable, | 21 | ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable, |