mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
+11
-3
@@ -1,6 +1,14 @@
|
|||||||
#import "fmt.odin";
|
Test1 :: type union {
|
||||||
#import "sync.odin";
|
A: int;
|
||||||
|
B: int;
|
||||||
|
};
|
||||||
|
|
||||||
|
Test :: type struct {
|
||||||
|
a: Test1;
|
||||||
|
};
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
fmt.println("Hellope");
|
test: Test;
|
||||||
|
match type x : ^test.a {
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1579,12 +1579,14 @@ ssaValue *ssa_emit_union_tag_ptr(ssaProcedure *proc, ssaValue *u) {
|
|||||||
Type *t = ssa_type(u);
|
Type *t = ssa_type(u);
|
||||||
GB_ASSERT(is_type_pointer(t) &&
|
GB_ASSERT(is_type_pointer(t) &&
|
||||||
is_type_union(type_deref(t)));
|
is_type_union(type_deref(t)));
|
||||||
|
GB_ASSERT(are_types_identical(t, ssa_type(u)));
|
||||||
return ssa_emit(proc, ssa_make_instr_union_tag_ptr(proc, u));
|
return ssa_emit(proc, ssa_make_instr_union_tag_ptr(proc, u));
|
||||||
}
|
}
|
||||||
|
|
||||||
ssaValue *ssa_emit_union_tag_value(ssaProcedure *proc, ssaValue *u) {
|
ssaValue *ssa_emit_union_tag_value(ssaProcedure *proc, ssaValue *u) {
|
||||||
Type *t = ssa_type(u);
|
Type *t = ssa_type(u);
|
||||||
GB_ASSERT(is_type_union(t));
|
GB_ASSERT(is_type_union(t));
|
||||||
|
GB_ASSERT(are_types_identical(t, ssa_type(u)));
|
||||||
return ssa_emit(proc, ssa_make_instr_union_tag_value(proc, u));
|
return ssa_emit(proc, ssa_make_instr_union_tag_value(proc, u));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -54,7 +54,11 @@ void ssa_opt_add_operands(ssaValueArray *ops, ssaInstr *i) {
|
|||||||
array_add(ops, i->Phi.edges.e[j]);
|
array_add(ops, i->Phi.edges.e[j]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ssaInstr_Unreachable: break;
|
case ssaInstr_Unreachable:
|
||||||
|
break;
|
||||||
|
case ssaInstr_UnaryOp:
|
||||||
|
array_add(ops, i->UnaryOp.expr);
|
||||||
|
break;
|
||||||
case ssaInstr_BinaryOp:
|
case ssaInstr_BinaryOp:
|
||||||
array_add(ops, i->BinaryOp.left);
|
array_add(ops, i->BinaryOp.left);
|
||||||
array_add(ops, i->BinaryOp.right);
|
array_add(ops, i->BinaryOp.right);
|
||||||
@@ -88,8 +92,6 @@ void ssa_opt_add_operands(ssaValueArray *ops, ssaInstr *i) {
|
|||||||
array_add(ops, i->SliceBoundsCheck.high);
|
array_add(ops, i->SliceBoundsCheck.high);
|
||||||
array_add(ops, i->SliceBoundsCheck.max);
|
array_add(ops, i->SliceBoundsCheck.max);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -206,7 +206,7 @@ void ssa_print_type(ssaFileBuffer *f, ssaModule *m, Type *t) {
|
|||||||
}
|
}
|
||||||
Type *ft = t->Record.fields[i]->type;
|
Type *ft = t->Record.fields[i]->type;
|
||||||
Type *bft = base_type(ft);
|
Type *bft = base_type(ft);
|
||||||
if (!is_type_struct(bft)) {
|
if (!is_type_struct(bft) && !is_type_union(bft)) {
|
||||||
ft = bft;
|
ft = bft;
|
||||||
}
|
}
|
||||||
ssa_print_type(f, m, ft);
|
ssa_print_type(f, m, ft);
|
||||||
@@ -242,7 +242,6 @@ void ssa_print_type(ssaFileBuffer *f, ssaModule *m, Type *t) {
|
|||||||
String *name = map_string_get(&m->type_names, hash_pointer(t));
|
String *name = map_string_get(&m->type_names, hash_pointer(t));
|
||||||
GB_ASSERT_MSG(name != NULL, "%.*s", LIT(t->Named.name));
|
GB_ASSERT_MSG(name != NULL, "%.*s", LIT(t->Named.name));
|
||||||
ssa_print_encoded_local(f, *name);
|
ssa_print_encoded_local(f, *name);
|
||||||
// ssa_print_encoded_local(f, t->Named.name);
|
|
||||||
} else {
|
} else {
|
||||||
ssa_print_type(f, m, base_type(t));
|
ssa_print_type(f, m, base_type(t));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user