mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-27 16:01:47 -07:00
Update and regression test old demos
This commit is contained in:
+3
-5
@@ -249,12 +249,10 @@ void check_assignment(Checker *c, Operand *operand, Type *type, String context_n
|
||||
operand->mode = Addressing_Invalid;
|
||||
return;
|
||||
}
|
||||
if (is_type_any(type)) {
|
||||
target_type = t_any;
|
||||
} else {
|
||||
target_type = default_type(operand->type);
|
||||
target_type = default_type(operand->type);
|
||||
if (!is_type_any(type)) {
|
||||
GB_ASSERT_MSG(is_type_typed(target_type), "%s", type_to_string(type));
|
||||
}
|
||||
GB_ASSERT_MSG(is_type_typed(target_type), "%s", type_to_string(type));
|
||||
add_type_info_type(c, type);
|
||||
add_type_info_type(c, target_type);
|
||||
}
|
||||
|
||||
+3
-1
@@ -1264,8 +1264,10 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
|
||||
case Entity_TypeName: {
|
||||
Type *t = base_type(e->type);
|
||||
if (is_type_union(t)) {
|
||||
for (isize i = 0; i < t->Record.variant_count; i++) {
|
||||
TokenPos pos = ast_node_token(expr).pos;
|
||||
for (isize i = 1; i < t->Record.variant_count; i++) {
|
||||
Entity *f = t->Record.variants[i];
|
||||
// gb_printf_err("%s\n", type_to_string(f->type));
|
||||
Entity *found = scope_insert_entity(c->context.scope, f);
|
||||
if (found != NULL) {
|
||||
gbString expr_str = expr_to_string(expr);
|
||||
|
||||
@@ -4263,8 +4263,10 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) {
|
||||
|
||||
irValue *ptr = ir_emit_conv(proc, ir_slice_elem(proc, s), t_u8_ptr);
|
||||
irValue *count = ir_slice_count(proc, s);
|
||||
irValue *capacity = ir_slice_capacity(proc, s);
|
||||
count = ir_emit_arith(proc, Token_Mul, count, ir_const_int(proc->module->allocator, elem_size), t_int);
|
||||
ir_fill_slice(proc, slice, ptr, count, count);
|
||||
capacity = ir_emit_arith(proc, Token_Mul, capacity, ir_const_int(proc->module->allocator, elem_size), t_int);
|
||||
ir_fill_slice(proc, slice, ptr, count, capacity);
|
||||
return ir_emit_load(proc, slice);
|
||||
} break;
|
||||
|
||||
@@ -4602,6 +4604,14 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
|
||||
ir_emit_store(proc, v, ir_emit_down_cast(proc, ir_build_expr(proc, ce->expr), type));
|
||||
return ir_addr(v);
|
||||
}
|
||||
case Token_union_cast: {
|
||||
ir_emit_comment(proc, str_lit("Cast - union_cast"));
|
||||
// NOTE(bill): Needed for dereference of pointer conversion
|
||||
Type *type = type_of_expr(proc->module->info, expr);
|
||||
irValue *v = ir_add_local_generated(proc, type);
|
||||
ir_emit_store(proc, v, ir_emit_union_cast(proc, ir_build_expr(proc, ce->expr), type, ast_node_token(expr).pos));
|
||||
return ir_addr(v);
|
||||
}
|
||||
default:
|
||||
GB_PANIC("Unknown cast expression");
|
||||
}
|
||||
|
||||
+2
-1
@@ -2272,6 +2272,7 @@ AstNode *parse_value_decl(AstFile *f, AstNodeArray lhs) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
AstNode *parse_simple_stmt(AstFile *f, bool in_stmt_ok) {
|
||||
AstNodeArray lhs = parse_lhs_expr_list(f);
|
||||
Token token = f->curr_token;
|
||||
@@ -3290,7 +3291,7 @@ AstNode *parse_stmt(AstFile *f) {
|
||||
return ast_using_stmt(f, token, list);
|
||||
}
|
||||
|
||||
AstNode *decl = parse_simple_stmt(f, false);
|
||||
AstNode *decl = parse_value_decl(f, list);
|
||||
expect_semicolon(f, decl);
|
||||
|
||||
if (decl->kind == AstNode_ValueDecl) {
|
||||
|
||||
Reference in New Issue
Block a user