aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorThisDrunkDane <hoej@northwolfprod.com>2018-02-12 06:07:15 +0100
committerThisDrunkDane <hoej@northwolfprod.com>2018-02-12 06:07:15 +0100
commite225158a6f69e3782a194e5b82b9a5af56686e71 (patch)
treef30b3c5713d5e59c16f4b7677fe32d884dd63bb5 /src/ir.cpp
parent4c06b443154bcb85982d61f39badbab901ac4da8 (diff)
parent2ce55783d2c9cfb72da5bc4a51556d9938b6124a (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index eb9ba8979..a28d28739 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1603,10 +1603,10 @@ void ir_emit_zero_init(irProcedure *p, irValue *address, AstNode *expr) {
irValue **args = gb_alloc_array(a, irValue *, 2);
args[0] = ir_emit_conv(p, address, t_rawptr);
args[1] = ir_const_int(a, type_size_of(a, t));
- ir_emit(p, ir_instr_zero_init(p, address));
if (p->entity->token.string != "__mem_zero") {
ir_emit_global_call(p, "__mem_zero", args, 2, expr);
}
+ ir_emit(p, ir_instr_zero_init(p, address));
}
irValue *ir_emit_comment(irProcedure *p, String text) {
@@ -4272,7 +4272,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
ir_emit_slice_bounds_check(proc, ast_node_token(ce->args[1]), v_zero, len, false);
irValue *slice_size = len;
- if (eal != 1) {
+ if (esz != 1) {
slice_size = ir_emit_arith(proc, Token_Mul, elem_size, len, t_int);
}
@@ -5578,7 +5578,10 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
case_end;
case_ast_node(be, BinaryExpr, expr);
- GB_PANIC("Invalid binary expression for ir_build_addr: %.*s\n", LIT(be->op.string));
+ irValue *v = ir_build_expr(proc, expr);
+ Type *t = ir_type(v);
+ GB_ASSERT(is_type_pointer(t));
+ return ir_addr(v);
case_end;
case_ast_node(ie, IndexExpr, expr);
@@ -8033,6 +8036,9 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
irValue *base = ir_type_info(proc, t->Enum.base_type);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), base);
+ // is_export
+ ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), ir_const_bool(a, t->Enum.is_export));
+
if (t->Enum.field_count > 0) {
Entity **fields = t->Enum.fields;
isize count = t->Enum.field_count;
@@ -8342,22 +8348,17 @@ void ir_gen_tree(irGen *s) {
}
}
- if (decl->init_expr != nullptr) {
- if (is_type_any(e->type)) {
- } else {
- TypeAndValue tav = type_and_value_of_expr(info, decl->init_expr);
- if (tav.mode != Addressing_Invalid) {
- if (tav.value.kind != ExactValue_Invalid) {
- ExactValue v = tav.value;
- g->Global.value = ir_add_module_constant(m, tav.type, v);
- }
+ if (decl->init_expr != nullptr && !is_type_any(e->type)) {
+ TypeAndValue tav = type_and_value_of_expr(info, decl->init_expr);
+ if (tav.mode != Addressing_Invalid) {
+ if (tav.value.kind != ExactValue_Invalid) {
+ ExactValue v = tav.value;
+ g->Global.value = ir_add_module_constant(m, tav.type, v);
}
}
}
- // if (g->Global.value == nullptr) {
- array_add(&global_variables, var);
- // }
+ array_add(&global_variables, var);
ir_module_add_value(m, e, g);
map_set(&m->members, hash_string(name), g);