mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 03:40:08 +00:00
Clean up _preload.odin types
This commit is contained in:
+2
-2
@@ -6837,14 +6837,14 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
|
||||
|
||||
o->type = t;
|
||||
o->mode = Addressing_OptionalOk;
|
||||
} else if (is_type_any(o->type)) {
|
||||
} else if (is_type_any(src)) {
|
||||
o->type = t;
|
||||
o->mode = Addressing_OptionalOk;
|
||||
|
||||
add_type_info_type(c, o->type);
|
||||
add_type_info_type(c, t);
|
||||
} else {
|
||||
error(o->expr, "Type assertions can only operate on unions");
|
||||
error(o->expr, "Type assertions can only operate on unions and `any`");
|
||||
o->mode = Addressing_Invalid;
|
||||
o->expr = node;
|
||||
return kind;
|
||||
|
||||
+6
-4
@@ -3339,6 +3339,11 @@ irValue *ir_emit_union_cast(irProcedure *proc, irValue *value, Type *type, Token
|
||||
irAddr ir_emit_any_cast_addr(irProcedure *proc, irValue *value, Type *type, TokenPos pos) {
|
||||
gbAllocator a = proc->module->allocator;
|
||||
Type *src_type = ir_type(value);
|
||||
|
||||
if (is_type_pointer(src_type)) {
|
||||
value = ir_emit_load(proc, value);
|
||||
}
|
||||
|
||||
bool is_tuple = true;
|
||||
Type *tuple = type;
|
||||
if (type->kind != Type_Tuple) {
|
||||
@@ -8049,11 +8054,9 @@ void ir_gen_tree(irGen *s) {
|
||||
tag = ir_emit_conv(proc, variant_ptr, t_type_info_union_ptr);
|
||||
|
||||
{
|
||||
irValue *variant_names = ir_emit_struct_ep(proc, tag, 1);
|
||||
irValue *variant_types = ir_emit_struct_ep(proc, tag, 2);
|
||||
irValue *variant_types = ir_emit_struct_ep(proc, tag, 0);
|
||||
|
||||
isize variant_count = gb_max(0, t->Union.variant_count-1);
|
||||
irValue *memory_names = ir_type_info_member_names_offset(proc, variant_count);
|
||||
irValue *memory_types = ir_type_info_member_types_offset(proc, variant_count);
|
||||
|
||||
// NOTE(bill): Zeroth is nil so ignore it
|
||||
@@ -8067,7 +8070,6 @@ void ir_gen_tree(irGen *s) {
|
||||
}
|
||||
|
||||
irValue *count = ir_const_int(a, variant_count);
|
||||
ir_fill_slice(proc, variant_names, memory_names, count, count);
|
||||
ir_fill_slice(proc, variant_types, memory_types, count, count);
|
||||
}
|
||||
|
||||
|
||||
+17
-8
@@ -4134,20 +4134,29 @@ AstNode *parse_match_stmt(AstFile *f) {
|
||||
if (f->curr_token.kind != Token_OpenBrace) {
|
||||
isize prev_level = f->expr_level;
|
||||
f->expr_level = -1;
|
||||
defer (f->expr_level = prev_level);
|
||||
|
||||
tag = parse_simple_stmt(f, StmtAllowFlag_In);
|
||||
if (tag->kind == AstNode_AssignStmt && tag->AssignStmt.op.kind == Token_in) {
|
||||
if (allow_token(f, Token_in)) {
|
||||
Array<AstNode *> lhs = {};
|
||||
Array<AstNode *> rhs = make_ast_node_array(f, 1);
|
||||
array_add(&rhs, parse_expr(f, false));
|
||||
|
||||
tag = ast_assign_stmt(f, token, lhs, rhs);
|
||||
is_type_match = true;
|
||||
} else {
|
||||
if (allow_token(f, Token_Semicolon)) {
|
||||
init = tag;
|
||||
tag = nullptr;
|
||||
if (f->curr_token.kind != Token_OpenBrace) {
|
||||
tag = parse_simple_stmt(f, StmtAllowFlag_None);
|
||||
tag = parse_simple_stmt(f, StmtAllowFlag_In);
|
||||
if (tag->kind == AstNode_AssignStmt && tag->AssignStmt.op.kind == Token_in) {
|
||||
is_type_match = true;
|
||||
} else {
|
||||
if (allow_token(f, Token_Semicolon)) {
|
||||
init = tag;
|
||||
tag = nullptr;
|
||||
if (f->curr_token.kind != Token_OpenBrace) {
|
||||
tag = parse_simple_stmt(f, StmtAllowFlag_None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
f->expr_level = prev_level;
|
||||
}
|
||||
open = expect_token(f, Token_OpenBrace);
|
||||
|
||||
|
||||
+12
-19
@@ -84,23 +84,13 @@ struct TypeRecord {
|
||||
|
||||
// All record types
|
||||
// Theses are arrays
|
||||
// Entity_Variable - struct/raw_union/union (for common fields)
|
||||
// Entity_Constant - enum
|
||||
// Entity_Variable - struct/raw_union (for common fields)
|
||||
Entity **fields;
|
||||
i32 field_count; // == struct_offsets count
|
||||
Entity **fields_in_src_order; // Entity_Variable
|
||||
AstNode *node;
|
||||
Scope * scope;
|
||||
|
||||
// Entity_TypeName - union
|
||||
// Type ** variants;
|
||||
// i32 variant_count;
|
||||
// Entity * union__tag;
|
||||
// i64 variant_block_size; // NOTE(bill): Internal use only
|
||||
|
||||
// Type * variant_parent;
|
||||
// i32 variant_index;
|
||||
|
||||
i64 * offsets;
|
||||
bool are_offsets_set;
|
||||
bool are_offsets_being_processed;
|
||||
@@ -109,11 +99,6 @@ struct TypeRecord {
|
||||
|
||||
i64 custom_align; // NOTE(bill): Only used in structs at the moment
|
||||
Entity * names;
|
||||
|
||||
// Type * enum_base_type;
|
||||
// Entity * enum_count;
|
||||
// Entity * enum_min_value;
|
||||
// Entity * enum_max_value;
|
||||
};
|
||||
|
||||
#define TYPE_KINDS \
|
||||
@@ -144,8 +129,6 @@ struct TypeRecord {
|
||||
Scope * scope; \
|
||||
Entity * union__tag; \
|
||||
i64 variant_block_size; \
|
||||
Type * variant_parent; \
|
||||
i32 variant_index; \
|
||||
i64 custom_align; \
|
||||
}) \
|
||||
TYPE_KIND(Named, struct { \
|
||||
@@ -1559,14 +1542,24 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n
|
||||
}
|
||||
|
||||
if (is_type) {
|
||||
if (type->kind == Type_Record) {
|
||||
switch (type->kind) {
|
||||
case Type_Record:
|
||||
if (type->Record.names != nullptr &&
|
||||
field_name == "names") {
|
||||
sel.entity = type->Record.names;
|
||||
return sel;
|
||||
}
|
||||
break;
|
||||
case Type_Enum:
|
||||
if (type->Enum.names != nullptr &&
|
||||
field_name == "names") {
|
||||
sel.entity = type->Enum.names;
|
||||
return sel;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (is_type_enum(type)) {
|
||||
// NOTE(bill): These may not have been added yet, so check in case
|
||||
if (type->Enum.count != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user