diff options
| author | gingerBill <bill@gingerbill.org> | 2017-11-10 18:24:49 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-11-10 18:24:49 +0000 |
| commit | 0d01a6f552ab186a5c2bfd7c4f3f8ebed662952c (patch) | |
| tree | 7e33cc0357ad0684839e2661b8262178aaf91799 /src/ir.cpp | |
| parent | ae3672608dcf77fdc642c77c9a3db378c0e16cd9 (diff) | |
Fix issue #139
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5eb380f9f..e57cf01da 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4013,7 +4013,6 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv } return ir_emit_source_code_location(proc, procedure, pos); - break; } case BuiltinProc_type_info_of: { @@ -4122,6 +4121,11 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv gbAllocator a = proc->module->allocator; Type *type = type_of_expr(proc->module->info, ce->args[0]); + String proc_name = {}; + if (proc->entity != nullptr) { + proc_name = proc->entity->token.string; + } + if (is_type_slice(type)) { Type *elem_type = core_type(type)->Slice.elem; Type *elem_ptr_type = make_type_pointer(a, elem_type); @@ -4140,10 +4144,12 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv irValue *slice_size = ir_emit_arith(proc, Token_Mul, elem_size, capacity, t_int); - irValue **args = gb_alloc_array(a, irValue *, 2); + + irValue **args = gb_alloc_array(a, irValue *, 3); args[0] = slice_size; args[1] = elem_align; - irValue *call = ir_emit_global_call(proc, "alloc", args, 2); + args[2] = ir_emit_source_code_location(proc, proc_name, ast_node_token(expr).pos); + irValue *call = ir_emit_global_call(proc, "alloc", args, 3); irValue *ptr = ir_emit_conv(proc, call, elem_ptr_type); |