aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-05 18:33:07 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-05 18:33:07 -0400
commitdb882e5d63d2840b1410a2574fd12d973b7f3ee2 (patch)
tree6316a85c4da5de1fd54b380c554d65daaf4d6700 /src/analyze.cpp
parenta3d384e593e9128ed3b69cc77e6d6e048f0c6bb7 (diff)
downloadzig-db882e5d63d2840b1410a2574fd12d973b7f3ee2.tar.gz
zig-db882e5d63d2840b1410a2574fd12d973b7f3ee2.zip
stage1: rename TypeTableEntry to ZigType
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp434
1 files changed, 217 insertions, 217 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index ff7dac1abf..28dc54f11a 100644
--- a/src/analyze.cpp
+++ b/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(&param_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') {