mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Implicit Values: context; Fix lvalue selector assignments; Fix offset_of* for using fields.
This commit is contained in:
+5
-9
@@ -34,7 +34,7 @@ Type_Info :: union {
|
||||
String: struct #ordered {}
|
||||
Boolean: struct #ordered {}
|
||||
Pointer: struct #ordered {
|
||||
elem: ^Type_Info
|
||||
elem: ^Type_Info // nil -> rawptr
|
||||
}
|
||||
Maybe: struct #ordered {
|
||||
elem: ^Type_Info
|
||||
@@ -138,10 +138,6 @@ Context :: struct #ordered {
|
||||
DEFAULT_ALIGNMENT :: align_of({4}f32)
|
||||
|
||||
|
||||
current_context :: proc() -> Context { // Copy of context
|
||||
return __context
|
||||
}
|
||||
|
||||
__check_context :: proc() {
|
||||
c := ^__context
|
||||
|
||||
@@ -157,27 +153,27 @@ alloc :: proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_AL
|
||||
|
||||
alloc_align :: proc(size, alignment: int) -> rawptr #inline {
|
||||
__check_context()
|
||||
a := current_context().allocator
|
||||
a := context.allocator
|
||||
return a.procedure(a.data, Allocator.Mode.ALLOC, size, alignment, nil, 0, 0)
|
||||
}
|
||||
|
||||
free :: proc(ptr: rawptr) #inline {
|
||||
__check_context()
|
||||
a := current_context().allocator
|
||||
a := context.allocator
|
||||
if ptr != nil {
|
||||
a.procedure(a.data, Allocator.Mode.FREE, 0, 0, ptr, 0, 0)
|
||||
}
|
||||
}
|
||||
free_all :: proc() #inline {
|
||||
__check_context()
|
||||
a := current_context().allocator
|
||||
a := context.allocator
|
||||
a.procedure(a.data, Allocator.Mode.FREE_ALL, 0, 0, nil, 0, 0)
|
||||
}
|
||||
|
||||
|
||||
resize :: proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT) }
|
||||
resize_align :: proc(ptr: rawptr, old_size, new_size, alignment: int) -> rawptr #inline {
|
||||
a := current_context().allocator
|
||||
a := context.allocator
|
||||
return a.procedure(a.data, Allocator.Mode.RESIZE, new_size, alignment, ptr, old_size, 0)
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -226,7 +226,14 @@ print_type_to_buffer :: proc(buf: ^[]byte, ti: ^Type_Info) {
|
||||
case String: print_string_to_buffer(buf, "string")
|
||||
case Boolean: print_string_to_buffer(buf, "bool")
|
||||
case Pointer:
|
||||
print_string_to_buffer(buf, "^")
|
||||
if info.elem == nil {
|
||||
print_string_to_buffer(buf, "rawptr")
|
||||
} else {
|
||||
print_string_to_buffer(buf, "^")
|
||||
print_type_to_buffer(buf, info.elem)
|
||||
}
|
||||
case Maybe:
|
||||
print_string_to_buffer(buf, "?")
|
||||
print_type_to_buffer(buf, info.elem)
|
||||
case Procedure:
|
||||
print_string_to_buffer(buf, "proc")
|
||||
@@ -415,7 +422,7 @@ print_any_to_buffer :: proc(buf: ^[]byte, arg: any) {
|
||||
|
||||
case Maybe:
|
||||
if arg.data != nil {
|
||||
|
||||
// TODO(bill): print maybe
|
||||
} else {
|
||||
print_string_to_buffer(buf, "<nil>")
|
||||
}
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ init_arena_from_memory :: proc(using a: ^Arena, data: []byte) {
|
||||
}
|
||||
|
||||
init_arena_from_context :: proc(using a: ^Arena, size: int) {
|
||||
backing = current_context().allocator
|
||||
backing = context.allocator
|
||||
memory = new_slice(u8, 0, size)
|
||||
temp_count = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user