Merge pull request #197 from bpunsky/context-bug-fix

Context bug fix
This commit is contained in:
gingerBill
2018-02-25 00:13:02 +00:00
committed by GitHub
4 changed files with 1088 additions and 1074 deletions
+4
View File
@@ -42,6 +42,10 @@ ptr_to_bytes :: proc "contextless" (ptr: ^$T, len := 1) -> []byte {
return transmute([]byte)raw.Slice{ptr, len*size_of(T)};
}
any_to_bytes :: proc "contextless" (val: any) -> []byte {
return transmute([]byte)raw.Slice{val.data, val.type_info.size};
}
kilobytes :: inline proc "contextless" (x: int) -> int do return (x) * 1024;
megabytes :: inline proc "contextless" (x: int) -> int do return kilobytes(x) * 1024;
+1078 -1074
View File
File diff suppressed because it is too large Load Diff
View File
+6
View File
@@ -1650,6 +1650,12 @@ irValue *ir_find_or_generate_context_ptr(irProcedure *proc) {
if (proc->context_stack.count > 0) {
return proc->context_stack[proc->context_stack.count-1];
}
irBlock *tmp_block = proc->curr_block;
proc->curr_block = proc->blocks[0];
defer (proc->curr_block = tmp_block);
irValue *c = ir_add_local_generated(proc, t_context);
array_add(&proc->context_stack, c);
ir_emit_store(proc, c, ir_emit_load(proc, proc->module->global_default_context));