Commit db882e5d63
Changed files (6)
src/all_types.hpp
@@ -24,7 +24,7 @@ struct FnTableEntry;
struct Scope;
struct ScopeBlock;
struct ScopeFnDef;
-struct TypeTableEntry;
+struct ZigType;
struct VariableTableEntry;
struct ErrorTableEntry;
struct BuiltinFnEntry;
@@ -251,7 +251,7 @@ struct ConstGlobalRefs {
};
struct ConstExprValue {
- TypeTableEntry *type;
+ ZigType *type;
ConstValSpecial special;
ConstGlobalRefs *global_refs;
@@ -265,7 +265,7 @@ struct ConstExprValue {
float128_t x_f128;
bool x_bool;
ConstBoundFnValue x_bound_fn;
- TypeTableEntry *x_type;
+ ZigType *x_type;
ConstExprValue *x_optional;
ConstErrValue x_err_union;
ErrorTableEntry *x_err_set;
@@ -353,7 +353,7 @@ struct TldContainer {
Tld base;
ScopeDecls *decls_scope;
- TypeTableEntry *type_entry;
+ ZigType *type_entry;
};
struct TldCompTime {
@@ -370,7 +370,7 @@ struct TypeEnumField {
struct TypeUnionField {
Buf *name;
TypeEnumField *enum_field;
- TypeTableEntry *type_entry;
+ ZigType *type_entry;
AstNode *decl_node;
uint32_t gen_index;
};
@@ -973,7 +973,7 @@ struct AstNode {
// this struct is allocated with allocate_nonzero
struct FnTypeParamInfo {
bool is_noalias;
- TypeTableEntry *type;
+ ZigType *type;
};
struct GenericFnTypeId {
@@ -986,14 +986,14 @@ uint32_t generic_fn_type_id_hash(GenericFnTypeId *id);
bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b);
struct FnTypeId {
- TypeTableEntry *return_type;
+ ZigType *return_type;
FnTypeParamInfo *param_info;
size_t param_count;
size_t next_param_index;
bool is_var_args;
CallingConvention cc;
uint32_t alignment;
- TypeTableEntry *async_allocator_type;
+ ZigType *async_allocator_type;
};
uint32_t fn_type_id_hash(FnTypeId*);
@@ -1005,14 +1005,14 @@ enum PtrLen {
};
struct TypeTableEntryPointer {
- TypeTableEntry *child_type;
+ ZigType *child_type;
PtrLen ptr_len;
bool is_const;
bool is_volatile;
uint32_t alignment;
uint32_t bit_offset;
uint32_t unaligned_bit_count;
- TypeTableEntry *slice_parent;
+ ZigType *slice_parent;
};
struct TypeTableEntryInt {
@@ -1025,13 +1025,13 @@ struct TypeTableEntryFloat {
};
struct TypeTableEntryArray {
- TypeTableEntry *child_type;
+ ZigType *child_type;
uint64_t len;
};
struct TypeStructField {
Buf *name;
- TypeTableEntry *type_entry;
+ ZigType *type_entry;
size_t src_index;
size_t gen_index;
// offset from the memory at gen_index
@@ -1069,12 +1069,12 @@ struct TypeTableEntryStruct {
};
struct TypeTableEntryOptional {
- TypeTableEntry *child_type;
+ ZigType *child_type;
};
struct TypeTableEntryErrorUnion {
- TypeTableEntry *err_set_type;
- TypeTableEntry *payload_type;
+ ZigType *err_set_type;
+ ZigType *payload_type;
};
struct TypeTableEntryErrorSet {
@@ -1089,7 +1089,7 @@ struct TypeTableEntryEnum {
uint32_t src_field_count;
TypeEnumField *fields;
bool is_invalid; // true if any fields are invalid
- TypeTableEntry *tag_int_type;
+ ZigType *tag_int_type;
ScopeDecls *decls_scope;
@@ -1107,8 +1107,8 @@ struct TypeTableEntryEnum {
HashMap<Buf *, TypeEnumField *, buf_hash, buf_eql_buf> fields_by_name;
};
-uint32_t type_ptr_hash(const TypeTableEntry *ptr);
-bool type_ptr_eql(const TypeTableEntry *a, const TypeTableEntry *b);
+uint32_t type_ptr_hash(const ZigType *ptr);
+bool type_ptr_eql(const ZigType *a, const ZigType *b);
struct TypeTableEntryUnion {
AstNode *decl_node;
@@ -1117,7 +1117,7 @@ struct TypeTableEntryUnion {
uint32_t gen_field_count;
TypeUnionField *fields;
bool is_invalid; // true if any fields are invalid
- TypeTableEntry *tag_type; // always an enum or null
+ ZigType *tag_type; // always an enum or null
LLVMTypeRef union_type_ref;
ScopeDecls *decls_scope;
@@ -1142,7 +1142,7 @@ struct TypeTableEntryUnion {
bool have_explicit_tag_type;
uint32_t union_size_bytes;
- TypeTableEntry *most_aligned_union_member;
+ ZigType *most_aligned_union_member;
HashMap<Buf *, TypeUnionField *, buf_hash, buf_eql_buf> fields_by_name;
};
@@ -1151,31 +1151,31 @@ struct FnGenParamInfo {
size_t src_index;
size_t gen_index;
bool is_byval;
- TypeTableEntry *type;
+ ZigType *type;
};
struct TypeTableEntryFn {
FnTypeId fn_type_id;
bool is_generic;
- TypeTableEntry *gen_return_type;
+ ZigType *gen_return_type;
size_t gen_param_count;
FnGenParamInfo *gen_param_info;
LLVMTypeRef raw_type_ref;
- TypeTableEntry *bound_fn_parent;
+ ZigType *bound_fn_parent;
};
struct TypeTableEntryBoundFn {
- TypeTableEntry *fn_type;
+ ZigType *fn_type;
};
struct TypeTableEntryPromise {
// null if `promise` instead of `promise->T`
- TypeTableEntry *result_type;
+ ZigType *result_type;
};
-enum TypeTableEntryId {
+enum ZigTypeId {
TypeTableEntryIdInvalid,
TypeTableEntryIdMetaType,
TypeTableEntryIdVoid,
@@ -1204,8 +1204,8 @@ enum TypeTableEntryId {
TypeTableEntryIdPromise,
};
-struct TypeTableEntry {
- TypeTableEntryId id;
+struct ZigType {
+ ZigTypeId id;
Buf name;
LLVMTypeRef type_ref;
@@ -1232,10 +1232,10 @@ struct TypeTableEntry {
} data;
// use these fields to make sure we don't duplicate type table entries for the same type
- TypeTableEntry *pointer_parent[2]; // [0 - mut, 1 - const]
- TypeTableEntry *optional_parent;
- TypeTableEntry *promise_parent;
- TypeTableEntry *promise_frame_parent;
+ ZigType *pointer_parent[2]; // [0 - mut, 1 - const]
+ ZigType *optional_parent;
+ ZigType *promise_parent;
+ ZigType *promise_frame_parent;
// If we generate a constant name value for this type, we memoize it here.
// The type of this is array
ConstExprValue *cached_const_name_val;
@@ -1291,11 +1291,11 @@ struct FnTableEntry {
Scope *child_scope; // parent is scope for last parameter
ScopeBlock *def_scope; // parent is child_scope
Buf symbol_name;
- TypeTableEntry *type_entry; // function type
+ ZigType *type_entry; // function type
// in the case of normal functions this is the implicit return type
// in the case of async functions this is the implicit return type according to the
// zig source code, not according to zig ir
- TypeTableEntry *src_implicit_return_type;
+ ZigType *src_implicit_return_type;
bool is_test;
FnInline fn_inline;
FnAnalState anal_state;
@@ -1445,11 +1445,11 @@ uint32_t fn_eval_hash(Scope*);
bool fn_eval_eql(Scope *a, Scope *b);
struct TypeId {
- TypeTableEntryId id;
+ ZigTypeId id;
union {
struct {
- TypeTableEntry *child_type;
+ ZigType *child_type;
PtrLen ptr_len;
bool is_const;
bool is_volatile;
@@ -1458,7 +1458,7 @@ struct TypeId {
uint32_t unaligned_bit_count;
} pointer;
struct {
- TypeTableEntry *child_type;
+ ZigType *child_type;
uint64_t size;
} array;
struct {
@@ -1466,8 +1466,8 @@ struct TypeId {
uint32_t bit_count;
} integer;
struct {
- TypeTableEntry *err_set_type;
- TypeTableEntry *payload_type;
+ ZigType *err_set_type;
+ ZigType *payload_type;
} error_union;
} data;
};
@@ -1563,9 +1563,9 @@ struct CodeGen {
// reminder: hash tables must be initialized before use
HashMap<Buf *, ImportTableEntry *, buf_hash, buf_eql_buf> import_table;
HashMap<Buf *, BuiltinFnEntry *, buf_hash, buf_eql_buf> builtin_fn_table;
- HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> primitive_type_table;
- HashMap<TypeId, TypeTableEntry *, type_id_hash, type_id_eql> type_table;
- HashMap<FnTypeId *, TypeTableEntry *, fn_type_id_hash, fn_type_id_eql> fn_type_table;
+ HashMap<Buf *, ZigType *, buf_hash, buf_eql_buf> primitive_type_table;
+ HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table;
+ HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table;
HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table;
HashMap<GenericFnTypeId *, FnTableEntry *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;
HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
@@ -1573,7 +1573,7 @@ struct CodeGen {
HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names;
HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_prototypes;
HashMap<Buf *, ConstExprValue *, buf_hash, buf_eql_buf> string_literals_table;
- HashMap<const TypeTableEntry *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
+ HashMap<const ZigType *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
ZigList<ImportTableEntry *> import_queue;
@@ -1586,38 +1586,38 @@ struct CodeGen {
uint32_t next_unresolved_index;
struct {
- TypeTableEntry *entry_bool;
- TypeTableEntry *entry_c_int[CIntTypeCount];
- TypeTableEntry *entry_c_longdouble;
- TypeTableEntry *entry_c_void;
- TypeTableEntry *entry_u8;
- TypeTableEntry *entry_u16;
- TypeTableEntry *entry_u32;
- TypeTableEntry *entry_u29;
- TypeTableEntry *entry_u64;
- TypeTableEntry *entry_i8;
- TypeTableEntry *entry_i32;
- TypeTableEntry *entry_i64;
- TypeTableEntry *entry_isize;
- TypeTableEntry *entry_usize;
- TypeTableEntry *entry_f16;
- TypeTableEntry *entry_f32;
- TypeTableEntry *entry_f64;
- TypeTableEntry *entry_f128;
- TypeTableEntry *entry_void;
- TypeTableEntry *entry_unreachable;
- TypeTableEntry *entry_type;
- TypeTableEntry *entry_invalid;
- TypeTableEntry *entry_namespace;
- TypeTableEntry *entry_block;
- TypeTableEntry *entry_num_lit_int;
- TypeTableEntry *entry_num_lit_float;
- TypeTableEntry *entry_undef;
- TypeTableEntry *entry_null;
- TypeTableEntry *entry_var;
- TypeTableEntry *entry_global_error_set;
- TypeTableEntry *entry_arg_tuple;
- TypeTableEntry *entry_promise;
+ ZigType *entry_bool;
+ ZigType *entry_c_int[CIntTypeCount];
+ ZigType *entry_c_longdouble;
+ ZigType *entry_c_void;
+ ZigType *entry_u8;
+ ZigType *entry_u16;
+ ZigType *entry_u32;
+ ZigType *entry_u29;
+ ZigType *entry_u64;
+ ZigType *entry_i8;
+ ZigType *entry_i32;
+ ZigType *entry_i64;
+ ZigType *entry_isize;
+ ZigType *entry_usize;
+ ZigType *entry_f16;
+ ZigType *entry_f32;
+ ZigType *entry_f64;
+ ZigType *entry_f128;
+ ZigType *entry_void;
+ ZigType *entry_unreachable;
+ ZigType *entry_type;
+ ZigType *entry_invalid;
+ ZigType *entry_namespace;
+ ZigType *entry_block;
+ ZigType *entry_num_lit_int;
+ ZigType *entry_num_lit_float;
+ ZigType *entry_undef;
+ ZigType *entry_null;
+ ZigType *entry_var;
+ ZigType *entry_global_error_set;
+ ZigType *entry_arg_tuple;
+ ZigType *entry_promise;
} builtin_types;
EmitFileType emit_file_type;
@@ -1735,11 +1735,11 @@ struct CodeGen {
size_t llvm_argv_len;
ZigList<FnTableEntry *> test_fns;
- TypeTableEntry *test_fn_type;
+ ZigType *test_fn_type;
bool each_lib_rpath;
- TypeTableEntry *err_tag_type;
+ ZigType *err_tag_type;
ZigList<ZigLLVMDIEnumerator *> err_enumerators;
ZigList<ErrorTableEntry *> errors_by_index;
bool generate_error_name_table;
@@ -1769,9 +1769,9 @@ struct CodeGen {
ZigList<FnTableEntry *> inline_fns;
ZigList<AstNode *> tld_ref_source_node_stack;
- TypeTableEntry *align_amt_type;
- TypeTableEntry *stack_trace_type;
- TypeTableEntry *ptr_to_stack_trace_type;
+ ZigType *align_amt_type;
+ ZigType *stack_trace_type;
+ ZigType *ptr_to_stack_trace_type;
ZigList<ZigLLVMDIType **> error_di_types;
@@ -1818,7 +1818,7 @@ struct ErrorTableEntry {
Buf name;
uint32_t value;
AstNode *decl_node;
- TypeTableEntry *set_with_only_this_in_it;
+ ZigType *set_with_only_this_in_it;
// If we generate a constant error name value for this error, we memoize it here.
// The type of this is array
ConstExprValue *cached_error_name_val;
@@ -1862,7 +1862,7 @@ struct ScopeDecls {
AstNode *fast_math_set_node;
ImportTableEntry *import;
// If this is a scope from a container, this is the type entry, otherwise null
- TypeTableEntry *container_type;
+ ZigType *container_type;
};
// This scope comes from a block expression in user code.
@@ -2386,7 +2386,7 @@ struct IrInstructionCast {
IrInstruction base;
IrInstruction *value;
- TypeTableEntry *dest_type;
+ ZigType *dest_type;
CastOp cast_op;
LLVMValueRef tmp_ptr;
};
@@ -2423,7 +2423,7 @@ struct IrInstructionStructInitField {
struct IrInstructionStructInit {
IrInstruction base;
- TypeTableEntry *struct_type;
+ ZigType *struct_type;
size_t field_count;
IrInstructionStructInitField *fields;
LLVMValueRef tmp_ptr;
@@ -2432,7 +2432,7 @@ struct IrInstructionStructInit {
struct IrInstructionUnionInit {
IrInstruction base;
- TypeTableEntry *union_type;
+ ZigType *union_type;
TypeUnionField *field;
IrInstruction *init_value;
LLVMValueRef tmp_ptr;
@@ -2661,7 +2661,7 @@ struct IrInstructionCmpxchg {
IrInstruction *failure_order_value;
// if this instruction gets to runtime then we know these values:
- TypeTableEntry *type;
+ ZigType *type;
AtomicOrder success_order;
AtomicOrder failure_order;
@@ -2831,7 +2831,7 @@ struct IrInstructionOverflowOp {
IrInstruction *op2;
IrInstruction *result_ptr;
- TypeTableEntry *result_ptr_type;
+ ZigType *result_ptr_type;
};
struct IrInstructionAlignOf {
src/analyze.cpp
@@ -19,12 +19,12 @@
static const size_t default_backward_branch_quota = 1000;
-static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type);
-static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type);
+static Error resolve_enum_type(CodeGen *g, ZigType *enum_type);
+static Error resolve_struct_type(CodeGen *g, ZigType *struct_type);
-static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type);
-static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type);
-static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type);
+static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type);
+static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type);
+static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type);
static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);
ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
@@ -70,13 +70,13 @@ ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *m
return err;
}
-TypeTableEntry *new_type_table_entry(TypeTableEntryId id) {
- TypeTableEntry *entry = allocate<TypeTableEntry>(1);
+ZigType *new_type_table_entry(ZigTypeId id) {
+ ZigType *entry = allocate<ZigType>(1);
entry->id = id;
return entry;
}
-static ScopeDecls **get_container_scope_ptr(TypeTableEntry *type_entry) {
+static ScopeDecls **get_container_scope_ptr(ZigType *type_entry) {
if (type_entry->id == TypeTableEntryIdStruct) {
return &type_entry->data.structure.decls_scope;
} else if (type_entry->id == TypeTableEntryIdEnum) {
@@ -87,7 +87,7 @@ static ScopeDecls **get_container_scope_ptr(TypeTableEntry *type_entry) {
zig_unreachable();
}
-ScopeDecls *get_container_scope(TypeTableEntry *type_entry) {
+ScopeDecls *get_container_scope(ZigType *type_entry) {
return *get_container_scope_ptr(type_entry);
}
@@ -97,7 +97,7 @@ void init_scope(Scope *dest, ScopeId id, AstNode *source_node, Scope *parent) {
dest->parent = parent;
}
-ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, TypeTableEntry *container_type, ImportTableEntry *import) {
+ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import) {
assert(node == nullptr || node->type == NodeTypeRoot || node->type == NodeTypeContainerDecl || node->type == NodeTypeFnCallExpr);
ScopeDecls *scope = allocate<ScopeDecls>(1);
init_scope(&scope->base, ScopeIdDecls, node, parent);
@@ -203,8 +203,8 @@ ImportTableEntry *get_scope_import(Scope *scope) {
zig_unreachable();
}
-static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *source_node, Scope *parent_scope) {
- TypeTableEntry *entry = new_type_table_entry(id);
+static ZigType *new_container_type_entry(ZigTypeId id, AstNode *source_node, Scope *parent_scope) {
+ ZigType *entry = new_type_table_entry(id);
*get_container_scope_ptr(entry) = create_decls_scope(source_node, parent_scope, entry, get_scope_import(parent_scope));
return entry;
}
@@ -218,7 +218,7 @@ static uint8_t bits_needed_for_unsigned(uint64_t x) {
return (upper >= x) ? base : (base + 1);
}
-AstNode *type_decl_node(TypeTableEntry *type_entry) {
+AstNode *type_decl_node(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -255,7 +255,7 @@ AstNode *type_decl_node(TypeTableEntry *type_entry) {
zig_unreachable();
}
-bool type_is_complete(TypeTableEntry *type_entry) {
+bool type_is_complete(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -293,7 +293,7 @@ bool type_is_complete(TypeTableEntry *type_entry) {
zig_unreachable();
}
-bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
+bool type_has_zero_bits_known(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -331,7 +331,7 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
}
-uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {
+uint64_t type_size(CodeGen *g, ZigType *type_entry) {
assert(type_is_complete(type_entry));
if (!type_has_bits(type_entry))
@@ -341,7 +341,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {
uint64_t size_in_bits = type_size_bits(g, type_entry);
return (size_in_bits + 7) / 8;
} else if (type_entry->id == TypeTableEntryIdArray) {
- TypeTableEntry *child_type = type_entry->data.array.child_type;
+ ZigType *child_type = type_entry->data.array.child_type;
if (child_type->id == TypeTableEntryIdStruct &&
child_type->data.structure.layout == ContainerLayoutPacked)
{
@@ -353,7 +353,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {
return LLVMStoreSizeOfType(g->target_data_ref, type_entry->type_ref);
}
-uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {
+uint64_t type_size_bits(CodeGen *g, ZigType *type_entry) {
assert(type_is_complete(type_entry));
if (!type_has_bits(type_entry))
@@ -366,7 +366,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {
}
return result;
} else if (type_entry->id == TypeTableEntryIdArray) {
- TypeTableEntry *child_type = type_entry->data.array.child_type;
+ ZigType *child_type = type_entry->data.array.child_type;
if (child_type->id == TypeTableEntryIdStruct &&
child_type->data.structure.layout == ContainerLayoutPacked)
{
@@ -377,7 +377,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {
return LLVMSizeOfTypeInBits(g->target_data_ref, type_entry->type_ref);
}
-Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry) {
+Result<bool> type_is_copyable(CodeGen *g, ZigType *type_entry) {
Error err;
if ((err = type_ensure_zero_bits_known(g, type_entry)))
return err;
@@ -394,23 +394,23 @@ Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry) {
return type_entry->is_copyable;
}
-static bool is_slice(TypeTableEntry *type) {
+static bool is_slice(ZigType *type) {
return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;
}
-TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) {
+ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) {
return get_int_type(g, false, bits_needed_for_unsigned(x));
}
-TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type) {
+ZigType *get_promise_type(CodeGen *g, ZigType *result_type) {
if (result_type != nullptr && result_type->promise_parent != nullptr) {
return result_type->promise_parent;
} else if (result_type == nullptr && g->builtin_types.entry_promise != nullptr) {
return g->builtin_types.entry_promise;
}
- TypeTableEntry *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPromise);
+ ZigType *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdPromise);
entry->type_ref = u8_ptr_type->type_ref;
entry->zero_bits = false;
entry->data.promise.result_type = result_type;
@@ -428,14 +428,14 @@ TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type) {
return entry;
}
-TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type, bool is_const,
+ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_const,
bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count)
{
assert(!type_is_invalid(child_type));
assert(ptr_len == PtrLenSingle || child_type->id != TypeTableEntryIdOpaque);
TypeId type_id = {};
- TypeTableEntry **parent_pointer = nullptr;
+ ZigType **parent_pointer = nullptr;
uint32_t abi_alignment = get_abi_alignment(g, child_type);
if (unaligned_bit_count != 0 || is_volatile || byte_alignment != abi_alignment || ptr_len != PtrLenSingle) {
type_id.id = TypeTableEntryIdPointer;
@@ -461,7 +461,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
assertNoError(type_ensure_zero_bits_known(g, child_type));
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPointer);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdPointer);
entry->is_copyable = true;
const char *star_str = ptr_len == PtrLenSingle ? "*" : "[*]";
@@ -487,7 +487,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
if (is_const || is_volatile || unaligned_bit_count != 0 || byte_alignment != abi_alignment ||
ptr_len != PtrLenSingle)
{
- TypeTableEntry *peer_type = get_pointer_to_type(g, child_type, false);
+ ZigType *peer_type = get_pointer_to_type(g, child_type, false);
entry->type_ref = peer_type->type_ref;
entry->di_type = peer_type->di_type;
} else {
@@ -520,18 +520,18 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
return entry;
}
-TypeTableEntry *get_pointer_to_type(CodeGen *g, TypeTableEntry *child_type, bool is_const) {
+ZigType *get_pointer_to_type(CodeGen *g, ZigType *child_type, bool is_const) {
return get_pointer_to_type_extra(g, child_type, is_const, false, PtrLenSingle,
get_abi_alignment(g, child_type), 0, 0);
}
-TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type) {
+ZigType *get_promise_frame_type(CodeGen *g, ZigType *return_type) {
if (return_type->promise_frame_parent != nullptr) {
return return_type->promise_frame_parent;
}
- TypeTableEntry *atomic_state_type = g->builtin_types.entry_usize;
- TypeTableEntry *result_ptr_type = get_pointer_to_type(g, return_type, false);
+ ZigType *atomic_state_type = g->builtin_types.entry_usize;
+ ZigType *result_ptr_type = get_pointer_to_type(g, return_type, false);
ZigList<const char *> field_names = {};
field_names.append(ATOMIC_STATE_FIELD_NAME);
@@ -543,7 +543,7 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
field_names.append(RETURN_ADDRESSES_FIELD_NAME);
}
- ZigList<TypeTableEntry *> field_types = {};
+ ZigList<ZigType *> field_types = {};
field_types.append(atomic_state_type);
field_types.append(return_type);
field_types.append(result_ptr_type);
@@ -555,20 +555,20 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
assert(field_names.length == field_types.length);
Buf *name = buf_sprintf("AsyncFramePromise(%s)", buf_ptr(&return_type->name));
- TypeTableEntry *entry = get_struct_type(g, buf_ptr(name), field_names.items, field_types.items, field_names.length);
+ ZigType *entry = get_struct_type(g, buf_ptr(name), field_names.items, field_types.items, field_names.length);
return_type->promise_frame_parent = entry;
return entry;
}
-TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
+ZigType *get_optional_type(CodeGen *g, ZigType *child_type) {
if (child_type->optional_parent) {
- TypeTableEntry *entry = child_type->optional_parent;
+ ZigType *entry = child_type->optional_parent;
return entry;
} else {
assertNoError(ensure_complete_type(g, child_type));
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdOptional);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdOptional);
assert(child_type->type_ref || child_type->zero_bits);
entry->is_copyable = type_is_copyable(g, child_type).unwrap();
@@ -606,7 +606,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
uint64_t val_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, child_type->type_ref);
uint64_t val_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
- TypeTableEntry *bool_type = g->builtin_types.entry_bool;
+ ZigType *bool_type = g->builtin_types.entry_bool;
uint64_t maybe_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, bool_type->type_ref);
uint64_t maybe_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, bool_type->type_ref);
uint64_t maybe_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);
@@ -645,7 +645,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
}
}
-TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *payload_type) {
+ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type) {
assert(err_set_type->id == TypeTableEntryIdErrorSet);
assert(!type_is_invalid(payload_type));
@@ -659,7 +659,7 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T
return existing_entry->value;
}
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdErrorUnion);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdErrorUnion);
entry->is_copyable = true;
assert(payload_type->di_type);
assertNoError(ensure_complete_type(g, payload_type));
@@ -740,20 +740,20 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T
return entry;
}
-TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t array_size) {
+ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size) {
TypeId type_id = {};
type_id.id = TypeTableEntryIdArray;
type_id.data.array.child_type = child_type;
type_id.data.array.size = array_size;
auto existing_entry = g->type_table.maybe_get(type_id);
if (existing_entry) {
- TypeTableEntry *entry = existing_entry->value;
+ ZigType *entry = existing_entry->value;
return entry;
}
assertNoError(ensure_complete_type(g, child_type));
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdArray);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdArray);
entry->zero_bits = (array_size == 0) || child_type->zero_bits;
entry->is_copyable = false;
@@ -780,7 +780,7 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
return entry;
}
-static void slice_type_common_init(CodeGen *g, TypeTableEntry *pointer_type, TypeTableEntry *entry) {
+static void slice_type_common_init(CodeGen *g, ZigType *pointer_type, ZigType *entry) {
unsigned element_count = 2;
Buf *ptr_field_name = buf_create_from_str("ptr");
Buf *len_field_name = buf_create_from_str("len");
@@ -811,16 +811,16 @@ static void slice_type_common_init(CodeGen *g, TypeTableEntry *pointer_type, Typ
}
}
-TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
+ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type) {
assert(ptr_type->id == TypeTableEntryIdPointer);
assert(ptr_type->data.pointer.ptr_len == PtrLenUnknown);
- TypeTableEntry **parent_pointer = &ptr_type->data.pointer.slice_parent;
+ ZigType **parent_pointer = &ptr_type->data.pointer.slice_parent;
if (*parent_pointer) {
return *parent_pointer;
}
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdStruct);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdStruct);
entry->is_copyable = true;
// replace the & with [] to go from a ptr type name to a slice type name
@@ -828,14 +828,14 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
size_t name_offset = (ptr_type->data.pointer.ptr_len == PtrLenSingle) ? 1 : 3;
buf_appendf(&entry->name, "[]%s", buf_ptr(&ptr_type->name) + name_offset);
- TypeTableEntry *child_type = ptr_type->data.pointer.child_type;
+ ZigType *child_type = ptr_type->data.pointer.child_type;
uint32_t abi_alignment = get_abi_alignment(g, child_type);
if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile ||
ptr_type->data.pointer.alignment != abi_alignment)
{
- TypeTableEntry *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,
+ ZigType *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,
PtrLenUnknown, abi_alignment, 0, 0);
- TypeTableEntry *peer_slice_type = get_slice_type(g, peer_ptr_type);
+ ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
slice_type_common_init(g, ptr_type, entry);
@@ -852,18 +852,18 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
// If the child type is []const T then we need to make sure the type ref
// and debug info is the same as if the child type were []T.
if (is_slice(child_type)) {
- TypeTableEntry *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;
assert(child_ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *grand_child_type = child_ptr_type->data.pointer.child_type;
+ ZigType *grand_child_type = child_ptr_type->data.pointer.child_type;
if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile ||
child_ptr_type->data.pointer.alignment != get_abi_alignment(g, grand_child_type))
{
- TypeTableEntry *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,
+ ZigType *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,
PtrLenUnknown, get_abi_alignment(g, grand_child_type), 0, 0);
- TypeTableEntry *bland_child_slice = get_slice_type(g, bland_child_ptr_type);
- TypeTableEntry *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,
+ ZigType *bland_child_slice = get_slice_type(g, bland_child_ptr_type);
+ ZigType *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,
PtrLenUnknown, get_abi_alignment(g, bland_child_slice), 0, 0);
- TypeTableEntry *peer_slice_type = get_slice_type(g, peer_ptr_type);
+ ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
entry->type_ref = peer_slice_type->type_ref;
entry->di_type = peer_slice_type->di_type;
@@ -889,7 +889,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
};
LLVMStructSetBody(entry->type_ref, element_types, 1, false);
- TypeTableEntry *usize_type = g->builtin_types.entry_usize;
+ ZigType *usize_type = g->builtin_types.entry_usize;
uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);
uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);
uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
@@ -928,7 +928,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
uint64_t ptr_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, ptr_type->type_ref);
uint64_t ptr_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
- TypeTableEntry *usize_type = g->builtin_types.entry_usize;
+ ZigType *usize_type = g->builtin_types.entry_usize;
uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);
uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);
uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);
@@ -971,8 +971,8 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
return entry;
}
-TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name) {
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdOpaque);
+ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name) {
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdOpaque);
buf_init_from_str(&entry->name, name);
@@ -991,13 +991,13 @@ TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node,
return entry;
}
-TypeTableEntry *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) {
- TypeTableEntry *fn_type = fn_entry->type_entry;
+ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) {
+ ZigType *fn_type = fn_entry->type_entry;
assert(fn_type->id == TypeTableEntryIdFn);
if (fn_type->data.fn.bound_fn_parent)
return fn_type->data.fn.bound_fn_parent;
- TypeTableEntry *bound_fn_type = new_type_table_entry(TypeTableEntryIdBoundFn);
+ ZigType *bound_fn_type = new_type_table_entry(TypeTableEntryIdBoundFn);
bound_fn_type->is_copyable = false;
bound_fn_type->data.bound_fn.fn_type = fn_type;
bound_fn_type->zero_bits = true;
@@ -1051,7 +1051,7 @@ static bool calling_convention_allows_zig_types(CallingConvention cc) {
zig_unreachable();
}
-TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g) {
+ZigType *get_ptr_to_stack_trace_type(CodeGen *g) {
if (g->stack_trace_type == nullptr) {
ConstExprValue *stack_trace_type_val = get_builtin_value(g, "StackTrace");
assert(stack_trace_type_val->type->id == TypeTableEntryIdMetaType);
@@ -1061,7 +1061,7 @@ TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g) {
return g->ptr_to_stack_trace_type;
}
-TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
+ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
Error err;
auto table_entry = g->fn_type_table.maybe_get(fn_type_id);
if (table_entry) {
@@ -1075,7 +1075,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447");
}
- TypeTableEntry *fn_type = new_type_table_entry(TypeTableEntryIdFn);
+ ZigType *fn_type = new_type_table_entry(TypeTableEntryIdFn);
fn_type->is_copyable = true;
fn_type->data.fn.fn_type_id = *fn_type_id;
@@ -1094,7 +1094,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
FnTypeParamInfo *param_info = &fn_type_id->param_info[i];
- TypeTableEntry *param_type = param_info->type;
+ ZigType *param_type = param_info->type;
const char *comma = (i == 0) ? "" : ", ";
const char *noalias_str = param_info->is_noalias ? "noalias " : "";
buf_appendf(&fn_type->name, "%s%s%s", comma, noalias_str, buf_ptr(¶m_type->name));
@@ -1131,13 +1131,13 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
ZigLLVMDIType **param_di_types = allocate<ZigLLVMDIType*>(5 + fn_type_id->param_count);
param_di_types[0] = fn_type_id->return_type->di_type;
size_t gen_param_index = 0;
- TypeTableEntry *gen_return_type;
+ ZigType *gen_return_type;
if (is_async) {
gen_return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);
} else if (!type_has_bits(fn_type_id->return_type)) {
gen_return_type = g->builtin_types.entry_void;
} else if (first_arg_return) {
- TypeTableEntry *gen_type = get_pointer_to_type(g, fn_type_id->return_type, false);
+ ZigType *gen_type = get_pointer_to_type(g, fn_type_id->return_type, false);
gen_param_types[gen_param_index] = gen_type->type_ref;
gen_param_index += 1;
// after the gen_param_index += 1 because 0 is the return type
@@ -1149,7 +1149,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
fn_type->data.fn.gen_return_type = gen_return_type;
if (prefix_arg_error_return_trace) {
- TypeTableEntry *gen_type = get_ptr_to_stack_trace_type(g);
+ ZigType *gen_type = get_ptr_to_stack_trace_type(g);
gen_param_types[gen_param_index] = gen_type->type_ref;
gen_param_index += 1;
// after the gen_param_index += 1 because 0 is the return type
@@ -1158,7 +1158,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
if (is_async) {
{
// async allocator param
- TypeTableEntry *gen_type = fn_type_id->async_allocator_type;
+ ZigType *gen_type = fn_type_id->async_allocator_type;
gen_param_types[gen_param_index] = gen_type->type_ref;
gen_param_index += 1;
// after the gen_param_index += 1 because 0 is the return type
@@ -1167,7 +1167,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
{
// error code pointer
- TypeTableEntry *gen_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
+ ZigType *gen_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
gen_param_types[gen_param_index] = gen_type->type_ref;
gen_param_index += 1;
// after the gen_param_index += 1 because 0 is the return type
@@ -1178,7 +1178,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
fn_type->data.fn.gen_param_info = allocate<FnGenParamInfo>(fn_type_id->param_count);
for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
FnTypeParamInfo *src_param_info = &fn_type->data.fn.fn_type_id.param_info[i];
- TypeTableEntry *type_entry = src_param_info->type;
+ ZigType *type_entry = src_param_info->type;
FnGenParamInfo *gen_param_info = &fn_type->data.fn.gen_param_info[i];
gen_param_info->src_index = i;
@@ -1188,7 +1188,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
return g->builtin_types.entry_invalid;
if (type_has_bits(type_entry)) {
- TypeTableEntry *gen_type;
+ ZigType *gen_type;
if (handle_is_ptr(type_entry)) {
gen_type = get_pointer_to_type(g, type_entry, true);
gen_param_info->is_byval = true;
@@ -1219,7 +1219,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
return fn_type;
}
-static TypeTableEntryId container_to_type(ContainerKind kind) {
+static ZigTypeId container_to_type(ContainerKind kind) {
switch (kind) {
case ContainerKindStruct:
return TypeTableEntryIdStruct;
@@ -1231,11 +1231,11 @@ static TypeTableEntryId container_to_type(ContainerKind kind) {
zig_unreachable();
}
-TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
+ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
AstNode *decl_node, const char *name, ContainerLayout layout)
{
- TypeTableEntryId type_id = container_to_type(kind);
- TypeTableEntry *entry = new_container_type_entry(type_id, decl_node, scope);
+ ZigTypeId type_id = container_to_type(kind);
+ ZigType *entry = new_container_type_entry(type_id, decl_node, scope);
switch (kind) {
case ContainerKindStruct:
@@ -1266,14 +1266,14 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi
return entry;
}
-static IrInstruction *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, TypeTableEntry *type_entry, Buf *type_name) {
+static IrInstruction *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry, Buf *type_name) {
size_t backward_branch_count = 0;
return ir_eval_const_value(g, scope, node, type_entry,
&backward_branch_count, default_backward_branch_quota,
nullptr, nullptr, node, type_name, nullptr);
}
-TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
+ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
IrInstruction *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type, nullptr);
if (result->value.type->id == TypeTableEntryIdInvalid)
return g->builtin_types.entry_invalid;
@@ -1282,8 +1282,8 @@ TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
return result->value.data.x_type;
}
-TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
- TypeTableEntry *fn_type = new_type_table_entry(TypeTableEntryIdFn);
+ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
+ ZigType *fn_type = new_type_table_entry(TypeTableEntryIdFn);
fn_type->is_copyable = false;
buf_resize(&fn_type->name, 0);
if (fn_type->data.fn.fn_type_id.cc == CallingConventionAsync) {
@@ -1350,9 +1350,9 @@ static bool analyze_const_align(CodeGen *g, Scope *scope, AstNode *node, uint32_
}
static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **out_buffer) {
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(g, ptr_type);
+ ZigType *str_type = get_slice_type(g, ptr_type);
IrInstruction *instr = analyze_const_value(g, scope, node, str_type, nullptr);
if (type_is_invalid(instr->value.type))
return false;
@@ -1382,7 +1382,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **
return true;
}
-static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
+static bool type_allowed_in_packed_struct(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -1415,7 +1415,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
return type_entry->data.unionation.layout == ContainerLayoutPacked;
case TypeTableEntryIdOptional:
{
- TypeTableEntry *child_type = type_entry->data.maybe.child_type;
+ ZigType *child_type = type_entry->data.maybe.child_type;
return type_is_codegen_pointer(child_type);
}
case TypeTableEntryIdEnum:
@@ -1424,7 +1424,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
zig_unreachable();
}
-static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
+static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -1471,7 +1471,7 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
return type_entry->data.structure.layout == ContainerLayoutExtern || type_entry->data.structure.layout == ContainerLayoutPacked;
case TypeTableEntryIdOptional:
{
- TypeTableEntry *child_type = type_entry->data.maybe.child_type;
+ ZigType *child_type = type_entry->data.maybe.child_type;
if (child_type->id != TypeTableEntryIdPointer && child_type->id != TypeTableEntryIdFn) {
return false;
}
@@ -1485,8 +1485,8 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
zig_unreachable();
}
-TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
- TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
+ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
+ ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_resize(&err_set_type->name, 0);
buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));
err_set_type->is_copyable = true;
@@ -1501,7 +1501,7 @@ TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
return err_set_type;
}
-static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) {
+static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) {
assert(proto_node->type == NodeTypeFnProto);
AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
Error err;
@@ -1524,7 +1524,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
return g->builtin_types.entry_invalid;
}
if (param_node->data.param_decl.type != nullptr) {
- TypeTableEntry *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
+ ZigType *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
if (type_is_invalid(type_entry)) {
return g->builtin_types.entry_invalid;
}
@@ -1557,7 +1557,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
return get_generic_fn_type(g, &fn_type_id);
}
- TypeTableEntry *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
+ ZigType *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
if (type_is_invalid(type_entry)) {
return g->builtin_types.entry_invalid;
}
@@ -1645,14 +1645,14 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
//return get_generic_fn_type(g, &fn_type_id);
}
- TypeTableEntry *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type);
+ ZigType *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type);
if (type_is_invalid(specified_return_type)) {
fn_type_id.return_type = g->builtin_types.entry_invalid;
return g->builtin_types.entry_invalid;
}
if (fn_proto->auto_err_set) {
- TypeTableEntry *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);
+ ZigType *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);
fn_type_id.return_type = get_error_union_type(g, inferred_err_set_type, specified_return_type);
} else {
fn_type_id.return_type = specified_return_type;
@@ -1723,7 +1723,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
return get_fn_type(g, &fn_type_id);
}
-bool type_is_invalid(TypeTableEntry *type_entry) {
+bool type_is_invalid(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
return true;
@@ -1740,7 +1740,7 @@ bool type_is_invalid(TypeTableEntry *type_entry) {
}
-static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
+static Error resolve_enum_type(CodeGen *g, ZigType *enum_type) {
assert(enum_type->id == TypeTableEntryIdEnum);
if (enum_type->data.enumeration.is_invalid)
@@ -1815,7 +1815,7 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
return ErrorNone;
}
- TypeTableEntry *tag_int_type = enum_type->data.enumeration.tag_int_type;
+ ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type;
// create debug type for tag
uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_int_type->type_ref);
@@ -1834,10 +1834,10 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
}
-TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
- TypeTableEntry *field_types[], size_t field_count)
+ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
+ ZigType *field_types[], size_t field_count)
{
- TypeTableEntry *struct_type = new_type_table_entry(TypeTableEntryIdStruct);
+ ZigType *struct_type = new_type_table_entry(TypeTableEntryIdStruct);
buf_init_from_str(&struct_type->name, type_name);
@@ -1881,7 +1881,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f
if (type_struct_field->gen_index == SIZE_MAX) {
continue;
}
- TypeTableEntry *field_type = type_struct_field->type_entry;
+ ZigType *field_type = type_struct_field->type_entry;
uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);
uint64_t debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, field_type->type_ref);
uint64_t debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, type_struct_field->gen_index);
@@ -1913,7 +1913,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f
return struct_type;
}
-static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
+static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
assert(struct_type->id == TypeTableEntryIdStruct);
if (struct_type->data.structure.complete)
@@ -1957,7 +1957,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
for (size_t i = 0; i < field_count; i += 1) {
TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];
- TypeTableEntry *field_type = type_struct_field->type_entry;
+ ZigType *field_type = type_struct_field->type_entry;
if ((err = ensure_complete_type(g, field_type))) {
struct_type->data.structure.is_invalid = true;
@@ -2088,12 +2088,12 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
continue;
}
- TypeTableEntry *field_type = type_struct_field->type_entry;
+ ZigType *field_type = type_struct_field->type_entry;
// if the field is a function, actually the debug info should be a pointer.
ZigLLVMDIType *field_di_type;
if (field_type->id == TypeTableEntryIdFn) {
- TypeTableEntry *field_ptr_type = get_pointer_to_type(g, field_type, true);
+ ZigType *field_ptr_type = get_pointer_to_type(g, field_type, true);
uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_ptr_type->type_ref);
uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_ptr_type->type_ref);
field_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, field_type->di_type,
@@ -2147,7 +2147,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
return ErrorNone;
}
-static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
+static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
assert(union_type->id == TypeTableEntryIdUnion);
if (union_type->data.unionation.complete)
@@ -2179,7 +2179,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
ZigLLVMDIType **union_inner_di_types = allocate<ZigLLVMDIType*>(gen_field_count);
- TypeTableEntry *most_aligned_union_member = nullptr;
+ ZigType *most_aligned_union_member = nullptr;
uint64_t size_of_most_aligned_member_in_bits = 0;
uint64_t biggest_align_in_bits = 0;
uint64_t biggest_size_in_bits = 0;
@@ -2194,7 +2194,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
for (uint32_t i = 0; i < field_count; i += 1) {
AstNode *field_node = decl_node->data.container_decl.fields.at(i);
TypeUnionField *union_field = &union_type->data.unionation.fields[i];
- TypeTableEntry *field_type = union_field->type_entry;
+ ZigType *field_type = union_field->type_entry;
if ((err = ensure_complete_type(g, field_type))) {
union_type->data.unionation.is_invalid = true;
@@ -2259,13 +2259,13 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
uint64_t padding_in_bits = biggest_size_in_bits - size_of_most_aligned_member_in_bits;
- TypeTableEntry *tag_type = union_type->data.unionation.tag_type;
+ ZigType *tag_type = union_type->data.unionation.tag_type;
if (tag_type == nullptr || tag_type->zero_bits) {
assert(most_aligned_union_member != nullptr);
if (padding_in_bits > 0) {
- TypeTableEntry *u8_type = get_int_type(g, false, 8);
- TypeTableEntry *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
+ ZigType *u8_type = get_int_type(g, false, 8);
+ ZigType *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
LLVMTypeRef union_element_types[] = {
most_aligned_union_member->type_ref,
padding_array->type_ref,
@@ -2295,8 +2295,8 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
LLVMTypeRef union_type_ref;
if (padding_in_bits > 0) {
- TypeTableEntry *u8_type = get_int_type(g, false, 8);
- TypeTableEntry *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
+ ZigType *u8_type = get_int_type(g, false, 8);
+ ZigType *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
LLVMTypeRef union_element_types[] = {
most_aligned_union_member->type_ref,
padding_array->type_ref,
@@ -2319,7 +2319,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
assert(8*LLVMStoreSizeOfType(g->target_data_ref, union_type_ref) >= biggest_size_in_bits);
// create llvm type for root struct
- TypeTableEntry *tag_int_type = tag_type->data.enumeration.tag_int_type;
+ ZigType *tag_int_type = tag_type->data.enumeration.tag_int_type;
uint64_t align_of_tag_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, tag_int_type->type_ref);
if (align_of_tag_in_bits >= biggest_align_in_bits) {
@@ -2387,7 +2387,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
return ErrorNone;
}
-static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
+static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {
assert(enum_type->id == TypeTableEntryIdEnum);
if (enum_type->data.enumeration.zero_bits_known)
@@ -2428,7 +2428,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> occupied_tag_values = {};
occupied_tag_values.init(field_count);
- TypeTableEntry *tag_int_type;
+ ZigType *tag_int_type;
if (enum_type->data.enumeration.layout == ContainerLayoutExtern) {
tag_int_type = get_c_int_type(g, CIntTypeInt);
} else {
@@ -2437,7 +2437,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
// TODO: Are extern enums allowed to have an init_arg_expr?
if (decl_node->data.container_decl.init_arg_expr != nullptr) {
- TypeTableEntry *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr);
+ ZigType *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr);
if (type_is_invalid(wanted_tag_int_type)) {
enum_type->data.enumeration.is_invalid = true;
} else if (wanted_tag_int_type->id != TypeTableEntryIdInt) {
@@ -2550,7 +2550,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
return ErrorNone;
}
-static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
+static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
assert(struct_type->id == TypeTableEntryIdStruct);
Error err;
@@ -2614,7 +2614,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
continue;
}
- TypeTableEntry *field_type = analyze_type_expr(g, scope, field_node->data.struct_field.type);
+ ZigType *field_type = analyze_type_expr(g, scope, field_node->data.struct_field.type);
type_struct_field->type_entry = field_type;
type_struct_field->src_index = i;
type_struct_field->gen_index = SIZE_MAX;
@@ -2669,7 +2669,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
return ErrorNone;
}
-static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
+static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
assert(union_type->id == TypeTableEntryIdUnion);
Error err;
@@ -2734,7 +2734,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
enum_type_node != nullptr;
bool auto_layout = (union_type->data.unionation.layout == ContainerLayoutAuto);
bool want_safety = (field_count >= 2) && (auto_layout || enum_type_node != nullptr);
- TypeTableEntry *tag_type;
+ ZigType *tag_type;
bool create_enum_type = decl_node->data.container_decl.auto_enum || (enum_type_node == nullptr && want_safety);
bool *covered_enum_fields;
ZigLLVMDIEnumerator **di_enumerators;
@@ -2744,7 +2744,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
di_enumerators = allocate<ZigLLVMDIEnumerator*>(field_count);
- TypeTableEntry *tag_int_type;
+ ZigType *tag_int_type;
if (enum_type_node != nullptr) {
tag_int_type = analyze_type_expr(g, scope, enum_type_node);
if (type_is_invalid(tag_int_type)) {
@@ -2779,7 +2779,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
tag_type->data.enumeration.decls_scope = union_type->data.unionation.decls_scope;
tag_type->data.enumeration.complete = true;
} else if (enum_type_node != nullptr) {
- TypeTableEntry *enum_type = analyze_type_expr(g, scope, enum_type_node);
+ ZigType *enum_type = analyze_type_expr(g, scope, enum_type_node);
if (type_is_invalid(enum_type)) {
union_type->data.unionation.is_invalid = true;
return ErrorSemanticAnalyzeFail;
@@ -2816,7 +2816,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
continue;
}
- TypeTableEntry *field_type;
+ ZigType *field_type;
if (field_node->data.struct_field.type == nullptr) {
if (decl_node->data.container_decl.auto_enum || decl_node->data.container_decl.init_arg_expr != nullptr) {
field_type = g->builtin_types.entry_void;
@@ -2860,7 +2860,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
// In this first pass we resolve explicit tag values.
// In a second pass we will fill in the unspecified ones.
if (tag_value != nullptr) {
- TypeTableEntry *tag_int_type = tag_type->data.enumeration.tag_int_type;
+ ZigType *tag_int_type = tag_type->data.enumeration.tag_int_type;
IrInstruction *result_inst = analyze_const_value(g, scope, tag_value, tag_int_type, nullptr);
if (result_inst->value.type->id == TypeTableEntryIdInvalid) {
union_type->data.unionation.is_invalid = true;
@@ -3075,7 +3075,7 @@ static bool scope_is_root_decls(Scope *scope) {
zig_unreachable();
}
-static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntry *fn_type) {
+static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, ZigType *fn_type) {
add_node_error(g, proto_node,
buf_sprintf("expected 'fn([]const u8, ?*builtin.StackTrace) noreturn', found '%s'",
buf_ptr(&fn_type->name)));
@@ -3084,30 +3084,30 @@ static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntr
static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) {
AstNode *proto_node = panic_fn->proto_node;
assert(proto_node->type == NodeTypeFnProto);
- TypeTableEntry *fn_type = panic_fn->type_entry;
+ ZigType *fn_type = panic_fn->type_entry;
FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
if (fn_type_id->param_count != 2) {
return wrong_panic_prototype(g, proto_node, fn_type);
}
- TypeTableEntry *const_u8_ptr = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *const_u8_ptr = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *const_u8_slice = get_slice_type(g, const_u8_ptr);
+ ZigType *const_u8_slice = get_slice_type(g, const_u8_ptr);
if (fn_type_id->param_info[0].type != const_u8_slice) {
return wrong_panic_prototype(g, proto_node, fn_type);
}
- TypeTableEntry *optional_ptr_to_stack_trace_type = get_optional_type(g, get_ptr_to_stack_trace_type(g));
+ ZigType *optional_ptr_to_stack_trace_type = get_optional_type(g, get_ptr_to_stack_trace_type(g));
if (fn_type_id->param_info[1].type != optional_ptr_to_stack_trace_type) {
return wrong_panic_prototype(g, proto_node, fn_type);
}
- TypeTableEntry *actual_return_type = fn_type_id->return_type;
+ ZigType *actual_return_type = fn_type_id->return_type;
if (actual_return_type != g->builtin_types.entry_unreachable) {
return wrong_panic_prototype(g, proto_node, fn_type);
}
}
-TypeTableEntry *get_test_fn_type(CodeGen *g) {
+ZigType *get_test_fn_type(CodeGen *g) {
if (g->test_fn_type)
return g->test_fn_type;
@@ -3280,7 +3280,7 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {
}
{
- TypeTableEntry *type = get_primitive_type(g, tld->name);
+ ZigType *type = get_primitive_type(g, tld->name);
if (type != nullptr) {
add_node_error(g, tld->source_node,
buf_sprintf("declaration shadows type '%s'", buf_ptr(&type->name)));
@@ -3444,7 +3444,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
}
static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {
- TypeTableEntry *type_entry = tld_container->type_entry;
+ ZigType *type_entry = tld_container->type_entry;
assert(type_entry);
switch (type_entry->id) {
@@ -3462,7 +3462,7 @@ static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {
}
}
-TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry) {
+ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
return g->builtin_types.entry_invalid;
@@ -3526,7 +3526,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent
add_error_note(g, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));
variable_entry->value->type = g->builtin_types.entry_invalid;
} else {
- TypeTableEntry *type = get_primitive_type(g, name);
+ ZigType *type = get_primitive_type(g, name);
if (type != nullptr) {
add_node_error(g, source_node,
buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));
@@ -3577,9 +3577,9 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
bool is_extern = var_decl->is_extern;
bool is_export = var_decl->is_export;
- TypeTableEntry *explicit_type = nullptr;
+ ZigType *explicit_type = nullptr;
if (var_decl->type) {
- TypeTableEntry *proposed_type = analyze_type_expr(g, tld_var->base.parent_scope, var_decl->type);
+ ZigType *proposed_type = analyze_type_expr(g, tld_var->base.parent_scope, var_decl->type);
explicit_type = validate_var_type(g, var_decl->type, proposed_type);
}
@@ -3597,7 +3597,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
IrInstruction *init_value = nullptr;
// TODO more validation for types that can't be used for export/extern variables
- TypeTableEntry *implicit_type = nullptr;
+ ZigType *implicit_type = nullptr;
if (explicit_type && explicit_type->id == TypeTableEntryIdInvalid) {
implicit_type = explicit_type;
} else if (var_decl->expr) {
@@ -3627,7 +3627,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
implicit_type = g->builtin_types.entry_invalid;
}
- TypeTableEntry *type = explicit_type ? explicit_type : implicit_type;
+ ZigType *type = explicit_type ? explicit_type : implicit_type;
assert(type != nullptr); // should have been caught by the parser
ConstExprValue *init_val = init_value ? &init_value->value : create_const_runtime(type);
@@ -3789,7 +3789,7 @@ FnTableEntry *scope_get_fn_if_root(Scope *scope) {
return nullptr;
}
-TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) {
+TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) {
assert(enum_type->id == TypeTableEntryIdEnum);
if (enum_type->data.enumeration.src_field_count == 0)
return nullptr;
@@ -3799,7 +3799,7 @@ TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) {
return entry->value;
}
-TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name) {
+TypeStructField *find_struct_type_field(ZigType *type_entry, Buf *name) {
assert(type_entry->id == TypeTableEntryIdStruct);
assert(type_entry->data.structure.complete);
if (type_entry->data.structure.src_field_count == 0)
@@ -3810,7 +3810,7 @@ TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name) {
return entry->value;
}
-TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name) {
+TypeUnionField *find_union_type_field(ZigType *type_entry, Buf *name) {
assert(type_entry->id == TypeTableEntryIdUnion);
assert(type_entry->data.unionation.zero_bits_known);
if (type_entry->data.unionation.src_field_count == 0)
@@ -3821,7 +3821,7 @@ TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name) {
return entry->value;
}
-TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt *tag) {
+TypeUnionField *find_union_field_by_tag(ZigType *type_entry, const BigInt *tag) {
assert(type_entry->id == TypeTableEntryIdUnion);
assert(type_entry->data.unionation.zero_bits_known);
for (uint32_t i = 0; i < type_entry->data.unionation.src_field_count; i += 1) {
@@ -3833,7 +3833,7 @@ TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt
return nullptr;
}
-TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *tag) {
+TypeEnumField *find_enum_field_by_tag(ZigType *enum_type, const BigInt *tag) {
assert(enum_type->data.enumeration.zero_bits_known);
for (uint32_t i = 0; i < enum_type->data.enumeration.src_field_count; i += 1) {
TypeEnumField *field = &enum_type->data.enumeration.fields[i];
@@ -3845,7 +3845,7 @@ TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *t
}
-static bool is_container(TypeTableEntry *type_entry) {
+static bool is_container(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -3880,28 +3880,28 @@ static bool is_container(TypeTableEntry *type_entry) {
zig_unreachable();
}
-bool is_ref(TypeTableEntry *type_entry) {
+bool is_ref(ZigType *type_entry) {
return type_entry->id == TypeTableEntryIdPointer && type_entry->data.pointer.ptr_len == PtrLenSingle;
}
-bool is_array_ref(TypeTableEntry *type_entry) {
- TypeTableEntry *array = is_ref(type_entry) ?
+bool is_array_ref(ZigType *type_entry) {
+ ZigType *array = is_ref(type_entry) ?
type_entry->data.pointer.child_type : type_entry;
return array->id == TypeTableEntryIdArray;
}
-bool is_container_ref(TypeTableEntry *type_entry) {
+bool is_container_ref(ZigType *type_entry) {
return is_ref(type_entry) ?
is_container(type_entry->data.pointer.child_type) : is_container(type_entry);
}
-TypeTableEntry *container_ref_type(TypeTableEntry *type_entry) {
+ZigType *container_ref_type(ZigType *type_entry) {
assert(is_container_ref(type_entry));
return is_ref(type_entry) ?
type_entry->data.pointer.child_type : type_entry;
}
-void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
+void resolve_container_type(CodeGen *g, ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdStruct:
resolve_struct_type(g, type_entry);
@@ -3939,7 +3939,7 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
}
}
-TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {
+ZigType *get_codegen_ptr_type(ZigType *type) {
if (type->id == TypeTableEntryIdPointer) return type;
if (type->id == TypeTableEntryIdFn) return type;
if (type->id == TypeTableEntryIdPromise) return type;
@@ -3951,12 +3951,12 @@ TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {
return nullptr;
}
-bool type_is_codegen_pointer(TypeTableEntry *type) {
+bool type_is_codegen_pointer(ZigType *type) {
return get_codegen_ptr_type(type) == type;
}
-uint32_t get_ptr_align(TypeTableEntry *type) {
- TypeTableEntry *ptr_type = get_codegen_ptr_type(type);
+uint32_t get_ptr_align(ZigType *type) {
+ ZigType *ptr_type = get_codegen_ptr_type(type);
if (ptr_type->id == TypeTableEntryIdPointer) {
return ptr_type->data.pointer.alignment;
} else if (ptr_type->id == TypeTableEntryIdFn) {
@@ -3968,8 +3968,8 @@ uint32_t get_ptr_align(TypeTableEntry *type) {
}
}
-bool get_ptr_const(TypeTableEntry *type) {
- TypeTableEntry *ptr_type = get_codegen_ptr_type(type);
+bool get_ptr_const(ZigType *type) {
+ ZigType *ptr_type = get_codegen_ptr_type(type);
if (ptr_type->id == TypeTableEntryIdPointer) {
return ptr_type->data.pointer.is_const;
} else if (ptr_type->id == TypeTableEntryIdFn) {
@@ -3991,7 +3991,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {
}
static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) {
- TypeTableEntry *fn_type = fn_table_entry->type_entry;
+ ZigType *fn_type = fn_table_entry->type_entry;
assert(!fn_type->data.fn.is_generic);
FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
@@ -4008,7 +4008,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
continue;
}
- TypeTableEntry *param_type = param_info->type;
+ ZigType *param_type = param_info->type;
bool is_noalias = param_info->is_noalias;
if (is_noalias && get_codegen_ptr_type(param_type) == nullptr) {
@@ -4031,7 +4031,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
}
}
-bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node) {
+bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) {
FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;
if (infer_fn != nullptr) {
if (infer_fn->anal_state == FnAnalStateInvalid) {
@@ -4053,11 +4053,11 @@ bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNod
}
void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) {
- TypeTableEntry *fn_type = fn_table_entry->type_entry;
+ ZigType *fn_type = fn_table_entry->type_entry;
assert(!fn_type->data.fn.is_generic);
FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
- TypeTableEntry *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable,
+ ZigType *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable,
&fn_table_entry->analyzed_executable, fn_type_id->return_type, return_type_node);
fn_table_entry->src_implicit_return_type = block_return_type;
@@ -4068,9 +4068,9 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ
}
if (fn_type_id->return_type->id == TypeTableEntryIdErrorUnion) {
- TypeTableEntry *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type;
+ ZigType *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type;
if (return_err_set_type->data.error_set.infer_fn != nullptr) {
- TypeTableEntry *inferred_err_set_type;
+ ZigType *inferred_err_set_type;
if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorSet) {
inferred_err_set_type = fn_table_entry->src_implicit_return_type;
} else if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorUnion) {
@@ -4129,7 +4129,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
define_local_param_variables(g, fn_table_entry);
- TypeTableEntry *fn_type = fn_table_entry->type_entry;
+ ZigType *fn_type = fn_table_entry->type_entry;
assert(!fn_type->data.fn.is_generic);
ir_gen_fn(g, fn_table_entry);
@@ -4355,7 +4355,7 @@ void semantic_analyze(CodeGen *g) {
}
}
-TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
+ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
TypeId type_id = {};
type_id.id = TypeTableEntryIdInt;
type_id.data.integer.is_signed = is_signed;
@@ -4367,20 +4367,20 @@ TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits)
return entry->value;
}
- TypeTableEntry *new_entry = make_int_type(g, is_signed, size_in_bits);
+ ZigType *new_entry = make_int_type(g, is_signed, size_in_bits);
g->type_table.put(type_id, new_entry);
return new_entry;
}
-TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type) {
+ZigType **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type) {
return &g->builtin_types.entry_c_int[c_int_type];
}
-TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type) {
+ZigType *get_c_int_type(CodeGen *g, CIntType c_int_type) {
return *get_c_int_type_ptr(g, c_int_type);
}
-bool handle_is_ptr(TypeTableEntry *type_entry) {
+bool handle_is_ptr(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
case TypeTableEntryIdMetaType:
@@ -4916,7 +4916,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
zig_unreachable();
}
-static bool return_type_is_cacheable(TypeTableEntry *return_type) {
+static bool return_type_is_cacheable(ZigType *return_type) {
switch (return_type->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -4958,7 +4958,7 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {
zig_unreachable();
}
-bool fn_eval_cacheable(Scope *scope, TypeTableEntry *return_type) {
+bool fn_eval_cacheable(Scope *scope, ZigType *return_type) {
if (!return_type_is_cacheable(return_type))
return false;
while (scope) {
@@ -5027,14 +5027,14 @@ bool fn_eval_eql(Scope *a, Scope *b) {
return false;
}
-bool type_has_bits(TypeTableEntry *type_entry) {
+bool type_has_bits(ZigType *type_entry) {
assert(type_entry);
assert(type_entry->id != TypeTableEntryIdInvalid);
assert(type_has_zero_bits_known(type_entry));
return !type_entry->zero_bits;
}
-bool type_requires_comptime(TypeTableEntry *type_entry) {
+bool type_requires_comptime(ZigType *type_entry) {
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
case TypeTableEntryIdOpaque:
@@ -5143,27 +5143,27 @@ ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *str) {
return const_val;
}
-void init_const_bigint(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *bigint) {
+void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint) {
const_val->special = ConstValSpecialStatic;
const_val->type = type;
bigint_init_bigint(&const_val->data.x_bigint, bigint);
}
-ConstExprValue *create_const_bigint(TypeTableEntry *type, const BigInt *bigint) {
+ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint) {
ConstExprValue *const_val = create_const_vals(1);
init_const_bigint(const_val, type, bigint);
return const_val;
}
-void init_const_unsigned_negative(ConstExprValue *const_val, TypeTableEntry *type, uint64_t x, bool negative) {
+void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative) {
const_val->special = ConstValSpecialStatic;
const_val->type = type;
bigint_init_unsigned(&const_val->data.x_bigint, x);
const_val->data.x_bigint.is_negative = negative;
}
-ConstExprValue *create_const_unsigned_negative(TypeTableEntry *type, uint64_t x, bool negative) {
+ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative) {
ConstExprValue *const_val = create_const_vals(1);
init_const_unsigned_negative(const_val, type, x, negative);
return const_val;
@@ -5177,19 +5177,19 @@ ConstExprValue *create_const_usize(CodeGen *g, uint64_t x) {
return create_const_unsigned_negative(g->builtin_types.entry_usize, x, false);
}
-void init_const_signed(ConstExprValue *const_val, TypeTableEntry *type, int64_t x) {
+void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x) {
const_val->special = ConstValSpecialStatic;
const_val->type = type;
bigint_init_signed(&const_val->data.x_bigint, x);
}
-ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x) {
+ConstExprValue *create_const_signed(ZigType *type, int64_t x) {
ConstExprValue *const_val = create_const_vals(1);
init_const_signed(const_val, type, x);
return const_val;
}
-void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value) {
+void init_const_float(ConstExprValue *const_val, ZigType *type, double value) {
const_val->special = ConstValSpecialStatic;
const_val->type = type;
if (type->id == TypeTableEntryIdComptimeFloat) {
@@ -5216,19 +5216,19 @@ void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double va
}
}
-ConstExprValue *create_const_float(TypeTableEntry *type, double value) {
+ConstExprValue *create_const_float(ZigType *type, double value) {
ConstExprValue *const_val = create_const_vals(1);
init_const_float(const_val, type, value);
return const_val;
}
-void init_const_enum(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *tag) {
+void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag) {
const_val->special = ConstValSpecialStatic;
const_val->type = type;
bigint_init_bigint(&const_val->data.x_enum_tag, tag);
}
-ConstExprValue *create_const_enum(TypeTableEntry *type, const BigInt *tag) {
+ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag) {
ConstExprValue *const_val = create_const_vals(1);
init_const_enum(const_val, type, tag);
return const_val;
@@ -5247,24 +5247,24 @@ ConstExprValue *create_const_bool(CodeGen *g, bool value) {
return const_val;
}
-void init_const_runtime(ConstExprValue *const_val, TypeTableEntry *type) {
+void init_const_runtime(ConstExprValue *const_val, ZigType *type) {
const_val->special = ConstValSpecialRuntime;
const_val->type = type;
}
-ConstExprValue *create_const_runtime(TypeTableEntry *type) {
+ConstExprValue *create_const_runtime(ZigType *type) {
ConstExprValue *const_val = create_const_vals(1);
init_const_runtime(const_val, type);
return const_val;
}
-void init_const_type(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *type_value) {
+void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value) {
const_val->special = ConstValSpecialStatic;
const_val->type = g->builtin_types.entry_type;
const_val->data.x_type = type_value;
}
-ConstExprValue *create_const_type(CodeGen *g, TypeTableEntry *type_value) {
+ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value) {
ConstExprValue *const_val = create_const_vals(1);
init_const_type(g, const_val, type_value);
return const_val;
@@ -5275,7 +5275,7 @@ void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *arr
{
assert(array_val->type->id == TypeTableEntryIdArray);
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, array_val->type->data.array.child_type,
+ ZigType *ptr_type = get_pointer_to_type_extra(g, array_val->type->data.array.child_type,
is_const, false, PtrLenUnknown, get_abi_alignment(g, array_val->type->data.array.child_type),
0, 0);
@@ -5298,7 +5298,7 @@ void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue
size_t elem_index, bool is_const, PtrLen ptr_len)
{
assert(array_val->type->id == TypeTableEntryIdArray);
- TypeTableEntry *child_type = array_val->type->data.array.child_type;
+ ZigType *child_type = array_val->type->data.array.child_type;
const_val->special = ConstValSpecialStatic;
const_val->type = get_pointer_to_type_extra(g, child_type, is_const, false,
@@ -5329,7 +5329,7 @@ ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bo
return const_val;
}
-void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *pointee_type,
+void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
size_t addr, bool is_const)
{
const_val->special = ConstValSpecialStatic;
@@ -5338,7 +5338,7 @@ void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeT
const_val->data.x_ptr.data.hard_coded_addr.addr = addr;
}
-ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, TypeTableEntry *pointee_type,
+ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
size_t addr, bool is_const)
{
ConstExprValue *const_val = create_const_vals(1);
@@ -5362,7 +5362,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_
void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
Error err;
- TypeTableEntry *wanted_type = const_val->type;
+ ZigType *wanted_type = const_val->type;
if (wanted_type->id == TypeTableEntryIdArray) {
const_val->special = ConstValSpecialStatic;
const_val->data.x_array.special = ConstArraySpecialUndef;
@@ -5400,7 +5400,7 @@ ConstExprValue *create_const_vals(size_t count) {
return vals;
}
-Error ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {
+Error ensure_complete_type(CodeGen *g, ZigType *type_entry) {
if (type_is_invalid(type_entry))
return ErrorSemanticAnalyzeFail;
if (type_entry->id == TypeTableEntryIdStruct) {
@@ -5416,7 +5416,7 @@ Error ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {
return ErrorNone;
}
-Error type_ensure_zero_bits_known(CodeGen *g, TypeTableEntry *type_entry) {
+Error type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry) {
if (type_is_invalid(type_entry))
return ErrorSemanticAnalyzeFail;
if (type_entry->id == TypeTableEntryIdStruct) {
@@ -5591,7 +5591,7 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
zig_unreachable();
}
-void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint, bool is_max) {
+void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max) {
assert(int_type->id == TypeTableEntryIdInt);
if (int_type->data.integral.bit_count == 0) {
bigint_init_unsigned(bigint, 0);
@@ -5628,7 +5628,7 @@ void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint
}
}
-void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *const_val, bool is_max) {
+void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max) {
if (type_entry->id == TypeTableEntryIdInt) {
const_val->special = ConstValSpecialStatic;
eval_min_max_value_int(g, type_entry, &const_val->data.x_bigint, is_max);
@@ -5642,7 +5642,7 @@ void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *
}
}
-void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, TypeTableEntry *type_entry) {
+void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {
switch (const_val->data.x_ptr.special) {
case ConstPtrSpecialInvalid:
zig_unreachable();
@@ -5690,7 +5690,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
}
assert(const_val->type);
- TypeTableEntry *type_entry = const_val->type;
+ ZigType *type_entry = const_val->type;
switch (type_entry->id) {
case TypeTableEntryIdOpaque:
zig_unreachable();
@@ -5765,7 +5765,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
}
case TypeTableEntryIdArray:
{
- TypeTableEntry *child_type = type_entry->data.array.child_type;
+ ZigType *child_type = type_entry->data.array.child_type;
uint64_t len = type_entry->data.array.len;
if (const_val->data.x_array.special == ConstArraySpecialUndef) {
@@ -5878,8 +5878,8 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
zig_unreachable();
}
-TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
+ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
entry->is_copyable = true;
entry->type_ref = (size_in_bits == 0) ? LLVMVoidType() : LLVMIntType(size_in_bits);
entry->zero_bits = (size_in_bits == 0);
@@ -6071,7 +6071,7 @@ void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {
ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {
assert(value->type);
- TypeTableEntry *type_entry = value->type;
+ ZigType *type_entry = value->type;
if (type_entry->id == TypeTableEntryIdArray) {
expand_undef_array(g, value);
return &value->data.x_array.s_none.parent;
@@ -6083,7 +6083,7 @@ ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {
return nullptr;
}
-static const TypeTableEntryId all_type_ids[] = {
+static const ZigTypeId all_type_ids[] = {
TypeTableEntryIdMetaType,
TypeTableEntryIdVoid,
TypeTableEntryIdBool,
@@ -6111,7 +6111,7 @@ static const TypeTableEntryId all_type_ids[] = {
TypeTableEntryIdPromise,
};
-TypeTableEntryId type_id_at_index(size_t index) {
+ZigTypeId type_id_at_index(size_t index) {
assert(index < array_length(all_type_ids));
return all_type_ids[index];
}
@@ -6120,7 +6120,7 @@ size_t type_id_len() {
return array_length(all_type_ids);
}
-size_t type_id_index(TypeTableEntry *entry) {
+size_t type_id_index(ZigType *entry) {
switch (entry->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -6180,7 +6180,7 @@ size_t type_id_index(TypeTableEntry *entry) {
zig_unreachable();
}
-const char *type_id_name(TypeTableEntryId id) {
+const char *type_id_name(ZigTypeId id) {
switch (id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -6266,7 +6266,7 @@ LinkLib *add_link_lib(CodeGen *g, Buf *name) {
return link_lib;
}
-uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) {
+uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry) {
assertNoError(type_ensure_zero_bits_known(g, type_entry));
if (type_entry->zero_bits) return 0;
@@ -6290,7 +6290,7 @@ uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) {
}
}
-TypeTableEntry *get_align_amt_type(CodeGen *g) {
+ZigType *get_align_amt_type(CodeGen *g) {
if (g->align_amt_type == nullptr) {
// according to LLVM the maximum alignment is 1 << 29.
g->align_amt_type = get_int_type(g, false, 29);
@@ -6298,11 +6298,11 @@ TypeTableEntry *get_align_amt_type(CodeGen *g) {
return g->align_amt_type;
}
-uint32_t type_ptr_hash(const TypeTableEntry *ptr) {
+uint32_t type_ptr_hash(const ZigType *ptr) {
return hash_ptr((void*)ptr);
}
-bool type_ptr_eql(const TypeTableEntry *a, const TypeTableEntry *b) {
+bool type_ptr_eql(const ZigType *a, const ZigType *b) {
return a == b;
}
@@ -6316,7 +6316,7 @@ ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) {
return var_value;
}
-bool type_is_global_error_set(TypeTableEntry *err_set_type) {
+bool type_is_global_error_set(ZigType *err_set_type) {
assert(err_set_type->id == TypeTableEntryIdErrorSet);
assert(err_set_type->data.error_set.infer_fn == nullptr);
return err_set_type->data.error_set.err_count == UINT32_MAX;
@@ -6326,7 +6326,7 @@ uint32_t get_coro_frame_align_bytes(CodeGen *g) {
return g->pointer_size_bytes * 2;
}
-bool type_can_fail(TypeTableEntry *type_entry) {
+bool type_can_fail(ZigType *type_entry) {
return type_entry->id == TypeTableEntryIdErrorUnion || type_entry->id == TypeTableEntryIdErrorSet;
}
@@ -6334,7 +6334,7 @@ bool fn_type_can_fail(FnTypeId *fn_type_id) {
return type_can_fail(fn_type_id->return_type) || fn_type_id->cc == CallingConventionAsync;
}
-TypeTableEntry *get_primitive_type(CodeGen *g, Buf *name) {
+ZigType *get_primitive_type(CodeGen *g, Buf *name) {
if (buf_len(name) >= 2) {
uint8_t first_c = buf_ptr(name)[0];
if (first_c == 'i' || first_c == 'u') {
src/analyze.hpp
@@ -14,35 +14,35 @@
void semantic_analyze(CodeGen *g);
ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg);
ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *msg);
-TypeTableEntry *new_type_table_entry(TypeTableEntryId id);
-TypeTableEntry *get_pointer_to_type(CodeGen *g, TypeTableEntry *child_type, bool is_const);
-TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type, bool is_const,
+ZigType *new_type_table_entry(ZigTypeId id);
+ZigType *get_pointer_to_type(CodeGen *g, ZigType *child_type, bool is_const);
+ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_const,
bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count);
-uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry);
-uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry);
-TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
-TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
-TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);
-TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);
-TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type);
-TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t array_size);
-TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type);
-TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
+uint64_t type_size(CodeGen *g, ZigType *type_entry);
+uint64_t type_size_bits(CodeGen *g, ZigType *type_entry);
+ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
+ZigType **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
+ZigType *get_c_int_type(CodeGen *g, CIntType c_int_type);
+ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);
+ZigType *get_optional_type(CodeGen *g, ZigType *child_type);
+ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size);
+ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type);
+ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
AstNode *decl_node, const char *name, ContainerLayout layout);
-TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
-TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *payload_type);
-TypeTableEntry *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry);
-TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name);
-TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
- TypeTableEntry *field_types[], size_t field_count);
-TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type);
-TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type);
-TypeTableEntry *get_test_fn_type(CodeGen *g);
-bool handle_is_ptr(TypeTableEntry *type_entry);
+ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
+ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type);
+ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry);
+ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name);
+ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
+ ZigType *field_types[], size_t field_count);
+ZigType *get_promise_type(CodeGen *g, ZigType *result_type);
+ZigType *get_promise_frame_type(CodeGen *g, ZigType *return_type);
+ZigType *get_test_fn_type(CodeGen *g);
+bool handle_is_ptr(ZigType *type_entry);
void find_libc_include_path(CodeGen *g);
void find_libc_lib_path(CodeGen *g);
-bool type_has_bits(TypeTableEntry *type_entry);
+bool type_has_bits(ZigType *type_entry);
ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *abs_full_path, Buf *source_code);
@@ -51,28 +51,28 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *a
VariableTableEntry *find_variable(CodeGen *g, Scope *orig_context, Buf *name);
Tld *find_decl(CodeGen *g, Scope *scope, Buf *name);
void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only, AstNode *source_node);
-bool type_is_codegen_pointer(TypeTableEntry *type);
-
-TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type);
-uint32_t get_ptr_align(TypeTableEntry *type);
-bool get_ptr_const(TypeTableEntry *type);
-TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry);
-TypeTableEntry *container_ref_type(TypeTableEntry *type_entry);
-bool type_is_complete(TypeTableEntry *type_entry);
-bool type_is_invalid(TypeTableEntry *type_entry);
-bool type_is_global_error_set(TypeTableEntry *err_set_type);
-bool type_has_zero_bits_known(TypeTableEntry *type_entry);
-void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry);
-ScopeDecls *get_container_scope(TypeTableEntry *type_entry);
-TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name);
-TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name);
-TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name);
-TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *tag);
-TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt *tag);
-
-bool is_ref(TypeTableEntry *type_entry);
-bool is_array_ref(TypeTableEntry *type_entry);
-bool is_container_ref(TypeTableEntry *type_entry);
+bool type_is_codegen_pointer(ZigType *type);
+
+ZigType *get_codegen_ptr_type(ZigType *type);
+uint32_t get_ptr_align(ZigType *type);
+bool get_ptr_const(ZigType *type);
+ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry);
+ZigType *container_ref_type(ZigType *type_entry);
+bool type_is_complete(ZigType *type_entry);
+bool type_is_invalid(ZigType *type_entry);
+bool type_is_global_error_set(ZigType *err_set_type);
+bool type_has_zero_bits_known(ZigType *type_entry);
+void resolve_container_type(CodeGen *g, ZigType *type_entry);
+ScopeDecls *get_container_scope(ZigType *type_entry);
+TypeStructField *find_struct_type_field(ZigType *type_entry, Buf *name);
+TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name);
+TypeUnionField *find_union_type_field(ZigType *type_entry, Buf *name);
+TypeEnumField *find_enum_field_by_tag(ZigType *enum_type, const BigInt *tag);
+TypeUnionField *find_union_field_by_tag(ZigType *type_entry, const BigInt *tag);
+
+bool is_ref(ZigType *type_entry);
+bool is_array_ref(ZigType *type_entry);
+bool is_container_ref(ZigType *type_entry);
void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node);
void scan_import(CodeGen *g, ImportTableEntry *import);
void preview_use_decl(CodeGen *g, AstNode *node);
@@ -82,20 +82,20 @@ ImportTableEntry *get_scope_import(Scope *scope);
void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope);
VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,
bool is_const, ConstExprValue *init_value, Tld *src_tld);
-TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
+ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
FnTableEntry *create_fn(AstNode *proto_node);
FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
FnTableEntry *scope_get_fn_if_root(Scope *scope);
-bool type_requires_comptime(TypeTableEntry *type_entry);
-Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry);
-Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, TypeTableEntry *type_entry);
-void complete_enum(CodeGen *g, TypeTableEntry *enum_type);
+bool type_requires_comptime(ZigType *type_entry);
+Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry);
+Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry);
+void complete_enum(CodeGen *g, ZigType *enum_type);
bool ir_get_var_is_comptime(VariableTableEntry *var);
bool const_values_equal(ConstExprValue *a, ConstExprValue *b);
-void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *const_val, bool is_max);
-void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint, bool is_max);
+void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max);
+void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max);
void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val);
void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node);
@@ -108,7 +108,7 @@ ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent);
ScopeLoop *create_loop_scope(AstNode *node, Scope *parent);
ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent);
ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry);
-ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, TypeTableEntry *container_type, ImportTableEntry *import);
+ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import);
Scope *create_comptime_scope(AstNode *node, Scope *parent);
Scope *create_coro_prelude_scope(AstNode *node, Scope *parent);
Scope *create_runtime_scope(AstNode *node, Scope *parent, IrInstruction *is_comptime);
@@ -119,39 +119,39 @@ ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);
void init_const_c_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *c_str);
ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *c_str);
-void init_const_bigint(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *bigint);
-ConstExprValue *create_const_bigint(TypeTableEntry *type, const BigInt *bigint);
+void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint);
+ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint);
-void init_const_unsigned_negative(ConstExprValue *const_val, TypeTableEntry *type, uint64_t x, bool negative);
-ConstExprValue *create_const_unsigned_negative(TypeTableEntry *type, uint64_t x, bool negative);
+void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative);
+ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative);
-void init_const_signed(ConstExprValue *const_val, TypeTableEntry *type, int64_t x);
-ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x);
+void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x);
+ConstExprValue *create_const_signed(ZigType *type, int64_t x);
void init_const_usize(CodeGen *g, ConstExprValue *const_val, uint64_t x);
ConstExprValue *create_const_usize(CodeGen *g, uint64_t x);
-void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value);
-ConstExprValue *create_const_float(TypeTableEntry *type, double value);
+void init_const_float(ConstExprValue *const_val, ZigType *type, double value);
+ConstExprValue *create_const_float(ZigType *type, double value);
-void init_const_enum(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *tag);
-ConstExprValue *create_const_enum(TypeTableEntry *type, const BigInt *tag);
+void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag);
+ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag);
void init_const_bool(CodeGen *g, ConstExprValue *const_val, bool value);
ConstExprValue *create_const_bool(CodeGen *g, bool value);
-void init_const_type(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *type_value);
-ConstExprValue *create_const_type(CodeGen *g, TypeTableEntry *type_value);
+void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value);
+ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value);
-void init_const_runtime(ConstExprValue *const_val, TypeTableEntry *type);
-ConstExprValue *create_const_runtime(TypeTableEntry *type);
+void init_const_runtime(ConstExprValue *const_val, ZigType *type);
+ConstExprValue *create_const_runtime(ZigType *type);
void init_const_ptr_ref(CodeGen *g, ConstExprValue *const_val, ConstExprValue *pointee_val, bool is_const);
ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bool is_const);
-void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *pointee_type,
+void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
size_t addr, bool is_const);
-ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, TypeTableEntry *pointee_type,
+ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
size_t addr, bool is_const);
void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
@@ -170,23 +170,23 @@ void init_const_undefined(CodeGen *g, ConstExprValue *const_val);
ConstExprValue *create_const_vals(size_t count);
-TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
+ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value);
void expand_undef_array(CodeGen *g, ConstExprValue *const_val);
void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value);
-const char *type_id_name(TypeTableEntryId id);
-TypeTableEntryId type_id_at_index(size_t index);
+const char *type_id_name(ZigTypeId id);
+ZigTypeId type_id_at_index(size_t index);
size_t type_id_len();
-size_t type_id_index(TypeTableEntry *entry);
-TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id);
-Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry);
+size_t type_id_index(ZigType *entry);
+ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id);
+Result<bool> type_is_copyable(CodeGen *g, ZigType *type_entry);
LinkLib *create_link_lib(Buf *name);
bool calling_convention_does_first_arg_return(CallingConvention cc);
LinkLib *add_link_lib(CodeGen *codegen, Buf *lib);
-uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry);
-TypeTableEntry *get_align_amt_type(CodeGen *g);
+uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry);
+ZigType *get_align_amt_type(CodeGen *g);
PackageTableEntry *new_anonymous_package(void);
Buf *const_value_to_buffer(ConstExprValue *const_val);
@@ -194,17 +194,17 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G
ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
-TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g);
-bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node);
+ZigType *get_ptr_to_stack_trace_type(CodeGen *g);
+bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node);
-TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);
+ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);
uint32_t get_coro_frame_align_bytes(CodeGen *g);
bool fn_type_can_fail(FnTypeId *fn_type_id);
-bool type_can_fail(TypeTableEntry *type_entry);
-bool fn_eval_cacheable(Scope *scope, TypeTableEntry *return_type);
-AstNode *type_decl_node(TypeTableEntry *type_entry);
+bool type_can_fail(ZigType *type_entry);
+bool fn_eval_cacheable(Scope *scope, ZigType *return_type);
+AstNode *type_decl_node(ZigType *type_entry);
-TypeTableEntry *get_primitive_type(CodeGen *g, Buf *name);
+ZigType *get_primitive_type(CodeGen *g, Buf *name);
#endif
src/codegen.cpp
@@ -437,11 +437,11 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e
if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync) {
return 0;
}
- TypeTableEntry *fn_type = fn_table_entry->type_entry;
+ ZigType *fn_type = fn_table_entry->type_entry;
if (!fn_type_can_fail(&fn_type->data.fn.fn_type_id)) {
return UINT32_MAX;
}
- TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;
+ ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
bool first_arg_ret = type_has_bits(return_type) && handle_is_ptr(return_type);
return first_arg_ret ? 1 : 0;
}
@@ -474,7 +474,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
}
- TypeTableEntry *fn_type = fn_table_entry->type_entry;
+ ZigType *fn_type = fn_table_entry->type_entry;
LLVMTypeRef fn_llvm_type = fn_type->data.fn.raw_type_ref;
if (fn_table_entry->body_node == nullptr) {
LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name));
@@ -532,7 +532,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
LLVMSetUnnamedAddr(fn_table_entry->llvm_value, true);
}
- TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;
+ ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
if (return_type->id == TypeTableEntryIdUnreachable) {
addLLVMFnAttr(fn_table_entry->llvm_value, "noreturn");
}
@@ -596,7 +596,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
FnTypeParamInfo *param_info = &fn_type->data.fn.fn_type_id.param_info[param_i];
- TypeTableEntry *param_type = gen_info->type;
+ ZigType *param_type = gen_info->type;
if (param_info->is_noalias) {
addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "noalias");
}
@@ -688,7 +688,7 @@ static void clear_debug_source_node(CodeGen *g) {
ZigLLVMClearCurrentDebugLocation(g->builder);
}
-static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
+static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, ZigType *type_entry,
const char *signed_name, const char *unsigned_name)
{
char fn_name[64];
@@ -712,7 +712,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_
return fn_val;
}
-static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry, AddSubMul add_sub_mul) {
+static LLVMValueRef get_int_overflow_fn(CodeGen *g, ZigType *type_entry, AddSubMul add_sub_mul) {
assert(type_entry->id == TypeTableEntryIdInt);
ZigLLVMFnKey key = {};
@@ -742,7 +742,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
return fn_val;
}
-static LLVMValueRef get_float_fn(CodeGen *g, TypeTableEntry *type_entry, ZigLLVMFnId fn_id) {
+static LLVMValueRef get_float_fn(CodeGen *g, ZigType *type_entry, ZigLLVMFnId fn_id) {
assert(type_entry->id == TypeTableEntryIdFloat);
ZigLLVMFnKey key = {};
@@ -787,7 +787,7 @@ static LLVMValueRef gen_store_untyped(CodeGen *g, LLVMValueRef value, LLVMValueR
return instruction;
}
-static LLVMValueRef gen_store(CodeGen *g, LLVMValueRef value, LLVMValueRef ptr, TypeTableEntry *ptr_type) {
+static LLVMValueRef gen_store(CodeGen *g, LLVMValueRef value, LLVMValueRef ptr, ZigType *ptr_type) {
assert(ptr_type->id == TypeTableEntryIdPointer);
return gen_store_untyped(g, value, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile);
}
@@ -805,12 +805,12 @@ static LLVMValueRef gen_load_untyped(CodeGen *g, LLVMValueRef ptr, uint32_t alig
return result;
}
-static LLVMValueRef gen_load(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *ptr_type, const char *name) {
+static LLVMValueRef gen_load(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type, const char *name) {
assert(ptr_type->id == TypeTableEntryIdPointer);
return gen_load_untyped(g, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile, name);
}
-static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *type, TypeTableEntry *ptr_type) {
+static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, ZigType *type, ZigType *ptr_type) {
if (type_has_bits(type)) {
if (handle_is_ptr(type)) {
return ptr;
@@ -918,9 +918,9 @@ static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) {
assert(val->global_refs->llvm_global);
}
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);
+ ZigType *str_type = get_slice_type(g, u8_ptr_type);
return LLVMConstBitCast(val->global_refs->llvm_global, LLVMPointerType(str_type->type_ref, 0));
}
@@ -929,7 +929,7 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace
LLVMValueRef fn_val = fn_llvm_value(g, g->panic_fn);
LLVMCallConv llvm_cc = get_llvm_cc(g, g->panic_fn->type_entry->data.fn.fn_type_id.cc);
if (stack_trace_arg == nullptr) {
- TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
+ ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
stack_trace_arg = LLVMConstNull(ptr_to_stack_trace_type->type_ref);
}
LLVMValueRef args[] = {
@@ -1186,7 +1186,7 @@ static LLVMValueRef get_return_address_fn_val(CodeGen *g) {
if (g->return_address_fn_val)
return g->return_address_fn_val;
- TypeTableEntry *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
+ ZigType *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,
&g->builtin_types.entry_i32->type_ref, 1, false);
@@ -1237,7 +1237,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {
size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;
LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, err_ret_trace_ptr, (unsigned)addresses_field_index, "");
- TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
+ ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");
size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
@@ -1337,7 +1337,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
(unsigned)src_index_field_index, "");
LLVMValueRef src_addresses_field_ptr = LLVMBuildStructGEP(g->builder, src_stack_trace_ptr,
(unsigned)src_addresses_field_index, "");
- TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
+ ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
LLVMValueRef src_ptr_field_ptr = LLVMBuildStructGEP(g->builder, src_addresses_field_ptr, (unsigned)ptr_field_index, "");
size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
@@ -1479,7 +1479,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
LLVMSetUnnamedAddr(global_array, true);
LLVMSetAlignment(global_array, u8_align_bytes);
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
LLVMValueRef full_buf_ptr_indices[] = {
LLVMConstNull(usize->type_ref),
LLVMConstNull(usize->type_ref),
@@ -1487,9 +1487,9 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
LLVMValueRef full_buf_ptr = LLVMConstInBoundsGEP(global_array, full_buf_ptr_indices, 2);
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);
+ ZigType *str_type = get_slice_type(g, u8_ptr_type);
LLVMValueRef global_slice_fields[] = {
full_buf_ptr,
LLVMConstNull(usize->type_ref),
@@ -1603,7 +1603,7 @@ static void gen_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val, Scope *sc
LLVMValueRef safety_crash_err_fn = get_safety_crash_err_fn(g);
LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, scope);
if (err_ret_trace_val == nullptr) {
- TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
+ ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
err_ret_trace_val = LLVMConstNull(ptr_to_stack_trace_type->type_ref);
}
LLVMValueRef args[] = {
@@ -1649,8 +1649,8 @@ static void add_bounds_check(CodeGen *g, LLVMValueRef target_val,
LLVMPositionBuilderAtEnd(g->builder, ok_block);
}
-static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, TypeTableEntry *actual_type,
- TypeTableEntry *wanted_type, LLVMValueRef expr_val)
+static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, ZigType *actual_type,
+ ZigType *wanted_type, LLVMValueRef expr_val)
{
assert(actual_type->id == wanted_type->id);
@@ -1729,7 +1729,7 @@ static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, T
}
}
-static LLVMValueRef gen_overflow_op(CodeGen *g, TypeTableEntry *type_entry, AddSubMul op,
+static LLVMValueRef gen_overflow_op(CodeGen *g, ZigType *type_entry, AddSubMul op,
LLVMValueRef val1, LLVMValueRef val2)
{
LLVMValueRef fn_val = get_int_overflow_fn(g, type_entry, op);
@@ -1789,11 +1789,11 @@ static LLVMRealPredicate cmp_op_to_real_predicate(IrBinOp cmp_op) {
}
}
-static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *ptr_type,
+static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type,
LLVMValueRef value)
{
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *child_type = ptr_type->data.pointer.child_type;
+ ZigType *child_type = ptr_type->data.pointer.child_type;
if (!type_has_bits(child_type))
return nullptr;
@@ -1807,7 +1807,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry
LLVMValueRef src_ptr = LLVMBuildBitCast(g->builder, value, ptr_u8, "");
LLVMValueRef dest_ptr = LLVMBuildBitCast(g->builder, ptr, ptr_u8, "");
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, child_type->type_ref);
uint64_t align_bytes = ptr_type->data.pointer.alignment;
assert(size_bytes > 0);
@@ -1876,7 +1876,7 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {
// values are rendered with a type other than the one we expect
if (handle_is_ptr(instruction->value.type)) {
render_const_val_global(g, &instruction->value, "");
- TypeTableEntry *ptr_type = get_pointer_to_type(g, instruction->value.type, true);
+ ZigType *ptr_type = get_pointer_to_type(g, instruction->value.type, true);
instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_global, ptr_type->type_ref, "");
} else if (instruction->value.type->id == TypeTableEntryIdPointer) {
instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_value, instruction->value.type->type_ref, "");
@@ -1904,7 +1904,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut
static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrInstructionReturn *return_instruction) {
LLVMValueRef value = ir_llvm_value(g, return_instruction->value);
- TypeTableEntry *return_type = return_instruction->value->value.type;
+ ZigType *return_type = return_instruction->value->value.type;
if (handle_is_ptr(return_type)) {
if (calling_convention_does_first_arg_return(g->cur_fn->type_entry->data.fn.fn_type_id.cc)) {
@@ -1921,7 +1921,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns
return nullptr;
}
-static LLVMValueRef gen_overflow_shl_op(CodeGen *g, TypeTableEntry *type_entry,
+static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,
LLVMValueRef val1, LLVMValueRef val2)
{
// for unsigned left shifting, we do the lossy shift, then logically shift
@@ -1951,7 +1951,7 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, TypeTableEntry *type_entry,
return result;
}
-static LLVMValueRef gen_overflow_shr_op(CodeGen *g, TypeTableEntry *type_entry,
+static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,
LLVMValueRef val1, LLVMValueRef val2)
{
assert(type_entry->id == TypeTableEntryIdInt);
@@ -1976,7 +1976,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, TypeTableEntry *type_entry,
return result;
}
-static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, TypeTableEntry *type_entry) {
+static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, ZigType *type_entry) {
if (type_entry->id == TypeTableEntryIdInt)
return val;
@@ -1984,7 +1984,7 @@ static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, TypeTableEntry *type
return LLVMBuildCall(g->builder, floor_fn, &val, 1, "");
}
-static LLVMValueRef gen_ceil(CodeGen *g, LLVMValueRef val, TypeTableEntry *type_entry) {
+static LLVMValueRef gen_ceil(CodeGen *g, LLVMValueRef val, ZigType *type_entry) {
if (type_entry->id == TypeTableEntryIdInt)
return val;
@@ -2018,7 +2018,7 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {
static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
LLVMValueRef val1, LLVMValueRef val2,
- TypeTableEntry *type_entry, DivKind div_kind)
+ ZigType *type_entry, DivKind div_kind)
{
ZigLLVMSetFastMath(g->builder, want_fast_math);
@@ -2177,7 +2177,7 @@ enum RemKind {
static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
LLVMValueRef val1, LLVMValueRef val2,
- TypeTableEntry *type_entry, RemKind rem_kind)
+ ZigType *type_entry, RemKind rem_kind)
{
ZigLLVMSetFastMath(g->builder, want_fast_math);
@@ -2246,7 +2246,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
(op_id == IrBinOpAdd || op_id == IrBinOpSub) &&
op1->value.type->data.pointer.ptr_len == PtrLenUnknown)
);
- TypeTableEntry *type_entry = op1->value.type;
+ ZigType *type_entry = op1->value.type;
bool want_runtime_safety = bin_op_instruction->safety_check_on &&
ir_want_runtime_safety(g, &bin_op_instruction->base);
@@ -2421,7 +2421,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
zig_unreachable();
}
-static void add_error_range_check(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *int_type, LLVMValueRef target_val) {
+static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *int_type, LLVMValueRef target_val) {
assert(err_set_type->id == TypeTableEntryIdErrorSet);
if (type_is_global_error_set(err_set_type)) {
@@ -2472,8 +2472,8 @@ static void add_error_range_check(CodeGen *g, TypeTableEntry *err_set_type, Type
static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
IrInstructionCast *cast_instruction)
{
- TypeTableEntry *actual_type = cast_instruction->value->value.type;
- TypeTableEntry *wanted_type = cast_instruction->base.value.type;
+ ZigType *actual_type = cast_instruction->value->value.type;
+ ZigType *wanted_type = cast_instruction->base.value.type;
LLVMValueRef expr_val = ir_llvm_value(g, cast_instruction->value);
assert(expr_val);
@@ -2491,10 +2491,10 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
assert(actual_type->id == TypeTableEntryIdStruct);
assert(actual_type->data.structure.is_slice);
- TypeTableEntry *actual_pointer_type = actual_type->data.structure.fields[0].type_entry;
- TypeTableEntry *actual_child_type = actual_pointer_type->data.pointer.child_type;
- TypeTableEntry *wanted_pointer_type = wanted_type->data.structure.fields[0].type_entry;
- TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
+ ZigType *actual_pointer_type = actual_type->data.structure.fields[0].type_entry;
+ ZigType *actual_child_type = actual_pointer_type->data.pointer.child_type;
+ ZigType *wanted_pointer_type = wanted_type->data.structure.fields[0].type_entry;
+ ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index].gen_index;
@@ -2553,8 +2553,8 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
assert(wanted_type->data.structure.is_slice);
assert(actual_type->id == TypeTableEntryIdArray);
- TypeTableEntry *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
- TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
+ ZigType *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
@@ -2628,7 +2628,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
case CastOpPtrOfArrayToSlice: {
assert(cast_instruction->tmp_ptr);
assert(actual_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = actual_type->data.pointer.child_type;
+ ZigType *array_type = actual_type->data.pointer.child_type;
assert(array_type->id == TypeTableEntryIdArray);
LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
@@ -2655,7 +2655,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
IrInstructionPtrCast *instruction)
{
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
if (!type_has_bits(wanted_type)) {
return nullptr;
}
@@ -2666,7 +2666,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
IrInstructionBitCast *instruction)
{
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
LLVMValueRef value = ir_llvm_value(g, instruction->value);
return LLVMBuildBitCast(g->builder, value, wanted_type->type_ref, "");
}
@@ -2674,10 +2674,10 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executable,
IrInstructionWidenOrShorten *instruction)
{
- TypeTableEntry *actual_type = instruction->target->value.type;
+ ZigType *actual_type = instruction->target->value.type;
// TODO instead of this logic, use the Noop instruction to change the type from
// enum_tag to the underlying int type
- TypeTableEntry *int_type;
+ ZigType *int_type;
if (actual_type->id == TypeTableEntryIdEnum) {
int_type = actual_type->data.enumeration.tag_int_type;
} else {
@@ -2689,21 +2689,21 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executa
}
static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutable *executable, IrInstructionIntToPtr *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
return LLVMBuildIntToPtr(g->builder, target_val, wanted_type->type_ref, "");
}
static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutable *executable, IrInstructionPtrToInt *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
return LLVMBuildPtrToInt(g->builder, target_val, wanted_type->type_ref, "");
}
static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable, IrInstructionIntToEnum *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdEnum);
- TypeTableEntry *tag_int_type = wanted_type->data.enumeration.tag_int_type;
+ ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type;
LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
LLVMValueRef tag_int_value = gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base),
@@ -2728,10 +2728,10 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable,
}
static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, IrInstructionIntToErr *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdErrorSet);
- TypeTableEntry *actual_type = instruction->target->value.type;
+ ZigType *actual_type = instruction->target->value.type;
assert(actual_type->id == TypeTableEntryIdInt);
assert(!actual_type->data.integral.is_signed);
@@ -2745,11 +2745,11 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, I
}
static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, IrInstructionErrToInt *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdInt);
assert(!wanted_type->data.integral.is_signed);
- TypeTableEntry *actual_type = instruction->target->value.type;
+ ZigType *actual_type = instruction->target->value.type;
LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
if (actual_type->id == TypeTableEntryIdErrorSet) {
@@ -2799,7 +2799,7 @@ static LLVMValueRef ir_render_br(CodeGen *g, IrExecutable *executable, IrInstruc
static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInstructionUnOp *un_op_instruction) {
IrUnOp op_id = un_op_instruction->op_id;
LLVMValueRef expr = ir_llvm_value(g, un_op_instruction->value);
- TypeTableEntry *expr_type = un_op_instruction->value->value.type;
+ ZigType *expr_type = un_op_instruction->value->value.type;
switch (op_id) {
case IrUnOpInvalid:
@@ -2880,13 +2880,13 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
if (have_init_expr) {
assert(var->value->type == init_value->value.type);
- TypeTableEntry *var_ptr_type = get_pointer_to_type_extra(g, var->value->type, false, false,
+ ZigType *var_ptr_type = get_pointer_to_type_extra(g, var->value->type, false, false,
PtrLenSingle, var->align_bytes, 0, 0);
gen_assign_raw(g, var->value_ref, var_ptr_type, ir_llvm_value(g, init_value));
} else {
bool want_safe = ir_want_runtime_safety(g, &decl_var_instruction->base);
if (want_safe) {
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, var->value->type->type_ref);
assert(size_bytes > 0);
@@ -2915,12 +2915,12 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
}
static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrInstructionLoadPtr *instruction) {
- TypeTableEntry *child_type = instruction->base.value.type;
+ ZigType *child_type = instruction->base.value.type;
if (!type_has_bits(child_type))
return nullptr;
LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
- TypeTableEntry *ptr_type = instruction->ptr->value.type;
+ ZigType *ptr_type = instruction->ptr->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
uint32_t unaligned_bit_count = ptr_type->data.pointer.unaligned_bit_count;
@@ -2947,7 +2947,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir
LLVMValueRef value = ir_llvm_value(g, instruction->value);
assert(instruction->ptr->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *ptr_type = instruction->ptr->value.type;
+ ZigType *ptr_type = instruction->ptr->value.type;
gen_assign_raw(g, ptr, ptr_type, value);
@@ -2966,9 +2966,9 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutable *executable, IrIn
static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrInstructionElemPtr *instruction) {
LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);
- TypeTableEntry *array_ptr_type = instruction->array_ptr->value.type;
+ ZigType *array_ptr_type = instruction->array_ptr->value.type;
assert(array_ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = array_ptr_type->data.pointer.child_type;
+ ZigType *array_type = array_ptr_type->data.pointer.child_type;
LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);
LLVMValueRef subscript_value = ir_llvm_value(g, instruction->elem_index);
assert(subscript_value);
@@ -2993,7 +2993,7 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
if (array_ptr_type->data.pointer.unaligned_bit_count != 0) {
return array_ptr_ptr;
}
- TypeTableEntry *child_type = array_type->data.array.child_type;
+ ZigType *child_type = array_type->data.array.child_type;
if (child_type->id == TypeTableEntryIdStruct &&
child_type->data.structure.layout == ContainerLayoutPacked)
{
@@ -3113,7 +3113,7 @@ static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) {
static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {
LLVMValueRef fn_val;
- TypeTableEntry *fn_type;
+ ZigType *fn_type;
if (instruction->fn_entry) {
fn_val = fn_llvm_value(g, instruction->fn_entry);
fn_type = instruction->fn_entry->type_entry;
@@ -3125,7 +3125,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
- TypeTableEntry *src_return_type = fn_type_id->return_type;
+ ZigType *src_return_type = fn_type_id->return_type;
bool ret_has_bits = type_has_bits(src_return_type);
bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&
@@ -3154,7 +3154,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
}
for (size_t call_i = 0; call_i < instruction->arg_count; call_i += 1) {
IrInstruction *param_instruction = instruction->args[call_i];
- TypeTableEntry *param_type = param_instruction->value.type;
+ ZigType *param_type = param_instruction->value.type;
if (is_var_args || type_has_bits(param_type)) {
LLVMValueRef param_value = ir_llvm_value(g, param_instruction);
assert(param_value);
@@ -3222,7 +3222,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
{
LLVMValueRef struct_ptr = ir_llvm_value(g, instruction->struct_ptr);
// not necessarily a pointer. could be TypeTableEntryIdStruct
- TypeTableEntry *struct_ptr_type = instruction->struct_ptr->value.type;
+ ZigType *struct_ptr_type = instruction->struct_ptr->value.type;
TypeStructField *field = instruction->field;
if (!type_has_bits(field->type_entry))
@@ -3241,9 +3241,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,
IrInstructionUnionFieldPtr *instruction)
{
- TypeTableEntry *union_ptr_type = instruction->union_ptr->value.type;
+ ZigType *union_ptr_type = instruction->union_ptr->value.type;
assert(union_ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *union_type = union_ptr_type->data.pointer.child_type;
+ ZigType *union_type = union_ptr_type->data.pointer.child_type;
assert(union_type->id == TypeTableEntryIdUnion);
TypeUnionField *field = instruction->field;
@@ -3411,9 +3411,9 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");
}
-static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {
+static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueRef maybe_handle) {
assert(maybe_type->id == TypeTableEntryIdOptional);
- TypeTableEntry *child_type = maybe_type->data.maybe.child_type;
+ ZigType *child_type = maybe_type->data.maybe.child_type;
if (child_type->zero_bits) {
return maybe_handle;
} else {
@@ -3436,11 +3436,11 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable
static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,
IrInstructionUnwrapOptional *instruction)
{
- TypeTableEntry *ptr_type = instruction->value->value.type;
+ ZigType *ptr_type = instruction->value->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *maybe_type = ptr_type->data.pointer.child_type;
+ ZigType *maybe_type = ptr_type->data.pointer.child_type;
assert(maybe_type->id == TypeTableEntryIdOptional);
- TypeTableEntry *child_type = maybe_type->data.maybe.child_type;
+ ZigType *child_type = maybe_type->data.maybe.child_type;
LLVMValueRef maybe_ptr = ir_llvm_value(g, instruction->value);
LLVMValueRef maybe_handle = get_handle_value(g, maybe_ptr, maybe_type, ptr_type);
if (ir_want_runtime_safety(g, &instruction->base) && instruction->safety_check_on) {
@@ -3467,7 +3467,7 @@ static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,
}
}
-static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, BuiltinFnId fn_id) {
+static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *int_type, BuiltinFnId fn_id) {
ZigLLVMFnKey key = {};
const char *fn_name;
uint32_t n_args;
@@ -3510,7 +3510,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
}
static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstructionClz *instruction) {
- TypeTableEntry *int_type = instruction->value->value.type;
+ ZigType *int_type = instruction->value->value.type;
LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);
LLVMValueRef operand = ir_llvm_value(g, instruction->value);
LLVMValueRef params[] {
@@ -3522,7 +3522,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstru
}
static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstructionCtz *instruction) {
- TypeTableEntry *int_type = instruction->value->value.type;
+ ZigType *int_type = instruction->value->value.type;
LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);
LLVMValueRef operand = ir_llvm_value(g, instruction->value);
LLVMValueRef params[] {
@@ -3534,7 +3534,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
}
static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutable *executable, IrInstructionPopCount *instruction) {
- TypeTableEntry *int_type = instruction->value->value.type;
+ ZigType *int_type = instruction->value->value.type;
LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
LLVMValueRef operand = ir_llvm_value(g, instruction->value);
LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, &operand, 1, "");
@@ -3611,15 +3611,15 @@ static LLVMValueRef ir_render_err_name(CodeGen *g, IrExecutable *executable, IrI
return LLVMBuildInBoundsGEP(g->builder, g->err_name_table, indices, 2, "");
}
-static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_type) {
+static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
assert(enum_type->id == TypeTableEntryIdEnum);
if (enum_type->data.enumeration.name_function)
return enum_type->data.enumeration.name_function;
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *u8_slice_type = get_slice_type(g, u8_ptr_type);
- TypeTableEntry *tag_int_type = enum_type->data.enumeration.tag_int_type;
+ ZigType *u8_slice_type = get_slice_type(g, u8_ptr_type);
+ ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type;
LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMPointerType(u8_slice_type->type_ref, 0),
&tag_int_type->type_ref, 1, false);
@@ -3652,7 +3652,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_
LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, tag_int_value, bad_value_block, field_count);
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
LLVMValueRef array_ptr_indices[] = {
LLVMConstNull(usize->type_ref),
LLVMConstNull(usize->type_ref),
@@ -3709,7 +3709,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_
static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable,
IrInstructionTagName *instruction)
{
- TypeTableEntry *enum_type = instruction->target->value.type;
+ ZigType *enum_type = instruction->target->value.type;
assert(enum_type->id == TypeTableEntryIdEnum);
LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type);
@@ -3722,10 +3722,10 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable
static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executable,
IrInstructionFieldParentPtr *instruction)
{
- TypeTableEntry *container_ptr_type = instruction->base.value.type;
+ ZigType *container_ptr_type = instruction->base.value.type;
assert(container_ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *container_type = container_ptr_type->data.pointer.child_type;
+ ZigType *container_type = container_ptr_type->data.pointer.child_type;
size_t byte_offset = LLVMOffsetOfElement(g->target_data_ref,
container_type->type_ref, instruction->field->gen_index);
@@ -3735,7 +3735,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executa
if (byte_offset == 0) {
return LLVMBuildBitCast(g->builder, field_ptr_val, container_ptr_type->type_ref, "");
} else {
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
LLVMValueRef field_ptr_int = LLVMBuildPtrToInt(g->builder, field_ptr_val,
usize->type_ref, "");
@@ -3756,7 +3756,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
return target_val;
}
- TypeTableEntry *target_type = instruction->base.value.type;
+ ZigType *target_type = instruction->base.value.type;
uint32_t align_bytes;
LLVMValueRef ptr_val;
@@ -3781,7 +3781,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
{
zig_panic("TODO audit this function");
} else if (target_type->id == TypeTableEntryIdStruct && target_type->data.structure.is_slice) {
- TypeTableEntry *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
align_bytes = slice_ptr_type->data.pointer.alignment;
size_t ptr_index = target_type->data.structure.fields[slice_ptr_index].gen_index;
@@ -3793,7 +3793,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
assert(align_bytes != 1);
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
LLVMValueRef ptr_as_int_val = LLVMBuildPtrToInt(g->builder, ptr_val, usize->type_ref, "");
LLVMValueRef alignment_minus_1 = LLVMConstInt(usize->type_ref, align_bytes - 1, false);
LLVMValueRef anded_val = LLVMBuildAnd(g->builder, ptr_as_int_val, alignment_minus_1, "");
@@ -3817,7 +3817,7 @@ static LLVMValueRef ir_render_error_return_trace(CodeGen *g, IrExecutable *execu
{
LLVMValueRef cur_err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope);
if (cur_err_ret_trace_val == nullptr) {
- TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
+ ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
return LLVMConstNull(ptr_to_stack_trace_type->type_ref);
}
return cur_err_ret_trace_val;
@@ -3877,9 +3877,9 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn
LLVMValueRef result_val = ZigLLVMBuildCmpXchg(g->builder, ptr_val, cmp_val, new_val,
success_order, failure_order, instruction->is_weak);
- TypeTableEntry *maybe_type = instruction->base.value.type;
+ ZigType *maybe_type = instruction->base.value.type;
assert(maybe_type->id == TypeTableEntryIdOptional);
- TypeTableEntry *child_type = maybe_type->data.maybe.child_type;
+ ZigType *child_type = maybe_type->data.maybe.child_type;
if (type_is_codegen_pointer(child_type)) {
LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, "");
@@ -3909,8 +3909,8 @@ static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutable *executable, IrInst
static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutable *executable, IrInstructionTruncate *instruction) {
LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
- TypeTableEntry *dest_type = instruction->base.value.type;
- TypeTableEntry *src_type = instruction->target->value.type;
+ ZigType *dest_type = instruction->base.value.type;
+ ZigType *src_type = instruction->target->value.type;
if (dest_type == src_type) {
// no-op
return target_val;
@@ -3931,7 +3931,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
- TypeTableEntry *ptr_type = instruction->dest_ptr->value.type;
+ ZigType *ptr_type = instruction->dest_ptr->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
LLVMValueRef is_volatile = ptr_type->data.pointer.is_volatile ?
@@ -3961,8 +3961,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, ptr_u8, "");
- TypeTableEntry *dest_ptr_type = instruction->dest_ptr->value.type;
- TypeTableEntry *src_ptr_type = instruction->src_ptr->value.type;
+ ZigType *dest_ptr_type = instruction->dest_ptr->value.type;
+ ZigType *src_ptr_type = instruction->src_ptr->value.type;
assert(dest_ptr_type->id == TypeTableEntryIdPointer);
assert(src_ptr_type->id == TypeTableEntryIdPointer);
@@ -3989,9 +3989,9 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
assert(instruction->tmp_ptr);
LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);
- TypeTableEntry *array_ptr_type = instruction->ptr->value.type;
+ ZigType *array_ptr_type = instruction->ptr->value.type;
assert(array_ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = array_ptr_type->data.pointer.child_type;
+ ZigType *array_type = array_ptr_type->data.pointer.child_type;
LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);
LLVMValueRef tmp_struct_ptr = instruction->tmp_ptr;
@@ -4140,7 +4140,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) {
if (g->frame_address_fn_val)
return g->frame_address_fn_val;
- TypeTableEntry *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
+ ZigType *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,
&g->builtin_types.entry_i32->type_ref, 1, false);
@@ -4178,7 +4178,7 @@ static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable,
}
static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) {
- TypeTableEntry *int_type = instruction->result_ptr_type;
+ ZigType *int_type = instruction->result_ptr_type;
assert(int_type->id == TypeTableEntryIdInt);
LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);
@@ -4218,7 +4218,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,
return render_shl_with_overflow(g, instruction);
}
- TypeTableEntry *int_type = instruction->result_ptr_type;
+ ZigType *int_type = instruction->result_ptr_type;
assert(int_type->id == TypeTableEntryIdInt);
LLVMValueRef fn_val = get_int_overflow_fn(g, int_type, add_sub_mul);
@@ -4241,8 +4241,8 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,
}
static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrInstructionTestErr *instruction) {
- TypeTableEntry *err_union_type = instruction->value->value.type;
- TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;
+ ZigType *err_union_type = instruction->value->value.type;
+ ZigType *payload_type = err_union_type->data.error_union.payload_type;
LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->value);
LLVMValueRef err_val;
@@ -4258,10 +4258,10 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI
}
static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrCode *instruction) {
- TypeTableEntry *ptr_type = instruction->value->value.type;
+ ZigType *ptr_type = instruction->value->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *err_union_type = ptr_type->data.pointer.child_type;
- TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;
+ ZigType *err_union_type = ptr_type->data.pointer.child_type;
+ ZigType *payload_type = err_union_type->data.error_union.payload_type;
LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);
LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);
@@ -4274,10 +4274,10 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab
}
static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrPayload *instruction) {
- TypeTableEntry *ptr_type = instruction->value->value.type;
+ ZigType *ptr_type = instruction->value->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *err_union_type = ptr_type->data.pointer.child_type;
- TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;
+ ZigType *err_union_type = ptr_type->data.pointer.child_type;
+ ZigType *payload_type = err_union_type->data.error_union.payload_type;
LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);
LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);
@@ -4313,11 +4313,11 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu
}
static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, IrInstructionOptionalWrap *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdOptional);
- TypeTableEntry *child_type = wanted_type->data.maybe.child_type;
+ ZigType *child_type = wanted_type->data.maybe.child_type;
if (child_type->zero_bits) {
return LLVMConstInt(LLVMInt1Type(), 1, false);
@@ -4340,12 +4340,12 @@ static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, I
}
static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapCode *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdErrorUnion);
- TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;
- TypeTableEntry *err_set_type = wanted_type->data.error_union.err_set_type;
+ ZigType *payload_type = wanted_type->data.error_union.payload_type;
+ ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
LLVMValueRef err_val = ir_llvm_value(g, instruction->value);
@@ -4361,12 +4361,12 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable
}
static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapPayload *instruction) {
- TypeTableEntry *wanted_type = instruction->base.value.type;
+ ZigType *wanted_type = instruction->base.value.type;
assert(wanted_type->id == TypeTableEntryIdErrorUnion);
- TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;
- TypeTableEntry *err_set_type = wanted_type->data.error_union.err_set_type;
+ ZigType *payload_type = wanted_type->data.error_union.payload_type;
+ ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
if (!type_has_bits(err_set_type)) {
return ir_llvm_value(g, instruction->value);
@@ -4391,10 +4391,10 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executa
}
static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, IrInstructionUnionTag *instruction) {
- TypeTableEntry *union_type = instruction->value->value.type;
+ ZigType *union_type = instruction->value->value.type;
assert(union_type->data.unionation.gen_tag_index != SIZE_MAX);
- TypeTableEntry *tag_type = union_type->data.unionation.tag_type;
+ ZigType *tag_type = union_type->data.unionation.tag_type;
if (!type_has_bits(tag_type))
return nullptr;
@@ -4404,7 +4404,7 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, Ir
LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, union_val,
union_type->data.unionation.gen_tag_index, "");
- TypeTableEntry *ptr_type = get_pointer_to_type(g, tag_type, false);
+ ZigType *ptr_type = get_pointer_to_type(g, tag_type, false);
return get_handle_value(g, tag_field_ptr, tag_type, ptr_type);
}
@@ -4421,7 +4421,7 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,
uint32_t field_align_bytes = get_abi_alignment(g, type_struct_field->type_entry);
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,
+ ZigType *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,
false, false, PtrLenSingle, field_align_bytes,
(uint32_t)type_struct_field->packed_bits_offset, (uint32_t)type_struct_field->unaligned_bit_count);
@@ -4437,14 +4437,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I
return nullptr;
uint32_t field_align_bytes = get_abi_alignment(g, type_union_field->type_entry);
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_union_field->type_entry,
+ ZigType *ptr_type = get_pointer_to_type_extra(g, type_union_field->type_entry,
false, false, PtrLenSingle, field_align_bytes,
0, 0);
LLVMValueRef uncasted_union_ptr;
// Even if safety is off in this block, if the union type has the safety field, we have to populate it
// correctly. Otherwise safety code somewhere other than here could fail.
- TypeTableEntry *union_type = instruction->union_type;
+ ZigType *union_type = instruction->union_type;
if (union_type->data.unionation.gen_tag_index != SIZE_MAX) {
LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr,
union_type->data.unionation.gen_tag_index, "");
@@ -4470,14 +4470,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I
static LLVMValueRef ir_render_container_init_list(CodeGen *g, IrExecutable *executable,
IrInstructionContainerInitList *instruction)
{
- TypeTableEntry *array_type = instruction->base.value.type;
+ ZigType *array_type = instruction->base.value.type;
assert(array_type->id == TypeTableEntryIdArray);
LLVMValueRef tmp_array_ptr = instruction->tmp_ptr;
assert(tmp_array_ptr);
size_t field_count = instruction->item_count;
- TypeTableEntry *child_type = array_type->data.array.child_type;
+ ZigType *child_type = array_type->data.array.child_type;
for (size_t i = 0; i < field_count; i += 1) {
LLVMValueRef elem_val = ir_llvm_value(g, instruction->items[i]);
LLVMValueRef indices[] = {
@@ -4601,13 +4601,13 @@ static LLVMValueRef ir_render_coro_promise(CodeGen *g, IrExecutable *executable,
return LLVMBuildBitCast(g->builder, uncasted_result, instruction->base.value.type->type_ref, "");
}
-static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_fn_type_ref, TypeTableEntry *fn_type) {
+static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_fn_type_ref, ZigType *fn_type) {
if (g->coro_alloc_helper_fn_val != nullptr)
return g->coro_alloc_helper_fn_val;
assert(fn_type->id == TypeTableEntryIdFn);
- TypeTableEntry *ptr_to_err_code_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
+ ZigType *ptr_to_err_code_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
LLVMTypeRef alloc_raw_fn_type_ref = LLVMGetElementType(alloc_fn_type_ref);
LLVMTypeRef *alloc_fn_arg_types = allocate<LLVMTypeRef>(LLVMCountParamTypes(alloc_raw_fn_type_ref));
@@ -4686,9 +4686,9 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f
LLVMPositionBuilderAtEnd(g->builder, ok_block);
LLVMValueRef payload_ptr = LLVMBuildStructGEP(g->builder, sret_ptr, err_union_payload_index, "");
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *slice_type = get_slice_type(g, u8_ptr_type);
+ ZigType *slice_type = get_slice_type(g, u8_ptr_type);
size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, payload_ptr, ptr_field_index, "");
LLVMValueRef ptr_val = LLVMBuildLoad(g->builder, ptr_field_ptr, "");
@@ -4733,7 +4733,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutable *executable,
IrInstructionAtomicRmw *instruction)
{
bool is_signed;
- TypeTableEntry *operand_type = instruction->operand->value.type;
+ ZigType *operand_type = instruction->operand->value.type;
if (operand_type->id == TypeTableEntryIdInt) {
is_signed = operand_type->data.integral.is_signed;
} else {
@@ -5090,14 +5090,14 @@ static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *ar
LLVMTypeKind el_type = LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(base_ptr)));
if (el_type == LLVMArrayTypeKind) {
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
LLVMValueRef indices[] = {
LLVMConstNull(usize->type_ref),
LLVMConstInt(usize->type_ref, index, false),
};
return LLVMConstInBoundsGEP(base_ptr, indices, 2);
} else if (el_type == LLVMStructTypeKind) {
- TypeTableEntry *u32 = g->builtin_types.entry_u32;
+ ZigType *u32 = g->builtin_types.entry_u32;
LLVMValueRef indices[] = {
LLVMConstNull(u32->type_ref),
LLVMConstInt(u32->type_ref, index, false),
@@ -5113,7 +5113,7 @@ static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *s
ConstParent *parent = &struct_const_val->data.x_struct.parent;
LLVMValueRef base_ptr = gen_parent_ptr(g, struct_const_val, parent);
- TypeTableEntry *u32 = g->builtin_types.entry_u32;
+ ZigType *u32 = g->builtin_types.entry_u32;
LLVMValueRef indices[] = {
LLVMConstNull(u32->type_ref),
LLVMConstInt(u32->type_ref, field_index, false),
@@ -5125,7 +5125,7 @@ static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *un
ConstParent *parent = &union_const_val->data.x_union.parent;
LLVMValueRef base_ptr = gen_parent_ptr(g, union_const_val, parent);
- TypeTableEntry *u32 = g->builtin_types.entry_u32;
+ ZigType *u32 = g->builtin_types.entry_u32;
LLVMValueRef indices[] = {
LLVMConstNull(u32->type_ref),
LLVMConstInt(u32->type_ref, 0, false), // TODO test const union with more aligned tag type than payload
@@ -5143,7 +5143,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
break;
}
- TypeTableEntry *type_entry = const_val->type;
+ ZigType *type_entry = const_val->type;
assert(!type_entry->zero_bits);
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
@@ -5228,7 +5228,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
// We have this because union constants can't be represented by the official union type,
// and this property bubbles up in whatever aggregate type contains a union constant
-static bool is_llvm_value_unnamed_type(TypeTableEntry *type_entry, LLVMValueRef val) {
+static bool is_llvm_value_unnamed_type(ZigType *type_entry, LLVMValueRef val) {
return LLVMTypeOf(val) != type_entry->type_ref;
}
@@ -5256,7 +5256,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
assert(array_const_val->type->id == TypeTableEntryIdArray);
if (array_const_val->type->zero_bits) {
// make this a null pointer
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),
const_val->type->type_ref);
render_const_val_global(g, const_val, "");
@@ -5276,7 +5276,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
assert(struct_const_val->type->id == TypeTableEntryIdStruct);
if (struct_const_val->type->zero_bits) {
// make this a null pointer
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),
const_val->type->type_ref);
render_const_val_global(g, const_val, "");
@@ -5296,7 +5296,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
{
render_const_val_global(g, const_val, name);
uint64_t addr_value = const_val->data.x_ptr.data.hard_coded_addr.addr;
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstInt(usize->type_ref, addr_value, false),
const_val->type->type_ref);
render_const_val_global(g, const_val, "");
@@ -5309,7 +5309,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
}
static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) {
- TypeTableEntry *type_entry = const_val->type;
+ ZigType *type_entry = const_val->type;
assert(!type_entry->zero_bits);
switch (const_val->special) {
@@ -5356,7 +5356,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
}
case TypeTableEntryIdOptional:
{
- TypeTableEntry *child_type = type_entry->data.maybe.child_type;
+ ZigType *child_type = type_entry->data.maybe.child_type;
if (child_type->zero_bits) {
return LLVMConstInt(LLVMInt1Type(), const_val->data.x_optional ? 1 : 0, false);
} else if (type_is_codegen_pointer(child_type)) {
@@ -5559,8 +5559,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
return gen_const_val_ptr(g, const_val, name);
case TypeTableEntryIdErrorUnion:
{
- TypeTableEntry *payload_type = type_entry->data.error_union.payload_type;
- TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;
+ ZigType *payload_type = type_entry->data.error_union.payload_type;
+ ZigType *err_set_type = type_entry->data.error_union.err_set_type;
if (!type_has_bits(payload_type)) {
assert(type_has_bits(err_set_type));
uint64_t value = const_val->data.x_err_union.err ? const_val->data.x_err_union.err->value : 0;
@@ -5650,9 +5650,9 @@ static void generate_error_name_table(CodeGen *g) {
assert(g->errors_by_index.length > 0);
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);
+ ZigType *str_type = get_slice_type(g, u8_ptr_type);
LLVMValueRef *values = allocate<LLVMValueRef>(g->errors_by_index.length);
values[0] = LLVMGetUndef(str_type->type_ref);
@@ -5700,7 +5700,7 @@ static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) {
}
static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef init_val,
- TypeTableEntry *type_entry)
+ ZigType *type_entry)
{
if (g->strip_debug_symbols) {
return;
@@ -5721,7 +5721,7 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini
// TODO ^^ make an actual global variable
}
-static LLVMValueRef build_alloca(CodeGen *g, TypeTableEntry *type_entry, const char *name, uint32_t alignment) {
+static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment) {
assert(alignment > 0);
LLVMValueRef result = LLVMBuildAlloca(g->builder, type_entry->type_ref, name);
LLVMSetAlignment(result, alignment);
@@ -5794,7 +5794,7 @@ static void do_code_gen(CodeGen *g) {
// Generate debug info for it but that's it.
ConstExprValue *const_val = var->value;
assert(const_val->special != ConstValSpecialRuntime);
- TypeTableEntry *var_type = g->builtin_types.entry_f128;
+ ZigType *var_type = g->builtin_types.entry_f128;
ConstExprValue coerced_value;
coerced_value.special = ConstValSpecialStatic;
coerced_value.type = var_type;
@@ -5812,7 +5812,7 @@ static void do_code_gen(CodeGen *g) {
if (bits_needed < 8) {
bits_needed = 8;
}
- TypeTableEntry *var_type = get_int_type(g, const_val->data.x_bigint.is_negative, bits_needed);
+ ZigType *var_type = get_int_type(g, const_val->data.x_bigint.is_negative, bits_needed);
LLVMValueRef init_val = bigint_to_llvm_const(var_type->type_ref, &const_val->data.x_bigint);
gen_global_var(g, var, init_val, var_type);
continue;
@@ -5869,7 +5869,7 @@ static void do_code_gen(CodeGen *g) {
LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);
g->cur_fn = fn_table_entry;
g->cur_fn_val = fn;
- TypeTableEntry *return_type = fn_table_entry->type_entry->data.fn.fn_type_id.return_type;
+ ZigType *return_type = fn_table_entry->type_entry->data.fn.fn_type_id.return_type;
if (handle_is_ptr(return_type)) {
g->cur_ret_ptr = LLVMGetParam(fn, 0);
} else {
@@ -5892,7 +5892,7 @@ static void do_code_gen(CodeGen *g) {
bool have_err_ret_trace_stack = g->have_err_ret_tracing && fn_table_entry->calls_or_awaits_errorable_fn && !is_async && !have_err_ret_trace_arg;
LLVMValueRef err_ret_array_val = nullptr;
if (have_err_ret_trace_stack) {
- TypeTableEntry *array_type = get_array_type(g, g->builtin_types.entry_usize, stack_trace_ptr_count);
+ ZigType *array_type = get_array_type(g, g->builtin_types.entry_usize, stack_trace_ptr_count);
err_ret_array_val = build_alloca(g, array_type, "error_return_trace_addresses", get_abi_alignment(g, array_type));
g->cur_err_ret_trace_val_stack = build_alloca(g, g->stack_trace_type, "error_return_trace", get_abi_alignment(g, g->stack_trace_type));
} else {
@@ -5903,7 +5903,7 @@ static void do_code_gen(CodeGen *g) {
for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_list.length; alloca_i += 1) {
IrInstruction *instruction = fn_table_entry->alloca_list.at(alloca_i);
LLVMValueRef *slot;
- TypeTableEntry *slot_type = instruction->value.type;
+ ZigType *slot_type = instruction->value.type;
if (instruction->id == IrInstructionIdCast) {
IrInstructionCast *cast_instruction = (IrInstructionCast *)instruction;
slot = &cast_instruction->tmp_ptr;
@@ -5968,7 +5968,7 @@ static void do_code_gen(CodeGen *g) {
} else {
assert(var->gen_arg_index != SIZE_MAX);
- TypeTableEntry *gen_type;
+ ZigType *gen_type;
FnGenParamInfo *gen_info = &fn_table_entry->type_entry->data.fn.gen_param_info[var->src_arg_index];
if (handle_is_ptr(var->value->type)) {
@@ -5994,7 +5994,7 @@ static void do_code_gen(CodeGen *g) {
// finishing error return trace setup. we have to do this after all the allocas.
if (have_err_ret_trace_stack) {
- TypeTableEntry *usize = g->builtin_types.entry_usize;
+ ZigType *usize = g->builtin_types.entry_usize;
size_t index_field_index = g->stack_trace_type->data.structure.fields[0].gen_index;
LLVMValueRef index_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)index_field_index, "");
gen_store_untyped(g, LLVMConstNull(usize->type_ref), index_field_ptr, 0, false);
@@ -6002,14 +6002,14 @@ static void do_code_gen(CodeGen *g) {
size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;
LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)addresses_field_index, "");
- TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
+ ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");
LLVMValueRef zero = LLVMConstNull(usize->type_ref);
LLVMValueRef indices[] = {zero, zero};
LLVMValueRef err_ret_array_val_elem0_ptr = LLVMBuildInBoundsGEP(g->builder, err_ret_array_val,
indices, 2, "");
- TypeTableEntry *ptr_ptr_usize_type = get_pointer_to_type(g, get_pointer_to_type(g, usize, false), false);
+ ZigType *ptr_ptr_usize_type = get_pointer_to_type(g, get_pointer_to_type(g, usize, false), false);
gen_store(g, err_ret_array_val_elem0_ptr, ptr_field_ptr, ptr_ptr_usize_type);
size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
@@ -6173,51 +6173,51 @@ static const GlobalLinkageValue global_linkage_values[] = {
static void define_builtin_types(CodeGen *g) {
{
// if this type is anywhere in the AST, we should never hit codegen.
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInvalid);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdInvalid);
buf_init_from_str(&entry->name, "(invalid)");
entry->zero_bits = true;
g->builtin_types.entry_invalid = entry;
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNamespace);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdNamespace);
buf_init_from_str(&entry->name, "(namespace)");
entry->zero_bits = true;
g->builtin_types.entry_namespace = entry;
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdBlock);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdBlock);
buf_init_from_str(&entry->name, "(block)");
entry->zero_bits = true;
g->builtin_types.entry_block = entry;
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);
buf_init_from_str(&entry->name, "comptime_float");
entry->zero_bits = true;
g->builtin_types.entry_num_lit_float = entry;
g->primitive_type_table.put(&entry->name, entry);
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);
buf_init_from_str(&entry->name, "comptime_int");
entry->zero_bits = true;
g->builtin_types.entry_num_lit_int = entry;
g->primitive_type_table.put(&entry->name, entry);
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefined);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdUndefined);
buf_init_from_str(&entry->name, "(undefined)");
entry->zero_bits = true;
g->builtin_types.entry_undef = entry;
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNull);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdNull);
buf_init_from_str(&entry->name, "(null)");
entry->zero_bits = true;
g->builtin_types.entry_null = entry;
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdArgTuple);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdArgTuple);
buf_init_from_str(&entry->name, "(args)");
entry->zero_bits = true;
g->builtin_types.entry_arg_tuple = entry;
@@ -6228,7 +6228,7 @@ static void define_builtin_types(CodeGen *g) {
uint32_t size_in_bits = target_c_type_size_in_bits(&g->zig_target, info->id);
bool is_signed = info->is_signed;
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
entry->type_ref = LLVMIntType(size_in_bits);
buf_init_from_str(&entry->name, info->name);
@@ -6245,7 +6245,7 @@ static void define_builtin_types(CodeGen *g) {
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdBool);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdBool);
entry->type_ref = LLVMInt1Type();
buf_init_from_str(&entry->name, "bool");
uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);
@@ -6259,7 +6259,7 @@ static void define_builtin_types(CodeGen *g) {
for (size_t sign_i = 0; sign_i < array_length(is_signed_list); sign_i += 1) {
bool is_signed = is_signed_list[sign_i];
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
entry->type_ref = LLVMIntType(g->pointer_size_bytes * 8);
const char u_or_i = is_signed ? 'i' : 'u';
@@ -6286,8 +6286,8 @@ static void define_builtin_types(CodeGen *g) {
const char *name,
uint32_t bit_count,
LLVMTypeRef type_ref,
- TypeTableEntry **field) {
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdFloat);
+ ZigType **field) {
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdFloat);
entry->type_ref = type_ref;
buf_init_from_str(&entry->name, name);
entry->data.floating.bit_count = bit_count;
@@ -6306,7 +6306,7 @@ static void define_builtin_types(CodeGen *g) {
add_fp_entry(g, "c_longdouble", 80, LLVMX86FP80Type(), &g->builtin_types.entry_c_longdouble);
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdVoid);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdVoid);
entry->type_ref = LLVMVoidType();
entry->zero_bits = true;
buf_init_from_str(&entry->name, "void");
@@ -6317,7 +6317,7 @@ static void define_builtin_types(CodeGen *g) {
g->primitive_type_table.put(&entry->name, entry);
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUnreachable);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdUnreachable);
entry->type_ref = LLVMVoidType();
entry->zero_bits = true;
buf_init_from_str(&entry->name, "noreturn");
@@ -6326,7 +6326,7 @@ static void define_builtin_types(CodeGen *g) {
g->primitive_type_table.put(&entry->name, entry);
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdMetaType);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdMetaType);
buf_init_from_str(&entry->name, "type");
entry->zero_bits = true;
g->builtin_types.entry_type = entry;
@@ -6348,7 +6348,7 @@ static void define_builtin_types(CodeGen *g) {
}
{
- TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdErrorSet);
+ ZigType *entry = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_init_from_str(&entry->name, "error");
entry->data.error_set.err_count = UINT32_MAX;
@@ -6370,7 +6370,7 @@ static void define_builtin_types(CodeGen *g) {
g->primitive_type_table.put(&entry->name, entry);
}
{
- TypeTableEntry *entry = get_promise_type(g, nullptr);
+ ZigType *entry = get_promise_type(g, nullptr);
g->primitive_type_table.put(&entry->name, entry);
}
@@ -6623,7 +6623,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
buf_appendf(contents, "pub const TypeId = enum {\n");
size_t field_count = type_id_len();
for (size_t i = 0; i < field_count; i += 1) {
- const TypeTableEntryId id = type_id_at_index(i);
+ const ZigTypeId id = type_id_at_index(i);
buf_appendf(contents, " %s,\n", type_id_name(id));
}
buf_appendf(contents, "};\n\n");
@@ -7068,14 +7068,14 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
exit(0);
}
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);
- TypeTableEntry *fn_type = get_test_fn_type(g);
+ ZigType *str_type = get_slice_type(g, u8_ptr_type);
+ ZigType *fn_type = get_test_fn_type(g);
const char *field_names[] = { "name", "func", };
- TypeTableEntry *field_types[] = { str_type, fn_type, };
- TypeTableEntry *struct_type = get_struct_type(g, "ZigTestFn", field_names, field_types, 2);
+ ZigType *field_types[] = { str_type, fn_type, };
+ ZigType *struct_type = get_struct_type(g, "ZigTestFn", field_names, field_types, 2);
ConstExprValue *test_fn_array = create_const_vals(1);
test_fn_array->type = get_array_type(g, struct_type, g->test_fns.length);
@@ -7217,10 +7217,10 @@ static const char *c_int_type_names[] = {
};
struct GenH {
- ZigList<TypeTableEntry *> types_to_declare;
+ ZigList<ZigType *> types_to_declare;
};
-static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry) {
+static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_entry) {
if (type_entry->gen_h_loop_flag)
return;
type_entry->gen_h_loop_flag = true;
@@ -7285,7 +7285,7 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry
}
}
-static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf *out_buf) {
+static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_buf) {
assert(type_entry);
for (size_t i = 0; i < array_length(c_int_type_names); i += 1) {
@@ -7354,7 +7354,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
case TypeTableEntryIdPointer:
{
Buf child_buf = BUF_INIT;
- TypeTableEntry *child_type = type_entry->data.pointer.child_type;
+ ZigType *child_type = type_entry->data.pointer.child_type;
get_c_type(g, gen_h, child_type, &child_buf);
const char *const_str = type_entry->data.pointer.is_const ? "const " : "";
@@ -7364,7 +7364,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
}
case TypeTableEntryIdOptional:
{
- TypeTableEntry *child_type = type_entry->data.maybe.child_type;
+ ZigType *child_type = type_entry->data.maybe.child_type;
if (child_type->zero_bits) {
buf_init_from_str(out_buf, "bool");
return;
@@ -7555,7 +7555,7 @@ static void gen_h_file(CodeGen *g) {
fprintf(out_h, "\n");
for (size_t type_i = 0; type_i < gen_h->types_to_declare.length; type_i += 1) {
- TypeTableEntry *type_entry = gen_h->types_to_declare.at(type_i);
+ ZigType *type_entry = gen_h->types_to_declare.at(type_i);
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
case TypeTableEntryIdMetaType:
src/ir.cpp
@@ -33,7 +33,7 @@ struct IrAnalyze {
IrExecContext exec_context;
size_t old_bb_index;
size_t instruction_index;
- TypeTableEntry *explicit_return_type;
+ ZigType *explicit_return_type;
ZigList<IrInstruction *> src_implicit_return_type_list;
IrBasicBlock *const_predecessor_bb;
};
@@ -99,38 +99,38 @@ struct ConstCastOnly {
};
struct ConstCastTypeMismatch {
- TypeTableEntry *wanted_type;
- TypeTableEntry *actual_type;
+ ZigType *wanted_type;
+ ZigType *actual_type;
};
struct ConstCastOptionalMismatch {
ConstCastOnly child;
- TypeTableEntry *wanted_child;
- TypeTableEntry *actual_child;
+ ZigType *wanted_child;
+ ZigType *actual_child;
};
struct ConstCastPointerMismatch {
ConstCastOnly child;
- TypeTableEntry *wanted_child;
- TypeTableEntry *actual_child;
+ ZigType *wanted_child;
+ ZigType *actual_child;
};
struct ConstCastSliceMismatch {
ConstCastOnly child;
- TypeTableEntry *wanted_child;
- TypeTableEntry *actual_child;
+ ZigType *wanted_child;
+ ZigType *actual_child;
};
struct ConstCastErrUnionErrSetMismatch {
ConstCastOnly child;
- TypeTableEntry *wanted_err_set;
- TypeTableEntry *actual_err_set;
+ ZigType *wanted_err_set;
+ ZigType *actual_err_set;
};
struct ConstCastErrUnionPayloadMismatch {
ConstCastOnly child;
- TypeTableEntry *wanted_payload;
- TypeTableEntry *actual_payload;
+ ZigType *wanted_payload;
+ ZigType *actual_payload;
};
struct ConstCastErrSetMismatch {
@@ -139,17 +139,17 @@ struct ConstCastErrSetMismatch {
static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval);
-static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction);
-static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *expected_type);
+static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction);
+static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type);
static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr);
static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg);
static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,
- IrInstruction *source_instr, IrInstruction *container_ptr, TypeTableEntry *container_type);
+ IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type);
static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, VariableTableEntry *var);
-static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op);
+static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op);
static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval);
-static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, uint32_t new_align);
-static TypeTableEntry *adjust_slice_align(CodeGen *g, TypeTableEntry *slice_type, uint32_t new_align);
+static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align);
+static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align);
static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);
static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);
@@ -183,7 +183,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
return result;
}
-static bool types_have_same_zig_comptime_repr(TypeTableEntry *a, TypeTableEntry *b) {
+static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {
if (a == b)
return true;
@@ -878,7 +878,7 @@ static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_nod
return special_instruction;
}
-static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, TypeTableEntry *dest_type,
+static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *dest_type,
IrInstruction *value, CastOp cast_op)
{
IrInstructionCast *cast_instruction = ir_build_instruction<IrInstructionCast>(irb, scope, source_node);
@@ -931,7 +931,7 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou
}
static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node,
- TypeTableEntry *type_entry)
+ ZigType *type_entry)
{
assert(type_entry);
IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
@@ -1002,7 +1002,7 @@ static IrInstruction *ir_build_const_u8(IrBuilder *irb, Scope *scope, AstNode *s
}
static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
- TypeTableEntry *type_entry)
+ ZigType *type_entry)
{
IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;
@@ -1012,7 +1012,7 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode
}
static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
- TypeTableEntry *type_entry)
+ ZigType *type_entry)
{
IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry);
ir_instruction_append(irb->current_basic_block, instruction);
@@ -1376,7 +1376,7 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop
}
static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode *source_node,
- TypeTableEntry *struct_type, size_t field_count, IrInstructionStructInitField *fields)
+ ZigType *struct_type, size_t field_count, IrInstructionStructInitField *fields)
{
IrInstructionStructInit *struct_init_instruction = ir_build_instruction<IrInstructionStructInit>(irb, scope, source_node);
struct_init_instruction->struct_type = struct_type;
@@ -1390,7 +1390,7 @@ static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode
}
static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *old_instruction,
- TypeTableEntry *struct_type, size_t field_count, IrInstructionStructInitField *fields)
+ ZigType *struct_type, size_t field_count, IrInstructionStructInitField *fields)
{
IrInstruction *new_instruction = ir_build_struct_init(irb, old_instruction->scope,
old_instruction->source_node, struct_type, field_count, fields);
@@ -1399,7 +1399,7 @@ static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *o
}
static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode *source_node,
- TypeTableEntry *union_type, TypeUnionField *field, IrInstruction *init_value)
+ ZigType *union_type, TypeUnionField *field, IrInstruction *init_value)
{
IrInstructionUnionInit *union_init_instruction = ir_build_instruction<IrInstructionUnionInit>(irb, scope, source_node);
union_init_instruction->union_type = union_type;
@@ -1412,7 +1412,7 @@ static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode
}
static IrInstruction *ir_build_union_init_from(IrBuilder *irb, IrInstruction *old_instruction,
- TypeTableEntry *union_type, TypeUnionField *field, IrInstruction *init_value)
+ ZigType *union_type, TypeUnionField *field, IrInstruction *init_value)
{
IrInstruction *new_instruction = ir_build_union_init(irb, old_instruction->scope,
old_instruction->source_node, union_type, field, init_value);
@@ -1973,7 +1973,7 @@ static IrInstruction *ir_build_cmpxchg(IrBuilder *irb, Scope *scope, AstNode *so
IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value,
IrInstruction *success_order_value, IrInstruction *failure_order_value,
bool is_weak,
- TypeTableEntry *type, AtomicOrder success_order, AtomicOrder failure_order)
+ ZigType *type, AtomicOrder success_order, AtomicOrder failure_order)
{
IrInstructionCmpxchg *instruction = ir_build_instruction<IrInstructionCmpxchg>(irb, scope, source_node);
instruction->type_value = type_value;
@@ -2286,7 +2286,7 @@ static IrInstruction *ir_build_handle_from(IrBuilder *irb, IrInstruction *old_in
static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,
IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
- IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)
+ IrInstruction *result_ptr, ZigType *result_ptr_type)
{
IrInstructionOverflowOp *instruction = ir_build_instruction<IrInstructionOverflowOp>(irb, scope, source_node);
instruction->op = op;
@@ -2306,7 +2306,7 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode
static IrInstruction *ir_build_overflow_op_from(IrBuilder *irb, IrInstruction *old_instruction,
IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
- IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)
+ IrInstruction *result_ptr, ZigType *result_ptr_type)
{
IrInstruction *new_instruction = ir_build_overflow_op(irb, old_instruction->scope, old_instruction->source_node,
op, type_value, op1, op2, result_ptr, result_ptr_type);
@@ -3343,7 +3343,7 @@ static VariableTableEntry *create_local_var(CodeGen *codegen, AstNode *node, Sco
add_error_note(codegen, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));
variable_entry->value->type = codegen->builtin_types.entry_invalid;
} else {
- TypeTableEntry *type = get_primitive_type(codegen, name);
+ ZigType *type = get_primitive_type(codegen, name);
if (type != nullptr) {
add_node_error(codegen, node,
buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));
@@ -3789,7 +3789,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
return &const_instruction->base;
}
- TypeTableEntry *primitive_type = get_primitive_type(irb->codegen, variable_name);
+ ZigType *primitive_type = get_primitive_type(irb->codegen, variable_name);
if (primitive_type != nullptr) {
IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_type);
if (lval == LValPtr) {
@@ -5696,7 +5696,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode
if (scope->id == ScopeIdDecls) {
ScopeDecls *decls_scope = (ScopeDecls *)scope;
- TypeTableEntry *container_type = decls_scope->container_type;
+ ZigType *container_type = decls_scope->container_type;
assert(container_type);
return ir_build_const_type(irb, scope, node, container_type);
}
@@ -6566,7 +6566,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
init_tld(&tld_container->base, TldIdContainer, name, visib_mod, node, parent_scope);
ContainerLayout layout = node->data.container_decl.layout;
- TypeTableEntry *container_type = get_partial_container_type(irb->codegen, parent_scope,
+ ZigType *container_type = get_partial_container_type(irb->codegen, parent_scope,
kind, node, buf_ptr(name), layout);
ScopeDecls *child_scope = get_container_scope(container_type);
@@ -6586,11 +6586,11 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
}
// errors should be populated with set1's values
-static TypeTableEntry *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, TypeTableEntry *set1, TypeTableEntry *set2) {
+static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigType *set1, ZigType *set2) {
assert(set1->id == TypeTableEntryIdErrorSet);
assert(set2->id == TypeTableEntryIdErrorSet);
- TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
+ ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_resize(&err_set_type->name, 0);
buf_appendf(&err_set_type->name, "error{");
@@ -6639,10 +6639,10 @@ static TypeTableEntry *get_error_set_union(CodeGen *g, ErrorTableEntry **errors,
}
-static TypeTableEntry *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node,
+static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node,
ErrorTableEntry *err_entry)
{
- TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
+ ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_resize(&err_set_type->name, 0);
buf_appendf(&err_set_type->name, "error{%s}", buf_ptr(&err_entry->name));
err_set_type->is_copyable = true;
@@ -6664,7 +6664,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A
uint32_t err_count = node->data.err_set_decl.decls.length;
Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node);
- TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
+ ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_init_from_buf(&err_set_type->name, type_name);
err_set_type->is_copyable = true;
err_set_type->data.error_set.err_count = err_count;
@@ -7386,7 +7386,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
IrInstruction *const_bool_false;
IrInstruction *coro_promise_ptr;
IrInstruction *err_ret_trace_ptr;
- TypeTableEntry *return_type;
+ ZigType *return_type;
Buf *result_ptr_field_name;
VariableTableEntry *coro_size_var;
if (is_async) {
@@ -7397,7 +7397,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;
IrInstruction *undef = ir_build_const_undefined(irb, coro_scope, node);
- TypeTableEntry *coro_frame_type = get_promise_frame_type(irb->codegen, return_type);
+ ZigType *coro_frame_type = get_promise_frame_type(irb->codegen, return_type);
IrInstruction *coro_frame_type_value = ir_build_const_type(irb, coro_scope, node, coro_frame_type);
// TODO mark this var decl as "no safety" e.g. disable initializing the undef value to 0xaa
ir_build_var_decl(irb, coro_scope, node, promise_var, coro_frame_type_value, nullptr, undef);
@@ -7629,7 +7629,7 @@ static ConstExprValue *ir_const_ptr_pointee(IrAnalyze *ira, ConstExprValue *cons
ConstExprValue *val = const_ptr_pointee_unchecked(ira->codegen, const_val);
assert(val != nullptr);
assert(const_val->type->id == TypeTableEntryIdPointer);
- TypeTableEntry *expected_type = const_val->type->data.pointer.child_type;
+ ZigType *expected_type = const_val->type->data.pointer.child_type;
if (!types_have_same_zig_comptime_repr(val->type, expected_type)) {
ir_add_error_node(ira, source_node,
buf_sprintf("TODO handle comptime reinterpreted pointer. See https://github.com/ziglang/zig/issues/955"));
@@ -7668,7 +7668,7 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so
return true;
}
-static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) {
+static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) {
return ((num_lit_type->id == TypeTableEntryIdComptimeFloat &&
(const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) ||
(num_lit_type->id == TypeTableEntryIdComptimeInt &&
@@ -8365,7 +8365,7 @@ void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) {
}
}
-static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *other_type,
+static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, ZigType *other_type,
bool explicit_cast)
{
if (type_is_invalid(other_type)) {
@@ -8399,7 +8399,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
} else if (const_val_fits_in_num_lit(const_val, other_type)) {
return true;
} else if (other_type->id == TypeTableEntryIdOptional) {
- TypeTableEntry *child_type = other_type->data.maybe.child_type;
+ ZigType *child_type = other_type->data.maybe.child_type;
if (const_val_fits_in_num_lit(const_val, child_type)) {
return true;
} else if (child_type->id == TypeTableEntryIdInt && const_val_is_int) {
@@ -8467,16 +8467,16 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
return false;
}
-static bool is_slice(TypeTableEntry *type) {
+static bool is_slice(ZigType *type) {
return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;
}
-static bool slice_is_const(TypeTableEntry *type) {
+static bool slice_is_const(ZigType *type) {
assert(is_slice(type));
return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
}
-static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry *set1, TypeTableEntry *set2,
+static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2,
AstNode *source_node)
{
assert(set1->id == TypeTableEntryIdErrorSet);
@@ -8502,7 +8502,7 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry
}
ZigList<ErrorTableEntry *> intersection_list = {};
- TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
+ ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
buf_resize(&err_set_type->name, 0);
buf_appendf(&err_set_type->name, "error{");
@@ -8531,8 +8531,8 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry
}
-static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry *wanted_type,
- TypeTableEntry *actual_type, AstNode *source_node, bool wanted_is_mutable)
+static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted_type,
+ ZigType *actual_type, AstNode *source_node, bool wanted_is_mutable)
{
CodeGen *g = ira->codegen;
ConstCastOnly result = {};
@@ -8595,8 +8595,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
// slice const
if (is_slice(wanted_type) && is_slice(actual_type)) {
- TypeTableEntry *actual_ptr_type = actual_type->data.structure.fields[slice_ptr_index].type_entry;
- TypeTableEntry *wanted_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *actual_ptr_type = actual_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *wanted_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
if ((!actual_ptr_type->data.pointer.is_const || wanted_ptr_type->data.pointer.is_const) &&
(!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile) &&
actual_ptr_type->data.pointer.bit_offset == wanted_ptr_type->data.pointer.bit_offset &&
@@ -8657,8 +8657,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
// error set
if (wanted_type->id == TypeTableEntryIdErrorSet && actual_type->id == TypeTableEntryIdErrorSet) {
- TypeTableEntry *contained_set = actual_type;
- TypeTableEntry *container_set = wanted_type;
+ ZigType *contained_set = actual_type;
+ ZigType *container_set = wanted_type;
// if the container set is inferred, then this will always work.
if (container_set->data.error_set.infer_fn != nullptr) {
@@ -8797,7 +8797,7 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t *
*errors = reallocate(*errors, old_errors_count, *errors_count);
}
-static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, TypeTableEntry *expected_type, IrInstruction **instructions, size_t instruction_count) {
+static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, IrInstruction **instructions, size_t instruction_count) {
Error err;
assert(instruction_count >= 1);
IrInstruction *prev_inst = instructions[0];
@@ -8806,7 +8806,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
}
ErrorTableEntry **errors = nullptr;
size_t errors_count = 0;
- TypeTableEntry *err_set_type = nullptr;
+ ZigType *err_set_type = nullptr;
if (prev_inst->value.type->id == TypeTableEntryIdErrorSet) {
if (type_is_global_error_set(prev_inst->value.type)) {
err_set_type = ira->codegen->builtin_types.entry_global_error_set;
@@ -8829,8 +8829,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
bool convert_to_const_slice = false;
for (size_t i = 1; i < instruction_count; i += 1) {
IrInstruction *cur_inst = instructions[i];
- TypeTableEntry *cur_type = cur_inst->value.type;
- TypeTableEntry *prev_type = prev_inst->value.type;
+ ZigType *cur_type = cur_inst->value.type;
+ ZigType *prev_type = prev_inst->value.type;
if (type_is_invalid(cur_type)) {
return cur_type;
@@ -8916,7 +8916,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
prev_inst = cur_inst;
continue;
}
- TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
+ ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
return ira->codegen->builtin_types.entry_invalid;
}
@@ -9021,8 +9021,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
}
if (prev_type->id == TypeTableEntryIdErrorUnion && cur_type->id == TypeTableEntryIdErrorUnion) {
- TypeTableEntry *prev_payload_type = prev_type->data.error_union.payload_type;
- TypeTableEntry *cur_payload_type = cur_type->data.error_union.payload_type;
+ ZigType *prev_payload_type = prev_type->data.error_union.payload_type;
+ ZigType *cur_payload_type = cur_type->data.error_union.payload_type;
bool const_cast_prev = types_match_const_cast_only(ira, prev_payload_type, cur_payload_type,
source_node, false).id == ConstCastResultIdOk;
@@ -9034,8 +9034,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
prev_inst = cur_inst;
}
- TypeTableEntry *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type;
- TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
+ ZigType *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type;
+ ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
if (!resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) {
return ira->codegen->builtin_types.entry_invalid;
@@ -9152,7 +9152,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
source_node, false).id == ConstCastResultIdOk)
{
if (err_set_type != nullptr) {
- TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
+ ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
return ira->codegen->builtin_types.entry_invalid;
}
@@ -9293,12 +9293,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
if (convert_to_const_slice) {
assert(prev_inst->value.type->id == TypeTableEntryIdArray);
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(
+ ZigType *ptr_type = get_pointer_to_type_extra(
ira->codegen, prev_inst->value.type->data.array.child_type,
true, false, PtrLenUnknown,
get_abi_alignment(ira->codegen, prev_inst->value.type->data.array.child_type),
0, 0);
- TypeTableEntry *slice_type = get_slice_type(ira->codegen, ptr_type);
+ ZigType *slice_type = get_slice_type(ira->codegen, ptr_type);
if (err_set_type != nullptr) {
return get_error_union_type(ira->codegen, err_set_type, slice_type);
} else {
@@ -9343,7 +9343,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
}
}
-static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *type_entry) {
+static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) {
if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) {
FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
if (fn_entry != nullptr) {
@@ -9366,8 +9366,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_
static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
CastOp cast_op,
- ConstExprValue *other_val, TypeTableEntry *other_type,
- ConstExprValue *const_val, TypeTableEntry *new_type)
+ ConstExprValue *other_val, ZigType *other_type,
+ ConstExprValue *const_val, ZigType *new_type)
{
const_val->special = other_val->special;
@@ -9467,7 +9467,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
return true;
}
static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
- TypeTableEntry *wanted_type, CastOp cast_op, bool need_alloca)
+ ZigType *wanted_type, CastOp cast_op, bool need_alloca)
{
if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)
@@ -9491,7 +9491,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
}
static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *value, TypeTableEntry *wanted_type)
+ IrInstruction *value, ZigType *wanted_type)
{
assert(value->value.type->id == TypeTableEntryIdPointer);
wanted_type = adjust_ptr_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);
@@ -9520,7 +9520,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira,
}
static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *value, TypeTableEntry *wanted_type)
+ IrInstruction *value, ZigType *wanted_type)
{
wanted_type = adjust_slice_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);
@@ -9530,7 +9530,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
return ira->codegen->invalid_instruction;
if (pointee->special != ConstValSpecialRuntime) {
assert(value->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = value->value.type->data.pointer.child_type;
+ ZigType *array_type = value->value.type->data.pointer.child_type;
assert(is_slice(wanted_type));
bool is_const = wanted_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
@@ -9551,7 +9551,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
return result;
}
-static bool is_container(TypeTableEntry *type) {
+static bool is_container(ZigType *type) {
return type->id == TypeTableEntryIdStruct ||
type->id == TypeTableEntryIdEnum ||
type->id == TypeTableEntryIdUnion;
@@ -9630,7 +9630,7 @@ static void ir_finish_bb(IrAnalyze *ira) {
}
}
-static TypeTableEntry *ir_unreach_error(IrAnalyze *ira) {
+static ZigType *ir_unreach_error(IrAnalyze *ira) {
ira->old_bb_index = SIZE_MAX;
ira->new_irb.exec->invalid = true;
return ira->codegen->builtin_types.entry_unreachable;
@@ -9653,7 +9653,7 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru
return true;
}
-static TypeTableEntry *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) {
+static ZigType *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) {
if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) {
if (!ir_emit_backward_branch(ira, source_instruction))
return ir_unreach_error(ira);
@@ -9664,7 +9664,7 @@ static TypeTableEntry *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instru
return ira->codegen->builtin_types.entry_unreachable;
}
-static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_type) {
+static ZigType *ir_finish_anal(IrAnalyze *ira, ZigType *result_type) {
if (result_type->id == TypeTableEntryIdUnreachable)
ir_finish_bb(ira);
return result_type;
@@ -9684,16 +9684,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in
return &new_instruction->value;
}
-static TypeTableEntry *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) {
+static ZigType *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) {
ir_build_const_from(ira, instruction);
return ira->codegen->builtin_types.entry_void;
}
static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
- ConstExprValue *pointee, TypeTableEntry *pointee_type,
+ ConstExprValue *pointee, ZigType *pointee_type,
ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align)
{
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0);
IrInstruction *const_instr = ir_get_const(ira, instruction);
ConstExprValue *const_val = &const_instr->value;
@@ -9704,8 +9704,8 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio
return const_instr;
}
-static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
- ConstExprValue *pointee, TypeTableEntry *pointee_type,
+static ZigType *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
+ ConstExprValue *pointee, ZigType *pointee_type,
ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile)
{
IrInstruction *const_instr = ir_get_const_ptr(ira, instruction, pointee,
@@ -9715,7 +9715,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr
return const_instr->value.type;
}
-static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) {
+static ZigType *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) {
ConstExprValue *const_val = ir_build_const_from(ira, instruction);
bigint_init_unsigned(&const_val->data.x_bigint, value);
return ira->codegen->builtin_types.entry_usize;
@@ -9748,7 +9748,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
}
IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
- TypeTableEntry *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
+ ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
IrExecutable *parent_exec)
{
@@ -9786,7 +9786,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node
analyzed_executable->backward_branch_count = backward_branch_count;
analyzed_executable->backward_branch_quota = backward_branch_quota;
analyzed_executable->begin_scope = scope;
- TypeTableEntry *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, node);
+ ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, node);
if (type_is_invalid(result_type))
return codegen->invalid_instruction;
@@ -9799,7 +9799,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node
return ir_exec_const_result(codegen, analyzed_executable);
}
-static TypeTableEntry *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
+static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
if (type_is_invalid(type_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -9837,11 +9837,11 @@ static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
return const_val->data.x_ptr.data.fn.fn_entry;
}
-static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {
+static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
assert(wanted_type->id == TypeTableEntryIdOptional);
if (instr_is_comptime(value)) {
- TypeTableEntry *payload_type = wanted_type->data.maybe.child_type;
+ ZigType *payload_type = wanted_type->data.maybe.child_type;
IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
if (type_is_invalid(casted_payload->value.type))
return ira->codegen->invalid_instruction;
@@ -9870,12 +9870,12 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc
}
static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *value, TypeTableEntry *wanted_type)
+ IrInstruction *value, ZigType *wanted_type)
{
assert(wanted_type->id == TypeTableEntryIdErrorUnion);
if (instr_is_comptime(value)) {
- TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;
+ ZigType *payload_type = wanted_type->data.error_union.payload_type;
IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
if (type_is_invalid(casted_payload->value.type))
return ira->codegen->invalid_instruction;
@@ -9901,7 +9901,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
}
static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
- TypeTableEntry *wanted_type)
+ ZigType *wanted_type)
{
assert(value->value.type->id == TypeTableEntryIdErrorSet);
assert(wanted_type->id == TypeTableEntryIdErrorSet);
@@ -9943,7 +9943,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou
return result;
}
-static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {
+static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
assert(wanted_type->id == TypeTableEntryIdErrorUnion);
IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type);
@@ -9970,7 +9970,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
}
static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *value, TypeTableEntry *wanted_type)
+ IrInstruction *value, ZigType *wanted_type)
{
if (instr_is_comptime(value)) {
ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
@@ -9994,7 +9994,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
source_instr->source_node, value, true, false);
new_instruction->value.type = wanted_type;
- TypeTableEntry *child_type = wanted_type->data.pointer.child_type;
+ ZigType *child_type = wanted_type->data.pointer.child_type;
if (type_has_bits(child_type)) {
FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
assert(fn_entry);
@@ -10005,7 +10005,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
}
}
-static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {
+static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
assert(wanted_type->id == TypeTableEntryIdOptional);
assert(instr_is_comptime(value));
@@ -10039,7 +10039,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
get_abi_alignment(ira->codegen, value->value.type));
}
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,
is_const, is_volatile, PtrLenSingle, get_abi_alignment(ira->codegen, value->value.type), 0, 0);
IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instruction->scope,
source_instruction->source_node, value, is_const, is_volatile);
@@ -10054,7 +10054,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
}
static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *array_arg, TypeTableEntry *wanted_type)
+ IrInstruction *array_arg, ZigType *wanted_type)
{
assert(is_slice(wanted_type));
// In this function we honor the const-ness of wanted_type, because
@@ -10068,7 +10068,7 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
} else {
array = array_arg;
}
- TypeTableEntry *array_type = array->value.type;
+ ZigType *array_type = array->value.type;
assert(array_type->id == TypeTableEntryIdArray);
if (instr_is_comptime(array)) {
@@ -10100,12 +10100,12 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
}
static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
Error err;
assert(wanted_type->id == TypeTableEntryIdInt);
- TypeTableEntry *actual_type = target->value.type;
+ ZigType *actual_type = target->value.type;
if ((err = ensure_complete_type(ira->codegen, actual_type)))
return ira->codegen->invalid_instruction;
@@ -10136,7 +10136,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
}
static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
assert(target->value.type->id == TypeTableEntryIdUnion);
assert(wanted_type->id == TypeTableEntryIdEnum);
@@ -10161,7 +10161,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou
}
static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
source_instr->source_node, wanted_type);
@@ -10170,7 +10170,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc
}
static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
Error err;
assert(wanted_type->id == TypeTableEntryIdUnion);
@@ -10229,7 +10229,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
}
static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
assert(wanted_type->id == TypeTableEntryIdInt || wanted_type->id == TypeTableEntryIdFloat);
@@ -10270,12 +10270,12 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction
}
static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
Error err;
assert(wanted_type->id == TypeTableEntryIdEnum);
- TypeTableEntry *actual_type = target->value.type;
+ ZigType *actual_type = target->value.type;
if ((err = ensure_complete_type(ira->codegen, wanted_type)))
return ira->codegen->invalid_instruction;
@@ -10320,7 +10320,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
}
static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr,
- IrInstruction *target, TypeTableEntry *wanted_type)
+ IrInstruction *target, ZigType *wanted_type)
{
ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
if (!val)
@@ -10339,7 +10339,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
}
static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
- TypeTableEntry *wanted_type)
+ ZigType *wanted_type)
{
assert(target->value.type->id == TypeTableEntryIdInt);
assert(!target->value.type->data.integral.is_signed);
@@ -10404,11 +10404,11 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
}
static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
- TypeTableEntry *wanted_type)
+ ZigType *wanted_type)
{
assert(wanted_type->id == TypeTableEntryIdInt);
- TypeTableEntry *err_type = target->value.type;
+ ZigType *err_type = target->value.type;
if (instr_is_comptime(target)) {
ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
@@ -10442,7 +10442,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
return result;
}
- TypeTableEntry *err_set_type;
+ ZigType *err_set_type;
if (err_type->id == TypeTableEntryIdErrorUnion) {
err_set_type = err_type->data.error_union.err_set_type;
} else if (err_type->id == TypeTableEntryIdErrorSet) {
@@ -10484,11 +10484,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
}
static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
- TypeTableEntry *wanted_type)
+ ZigType *wanted_type)
{
assert(wanted_type->id == TypeTableEntryIdPointer);
wanted_type = adjust_ptr_align(ira->codegen, wanted_type, target->value.type->data.pointer.alignment);
- TypeTableEntry *array_type = wanted_type->data.pointer.child_type;
+ ZigType *array_type = wanted_type->data.pointer.child_type;
assert(array_type->id == TypeTableEntryIdArray);
assert(array_type->data.array.len == 1);
@@ -10620,10 +10620,10 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
}
static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr,
- TypeTableEntry *wanted_type, IrInstruction *value)
+ ZigType *wanted_type, IrInstruction *value)
{
Error err;
- TypeTableEntry *actual_type = value->value.type;
+ ZigType *actual_type = value->value.type;
AstNode *source_node = source_instr->source_node;
if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) {
@@ -10665,7 +10665,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
// cast from [N]T to []const T
if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdArray) {
- TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
assert(ptr_type->id == TypeTableEntryIdPointer);
if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
@@ -10681,10 +10681,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
actual_type->data.pointer.is_const &&
actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
{
- TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = actual_type->data.pointer.child_type;
+ ZigType *array_type = actual_type->data.pointer.child_type;
if ((ptr_type->data.pointer.is_const || array_type->data.array.len == 0) &&
types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, array_type->data.array.child_type,
@@ -10700,7 +10700,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
is_slice(wanted_type->data.pointer.child_type) &&
actual_type->id == TypeTableEntryIdArray)
{
- TypeTableEntry *ptr_type =
+ ZigType *ptr_type =
wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry;
assert(ptr_type->id == TypeTableEntryIdPointer);
if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
@@ -10724,7 +10724,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
is_slice(wanted_type->data.maybe.child_type) &&
actual_type->id == TypeTableEntryIdArray)
{
- TypeTableEntry *ptr_type =
+ ZigType *ptr_type =
wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry;
assert(ptr_type->id == TypeTableEntryIdPointer);
if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
@@ -10763,7 +10763,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
actual_type->data.pointer.ptr_len == PtrLenSingle &&
actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
{
- TypeTableEntry *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
assert(slice_ptr_type->id == TypeTableEntryIdPointer);
if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type,
actual_type->data.pointer.child_type->data.array.child_type, source_node,
@@ -10777,7 +10777,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
// cast from T to ?T
// note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism
if (wanted_type->id == TypeTableEntryIdOptional) {
- TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;
+ ZigType *wanted_child_type = wanted_type->data.maybe.child_type;
if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node,
false).id == ConstCastResultIdOk)
{
@@ -10850,7 +10850,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
is_slice(wanted_type->data.error_union.payload_type) &&
actual_type->id == TypeTableEntryIdArray)
{
- TypeTableEntry *ptr_type =
+ ZigType *ptr_type =
wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry;
assert(ptr_type->id == TypeTableEntryIdPointer);
if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
@@ -10881,7 +10881,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
wanted_type->data.error_union.payload_type->id == TypeTableEntryIdOptional &&
actual_type->id != TypeTableEntryIdOptional)
{
- TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
+ ZigType *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk ||
actual_type->id == TypeTableEntryIdNull ||
actual_type->id == TypeTableEntryIdComptimeInt ||
@@ -10983,7 +10983,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
// enum to &const union which has the enum as the tag type
if (actual_type->id == TypeTableEntryIdEnum && wanted_type->id == TypeTableEntryIdPointer) {
- TypeTableEntry *union_type = wanted_type->data.pointer.child_type;
+ ZigType *union_type = wanted_type->data.pointer.child_type;
if (union_type->data.unionation.decl_node->data.container_decl.auto_enum ||
union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)
{
@@ -11008,7 +11008,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle &&
actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle)
{
- TypeTableEntry *array_type = wanted_type->data.pointer.child_type;
+ ZigType *array_type = wanted_type->data.pointer.child_type;
if (array_type->id == TypeTableEntryIdArray && array_type->data.array.len == 1 &&
types_match_const_cast_only(ira, array_type->data.array.child_type,
actual_type->data.pointer.child_type, source_node,
@@ -11049,7 +11049,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
// cast from something to const pointer of it
if (!type_requires_comptime(actual_type)) {
- TypeTableEntry *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);
+ ZigType *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);
if (types_match_const_cast_only(ira, wanted_type, const_ptr_actual, source_node, false).id == ConstCastResultIdOk) {
return ir_analyze_cast_ref(ira, source_instr, value, wanted_type);
}
@@ -11063,7 +11063,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
return ira->codegen->invalid_instruction;
}
-static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *expected_type) {
+static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) {
assert(value);
assert(value != ira->codegen->invalid_instruction);
assert(!expected_type || !type_is_invalid(expected_type));
@@ -11080,11 +11080,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Typ
}
static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr) {
- TypeTableEntry *type_entry = ptr->value.type;
+ ZigType *type_entry = ptr->value.type;
if (type_is_invalid(type_entry)) {
return ira->codegen->invalid_instruction;
} else if (type_entry->id == TypeTableEntryIdPointer) {
- TypeTableEntry *child_type = type_entry->data.pointer.child_type;
+ ZigType *child_type = type_entry->data.pointer.child_type;
if (instr_is_comptime(ptr)) {
if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst ||
ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar)
@@ -11114,7 +11114,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
}
}
-static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value,
+static ZigType *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value,
bool is_const, bool is_volatile)
{
IrInstruction *result = ir_get_ref(ira, source_instruction, value, is_const, is_volatile);
@@ -11149,7 +11149,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, uint32_t *out
return true;
}
-static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *int_type, uint64_t *out) {
+static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) {
if (type_is_invalid(value->value.type))
return false;
@@ -11199,7 +11199,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");
assert(atomic_order_val->type->id == TypeTableEntryIdMetaType);
- TypeTableEntry *atomic_order_type = atomic_order_val->data.x_type;
+ ZigType *atomic_order_type = atomic_order_val->data.x_type;
IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type);
if (type_is_invalid(casted_value->value.type))
@@ -11219,7 +11219,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");
assert(atomic_rmw_op_val->type->id == TypeTableEntryIdMetaType);
- TypeTableEntry *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
+ ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type);
if (type_is_invalid(casted_value->value.type))
@@ -11239,7 +11239,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");
assert(global_linkage_val->type->id == TypeTableEntryIdMetaType);
- TypeTableEntry *global_linkage_type = global_linkage_val->data.x_type;
+ ZigType *global_linkage_type = global_linkage_val->data.x_type;
IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type);
if (type_is_invalid(casted_value->value.type))
@@ -11259,7 +11259,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");
assert(float_mode_val->type->id == TypeTableEntryIdMetaType);
- TypeTableEntry *float_mode_type = float_mode_val->data.x_type;
+ ZigType *float_mode_type = float_mode_val->data.x_type;
IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type);
if (type_is_invalid(casted_value->value.type))
@@ -11278,10 +11278,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
if (type_is_invalid(value->value.type))
return nullptr;
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
true, false, PtrLenUnknown,
get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(ira->codegen, ptr_type);
+ ZigType *str_type = get_slice_type(ira->codegen, ptr_type);
IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type);
if (type_is_invalid(casted_value->value.type))
return nullptr;
@@ -11314,7 +11314,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
return result;
}
-static TypeTableEntry *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira,
IrInstructionAddImplicitReturnType *instruction)
{
IrInstruction *value = instruction->value->other;
@@ -11328,7 +11328,7 @@ static TypeTableEntry *ir_analyze_instruction_add_implicit_return_type(IrAnalyze
return out_val->type;
}
-static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_return(IrAnalyze *ira,
IrInstructionReturn *return_instruction)
{
IrInstruction *value = return_instruction->value->other;
@@ -11353,13 +11353,13 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,
return ir_finish_anal(ira, result->value.type);
}
-static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) {
+static ZigType *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) {
ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base);
*out_val = const_instruction->base.value;
return const_instruction->base.value.type;
}
-static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
+static ZigType *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
IrInstruction *op1 = bin_op_instruction->op1->other;
if (type_is_invalid(op1->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -11368,7 +11368,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
if (type_is_invalid(op2->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;
+ ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type);
if (casted_op1 == ira->codegen->invalid_instruction)
@@ -11433,7 +11433,7 @@ static bool optional_value_is_null(ConstExprValue *val) {
}
}
-static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
+static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
Error err;
IrInstruction *op1 = bin_op_instruction->op1->other;
IrInstruction *op2 = bin_op_instruction->op2->other;
@@ -11486,7 +11486,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors"));
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node);
+ ZigType *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node);
if (type_is_invalid(intersect_type)) {
return ira->codegen->builtin_types.entry_invalid;
}
@@ -11567,7 +11567,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
}
IrInstruction *instructions[] = {op1, op2};
- TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2);
+ ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2);
if (type_is_invalid(resolved_type))
return resolved_type;
if ((err = type_ensure_zero_bits_known(ira->codegen, resolved_type)))
@@ -11705,7 +11705,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
return ira->codegen->builtin_types.entry_bool;
}
-static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,
+static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val,
IrBinOp op_id, ConstExprValue *op2_val, ConstExprValue *out_val)
{
bool is_int;
@@ -11885,7 +11885,7 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,
return 0;
}
-static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
+static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
IrInstruction *op1 = bin_op_instruction->op1->other;
if (type_is_invalid(op1->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -11917,7 +11917,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
return ira->codegen->builtin_types.entry_invalid;
}
} else {
- TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
+ ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
op1->value.type->data.integral.bit_count - 1);
if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy &&
op2->value.type->id == TypeTableEntryIdComptimeInt) {
@@ -11985,7 +11985,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
return op1->value.type;
}
-static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
+static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
IrInstruction *op1 = bin_op_instruction->op1->other;
if (type_is_invalid(op1->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -12012,7 +12012,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
}
IrInstruction *instructions[] = {op1, op2};
- TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, nullptr, instructions, 2);
+ ZigType *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, nullptr, instructions, 2);
if (type_is_invalid(resolved_type))
return resolved_type;
@@ -12206,14 +12206,14 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
}
-static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) {
+static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) {
IrInstruction *op1 = instruction->op1->other;
- TypeTableEntry *op1_type = op1->value.type;
+ ZigType *op1_type = op1->value.type;
if (type_is_invalid(op1_type))
return ira->codegen->builtin_types.entry_invalid;
IrInstruction *op2 = instruction->op2->other;
- TypeTableEntry *op2_type = op2->value.type;
+ ZigType *op2_type = op2->value.type;
if (type_is_invalid(op2_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -12228,7 +12228,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
ConstExprValue *op1_array_val;
size_t op1_array_index;
size_t op1_array_end;
- TypeTableEntry *child_type;
+ ZigType *child_type;
if (op1_type->id == TypeTableEntryIdArray) {
child_type = op1_type->data.array.child_type;
op1_array_val = op1_val;
@@ -12244,7 +12244,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
op1_array_index = op1_val->data.x_ptr.data.base_array.elem_index;
op1_array_end = op1_array_val->type->data.array.len - 1;
} else if (is_slice(op1_type)) {
- TypeTableEntry *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry;
child_type = ptr_type->data.pointer.child_type;
ConstExprValue *ptr_val = &op1_val->data.x_struct.fields[slice_ptr_index];
assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
@@ -12285,7 +12285,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
op2_array_index = op2_val->data.x_ptr.data.base_array.elem_index;
op2_array_end = op2_array_val->type->data.array.len - 1;
} else if (is_slice(op2_type)) {
- TypeTableEntry *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
if (ptr_type->data.pointer.child_type != child_type) {
ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
buf_ptr(&child_type->name),
@@ -12305,7 +12305,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
- TypeTableEntry *result_type;
+ ZigType *result_type;
ConstExprValue *out_array_val;
size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index);
if (op1_type->id == TypeTableEntryIdArray || op2_type->id == TypeTableEntryIdArray) {
@@ -12313,7 +12313,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
out_array_val = out_val;
} else if (is_slice(op1_type) || is_slice(op2_type)) {
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, child_type), 0, 0);
result_type = get_slice_type(ira->codegen, ptr_type);
out_array_val = create_const_vals(1);
@@ -12374,7 +12374,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
return result_type;
}
-static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) {
+static ZigType *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) {
IrInstruction *op1 = instruction->op1->other;
if (type_is_invalid(op1->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -12391,7 +12391,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
if (!ir_resolve_usize(ira, op2, &mult_amt))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *array_type = op1->value.type;
+ ZigType *array_type = op1->value.type;
if (array_type->id != TypeTableEntryIdArray) {
ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name)));
return ira->codegen->builtin_types.entry_invalid;
@@ -12410,7 +12410,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
if (array_val->data.x_array.special == ConstArraySpecialUndef) {
out_val->data.x_array.special = ConstArraySpecialUndef;
- TypeTableEntry *child_type = array_type->data.array.child_type;
+ ZigType *child_type = array_type->data.array.child_type;
return get_array_type(ira->codegen, child_type, new_array_len);
}
@@ -12425,16 +12425,16 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
}
assert(i == new_array_len);
- TypeTableEntry *child_type = array_type->data.array.child_type;
+ ZigType *child_type = array_type->data.array.child_type;
return get_array_type(ira->codegen, child_type, new_array_len);
}
-static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
- TypeTableEntry *op1_type = ir_resolve_type(ira, instruction->op1->other);
+static ZigType *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
+ ZigType *op1_type = ir_resolve_type(ira, instruction->op1->other);
if (type_is_invalid(op1_type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *op2_type = ir_resolve_type(ira, instruction->op2->other);
+ ZigType *op2_type = ir_resolve_type(ira, instruction->op2->other);
if (type_is_invalid(op2_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -12460,7 +12460,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction
assert(errors[error_entry->value] == nullptr);
errors[error_entry->value] = error_entry;
}
- TypeTableEntry *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type);
+ ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type);
free(errors);
@@ -12469,7 +12469,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
+static ZigType *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
IrBinOp op_id = bin_op_instruction->op_id;
switch (op_id) {
case IrBinOpInvalid:
@@ -12516,7 +12516,7 @@ static TypeTableEntry *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructi
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDeclVar *decl_var_instruction) {
+static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDeclVar *decl_var_instruction) {
Error err;
VariableTableEntry *var = decl_var_instruction->var;
@@ -12526,11 +12526,11 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
return var->value->type;
}
- TypeTableEntry *explicit_type = nullptr;
+ ZigType *explicit_type = nullptr;
IrInstruction *var_type = nullptr;
if (decl_var_instruction->var_type != nullptr) {
var_type = decl_var_instruction->var_type->other;
- TypeTableEntry *proposed_type = ir_resolve_type(ira, var_type);
+ ZigType *proposed_type = ir_resolve_type(ira, var_type);
explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);
if (type_is_invalid(explicit_type)) {
var->value->type = ira->codegen->builtin_types.entry_invalid;
@@ -12545,7 +12545,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
bool var_class_requires_const = false;
- TypeTableEntry *result_type = casted_init_value->value.type;
+ ZigType *result_type = casted_init_value->value.type;
if (type_is_invalid(result_type)) {
result_type = ira->codegen->builtin_types.entry_invalid;
} else {
@@ -12651,7 +12651,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {
+static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {
IrInstruction *name = instruction->name->other;
Buf *symbol_name = ir_resolve_str(ira, name);
if (symbol_name == nullptr) {
@@ -12731,7 +12731,7 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
}
break;
case TypeTableEntryIdMetaType: {
- TypeTableEntry *type_value = target->value.data.x_type;
+ ZigType *type_value = target->value.data.x_type;
switch (type_value->id) {
case TypeTableEntryIdInvalid:
zig_unreachable();
@@ -12826,12 +12826,12 @@ static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) {
return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;
}
-static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
IrInstructionErrorReturnTrace *instruction)
{
if (instruction->optional == IrInstructionErrorReturnTrace::Null) {
- TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(ira->codegen);
- TypeTableEntry *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
+ ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(ira->codegen);
+ ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
assert(get_codegen_ptr_type(optional_type) != nullptr);
@@ -12852,14 +12852,14 @@ static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
}
}
-static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira,
IrInstructionErrorUnion *instruction)
{
- TypeTableEntry *err_set_type = ir_resolve_type(ira, instruction->err_set->other);
+ ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->other);
if (type_is_invalid(err_set_type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *payload_type = ir_resolve_type(ira, instruction->payload->other);
+ ZigType *payload_type = ir_resolve_type(ira, instruction->payload->other);
if (type_is_invalid(payload_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -12870,7 +12870,7 @@ static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);
+ ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
out_val->data.x_type = result_type;
@@ -12913,38 +12913,38 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i
zig_unreachable();
}
-static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, TypeTableEntry *fn_type,
+static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, ZigType *fn_type,
IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst)
{
Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME);
//Buf *free_field_name = buf_create_from_str("freeFn");
assert(async_allocator_inst->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *container_type = async_allocator_inst->value.type->data.pointer.child_type;
+ ZigType *container_type = async_allocator_inst->value.type->data.pointer.child_type;
IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, alloc_field_name, &call_instruction->base,
async_allocator_inst, container_type);
if (type_is_invalid(field_ptr_inst->value.type)) {
return ira->codegen->invalid_instruction;
}
- TypeTableEntry *ptr_to_alloc_fn_type = field_ptr_inst->value.type;
+ ZigType *ptr_to_alloc_fn_type = field_ptr_inst->value.type;
assert(ptr_to_alloc_fn_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
+ ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
if (alloc_fn_type->id != TypeTableEntryIdFn) {
ir_add_error(ira, &call_instruction->base,
buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name)));
return ira->codegen->invalid_instruction;
}
- TypeTableEntry *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type;
+ ZigType *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type;
if (alloc_fn_return_type->id != TypeTableEntryIdErrorUnion) {
ir_add_error(ira, fn_ref,
buf_sprintf("expected allocation function to return error union, but it returns '%s'", buf_ptr(&alloc_fn_return_type->name)));
return ira->codegen->invalid_instruction;
}
- TypeTableEntry *alloc_fn_error_set_type = alloc_fn_return_type->data.error_union.err_set_type;
- TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;
- TypeTableEntry *promise_type = get_promise_type(ira->codegen, return_type);
- TypeTableEntry *async_return_type = get_error_union_type(ira->codegen, alloc_fn_error_set_type, promise_type);
+ ZigType *alloc_fn_error_set_type = alloc_fn_return_type->data.error_union.err_set_type;
+ ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
+ ZigType *promise_type = get_promise_type(ira->codegen, return_type);
+ ZigType *async_return_type = get_error_union_type(ira->codegen, alloc_fn_error_set_type, promise_type);
IrInstruction *result = ir_build_call(&ira->new_irb, call_instruction->base.scope, call_instruction->base.source_node,
fn_entry, fn_ref, arg_count, casted_args, false, FnInlineAuto, true, async_allocator_inst, nullptr);
@@ -12961,7 +12961,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
IrInstruction *casted_arg;
if (param_decl_node->data.param_decl.var_token == nullptr) {
AstNode *param_type_node = param_decl_node->data.param_decl.type;
- TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node);
+ ZigType *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node);
if (type_is_invalid(param_type))
return false;
@@ -13001,7 +13001,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
} else {
if (param_decl_node->data.param_decl.var_token == nullptr) {
AstNode *param_type_node = param_decl_node->data.param_decl.type;
- TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node);
+ ZigType *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node);
if (type_is_invalid(param_type))
return false;
@@ -13156,8 +13156,8 @@ no_mem_slot:
return var_ptr_instruction;
}
-static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction,
- FnTableEntry *fn_entry, TypeTableEntry *fn_type, IrInstruction *fn_ref,
+static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction,
+ FnTableEntry *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,
IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)
{
Error err;
@@ -13249,7 +13249,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
bool first_arg_known_bare = false;
if (fn_type_id->next_param_index >= 1) {
- TypeTableEntry *param_type = fn_type_id->param_info[next_proto_i].type;
+ ZigType *param_type = fn_type_id->param_info[next_proto_i].type;
if (type_is_invalid(param_type))
return ira->codegen->builtin_types.entry_invalid;
first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;
@@ -13285,11 +13285,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
}
AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
- TypeTableEntry *specified_return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node);
+ ZigType *specified_return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node);
if (type_is_invalid(specified_return_type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *return_type;
- TypeTableEntry *inferred_err_set_type = nullptr;
+ ZigType *return_type;
+ ZigType *inferred_err_set_type = nullptr;
if (fn_proto_node->data.fn_proto.auto_err_set) {
inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry);
return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);
@@ -13320,7 +13320,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1);
inferred_err_set_type->data.error_set.errors[0] = result->value.data.x_err_union.err;
}
- TypeTableEntry *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type;
+ ZigType *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type;
inferred_err_set_type->data.error_set.err_count = fn_inferred_err_set_type->data.error_set.err_count;
inferred_err_set_type->data.error_set.errors = fn_inferred_err_set_type->data.error_set.errors;
} else if (result->value.type->id == TypeTableEntryIdErrorSet) {
@@ -13344,10 +13344,10 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
IrInstruction *casted_new_stack = nullptr;
if (call_instruction->new_stack != nullptr) {
- TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
false, false, PtrLenUnknown,
get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *u8_slice = get_slice_type(ira->codegen, u8_ptr);
+ ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
IrInstruction *new_stack = call_instruction->new_stack->other;
if (type_is_invalid(new_stack->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13405,7 +13405,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
bool first_arg_known_bare = false;
if (fn_type_id->next_param_index >= 1) {
- TypeTableEntry *param_type = fn_type_id->param_info[next_proto_i].type;
+ ZigType *param_type = fn_type_id->param_info[next_proto_i].type;
if (type_is_invalid(param_type))
return ira->codegen->builtin_types.entry_invalid;
first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;
@@ -13515,11 +13515,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
if (fn_proto_node->data.fn_proto.return_var_token == nullptr) {
AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
- TypeTableEntry *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node);
+ ZigType *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node);
if (type_is_invalid(specified_return_type))
return ira->codegen->builtin_types.entry_invalid;
if (fn_proto_node->data.fn_proto.auto_err_set) {
- TypeTableEntry *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn);
+ ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn);
inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);
} else {
inst_fn_type_id.return_type = specified_return_type;
@@ -13537,7 +13537,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
if (call_instruction->is_async) {
AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type;
if (async_allocator_type_node != nullptr) {
- TypeTableEntry *async_allocator_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, async_allocator_type_node);
+ ZigType *async_allocator_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, async_allocator_type_node);
if (type_is_invalid(async_allocator_type))
return ira->codegen->builtin_types.entry_invalid;
inst_fn_type_id.async_allocator_type = async_allocator_type;
@@ -13581,7 +13581,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
ira->codegen->fn_defs.append(impl_fn);
}
- TypeTableEntry *return_type = impl_fn->type_entry->data.fn.fn_type_id.return_type;
+ ZigType *return_type = impl_fn->type_entry->data.fn.fn_type_id.return_type;
if (fn_type_can_fail(&impl_fn->type_entry->data.fn.fn_type_id)) {
parent_fn_entry->calls_or_awaits_errorable_fn = true;
}
@@ -13618,7 +13618,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
if (first_arg_ptr) {
assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type;
+ ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
if (type_is_invalid(param_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13646,7 +13646,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
return ira->codegen->builtin_types.entry_invalid;
IrInstruction *casted_arg;
if (next_arg_index < src_param_count) {
- TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type;
+ ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
if (type_is_invalid(param_type))
return ira->codegen->builtin_types.entry_invalid;
casted_arg = ir_implicit_cast(ira, old_arg, param_type);
@@ -13662,7 +13662,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
assert(next_arg_index == call_param_count);
- TypeTableEntry *return_type = fn_type_id->return_type;
+ ZigType *return_type = fn_type_id->return_type;
if (type_is_invalid(return_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13703,7 +13703,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
return ir_finish_anal(ira, return_type);
}
-static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *call_instruction) {
+static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *call_instruction) {
IrInstruction *fn_ref = call_instruction->fn_ref->other;
if (type_is_invalid(fn_ref->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13713,7 +13713,7 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction
if (is_comptime || instr_is_comptime(fn_ref)) {
if (fn_ref->value.type->id == TypeTableEntryIdMetaType) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, fn_ref);
+ ZigType *dest_type = ir_resolve_type(ira, fn_ref);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13793,12 +13793,12 @@ static Error ir_read_const_ptr(IrAnalyze *ira, AstNode *source_node,
return ErrorNone;
}
-static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
+static ZigType *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
Error err;
IrInstruction *value = un_op_instruction->value->other;
- TypeTableEntry *ptr_type = value->value.type;
- TypeTableEntry *child_type;
+ ZigType *ptr_type = value->value.type;
+ ZigType *child_type;
if (type_is_invalid(ptr_type)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (ptr_type->id == TypeTableEntryIdPointer) {
@@ -13835,10 +13835,10 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp
return child_type;
}
-static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
+static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
Error err;
IrInstruction *value = un_op_instruction->value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, value);
+ ZigType *type_entry = ir_resolve_type(ira, value);
if (type_is_invalid(type_entry))
return ira->codegen->builtin_types.entry_invalid;
if ((err = ensure_complete_type(ira->codegen, type_entry)))
@@ -13884,9 +13884,9 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
+static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
IrInstruction *value = un_op_instruction->value->other;
- TypeTableEntry *expr_type = value->value.type;
+ ZigType *expr_type = value->value.type;
if (type_is_invalid(expr_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13931,9 +13931,9 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
return ira->codegen->builtin_types.entry_invalid;
}
-static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) {
+static ZigType *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) {
IrInstruction *value = instruction->value->other;
- TypeTableEntry *expr_type = value->value.type;
+ ZigType *expr_type = value->value.type;
if (type_is_invalid(expr_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -13958,7 +13958,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins
return ira->codegen->builtin_types.entry_invalid;
}
-static TypeTableEntry *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
+static ZigType *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
IrUnOp op_id = un_op_instruction->op_id;
switch (op_id) {
case IrUnOpInvalid:
@@ -13976,7 +13976,7 @@ static TypeTableEntry *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructio
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) {
+static ZigType *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) {
IrBasicBlock *old_dest_block = br_instruction->dest_block;
bool is_comptime;
@@ -13994,7 +13994,7 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
}
-static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) {
+static ZigType *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) {
IrInstruction *condition = cond_br_instruction->condition->other;
if (type_is_invalid(condition->value.type))
return ir_unreach_error(ira);
@@ -14022,7 +14022,7 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
}
- TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;
+ ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type);
if (casted_condition == ira->codegen->invalid_instruction)
return ir_unreach_error(ira);
@@ -14041,14 +14041,14 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
}
-static TypeTableEntry *ir_analyze_instruction_unreachable(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_unreachable(IrAnalyze *ira,
IrInstructionUnreachable *unreachable_instruction)
{
ir_build_unreachable_from(&ira->new_irb, &unreachable_instruction->base);
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
}
-static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) {
+static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) {
if (ira->const_predecessor_bb) {
for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) {
IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i];
@@ -14105,7 +14105,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
return first_value->value.type;
}
- TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,
+ ZigType *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,
new_incoming_values.items, new_incoming_values.length);
if (type_is_invalid(resolved_type))
return resolved_type;
@@ -14157,7 +14157,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
return resolved_type;
}
-static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
+static ZigType *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
VariableTableEntry *var)
{
IrInstruction *result = ir_get_var_ptr(ira, instruction, var);
@@ -14165,12 +14165,12 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {
+static ZigType *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {
VariableTableEntry *var = var_ptr_instruction->var;
return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var);
}
-static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, uint32_t new_align) {
+static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align) {
assert(ptr_type->id == TypeTableEntryIdPointer);
return get_pointer_to_type_extra(g,
ptr_type->data.pointer.child_type,
@@ -14180,14 +14180,14 @@ static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, ui
ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);
}
-static TypeTableEntry *adjust_slice_align(CodeGen *g, TypeTableEntry *slice_type, uint32_t new_align) {
+static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align) {
assert(is_slice(slice_type));
- TypeTableEntry *ptr_type = adjust_ptr_align(g, slice_type->data.structure.fields[slice_ptr_index].type_entry,
+ ZigType *ptr_type = adjust_ptr_align(g, slice_type->data.structure.fields[slice_ptr_index].type_entry,
new_align);
return get_slice_type(g, ptr_type);
}
-static TypeTableEntry *adjust_ptr_len(CodeGen *g, TypeTableEntry *ptr_type, PtrLen ptr_len) {
+static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) {
assert(ptr_type->id == TypeTableEntryIdPointer);
return get_pointer_to_type_extra(g,
ptr_type->data.pointer.child_type,
@@ -14197,7 +14197,7 @@ static TypeTableEntry *adjust_ptr_len(CodeGen *g, TypeTableEntry *ptr_type, PtrL
ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);
}
-static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) {
+static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) {
Error err;
IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->other;
if (type_is_invalid(array_ptr->value.type))
@@ -14209,14 +14209,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
if (type_is_invalid(elem_index->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = orig_array_ptr_val->type;
+ ZigType *ptr_type = orig_array_ptr_val->type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = ptr_type->data.pointer.child_type;
+ ZigType *array_type = ptr_type->data.pointer.child_type;
// At first return_type will be the pointer type we want to return, except with an optimistic alignment.
// We will adjust return_type's alignment before returning it.
- TypeTableEntry *return_type;
+ ZigType *return_type;
if (type_is_invalid(array_type)) {
return array_type;
@@ -14240,7 +14240,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
buf_sprintf("index 0 outside array of size 0"));
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *child_type = array_type->data.array.child_type;
+ ZigType *child_type = array_type->data.array.child_type;
if (ptr_type->data.pointer.unaligned_bit_count == 0) {
return_type = get_pointer_to_type_extra(ira->codegen, child_type,
ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
@@ -14306,7 +14306,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize);
if (casted_elem_index == ira->codegen->invalid_instruction)
return ira->codegen->builtin_types.entry_invalid;
@@ -14496,8 +14496,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
}
static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,
- TypeTableEntry *bare_struct_type, Buf *field_name, IrInstruction *source_instr,
- IrInstruction *container_ptr, TypeTableEntry *container_type)
+ ZigType *bare_struct_type, Buf *field_name, IrInstruction *source_instr,
+ IrInstruction *container_ptr, ZigType *container_type)
{
if (!is_slice(bare_struct_type)) {
ScopeDecls *container_scope = get_container_scope(bare_struct_type);
@@ -14536,11 +14536,11 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,
}
static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,
- IrInstruction *source_instr, IrInstruction *container_ptr, TypeTableEntry *container_type)
+ IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type)
{
Error err;
- TypeTableEntry *bare_type = container_ref_type(container_type);
+ ZigType *bare_type = container_ref_type(container_type);
if ((err = ensure_complete_type(ira->codegen, bare_type)))
return ira->codegen->invalid_instruction;
@@ -14568,7 +14568,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
if (type_is_invalid(struct_val->type))
return ira->codegen->invalid_instruction;
ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index];
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, field_val->type,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_val->type,
is_const, is_volatile, PtrLenSingle, align_bytes,
(uint32_t)(ptr_bit_offset + field->packed_bits_offset),
(uint32_t)unaligned_bit_count_for_result_type);
@@ -14625,7 +14625,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
ConstExprValue *payload_val = union_val->data.x_union.payload;
- TypeTableEntry *field_type = field->type_entry;
+ ZigType *field_type = field->type_entry;
if (field_type->id == TypeTableEntryIdVoid) {
assert(payload_val == nullptr);
payload_val = create_const_vals(1);
@@ -14633,7 +14633,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
payload_val->type = field_type;
}
- TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
+ ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
is_const, is_volatile,
PtrLenSingle,
get_abi_alignment(ira->codegen, field_type), 0, 0);
@@ -14680,7 +14680,7 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name,
}
-static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) {
+static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) {
bool pointer_only = false;
resolve_top_level_decl(ira->codegen, tld, pointer_only, source_instruction->source_node);
if (tld->resolution == TldResolutionInvalid)
@@ -14731,7 +14731,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
zig_unreachable();
}
-static ErrorTableEntry *find_err_table_entry(TypeTableEntry *err_set_type, Buf *field_name) {
+static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_name) {
assert(err_set_type->id == TypeTableEntryIdErrorSet);
for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {
ErrorTableEntry *err_table_entry = err_set_type->data.error_set.errors[i];
@@ -14742,13 +14742,13 @@ static ErrorTableEntry *find_err_table_entry(TypeTableEntry *err_set_type, Buf *
return nullptr;
}
-static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) {
+static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) {
Error err;
IrInstruction *container_ptr = field_ptr_instruction->container_ptr->other;
if (type_is_invalid(container_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *container_type = container_ptr->value.type->data.pointer.child_type;
+ ZigType *container_type = container_ptr->value.type->data.pointer.child_type;
assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
Buf *field_name = field_ptr_instruction->field_name_buffer;
@@ -14767,7 +14767,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
} else if (is_container_ref(container_type)) {
assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
if (container_type->id == TypeTableEntryIdPointer) {
- TypeTableEntry *bare_type = container_ref_type(container_type);
+ ZigType *bare_type = container_ref_type(container_type);
IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr);
IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type);
ir_link_new_instruction(result, &field_ptr_instruction->base);
@@ -14786,7 +14786,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
init_const_usize(ira->codegen, len_val, container_type->data.array.len);
}
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
bool ptr_is_const = true;
bool ptr_is_volatile = false;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
@@ -14812,7 +14812,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index;
init_const_usize(ira->codegen, len_val, len);
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
bool ptr_is_const = true;
bool ptr_is_volatile = false;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
@@ -14832,7 +14832,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node);
if (child_val == nullptr)
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *child_type = child_val->data.x_type;
+ ZigType *child_type = child_val->data.x_type;
if (type_is_invalid(child_type)) {
return ira->codegen->builtin_types.entry_invalid;
@@ -14842,7 +14842,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
bool ptr_is_volatile = false;
TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index];
assert(ptr_field->type_entry->id == TypeTableEntryIdPointer);
- TypeTableEntry *child_type = ptr_field->type_entry->data.pointer.child_type;
+ ZigType *child_type = ptr_field->type_entry->data.pointer.child_type;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
create_const_type(ira->codegen, child_type),
ira->codegen->builtin_types.entry_type,
@@ -14877,7 +14877,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
TypeUnionField *field = find_union_type_field(child_type, field_name);
if (field) {
- TypeTableEntry *enum_type = child_type->data.unionation.tag_type;
+ ZigType *enum_type = child_type->data.unionation.tag_type;
bool ptr_is_const = true;
bool ptr_is_volatile = false;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
@@ -14891,7 +14891,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
} else if (child_type->id == TypeTableEntryIdErrorSet) {
ErrorTableEntry *err_entry;
- TypeTableEntry *err_set_type;
+ ZigType *err_set_type;
if (type_is_global_error_set(child_type)) {
auto existing_entry = ira->codegen->error_table.maybe_get(field_name);
if (existing_entry) {
@@ -15131,7 +15131,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
}
}
-static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *load_ptr_instruction) {
+static ZigType *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *load_ptr_instruction) {
IrInstruction *ptr = load_ptr_instruction->ptr->other;
if (type_is_invalid(ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -15142,7 +15142,7 @@ static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstruc
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *store_ptr_instruction) {
+static ZigType *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *store_ptr_instruction) {
IrInstruction *ptr = store_ptr_instruction->ptr->other;
if (type_is_invalid(ptr->value.type))
return ptr->value.type;
@@ -15166,7 +15166,7 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *child_type = ptr->value.type->data.pointer.child_type;
+ ZigType *child_type = ptr->value.type->data.pointer.child_type;
IrInstruction *casted_value = ir_implicit_cast(ira, value, child_type);
if (casted_value == ira->codegen->invalid_instruction)
return ira->codegen->builtin_types.entry_invalid;
@@ -15202,9 +15202,9 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) {
+static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) {
IrInstruction *expr_value = typeof_instruction->value->other;
- TypeTableEntry *type_entry = expr_value->value.type;
+ ZigType *type_entry = expr_value->value.type;
if (type_is_invalid(type_entry))
return ira->codegen->builtin_types.entry_invalid;
switch (type_entry->id) {
@@ -15246,15 +15246,15 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
IrInstructionToPtrType *to_ptr_type_instruction)
{
IrInstruction *value = to_ptr_type_instruction->value->other;
- TypeTableEntry *type_entry = value->value.type;
+ ZigType *type_entry = value->value.type;
if (type_is_invalid(type_entry))
return type_entry;
- TypeTableEntry *ptr_type;
+ ZigType *ptr_type;
if (type_entry->id == TypeTableEntryIdArray) {
ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, false);
} else if (is_slice(type_entry)) {
@@ -15275,11 +15275,11 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
IrInstructionPtrTypeChild *ptr_type_child_instruction)
{
IrInstruction *type_value = ptr_type_child_instruction->value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if (type_is_invalid(type_entry))
return type_entry;
@@ -15294,7 +15294,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) {
+static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) {
if (ira->new_irb.exec->is_inline) {
// ignore setCold when running functions at compile time
ir_build_const_from(ira, &instruction->base);
@@ -15324,7 +15324,7 @@ static TypeTableEntry *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstruc
ir_build_const_from(ira, &instruction->base);
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
IrInstructionSetRuntimeSafety *set_runtime_safety_instruction)
{
if (ira->new_irb.exec->is_inline) {
@@ -15381,11 +15381,11 @@ static TypeTableEntry *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
IrInstructionSetFloatMode *instruction)
{
IrInstruction *target_instruction = instruction->scope_value->other;
- TypeTableEntry *target_type = target_instruction->value.type;
+ ZigType *target_type = target_instruction->value.type;
if (type_is_invalid(target_type))
return ira->codegen->builtin_types.entry_invalid;
ConstExprValue *target_val = ir_resolve_const(ira, target_instruction, UndefBad);
@@ -15412,7 +15412,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node;
} else if (target_type->id == TypeTableEntryIdMetaType) {
ScopeDecls *decls_scope;
- TypeTableEntry *type_arg = target_val->data.x_type;
+ ZigType *type_arg = target_val->data.x_type;
if (type_arg->id == TypeTableEntryIdStruct) {
decls_scope = type_arg->data.structure.decls_scope;
} else if (type_arg->id == TypeTableEntryIdEnum) {
@@ -15452,7 +15452,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira,
IrInstructionSliceType *slice_type_instruction)
{
Error err;
@@ -15462,7 +15462,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->other);
+ ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->other);
if (type_is_invalid(child_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -15509,9 +15509,9 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
{
if ((err = type_ensure_zero_bits_known(ira->codegen, child_type)))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
+ ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
is_const, is_volatile, PtrLenUnknown, align_bytes, 0, 0);
- TypeTableEntry *result_type = get_slice_type(ira->codegen, slice_ptr_type);
+ ZigType *result_type = get_slice_type(ira->codegen, slice_ptr_type);
ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base);
out_val->data.x_type = result_type;
return ira->codegen->builtin_types.entry_type;
@@ -15520,7 +15520,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsm *asm_instruction) {
+static ZigType *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsm *asm_instruction) {
assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr);
AstNodeAsmExpr *asm_expr = &asm_instruction->base.source_node->data.asm_expr;
@@ -15550,7 +15550,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA
IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length);
IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length);
- TypeTableEntry *return_type = ira->codegen->builtin_types.entry_void;
+ ZigType *return_type = ira->codegen->builtin_types.entry_void;
for (size_t i = 0; i < asm_expr->output_list.length; i += 1) {
AsmOutput *asm_output = asm_expr->output_list.at(i);
if (asm_output->return_type) {
@@ -15572,7 +15572,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA
return return_type;
}
-static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira,
IrInstructionArrayType *array_type_instruction)
{
Error err;
@@ -15583,7 +15583,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_invalid;
IrInstruction *child_type_value = array_type_instruction->child_type->other;
- TypeTableEntry *child_type = ir_resolve_type(ira, child_type_value);
+ ZigType *child_type = ir_resolve_type(ira, child_type_value);
if (type_is_invalid(child_type))
return ira->codegen->builtin_types.entry_invalid;
switch (child_type->id) {
@@ -15620,7 +15620,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
{
if ((err = ensure_complete_type(ira->codegen, child_type)))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *result_type = get_array_type(ira->codegen, child_type, size);
+ ZigType *result_type = get_array_type(ira->codegen, child_type, size);
ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base);
out_val->data.x_type = result_type;
return ira->codegen->builtin_types.entry_type;
@@ -15629,13 +15629,13 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInstructionPromiseType *instruction) {
- TypeTableEntry *promise_type;
+static ZigType *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInstructionPromiseType *instruction) {
+ ZigType *promise_type;
if (instruction->payload_type == nullptr) {
promise_type = ira->codegen->builtin_types.entry_promise;
} else {
- TypeTableEntry *payload_type = ir_resolve_type(ira, instruction->payload_type->other);
+ ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->other);
if (type_is_invalid(payload_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -15647,12 +15647,12 @@ static TypeTableEntry *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrIns
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira,
IrInstructionSizeOf *size_of_instruction)
{
Error err;
IrInstruction *type_value = size_of_instruction->type_value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if ((err = ensure_complete_type(ira->codegen, type_entry)))
return ira->codegen->builtin_types.entry_invalid;
@@ -15698,12 +15698,12 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) {
+static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *type_entry = value->value.type;
+ ZigType *type_entry = value->value.type;
if (type_entry->id == TypeTableEntryIdOptional) {
if (instr_is_comptime(value)) {
@@ -15729,17 +15729,17 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
}
}
-static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
IrInstructionUnwrapOptional *unwrap_maybe_instruction)
{
IrInstruction *value = unwrap_maybe_instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = value->value.type;
+ ZigType *ptr_type = value->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;
+ ZigType *type_entry = ptr_type->data.pointer.child_type;
if (type_is_invalid(type_entry)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (type_entry->id != TypeTableEntryIdOptional) {
@@ -15747,8 +15747,8 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name)));
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *child_type = type_entry->data.maybe.child_type;
- TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, child_type,
+ ZigType *child_type = type_entry->data.maybe.child_type;
+ ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type,
ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
PtrLenSingle,
get_abi_alignment(ira->codegen, child_type), 0, 0);
@@ -15783,12 +15783,12 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
return result_type;
}
-static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz_instruction) {
+static ZigType *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz_instruction) {
IrInstruction *value = ctz_instruction->value->other;
if (type_is_invalid(value->value.type)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (value->value.type->id == TypeTableEntryIdInt) {
- TypeTableEntry *return_type = get_smallest_unsigned_int_type(ira->codegen,
+ ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen,
value->value.type->data.integral.bit_count);
if (value->value.special != ConstValSpecialRuntime) {
size_t result = bigint_ctz(&value->value.data.x_bigint,
@@ -15807,12 +15807,12 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC
}
}
-static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz_instruction) {
+static ZigType *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz_instruction) {
IrInstruction *value = clz_instruction->value->other;
if (type_is_invalid(value->value.type)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (value->value.type->id == TypeTableEntryIdInt) {
- TypeTableEntry *return_type = get_smallest_unsigned_int_type(ira->codegen,
+ ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen,
value->value.type->data.integral.bit_count);
if (value->value.special != ConstValSpecialRuntime) {
size_t result = bigint_clz(&value->value.data.x_bigint,
@@ -15831,7 +15831,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC
}
}
-static TypeTableEntry *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) {
+static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -15895,7 +15895,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
return ira->codegen->invalid_instruction;
}
- TypeTableEntry *tag_type = value->value.type->data.unionation.tag_type;
+ ZigType *tag_type = value->value.type->data.unionation.tag_type;
assert(tag_type->id == TypeTableEntryIdEnum);
if (instr_is_comptime(value)) {
@@ -15916,7 +15916,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
return result;
}
-static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira,
IrInstructionSwitchBr *switch_br_instruction)
{
IrInstruction *target_value = switch_br_instruction->target_value->other;
@@ -16024,7 +16024,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira,
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
}
-static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira,
IrInstructionSwitchTarget *switch_target_instruction)
{
Error err;
@@ -16034,7 +16034,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
if (target_value_ptr->value.type->id == TypeTableEntryIdMetaType) {
assert(instr_is_comptime(target_value_ptr));
- TypeTableEntry *ptr_type = target_value_ptr->value.data.x_type;
+ ZigType *ptr_type = target_value_ptr->value.data.x_type;
assert(ptr_type->id == TypeTableEntryIdPointer);
ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base);
out_val->type = ira->codegen->builtin_types.entry_type;
@@ -16047,7 +16047,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type;
+ ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
ConstExprValue *pointee_val = nullptr;
if (instr_is_comptime(target_value_ptr)) {
pointee_val = ir_const_ptr_pointee(ira, &target_value_ptr->value, target_value_ptr->source_node);
@@ -16095,7 +16095,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
buf_sprintf("consider 'union(enum)' here"));
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *tag_type = target_type->data.unionation.tag_type;
+ ZigType *tag_type = target_type->data.unionation.tag_type;
assert(tag_type != nullptr);
assert(tag_type->id == TypeTableEntryIdEnum);
if (pointee_val) {
@@ -16160,7 +16160,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) {
+static ZigType *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) {
IrInstruction *target_value_ptr = instruction->target_value_ptr->other;
if (type_is_invalid(target_value_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16170,7 +16170,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr
return ira->codegen->builtin_types.entry_invalid;
assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type;
+ ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
if (target_type->id == TypeTableEntryIdUnion) {
ConstExprValue *prong_val = ir_resolve_const(ira, prong_value, UndefBad);
if (!prong_val)
@@ -16205,14 +16205,14 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr
}
}
-static TypeTableEntry *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) {
+static ZigType *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) {
IrInstruction *value = instruction->value->other;
IrInstruction *new_instruction = ir_analyze_union_tag(ira, &instruction->base, value);
ir_link_new_instruction(new_instruction, &instruction->base);
return new_instruction->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) {
+static ZigType *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) {
IrInstruction *name_value = import_instruction->name->other;
Buf *import_target_str = ir_resolve_str(ira, name_value);
if (!import_target_str)
@@ -16278,11 +16278,11 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
}
-static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_array_len(IrAnalyze *ira,
IrInstructionArrayLen *array_len_instruction)
{
IrInstruction *array_value = array_len_instruction->array_value->other;
- TypeTableEntry *type_entry = array_value->value.type;
+ ZigType *type_entry = array_value->value.type;
if (type_is_invalid(type_entry)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (type_entry->id == TypeTableEntryIdArray) {
@@ -16309,13 +16309,13 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,
}
}
-static TypeTableEntry *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) {
+static ZigType *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) {
IrInstruction *value = ref_instruction->value->other;
return ir_analyze_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile);
}
-static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,
- TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
+static ZigType *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,
+ ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
{
Error err;
assert(container_type->id == TypeTableEntryIdUnion);
@@ -16380,8 +16380,8 @@ static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, Ir
return container_type;
}
-static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,
- TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
+static ZigType *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,
+ ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
{
Error err;
if (container_type->id == TypeTableEntryIdUnion) {
@@ -16500,7 +16500,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
return container_type;
}
-static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
IrInstructionContainerInitList *instruction)
{
IrInstruction *container_type_value = instruction->container_type->other;
@@ -16509,7 +16509,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
size_t elem_count = instruction->item_count;
if (container_type_value->value.type->id == TypeTableEntryIdMetaType) {
- TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);
+ ZigType *container_type = ir_resolve_type(ira, container_type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16518,11 +16518,11 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
0, nullptr);
} else if (is_slice(container_type) || container_type->id == TypeTableEntryIdArray) {
// array is same as slice init but we make a compile error if the length is wrong
- TypeTableEntry *child_type;
+ ZigType *child_type;
if (container_type->id == TypeTableEntryIdArray) {
child_type = container_type->data.array.child_type;
if (container_type->data.array.len != elem_count) {
- TypeTableEntry *literal_type = get_array_type(ira->codegen, child_type, elem_count);
+ ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count);
ir_add_error(ira, &instruction->base,
buf_sprintf("expected %s literal, found %s literal",
@@ -16530,12 +16530,12 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
return ira->codegen->builtin_types.entry_invalid;
}
} else {
- TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry;
assert(pointer_type->id == TypeTableEntryIdPointer);
child_type = pointer_type->data.pointer.child_type;
}
- TypeTableEntry *fixed_size_array_type = get_array_type(ira->codegen, child_type, elem_count);
+ ZigType *fixed_size_array_type = get_array_type(ira->codegen, child_type, elem_count);
ConstExprValue const_val = {};
const_val.special = ConstValSpecialStatic;
@@ -16618,9 +16618,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
}
}
-static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
+static ZigType *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
IrInstruction *container_type_value = instruction->container_type->other;
- TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);
+ ZigType *container_type = ir_resolve_type(ira, container_type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16628,10 +16628,10 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i
instruction->field_count, instruction->fields);
}
-static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction,
+static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction,
IrInstruction *target_type_value, bool is_max)
{
- TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value);
+ ZigType *target_type = ir_resolve_type(ira, target_type_value);
if (type_is_invalid(target_type))
return ira->codegen->builtin_types.entry_invalid;
switch (target_type->id) {
@@ -16684,19 +16684,19 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_min_value(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_min_value(IrAnalyze *ira,
IrInstructionMinValue *instruction)
{
return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, false);
}
-static TypeTableEntry *ir_analyze_instruction_max_value(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_max_value(IrAnalyze *ira,
IrInstructionMaxValue *instruction)
{
return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, true);
}
-static TypeTableEntry *ir_analyze_instruction_compile_err(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_compile_err(IrAnalyze *ira,
IrInstructionCompileErr *instruction)
{
IrInstruction *msg_value = instruction->msg->other;
@@ -16720,7 +16720,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_err(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_invalid;
}
-static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) {
+static ZigType *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) {
Buf buf = BUF_INIT;
fprintf(stderr, "| ");
for (size_t i = 0; i < instruction->msg_count; i += 1) {
@@ -16740,7 +16740,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) {
+static ZigType *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16749,9 +16749,9 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc
if (type_is_invalid(casted_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type);
+ ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
if (casted_value->value.special == ConstValSpecialStatic) {
ErrorTableEntry *err = casted_value->value.data.x_err_set;
if (!err->cached_error_name_val) {
@@ -16768,7 +16768,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc
return str_type;
}
-static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) {
+static ZigType *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) {
Error err;
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
@@ -16789,7 +16789,7 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn
IrInstruction *result = ir_build_tag_name(&ira->new_irb, instruction->base.scope,
instruction->base.source_node, target);
ir_link_new_instruction(result, &instruction->base);
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(
ira->codegen, ira->codegen->builtin_types.entry_u8,
true, false, PtrLenUnknown,
get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),
@@ -16798,12 +16798,12 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
IrInstructionFieldParentPtr *instruction)
{
Error err;
IrInstruction *type_value = instruction->type_value->other;
- TypeTableEntry *container_type = ir_resolve_type(ira, type_value);
+ ZigType *container_type = ir_resolve_type(ira, type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16843,7 +16843,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
uint32_t field_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, field->type_entry);
uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type);
- TypeTableEntry *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,
+ ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,
field_ptr->value.type->data.pointer.is_const,
field_ptr->value.type->data.pointer.is_volatile,
PtrLenSingle,
@@ -16852,7 +16852,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
if (type_is_invalid(casted_field_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, container_type,
+ ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type,
casted_field_ptr->value.type->data.pointer.is_const,
casted_field_ptr->value.type->data.pointer.is_volatile,
PtrLenSingle,
@@ -16891,12 +16891,12 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
return result_type;
}
-static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_offset_of(IrAnalyze *ira,
IrInstructionOffsetOf *instruction)
{
Error err;
IrInstruction *type_value = instruction->type_value->other;
- TypeTableEntry *container_type = ir_resolve_type(ira, type_value);
+ ZigType *container_type = ir_resolve_type(ira, type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -16934,7 +16934,7 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
return ira->codegen->builtin_types.entry_num_lit_int;
}
-static void ensure_field_index(TypeTableEntry *type, const char *field_name, size_t index)
+static void ensure_field_index(ZigType *type, const char *field_name, size_t index)
{
Buf *field_name_buf;
@@ -16945,10 +16945,10 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz
(buf_deinit(field_name_buf), true));
}
-static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, TypeTableEntry *root) {
+static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) {
Error err;
static ConstExprValue *type_info_var = nullptr;
- static TypeTableEntry *type_info_type = nullptr;
+ static ZigType *type_info_type = nullptr;
if (type_info_var == nullptr) {
type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
assert(type_info_var->type->id == TypeTableEntryIdMetaType);
@@ -16963,7 +16963,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
else if (type_name == nullptr)
return root;
- TypeTableEntry *root_type = (root == nullptr) ? type_info_type : root;
+ ZigType *root_type = (root == nullptr) ? type_info_type : root;
ScopeDecls *type_info_scope = get_container_scope(root_type);
assert(type_info_scope != nullptr);
@@ -16986,7 +16986,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope) {
Error err;
- TypeTableEntry *type_info_definition_type = ir_type_info_get_type(ira, "Definition", nullptr);
+ ZigType *type_info_definition_type = ir_type_info_get_type(ira, "Definition", nullptr);
if ((err = ensure_complete_type(ira->codegen, type_info_definition_type)))
return err;
@@ -16994,15 +16994,15 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
ensure_field_index(type_info_definition_type, "is_pub", 1);
ensure_field_index(type_info_definition_type, "data", 2);
- TypeTableEntry *type_info_definition_data_type = ir_type_info_get_type(ira, "Data", type_info_definition_type);
+ ZigType *type_info_definition_data_type = ir_type_info_get_type(ira, "Data", type_info_definition_type);
if ((err = ensure_complete_type(ira->codegen, type_info_definition_data_type)))
return err;
- TypeTableEntry *type_info_fn_def_type = ir_type_info_get_type(ira, "FnDef", type_info_definition_data_type);
+ ZigType *type_info_fn_def_type = ir_type_info_get_type(ira, "FnDef", type_info_definition_data_type);
if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_type)))
return err;
- TypeTableEntry *type_info_fn_def_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_def_type);
+ ZigType *type_info_fn_def_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_def_type);
if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_inline_type)))
return err;
@@ -17153,7 +17153,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
// lib_name: ?[]const u8
ensure_field_index(fn_def_val->type, "lib_name", 6);
fn_def_fields[6].special = ConstValSpecialStatic;
- TypeTableEntry *u8_ptr = get_pointer_to_type_extra(
+ ZigType *u8_ptr = get_pointer_to_type_extra(
ira->codegen, ira->codegen->builtin_types.entry_u8,
true, false, PtrLenUnknown,
get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),
@@ -17205,7 +17205,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
}
case TldIdContainer:
{
- TypeTableEntry *type_entry = ((TldContainer *)curr_entry->value)->type_entry;
+ ZigType *type_entry = ((TldContainer *)curr_entry->value)->type_entry;
if ((err = ensure_complete_type(ira->codegen, type_entry)))
return ErrorSemanticAnalyzeFail;
@@ -17232,8 +17232,8 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
return ErrorNone;
}
-static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry *ptr_type_entry) {
- TypeTableEntry *attrs_type;
+static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {
+ ZigType *attrs_type;
uint32_t size_enum_index;
if (is_slice(ptr_type_entry)) {
attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;
@@ -17245,7 +17245,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
zig_unreachable();
}
- TypeTableEntry *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
+ ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_type));
ConstExprValue *result = create_const_vals(1);
@@ -17257,7 +17257,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
// size: Size
ensure_field_index(result->type, "size", 0);
- TypeTableEntry *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
+ ZigType *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_size_type));
fields[0].special = ConstValSpecialStatic;
fields[0].type = type_info_pointer_size_type;
@@ -17288,7 +17288,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
};
static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field,
- TypeTableEntry *type_info_enum_field_type)
+ ZigType *type_info_enum_field_type)
{
enum_field_val->special = ConstValSpecialStatic;
enum_field_val->type = type_info_enum_field_type;
@@ -17305,7 +17305,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val,
enum_field_val->data.x_struct.fields = inner_fields;
}
-static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry, ConstExprValue **out) {
+static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstExprValue **out) {
Error err;
assert(type_entry != nullptr);
assert(!type_is_invalid(type_entry));
@@ -17478,7 +17478,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
// fields: []TypeInfo.EnumField
ensure_field_index(result->type, "fields", 2);
- TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
+ ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;
ConstExprValue *enum_field_array = create_const_vals(1);
@@ -17518,7 +17518,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
// errors: []TypeInfo.Error
ensure_field_index(result->type, "errors", 0);
- TypeTableEntry *type_info_error_type = ir_type_info_get_type(ira, "Error", nullptr);
+ ZigType *type_info_error_type = ir_type_info_get_type(ira, "Error", nullptr);
uint32_t error_count = type_entry->data.error_set.err_count;
ConstExprValue *error_array = create_const_vals(1);
error_array->special = ConstValSpecialStatic;
@@ -17612,7 +17612,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
// fields: []TypeInfo.UnionField
ensure_field_index(result->type, "fields", 2);
- TypeTableEntry *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);
+ ZigType *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);
uint32_t union_field_count = type_entry->data.unionation.src_field_count;
ConstExprValue *union_field_array = create_const_vals(1);
@@ -17624,7 +17624,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);
- TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
+ ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {
TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index];
@@ -17685,7 +17685,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
// fields: []TypeInfo.StructField
ensure_field_index(result->type, "fields", 1);
- TypeTableEntry *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);
+ ZigType *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);
uint32_t struct_field_count = type_entry->data.structure.src_field_count;
ConstExprValue *struct_field_array = create_const_vals(1);
@@ -17790,7 +17790,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
fields[4].data.x_optional = async_alloc_type;
}
// args: []TypeInfo.FnArg
- TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
+ ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -
(is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);
@@ -17844,7 +17844,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
}
case TypeTableEntryIdBoundFn:
{
- TypeTableEntry *fn_type = type_entry->data.bound_fn.fn_type;
+ ZigType *fn_type = type_entry->data.bound_fn.fn_type;
assert(fn_type->id == TypeTableEntryIdFn);
if ((err = ir_make_type_info_value(ira, fn_type, &result)))
return err;
@@ -17859,16 +17859,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
return ErrorNone;
}
-static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_type_info(IrAnalyze *ira,
IrInstructionTypeInfo *instruction)
{
Error err;
IrInstruction *type_value = instruction->type_value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if (type_is_invalid(type_entry))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr, nullptr);
+ ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr);
ConstExprValue *payload;
if ((err = ir_make_type_info_value(ira, type_entry, &payload)))
@@ -17888,24 +17888,24 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
return result_type;
}
-static TypeTableEntry *ir_analyze_instruction_type_id(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_type_id(IrAnalyze *ira,
IrInstructionTypeId *instruction)
{
IrInstruction *type_value = instruction->type_value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if (type_is_invalid(type_entry))
return ira->codegen->builtin_types.entry_invalid;
ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId");
assert(var_value->type->id == TypeTableEntryIdMetaType);
- TypeTableEntry *result_type = var_value->data.x_type;
+ ZigType *result_type = var_value->data.x_type;
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
bigint_init_unsigned(&out_val->data.x_enum_tag, type_id_index(type_entry));
return result_type;
}
-static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
IrInstructionSetEvalBranchQuota *instruction)
{
if (ira->new_irb.exec->parent_exec != nullptr && !ira->new_irb.exec->is_generic_instantiation) {
@@ -17926,9 +17926,9 @@ static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *i
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
+static ZigType *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
IrInstruction *type_value = instruction->type_value->other;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if (type_is_invalid(type_entry))
return ira->codegen->builtin_types.entry_invalid;
@@ -17940,7 +17940,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru
return out_val->type;
}
-static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) {
+static ZigType *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) {
AstNode *node = instruction->base.source_node;
assert(node->type == NodeTypeFnCallExpr);
AstNode *block_node = node->data.fn_call_expr.params.at(0);
@@ -17948,7 +17948,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
ScopeCImport *cimport_scope = create_cimport_scope(node, instruction->base.scope);
// Execute the C import block like an inline function
- TypeTableEntry *void_type = ira->codegen->builtin_types.entry_void;
+ ZigType *void_type = ira->codegen->builtin_types.entry_void;
IrInstruction *result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type,
ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,
&cimport_scope->buf, block_node, nullptr, nullptr);
@@ -17999,7 +17999,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_namespace;
}
-static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) {
+static ZigType *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) {
IrInstruction *name_value = instruction->name->other;
if (type_is_invalid(name_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18018,7 +18018,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) {
+static ZigType *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) {
IrInstruction *name = instruction->name->other;
if (type_is_invalid(name->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18045,7 +18045,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) {
+static ZigType *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) {
IrInstruction *name = instruction->name->other;
if (type_is_invalid(name->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18064,7 +18064,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) {
+static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) {
IrInstruction *name = instruction->name->other;
if (type_is_invalid(name->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18106,8 +18106,8 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(file_contents));
}
-static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) {
- TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->other);
+static ZigType *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) {
+ ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->other);
if (type_is_invalid(operand_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18116,7 +18116,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct
return ira->codegen->builtin_types.entry_invalid;
// TODO let this be volatile
- TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
+ ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);
if (type_is_invalid(casted_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18187,7 +18187,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) {
+static ZigType *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) {
IrInstruction *order_value = instruction->order_value->other;
if (type_is_invalid(order_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18200,9 +18200,9 @@ static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructio
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
+static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
IrInstruction *dest_type_value = instruction->dest_type->other;
- TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);
+ ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18214,7 +18214,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
}
IrInstruction *target = instruction->target->other;
- TypeTableEntry *src_type = target->value.type;
+ ZigType *src_type = target->value.type;
if (type_is_invalid(src_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18248,8 +18248,8 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
+static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {
+ ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18289,8 +18289,8 @@ static TypeTableEntry *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruc
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
+static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {
+ ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18337,8 +18337,8 @@ static TypeTableEntry *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstr
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
+static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {
+ ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18365,8 +18365,8 @@ static TypeTableEntry *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrIns
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
- TypeTableEntry *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->other);
+static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
+ ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->other);
if (type_is_invalid(dest_child_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18382,7 +18382,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
src_ptr_volatile = target->value.type->data.pointer.is_volatile;
src_ptr_align = target->value.type->data.pointer.alignment;
} else if (is_slice(target->value.type)) {
- TypeTableEntry *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
src_ptr_const = src_ptr_type->data.pointer.is_const;
src_ptr_volatile = src_ptr_type->data.pointer.is_volatile;
src_ptr_align = src_ptr_type->data.pointer.alignment;
@@ -18392,15 +18392,15 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);
}
- TypeTableEntry *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
+ ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
src_ptr_const, src_ptr_volatile, PtrLenUnknown,
src_ptr_align, 0, 0);
- TypeTableEntry *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
+ ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
- TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
src_ptr_const, src_ptr_volatile, PtrLenUnknown,
src_ptr_align, 0, 0);
- TypeTableEntry *u8_slice = get_slice_type(ira->codegen, u8_ptr);
+ ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice);
if (type_is_invalid(casted_value->value.type))
@@ -18445,7 +18445,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
return dest_slice_type;
}
-static TypeTableEntry *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) {
+static ZigType *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) {
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18456,20 +18456,20 @@ static TypeTableEntry *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
- TypeTableEntry *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown,
src_ptr_type->data.pointer.alignment, 0, 0);
- TypeTableEntry *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
+ ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_slice_type, CastOpResizeSlice, true);
ir_link_new_instruction(result, &instruction->base);
return dest_slice_type;
}
-static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
+static ZigType *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {
+ ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18488,8 +18488,8 @@ static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrIns
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {
- TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
+static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {
+ ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18516,7 +18516,7 @@ static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrIns
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) {
+static ZigType *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) {
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18535,7 +18535,7 @@ static TypeTableEntry *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) {
+static ZigType *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) {
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18549,7 +18549,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) {
+static ZigType *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) {
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18570,13 +18570,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInst
return ira->codegen->builtin_types.entry_num_lit_int;
}
- TypeTableEntry *u1_type = get_int_type(ira->codegen, false, 1);
+ ZigType *u1_type = get_int_type(ira->codegen, false, 1);
IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt, false);
ir_link_new_instruction(result, &instruction->base);
return u1_type;
}
-static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) {
+static ZigType *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) {
IrInstruction *is_signed_value = instruction->is_signed->other;
bool is_signed;
if (!ir_resolve_bool(ira, is_signed_value, &is_signed))
@@ -18592,12 +18592,12 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) {
+static ZigType *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;
+ ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type);
if (type_is_invalid(casted_value->value.type))
@@ -18617,7 +18617,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc
return bool_type;
}
-static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) {
+static ZigType *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) {
IrInstruction *dest_ptr = instruction->dest_ptr->other;
if (type_is_invalid(dest_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18630,15 +18630,15 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
if (type_is_invalid(count_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *dest_uncasted_type = dest_ptr->value.type;
+ ZigType *dest_uncasted_type = dest_ptr->value.type;
bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
dest_uncasted_type->data.pointer.is_volatile;
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
- TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *u8 = ira->codegen->builtin_types.entry_u8;
uint32_t dest_align = (dest_uncasted_type->id == TypeTableEntryIdPointer) ?
dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);
- TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
+ ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
PtrLenUnknown, dest_align, 0, 0);
IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);
@@ -18709,7 +18709,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) {
+static ZigType *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) {
IrInstruction *dest_ptr = instruction->dest_ptr->other;
if (type_is_invalid(dest_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18722,9 +18722,9 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
if (type_is_invalid(count_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
- TypeTableEntry *dest_uncasted_type = dest_ptr->value.type;
- TypeTableEntry *src_uncasted_type = src_ptr->value.type;
+ ZigType *u8 = ira->codegen->builtin_types.entry_u8;
+ ZigType *dest_uncasted_type = dest_ptr->value.type;
+ ZigType *src_uncasted_type = src_ptr->value.type;
bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
dest_uncasted_type->data.pointer.is_volatile;
bool src_is_volatile = (src_uncasted_type->id == TypeTableEntryIdPointer) &&
@@ -18734,10 +18734,10 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
uint32_t src_align = (src_uncasted_type->id == TypeTableEntryIdPointer) ?
src_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
- TypeTableEntry *u8_ptr_mut = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *u8_ptr_mut = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
PtrLenUnknown, dest_align, 0, 0);
- TypeTableEntry *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,
+ ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,
PtrLenUnknown, src_align, 0, 0);
IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);
@@ -18844,20 +18844,20 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice *instruction) {
+static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice *instruction) {
IrInstruction *ptr_ptr = instruction->ptr->other;
if (type_is_invalid(ptr_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = ptr_ptr->value.type;
+ ZigType *ptr_type = ptr_ptr->value.type;
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *array_type = ptr_type->data.pointer.child_type;
+ ZigType *array_type = ptr_type->data.pointer.child_type;
IrInstruction *start = instruction->start->other;
if (type_is_invalid(start->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
IrInstruction *casted_start = ir_implicit_cast(ira, start, usize);
if (type_is_invalid(casted_start->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -18874,7 +18874,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
end = nullptr;
}
- TypeTableEntry *return_type;
+ ZigType *return_type;
if (array_type->id == TypeTableEntryIdArray) {
uint32_t byte_alignment = ptr_type->data.pointer.alignment;
@@ -18883,7 +18883,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
}
bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic &&
ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst;
- TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,
+ ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,
ptr_type->data.pointer.is_const || is_comptime_const,
ptr_type->data.pointer.is_volatile,
PtrLenUnknown,
@@ -18891,9 +18891,9 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
return_type = get_slice_type(ira->codegen, slice_ptr_type);
} else if (array_type->id == TypeTableEntryIdPointer) {
if (array_type->data.pointer.ptr_len == PtrLenSingle) {
- TypeTableEntry *main_type = array_type->data.pointer.child_type;
+ ZigType *main_type = array_type->data.pointer.child_type;
if (main_type->id == TypeTableEntryIdArray) {
- TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen,
+ ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen,
main_type->data.pointer.child_type,
array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,
PtrLenUnknown,
@@ -18904,7 +18904,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
return ira->codegen->builtin_types.entry_invalid;
}
} else {
- TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type,
+ ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type,
array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,
PtrLenUnknown,
array_type->data.pointer.alignment, 0, 0);
@@ -18915,7 +18915,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
}
}
} else if (is_slice(array_type)) {
- TypeTableEntry *ptr_type = array_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *ptr_type = array_type->data.structure.fields[slice_ptr_index].type_entry;
return_type = get_slice_type(ira->codegen, ptr_type);
} else {
ir_add_error(ira, &instruction->base,
@@ -18936,7 +18936,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
(array_type->id == TypeTableEntryIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))
{
if (array_type->id == TypeTableEntryIdPointer) {
- TypeTableEntry *child_array_type = array_type->data.pointer.child_type;
+ ZigType *child_array_type = array_type->data.pointer.child_type;
assert(child_array_type->id == TypeTableEntryIdArray);
parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node);
if (parent_ptr == nullptr)
@@ -19109,12 +19109,12 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
return return_type;
}
-static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) {
+static ZigType *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) {
Error err;
IrInstruction *container = instruction->container->other;
if (type_is_invalid(container->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *container_type = ir_resolve_type(ira, container);
+ ZigType *container_type = ir_resolve_type(ira, container);
if ((err = ensure_complete_type(ira->codegen, container_type)))
return ira->codegen->builtin_types.entry_invalid;
@@ -19147,10 +19147,10 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns
return ira->codegen->builtin_types.entry_num_lit_int;
}
-static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
+static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
Error err;
IrInstruction *container_type_value = instruction->container_type->other;
- TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);
+ ZigType *container_type = ir_resolve_type(ira, container_type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19194,10 +19194,10 @@ static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInst
}
}
-static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
+static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
Error err;
IrInstruction *container_type_value = instruction->container_type->other;
- TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);
+ ZigType *container_type = ir_resolve_type(ira, container_type_value);
if (type_is_invalid(container_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19252,28 +19252,28 @@ static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInst
}
}
-static TypeTableEntry *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) {
+static ZigType *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) {
ir_build_breakpoint_from(&ira->new_irb, &instruction->base);
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) {
+static ZigType *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) {
ir_build_return_address_from(&ira->new_irb, &instruction->base);
- TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
- TypeTableEntry *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
+ ZigType *u8 = ira->codegen->builtin_types.entry_u8;
+ ZigType *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
return u8_ptr_const;
}
-static TypeTableEntry *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) {
+static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) {
ir_build_frame_address_from(&ira->new_irb, &instruction->base);
- TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
- TypeTableEntry *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
+ ZigType *u8 = ira->codegen->builtin_types.entry_u8;
+ ZigType *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
return u8_ptr_const;
}
-static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {
+static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {
ir_build_handle_from(&ira->new_irb, &instruction->base);
FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
@@ -19281,12 +19281,12 @@ static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructi
return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type);
}
-static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {
+static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {
Error err;
IrInstruction *type_value = instruction->type_value->other;
if (type_is_invalid(type_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);
+ ZigType *type_entry = ir_resolve_type(ira, type_value);
if ((err = type_ensure_zero_bits_known(ira->codegen, type_entry)))
return ira->codegen->builtin_types.entry_invalid;
@@ -19332,12 +19332,12 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) {
+static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) {
IrInstruction *type_value = instruction->type_value->other;
if (type_is_invalid(type_value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *dest_type = ir_resolve_type(ira, type_value);
+ ZigType *dest_type = ir_resolve_type(ira, type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19361,7 +19361,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
IrInstruction *casted_op2;
if (instruction->op == IrOverflowOpShl) {
- TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
+ ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
dest_type->data.integral.bit_count - 1);
casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);
} else {
@@ -19374,7 +19374,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
if (type_is_invalid(result_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *expected_ptr_type;
+ ZigType *expected_ptr_type;
if (result_ptr->value.type->id == TypeTableEntryIdPointer) {
expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type,
false, result_ptr->value.type->data.pointer.is_volatile,
@@ -19431,12 +19431,12 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
return ira->codegen->builtin_types.entry_bool;
}
-static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErr *instruction) {
+static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErr *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *type_entry = value->value.type;
+ ZigType *type_entry = value->value.type;
if (type_is_invalid(type_entry)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (type_entry->id == TypeTableEntryIdErrorUnion) {
@@ -19452,7 +19452,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
}
}
- TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;
+ ZigType *err_set_type = type_entry->data.error_union.err_set_type;
if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {
return ira->codegen->builtin_types.entry_invalid;
}
@@ -19478,18 +19478,18 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
}
}
-static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
IrInstructionUnwrapErrCode *instruction)
{
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = value->value.type;
+ ZigType *ptr_type = value->value.type;
// This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;
+ ZigType *type_entry = ptr_type->data.pointer.child_type;
if (type_is_invalid(type_entry)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (type_entry->id == TypeTableEntryIdErrorUnion) {
@@ -19519,27 +19519,27 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
}
}
-static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
IrInstructionUnwrapErrPayload *instruction)
{
assert(instruction->value->other);
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = value->value.type;
+ ZigType *ptr_type = value->value.type;
// This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
assert(ptr_type->id == TypeTableEntryIdPointer);
- TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;
+ ZigType *type_entry = ptr_type->data.pointer.child_type;
if (type_is_invalid(type_entry)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (type_entry->id == TypeTableEntryIdErrorUnion) {
- TypeTableEntry *payload_type = type_entry->data.error_union.payload_type;
+ ZigType *payload_type = type_entry->data.error_union.payload_type;
if (type_is_invalid(payload_type)) {
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, payload_type,
+ ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type,
ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
PtrLenSingle,
get_abi_alignment(ira->codegen, payload_type), 0, 0);
@@ -19575,7 +19575,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
}
-static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) {
+static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) {
AstNode *proto_node = instruction->base.source_node;
assert(proto_node->type == NodeTypeFnProto);
@@ -19656,7 +19656,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) {
+static ZigType *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) {
IrInstruction *value = instruction->value->other;
if (type_is_invalid(value->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19666,11 +19666,11 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn
return ira->codegen->builtin_types.entry_bool;
}
-static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
IrInstructionCheckSwitchProngs *instruction)
{
IrInstruction *target_value = instruction->target_value->other;
- TypeTableEntry *switch_type = target_value->value.type;
+ ZigType *switch_type = target_value->value.type;
if (type_is_invalid(switch_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19846,11 +19846,11 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,
IrInstructionCheckStatementIsVoid *instruction)
{
IrInstruction *statement_value = instruction->statement_value->other;
- TypeTableEntry *statement_type = statement_value->value.type;
+ ZigType *statement_type = statement_value->value.type;
if (type_is_invalid(statement_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -19862,7 +19862,7 @@ static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) {
+static ZigType *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) {
IrInstruction *msg = instruction->msg->other;
if (type_is_invalid(msg->value.type))
return ir_unreach_error(ira);
@@ -19872,9 +19872,9 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio
return ir_unreach_error(ira);
}
- TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
+ ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
- TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type);
+ ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type);
if (type_is_invalid(casted_msg->value.type))
return ir_unreach_error(ira);
@@ -19886,10 +19886,10 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio
}
static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) {
- TypeTableEntry *target_type = target->value.type;
+ ZigType *target_type = target->value.type;
assert(!type_is_invalid(target_type));
- TypeTableEntry *result_type;
+ ZigType *result_type;
uint32_t old_align_bytes;
if (target_type->id == TypeTableEntryIdPointer) {
@@ -19903,9 +19903,9 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
} else if (target_type->id == TypeTableEntryIdOptional &&
target_type->data.maybe.child_type->id == TypeTableEntryIdPointer)
{
- TypeTableEntry *ptr_type = target_type->data.maybe.child_type;
+ ZigType *ptr_type = target_type->data.maybe.child_type;
old_align_bytes = ptr_type->data.pointer.alignment;
- TypeTableEntry *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes);
+ ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes);
result_type = get_optional_type(ira->codegen, better_ptr_type);
} else if (target_type->id == TypeTableEntryIdOptional &&
@@ -19914,12 +19914,12 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
FnTypeId fn_type_id = target_type->data.maybe.child_type->data.fn.fn_type_id;
old_align_bytes = fn_type_id.alignment;
fn_type_id.alignment = align_bytes;
- TypeTableEntry *fn_type = get_fn_type(ira->codegen, &fn_type_id);
+ ZigType *fn_type = get_fn_type(ira->codegen, &fn_type_id);
result_type = get_optional_type(ira->codegen, fn_type);
} else if (is_slice(target_type)) {
- TypeTableEntry *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
+ ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
old_align_bytes = slice_ptr_type->data.pointer.alignment;
- TypeTableEntry *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes);
+ ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes);
result_type = get_slice_type(ira->codegen, result_ptr_type);
} else {
ir_add_error(ira, target,
@@ -19957,16 +19957,16 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
return result;
}
-static TypeTableEntry *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
+static ZigType *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
Error err;
IrInstruction *dest_type_value = instruction->dest_type->other;
- TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);
+ ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
IrInstruction *ptr = instruction->ptr->other;
- TypeTableEntry *src_type = ptr->value.type;
+ ZigType *src_type = ptr->value.type;
if (type_is_invalid(src_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20155,15 +20155,15 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
+static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
Error err;
IrInstruction *dest_type_value = instruction->dest_type->other;
- TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);
+ ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
IrInstruction *value = instruction->value->other;
- TypeTableEntry *src_type = value->value.type;
+ ZigType *src_type = value->value.type;
if (type_is_invalid(src_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20255,10 +20255,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
+static ZigType *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
Error err;
IrInstruction *dest_type_value = instruction->dest_type->other;
- TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);
+ ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20300,7 +20300,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstr
return dest_type;
}
-static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
IrInstructionDeclRef *instruction)
{
Tld *tld = instruction->tld;
@@ -20361,12 +20361,12 @@ static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) {
+static ZigType *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) {
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
+ ZigType *usize = ira->codegen->builtin_types.entry_usize;
if (get_codegen_ptr_type(target->value.type) == nullptr) {
ir_add_error(ira, target,
@@ -20400,9 +20400,9 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr
return usize;
}
-static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
+static ZigType *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
Error err;
- TypeTableEntry *child_type = ir_resolve_type(ira, instruction->child_type->other);
+ ZigType *child_type = ir_resolve_type(ira, instruction->child_type->other);
if (type_is_invalid(child_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20433,7 +20433,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) {
+static ZigType *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) {
uint32_t align_bytes;
IrInstruction *align_bytes_inst = instruction->align_bytes->other;
if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))
@@ -20451,7 +20451,7 @@ static TypeTableEntry *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) {
+static ZigType *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) {
Buf *name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", instruction->base.source_node);
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
out_val->data.x_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node,
@@ -20459,7 +20459,7 @@ static TypeTableEntry *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInst
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) {
+static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) {
uint32_t align_bytes;
IrInstruction *align_bytes_inst = instruction->align_bytes->other;
if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))
@@ -20499,9 +20499,9 @@ static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, Ir
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
+static ZigType *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
IrInstruction *fn_type_inst = instruction->fn_type->other;
- TypeTableEntry *fn_type = ir_resolve_type(ira, fn_type_inst);
+ ZigType *fn_type = ir_resolve_type(ira, fn_type_inst);
if (type_is_invalid(fn_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20538,10 +20538,10 @@ static TypeTableEntry *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
+static ZigType *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
Error err;
IrInstruction *target_inst = instruction->target->other;
- TypeTableEntry *enum_type = ir_resolve_type(ira, target_inst);
+ ZigType *enum_type = ir_resolve_type(ira, target_inst);
if (type_is_invalid(enum_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20576,7 +20576,7 @@ static TypeTableEntry *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruc
}
}
-static TypeTableEntry *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) {
+static ZigType *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) {
IrInstruction *target_inst = instruction->target->other;
if (type_is_invalid(target_inst->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20591,7 +20591,7 @@ static TypeTableEntry *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructi
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstructionCoroId *instruction) {
+static ZigType *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstructionCoroId *instruction) {
IrInstruction *promise_ptr = instruction->promise_ptr->other;
if (type_is_invalid(promise_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20603,7 +20603,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstruct
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstructionCoroAlloc *instruction) {
+static ZigType *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstructionCoroAlloc *instruction) {
IrInstruction *coro_id = instruction->coro_id->other;
if (type_is_invalid(coro_id->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20615,14 +20615,14 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_size(IrAnalyze *ira, IrInstructionCoroSize *instruction) {
+static ZigType *ir_analyze_instruction_coro_size(IrAnalyze *ira, IrInstructionCoroSize *instruction) {
IrInstruction *result = ir_build_coro_size(&ira->new_irb, instruction->base.scope, instruction->base.source_node);
ir_link_new_instruction(result, &instruction->base);
result->value.type = ira->codegen->builtin_types.entry_usize;
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionCoroBegin *instruction) {
+static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionCoroBegin *instruction) {
IrInstruction *coro_id = instruction->coro_id->other;
if (type_is_invalid(coro_id->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20640,13 +20640,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_get_implicit_allocator(IrAnalyze *ira, IrInstructionGetImplicitAllocator *instruction) {
+static ZigType *ir_analyze_instruction_get_implicit_allocator(IrAnalyze *ira, IrInstructionGetImplicitAllocator *instruction) {
IrInstruction *result = ir_get_implicit_allocator(ira, &instruction->base, instruction->id);
ir_link_new_instruction(result, &instruction->base);
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, IrInstructionCoroAllocFail *instruction) {
+static ZigType *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, IrInstructionCoroAllocFail *instruction) {
IrInstruction *err_val = instruction->err_val->other;
if (type_is_invalid(err_val->value.type))
return ir_unreach_error(ira);
@@ -20657,7 +20657,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, Ir
return ir_finish_anal(ira, result->value.type);
}
-static TypeTableEntry *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrInstructionCoroSuspend *instruction) {
+static ZigType *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrInstructionCoroSuspend *instruction) {
IrInstruction *save_point = nullptr;
if (instruction->save_point != nullptr) {
save_point = instruction->save_point->other;
@@ -20676,7 +20676,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrIns
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstructionCoroEnd *instruction) {
+static ZigType *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstructionCoroEnd *instruction) {
IrInstruction *result = ir_build_coro_end(&ira->new_irb, instruction->base.scope,
instruction->base.source_node);
ir_link_new_instruction(result, &instruction->base);
@@ -20684,7 +20684,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstruc
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstructionCoroFree *instruction) {
+static ZigType *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstructionCoroFree *instruction) {
IrInstruction *coro_id = instruction->coro_id->other;
if (type_is_invalid(coro_id->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20696,12 +20696,12 @@ static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstru
IrInstruction *result = ir_build_coro_free(&ira->new_irb, instruction->base.scope,
instruction->base.source_node, coro_id, coro_handle);
ir_link_new_instruction(result, &instruction->base);
- TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
+ ZigType *ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
result->value.type = get_optional_type(ira->codegen, ptr_type);
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInstructionCoroResume *instruction) {
+static ZigType *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInstructionCoroResume *instruction) {
IrInstruction *awaiter_handle = instruction->awaiter_handle->other;
if (type_is_invalid(awaiter_handle->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20717,7 +20717,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInst
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstructionCoroSave *instruction) {
+static ZigType *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstructionCoroSave *instruction) {
IrInstruction *coro_handle = instruction->coro_handle->other;
if (type_is_invalid(coro_handle->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20729,7 +20729,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstru
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructionCoroPromise *instruction) {
+static ZigType *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructionCoroPromise *instruction) {
IrInstruction *coro_handle = instruction->coro_handle->other;
if (type_is_invalid(coro_handle->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20742,7 +20742,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns
return ira->codegen->builtin_types.entry_invalid;
}
- TypeTableEntry *coro_frame_type = get_promise_frame_type(ira->codegen,
+ ZigType *coro_frame_type = get_promise_frame_type(ira->codegen,
coro_handle->value.type->data.promise.result_type);
IrInstruction *result = ir_build_coro_promise(&ira->new_irb, instruction->base.scope,
@@ -20752,7 +20752,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, IrInstructionCoroAllocHelper *instruction) {
+static ZigType *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, IrInstructionCoroAllocHelper *instruction) {
IrInstruction *alloc_fn = instruction->alloc_fn->other;
if (type_is_invalid(alloc_fn->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20764,13 +20764,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira,
IrInstruction *result = ir_build_coro_alloc_helper(&ira->new_irb, instruction->base.scope,
instruction->base.source_node, alloc_fn, coro_size);
ir_link_new_instruction(result, &instruction->base);
- TypeTableEntry *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
+ ZigType *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
result->value.type = get_optional_type(ira->codegen, u8_ptr_type);
return result->value.type;
}
-static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {
- TypeTableEntry *operand_type = ir_resolve_type(ira, op);
+static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {
+ ZigType *operand_type = ir_resolve_type(ira, op);
if (type_is_invalid(operand_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20801,8 +20801,8 @@ static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruct
return operand_type;
}
-static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) {
- TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
+static ZigType *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) {
+ ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
if (type_is_invalid(operand_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20811,7 +20811,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr
return ira->codegen->builtin_types.entry_invalid;
// TODO let this be volatile
- TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
+ ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
if (type_is_invalid(casted_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20859,8 +20859,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) {
- TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
+static ZigType *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) {
+ ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
if (type_is_invalid(operand_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20868,7 +20868,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst
if (type_is_invalid(ptr_inst->value.type))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);
+ ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);
IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
if (type_is_invalid(casted_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20902,8 +20902,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {
- TypeTableEntry *promise_type = ir_resolve_type(ira, instruction->promise_type->other);
+static ZigType *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {
+ ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->other);
if (type_is_invalid(promise_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20918,8 +20918,8 @@ static TypeTableEntry *ir_analyze_instruction_promise_result_type(IrAnalyze *ira
return ira->codegen->builtin_types.entry_type;
}
-static TypeTableEntry *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {
- TypeTableEntry *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->other);
+static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {
+ ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->other);
if (type_is_invalid(promise_result_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20935,7 +20935,7 @@ static TypeTableEntry *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira,
return out_val->type;
}
-static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira,
+static ZigType *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira,
IrInstructionMergeErrRetTraces *instruction)
{
IrInstruction *coro_promise_ptr = instruction->coro_promise_ptr->other;
@@ -20943,9 +20943,9 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir
return ira->codegen->builtin_types.entry_invalid;
assert(coro_promise_ptr->value.type->id == TypeTableEntryIdPointer);
- TypeTableEntry *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type;
+ ZigType *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type;
assert(promise_frame_type->id == TypeTableEntryIdStruct);
- TypeTableEntry *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry;
+ ZigType *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry;
if (!type_can_fail(promise_result_type)) {
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
@@ -20968,7 +20968,7 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) {
+static ZigType *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) {
IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope,
instruction->base.source_node);
ir_link_new_instruction(result, &instruction->base);
@@ -20976,7 +20976,7 @@ static TypeTableEntry *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira,
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *ira, IrInstructionMarkErrRetTracePtr *instruction) {
+static ZigType *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *ira, IrInstructionMarkErrRetTracePtr *instruction) {
IrInstruction *err_ret_trace_ptr = instruction->err_ret_trace_ptr->other;
if (type_is_invalid(err_ret_trace_ptr->value.type))
return ira->codegen->builtin_types.entry_invalid;
@@ -20988,8 +20988,8 @@ static TypeTableEntry *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {
- TypeTableEntry *float_type = ir_resolve_type(ira, instruction->type->other);
+static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {
+ ZigType *float_type = ir_resolve_type(ira, instruction->type->other);
if (type_is_invalid(float_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -21055,7 +21055,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) {
+static ZigType *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) {
Error err;
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
@@ -21070,17 +21070,17 @@ static TypeTableEntry *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInst
if ((err = type_ensure_zero_bits_known(ira->codegen, target->value.type)))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *tag_type = target->value.type->data.enumeration.tag_int_type;
+ ZigType *tag_type = target->value.type->data.enumeration.tag_int_type;
IrInstruction *result = ir_analyze_enum_to_int(ira, &instruction->base, target, tag_type);
ir_link_new_instruction(result, &instruction->base);
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
+static ZigType *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
Error err;
IrInstruction *dest_type_value = instruction->dest_type->other;
- TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);
+ ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
if (type_is_invalid(dest_type))
return ira->codegen->builtin_types.entry_invalid;
@@ -21093,7 +21093,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst
if ((err = type_ensure_zero_bits_known(ira->codegen, dest_type)))
return ira->codegen->builtin_types.entry_invalid;
- TypeTableEntry *tag_type = dest_type->data.enumeration.tag_int_type;
+ ZigType *tag_type = dest_type->data.enumeration.tag_int_type;
IrInstruction *target = instruction->target->other;
if (type_is_invalid(target->value.type))
@@ -21108,7 +21108,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst
return result->value.type;
}
-static TypeTableEntry *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) {
+static ZigType *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) {
IrInstruction *block_comptime_inst = instruction->scope_is_comptime->other;
bool scope_is_comptime;
if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime))
@@ -21131,7 +21131,7 @@ static TypeTableEntry *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira
return ira->codegen->builtin_types.entry_void;
}
-static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) {
+static ZigType *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) {
switch (instruction->id) {
case IrInstructionIdInvalid:
case IrInstructionIdWidenOrShorten:
@@ -21413,8 +21413,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi
zig_unreachable();
}
-static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction) {
- TypeTableEntry *instruction_type = ir_analyze_instruction_nocast(ira, instruction);
+static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction) {
+ ZigType *instruction_type = ir_analyze_instruction_nocast(ira, instruction);
instruction->value.type = instruction_type;
if (instruction->other) {
@@ -21430,8 +21430,8 @@ static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *ins
// This function attempts to evaluate IR code while doing type checking and other analysis.
// It emits a new IrExecutable which is partially evaluated IR code.
-TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec,
- TypeTableEntry *expected_type, AstNode *expected_type_source_node)
+ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec,
+ ZigType *expected_type, AstNode *expected_type_source_node)
{
assert(!old_exec->invalid);
assert(expected_type == nullptr || !type_is_invalid(expected_type));
@@ -21472,7 +21472,7 @@ TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutabl
continue;
}
- TypeTableEntry *return_type = ir_analyze_instruction(ira, old_instruction);
+ ZigType *return_type = ir_analyze_instruction(ira, old_instruction);
if (type_is_invalid(return_type) && ir_should_inline(new_exec, old_instruction->scope)) {
return ira->codegen->builtin_types.entry_invalid;
}
src/ir.hpp
@@ -14,12 +14,12 @@ bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable
bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry);
IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
- TypeTableEntry *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
+ ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
IrExecutable *parent_exec);
-TypeTableEntry *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,
- TypeTableEntry *expected_type, AstNode *expected_type_source_node);
+ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,
+ ZigType *expected_type, AstNode *expected_type_source_node);
bool ir_has_side_effects(IrInstruction *instruction);
ConstExprValue *const_ptr_pointee(CodeGen *codegen, ConstExprValue *const_val);