Begin transition to Jai-like syntax

This commit is contained in:
Ginger Bill
2017-01-01 19:08:03 +00:00
parent 3f1195cd03
commit a48e0c7179
20 changed files with 2348 additions and 2365 deletions
+15 -15
View File
@@ -83,7 +83,7 @@ proc type_info_base(info ^Type_Info) -> ^Type_Info {
if info == nil {
return nil;
}
var base = info;
base := info;
match type i : base {
case Type_Info.Named:
base = i.base;
@@ -140,14 +140,14 @@ type {
}
}
#thread_local var __context Context;
#thread_local __context: Context;
const DEFAULT_ALIGNMENT = align_of([vector 4]f32);
DEFAULT_ALIGNMENT :: align_of([vector 4]f32);
proc __check_context() {
var c = ^__context;
c := ^__context;
if c.allocator.procedure == nil {
c.allocator = default_allocator();
@@ -161,20 +161,20 @@ proc alloc(size int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNM
proc alloc_align(size, alignment int) -> rawptr #inline {
__check_context();
var a = context.allocator;
a := context.allocator;
return a.procedure(a.data, Allocator_Mode.ALLOC, size, alignment, nil, 0, 0);
}
proc free(ptr rawptr) #inline {
__check_context();
var a = context.allocator;
a := context.allocator;
if ptr != nil {
a.procedure(a.data, Allocator_Mode.FREE, 0, 0, ptr, 0, 0);
}
}
proc free_all() #inline {
__check_context();
var a = context.allocator;
a := context.allocator;
a.procedure(a.data, Allocator_Mode.FREE_ALL, 0, 0, nil, 0, 0);
}
@@ -182,7 +182,7 @@ proc free_all() #inline {
proc resize (ptr rawptr, old_size, new_size int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT); }
proc resize_align(ptr rawptr, old_size, new_size, alignment int) -> rawptr #inline {
__check_context();
var a = context.allocator;
a := context.allocator;
return a.procedure(a.data, Allocator_Mode.RESIZE, new_size, alignment, ptr, old_size, 0);
}
@@ -202,7 +202,7 @@ proc default_resize_align(old_memory rawptr, old_size, new_size, alignment int)
return old_memory;
}
var new_memory = alloc_align(new_size, alignment);
new_memory := alloc_align(new_size, alignment);
if new_memory == nil {
return nil;
}
@@ -221,9 +221,9 @@ proc default_allocator_proc(allocator_data rawptr, mode Allocator_Mode,
when false {
match mode {
case ALLOC:
var total_size = size + alignment + size_of(mem.AllocationHeader);
var ptr = os.heap_alloc(total_size);
var header = ptr as ^mem.AllocationHeader;
total_size := size + alignment + size_of(mem.AllocationHeader);
ptr := os.heap_alloc(total_size);
header := ptr as ^mem.AllocationHeader;
ptr = mem.align_forward(header+1, alignment);
mem.allocation_header_fill(header, ptr, size);
return mem.zero(ptr, size);
@@ -236,9 +236,9 @@ proc default_allocator_proc(allocator_data rawptr, mode Allocator_Mode,
// NOTE(bill): Does nothing
case RESIZE:
var total_size = size + alignment + size_of(mem.AllocationHeader);
var ptr = os.heap_resize(mem.allocation_header(old_memory), total_size);
var header = ptr as ^mem.AllocationHeader;
total_size := size + alignment + size_of(mem.AllocationHeader);
ptr := os.heap_resize(mem.allocation_header(old_memory), total_size);
header := ptr as ^mem.AllocationHeader;
ptr = mem.align_forward(header+1, alignment);
mem.allocation_header_fill(header, ptr, size);
return mem.zero(ptr, size);