aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2017-11-27 23:00:23 +0000
committergingerBill <bill@gingerbill.org>2017-11-27 23:00:23 +0000
commit91b534d128be65ee672fd21f8100a15244597604 (patch)
treeac1db2c3b20838090d020678f576ad514f1a5787 /src/ir.cpp
parent3268f43340454c6df15ea9f644f120923cbe4839 (diff)
Fix `transmute`
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index bd2d3ca9e..b8efb563e 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3351,6 +3351,7 @@ bool ir_is_type_aggregate(Type *t) {
case Type_Array:
case Type_Slice:
case Type_Struct:
+ case Type_Union:
case Type_Tuple:
case Type_DynamicArray:
case Type_Map:
@@ -6020,7 +6021,17 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
case_ast_node(tc, TypeCast, expr);
Type *type = type_of_expr(proc->module->info, expr);
irValue *x = ir_build_expr(proc, tc->expr);
- irValue *e = ir_emit_conv(proc, x, type);
+ irValue *e = nullptr;
+ switch (tc->token.kind) {
+ case Token_cast:
+ e = ir_emit_conv(proc, x, type);
+ break;
+ case Token_transmute:
+ e = ir_emit_transmute(proc, x, type);
+ break;
+ default:
+ GB_PANIC("Invalid AST TypeCast");
+ }
irValue *v = ir_add_local_generated(proc, type);
ir_emit_store(proc, v, e);
return ir_addr(v);