Prechádzať zdrojové kódy

Prefix `proc` syntax

Ginger Bill 8 rokov pred
rodič
commit
33eeb58521

+ 5 - 2
code/demo.odin

@@ -11,6 +11,9 @@
 #import "utf8.odin";
 #import "utf16.odin";
 
-const main = proc() {
-	fmt.println("Hello");
+proc main() {
+	var x = proc() {
+		fmt.println("Hello");
+	};
+	x();
 }

+ 68 - 68
core/_preload.odin

@@ -114,7 +114,7 @@ var __type_table: []TypeInfo;
 var __argv__: ^^u8;
 var __argc__: i32;
 
-const type_info_base = proc(info: ^TypeInfo) -> ^TypeInfo {
+proc type_info_base(info: ^TypeInfo) -> ^TypeInfo {
 	if info == nil {
 		return nil;
 	}
@@ -127,7 +127,7 @@ const type_info_base = proc(info: ^TypeInfo) -> ^TypeInfo {
 }
 
 
-const type_info_base_without_enum = proc(info: ^TypeInfo) -> ^TypeInfo {
+proc type_info_base_without_enum(info: ^TypeInfo) -> ^TypeInfo {
 	if info == nil {
 		return nil;
 	}
@@ -143,11 +143,11 @@ const type_info_base_without_enum = proc(info: ^TypeInfo) -> ^TypeInfo {
 
 
 
-const assume = proc(cond: bool) #foreign __llvm_core "llvm.assume";
+proc assume(cond: bool) #foreign __llvm_core "llvm.assume";
 
-const __debug_trap       = proc()        #foreign __llvm_core "llvm.debugtrap";
-const __trap             = proc()        #foreign __llvm_core "llvm.trap";
-const read_cycle_counter = proc() -> u64 #foreign __llvm_core "llvm.readcyclecounter";
+proc __debug_trap      ()        #foreign __llvm_core "llvm.debugtrap";
+proc __trap            ()        #foreign __llvm_core "llvm.trap";
+proc read_cycle_counter() -> u64 #foreign __llvm_core "llvm.readcyclecounter";
 
 
 // IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
@@ -181,7 +181,7 @@ const Context = struct #ordered {
 const DEFAULT_ALIGNMENT = align_of([vector 4]f32);
 
 
-const __check_context = proc() {
+proc __check_context() {
 	var c = &__context;
 
 	if c.allocator.procedure == nil {
@@ -192,15 +192,15 @@ const __check_context = proc() {
 	}
 }
 
-const alloc = proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNMENT); }
+proc alloc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNMENT); }
 
-const alloc_align = proc(size, alignment: int) -> rawptr #inline {
+proc alloc_align(size, alignment: int) -> rawptr #inline {
 	__check_context();
 	var a = context.allocator;
 	return a.procedure(a.data, AllocatorMode.Alloc, size, alignment, nil, 0, 0);
 }
 
-const free_ptr_with_allocator = proc(a: Allocator, ptr: rawptr) #inline {
+proc free_ptr_with_allocator(a: Allocator, ptr: rawptr) #inline {
 	if ptr == nil {
 		return;
 	}
@@ -210,20 +210,20 @@ const free_ptr_with_allocator = proc(a: Allocator, ptr: rawptr) #inline {
 	a.procedure(a.data, AllocatorMode.Free, 0, 0, ptr, 0, 0);
 }
 
-const free_ptr = proc(ptr: rawptr) #inline {
+proc free_ptr(ptr: rawptr) #inline {
 	__check_context();
 	free_ptr_with_allocator(context.allocator, ptr);
 }
 
-const free_all = proc() #inline {
+proc free_all() #inline {
 	__check_context();
 	var a = context.allocator;
 	a.procedure(a.data, AllocatorMode.FreeAll, 0, 0, nil, 0, 0);
 }
 
 
-const resize       = proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT); }
-const resize_align = proc(ptr: rawptr, old_size, new_size, alignment: int) -> rawptr #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;
 	return a.procedure(a.data, AllocatorMode.Resize, new_size, alignment, ptr, old_size, 0);
@@ -231,7 +231,7 @@ const resize_align = proc(ptr: rawptr, old_size, new_size, alignment: int) -> ra
 
 
 
-const default_resize_align = proc(old_memory: rawptr, old_size, new_size, alignment: int) -> rawptr {
+proc default_resize_align(old_memory: rawptr, old_size, new_size, alignment: int) -> rawptr {
 	if old_memory == nil {
 		return alloc_align(new_size, alignment);
 	}
@@ -256,7 +256,7 @@ const default_resize_align = proc(old_memory: rawptr, old_size, new_size, alignm
 }
 
 
-const default_allocator_proc = proc(allocator_data: rawptr, mode: AllocatorMode,
+proc default_allocator_proc(allocator_data: rawptr, mode: AllocatorMode,
                                size, alignment: int,
                                old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
 	using AllocatorMode;
@@ -281,7 +281,7 @@ const default_allocator_proc = proc(allocator_data: rawptr, mode: AllocatorMode,
 	return nil;
 }
 
-const default_allocator = proc() -> Allocator {
+proc default_allocator() -> Allocator {
 	return Allocator{
 		procedure = default_allocator_proc,
 		data = nil,
@@ -296,7 +296,7 @@ const default_allocator = proc() -> Allocator {
 
 
 
-const __string_eq = proc(a, b: string) -> bool {
+proc __string_eq(a, b: string) -> bool {
 	if len(a) != len(b) {
 		return false;
 	}
@@ -309,34 +309,34 @@ const __string_eq = proc(a, b: string) -> bool {
 	return __string_cmp(a, b) == 0;
 }
 
-const __string_cmp = proc(a, b: string) -> int {
+proc __string_cmp(a, b: string) -> int {
 	return __mem_compare(&a[0], &b[0], min(len(a), len(b)));
 }
 
-const __string_ne = proc(a, b: string) -> bool #inline { return !__string_eq(a, b); }
-const __string_lt = proc(a, b: string) -> bool #inline { return __string_cmp(a, b) < 0; }
-const __string_gt = proc(a, b: string) -> bool #inline { return __string_cmp(a, b) > 0; }
-const __string_le = proc(a, b: string) -> bool #inline { return __string_cmp(a, b) <= 0; }
-const __string_ge = proc(a, b: string) -> bool #inline { return __string_cmp(a, b) >= 0; }
+proc __string_ne(a, b: string) -> bool #inline { return !__string_eq(a, b); }
+proc __string_lt(a, b: string) -> bool #inline { return __string_cmp(a, b) < 0; }
+proc __string_gt(a, b: string) -> bool #inline { return __string_cmp(a, b) > 0; }
+proc __string_le(a, b: string) -> bool #inline { return __string_cmp(a, b) <= 0; }
+proc __string_ge(a, b: string) -> bool #inline { return __string_cmp(a, b) >= 0; }
 
 
-const __complex64_eq  = proc(a, b: complex64)  -> bool #inline { return real(a) == real(b) && imag(a) == imag(b); }
-const __complex64_ne  = proc(a, b: complex64)  -> bool #inline { return real(a) != real(b) || imag(a) != imag(b); }
+proc __complex64_eq (a, b: complex64)  -> bool #inline { return real(a) == real(b) && imag(a) == imag(b); }
+proc __complex64_ne (a, b: complex64)  -> bool #inline { return real(a) != real(b) || imag(a) != imag(b); }
 
-const __complex128_eq = proc(a, b: complex128) -> bool #inline { return real(a) == real(b) && imag(a) == imag(b); }
-const __complex128_ne = proc(a, b: complex128) -> bool #inline { return real(a) != real(b) || imag(a) != imag(b); }
+proc __complex128_eq(a, b: complex128) -> bool #inline { return real(a) == real(b) && imag(a) == imag(b); }
+proc __complex128_ne(a, b: complex128) -> bool #inline { return real(a) != real(b) || imag(a) != imag(b); }
 
-const __assert = proc(file: string, line, column: int, msg: string) #inline {
+proc __assert(file: string, line, column: int, msg: string) #inline {
 	fmt.fprintf(os.stderr, "%s(%d:%d) Runtime assertion: %s\n",
 	            file, line, column, msg);
 	__debug_trap();
 }
-const __panic = proc(file: string, line, column: int, msg: string) #inline {
+proc __panic(file: string, line, column: int, msg: string) #inline {
 	fmt.fprintf(os.stderr, "%s(%d:%d) Panic: %s\n",
 	            file, line, column, msg);
 	__debug_trap();
 }
-const __bounds_check_error = proc(file: string, line, column: int, index, count: int) {
+proc __bounds_check_error(file: string, line, column: int, index, count: int) {
 	if 0 <= index && index < count {
 		return;
 	}
@@ -345,7 +345,7 @@ const __bounds_check_error = proc(file: string, line, column: int, index, count:
 	__debug_trap();
 }
 
-const __slice_expr_error = proc(file: string, line, column: int, low, high, max: int) {
+proc __slice_expr_error(file: string, line, column: int, low, high, max: int) {
 	if 0 <= low && low <= high && high <= max {
 		return;
 	}
@@ -354,7 +354,7 @@ const __slice_expr_error = proc(file: string, line, column: int, low, high, max:
 	__debug_trap();
 }
 
-const __substring_expr_error = proc(file: string, line, column: int, low, high: int) {
+proc __substring_expr_error(file: string, line, column: int, low, high: int) {
 	if 0 <= low && low <= high {
 		return;
 	}
@@ -362,7 +362,7 @@ const __substring_expr_error = proc(file: string, line, column: int, low, high:
 	            file, line, column, low, high);
 	__debug_trap();
 }
-const __type_assertion_check = proc(ok: bool, file: string, line, column: int, from, to: ^TypeInfo) {
+proc __type_assertion_check(ok: bool, file: string, line, column: int, from, to: ^TypeInfo) {
 	if !ok {
 		fmt.fprintf(os.stderr, "%s(%d:%d) Invalid type_assertion from %T to %T\n",
 		            file, line, column, from, to);
@@ -370,33 +370,33 @@ const __type_assertion_check = proc(ok: bool, file: string, line, column: int, f
 	}
 }
 
-const __string_decode_rune = proc(s: string) -> (rune, int) #inline {
+proc __string_decode_rune(s: string) -> (rune, int) #inline {
 	return utf8.decode_rune(s);
 }
 
 
-const __mem_set = proc(data: rawptr, value: i32, len: int) -> rawptr {
-	const llvm_memset_64bit = proc(dst: rawptr, val: u8, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memset.p0i8.i64";
+proc __mem_set(data: rawptr, value: i32, len: int) -> rawptr {
+	proc llvm_memset_64bit(dst: rawptr, val: u8, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memset.p0i8.i64";
 	llvm_memset_64bit(data, u8(value), len, 1, false);
 	return data;
 }
-const __mem_zero = proc(data: rawptr, len: int) -> rawptr {
+proc __mem_zero(data: rawptr, len: int) -> rawptr {
 	return __mem_set(data, 0, len);
 }
-const __mem_copy = proc(dst, src: rawptr, len: int) -> rawptr {
+proc __mem_copy(dst, src: rawptr, len: int) -> rawptr {
 	// NOTE(bill): This _must_ be implemented like C's memmove
-	const llvm_memmove_64bit = proc(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memmove.p0i8.p0i8.i64";
+	proc llvm_memmove_64bit(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memmove.p0i8.p0i8.i64";
 	llvm_memmove_64bit(dst, src, len, 1, false);
 	return dst;
 }
-const __mem_copy_non_overlapping = proc(dst, src: rawptr, len: int) -> rawptr {
+proc __mem_copy_non_overlapping(dst, src: rawptr, len: int) -> rawptr {
 	// NOTE(bill): This _must_ be implemented like C's memcpy
-	const llvm_memcpy_64bit = proc(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memcpy.p0i8.p0i8.i64";
+	proc llvm_memcpy_64bit(dst, src: rawptr, len: int, align: i32, is_volatile: bool) #foreign __llvm_core "llvm.memcpy.p0i8.p0i8.i64";
 	llvm_memcpy_64bit(dst, src, len, 1, false);
 	return dst;
 }
 
-const __mem_compare = proc(a, b: ^u8, n: int) -> int {
+proc __mem_compare(a, b: ^u8, n: int) -> int {
 	for i in 0..<n {
 		match {
 		case (a+i)^ < (b+i)^:
@@ -408,13 +408,13 @@ const __mem_compare = proc(a, b: ^u8, n: int) -> int {
 	return 0;
 }
 
-const __sqrt_f32 = proc(x: f32) -> f32 #foreign __llvm_core "llvm.sqrt.f32";
-const __sqrt_f64 = proc(x: f64) -> f64 #foreign __llvm_core "llvm.sqrt.f64";
-const __abs_complex64 = proc(x: complex64) -> f32 #inline {
+proc __sqrt_f32(x: f32) -> f32 #foreign __llvm_core "llvm.sqrt.f32";
+proc __sqrt_f64(x: f64) -> f64 #foreign __llvm_core "llvm.sqrt.f64";
+proc __abs_complex64(x: complex64) -> f32 #inline {
 	var r, i = real(x), imag(x);
 	return __sqrt_f32(r*r + i*i);
 }
-const __abs_complex128 = proc(x: complex128) -> f64 #inline {
+proc __abs_complex128(x: complex128) -> f64 #inline {
 	var r, i = real(x), imag(x);
 	return __sqrt_f64(r*r + i*i);
 }
@@ -422,7 +422,7 @@ const __abs_complex128 = proc(x: complex128) -> f64 #inline {
 
 
 
-const __dynamic_array_make = proc(array_: rawptr, elem_size, elem_align: int, len, cap: int) {
+proc __dynamic_array_make(array_: rawptr, elem_size, elem_align: int, len, cap: int) {
 	var array = ^raw.DynamicArray(array_);
 	__check_context();
 	array.allocator = context.allocator;
@@ -434,7 +434,7 @@ const __dynamic_array_make = proc(array_: rawptr, elem_size, elem_align: int, le
 	}
 }
 
-const __dynamic_array_reserve = proc(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool {
+proc __dynamic_array_reserve(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool {
 	var array = ^raw.DynamicArray(array_);
 
 	if cap <= array.cap {
@@ -461,7 +461,7 @@ const __dynamic_array_reserve = proc(array_: rawptr, elem_size, elem_align: int,
 	return true;
 }
 
-const __dynamic_array_resize = proc(array_: rawptr, elem_size, elem_align: int, len: int) -> bool {
+proc __dynamic_array_resize(array_: rawptr, elem_size, elem_align: int, len: int) -> bool {
 	var array = ^raw.DynamicArray(array_);
 
 	var ok = __dynamic_array_reserve(array_, elem_size, elem_align, len);
@@ -472,7 +472,7 @@ const __dynamic_array_resize = proc(array_: rawptr, elem_size, elem_align: int,
 }
 
 
-const __dynamic_array_append = proc(array_: rawptr, elem_size, elem_align: int,
+proc __dynamic_array_append(array_: rawptr, elem_size, elem_align: int,
                                items: rawptr, item_count: int) -> int {
 	var array = ^raw.DynamicArray(array_);
 
@@ -497,7 +497,7 @@ const __dynamic_array_append = proc(array_: rawptr, elem_size, elem_align: int,
 	return array.len;
 }
 
-const __dynamic_array_append_nothing = proc(array_: rawptr, elem_size, elem_align: int) -> int {
+proc __dynamic_array_append_nothing(array_: rawptr, elem_size, elem_align: int) -> int {
 	var array = ^raw.DynamicArray(array_);
 
 	var ok = true;
@@ -516,7 +516,7 @@ const __dynamic_array_append_nothing = proc(array_: rawptr, elem_size, elem_alig
 	return array.len;
 }
 
-const __slice_append = proc(slice_: rawptr, elem_size, elem_align: int,
+proc __slice_append(slice_: rawptr, elem_size, elem_align: int,
                        items: rawptr, item_count: int) -> int {
 	var slice = ^raw.Slice(slice_);
 
@@ -537,8 +537,8 @@ const __slice_append = proc(slice_: rawptr, elem_size, elem_align: int,
 
 // Map stuff
 
-const __default_hash = proc(data: []u8) -> u128 {
-	const fnv128a = proc(data: []u8) -> u128 {
+proc __default_hash(data: []u8) -> u128 {
+	proc fnv128a(data: []u8) -> u128 {
 		var h: u128 = 0x6c62272e07bb014262b821756295c58d;
 		for b in data {
 			h = (h ~ u128(b)) * 0x1000000000000000000013b;
@@ -547,7 +547,7 @@ const __default_hash = proc(data: []u8) -> u128 {
 	}
 	return fnv128a(data);
 }
-const __default_hash_string = proc(s: string) -> u128 {
+proc __default_hash_string(s: string) -> u128 {
 	return __default_hash([]u8(s));
 }
 
@@ -581,12 +581,12 @@ const __MapHeader = struct #ordered {
 	value_size:    int,
 }
 
-const __dynamic_map_reserve = proc(using header: __MapHeader, cap: int)  {
+proc __dynamic_map_reserve(using header: __MapHeader, cap: int)  {
 	__dynamic_array_reserve(&m.hashes, size_of(int), align_of(int), cap);
 	__dynamic_array_reserve(&m.entries, entry_size, entry_align,    cap);
 }
 
-const __dynamic_map_rehash = proc(using header: __MapHeader, new_count: int) {
+proc __dynamic_map_rehash(using header: __MapHeader, new_count: int) {
 	var new_header: __MapHeader = header;
 	var nm: raw.DynamicMap;
 	new_header.m = &nm;
@@ -631,7 +631,7 @@ const __dynamic_map_rehash = proc(using header: __MapHeader, new_count: int) {
 	header.m^ = nm;
 }
 
-const __dynamic_map_get = proc(h: __MapHeader, key: __MapKey) -> rawptr {
+proc __dynamic_map_get(h: __MapHeader, key: __MapKey) -> rawptr {
 	var index = __dynamic_map_find(h, key).entry_index;
 	if index >= 0 {
 		var data = ^u8(__dynamic_map_get_entry(h, index));
@@ -641,7 +641,7 @@ const __dynamic_map_get = proc(h: __MapHeader, key: __MapKey) -> rawptr {
 	return nil;
 }
 
-const __dynamic_map_set = proc(using h: __MapHeader, key: __MapKey, value: rawptr) {
+proc __dynamic_map_set(using h: __MapHeader, key: __MapKey, value: rawptr) {
 	var index: int;
 	assert(value != nil);
 
@@ -676,17 +676,17 @@ const __dynamic_map_set = proc(using h: __MapHeader, key: __MapKey, value: rawpt
 }
 
 
-const __dynamic_map_grow = proc(using h: __MapHeader) {
+proc __dynamic_map_grow(using h: __MapHeader) {
 	var new_count = max(2*m.entries.cap + 8, __INITIAL_MAP_CAP);
 	__dynamic_map_rehash(h, new_count);
 }
 
-const __dynamic_map_full = proc(using h: __MapHeader) -> bool {
+proc __dynamic_map_full(using h: __MapHeader) -> bool {
 	return int(0.75 * f64(len(m.hashes))) <= m.entries.cap;
 }
 
 
-const __dynamic_map_hash_equal = proc(h: __MapHeader, a, b: __MapKey) -> bool {
+proc __dynamic_map_hash_equal(h: __MapHeader, a, b: __MapKey) -> bool {
 	if a.hash == b.hash {
 		if h.is_key_string {
 			return a.str == b.str;
@@ -696,7 +696,7 @@ const __dynamic_map_hash_equal = proc(h: __MapHeader, a, b: __MapKey) -> bool {
 	return false;
 }
 
-const __dynamic_map_find = proc(using h: __MapHeader, key: __MapKey) -> __MapFindResult {
+proc __dynamic_map_find(using h: __MapHeader, key: __MapKey) -> __MapFindResult {
 	var fr = __MapFindResult{-1, -1, -1};
 	if len(m.hashes) > 0 {
 		fr.hash_index = int(key.hash % u128(len(m.hashes)));
@@ -713,7 +713,7 @@ const __dynamic_map_find = proc(using h: __MapHeader, key: __MapKey) -> __MapFin
 	return fr;
 }
 
-const __dynamic_map_add_entry = proc(using h: __MapHeader, key: __MapKey) -> int {
+proc __dynamic_map_add_entry(using h: __MapHeader, key: __MapKey) -> int {
 	var prev = m.entries.len;
 	var c = __dynamic_array_append_nothing(&m.entries, entry_size, entry_align);
 	if c != prev {
@@ -725,19 +725,19 @@ const __dynamic_map_add_entry = proc(using h: __MapHeader, key: __MapKey) -> int
 }
 
 
-const __dynamic_map_delete = proc(using h: __MapHeader, key: __MapKey) {
+proc __dynamic_map_delete(using h: __MapHeader, key: __MapKey) {
 	var fr = __dynamic_map_find(h, key);
 	if fr.entry_index >= 0 {
 		__dynamic_map_erase(h, fr);
 	}
 }
 
-const __dynamic_map_get_entry = proc(using h: __MapHeader, index: int) -> ^__MapEntryHeader {
+proc __dynamic_map_get_entry(using h: __MapHeader, index: int) -> ^__MapEntryHeader {
 	var data = ^u8(m.entries.data) + index*entry_size;
 	return ^__MapEntryHeader(data);
 }
 
-const __dynamic_map_erase = proc(using h: __MapHeader, fr: __MapFindResult) {
+proc __dynamic_map_erase(using h: __MapHeader, fr: __MapFindResult) {
 	if fr.entry_prev < 0 {
 		m.hashes[fr.hash_index] = __dynamic_map_get_entry(h, fr.entry_index).next;
 	} else {

+ 11 - 11
core/_soft_numbers.odin

@@ -1,26 +1,26 @@
 #shared_global_scope;
 
-const __u128_mod = proc(a, b: u128) -> u128 #cc_odin #link_name "__umodti3" {
+proc __u128_mod(a, b: u128) -> u128 #cc_odin #link_name "__umodti3" {
 	var r: u128;
 	__u128_quo_mod(a, b, &r);
 	return r;
 }
 
-const __u128_quo = proc(a, b: u128) -> u128 #cc_odin #link_name "__udivti3" {
+proc __u128_quo(a, b: u128) -> u128 #cc_odin #link_name "__udivti3" {
 	return __u128_quo_mod(a, b, nil);
 }
 
-const __i128_mod = proc(a, b: i128) -> i128 #cc_odin #link_name "__modti3" {
+proc __i128_mod(a, b: i128) -> i128 #cc_odin #link_name "__modti3" {
 	var r: i128;
 	__i128_quo_mod(a, b, &r);
 	return r;
 }
 
-const __i128_quo = proc(a, b: i128) -> i128 #cc_odin #link_name "__divti3" {
+proc __i128_quo(a, b: i128) -> i128 #cc_odin #link_name "__divti3" {
 	return __i128_quo_mod(a, b, nil);
 }
 
-const __i128_quo_mod = proc(a, b: i128, rem: ^i128) -> (quo: i128) #cc_odin #link_name "__divmodti4" {
+proc __i128_quo_mod(a, b: i128, rem: ^i128) -> (quo: i128) #cc_odin #link_name "__divmodti4" {
 	var s: i128;
 	s = b >> 127;
 	b = (b~s) - s;
@@ -39,7 +39,7 @@ const __i128_quo_mod = proc(a, b: i128, rem: ^i128) -> (quo: i128) #cc_odin #lin
 }
 
 
-const __u128_quo_mod = proc(a, b: u128, rem: ^u128) -> (quo: u128) #cc_odin #link_name "__udivmodti4" {
+proc __u128_quo_mod(a, b: u128, rem: ^u128) -> (quo: u128) #cc_odin #link_name "__udivmodti4" {
 	var alo, ahi = u64(a), u64(a>>64);
 	var blo, bhi = u64(b), u64(b>>64);
 	if b == 0 {
@@ -68,7 +68,7 @@ const __u128_quo_mod = proc(a, b: u128, rem: ^u128) -> (quo: u128) #cc_odin #lin
 }
 
 /*
-const __f16_to_f32 = proc(f: f16) -> f32 #cc_odin #no_inline #link_name "__gnu_h2f_ieee" {
+proc __f16_to_f32(f: f16) -> f32 #cc_odin #no_inline #link_name "__gnu_h2f_ieee" {
 	when true {
 		// Source: https://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/
 		const FP32 = raw_union {u: u32, f: f32};
@@ -81,7 +81,7 @@ const __f16_to_f32 = proc(f: f16) -> f32 #cc_odin #no_inline #link_name "__gnu_h
 
 		o := FP32{};
 
-		o.u = u32((hu & 0x7fff) << 13);
+		o.u = u32(hu & 0x7fff) << 13);
 		o.f *= magic.f;
 		if o.f >= was_infnan.f {
 			o.u |= 255 << 23;
@@ -92,7 +92,7 @@ const __f16_to_f32 = proc(f: f16) -> f32 #cc_odin #no_inline #link_name "__gnu_h
 		return 0;
 	}
 }
-const __f32_to_f16 = proc(f_: f32) -> f16 #cc_odin #no_inline #link_name "__gnu_f2h_ieee" {
+proc __f32_to_f16(f_: f32) -> f16 #cc_odin #no_inline #link_name "__gnu_f2h_ieee" {
 	when false {
 		// Source: https://gist.github.com/rygorous/2156668
 		const FP16 = raw_union {u: u16, f: f16};
@@ -182,11 +182,11 @@ const __f32_to_f16 = proc(f_: f32) -> f16 #cc_odin #no_inline #link_name "__gnu_
 	}
 }
 
-const __f64_to_f16 = proc(f: f64) -> f16 #cc_odin #no_inline #link_name "__truncdfhf2" {
+proc __f64_to_f16(f: f64) -> f16 #cc_odin #no_inline #link_name "__truncdfhf2" {
 	return __f32_to_f16(f32(f));
 }
 
-const __f16_to_f64 = proc(f: f16) -> f64 #cc_odin #no_inline {
+proc __f16_to_f64(f: f16) -> f64 #cc_odin #no_inline {
 	return f64(__f16_to_f32(f));
 }
 */

+ 24 - 24
core/atomics.odin

@@ -5,35 +5,35 @@
 var _ = compile_assert(ODIN_ARCH == "amd64"); // TODO(bill): x86 version
 
 
-const yield_thread = proc() { win32.mm_pause(); }
-const mfence       = proc() { win32.read_write_barrier(); }
-const sfence       = proc() { win32.write_barrier(); }
-const lfence       = proc() { win32.read_barrier(); }
+proc yield_thread() { win32.mm_pause(); }
+proc mfence      () { win32.read_write_barrier(); }
+proc sfence      () { win32.write_barrier(); }
+proc lfence      () { win32.read_barrier(); }
 
 
-const load = proc(a: ^i32) -> i32 {
+proc load(a: ^i32) -> i32 {
 	return a^;
 }
-const store = proc(a: ^i32, value: i32) {
+proc store(a: ^i32, value: i32) {
 	a^ = value;
 }
-const compare_exchange = proc(a: ^i32, expected, desired: i32) -> i32 {
+proc compare_exchange(a: ^i32, expected, desired: i32) -> i32 {
 	return win32.interlocked_compare_exchange(a, desired, expected);
 }
-const exchanged = proc(a: ^i32, desired: i32) -> i32 {
+proc exchanged(a: ^i32, desired: i32) -> i32 {
 	return win32.interlocked_exchange(a, desired);
 }
-const fetch_add = proc(a: ^i32, operand: i32) -> i32 {
+proc fetch_add(a: ^i32, operand: i32) -> i32 {
 	return win32.interlocked_exchange_add(a, operand);
 
 }
-const fetch_and = proc(a: ^i32, operand: i32) -> i32 {
+proc fetch_and(a: ^i32, operand: i32) -> i32 {
 	return win32.interlocked_and(a, operand);
 }
-const fetch_or = proc(a: ^i32, operand: i32) -> i32 {
+proc fetch_or(a: ^i32, operand: i32) -> i32 {
 	return win32.interlocked_or(a, operand);
 }
-const spin_lock = proc(a: ^i32, time_out: int) -> bool { // NOTE(bill) time_out = -1 as default
+proc spin_lock(a: ^i32, time_out: int) -> bool { // NOTE(bill) time_out = -1 as default
 	var old_value = compare_exchange(a, 1, 0);
 	var counter = 0;
 	for old_value != 0 && (time_out < 0 || counter < time_out) {
@@ -44,11 +44,11 @@ const spin_lock = proc(a: ^i32, time_out: int) -> bool { // NOTE(bill) time_out
 	}
 	return old_value == 0;
 }
-const spin_unlock = proc(a: ^i32) {
+proc spin_unlock(a: ^i32) {
 	store(a, 0);
 	mfence();
 }
-const try_acquire_lock = proc(a: ^i32) -> bool {
+proc try_acquire_lock(a: ^i32) -> bool {
 	yield_thread();
 	var old_value = compare_exchange(a, 1, 0);
 	mfence();
@@ -56,28 +56,28 @@ const try_acquire_lock = proc(a: ^i32) -> bool {
 }
 
 
-const load = proc(a: ^i64) -> i64 {
+proc load(a: ^i64) -> i64 {
 	return a^;
 }
-const store = proc(a: ^i64, value: i64) {
+proc store(a: ^i64, value: i64) {
 	a^ = value;
 }
-const compare_exchange = proc(a: ^i64, expected, desired: i64) -> i64 {
+proc compare_exchange(a: ^i64, expected, desired: i64) -> i64 {
 	return win32.interlocked_compare_exchange64(a, desired, expected);
 }
-const exchanged = proc(a: ^i64, desired: i64) -> i64 {
+proc exchanged(a: ^i64, desired: i64) -> i64 {
 	return win32.interlocked_exchange64(a, desired);
 }
-const fetch_add = proc(a: ^i64, operand: i64) -> i64 {
+proc fetch_add(a: ^i64, operand: i64) -> i64 {
 	return win32.interlocked_exchange_add64(a, operand);
 }
-const fetch_and = proc(a: ^i64, operand: i64) -> i64 {
+proc fetch_and(a: ^i64, operand: i64) -> i64 {
 	return win32.interlocked_and64(a, operand);
 }
-const fetch_or = proc(a: ^i64, operand: i64) -> i64 {
+proc fetch_or(a: ^i64, operand: i64) -> i64 {
 	return win32.interlocked_or64(a, operand);
 }
-const spin_lock = proc(a: ^i64, time_out: int) -> bool { // NOTE(bill) time_out = -1 as default
+proc spin_lock(a: ^i64, time_out: int) -> bool { // NOTE(bill) time_out = -1 as default
 	var old_value = compare_exchange(a, 1, 0);
 	var counter = 0;
 	for old_value != 0 && (time_out < 0 || counter < time_out) {
@@ -88,11 +88,11 @@ const spin_lock = proc(a: ^i64, time_out: int) -> bool { // NOTE(bill) time_out
 	}
 	return old_value == 0;
 }
-const spin_unlock = proc(a: ^i64) {
+proc spin_unlock(a: ^i64) {
 	store(a, 0);
 	mfence();
 }
-const try_acquire_lock = proc(a: ^i64) -> bool {
+proc try_acquire_lock(a: ^i64) -> bool {
 	yield_thread();
 	var old_value = compare_exchange(a, 1, 0);
 	mfence();

+ 190 - 190
core/bits.odin

@@ -23,179 +23,179 @@ const I64_MAX  =  i64(0x7fff_ffff_ffff_ffff);
 const I128_MAX = i128(0x7fff_ffff_ffff_ffff_ffff_ffff_ffff_ffff);
 
 
-const count_ones = proc(i:   u8) ->   u8 { const __llvm_ctpop = proc(u8)   ->   u8 #foreign __llvm_core "llvm.ctpop.i8";  return __llvm_ctpop(i); }
-const count_ones = proc(i:   i8) ->   i8 { const __llvm_ctpop = proc(i8)   ->   i8 #foreign __llvm_core "llvm.ctpop.i8";  return __llvm_ctpop(i); }
-const count_ones = proc(i:  u16) ->  u16 { const __llvm_ctpop = proc(u16)  ->  u16 #foreign __llvm_core "llvm.ctpop.i16"; return __llvm_ctpop(i); }
-const count_ones = proc(i:  i16) ->  i16 { const __llvm_ctpop = proc(i16)  ->  i16 #foreign __llvm_core "llvm.ctpop.i16"; return __llvm_ctpop(i); }
-const count_ones = proc(i:  u32) ->  u32 { const __llvm_ctpop = proc(u32)  ->  u32 #foreign __llvm_core "llvm.ctpop.i32"; return __llvm_ctpop(i); }
-const count_ones = proc(i:  i32) ->  i32 { const __llvm_ctpop = proc(i32)  ->  i32 #foreign __llvm_core "llvm.ctpop.i32"; return __llvm_ctpop(i); }
-const count_ones = proc(i:  u64) ->  u64 { const __llvm_ctpop = proc(u64)  ->  u64 #foreign __llvm_core "llvm.ctpop.i64"; return __llvm_ctpop(i); }
-const count_ones = proc(i:  i64) ->  i64 { const __llvm_ctpop = proc(i64)  ->  i64 #foreign __llvm_core "llvm.ctpop.i64"; return __llvm_ctpop(i); }
-const count_ones = proc(i: u128) -> u128 { const __llvm_ctpop = proc(u128) -> u128 #foreign __llvm_core "llvm.ctpop.i128";return __llvm_ctpop(i); }
-const count_ones = proc(i: i128) -> i128 { const __llvm_ctpop = proc(i128) -> i128 #foreign __llvm_core "llvm.ctpop.i128";return __llvm_ctpop(i); }
-const count_ones = proc(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(count_ones(u32(i))); } else { return uint(count_ones(u64(i))); } }
-const count_ones = proc(i:  int) ->  int { when size_of(int)  == size_of(i32) { return int(count_ones(i32(i))); } else { return int(count_ones(i64(i))); } }
+proc count_ones(i:   u8) ->   u8 { proc __llvm_ctpop(u8)   ->   u8 #foreign __llvm_core "llvm.ctpop.i8";  return __llvm_ctpop(i); }
+proc count_ones(i:   i8) ->   i8 { proc __llvm_ctpop(i8)   ->   i8 #foreign __llvm_core "llvm.ctpop.i8";  return __llvm_ctpop(i); }
+proc count_ones(i:  u16) ->  u16 { proc __llvm_ctpop(u16)  ->  u16 #foreign __llvm_core "llvm.ctpop.i16"; return __llvm_ctpop(i); }
+proc count_ones(i:  i16) ->  i16 { proc __llvm_ctpop(i16)  ->  i16 #foreign __llvm_core "llvm.ctpop.i16"; return __llvm_ctpop(i); }
+proc count_ones(i:  u32) ->  u32 { proc __llvm_ctpop(u32)  ->  u32 #foreign __llvm_core "llvm.ctpop.i32"; return __llvm_ctpop(i); }
+proc count_ones(i:  i32) ->  i32 { proc __llvm_ctpop(i32)  ->  i32 #foreign __llvm_core "llvm.ctpop.i32"; return __llvm_ctpop(i); }
+proc count_ones(i:  u64) ->  u64 { proc __llvm_ctpop(u64)  ->  u64 #foreign __llvm_core "llvm.ctpop.i64"; return __llvm_ctpop(i); }
+proc count_ones(i:  i64) ->  i64 { proc __llvm_ctpop(i64)  ->  i64 #foreign __llvm_core "llvm.ctpop.i64"; return __llvm_ctpop(i); }
+proc count_ones(i: u128) -> u128 { proc __llvm_ctpop(u128) -> u128 #foreign __llvm_core "llvm.ctpop.i128";return __llvm_ctpop(i); }
+proc count_ones(i: i128) -> i128 { proc __llvm_ctpop(i128) -> i128 #foreign __llvm_core "llvm.ctpop.i128";return __llvm_ctpop(i); }
+proc count_ones(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(count_ones(u32(i))); } else { return uint(count_ones(u64(i))); } }
+proc count_ones(i:  int) ->  int { when size_of(int)  == size_of(i32) { return int(count_ones(i32(i)));  } else { return int(count_ones(i64(i))); } }
 
-const count_zeros = proc(i:   u8) ->   u8 { return   8 - count_ones(i); }
-const count_zeros = proc(i:   i8) ->   i8 { return   8 - count_ones(i); }
-const count_zeros = proc(i:  u16) ->  u16 { return  16 - count_ones(i); }
-const count_zeros = proc(i:  i16) ->  i16 { return  16 - count_ones(i); }
-const count_zeros = proc(i:  u32) ->  u32 { return  32 - count_ones(i); }
-const count_zeros = proc(i:  i32) ->  i32 { return  32 - count_ones(i); }
-const count_zeros = proc(i:  u64) ->  u64 { return  64 - count_ones(i); }
-const count_zeros = proc(i:  i64) ->  i64 { return  64 - count_ones(i); }
-const count_zeros = proc(i: u128) -> u128 { return 128 - count_ones(i); }
-const count_zeros = proc(i: i128) -> i128 { return 128 - count_ones(i); }
-const count_zeros = proc(i: uint) -> uint { return 8*size_of(uint) - count_ones(i); }
-const count_zeros = proc(i:  int) ->  int { return 8*size_of(int)  - count_ones(i); }
+proc count_zeros(i:   u8) ->   u8 { return   8 - count_ones(i); }
+proc count_zeros(i:   i8) ->   i8 { return   8 - count_ones(i); }
+proc count_zeros(i:  u16) ->  u16 { return  16 - count_ones(i); }
+proc count_zeros(i:  i16) ->  i16 { return  16 - count_ones(i); }
+proc count_zeros(i:  u32) ->  u32 { return  32 - count_ones(i); }
+proc count_zeros(i:  i32) ->  i32 { return  32 - count_ones(i); }
+proc count_zeros(i:  u64) ->  u64 { return  64 - count_ones(i); }
+proc count_zeros(i:  i64) ->  i64 { return  64 - count_ones(i); }
+proc count_zeros(i: u128) -> u128 { return 128 - count_ones(i); }
+proc count_zeros(i: i128) -> i128 { return 128 - count_ones(i); }
+proc count_zeros(i: uint) -> uint { return 8*size_of(uint) - count_ones(i); }
+proc count_zeros(i:  int) ->  int { return 8*size_of(int)  - count_ones(i); }
 
 
-const rotate_left = proc(i: u8,   s: uint) ->   u8 { return (i << s)|(i >> (8*size_of(u8)   - s)); }
-const rotate_left = proc(i: i8,   s: uint) ->   i8 { return (i << s)|(i >> (8*size_of(i8)   - s)); }
-const rotate_left = proc(i: u16,  s: uint) ->  u16 { return (i << s)|(i >> (8*size_of(u16)  - s)); }
-const rotate_left = proc(i: i16,  s: uint) ->  i16 { return (i << s)|(i >> (8*size_of(i16)  - s)); }
-const rotate_left = proc(i: u32,  s: uint) ->  u32 { return (i << s)|(i >> (8*size_of(u32)  - s)); }
-const rotate_left = proc(i: i32,  s: uint) ->  i32 { return (i << s)|(i >> (8*size_of(i32)  - s)); }
-const rotate_left = proc(i: u64,  s: uint) ->  u64 { return (i << s)|(i >> (8*size_of(u64)  - s)); }
-const rotate_left = proc(i: i64,  s: uint) ->  i64 { return (i << s)|(i >> (8*size_of(i64)  - s)); }
-const rotate_left = proc(i: u128, s: uint) -> u128 { return (i << s)|(i >> (8*size_of(u128) - s)); }
-const rotate_left = proc(i: i128, s: uint) -> i128 { return (i << s)|(i >> (8*size_of(i128) - s)); }
-const rotate_left = proc(i: uint, s: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(rotate_left(u32(i), s)); } else { return uint(rotate_left(u64(i), s)); } }
-const rotate_left = proc(i:  int, s: uint) ->  int { when size_of(int)  == size_of(i32) { return  int(rotate_left(i32(i), s)); } else { return  int(rotate_left(i64(i), s)); } }
+proc rotate_left(i: u8,   s: uint) ->   u8 { return (i << s)|(i >> (8*size_of(u8)   - s)); }
+proc rotate_left(i: i8,   s: uint) ->   i8 { return (i << s)|(i >> (8*size_of(i8)   - s)); }
+proc rotate_left(i: u16,  s: uint) ->  u16 { return (i << s)|(i >> (8*size_of(u16)  - s)); }
+proc rotate_left(i: i16,  s: uint) ->  i16 { return (i << s)|(i >> (8*size_of(i16)  - s)); }
+proc rotate_left(i: u32,  s: uint) ->  u32 { return (i << s)|(i >> (8*size_of(u32)  - s)); }
+proc rotate_left(i: i32,  s: uint) ->  i32 { return (i << s)|(i >> (8*size_of(i32)  - s)); }
+proc rotate_left(i: u64,  s: uint) ->  u64 { return (i << s)|(i >> (8*size_of(u64)  - s)); }
+proc rotate_left(i: i64,  s: uint) ->  i64 { return (i << s)|(i >> (8*size_of(i64)  - s)); }
+proc rotate_left(i: u128, s: uint) -> u128 { return (i << s)|(i >> (8*size_of(u128) - s)); }
+proc rotate_left(i: i128, s: uint) -> i128 { return (i << s)|(i >> (8*size_of(i128) - s)); }
+proc rotate_left(i: uint, s: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(rotate_left(u32(i), s)); } else { return uint(rotate_left(u64(i), s)); } }
+proc rotate_left(i:  int, s: uint) ->  int { when size_of(int)  == size_of(i32) { return  int(rotate_left(i32(i), s)); } else { return  int(rotate_left(i64(i), s)); } }
 
 
-const rotate_right = proc(i: u8,   s: uint) ->   u8 { return (i >> s)|(i << (8*size_of(u8)   - s)); }
-const rotate_right = proc(i: i8,   s: uint) ->   i8 { return (i >> s)|(i << (8*size_of(i8)   - s)); }
-const rotate_right = proc(i: u16,  s: uint) ->  u16 { return (i >> s)|(i << (8*size_of(u16)  - s)); }
-const rotate_right = proc(i: i16,  s: uint) ->  i16 { return (i >> s)|(i << (8*size_of(i16)  - s)); }
-const rotate_right = proc(i: u32,  s: uint) ->  u32 { return (i >> s)|(i << (8*size_of(u32)  - s)); }
-const rotate_right = proc(i: i32,  s: uint) ->  i32 { return (i >> s)|(i << (8*size_of(i32)  - s)); }
-const rotate_right = proc(i: u64,  s: uint) ->  u64 { return (i >> s)|(i << (8*size_of(u64)  - s)); }
-const rotate_right = proc(i: i64,  s: uint) ->  i64 { return (i >> s)|(i << (8*size_of(i64)  - s)); }
-const rotate_right = proc(i: u128, s: uint) -> u128 { return (i >> s)|(i << (8*size_of(u128) - s)); }
-const rotate_right = proc(i: i128, s: uint) -> i128 { return (i >> s)|(i << (8*size_of(i128) - s)); }
-const rotate_right = proc(i: uint, s: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(rotate_right(u32(i), s)); } else { return uint(rotate_right(u64(i), s)); } }
-const rotate_right = proc(i:  int, s: uint) ->  int { when size_of(int)  == size_of(i32) { return  int(rotate_right(i32(i), s)); } else { return  int(rotate_right(i64(i), s)); } }
+proc rotate_right(i: u8,   s: uint) ->   u8 { return (i >> s)|(i << (8*size_of(u8)   - s)); }
+proc rotate_right(i: i8,   s: uint) ->   i8 { return (i >> s)|(i << (8*size_of(i8)   - s)); }
+proc rotate_right(i: u16,  s: uint) ->  u16 { return (i >> s)|(i << (8*size_of(u16)  - s)); }
+proc rotate_right(i: i16,  s: uint) ->  i16 { return (i >> s)|(i << (8*size_of(i16)  - s)); }
+proc rotate_right(i: u32,  s: uint) ->  u32 { return (i >> s)|(i << (8*size_of(u32)  - s)); }
+proc rotate_right(i: i32,  s: uint) ->  i32 { return (i >> s)|(i << (8*size_of(i32)  - s)); }
+proc rotate_right(i: u64,  s: uint) ->  u64 { return (i >> s)|(i << (8*size_of(u64)  - s)); }
+proc rotate_right(i: i64,  s: uint) ->  i64 { return (i >> s)|(i << (8*size_of(i64)  - s)); }
+proc rotate_right(i: u128, s: uint) -> u128 { return (i >> s)|(i << (8*size_of(u128) - s)); }
+proc rotate_right(i: i128, s: uint) -> i128 { return (i >> s)|(i << (8*size_of(i128) - s)); }
+proc rotate_right(i: uint, s: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(rotate_right(u32(i), s)); } else { return uint(rotate_right(u64(i), s)); } }
+proc rotate_right(i:  int, s: uint) ->  int { when size_of(int)  == size_of(i32) { return  int(rotate_right(i32(i), s)); } else { return  int(rotate_right(i64(i), s)); } }
 
 
-const leading_zeros = proc(i:   u8) ->   u8 { const __llvm_ctlz = proc(u8,   bool) ->   u8 #foreign __llvm_core "llvm.ctlz.i8";  return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:   i8) ->   i8 { const __llvm_ctlz = proc(i8,   bool) ->   i8 #foreign __llvm_core "llvm.ctlz.i8";  return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  u16) ->  u16 { const __llvm_ctlz = proc(u16,  bool) ->  u16 #foreign __llvm_core "llvm.ctlz.i16"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  i16) ->  i16 { const __llvm_ctlz = proc(i16,  bool) ->  i16 #foreign __llvm_core "llvm.ctlz.i16"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  u32) ->  u32 { const __llvm_ctlz = proc(u32,  bool) ->  u32 #foreign __llvm_core "llvm.ctlz.i32"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  i32) ->  i32 { const __llvm_ctlz = proc(i32,  bool) ->  i32 #foreign __llvm_core "llvm.ctlz.i32"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  u64) ->  u64 { const __llvm_ctlz = proc(u64,  bool) ->  u64 #foreign __llvm_core "llvm.ctlz.i64"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i:  i64) ->  i64 { const __llvm_ctlz = proc(i64,  bool) ->  i64 #foreign __llvm_core "llvm.ctlz.i64"; return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i: u128) -> u128 { const __llvm_ctlz = proc(u128, bool) -> u128 #foreign __llvm_core "llvm.ctlz.i128";return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i: i128) -> i128 { const __llvm_ctlz = proc(i128, bool) -> i128 #foreign __llvm_core "llvm.ctlz.i128";return __llvm_ctlz(i, false); }
-const leading_zeros = proc(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(leading_zeros(u32(i))); } else { return uint(leading_zeros(u64(i))); } }
-const leading_zeros = proc(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(leading_zeros(i32(i))); } else { return  int(leading_zeros(i64(i))); } }
+proc leading_zeros(i:   u8) ->   u8 { proc __llvm_ctlz(u8,   bool) ->   u8 #foreign __llvm_core "llvm.ctlz.i8";  return __llvm_ctlz(i, false); }
+proc leading_zeros(i:   i8) ->   i8 { proc __llvm_ctlz(i8,   bool) ->   i8 #foreign __llvm_core "llvm.ctlz.i8";  return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  u16) ->  u16 { proc __llvm_ctlz(u16,  bool) ->  u16 #foreign __llvm_core "llvm.ctlz.i16"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  i16) ->  i16 { proc __llvm_ctlz(i16,  bool) ->  i16 #foreign __llvm_core "llvm.ctlz.i16"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  u32) ->  u32 { proc __llvm_ctlz(u32,  bool) ->  u32 #foreign __llvm_core "llvm.ctlz.i32"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  i32) ->  i32 { proc __llvm_ctlz(i32,  bool) ->  i32 #foreign __llvm_core "llvm.ctlz.i32"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  u64) ->  u64 { proc __llvm_ctlz(u64,  bool) ->  u64 #foreign __llvm_core "llvm.ctlz.i64"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i:  i64) ->  i64 { proc __llvm_ctlz(i64,  bool) ->  i64 #foreign __llvm_core "llvm.ctlz.i64"; return __llvm_ctlz(i, false); }
+proc leading_zeros(i: u128) -> u128 { proc __llvm_ctlz(u128, bool) -> u128 #foreign __llvm_core "llvm.ctlz.i128";return __llvm_ctlz(i, false); }
+proc leading_zeros(i: i128) -> i128 { proc __llvm_ctlz(i128, bool) -> i128 #foreign __llvm_core "llvm.ctlz.i128";return __llvm_ctlz(i, false); }
+proc leading_zeros(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(leading_zeros(u32(i))); } else { return uint(leading_zeros(u64(i))); } }
+proc leading_zeros(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(leading_zeros(i32(i))); } else { return  int(leading_zeros(i64(i))); } }
 
-const trailing_zeros = proc(i:   u8) ->   u8 { const __llvm_cttz = proc(u8,   bool) ->   u8 #foreign __llvm_core "llvm.cttz.i8";  return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:   i8) ->   i8 { const __llvm_cttz = proc(i8,   bool) ->   i8 #foreign __llvm_core "llvm.cttz.i8";  return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  u16) ->  u16 { const __llvm_cttz = proc(u16,  bool) ->  u16 #foreign __llvm_core "llvm.cttz.i16"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  i16) ->  i16 { const __llvm_cttz = proc(i16,  bool) ->  i16 #foreign __llvm_core "llvm.cttz.i16"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  u32) ->  u32 { const __llvm_cttz = proc(u32,  bool) ->  u32 #foreign __llvm_core "llvm.cttz.i32"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  i32) ->  i32 { const __llvm_cttz = proc(i32,  bool) ->  i32 #foreign __llvm_core "llvm.cttz.i32"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  u64) ->  u64 { const __llvm_cttz = proc(u64,  bool) ->  u64 #foreign __llvm_core "llvm.cttz.i64"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i:  i64) ->  i64 { const __llvm_cttz = proc(i64,  bool) ->  i64 #foreign __llvm_core "llvm.cttz.i64"; return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i: u128) -> u128 { const __llvm_cttz = proc(u128, bool) -> u128 #foreign __llvm_core "llvm.cttz.i128";return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i: i128) -> i128 { const __llvm_cttz = proc(i128, bool) -> i128 #foreign __llvm_core "llvm.cttz.i128";return __llvm_cttz(i, false); }
-const trailing_zeros = proc(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(trailing_zeros(u32(i))); } else { return uint(trailing_zeros(u64(i))); } }
-const trailing_zeros = proc(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(trailing_zeros(i32(i))); } else { return  int(trailing_zeros(i64(i))); } }
+proc trailing_zeros(i:   u8) ->   u8 { proc __llvm_cttz(u8,   bool) ->   u8 #foreign __llvm_core "llvm.cttz.i8";  return __llvm_cttz(i, false); }
+proc trailing_zeros(i:   i8) ->   i8 { proc __llvm_cttz(i8,   bool) ->   i8 #foreign __llvm_core "llvm.cttz.i8";  return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  u16) ->  u16 { proc __llvm_cttz(u16,  bool) ->  u16 #foreign __llvm_core "llvm.cttz.i16"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  i16) ->  i16 { proc __llvm_cttz(i16,  bool) ->  i16 #foreign __llvm_core "llvm.cttz.i16"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  u32) ->  u32 { proc __llvm_cttz(u32,  bool) ->  u32 #foreign __llvm_core "llvm.cttz.i32"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  i32) ->  i32 { proc __llvm_cttz(i32,  bool) ->  i32 #foreign __llvm_core "llvm.cttz.i32"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  u64) ->  u64 { proc __llvm_cttz(u64,  bool) ->  u64 #foreign __llvm_core "llvm.cttz.i64"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i:  i64) ->  i64 { proc __llvm_cttz(i64,  bool) ->  i64 #foreign __llvm_core "llvm.cttz.i64"; return __llvm_cttz(i, false); }
+proc trailing_zeros(i: u128) -> u128 { proc __llvm_cttz(u128, bool) -> u128 #foreign __llvm_core "llvm.cttz.i128";return __llvm_cttz(i, false); }
+proc trailing_zeros(i: i128) -> i128 { proc __llvm_cttz(i128, bool) -> i128 #foreign __llvm_core "llvm.cttz.i128";return __llvm_cttz(i, false); }
+proc trailing_zeros(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(trailing_zeros(u32(i))); } else { return uint(trailing_zeros(u64(i))); } }
+proc trailing_zeros(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(trailing_zeros(i32(i))); } else { return  int(trailing_zeros(i64(i))); } }
 
 
-const reverse_bits = proc(i:   u8) ->   u8 { const __llvm_bitreverse = proc(u8)   ->   u8 #foreign __llvm_core "llvm.bitreverse.i8";  return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:   i8) ->   i8 { const __llvm_bitreverse = proc(i8)   ->   i8 #foreign __llvm_core "llvm.bitreverse.i8";  return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  u16) ->  u16 { const __llvm_bitreverse = proc(u16)  ->  u16 #foreign __llvm_core "llvm.bitreverse.i16"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  i16) ->  i16 { const __llvm_bitreverse = proc(i16)  ->  i16 #foreign __llvm_core "llvm.bitreverse.i16"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  u32) ->  u32 { const __llvm_bitreverse = proc(u32)  ->  u32 #foreign __llvm_core "llvm.bitreverse.i32"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  i32) ->  i32 { const __llvm_bitreverse = proc(i32)  ->  i32 #foreign __llvm_core "llvm.bitreverse.i32"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  u64) ->  u64 { const __llvm_bitreverse = proc(u64)  ->  u64 #foreign __llvm_core "llvm.bitreverse.i64"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i:  i64) ->  i64 { const __llvm_bitreverse = proc(i64)  ->  i64 #foreign __llvm_core "llvm.bitreverse.i64"; return __llvm_bitreverse(i); }
-const reverse_bits = proc(i: u128) -> u128 { const __llvm_bitreverse = proc(u128) -> u128 #foreign __llvm_core "llvm.bitreverse.i128";return __llvm_bitreverse(i); }
-const reverse_bits = proc(i: i128) -> i128 { const __llvm_bitreverse = proc(i128) -> i128 #foreign __llvm_core "llvm.bitreverse.i128";return __llvm_bitreverse(i); }
-const reverse_bits = proc(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(reverse_bits(u32(i))); } else { return uint(reverse_bits(u64(i))); } }
-const reverse_bits = proc(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(reverse_bits(i32(i))); } else { return  int(reverse_bits(i64(i))); } }
+proc reverse_bits(i:   u8) ->   u8 { proc __llvm_bitreverse(u8)   ->   u8 #foreign __llvm_core "llvm.bitreverse.i8";  return __llvm_bitreverse(i); }
+proc reverse_bits(i:   i8) ->   i8 { proc __llvm_bitreverse(i8)   ->   i8 #foreign __llvm_core "llvm.bitreverse.i8";  return __llvm_bitreverse(i); }
+proc reverse_bits(i:  u16) ->  u16 { proc __llvm_bitreverse(u16)  ->  u16 #foreign __llvm_core "llvm.bitreverse.i16"; return __llvm_bitreverse(i); }
+proc reverse_bits(i:  i16) ->  i16 { proc __llvm_bitreverse(i16)  ->  i16 #foreign __llvm_core "llvm.bitreverse.i16"; return __llvm_bitreverse(i); }
+proc reverse_bits(i:  u32) ->  u32 { proc __llvm_bitreverse(u32)  ->  u32 #foreign __llvm_core "llvm.bitreverse.i32"; return __llvm_bitreverse(i); }
+proc reverse_bits(i:  i32) ->  i32 { proc __llvm_bitreverse(i32)  ->  i32 #foreign __llvm_core "llvm.bitreverse.i32"; return __llvm_bitreverse(i); }
+proc reverse_bits(i:  u64) ->  u64 { proc __llvm_bitreverse(u64)  ->  u64 #foreign __llvm_core "llvm.bitreverse.i64"; return __llvm_bitreverse(i); }
+proc reverse_bits(i:  i64) ->  i64 { proc __llvm_bitreverse(i64)  ->  i64 #foreign __llvm_core "llvm.bitreverse.i64"; return __llvm_bitreverse(i); }
+proc reverse_bits(i: u128) -> u128 { proc __llvm_bitreverse(u128) -> u128 #foreign __llvm_core "llvm.bitreverse.i128";return __llvm_bitreverse(i); }
+proc reverse_bits(i: i128) -> i128 { proc __llvm_bitreverse(i128) -> i128 #foreign __llvm_core "llvm.bitreverse.i128";return __llvm_bitreverse(i); }
+proc reverse_bits(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(reverse_bits(u32(i))); } else { return uint(reverse_bits(u64(i))); } }
+proc reverse_bits(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(reverse_bits(i32(i))); } else { return  int(reverse_bits(i64(i))); } }
 
 
-const byte_swap = proc(u16)  ->  u16 #foreign __llvm_core "llvm.bswap.i16";
-const byte_swap = proc(i16)  ->  i16 #foreign __llvm_core "llvm.bswap.i16";
-const byte_swap = proc(u32)  ->  u32 #foreign __llvm_core "llvm.bswap.i32";
-const byte_swap = proc(i32)  ->  i32 #foreign __llvm_core "llvm.bswap.i32";
-const byte_swap = proc(u64)  ->  u64 #foreign __llvm_core "llvm.bswap.i64";
-const byte_swap = proc(i64)  ->  i64 #foreign __llvm_core "llvm.bswap.i64";
-const byte_swap = proc(u128) -> u128 #foreign __llvm_core "llvm.bswap.i128";
-const byte_swap = proc(i128) -> i128 #foreign __llvm_core "llvm.bswap.i128";
-const byte_swap = proc(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(byte_swap(u32(i))); } else { return uint(byte_swap(u64(i))); } }
-const byte_swap = proc(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(byte_swap(i32(i))); } else { return  int(byte_swap(i64(i))); } }
+proc byte_swap(u16)  ->  u16 #foreign __llvm_core "llvm.bswap.i16";
+proc byte_swap(i16)  ->  i16 #foreign __llvm_core "llvm.bswap.i16";
+proc byte_swap(u32)  ->  u32 #foreign __llvm_core "llvm.bswap.i32";
+proc byte_swap(i32)  ->  i32 #foreign __llvm_core "llvm.bswap.i32";
+proc byte_swap(u64)  ->  u64 #foreign __llvm_core "llvm.bswap.i64";
+proc byte_swap(i64)  ->  i64 #foreign __llvm_core "llvm.bswap.i64";
+proc byte_swap(u128) -> u128 #foreign __llvm_core "llvm.bswap.i128";
+proc byte_swap(i128) -> i128 #foreign __llvm_core "llvm.bswap.i128";
+proc byte_swap(i: uint) -> uint { when size_of(uint) == size_of(u32) { return uint(byte_swap(u32(i))); } else { return uint(byte_swap(u64(i))); } }
+proc byte_swap(i:  int) ->  int { when size_of(int)  == size_of(i32) { return  int(byte_swap(i32(i))); } else { return  int(byte_swap(i64(i))); } }
 
 
-const from_be = proc(i:   u8) ->   u8 { return i; }
-const from_be = proc(i:   i8) ->   i8 { return i; }
-const from_be = proc(i:  u16) ->  u16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  i16) ->  i16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  u32) ->  u32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  i32) ->  i32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  u64) ->  u64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  i64) ->  i64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i: u128) -> u128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i: i128) -> i128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i: uint) -> uint { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const from_be = proc(i:  int) ->  int { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:   u8) ->   u8 { return i; }
+proc from_be(i:   i8) ->   i8 { return i; }
+proc from_be(i:  u16) ->  u16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  i16) ->  i16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  u32) ->  u32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  i32) ->  i32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  u64) ->  u64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  i64) ->  i64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i: u128) -> u128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i: i128) -> i128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i: uint) -> uint { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc from_be(i:  int) ->  int { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
 
-const from_le = proc(i:   u8) ->   u8 { return i; }
-const from_le = proc(i:   i8) ->   i8 { return i; }
-const from_le = proc(i:  u16) ->  u16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  i16) ->  i16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  u32) ->  u32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  i32) ->  i32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  u64) ->  u64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  i64) ->  i64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i: u128) -> u128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i: i128) -> i128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i: uint) -> uint { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const from_le = proc(i:  int) ->  int { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:   u8) ->   u8 { return i; }
+proc from_le(i:   i8) ->   i8 { return i; }
+proc from_le(i:  u16) ->  u16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  i16) ->  i16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  u32) ->  u32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  i32) ->  i32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  u64) ->  u64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  i64) ->  i64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i: u128) -> u128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i: i128) -> i128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i: uint) -> uint { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc from_le(i:  int) ->  int { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
 
-const to_be = proc(i:   u8) ->   u8 { return i; }
-const to_be = proc(i:   i8) ->   i8 { return i; }
-const to_be = proc(i:  u16) ->  u16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  i16) ->  i16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  u32) ->  u32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  i32) ->  i32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  u64) ->  u64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  i64) ->  i64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i: u128) -> u128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i: i128) -> i128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i: uint) -> uint { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
-const to_be = proc(i:  int) ->  int { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:   u8) ->   u8 { return i; }
+proc to_be(i:   i8) ->   i8 { return i; }
+proc to_be(i:  u16) ->  u16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  i16) ->  i16 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  u32) ->  u32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  i32) ->  i32 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  u64) ->  u64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  i64) ->  i64 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i: u128) -> u128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i: i128) -> i128 { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i: uint) -> uint { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
+proc to_be(i:  int) ->  int { when ODIN_ENDIAN == "big" { return i; } else { return byte_swap(i); } }
 
 
-const to_le = proc(i:   u8) ->   u8 { return i; }
-const to_le = proc(i:   i8) ->   i8 { return i; }
-const to_le = proc(i:  u16) ->  u16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  i16) ->  i16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  u32) ->  u32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  i32) ->  i32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  u64) ->  u64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  i64) ->  i64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i: u128) -> u128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i: i128) -> i128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i: uint) -> uint { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
-const to_le = proc(i:  int) ->  int { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:   u8) ->   u8 { return i; }
+proc to_le(i:   i8) ->   i8 { return i; }
+proc to_le(i:  u16) ->  u16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  i16) ->  i16 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  u32) ->  u32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  i32) ->  i32 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  u64) ->  u64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  i64) ->  i64 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i: u128) -> u128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i: i128) -> i128 { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i: uint) -> uint { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
+proc to_le(i:  int) ->  int { when ODIN_ENDIAN == "little" { return i; } else { return byte_swap(i); } }
 
 
-const overflowing_add = proc(lhs, rhs:   u8) -> (u8, bool)   { const op = proc(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.uadd.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:   i8) -> (i8, bool)   { const op = proc(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.sadd.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  u16) -> (u16, bool)  { const op = proc(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  i16) -> (i16, bool)  { const op = proc(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  u32) -> (u32, bool)  { const op = proc(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  i32) -> (i32, bool)  { const op = proc(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  u64) -> (u64, bool)  { const op = proc(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs:  i64) -> (i64, bool)  { const op = proc(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs: u128) -> (u128, bool) { const op = proc(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.uadd.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs: i128) -> (i128, bool) { const op = proc(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.sadd.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_add = proc(lhs, rhs: uint) -> (uint, bool) {
+proc overflowing_add(lhs, rhs:   u8) -> (u8, bool)   { proc op(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.uadd.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:   i8) -> (i8, bool)   { proc op(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.sadd.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  u16) -> (u16, bool)  { proc op(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  i16) -> (i16, bool)  { proc op(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  u32) -> (u32, bool)  { proc op(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  i32) -> (i32, bool)  { proc op(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  u64) -> (u64, bool)  { proc op(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.uadd.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs:  i64) -> (i64, bool)  { proc op(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.sadd.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs: u128) -> (u128, bool) { proc op(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.uadd.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs: i128) -> (i128, bool) { proc op(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.sadd.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_add(lhs, rhs: uint) -> (uint, bool) {
 	when size_of(uint) == size_of(u32) {
 		var x, ok = overflowing_add(u32(lhs), u32(rhs));
 		return uint(x), ok;
@@ -204,7 +204,7 @@ const overflowing_add = proc(lhs, rhs: uint) -> (uint, bool) {
 		return uint(x), ok;
 	}
 }
-const overflowing_add = proc(lhs, rhs: int) -> (int, bool) {
+proc overflowing_add(lhs, rhs: int) -> (int, bool) {
 	when size_of(int) == size_of(i32) {
 		var x, ok = overflowing_add(i32(lhs), i32(rhs));
 		return int(x), ok;
@@ -214,17 +214,17 @@ const overflowing_add = proc(lhs, rhs: int) -> (int, bool) {
 	}
 }
 
-const overflowing_sub = proc(lhs, rhs:   u8) -> (u8, bool)   { const op = proc(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.usub.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:   i8) -> (i8, bool)   { const op = proc(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.ssub.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  u16) -> (u16, bool)  { const op = proc(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  i16) -> (i16, bool)  { const op = proc(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  u32) -> (u32, bool)  { const op = proc(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  i32) -> (i32, bool)  { const op = proc(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  u64) -> (u64, bool)  { const op = proc(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs:  i64) -> (i64, bool)  { const op = proc(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs: u128) -> (u128, bool) { const op = proc(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.usub.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs: i128) -> (i128, bool) { const op = proc(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.ssub.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_sub = proc(lhs, rhs: uint) -> (uint, bool) {
+proc overflowing_sub(lhs, rhs:   u8) -> (u8, bool)   { proc op(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.usub.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:   i8) -> (i8, bool)   { proc op(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.ssub.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  u16) -> (u16, bool)  { proc op(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  i16) -> (i16, bool)  { proc op(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  u32) -> (u32, bool)  { proc op(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  i32) -> (i32, bool)  { proc op(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  u64) -> (u64, bool)  { proc op(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.usub.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs:  i64) -> (i64, bool)  { proc op(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.ssub.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs: u128) -> (u128, bool) { proc op(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.usub.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs: i128) -> (i128, bool) { proc op(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.ssub.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_sub(lhs, rhs: uint) -> (uint, bool) {
 	when size_of(uint) == size_of(u32) {
 		var x, ok = overflowing_sub(u32(lhs), u32(rhs));
 		return uint(x), ok;
@@ -233,7 +233,7 @@ const overflowing_sub = proc(lhs, rhs: uint) -> (uint, bool) {
 		return uint(x), ok;
 	}
 }
-const overflowing_sub = proc(lhs, rhs: int) -> (int, bool) {
+proc overflowing_sub(lhs, rhs: int) -> (int, bool) {
 	when size_of(int) == size_of(i32) {
 		var x, ok = overflowing_sub(i32(lhs), i32(rhs));
 		return int(x), ok;
@@ -243,17 +243,17 @@ const overflowing_sub = proc(lhs, rhs: int) -> (int, bool) {
 	}
 }
 
-const overflowing_mul = proc(lhs, rhs:   u8) -> (u8, bool)   { const op = proc(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.umul.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:   i8) -> (i8, bool)   { const op = proc(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.smul.with.overflow.i8";   return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  u16) -> (u16, bool)  { const op = proc(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  i16) -> (i16, bool)  { const op = proc(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i16";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  u32) -> (u32, bool)  { const op = proc(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  i32) -> (i32, bool)  { const op = proc(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i32";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  u64) -> (u64, bool)  { const op = proc(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs:  i64) -> (i64, bool)  { const op = proc(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i64";  return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs: u128) -> (u128, bool) { const op = proc(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.umul.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs: i128) -> (i128, bool) { const op = proc(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.smul.with.overflow.i128"; return op(lhs, rhs); }
-const overflowing_mul = proc(lhs, rhs: uint) -> (uint, bool) {
+proc overflowing_mul(lhs, rhs:   u8) -> (u8, bool)   { proc op(u8, u8)     -> (u8, bool)   #foreign __llvm_core "llvm.umul.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:   i8) -> (i8, bool)   { proc op(i8, i8)     -> (i8, bool)   #foreign __llvm_core "llvm.smul.with.overflow.i8";   return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  u16) -> (u16, bool)  { proc op(u16, u16)   -> (u16, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  i16) -> (i16, bool)  { proc op(i16, i16)   -> (i16, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i16";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  u32) -> (u32, bool)  { proc op(u32, u32)   -> (u32, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  i32) -> (i32, bool)  { proc op(i32, i32)   -> (i32, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i32";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  u64) -> (u64, bool)  { proc op(u64, u64)   -> (u64, bool)  #foreign __llvm_core "llvm.umul.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs:  i64) -> (i64, bool)  { proc op(i64, i64)   -> (i64, bool)  #foreign __llvm_core "llvm.smul.with.overflow.i64";  return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs: u128) -> (u128, bool) { proc op(u128, u128) -> (u128, bool) #foreign __llvm_core "llvm.umul.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs: i128) -> (i128, bool) { proc op(i128, i128) -> (i128, bool) #foreign __llvm_core "llvm.smul.with.overflow.i128"; return op(lhs, rhs); }
+proc overflowing_mul(lhs, rhs: uint) -> (uint, bool) {
 	when size_of(uint) == size_of(u32) {
 		var x, ok = overflowing_mul(u32(lhs), u32(rhs));
 		return uint(x), ok;
@@ -262,7 +262,7 @@ const overflowing_mul = proc(lhs, rhs: uint) -> (uint, bool) {
 		return uint(x), ok;
 	}
 }
-const overflowing_mul = proc(lhs, rhs: int) -> (int, bool) {
+proc overflowing_mul(lhs, rhs: int) -> (int, bool) {
 	when size_of(int) == size_of(i32) {
 		var x, ok = overflowing_mul(i32(lhs), i32(rhs));
 		return int(x), ok;
@@ -272,15 +272,15 @@ const overflowing_mul = proc(lhs, rhs: int) -> (int, bool) {
 	}
 }
 
-const is_power_of_two = proc(i:   u8) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:   i8) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  u16) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  i16) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  u32) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  i32) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  u64) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  i64) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i: u128) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i: i128) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i: uint) -> bool { return i > 0 && (i & (i-1)) == 0; }
-const is_power_of_two = proc(i:  int) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:   u8) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:   i8) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  u16) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  i16) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  u32) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  i32) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  u64) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  i64) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i: u128) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i: i128) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i: uint) -> bool { return i > 0 && (i & (i-1)) == 0; }
+proc is_power_of_two(i:  int) -> bool { return i > 0 && (i & (i-1)) == 0; }

+ 12 - 12
core/decimal.odin

@@ -9,8 +9,8 @@ const Decimal = struct {
 	neg, trunc:    bool,
 }
 
-const decimal_to_string = proc(buf: []u8, a: ^Decimal) -> string {
-	const digit_zero = proc(buf: []u8) -> int {
+proc decimal_to_string(buf: []u8, a: ^Decimal) -> string {
+	proc digit_zero(buf: []u8) -> int {
 		for _, i in buf {
 			buf[i] = '0';
 		}
@@ -48,7 +48,7 @@ const decimal_to_string = proc(buf: []u8, a: ^Decimal) -> string {
 }
 
 // trim trailing zeros
-const trim = proc(a: ^Decimal) {
+proc trim(a: ^Decimal) {
 	for a.count > 0 && a.digits[a.count-1] == '0' {
 		a.count--;
 	}
@@ -58,7 +58,7 @@ const trim = proc(a: ^Decimal) {
 }
 
 
-const assign = proc(a: ^Decimal, i: u64) {
+proc assign(a: ^Decimal, i: u64) {
 	var buf: [32]u8;
 	var n = 0;
 	for i > 0 {
@@ -81,7 +81,7 @@ const assign = proc(a: ^Decimal, i: u64) {
 const uint_size = 8*size_of(uint);
 const max_shift = uint_size-4;
 
-const shift_right = proc(a: ^Decimal, k: uint) {
+proc shift_right(a: ^Decimal, k: uint) {
 	var r = 0; // read index
 	var w = 0; // write index
 
@@ -132,7 +132,7 @@ const shift_right = proc(a: ^Decimal, k: uint) {
 	trim(a);
 }
 
-const shift_left = proc(a: ^Decimal, k: uint) {
+proc shift_left(a: ^Decimal, k: uint) {
 	var delta = int(k/4);
 
 	var r = a.count;       // read index
@@ -170,7 +170,7 @@ const shift_left = proc(a: ^Decimal, k: uint) {
 	trim(a);
 }
 
-const shift = proc(a: ^Decimal, k: int) {
+proc shift(a: ^Decimal, k: int) {
 	match {
 	case a.count == 0:
 		// no need to update
@@ -191,7 +191,7 @@ const shift = proc(a: ^Decimal, k: int) {
 	}
 }
 
-const can_round_up = proc(a: ^Decimal, nd: int) -> bool {
+proc can_round_up(a: ^Decimal, nd: int) -> bool {
 	if nd < 0 || nd >= a.count { return false ; }
 	if a.digits[nd] == '5' && nd+1 == a.count {
 		if a.trunc {
@@ -203,7 +203,7 @@ const can_round_up = proc(a: ^Decimal, nd: int) -> bool {
 	return a.digits[nd] >= '5';
 }
 
-const round = proc(a: ^Decimal, nd: int) {
+proc round(a: ^Decimal, nd: int) {
 	if nd < 0 || nd >= a.count { return; }
 	if can_round_up(a, nd) {
 		round_up(a, nd);
@@ -212,7 +212,7 @@ const round = proc(a: ^Decimal, nd: int) {
 	}
 }
 
-const round_up = proc(a: ^Decimal, nd: int) {
+proc round_up(a: ^Decimal, nd: int) {
 	if nd < 0 || nd >= a.count { return; }
 
 	for var i = nd-1; i >= 0; i-- {
@@ -229,7 +229,7 @@ const round_up = proc(a: ^Decimal, nd: int) {
 	a.decimal_point++;
 }
 
-const round_down = proc(a: ^Decimal, nd: int) {
+proc round_down(a: ^Decimal, nd: int) {
 	if nd < 0 || nd >= a.count { return; }
 	a.count = nd;
 	trim(a);
@@ -237,7 +237,7 @@ const round_down = proc(a: ^Decimal, nd: int) {
 
 
 // Extract integer part, rounded appropriately. There are no guarantees about overflow.
-const rounded_integer = proc(a: ^Decimal) -> u64 {
+proc rounded_integer(a: ^Decimal) -> u64 {
 	if a.decimal_point > 20 {
 		return 0xffff_ffff_ffff_ffff;
 	}

+ 53 - 53
core/fmt.odin

@@ -33,14 +33,14 @@ const FmtInfo = struct {
 }
 
 
-const make_string_buffer_from_slice = proc(b: []u8) -> StringBuffer {
+proc make_string_buffer_from_slice(b: []u8) -> StringBuffer {
 	return StringBuffer.Static{b};
 }
 
-const make_string_dynamic_buffer = proc() -> StringBuffer {
+proc make_string_dynamic_buffer() -> StringBuffer {
 	return StringBuffer.Dynamic{make([dynamic]u8)};
 }
-const string_buffer_data = proc(buf: ^StringBuffer) -> []u8 {
+proc string_buffer_data(buf: ^StringBuffer) -> []u8 {
 	match b in buf {
 	case StringBuffer.Static:
 		return b.buf[..];
@@ -49,7 +49,7 @@ const string_buffer_data = proc(buf: ^StringBuffer) -> []u8 {
 	}
 	return nil;
 }
-const string_buffer_data = proc(buf: StringBuffer) -> []u8 {
+proc string_buffer_data(buf: StringBuffer) -> []u8 {
 	match b in buf {
 	case StringBuffer.Static:
 		return b.buf[..];
@@ -58,15 +58,15 @@ const string_buffer_data = proc(buf: StringBuffer) -> []u8 {
 	}
 	return nil;
 }
-const to_string = proc(buf: StringBuffer) -> string {
+proc to_string(buf: StringBuffer) -> string {
 	return string(string_buffer_data(buf));
 }
 
 
-const write_string = proc(buf: ^StringBuffer, s: string) {
+proc write_string(buf: ^StringBuffer, s: string) {
 	write_bytes(buf, []u8(s));
 }
-const write_bytes = proc(buf: ^StringBuffer, data: []u8) {
+proc write_bytes(buf: ^StringBuffer, data: []u8) {
 	match b in buf {
 	case StringBuffer.Static:
 		append(b.buf, ..data);
@@ -74,7 +74,7 @@ const write_bytes = proc(buf: ^StringBuffer, data: []u8) {
 		append(b.buf, ..data);
 	}
 }
-const write_byte = proc(buf: ^StringBuffer, data: u8) {
+proc write_byte(buf: ^StringBuffer, data: u8) {
 	match b in buf {
 	case StringBuffer.Static:
 		append(b.buf, data);
@@ -82,7 +82,7 @@ const write_byte = proc(buf: ^StringBuffer, data: u8) {
 		append(b.buf, data);
 	}
 }
-const write_rune = proc(buf: ^StringBuffer, r: rune) {
+proc write_rune(buf: ^StringBuffer, r: rune) {
 	if r < utf8.RUNE_SELF {
 		write_byte(buf, u8(r));
 		return;
@@ -92,12 +92,12 @@ const write_rune = proc(buf: ^StringBuffer, r: rune) {
 	write_bytes(buf, b[0..<n]);
 }
 
-const write_int = proc(buf: ^StringBuffer, i: i128, base: int) {
+proc write_int(buf: ^StringBuffer, i: i128, base: int) {
 	var b: [129]u8;
 	var s = strconv.append_bits(b[0..<0], u128(i), base, true, 128, strconv.digits, 0);
 	write_string(buf, s);
 }
-const write_int = proc(buf: ^StringBuffer, i: i64, base: int) {
+proc write_int(buf: ^StringBuffer, i: i64, base: int) {
 	var b: [129]u8;
 	var s = strconv.append_bits(b[0..<0], u128(i), base, true, 64, strconv.digits, 0);
 	write_string(buf, s);
@@ -105,7 +105,7 @@ const write_int = proc(buf: ^StringBuffer, i: i64, base: int) {
 
 
 
-const fprint = proc(fd: os.Handle, args: ..any) -> int {
+proc fprint(fd: os.Handle, args: ..any) -> int {
 	var data: [_BUFFER_SIZE]u8;
 	var buf = make_string_buffer_from_slice(data[0..<0]);
 	sbprint(&buf, ..args);
@@ -114,7 +114,7 @@ const fprint = proc(fd: os.Handle, args: ..any) -> int {
 	return len(res);
 }
 
-const fprintln = proc(fd: os.Handle, args: ..any) -> int {
+proc fprintln(fd: os.Handle, args: ..any) -> int {
 	var data: [_BUFFER_SIZE]u8;
 	var buf = make_string_buffer_from_slice(data[0..<0]);
 	sbprintln(&buf, ..args);
@@ -122,7 +122,7 @@ const fprintln = proc(fd: os.Handle, args: ..any) -> int {
 	os.write(fd, res);
 	return len(res);
 }
-const fprintf = proc(fd: os.Handle, fmt: string, args: ..any) -> int {
+proc fprintf(fd: os.Handle, fmt: string, args: ..any) -> int {
 	var data: [_BUFFER_SIZE]u8;
 	var buf = make_string_buffer_from_slice(data[0..<0]);
 	sbprintf(&buf, fmt, ..args);
@@ -133,27 +133,27 @@ const fprintf = proc(fd: os.Handle, fmt: string, args: ..any) -> int {
 
 
 // print* procedures return the number of bytes written
-const print       = proc(args: ..any)              -> int { return fprint(os.stdout, ..args); }
-const print_err   = proc(args: ..any)              -> int { return fprint(os.stderr, ..args); }
-const println     = proc(args: ..any)              -> int { return fprintln(os.stdout, ..args); }
-const println_err = proc(args: ..any)              -> int { return fprintln(os.stderr, ..args); }
-const printf      = proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args); }
-const printf_err  = proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args); }
+proc print       (args: ..any)              -> int { return fprint(os.stdout, ..args); }
+proc print_err   (args: ..any)              -> int { return fprint(os.stderr, ..args); }
+proc println     (args: ..any)              -> int { return fprintln(os.stdout, ..args); }
+proc println_err (args: ..any)              -> int { return fprintln(os.stderr, ..args); }
+proc printf      (fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args); }
+proc printf_err  (fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args); }
 
 
 // aprint* procedures return a string that was allocated with the current context
 // They must be freed accordingly
-const aprint = proc(args: ..any) -> string {
+proc aprint(args: ..any) -> string {
 	var buf = make_string_dynamic_buffer();
 	sbprint(&buf, ..args);
 	return to_string(buf);
 }
-const aprintln = proc(args: ..any) -> string {
+proc aprintln(args: ..any) -> string {
 	var buf = make_string_dynamic_buffer();
 	sbprintln(&buf, ..args);
 	return to_string(buf);
 }
-const aprintf = proc(fmt: string, args: ..any) -> string {
+proc aprintf(fmt: string, args: ..any) -> string {
 	var buf = make_string_dynamic_buffer();
 	sbprintf(&buf, fmt, ..args);
 	return to_string(buf);
@@ -162,15 +162,15 @@ const aprintf = proc(fmt: string, args: ..any) -> string {
 
 // bprint* procedures return a string that was allocated with the current context
 // They must be freed accordingly
-const bprint = proc(buf: []u8, args: ..any) -> string {
+proc bprint(buf: []u8, args: ..any) -> string {
 	var sb = make_string_buffer_from_slice(buf[0..<0..<len(buf)]);
 	return sbprint(&sb, ..args);
 }
-const bprintln = proc(buf: []u8, args: ..any) -> string {
+proc bprintln(buf: []u8, args: ..any) -> string {
 	var sb = make_string_buffer_from_slice(buf[0..<0..<len(buf)]);
 	return sbprintln(&sb, ..args);
 }
-const bprintf = proc(buf: []u8, fmt: string, args: ..any) -> string {
+proc bprintf(buf: []u8, fmt: string, args: ..any) -> string {
 	var sb = make_string_buffer_from_slice(buf[0..<0..<len(buf)]);
 	return sbprintf(&sb, fmt, ..args);
 }
@@ -180,14 +180,14 @@ const bprintf = proc(buf: []u8, fmt: string, args: ..any) -> string {
 
 
 
-const fprint_type = proc(fd: os.Handle, info: ^TypeInfo) {
+proc fprint_type(fd: os.Handle, info: ^TypeInfo) {
 	var data: [_BUFFER_SIZE]u8;
 	var buf = make_string_buffer_from_slice(data[0..<0]);
 	write_type(&buf, info);
 	os.write(fd, string_buffer_data(buf));
 }
 
-const write_type = proc(buf: ^StringBuffer, ti: ^TypeInfo) {
+proc write_type(buf: ^StringBuffer, ti: ^TypeInfo) {
 	if ti == nil {
 		return;
 	}
@@ -392,8 +392,8 @@ const write_type = proc(buf: ^StringBuffer, ti: ^TypeInfo) {
 }
 
 
-const _parse_int = proc(s: string, offset: int) -> (result: int, offset: int, ok: bool) {
-	const is_digit = proc(r: rune) -> bool #inline {
+proc _parse_int(s: string, offset: int) -> (result: int, offset: int, ok: bool) {
+	proc is_digit(r: rune) -> bool #inline {
 		return '0' <= r && r <= '9';
 	}
 
@@ -415,8 +415,8 @@ const _parse_int = proc(s: string, offset: int) -> (result: int, offset: int, ok
 	return result, offset+i, i != 0;
 }
 
-const _arg_number = proc(fi: ^FmtInfo, arg_index: int, format: string, offset, arg_count: int) -> (index, offset: int, ok: bool) {
-	const parse_arg_number = proc(format: string) -> (int, int, bool) {
+proc _arg_number(fi: ^FmtInfo, arg_index: int, format: string, offset, arg_count: int) -> (index, offset: int, ok: bool) {
+	proc parse_arg_number(format: string) -> (int, int, bool) {
 		if len(format) < 3 {
 			return 0, 1, false;
 		}
@@ -447,7 +447,7 @@ const _arg_number = proc(fi: ^FmtInfo, arg_index: int, format: string, offset, a
 	return arg_index, offset+width, false;
 }
 
-const int_from_arg = proc(args: []any, arg_index: int) -> (int, int, bool) {
+proc int_from_arg(args: []any, arg_index: int) -> (int, int, bool) {
 	var num = 0;
 	var new_arg_index = arg_index;
 	var ok = true;
@@ -473,7 +473,7 @@ const int_from_arg = proc(args: []any, arg_index: int) -> (int, int, bool) {
 }
 
 
-const fmt_bad_verb = proc(using fi: ^FmtInfo, verb: rune) {
+proc fmt_bad_verb(using fi: ^FmtInfo, verb: rune) {
 	assert(verb != 'v');
 	write_string(buf, "%!");
 	write_rune(buf, verb);
@@ -488,7 +488,7 @@ const fmt_bad_verb = proc(using fi: ^FmtInfo, verb: rune) {
 	write_byte(buf, ')');
 }
 
-const fmt_bool = proc(using fi: ^FmtInfo, b: bool, verb: rune) {
+proc fmt_bool(using fi: ^FmtInfo, b: bool, verb: rune) {
 	match verb {
 	case 't', 'v':
 		write_string(buf, b ? "true" : "false");
@@ -498,7 +498,7 @@ const fmt_bool = proc(using fi: ^FmtInfo, b: bool, verb: rune) {
 }
 
 
-const fmt_write_padding = proc(fi: ^FmtInfo, width: int) {
+proc fmt_write_padding(fi: ^FmtInfo, width: int) {
 	if width <= 0 {
 		return;
 	}
@@ -514,7 +514,7 @@ const fmt_write_padding = proc(fi: ^FmtInfo, width: int) {
 	}
 }
 
-const _fmt_int = proc(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_size: int, digits: string) {
+proc _fmt_int(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_size: int, digits: string) {
 	var _, neg = strconv.is_integer_negative(u128(u), is_signed, bit_size);
 
 	const BUF_SIZE = 256;
@@ -585,7 +585,7 @@ const _fmt_int = proc(fi: ^FmtInfo, u: u128, base: int, is_signed: bool, bit_siz
 immutable var __DIGITS_LOWER = "0123456789abcdefx";
 immutable var __DIGITS_UPPER = "0123456789ABCDEFX";
 
-const fmt_rune = proc(fi: ^FmtInfo, r: rune, verb: rune) {
+proc fmt_rune(fi: ^FmtInfo, r: rune, verb: rune) {
 	match verb {
 	case 'c', 'r', 'v':
 		write_rune(fi.buf, r);
@@ -594,7 +594,7 @@ const fmt_rune = proc(fi: ^FmtInfo, r: rune, verb: rune) {
 	}
 }
 
-const fmt_int = proc(fi: ^FmtInfo, u: u128, is_signed: bool, bit_size: int, verb: rune) {
+proc fmt_int(fi: ^FmtInfo, u: u128, is_signed: bool, bit_size: int, verb: rune) {
 	match verb {
 	case 'v': _fmt_int(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER);
 	case 'b': _fmt_int(fi, u,  2, is_signed, bit_size, __DIGITS_LOWER);
@@ -618,7 +618,7 @@ const fmt_int = proc(fi: ^FmtInfo, u: u128, is_signed: bool, bit_size: int, verb
 	}
 }
 
-const _pad = proc(fi: ^FmtInfo, s: string) {
+proc _pad(fi: ^FmtInfo, s: string) {
 	if !fi.width_set {
 		write_string(fi.buf, s);
 		return;
@@ -633,7 +633,7 @@ const _pad = proc(fi: ^FmtInfo, s: string) {
 	}
 }
 
-const fmt_float = proc(fi: ^FmtInfo, v: f64, bit_size: int, verb: rune) {
+proc fmt_float(fi: ^FmtInfo, v: f64, bit_size: int, verb: rune) {
 	match verb {
 	// case 'e', 'E', 'f', 'F', 'g', 'G', 'v':
 	// case 'f', 'F', 'v':
@@ -678,7 +678,7 @@ const fmt_float = proc(fi: ^FmtInfo, v: f64, bit_size: int, verb: rune) {
 		fmt_bad_verb(fi, verb);
 	}
 }
-const fmt_string = proc(fi: ^FmtInfo, s: string, verb: rune) {
+proc fmt_string(fi: ^FmtInfo, s: string, verb: rune) {
 	match verb {
 	case 's', 'v':
 		write_string(fi.buf, s);
@@ -700,7 +700,7 @@ const fmt_string = proc(fi: ^FmtInfo, s: string, verb: rune) {
 	}
 }
 
-const fmt_pointer = proc(fi: ^FmtInfo, p: rawptr, verb: rune) {
+proc fmt_pointer(fi: ^FmtInfo, p: rawptr, verb: rune) {
 	match verb {
 	case 'p', 'v':
 		// Okay
@@ -715,7 +715,7 @@ const fmt_pointer = proc(fi: ^FmtInfo, p: rawptr, verb: rune) {
 	_fmt_int(fi, u, 16, false, 8*size_of(rawptr), __DIGITS_UPPER);
 }
 
-const fmt_enum = proc(fi: ^FmtInfo, v: any, verb: rune) {
+proc fmt_enum(fi: ^FmtInfo, v: any, verb: rune) {
 	if v.type_info == nil || v.data == nil {
 		write_string(fi.buf, "<nil>");
 		return;
@@ -786,7 +786,7 @@ const fmt_enum = proc(fi: ^FmtInfo, v: any, verb: rune) {
 }
 
 
-const fmt_value = proc(fi: ^FmtInfo, v: any, verb: rune) {
+proc fmt_value(fi: ^FmtInfo, v: any, verb: rune) {
 	if v.data == nil || v.type_info == nil {
 		write_string(fi.buf, "<nil>");
 		return;
@@ -962,7 +962,7 @@ const fmt_value = proc(fi: ^FmtInfo, v: any, verb: rune) {
 	}
 }
 
-const fmt_complex = proc(fi: ^FmtInfo, c: complex128, bits: int, verb: rune) {
+proc fmt_complex(fi: ^FmtInfo, c: complex128, bits: int, verb: rune) {
 	match verb {
 	case 'f', 'F', 'v':
 		var r = real(c);
@@ -980,15 +980,15 @@ const fmt_complex = proc(fi: ^FmtInfo, c: complex128, bits: int, verb: rune) {
 	}
 }
 
-const _u128_to_lo_hi = proc(a: u128) -> (lo, hi: u64) { return u64(a), u64(a>>64); }
-const _i128_to_lo_hi = proc(a: u128) -> (lo: u64 hi: i64) { return u64(a), i64(a>>64); }
+proc _u128_to_lo_hi(a: u128) -> (lo, hi: u64) { return u64(a), u64(a>>64); }
+proc _i128_to_lo_hi(a: u128) -> (lo: u64 hi: i64) { return u64(a), i64(a>>64); }
 
 
-const do_foo = proc(fi: ^FmtInfo, f: f64) {
+proc do_foo(fi: ^FmtInfo, f: f64) {
 	fmt_string(fi, "Hellope$%!", 'v');
 }
 
-const fmt_arg = proc(fi: ^FmtInfo, arg: any, verb: rune) {
+proc fmt_arg(fi: ^FmtInfo, arg: any, verb: rune) {
 	if arg == nil {
 		write_string(fi.buf, "<nil>");
 		return;
@@ -1043,7 +1043,7 @@ const fmt_arg = proc(fi: ^FmtInfo, arg: any, verb: rune) {
 
 
 
-const sbprint = proc(buf: ^StringBuffer, args: ..any) -> string {
+proc sbprint(buf: ^StringBuffer, args: ..any) -> string {
 	var fi: FmtInfo;
 	fi.buf = buf;
 
@@ -1059,7 +1059,7 @@ const sbprint = proc(buf: ^StringBuffer, args: ..any) -> string {
 	return to_string(buf^);
 }
 
-const sbprintln = proc(buf: ^StringBuffer, args: ..any) -> string {
+proc sbprintln(buf: ^StringBuffer, args: ..any) -> string {
 	var fi: FmtInfo;
 	fi.buf = buf;
 
@@ -1073,7 +1073,7 @@ const sbprintln = proc(buf: ^StringBuffer, args: ..any) -> string {
 	return to_string(buf^);
 }
 
-const sbprintf = proc(b: ^StringBuffer, fmt: string, args: ..any) -> string {
+proc sbprintf(b: ^StringBuffer, fmt: string, args: ..any) -> string {
 	var fi = FmtInfo{};
 	var end = len(fmt);
 	var arg_index = 0;

+ 57 - 57
core/math.odin

@@ -27,36 +27,36 @@ const Mat4 = [4][4]f32;
 
 const Complex = complex64;
 
-const sqrt = proc(x: f32) -> f32 #foreign __llvm_core "llvm.sqrt.f32";
-const sqrt = proc(x: f64) -> f64 #foreign __llvm_core "llvm.sqrt.f64";
+proc sqrt(x: f32) -> f32 #foreign __llvm_core "llvm.sqrt.f32";
+proc sqrt(x: f64) -> f64 #foreign __llvm_core "llvm.sqrt.f64";
 
-const sin  = proc(θ: f32) -> f32 #foreign __llvm_core "llvm.sin.f32";
-const sin  = proc(θ: f64) -> f64 #foreign __llvm_core "llvm.sin.f64";
+proc sin (θ: f32) -> f32 #foreign __llvm_core "llvm.sin.f32";
+proc sin (θ: f64) -> f64 #foreign __llvm_core "llvm.sin.f64";
 
-const cos  = proc(θ: f32) -> f32 #foreign __llvm_core "llvm.cos.f32";
-const cos  = proc(θ: f64) -> f64 #foreign __llvm_core "llvm.cos.f64";
+proc cos (θ: f32) -> f32 #foreign __llvm_core "llvm.cos.f32";
+proc cos (θ: f64) -> f64 #foreign __llvm_core "llvm.cos.f64";
 
-const tan  = proc(θ: f32) -> f32 #inline { return sin(θ)/cos(θ); }
-const tan  = proc(θ: f64) -> f64 #inline { return sin(θ)/cos(θ); }
+proc tan (θ: f32) -> f32 #inline { return sin(θ)/cos(θ); }
+proc tan (θ: f64) -> f64 #inline { return sin(θ)/cos(θ); }
 
-const pow  = proc(x, power: f32) -> f32 #foreign __llvm_core "llvm.pow.f32";
-const pow  = proc(x, power: f64) -> f64 #foreign __llvm_core "llvm.pow.f64";
+proc pow (x, power: f32) -> f32 #foreign __llvm_core "llvm.pow.f32";
+proc pow (x, power: f64) -> f64 #foreign __llvm_core "llvm.pow.f64";
 
 
-const lerp   = proc(a, b, t: f32) -> (x: f32) { return a*(1-t) + b*t; }
-const lerp   = proc(a, b, t: f64) -> (x: f64) { return a*(1-t) + b*t; }
-const unlerp = proc(a, b, x: f32) -> (t: f32) { return (x-a)/(b-a); }
-const unlerp = proc(a, b, x: f64) -> (t: f64) { return (x-a)/(b-a); }
+proc lerp  (a, b, t: f32) -> (x: f32) { return a*(1-t) + b*t; }
+proc lerp  (a, b, t: f64) -> (x: f64) { return a*(1-t) + b*t; }
+proc unlerp(a, b, x: f32) -> (t: f32) { return (x-a)/(b-a); }
+proc unlerp(a, b, x: f64) -> (t: f64) { return (x-a)/(b-a); }
 
 
-const sign = proc(x: f32) -> f32 { return x >= 0 ? +1 : -1; }
-const sign = proc(x: f64) -> f64 { return x >= 0 ? +1 : -1; }
+proc sign(x: f32) -> f32 { return x >= 0 ? +1 : -1; }
+proc sign(x: f64) -> f64 { return x >= 0 ? +1 : -1; }
 
-const fmuladd = proc(a, b, c: f32) -> f32 #foreign __llvm_core "llvm.fmuladd.f32";
-const fmuladd = proc(a, b, c: f64) -> f64 #foreign __llvm_core "llvm.fmuladd.f64";
+proc fmuladd(a, b, c: f32) -> f32 #foreign __llvm_core "llvm.fmuladd.f32";
+proc fmuladd(a, b, c: f64) -> f64 #foreign __llvm_core "llvm.fmuladd.f64";
 
 
-const copy_sign = proc(x, y: f32) -> f32 {
+proc copy_sign(x, y: f32) -> f32 {
 	var ix = transmute(u32, x);
 	var iy = transmute(u32, y);
 	ix &= 0x7fff_ffff;
@@ -64,7 +64,7 @@ const copy_sign = proc(x, y: f32) -> f32 {
 	return transmute(f32, ix);
 }
 
-const copy_sign = proc(x, y: f64) -> f64 {
+proc copy_sign(x, y: f64) -> f64 {
 	var ix = transmute(u64, x);
 	var iy = transmute(u64, y);
 	ix &= 0x7fff_ffff_ffff_ff;
@@ -72,19 +72,19 @@ const copy_sign = proc(x, y: f64) -> f64 {
 	return transmute(f64, ix);
 }
 
-const round     = proc(x: f32) -> f32 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
-const round     = proc(x: f64) -> f64 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
+proc round    (x: f32) -> f32 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
+proc round    (x: f64) -> f64 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
 
-const floor     = proc(x: f32) -> f32 { return x >= 0 ? f32(i64(x)) : f32(i64(x-0.5)); } // TODO: Get accurate versions
-const floor     = proc(x: f64) -> f64 { return x >= 0 ? f64(i64(x)) : f64(i64(x-0.5)); } // TODO: Get accurate versions
+proc floor    (x: f32) -> f32 { return x >= 0 ? f32(i64(x)) : f32(i64(x-0.5)); } // TODO: Get accurate versions
+proc floor    (x: f64) -> f64 { return x >= 0 ? f64(i64(x)) : f64(i64(x-0.5)); } // TODO: Get accurate versions
 
-const ceil      = proc(x: f32) -> f32 { return x <  0 ? f32(i64(x)) : f32(i64(x+1)); } // TODO: Get accurate versions
-const ceil      = proc(x: f64) -> f64 { return x <  0 ? f64(i64(x)) : f64(i64(x+1)); } // TODO: Get accurate versions
+proc ceil     (x: f32) -> f32 { return x <  0 ? f32(i64(x)) : f32(i64(x+1)); } // TODO: Get accurate versions
+proc ceil     (x: f64) -> f64 { return x <  0 ? f64(i64(x)) : f64(i64(x+1)); } // TODO: Get accurate versions
 
-const remainder = proc(x, y: f32) -> f32 { return x - round(x/y) * y; }
-const remainder = proc(x, y: f64) -> f64 { return x - round(x/y) * y; }
+proc remainder(x, y: f32) -> f32 { return x - round(x/y) * y; }
+proc remainder(x, y: f64) -> f64 { return x - round(x/y) * y; }
 
-const mod = proc(x, y: f32) -> f32 {
+proc mod(x, y: f32) -> f32 {
 	y = abs(y);
 	var result = remainder(abs(x), y);
 	if sign(result) < 0 {
@@ -92,7 +92,7 @@ const mod = proc(x, y: f32) -> f32 {
 	}
 	return copy_sign(result, x);
 }
-const mod = proc(x, y: f64) -> f64 {
+proc mod(x, y: f64) -> f64 {
 	y = abs(y);
 	var result = remainder(abs(x), y);
 	if sign(result) < 0 {
@@ -102,31 +102,31 @@ const mod = proc(x, y: f64) -> f64 {
 }
 
 
-const to_radians = proc(degrees: f32) -> f32 { return degrees * TAU / 360; }
-const to_degrees = proc(radians: f32) -> f32 { return radians * 360 / TAU; }
+proc to_radians(degrees: f32) -> f32 { return degrees * TAU / 360; }
+proc to_degrees(radians: f32) -> f32 { return radians * 360 / TAU; }
 
 
 
-const dot = proc(a, b: Vec2) -> f32 { var c = a*b; return c.x + c.y; }
-const dot = proc(a, b: Vec3) -> f32 { var c = a*b; return c.x + c.y + c.z; }
-const dot = proc(a, b: Vec4) -> f32 { var c = a*b; return c.x + c.y + c.z + c.w; }
+proc dot(a, b: Vec2) -> f32 { var c = a*b; return c.x + c.y; }
+proc dot(a, b: Vec3) -> f32 { var c = a*b; return c.x + c.y + c.z; }
+proc dot(a, b: Vec4) -> f32 { var c = a*b; return c.x + c.y + c.z + c.w; }
 
-const cross = proc(x, y: Vec3) -> Vec3 {
+proc cross(x, y: Vec3) -> Vec3 {
 	var a = swizzle(x, 1, 2, 0) * swizzle(y, 2, 0, 1);
 	var b = swizzle(x, 2, 0, 1) * swizzle(y, 1, 2, 0);
 	return a - b;
 }
 
 
-const mag = proc(v: Vec2) -> f32 { return sqrt(dot(v, v)); }
-const mag = proc(v: Vec3) -> f32 { return sqrt(dot(v, v)); }
-const mag = proc(v: Vec4) -> f32 { return sqrt(dot(v, v)); }
+proc mag(v: Vec2) -> f32 { return sqrt(dot(v, v)); }
+proc mag(v: Vec3) -> f32 { return sqrt(dot(v, v)); }
+proc mag(v: Vec4) -> f32 { return sqrt(dot(v, v)); }
 
-const norm = proc(v: Vec2) -> Vec2 { return v / mag(v); }
-const norm = proc(v: Vec3) -> Vec3 { return v / mag(v); }
-const norm = proc(v: Vec4) -> Vec4 { return v / mag(v); }
+proc norm(v: Vec2) -> Vec2 { return v / mag(v); }
+proc norm(v: Vec3) -> Vec3 { return v / mag(v); }
+proc norm(v: Vec4) -> Vec4 { return v / mag(v); }
 
-const norm0 = proc(v: Vec2) -> Vec2 {
+proc norm0(v: Vec2) -> Vec2 {
 	var m = mag(v);
 	if m == 0 {
 		return 0;
@@ -134,7 +134,7 @@ const norm0 = proc(v: Vec2) -> Vec2 {
 	return v / m;
 }
 
-const norm0 = proc(v: Vec3) -> Vec3 {
+proc norm0(v: Vec3) -> Vec3 {
 	var m = mag(v);
 	if m == 0 {
 		return 0;
@@ -142,7 +142,7 @@ const norm0 = proc(v: Vec3) -> Vec3 {
 	return v / m;
 }
 
-const norm0 = proc(v: Vec4) -> Vec4 {
+proc norm0(v: Vec4) -> Vec4 {
 	var m = mag(v);
 	if m == 0 {
 		return 0;
@@ -152,7 +152,7 @@ const norm0 = proc(v: Vec4) -> Vec4 {
 
 
 
-const mat4_identity = proc() -> Mat4 {
+proc mat4_identity() -> Mat4 {
 	return Mat4{
 		{1, 0, 0, 0},
 		{0, 1, 0, 0},
@@ -161,7 +161,7 @@ const mat4_identity = proc() -> Mat4 {
 	};
 }
 
-const mat4_transpose = proc(m: Mat4) -> Mat4 {
+proc mat4_transpose(m: Mat4) -> Mat4 {
 	for j in 0..<4 {
 		for i in 0..<4 {
 			m[i][j], m[j][i] = m[j][i], m[i][j];
@@ -170,7 +170,7 @@ const mat4_transpose = proc(m: Mat4) -> Mat4 {
 	return m;
 }
 
-const mul = proc(a, b: Mat4) -> Mat4 {
+proc mul(a, b: Mat4) -> Mat4 {
 	var c: Mat4;
 	for j in 0..<4 {
 		for i in 0..<4 {
@@ -183,7 +183,7 @@ const mul = proc(a, b: Mat4) -> Mat4 {
 	return c;
 }
 
-const mul = proc(m: Mat4, v: Vec4) -> Vec4 {
+proc mul(m: Mat4, v: Vec4) -> Vec4 {
 	return Vec4{
 		m[0][0]*v.x + m[1][0]*v.y + m[2][0]*v.z + m[3][0]*v.w,
 		m[0][1]*v.x + m[1][1]*v.y + m[2][1]*v.z + m[3][1]*v.w,
@@ -192,7 +192,7 @@ const mul = proc(m: Mat4, v: Vec4) -> Vec4 {
 	};
 }
 
-const inverse = proc(m: Mat4) -> Mat4 {
+proc inverse(m: Mat4) -> Mat4 {
 	var o: Mat4;
 
 	var sf00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
@@ -261,7 +261,7 @@ const inverse = proc(m: Mat4) -> Mat4 {
 }
 
 
-const mat4_translate = proc(v: Vec3) -> Mat4 {
+proc mat4_translate(v: Vec3) -> Mat4 {
 	var m = mat4_identity();
 	m[3][0] = v.x;
 	m[3][1] = v.y;
@@ -270,7 +270,7 @@ const mat4_translate = proc(v: Vec3) -> Mat4 {
 	return m;
 }
 
-const mat4_rotate = proc(v: Vec3, angle_radians: f32) -> Mat4 {
+proc mat4_rotate(v: Vec3, angle_radians: f32) -> Mat4 {
 	var c = cos(angle_radians);
 	var s = sin(angle_radians);
 
@@ -297,14 +297,14 @@ const mat4_rotate = proc(v: Vec3, angle_radians: f32) -> Mat4 {
 	return rot;
 }
 
-const scale = proc(m: Mat4, v: Vec3) -> Mat4 {
+proc scale(m: Mat4, v: Vec3) -> Mat4 {
 	m[0][0] *= v.x;
 	m[1][1] *= v.y;
 	m[2][2] *= v.z;
 	return m;
 }
 
-const scale = proc(m: Mat4, s: f32) -> Mat4 {
+proc scale(m: Mat4, s: f32) -> Mat4 {
 	m[0][0] *= s;
 	m[1][1] *= s;
 	m[2][2] *= s;
@@ -312,7 +312,7 @@ const scale = proc(m: Mat4, s: f32) -> Mat4 {
 }
 
 
-const look_at = proc(eye, centre, up: Vec3) -> Mat4 {
+proc look_at(eye, centre, up: Vec3) -> Mat4 {
 	var f = norm(centre - eye);
 	var s = norm(cross(f, up));
 	var u = cross(s, f);
@@ -325,7 +325,7 @@ const look_at = proc(eye, centre, up: Vec3) -> Mat4 {
 	};
 }
 
-const perspective = proc(fovy, aspect, near, far: f32) -> Mat4 {
+proc perspective(fovy, aspect, near, far: f32) -> Mat4 {
 	var m: Mat4;
 	var tan_half_fovy = tan(0.5 * fovy);
 	m[0][0] = 1.0 / (aspect*tan_half_fovy);
@@ -337,7 +337,7 @@ const perspective = proc(fovy, aspect, near, far: f32) -> Mat4 {
 }
 
 
-const ortho3d = proc(left, right, bottom, top, near, far: f32) -> Mat4 {
+proc ortho3d(left, right, bottom, top, near, far: f32) -> Mat4 {
 	var m = mat4_identity();
 	m[0][0] = +2.0 / (right - left);
 	m[1][1] = +2.0 / (top - bottom);

+ 27 - 27
core/mem.odin

@@ -1,42 +1,42 @@
 #import "fmt.odin";
 #import "os.odin";
 
-const swap = proc(b: u16) -> u16 #foreign __llvm_core "llvm.bswap.i16";
-const swap = proc(b: u32) -> u32 #foreign __llvm_core "llvm.bswap.i32";
-const swap = proc(b: u64) -> u64 #foreign __llvm_core "llvm.bswap.i64";
+proc swap(b: u16) -> u16 #foreign __llvm_core "llvm.bswap.i16";
+proc swap(b: u32) -> u32 #foreign __llvm_core "llvm.bswap.i32";
+proc swap(b: u64) -> u64 #foreign __llvm_core "llvm.bswap.i64";
 
 
-const set = proc(data: rawptr, value: i32, len: int) -> rawptr {
+proc set(data: rawptr, value: i32, len: int) -> rawptr {
 	return __mem_set(data, value, len);
 }
-const zero = proc(data: rawptr, len: int) -> rawptr {
+proc zero(data: rawptr, len: int) -> rawptr {
 	return __mem_zero(data, len);
 }
-const copy = proc(dst, src: rawptr, len: int) -> rawptr {
+proc copy(dst, src: rawptr, len: int) -> rawptr {
 	return __mem_copy(dst, src, len);
 }
-const copy_non_overlapping = proc(dst, src: rawptr, len: int) -> rawptr {
+proc copy_non_overlapping(dst, src: rawptr, len: int) -> rawptr {
 	return __mem_copy_non_overlapping(dst, src, len);
 }
-const compare = proc(a, b: []u8) -> int {
+proc compare(a, b: []u8) -> int {
 	return __mem_compare(&a[0], &b[0], min(len(a), len(b)));
 }
 
 
 
-const kilobytes = proc(x: int) -> int #inline { return          (x) * 1024; }
-const megabytes = proc(x: int) -> int #inline { return kilobytes(x) * 1024; }
-const gigabytes = proc(x: int) -> int #inline { return megabytes(x) * 1024; }
-const terabytes = proc(x: int) -> int #inline { return gigabytes(x) * 1024; }
+proc kilobytes(x: int) -> int #inline { return          (x) * 1024; }
+proc megabytes(x: int) -> int #inline { return kilobytes(x) * 1024; }
+proc gigabytes(x: int) -> int #inline { return megabytes(x) * 1024; }
+proc terabytes(x: int) -> int #inline { return gigabytes(x) * 1024; }
 
-const is_power_of_two = proc(x: int) -> bool {
+proc is_power_of_two(x: int) -> bool {
 	if x <= 0 {
 		return false;
 	}
 	return (x & (x-1)) == 0;
 }
 
-const align_forward = proc(ptr: rawptr, align: int) -> rawptr {
+proc align_forward(ptr: rawptr, align: int) -> rawptr {
 	assert(is_power_of_two(align));
 
 	var a = uint(align);
@@ -54,7 +54,7 @@ const AllocationHeader = struct {
 	size: int,
 }
 
-const allocation_header_fill = proc(header: ^AllocationHeader, data: rawptr, size: int) {
+proc allocation_header_fill(header: ^AllocationHeader, data: rawptr, size: int) {
 	header.size = size;
 	var ptr = ^int(header+1);
 
@@ -62,7 +62,7 @@ const allocation_header_fill = proc(header: ^AllocationHeader, data: rawptr, siz
 		(ptr+i)^ = -1;
 	}
 }
-const allocation_header = proc(data: rawptr) -> ^AllocationHeader {
+proc allocation_header(data: rawptr) -> ^AllocationHeader {
 	if data == nil {
 		return nil;
 	}
@@ -94,19 +94,19 @@ const ArenaTempMemory = struct {
 
 
 
-const init_arena_from_memory = proc(using a: ^Arena, data: []u8) {
+proc init_arena_from_memory(using a: ^Arena, data: []u8) {
 	backing    = Allocator{};
 	memory     = data[0..<0];
 	temp_count = 0;
 }
 
-const init_arena_from_context = proc(using a: ^Arena, size: int) {
+proc init_arena_from_context(using a: ^Arena, size: int) {
 	backing = context.allocator;
 	memory = make([]u8, size);
 	temp_count = 0;
 }
 
-const free_arena = proc(using a: ^Arena) {
+proc free_arena(using a: ^Arena) {
 	if backing.procedure != nil {
 		push_allocator backing {
 			free(memory);
@@ -116,14 +116,14 @@ const free_arena = proc(using a: ^Arena) {
 	}
 }
 
-const arena_allocator = proc(arena: ^Arena) -> Allocator {
+proc arena_allocator(arena: ^Arena) -> Allocator {
 	return Allocator{
 		procedure = arena_allocator_proc,
 		data = arena,
 	};
 }
 
-const arena_allocator_proc = proc(allocator_data: rawptr, mode: AllocatorMode,
+proc arena_allocator_proc(allocator_data: rawptr, mode: AllocatorMode,
                           size, alignment: int,
                           old_memory: rawptr, old_size: int, flags: u64) -> rawptr {
 	using AllocatorMode;
@@ -158,7 +158,7 @@ const arena_allocator_proc = proc(allocator_data: rawptr, mode: AllocatorMode,
 	return nil;
 }
 
-const begin_arena_temp_memory = proc(a: ^Arena) -> ArenaTempMemory {
+proc begin_arena_temp_memory(a: ^Arena) -> ArenaTempMemory {
 	var tmp: ArenaTempMemory;
 	tmp.arena = a;
 	tmp.original_count = len(a.memory);
@@ -166,7 +166,7 @@ const begin_arena_temp_memory = proc(a: ^Arena) -> ArenaTempMemory {
 	return tmp;
 }
 
-const end_arena_temp_memory = proc(using tmp: ArenaTempMemory) {
+proc end_arena_temp_memory(using tmp: ArenaTempMemory) {
 	assert(len(arena.memory) >= original_count);
 	assert(arena.temp_count > 0);
 	arena.memory = arena.memory[0..<original_count];
@@ -179,8 +179,8 @@ const end_arena_temp_memory = proc(using tmp: ArenaTempMemory) {
 
 
 
-const align_of_type_info = proc(type_info: ^TypeInfo) -> int {
-	const prev_pow2 = proc(n: i64) -> i64 {
+proc align_of_type_info(type_info: ^TypeInfo) -> int {
+	proc prev_pow2(n: i64) -> i64 {
 		if n <= 0 {
 			return 0;
 		}
@@ -241,12 +241,12 @@ const align_of_type_info = proc(type_info: ^TypeInfo) -> int {
 	return 0;
 }
 
-const align_formula = proc(size, align: int) -> int {
+proc align_formula(size, align: int) -> int {
 	var result = size + align-1;
 	return result - result%align;
 }
 
-const size_of_type_info = proc(type_info: ^TypeInfo) -> int {
+proc size_of_type_info(type_info: ^TypeInfo) -> int {
 	const WORD_SIZE = size_of(int);
 	using TypeInfo;
 	match info in type_info {

+ 31 - 31
core/opengl.odin

@@ -4,38 +4,38 @@
 #import "sys/wgl.odin" when ODIN_OS == "windows";
 #load "opengl_constants.odin";
 
-const Clear         = proc(mask: u32)                                #foreign lib "glClear";
-const ClearColor    = proc(r, g, b, a: f32)                          #foreign lib "glClearColor";
-const Begin         = proc(mode: i32)                                #foreign lib "glBegin";
-const End           = proc()                                         #foreign lib "glEnd";
-const Finish        = proc()                                         #foreign lib "glFinish";
-const BlendFunc     = proc(sfactor, dfactor: i32)                    #foreign lib "glBlendFunc";
-const Enable        = proc(cap: i32)                                 #foreign lib "glEnable";
-const Disable       = proc(cap: i32)                                 #foreign lib "glDisable";
-const GenTextures   = proc(count: i32, result: ^u32)                 #foreign lib "glGenTextures";
-const DeleteTextures= proc(count: i32, result: ^u32)                 #foreign lib "glDeleteTextures";
-const TexParameteri = proc(target, pname, param: i32)                #foreign lib "glTexParameteri";
-const TexParameterf = proc(target: i32, pname: i32, param: f32)      #foreign lib "glTexParameterf";
-const BindTexture   = proc(target: i32, texture: u32)                #foreign lib "glBindTexture";
-const LoadIdentity  = proc()                                         #foreign lib "glLoadIdentity";
-const Viewport      = proc(x, y, width, height: i32)                 #foreign lib "glViewport";
-const Ortho         = proc(left, right, bottom, top, near, far: f64) #foreign lib "glOrtho";
-const Color3f       = proc(r, g, b: f32)                             #foreign lib "glColor3f";
-const Vertex3f      = proc(x, y, z: f32)                             #foreign lib "glVertex3f";
-const GetError      = proc() -> i32                                  #foreign lib "glGetError";
-const GetString     = proc(name: i32) -> ^u8                       #foreign lib "glGetString";
-const GetIntegerv   = proc(name: i32, v: ^i32)                       #foreign lib "glGetIntegerv";
-const TexCoord2f    = proc(x, y: f32)                                #foreign lib "glTexCoord2f";
-const TexImage2D    = proc(target, level, internal_format,
-                      width, height, border,
-                      format, type_: i32, pixels: rawptr)        #foreign lib "glTexImage2D";
-
-
-const _string_data = proc(s: string) -> ^u8 #inline { return &s[0]; }
+proc Clear         (mask: u32)                                #foreign lib "glClear";
+proc ClearColor    (r, g, b, a: f32)                          #foreign lib "glClearColor";
+proc Begin         (mode: i32)                                #foreign lib "glBegin";
+proc End           ()                                         #foreign lib "glEnd";
+proc Finish        ()                                         #foreign lib "glFinish";
+proc BlendFunc     (sfactor, dfactor: i32)                    #foreign lib "glBlendFunc";
+proc Enable        (cap: i32)                                 #foreign lib "glEnable";
+proc Disable       (cap: i32)                                 #foreign lib "glDisable";
+proc GenTextures   (count: i32, result: ^u32)                 #foreign lib "glGenTextures";
+proc DeleteTextures(count: i32, result: ^u32)                 #foreign lib "glDeleteTextures";
+proc TexParameteri (target, pname, param: i32)                #foreign lib "glTexParameteri";
+proc TexParameterf (target: i32, pname: i32, param: f32)      #foreign lib "glTexParameterf";
+proc BindTexture   (target: i32, texture: u32)                #foreign lib "glBindTexture";
+proc LoadIdentity  ()                                         #foreign lib "glLoadIdentity";
+proc Viewport      (x, y, width, height: i32)                 #foreign lib "glViewport";
+proc Ortho         (left, right, bottom, top, near, far: f64) #foreign lib "glOrtho";
+proc Color3f       (r, g, b: f32)                             #foreign lib "glColor3f";
+proc Vertex3f      (x, y, z: f32)                             #foreign lib "glVertex3f";
+proc GetError      () -> i32                                  #foreign lib "glGetError";
+proc GetString     (name: i32) -> ^u8                         #foreign lib "glGetString";
+proc GetIntegerv   (name: i32, v: ^i32)                       #foreign lib "glGetIntegerv";
+proc TexCoord2f    (x, y: f32)                                #foreign lib "glTexCoord2f";
+proc TexImage2D    (target, level, internal_format,
+                    width, height, border,
+                    format, type_: i32, pixels: rawptr)       #foreign lib "glTexImage2D";
+
+
+proc _string_data(s: string) -> ^u8 #inline { return &s[0]; }
 
 var _libgl = win32.load_library_a(_string_data("opengl32.dll\x00"));
 
-const get_proc_address = proc(name: string) -> proc() #cc_c {
+proc get_proc_address(name: string) -> proc() #cc_c {
 	if name[len(name)-1] == 0 {
 		name = name[0..<len(name)-1];
 	}
@@ -108,8 +108,8 @@ var UniformMatrix4fv:         proc(loc: i32, count: u32, transpose: i32, value:
 
 var GetUniformLocation:       proc(program: u32, name: ^u8) -> i32 #cc_c;
 
-const init = proc() {
-	const set_proc_address = proc(p: rawptr, name: string) #inline {
+proc init() {
+	proc set_proc_address(p: rawptr, name: string) #inline {
 		var x = ^(proc() #cc_c)(p);
 		x^ = get_proc_address(name);
 	}

+ 3 - 3
core/os.odin

@@ -2,11 +2,11 @@
 #load "os_x.odin"       when ODIN_OS == "osx";
 #load "os_linux.odin"   when ODIN_OS == "linux";
 
-const write_string = proc(fd: Handle, str: string) -> (int, Errno) {
+proc write_string(fd: Handle, str: string) -> (int, Errno) {
 	return write(fd, []u8(str));
 }
 
-const read_entire_file = proc(name: string) -> ([]u8, bool) {
+proc read_entire_file(name: string) -> ([]u8, bool) {
 	var fd, err = open(name, O_RDONLY, 0);
 	if err != 0 {
 		return nil, false;
@@ -35,7 +35,7 @@ const read_entire_file = proc(name: string) -> ([]u8, bool) {
 	return data[0..<bytes_read], true;
 }
 
-const write_entire_file = proc(name: string, data: []u8) -> bool {
+proc write_entire_file(name: string, data: []u8) -> bool {
 	var fd, err = open(name, O_WRONLY, 0);
 	if err != 0 {
 		return false;

+ 46 - 46
core/os_linux.odin

@@ -107,13 +107,13 @@ const S_ISUID = 0004000; // Set user id on execution
 const S_ISGID = 0002000; // Set group id on execution
 const S_ISVTX = 0001000; // Directory restrcted delete
 
-const S_ISLNK  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFLNK; }
-const S_ISREG  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFREG; }
-const S_ISDIR  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFDIR; }
-const S_ISCHR  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFCHR; }
-const S_ISBLK  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFBLK; }
-const S_ISFIFO = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFIFO; }
-const S_ISSOCK = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFSOCK;}
+proc S_ISLNK (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFLNK; }
+proc S_ISREG (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFREG; }
+proc S_ISDIR (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFDIR; }
+proc S_ISCHR (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFCHR; }
+proc S_ISBLK (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFBLK; }
+proc S_ISFIFO(m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFIFO; }
+proc S_ISSOCK(m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFSOCK;}
 
 const R_OK = 4; // Test for read permission
 const W_OK = 2; // Test for write permission
@@ -123,29 +123,29 @@ const F_OK = 0; // Test for file existance
 #foreign_system_library dl   "dl";
 #foreign_system_library libc "c";
 
-const _unix_open   = proc(path: ^u8, mode: int) -> Handle                               #foreign libc "open";
-const _unix_close  = proc(fd: Handle) -> i32                                            #foreign libc "close";
-const _unix_read   = proc(fd: Handle, buf: rawptr, size: int) -> int                    #foreign libc "read";
-const _unix_write  = proc(fd: Handle, buf: rawptr, size: int) -> int                    #foreign libc "write";
-const _unix_seek   = proc(fd: Handle, offset: i64, whence: i32) -> i64                  #foreign libc "lseek64";
-const _unix_gettid = proc() -> u64                                                      #foreign libc "gettid";
-const _unix_stat   = proc(path: ^u8, stat: ^Stat) -> i32                                #foreign libc "stat";
-const _unix_access = proc(path: ^u8, mask: int) -> i32                                  #foreign libc "access";
+proc _unix_open  (path: ^u8, mode: int) -> Handle                               #foreign libc "open";
+proc _unix_close (fd: Handle) -> i32                                            #foreign libc "close";
+proc _unix_read  (fd: Handle, buf: rawptr, size: int) -> int                    #foreign libc "read";
+proc _unix_write (fd: Handle, buf: rawptr, size: int) -> int                    #foreign libc "write";
+proc _unix_seek  (fd: Handle, offset: i64, whence: i32) -> i64                  #foreign libc "lseek64";
+proc _unix_gettid() -> u64                                                      #foreign libc "gettid";
+proc _unix_stat  (path: ^u8, stat: ^Stat) -> i32                                #foreign libc "stat";
+proc _unix_access(path: ^u8, mask: int) -> i32                                  #foreign libc "access";
 
-const _unix_malloc  = proc(size: int) -> rawptr                                         #foreign libc "malloc";
-const _unix_free    = proc(ptr: rawptr)                                                 #foreign libc "free";
-const _unix_realloc = proc(ptr: rawptr, size: int) -> rawptr                            #foreign libc "realloc";
-const _unix_getenv  = proc(^u8) -> ^u8                                                  #foreign libc "getenv";
+proc _unix_malloc (size: int) -> rawptr                                         #foreign libc "malloc";
+proc _unix_free   (ptr: rawptr)                                                 #foreign libc "free";
+proc _unix_realloc(ptr: rawptr, size: int) -> rawptr                            #foreign libc "realloc";
+proc _unix_getenv (^u8) -> ^u8                                                  #foreign libc "getenv";
 
-const _unix_exit = proc(status: int)                                                    #foreign libc "exit";
+proc _unix_exit(status: int)                                                    #foreign libc "exit";
 
-const _unix_dlopen  = proc(filename: ^u8, flags: int) -> rawptr                         #foreign dl   "dlopen";
-const _unix_dlsym   = proc(handle: rawptr, symbol: ^u8) ->  (proc() #cc_c)              #foreign dl   "dlsym";
-const _unix_dlclose = proc(handle: rawptr) -> int                                       #foreign dl   "dlclose";
-const _unix_dlerror = proc() -> ^u8                                                     #foreign dl   "dlerror";
+proc _unix_dlopen (filename: ^u8, flags: int) -> rawptr                         #foreign dl   "dlopen";
+proc _unix_dlsym  (handle: rawptr, symbol: ^u8) ->  (proc() #cc_c)              #foreign dl   "dlsym";
+proc _unix_dlclose(handle: rawptr) -> int                                       #foreign dl   "dlclose";
+proc _unix_dlerror() -> ^u8                                                     #foreign dl   "dlerror";
 
 // TODO(zangent): Change this to just `open` when Bill fixes overloading.
-const open_simple = proc(path: string, mode: int) -> (Handle, Errno) {
+proc open_simple(path: string, mode: int) -> (Handle, Errno) {
 
 	var cstr = strings.new_c_string(path);
 	var handle = _unix_open(cstr, mode);
@@ -156,30 +156,30 @@ const open_simple = proc(path: string, mode: int) -> (Handle, Errno) {
 	return handle, 0;
 }
 // NOTE(zangent): This is here for compatability reasons. Should this be here?
-const open = proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
+proc open(path: string, mode: int, perm: u32) -> (Handle, Errno) {
 	return open_simple(path, mode);
 }
 
-const close = proc(fd: Handle) {
+proc close(fd: Handle) {
 	_unix_close(fd);
 }
 
-const read = proc(fd: Handle, data: []u8) -> (int, Errno) {
+proc read(fd: Handle, data: []u8) -> (int, Errno) {
 	var sz = _unix_read(fd, &data[0], len(data));
 	return sz, 0;
 }
 
-const write = proc(fd: Handle, data: []u8) -> (int, Errno) {
+proc write(fd: Handle, data: []u8) -> (int, Errno) {
 	var sz = _unix_write(fd, &data[0], len(data));
 	return sz, 0;
 }
 
-const seek = proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
+proc seek(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
 	var res = _unix_seek(fd, offset, i32(whence));
 	return res, 0;
 }
 
-const file_size = proc(fd: Handle) -> (i64, Errno) {
+proc file_size(fd: Handle) -> (i64, Errno) {
 	var prev, _ = seek(fd, 0, SEEK_CUR);
 	var size, err = seek(fd, 0, SEEK_END);
 	seek(fd, prev, SEEK_SET);
@@ -193,11 +193,11 @@ var stdout: Handle = 1;
 var stderr: Handle = 2;
 
 /* TODO(zangent): Implement these!
-const last_write_time = proc(fd: Handle) -> FileTime {}
-const last_write_time_by_name = proc(name: string) -> FileTime {}
+proc last_write_time(fd: Handle) -> FileTime {}
+proc last_write_time_by_name(name: string) -> FileTime {}
 */
 
-const stat = proc(path: string) -> (Stat, int) #inline {
+proc stat(path: string) -> (Stat, int) #inline {
 	var s: Stat;
 	var cstr = strings.new_c_string(path);
 	defer free(cstr);
@@ -205,26 +205,26 @@ const stat = proc(path: string) -> (Stat, int) #inline {
 	return s, int(ret_int);
 }
 
-const access = proc(path: string, mask: int) -> bool #inline {
+proc access(path: string, mask: int) -> bool #inline {
 	var cstr = strings.new_c_string(path);
 	defer free(cstr);
 	return _unix_access(cstr, mask) == 0;
 }
 
-const heap_alloc = proc(size: int) -> rawptr {
+proc heap_alloc(size: int) -> rawptr {
 	assert(size > 0);
 	return _unix_malloc(size);
 }
 
-const heap_resize = proc(ptr: rawptr, new_size: int) -> rawptr {
+proc heap_resize(ptr: rawptr, new_size: int) -> rawptr {
 	return _unix_realloc(ptr, new_size);
 }
 
-const heap_free = proc(ptr: rawptr) {
+proc heap_free(ptr: rawptr) {
 	_unix_free(ptr);
 }
 
-const getenv = proc(name: string) -> (string, bool) {
+proc getenv(name: string) -> (string, bool) {
 	var path_str = strings.new_c_string(name);
 	var cstr: ^u8 = _unix_getenv(path_str);
 	free(path_str);
@@ -234,38 +234,38 @@ const getenv = proc(name: string) -> (string, bool) {
 	return strings.to_odin_string(cstr), true;
 }
 
-const exit = proc(code: int) {
+proc exit(code: int) {
 	_unix_exit(code);
 }
 
-const current_thread_id = proc() -> int {
+proc current_thread_id() -> int {
 	// return int(_unix_gettid());
 	return 0;
 }
 
-const dlopen = proc(filename: string, flags: int) -> rawptr #inline {
+proc dlopen(filename: string, flags: int) -> rawptr #inline {
 	var cstr = strings.new_c_string(filename);
 	var handle = _unix_dlopen(cstr, flags);
 	free(cstr);
 	return handle;
 }
-const dlsym = proc(handle: rawptr, symbol: string) -> (proc() #cc_c) #inline {
+proc dlsym(handle: rawptr, symbol: string) -> (proc() #cc_c) #inline {
 	assert(handle != nil);
 	var cstr = strings.new_c_string(symbol);
 	var proc_handle = _unix_dlsym(handle, cstr);
 	free(cstr);
 	return proc_handle;
 }
-const dlclose = proc(handle: rawptr) -> bool #inline {
+proc dlclose(handle: rawptr) -> bool #inline {
 	assert(handle != nil);
 	return _unix_dlclose(handle) == 0;
 }
-const dlerror = proc() -> string {
+proc dlerror() -> string {
 	return strings.to_odin_string(_unix_dlerror());
 }
 
 
-const _alloc_command_line_arguments = proc() -> []string {
+proc _alloc_command_line_arguments() -> []string {
 	// TODO(bill):
 	return nil;
 }

+ 16 - 16
core/os_windows.odin

@@ -52,7 +52,7 @@ const ERROR_FILE_IS_PIPE: Errno = 1<<29 + 0;
 immutable var args = _alloc_command_line_arguments();
 
 
-const open = proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
+proc open(path: string, mode: int, perm: u32) -> (Handle, Errno) {
 	if len(path) == 0 {
 		return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
 	}
@@ -104,12 +104,12 @@ const open = proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
 	return INVALID_HANDLE, Errno(err);
 }
 
-const close = proc(fd: Handle) {
+proc close(fd: Handle) {
 	win32.close_handle(win32.Handle(fd));
 }
 
 
-const write = proc(fd: Handle, data: []u8) -> (int, Errno) {
+proc write(fd: Handle, data: []u8) -> (int, Errno) {
 	if len(data) == 0 {
 		return 0, ERROR_NONE;
 	}
@@ -136,7 +136,7 @@ const write = proc(fd: Handle, data: []u8) -> (int, Errno) {
 	return int(total_write), ERROR_NONE;
 }
 
-const read = proc(fd: Handle, data: []u8) -> (int, Errno) {
+proc read(fd: Handle, data: []u8) -> (int, Errno) {
 	if len(data) == 0 {
 		return 0, ERROR_NONE;
 	}
@@ -165,7 +165,7 @@ const read = proc(fd: Handle, data: []u8) -> (int, Errno) {
 	return int(total_read), ERROR_NONE;
 }
 
-const seek = proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
+proc seek(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
 	var w: u32;
 	match whence {
 	case 0: w = win32.FILE_BEGIN;
@@ -186,7 +186,7 @@ const seek = proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
 	return i64(hi)<<32 + i64(dw_ptr), ERROR_NONE;
 }
 
-const file_size = proc(fd: Handle) -> (i64, Errno) {
+proc file_size(fd: Handle) -> (i64, Errno) {
 	var length: i64;
 	var err: Errno;
 	if win32.get_file_size_ex(win32.Handle(fd), &length) == 0 {
@@ -203,7 +203,7 @@ var stdout = get_std_handle(win32.STD_OUTPUT_HANDLE);
 var stderr = get_std_handle(win32.STD_ERROR_HANDLE);
 
 
-const get_std_handle = proc(h: int) -> Handle {
+proc get_std_handle(h: int) -> Handle {
 	var fd = win32.get_std_handle(i32(h));
 	win32.set_handle_information(fd, win32.HANDLE_FLAG_INHERIT, 0);
 	return Handle(fd);
@@ -214,7 +214,7 @@ const get_std_handle = proc(h: int) -> Handle {
 
 
 
-const last_write_time = proc(fd: Handle) -> FileTime {
+proc last_write_time(fd: Handle) -> FileTime {
 	var file_info: win32.ByHandleFileInformation;
 	win32.get_file_information_by_handle(win32.Handle(fd), &file_info);
 	var lo = FileTime(file_info.last_write_time.lo);
@@ -222,7 +222,7 @@ const last_write_time = proc(fd: Handle) -> FileTime {
 	return lo | hi << 32;
 }
 
-const last_write_time_by_name = proc(name: string) -> FileTime {
+proc last_write_time_by_name(name: string) -> FileTime {
 	var last_write_time: win32.Filetime;
 	var data: win32.FileAttributeData;
 	var buf: [1024]u8;
@@ -242,10 +242,10 @@ const last_write_time_by_name = proc(name: string) -> FileTime {
 
 
 
-const heap_alloc = proc(size: int) -> rawptr {
+proc heap_alloc(size: int) -> rawptr {
 	return win32.heap_alloc(win32.get_process_heap(), win32.HEAP_ZERO_MEMORY, size);
 }
-const heap_resize = proc(ptr: rawptr, new_size: int) -> rawptr {
+proc heap_resize(ptr: rawptr, new_size: int) -> rawptr {
 	if new_size == 0 {
 		heap_free(ptr);
 		return nil;
@@ -255,7 +255,7 @@ const heap_resize = proc(ptr: rawptr, new_size: int) -> rawptr {
 	}
 	return win32.heap_realloc(win32.get_process_heap(), win32.HEAP_ZERO_MEMORY, ptr, new_size);
 }
-const heap_free = proc(ptr: rawptr) {
+proc heap_free(ptr: rawptr) {
 	if ptr == nil {
 		return;
 	}
@@ -263,21 +263,21 @@ const heap_free = proc(ptr: rawptr) {
 }
 
 
-const exit = proc(code: int) {
+proc exit(code: int) {
 	win32.exit_process(u32(code));
 }
 
 
 
-const current_thread_id = proc() -> int {
+proc current_thread_id() -> int {
 	return int(win32.get_current_thread_id());
 }
 
 
 
 
-const _alloc_command_line_arguments = proc() -> []string {
-	const alloc_ucs2_to_utf8 = proc(wstr: ^u16) -> string {
+proc _alloc_command_line_arguments() -> []string {
+	proc alloc_ucs2_to_utf8(wstr: ^u16) -> string {
 		var wstr_len = 0;
 		for (wstr+wstr_len)^ != 0 {
 			wstr_len++;

+ 45 - 45
core/os_x.odin

@@ -107,13 +107,13 @@ const S_ISUID = 0004000; // Set user id on execution
 const S_ISGID = 0002000; // Set group id on execution
 const S_ISVTX = 0001000; // Directory restrcted delete
 
-const S_ISLNK  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFLNK; }
-const S_ISREG  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFREG; }
-const S_ISDIR  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFDIR; }
-const S_ISCHR  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFCHR; }
-const S_ISBLK  = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFBLK; }
-const S_ISFIFO = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFIFO; }
-const S_ISSOCK = proc(m: u32) -> bool #inline  {return ((m) & S_IFMT) == S_IFSOCK;}
+proc S_ISLNK (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFLNK; }
+proc S_ISREG (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFREG; }
+proc S_ISDIR (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFDIR; }
+proc S_ISCHR (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFCHR; }
+proc S_ISBLK (m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFBLK; }
+proc S_ISFIFO(m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFIFO; }
+proc S_ISSOCK(m: u32) -> bool #inline  {return (m & S_IFMT) == S_IFSOCK;}
 
 const R_OK = 4; // Test for read permission
 const W_OK = 2; // Test for write permission
@@ -123,30 +123,30 @@ const F_OK = 0; // Test for file existance
 #foreign_system_library dl   "dl";
 #foreign_system_library libc "c";
 
-const unix_open   = proc(path: ^u8, mode: int) -> Handle                               #foreign libc "open";
-const unix_close  = proc(handle: Handle)                                               #foreign libc "close";
-const unix_read   = proc(handle: Handle, buffer: rawptr, count: int) -> AddressSize    #foreign libc "read";
-const unix_write  = proc(handle: Handle, buffer: rawptr, count: int) -> AddressSize    #foreign libc "write";
-const unix_lseek  = proc(fs: Handle, offset: AddressSize, whence: int) -> AddressSize  #foreign libc "lseek";
-const unix_gettid = proc() -> u64                                                      #foreign libc "gettid";
-const unix_stat   = proc(path: ^u8, stat: ^Stat) -> int                                #foreign libc "stat";
-const unix_access = proc(path: ^u8, mask: int) -> int                                  #foreign libc "access";
+proc unix_open  (path: ^u8, mode: int) -> Handle                               #foreign libc "open";
+proc unix_close (handle: Handle)                                               #foreign libc "close";
+proc unix_read  (handle: Handle, buffer: rawptr, count: int) -> AddressSize    #foreign libc "read";
+proc unix_write (handle: Handle, buffer: rawptr, count: int) -> AddressSize    #foreign libc "write";
+proc unix_lseek (fs: Handle, offset: AddressSize, whence: int) -> AddressSize  #foreign libc "lseek";
+proc unix_gettid() -> u64                                                      #foreign libc "gettid";
+proc unix_stat  (path: ^u8, stat: ^Stat) -> int                                #foreign libc "stat";
+proc unix_access(path: ^u8, mask: int) -> int                                  #foreign libc "access";
 
-const unix_malloc  = proc(size: int) -> rawptr                                         #foreign libc "malloc";
-const unix_free    = proc(ptr: rawptr)                                                 #foreign libc "free";
-const unix_realloc = proc(ptr: rawptr, size: int) -> rawptr                            #foreign libc "realloc";
-const unix_getenv  = proc(^u8) -> ^u8                                                  #foreign libc "getenv";
+proc unix_malloc (size: int) -> rawptr                                         #foreign libc "malloc";
+proc unix_free   (ptr: rawptr)                                                 #foreign libc "free";
+proc unix_realloc(ptr: rawptr, size: int) -> rawptr                            #foreign libc "realloc";
+proc unix_getenv (^u8) -> ^u8                                                  #foreign libc "getenv";
 
-const unix_exit = proc(status: int)                                                    #foreign libc "exit";
+proc unix_exit(status: int)                                                    #foreign libc "exit";
 
-const unix_dlopen  = proc(filename: ^u8, flags: int) -> rawptr                         #foreign dl   "dlopen";
-const unix_dlsym   = proc(handle: rawptr, symbol: ^u8) ->  (proc() #cc_c)              #foreign dl   "dlsym";
-const unix_dlclose = proc(handle: rawptr) -> int                                       #foreign dl   "dlclose";
-const unix_dlerror = proc() -> ^u8                                                     #foreign dl   "dlerror";
+proc unix_dlopen (filename: ^u8, flags: int) -> rawptr                         #foreign dl   "dlopen";
+proc unix_dlsym  (handle: rawptr, symbol: ^u8) ->  (proc() #cc_c)              #foreign dl   "dlsym";
+proc unix_dlclose(handle: rawptr) -> int                                       #foreign dl   "dlclose";
+proc unix_dlerror() -> ^u8                                                     #foreign dl   "dlerror";
 
 
 // TODO(zangent): Change this to just `open` when Bill fixes overloading.
-const open_simple = proc(path: string, mode: int) -> (Handle, Errno) {
+proc open_simple(path: string, mode: int) -> (Handle, Errno) {
 
 	var cstr = strings.new_c_string(path);
 	var handle = unix_open(cstr, mode);
@@ -158,15 +158,15 @@ const open_simple = proc(path: string, mode: int) -> (Handle, Errno) {
 }
 
 // NOTE(zangent): This is here for compatability reasons. Should this be here?
-const open = proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
+proc open(path: string, mode: int, perm: u32) -> (Handle, Errno) {
 	return open_simple(path, mode);
 }
 
-const close = proc(fd: Handle) {
+proc close(fd: Handle) {
 	unix_close(fd);
 }
 
-const write = proc(fd: Handle, data: []u8) -> (AddressSize, Errno) {
+proc write(fd: Handle, data: []u8) -> (AddressSize, Errno) {
 	assert(fd != -1);
 
 	var bytes_written = unix_write(fd, &data[0], len(data));
@@ -176,7 +176,7 @@ const write = proc(fd: Handle, data: []u8) -> (AddressSize, Errno) {
 	return bytes_written, 0;
 }
 
-const read = proc(fd: Handle, data: []u8) -> (AddressSize, Errno) {
+proc read(fd: Handle, data: []u8) -> (AddressSize, Errno) {
 	assert(fd != -1);
 
 	var bytes_read = unix_read(fd, &data[0], len(data));
@@ -186,7 +186,7 @@ const read = proc(fd: Handle, data: []u8) -> (AddressSize, Errno) {
 	return bytes_read, 0;
 }
 
-const seek = proc(fd: Handle, offset: AddressSize, whence: int) -> (AddressSize, Errno) {
+proc seek(fd: Handle, offset: AddressSize, whence: int) -> (AddressSize, Errno) {
 	assert(fd != -1);
 
 	var final_offset = unix_lseek(fd, offset, whence);
@@ -196,7 +196,7 @@ const seek = proc(fd: Handle, offset: AddressSize, whence: int) -> (AddressSize,
 	return final_offset, 0;
 }
 
-const file_size = proc(fd: Handle) -> (i64, Errno) {
+proc file_size(fd: Handle) -> (i64, Errno) {
 	var prev, _ = seek(fd, 0, SEEK_CUR);
 	var size, err = seek(fd, 0, SEEK_END);
 	seek(fd, prev, SEEK_SET);
@@ -211,11 +211,11 @@ var stdout: Handle = 1; // get_std_handle(win32.STD_OUTPUT_HANDLE);
 var stderr: Handle = 2; // get_std_handle(win32.STD_ERROR_HANDLE);
 
 /* TODO(zangent): Implement these!
-const last_write_time = proc(fd: Handle) -> FileTime {}
-const last_write_time_by_name = proc(name: string) -> FileTime {}
+proc last_write_time(fd: Handle) -> FileTime {}
+proc last_write_time_by_name(name: string) -> FileTime {}
 */
 
-const stat = proc(path: string) -> (Stat, bool) #inline {
+proc stat(path: string) -> (Stat, bool) #inline {
 	var s: Stat;
 	var cstr = strings.new_c_string(path);
 	defer free(cstr);
@@ -223,24 +223,24 @@ const stat = proc(path: string) -> (Stat, bool) #inline {
 	return s, ret_int==0;
 }
 
-const access = proc(path: string, mask: int) -> bool #inline {
+proc access(path: string, mask: int) -> bool #inline {
 	var cstr = strings.new_c_string(path);
 	defer free(cstr);
 	return unix_access(cstr, mask) == 0;
 }
 
-const heap_alloc = proc(size: int) -> rawptr #inline {
+proc heap_alloc(size: int) -> rawptr #inline {
 	assert(size > 0);
 	return unix_malloc(size);
 }
-const heap_resize = proc(ptr: rawptr, new_size: int) -> rawptr #inline {
+proc heap_resize(ptr: rawptr, new_size: int) -> rawptr #inline {
 	return unix_realloc(ptr, new_size);
 }
-const heap_free = proc(ptr: rawptr) #inline {
+proc heap_free(ptr: rawptr) #inline {
 	unix_free(ptr);
 }
 
-const getenv = proc(name: string) -> (string, bool) {
+proc getenv(name: string) -> (string, bool) {
 	var path_str = strings.new_c_string(name);
 	var cstr: ^u8 = unix_getenv(path_str);
 	free(path_str);
@@ -250,33 +250,33 @@ const getenv = proc(name: string) -> (string, bool) {
 	return strings.to_odin_string(cstr), true;
 }
 
-const exit = proc(code: int) #inline {
+proc exit(code: int) #inline {
 	unix_exit(code);
 }
 
 
-const current_thread_id = proc() -> int {
+proc current_thread_id() -> int {
 	// return cast(int) unix_gettid();
 	return 0;
 }
 
-const dlopen = proc(filename: string, flags: int) -> rawptr #inline {
+proc dlopen(filename: string, flags: int) -> rawptr #inline {
 	var cstr = strings.new_c_string(filename);
 	var handle = unix_dlopen(cstr, flags);
 	free(cstr);
 	return handle;
 }
-const dlsym = proc(handle: rawptr, symbol: string) -> (proc() #cc_c) #inline {
+proc dlsym(handle: rawptr, symbol: string) -> (proc() #cc_c) #inline {
 	assert(handle != nil);
 	var cstr = strings.new_c_string(symbol);
 	var proc_handle = unix_dlsym(handle, cstr);
 	free(cstr);
 	return proc_handle;
 }
-const dlclose = proc(handle: rawptr) -> bool #inline {
+proc dlclose(handle: rawptr) -> bool #inline {
 	assert(handle != nil);
 	return unix_dlclose(handle) == 0;
 }
-const dlerror = proc() -> string {
+proc dlerror() -> string {
 	return strings.to_odin_string(unix_dlerror());
 }

+ 17 - 17
core/strconv.odin

@@ -7,7 +7,7 @@ const IntFlag = enum {
 }
 
 
-const parse_bool = proc(s: string) -> (result: bool, ok: bool) {
+proc parse_bool(s: string) -> (result: bool, ok: bool) {
 	match s {
 	case "1", "t", "T", "true", "TRUE", "True":
 		return true, true;
@@ -17,7 +17,7 @@ const parse_bool = proc(s: string) -> (result: bool, ok: bool) {
 	return false, false;
 }
 
-const _digit_value = proc(r: rune) -> (int) {
+proc _digit_value(r: rune) -> int {
 	var ri = int(r);
 	var v: int = 16;
 	match r {
@@ -28,7 +28,7 @@ const _digit_value = proc(r: rune) -> (int) {
 	return v;
 }
 
-const parse_i128 = proc(s: string) -> i128 {
+proc parse_i128(s: string) -> i128 {
 	var neg = false;
 	if len(s) > 1 {
 		match s[0] {
@@ -70,7 +70,7 @@ const parse_i128 = proc(s: string) -> i128 {
 	return neg ? -value : value;
 }
 
-const parse_u128 = proc(s: string) -> u128 {
+proc parse_u128(s: string) -> u128 {
 	var neg = false;
 	if len(s) > 1 && s[0] == '+' {
 		s = s[1..];
@@ -107,14 +107,14 @@ const parse_u128 = proc(s: string) -> u128 {
 }
 
 
-const parse_int = proc(s: string) -> int {
+proc parse_int(s: string) -> int {
 	return int(parse_i128(s));
 }
-const parse_uint = proc(s: string, base: int) -> uint {
+proc parse_uint(s: string, base: int) -> uint {
 	return uint(parse_u128(s));
 }
 
-const parse_f64 = proc(s: string) -> f64 {
+proc parse_f64(s: string) -> f64 {
 	var i = 0;
 
 	var sign: f64 = 1;
@@ -189,21 +189,21 @@ const parse_f64 = proc(s: string) -> f64 {
 }
 
 
-const append_bool = proc(buf: []u8, b: bool) -> string {
+proc append_bool(buf: []u8, b: bool) -> string {
 	var s = b ? "true" : "false";
 	append(buf, ..[]u8(s));
 	return string(buf);
 }
 
-const append_uint = proc(buf: []u8, u: u64, base: int) -> string {
+proc append_uint(buf: []u8, u: u64, base: int) -> string {
 	return append_bits(buf, u128(u), base, false, 8*size_of(uint), digits, 0);
 }
-const append_int = proc(buf: []u8, i: i64, base: int) -> string {
+proc append_int(buf: []u8, i: i64, base: int) -> string {
 	return append_bits(buf, u128(i), base, true, 8*size_of(int), digits, 0);
 }
-const itoa = proc(buf: []u8, i: int) -> string { return append_int(buf, i64(i), 10); }
+proc itoa(buf: []u8, i: int) -> string { return append_int(buf, i64(i), 10); }
 
-const append_float = proc(buf: []u8, f: f64, fmt: u8, prec, bit_size: int) -> string {
+proc append_float(buf: []u8, f: f64, fmt: u8, prec, bit_size: int) -> string {
 	return string(generic_ftoa(buf, f, fmt, prec, bit_size));
 }
 
@@ -228,7 +228,7 @@ var _f32_info = Float_Info{23, 8,  -127};
 var _f64_info = Float_Info{52, 11, -1023};
 
 
-const generic_ftoa = proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8 {
+proc generic_ftoa(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8 {
 	var bits: u64;
 	var flt: ^Float_Info;
 	match bit_size {
@@ -300,7 +300,7 @@ const generic_ftoa = proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) ->
 
 
 
-const format_digits = proc(buf: []u8, shortest: bool, neg: bool, digs: DecimalSlice, prec: int, fmt: u8) -> []u8 {
+proc format_digits(buf: []u8, shortest: bool, neg: bool, digs: DecimalSlice, prec: int, fmt: u8) -> []u8 {
 	match fmt {
 	case 'f', 'F':
 		append(buf, neg ? '-' : '+');
@@ -347,7 +347,7 @@ const format_digits = proc(buf: []u8, shortest: bool, neg: bool, digs: DecimalSl
 	return buf;
 }
 
-const round_shortest = proc(d: ^Decimal, mant: u64, exp: int, flt: ^Float_Info) {
+proc round_shortest(d: ^Decimal, mant: u64, exp: int, flt: ^Float_Info) {
 	if mant == 0 { // If mantissa is zero, the number is zero
 		d.count = 0;
 		return;
@@ -418,7 +418,7 @@ const MAX_BASE = 32;
 immutable var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
 
 
-const is_integer_negative = proc(u: u128, is_signed: bool, bit_size: int) -> (unsigned: u128, neg: bool) {
+proc is_integer_negative(u: u128, is_signed: bool, bit_size: int) -> (unsigned: u128, neg: bool) {
 	var neg = false;
 	if is_signed {
 		match bit_size {
@@ -454,7 +454,7 @@ const is_integer_negative = proc(u: u128, is_signed: bool, bit_size: int) -> (un
 	return u, neg;
 }
 
-const append_bits = proc(buf: []u8, u_: u128, base: int, is_signed: bool, bit_size: int, digits: string, flags: IntFlag) -> string {
+proc append_bits(buf: []u8, u_: u128, base: int, is_signed: bool, bit_size: int, digits: string, flags: IntFlag) -> string {
 	if base < 2 || base > MAX_BASE {
 		panic("strconv: illegal base passed to append_bits");
 	}

+ 2 - 2
core/strings.odin

@@ -1,11 +1,11 @@
-const new_c_string = proc(s: string) -> ^u8 {
+proc new_c_string(s: string) -> ^u8 {
 	var c = make([]u8, len(s)+1);
 	copy(c, []u8(s));
 	c[len(s)] = 0;
 	return &c[0];
 }
 
-const to_odin_string = proc(c: ^u8) -> string {
+proc to_odin_string(c: ^u8) -> string {
 	var len = 0;
 	for (c+len)^ != 0 {
 		len++;

+ 11 - 11
core/sync_linux.odin

@@ -12,41 +12,41 @@ const Mutex = struct {
 	_recursion: i32,
 }
 
-const current_thread_id = proc() -> i32 {
+proc current_thread_id() -> i32 {
 	return i32(os.current_thread_id());
 }
 
-const semaphore_init = proc(s: ^Semaphore) {
+proc semaphore_init(s: ^Semaphore) {
 	// s._handle = win32.CreateSemaphoreA(nil, 0, 1<<31-1, nil);
 }
 
-const semaphore_destroy = proc(s: ^Semaphore) {
+proc semaphore_destroy(s: ^Semaphore) {
 	// win32.CloseHandle(s._handle);
 }
 
-const semaphore_post = proc(s: ^Semaphore, count: int) {
+proc semaphore_post(s: ^Semaphore, count: int) {
 	// win32.ReleaseSemaphore(s._handle, cast(i32)count, nil);
 }
 
-const semaphore_release = proc(s: ^Semaphore) #inline {
+proc semaphore_release(s: ^Semaphore) #inline {
 	semaphore_post(s, 1);
 }
 
-const semaphore_wait = proc(s: ^Semaphore) {
+proc semaphore_wait(s: ^Semaphore) {
 	// win32.WaitForSingleObject(s._handle, win32.INFINITE);
 }
 
 
-const mutex_init = proc(m: ^Mutex) {
+proc mutex_init(m: ^Mutex) {
 	atomics.store(&m._counter, 0);
 	atomics.store(&m._owner, current_thread_id());
 	semaphore_init(&m._semaphore);
 	m._recursion = 0;
 }
-const mutex_destroy = proc(m: ^Mutex) {
+proc mutex_destroy(m: ^Mutex) {
 	semaphore_destroy(&m._semaphore);
 }
-const mutex_lock = proc(m: ^Mutex) {
+proc mutex_lock(m: ^Mutex) {
 	var thread_id = current_thread_id();
 	if atomics.fetch_add(&m._counter, 1) > 0 {
 		if thread_id != atomics.load(&m._owner) {
@@ -56,7 +56,7 @@ const mutex_lock = proc(m: ^Mutex) {
 	atomics.store(&m._owner, thread_id);
 	m._recursion++;
 }
-const mutex_try_lock = proc(m: ^Mutex) -> bool {
+proc mutex_try_lock(m: ^Mutex) -> bool {
 	var thread_id = current_thread_id();
 	if atomics.load(&m._owner) == thread_id {
 		atomics.fetch_add(&m._counter, 1);
@@ -73,7 +73,7 @@ const mutex_try_lock = proc(m: ^Mutex) -> bool {
 	m._recursion++;
 	return true;
 }
-const mutex_unlock = proc(m: ^Mutex) {
+proc mutex_unlock(m: ^Mutex) {
 	var recursion: i32;
 	var thread_id = current_thread_id();
 	assert(thread_id == atomics.load(&m._owner));

+ 11 - 11
core/sync_windows.odin

@@ -12,39 +12,39 @@ const Mutex = struct {
 	_recursion: i32,
 }
 
-const current_thread_id = proc() -> i32 {
+proc current_thread_id() -> i32 {
 	return i32(win32.get_current_thread_id());
 }
 
-const semaphore_init = proc(s: ^Semaphore) {
+proc semaphore_init(s: ^Semaphore) {
 	s._handle = win32.create_semaphore_a(nil, 0, 1<<31-1, nil);
 }
 
-const semaphore_destroy = proc(s: ^Semaphore) {
+proc semaphore_destroy(s: ^Semaphore) {
 	win32.close_handle(s._handle);
 }
 
-const semaphore_post = proc(s: ^Semaphore, count: int) {
+proc semaphore_post(s: ^Semaphore, count: int) {
 	win32.release_semaphore(s._handle, i32(count), nil);
 }
 
-const semaphore_release = proc(s: ^Semaphore) #inline { semaphore_post(s, 1); }
+proc semaphore_release(s: ^Semaphore) #inline { semaphore_post(s, 1); }
 
-const semaphore_wait = proc(s: ^Semaphore) {
+proc semaphore_wait(s: ^Semaphore) {
 	win32.wait_for_single_object(s._handle, win32.INFINITE);
 }
 
 
-const mutex_init = proc(m: ^Mutex) {
+proc mutex_init(m: ^Mutex) {
 	atomics.store(&m._counter, 0);
 	atomics.store(&m._owner, current_thread_id());
 	semaphore_init(&m._semaphore);
 	m._recursion = 0;
 }
-const mutex_destroy = proc(m: ^Mutex) {
+proc mutex_destroy(m: ^Mutex) {
 	semaphore_destroy(&m._semaphore);
 }
-const mutex_lock = proc(m: ^Mutex) {
+proc mutex_lock(m: ^Mutex) {
 	var thread_id = current_thread_id();
 	if atomics.fetch_add(&m._counter, 1) > 0 {
 		if thread_id != atomics.load(&m._owner) {
@@ -54,7 +54,7 @@ const mutex_lock = proc(m: ^Mutex) {
 	atomics.store(&m._owner, thread_id);
 	m._recursion++;
 }
-const mutex_try_lock = proc(m: ^Mutex) -> bool {
+proc mutex_try_lock(m: ^Mutex) -> bool {
 	var thread_id = current_thread_id();
 	if atomics.load(&m._owner) == thread_id {
 		atomics.fetch_add(&m._counter, 1);
@@ -71,7 +71,7 @@ const mutex_try_lock = proc(m: ^Mutex) -> bool {
 	m._recursion++;
 	return true;
 }
-const mutex_unlock = proc(m: ^Mutex) {
+proc mutex_unlock(m: ^Mutex) {
 	var recursion: i32;
 	var thread_id = current_thread_id();
 	assert(thread_id == atomics.load(&m._owner));

+ 16 - 16
core/sys/wgl.odin

@@ -64,19 +64,19 @@ var get_extensions_string_arb:  GetExtensionsStringARBType;
 
 
 
-const create_context            = proc(hdc: Hdc) -> Hglrc                                                                                                 #foreign opengl32 "wglCreateContext";
-const make_current              = proc(hdc: Hdc, hglrc: Hglrc) -> Bool                                                                                    #foreign opengl32 "wglMakeCurrent";
-const get_proc_address          = proc(c_str: ^u8) -> Proc                                                                                                #foreign opengl32 "wglGetProcAddress";
-const delete_context            = proc(hglrc: Hglrc) -> Bool                                                                                              #foreign opengl32 "wglDeleteContext";
-const copy_context              = proc(src, dst: Hglrc, mask: u32) -> Bool                                                                                #foreign opengl32 "wglCopyContext";
-const create_layer_context      = proc(hdc: Hdc, layer_plane: i32) -> Hglrc                                                                               #foreign opengl32 "wglCreateLayerContext";
-const describe_layer_plane      = proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^LayerPlaneDescriptor) -> Bool                           #foreign opengl32 "wglDescribeLayerPlane";
-const get_current_context       = proc() -> Hglrc                                                                                                         #foreign opengl32 "wglGetCurrentContext";
-const get_current_dc            = proc() -> Hdc                                                                                                           #foreign opengl32 "wglGetCurrentDC";
-const get_layer_palette_entries = proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32                                                 #foreign opengl32 "wglGetLayerPaletteEntries";
-const realize_layer_palette     = proc(hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool                                                                 #foreign opengl32 "wglRealizeLayerPalette";
-const set_layer_palette_entries = proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32                                                 #foreign opengl32 "wglSetLayerPaletteEntries";
-const share_lists               = proc(hglrc1, hglrc2: Hglrc) -> Bool                                                                                     #foreign opengl32 "wglShareLists";
-const swap_layer_buffers        = proc(hdc: Hdc, planes: u32) -> Bool                                                                                     #foreign opengl32 "wglSwapLayerBuffers";
-const use_font_bitmaps          = proc(hdc: Hdc, first, count, list_base: u32) -> Bool                                                                    #foreign opengl32 "wglUseFontBitmaps";
-const use_font_outlines         = proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_MetricsFloat) -> Bool  #foreign opengl32 "wglUseFontOutlines";
+proc create_context           (hdc: Hdc) -> Hglrc                                                                                                 #foreign opengl32 "wglCreateContext";
+proc make_current             (hdc: Hdc, hglrc: Hglrc) -> Bool                                                                                    #foreign opengl32 "wglMakeCurrent";
+proc get_proc_address         (c_str: ^u8) -> Proc                                                                                                #foreign opengl32 "wglGetProcAddress";
+proc delete_context           (hglrc: Hglrc) -> Bool                                                                                              #foreign opengl32 "wglDeleteContext";
+proc copy_context             (src, dst: Hglrc, mask: u32) -> Bool                                                                                #foreign opengl32 "wglCopyContext";
+proc create_layer_context     (hdc: Hdc, layer_plane: i32) -> Hglrc                                                                               #foreign opengl32 "wglCreateLayerContext";
+proc describe_layer_plane     (hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^LayerPlaneDescriptor) -> Bool                           #foreign opengl32 "wglDescribeLayerPlane";
+proc get_current_context      () -> Hglrc                                                                                                         #foreign opengl32 "wglGetCurrentContext";
+proc get_current_dc           () -> Hdc                                                                                                           #foreign opengl32 "wglGetCurrentDC";
+proc get_layer_palette_entries(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32                                                 #foreign opengl32 "wglGetLayerPaletteEntries";
+proc realize_layer_palette    (hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool                                                                 #foreign opengl32 "wglRealizeLayerPalette";
+proc set_layer_palette_entries(hdc: Hdc, layer_plane, start, entries: i32, cr: ^ColorRef) -> i32                                                 #foreign opengl32 "wglSetLayerPaletteEntries";
+proc share_lists              (hglrc1, hglrc2: Hglrc) -> Bool                                                                                     #foreign opengl32 "wglShareLists";
+proc swap_layer_buffers       (hdc: Hdc, planes: u32) -> Bool                                                                                     #foreign opengl32 "wglSwapLayerBuffers";
+proc use_font_bitmaps         (hdc: Hdc, first, count, list_base: u32) -> Bool                                                                    #foreign opengl32 "wglUseFontBitmaps";
+proc use_font_outlines        (hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_MetricsFloat) -> Bool  #foreign opengl32 "wglUseFontOutlines";

+ 102 - 102
core/sys/windows.odin

@@ -169,93 +169,93 @@ const GET_FILEEX_INFO_LEVELS = i32;
 const GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS = 0;
 const GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS = 1;
 
-const get_last_error      = proc() -> i32                            #foreign kernel32 "GetLastError";
-const exit_process        = proc(exit_code: u32)                     #foreign kernel32 "ExitProcess";
-const get_desktop_window  = proc() -> Hwnd                           #foreign user32   "GetDesktopWindow";
-const show_cursor         = proc(show : Bool)                        #foreign user32   "ShowCursor";
-const get_cursor_pos      = proc(p: ^Point) -> i32                   #foreign user32   "GetCursorPos";
-const screen_to_client    = proc(h: Hwnd, p: ^Point) -> i32          #foreign user32   "ScreenToClient";
-const get_module_handle_a = proc(module_name: ^u8) -> Hinstance      #foreign kernel32 "GetModuleHandleA";
-const get_stock_object    = proc(fn_object: i32) -> Hgdiobj          #foreign gdi32    "GetStockObject";
-const post_quit_message   = proc(exit_code: i32)                     #foreign user32   "PostQuitMessage";
-const set_window_text_a   = proc(hwnd: Hwnd, c_string: ^u8) -> Bool  #foreign user32   "SetWindowTextA";
+proc get_last_error     () -> i32                            #foreign kernel32 "GetLastError";
+proc exit_process       (exit_code: u32)                     #foreign kernel32 "ExitProcess";
+proc get_desktop_window () -> Hwnd                           #foreign user32   "GetDesktopWindow";
+proc show_cursor        (show : Bool)                        #foreign user32   "ShowCursor";
+proc get_cursor_pos     (p: ^Point) -> i32                   #foreign user32   "GetCursorPos";
+proc screen_to_client   (h: Hwnd, p: ^Point) -> i32          #foreign user32   "ScreenToClient";
+proc get_module_handle_a(module_name: ^u8) -> Hinstance      #foreign kernel32 "GetModuleHandleA";
+proc get_stock_object   (fn_object: i32) -> Hgdiobj          #foreign gdi32    "GetStockObject";
+proc post_quit_message  (exit_code: i32)                     #foreign user32   "PostQuitMessage";
+proc set_window_text_a  (hwnd: Hwnd, c_string: ^u8) -> Bool  #foreign user32   "SetWindowTextA";
 
-const query_performance_frequency = proc(result: ^i64) -> i32 #foreign kernel32 "QueryPerformanceFrequency";
-const query_performance_counter   = proc(result: ^i64) -> i32 #foreign kernel32 "QueryPerformanceCounter";
+proc query_performance_frequency(result: ^i64) -> i32 #foreign kernel32 "QueryPerformanceFrequency";
+proc query_performance_counter  (result: ^i64) -> i32 #foreign kernel32 "QueryPerformanceCounter";
 
-const sleep = proc(ms: i32) -> i32 #foreign kernel32 "Sleep";
+proc sleep(ms: i32) -> i32 #foreign kernel32 "Sleep";
 
-const output_debug_string_a = proc(c_str: ^u8) #foreign kernel32 "OutputDebugStringA";
+proc output_debug_string_a(c_str: ^u8) #foreign kernel32 "OutputDebugStringA";
 
 
-const register_class_ex_a = proc(wc: ^WndClassExA) -> i16 #foreign user32 "RegisterClassExA";
-const create_window_ex_a  = proc(ex_style: u32,
+proc register_class_ex_a(wc: ^WndClassExA) -> i16 #foreign user32 "RegisterClassExA";
+proc create_window_ex_a (ex_style: u32,
                             class_name, title: ^u8,
                             style: u32,
                             x, y, w, h: i32,
                             parent: Hwnd, menu: Hmenu, instance: Hinstance,
                             param: rawptr) -> Hwnd #foreign user32 "CreateWindowExA";
 
-const show_window        = proc(hwnd: Hwnd, cmd_show: i32) -> Bool #foreign user32 "ShowWindow";
-const translate_message  = proc(msg: ^Msg) -> Bool                 #foreign user32 "TranslateMessage";
-const dispatch_message_a = proc(msg: ^Msg) -> Lresult              #foreign user32 "DispatchMessageA";
-const update_window      = proc(hwnd: Hwnd) -> Bool                #foreign user32 "UpdateWindow";
-const get_message_a      = proc(msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max : u32) -> Bool #foreign user32 "GetMessageA";
-const peek_message_a     = proc(msg: ^Msg, hwnd: Hwnd,
+proc show_window       (hwnd: Hwnd, cmd_show: i32) -> Bool #foreign user32 "ShowWindow";
+proc translate_message (msg: ^Msg) -> Bool                 #foreign user32 "TranslateMessage";
+proc dispatch_message_a(msg: ^Msg) -> Lresult              #foreign user32 "DispatchMessageA";
+proc update_window     (hwnd: Hwnd) -> Bool                #foreign user32 "UpdateWindow";
+proc get_message_a     (msg: ^Msg, hwnd: Hwnd, msg_filter_min, msg_filter_max : u32) -> Bool #foreign user32 "GetMessageA";
+proc peek_message_a    (msg: ^Msg, hwnd: Hwnd,
                            msg_filter_min, msg_filter_max, remove_msg: u32) -> Bool #foreign user32 "PeekMessageA";
 
-const post_message = proc(hwnd: Hwnd, msg, wparam, lparam : u32) -> Bool #foreign user32 "PostMessageA";
+proc post_message(hwnd: Hwnd, msg, wparam, lparam : u32) -> Bool #foreign user32 "PostMessageA";
 
-const def_window_proc_a = proc(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult #foreign user32 "DefWindowProcA";
+proc def_window_proc_a(hwnd: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Lresult #foreign user32 "DefWindowProcA";
 
-const adjust_window_rect = proc(rect: ^Rect, style: u32, menu: Bool) -> Bool #foreign user32 "AdjustWindowRect";
-const get_active_window  = proc() -> Hwnd                                    #foreign user32 "GetActiveWindow";
+proc adjust_window_rect(rect: ^Rect, style: u32, menu: Bool) -> Bool #foreign user32 "AdjustWindowRect";
+proc get_active_window () -> Hwnd                                    #foreign user32 "GetActiveWindow";
 
-const destroy_window        = proc(wnd: Hwnd) -> Bool                                                           #foreign user32 "DestroyWindow";
-const describe_pixel_format = proc(dc: Hdc, pixel_format: i32, bytes : u32, pfd: ^PixelFormatDescriptor) -> i32 #foreign user32 "DescribePixelFormat";
+proc destroy_window       (wnd: Hwnd) -> Bool                                                           #foreign user32 "DestroyWindow";
+proc describe_pixel_format(dc: Hdc, pixel_format: i32, bytes : u32, pfd: ^PixelFormatDescriptor) -> i32 #foreign user32 "DescribePixelFormat";
 
 
-const get_query_performance_frequency = proc() -> i64 {
+proc get_query_performance_frequency() -> i64 {
 	var r: i64;
 	query_performance_frequency(&r);
 	return r;
 }
 
-const get_command_line_a     = proc() -> ^u8                                 #foreign kernel32 "GetCommandLineA";
-const get_command_line_w     = proc() -> ^u16                                #foreign kernel32 "GetCommandLineW";
-const get_system_metrics     = proc(index: i32) -> i32                       #foreign kernel32 "GetSystemMetrics";
-const get_current_thread_id  = proc() -> u32                                 #foreign kernel32 "GetCurrentThreadId";
-const command_line_to_argv_w = proc(cmd_list: ^u16, num_args: ^i32) -> ^^u16 #foreign shell32  "CommandLineToArgvW";
+proc get_command_line_a    () -> ^u8                                 #foreign kernel32 "GetCommandLineA";
+proc get_command_line_w    () -> ^u16                                #foreign kernel32 "GetCommandLineW";
+proc get_system_metrics    (index: i32) -> i32                       #foreign kernel32 "GetSystemMetrics";
+proc get_current_thread_id () -> u32                                 #foreign kernel32 "GetCurrentThreadId";
+proc command_line_to_argv_w(cmd_list: ^u16, num_args: ^i32) -> ^^u16 #foreign shell32  "CommandLineToArgvW";
 
-const time_get_time                = proc() -> u32                                                  #foreign winmm    "timeGetTime";
-const get_system_time_as_file_time = proc(system_time_as_file_time: ^Filetime)                      #foreign kernel32 "GetSystemTimeAsFileTime";
-const file_time_to_local_file_time = proc(file_time: ^Filetime, local_file_time: ^Filetime) -> Bool #foreign kernel32 "FileTimeToLocalFileTime";
-const file_time_to_system_time     = proc(file_time: ^Filetime, system_time: ^Systemtime) -> Bool   #foreign kernel32 "FileTimeToSystemTime";
-const system_time_to_file_time     = proc(system_time: ^Systemtime, file_time: ^Filetime) -> Bool   #foreign kernel32 "SystemTimeToFileTime";
+proc time_get_time               () -> u32                                                  #foreign winmm    "timeGetTime";
+proc get_system_time_as_file_time(system_time_as_file_time: ^Filetime)                      #foreign kernel32 "GetSystemTimeAsFileTime";
+proc file_time_to_local_file_time(file_time: ^Filetime, local_file_time: ^Filetime) -> Bool #foreign kernel32 "FileTimeToLocalFileTime";
+proc file_time_to_system_time    (file_time: ^Filetime, system_time: ^Systemtime) -> Bool   #foreign kernel32 "FileTimeToSystemTime";
+proc system_time_to_file_time    (system_time: ^Systemtime, file_time: ^Filetime) -> Bool   #foreign kernel32 "SystemTimeToFileTime";
 
 // File Stuff
 
-const close_handle   = proc(h: Handle) -> i32 #foreign kernel32 "CloseHandle";
-const get_std_handle = proc(h: i32) -> Handle #foreign kernel32 "GetStdHandle";
-const create_file_a  = proc(filename: ^u8, desired_access, share_mode: u32,
+proc close_handle  (h: Handle) -> i32 #foreign kernel32 "CloseHandle";
+proc get_std_handle(h: i32) -> Handle #foreign kernel32 "GetStdHandle";
+proc create_file_a (filename: ^u8, desired_access, share_mode: u32,
                        security: rawptr,
                        creation, flags_and_attribs: u32, template_file: Handle) -> Handle #foreign kernel32 "CreateFileA";
-const read_file  = proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool #foreign kernel32 "ReadFile";
-const write_file = proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool #foreign kernel32 "WriteFile";
+proc read_file (h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool #foreign kernel32 "ReadFile";
+proc write_file(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool #foreign kernel32 "WriteFile";
 
-const get_file_size_ex               = proc(file_handle: Handle, file_size: ^i64) -> Bool                                    #foreign kernel32 "GetFileSizeEx";
-const get_file_attributes_a          = proc(filename: ^u8) -> u32                                                          #foreign kernel32 "GetFileAttributesA";
-const get_file_attributes_ex_a       = proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> Bool #foreign kernel32 "GetFileAttributesExA";
-const get_file_information_by_handle = proc(file_handle: Handle, file_info: ^ByHandleFileInformation) -> Bool                #foreign kernel32 "GetFileInformationByHandle";
+proc get_file_size_ex              (file_handle: Handle, file_size: ^i64) -> Bool                                    #foreign kernel32 "GetFileSizeEx";
+proc get_file_attributes_a         (filename: ^u8) -> u32                                                          #foreign kernel32 "GetFileAttributesA";
+proc get_file_attributes_ex_a      (filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> Bool #foreign kernel32 "GetFileAttributesExA";
+proc get_file_information_by_handle(file_handle: Handle, file_info: ^ByHandleFileInformation) -> Bool                #foreign kernel32 "GetFileInformationByHandle";
 
-const get_file_type    = proc(file_handle: Handle) -> u32                                                                       #foreign kernel32 "GetFileType";
-const set_file_pointer = proc(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 #foreign kernel32 "SetFilePointer";
+proc get_file_type   (file_handle: Handle) -> u32                                                                       #foreign kernel32 "GetFileType";
+proc set_file_pointer(file_handle: Handle, distance_to_move: i32, distance_to_move_high: ^i32, move_method: u32) -> u32 #foreign kernel32 "SetFilePointer";
 
-const set_handle_information = proc(obj: Handle, mask, flags: u32) -> Bool #foreign kernel32 "SetHandleInformation";
+proc set_handle_information(obj: Handle, mask, flags: u32) -> Bool #foreign kernel32 "SetHandleInformation";
 
-const find_first_file_a = proc(file_name : ^u8, data : ^FindData) -> Handle #foreign kernel32 "FindFirstFileA";
-const find_next_file_a  = proc(file : Handle, data : ^FindData) -> Bool       #foreign kernel32 "FindNextFileA";
-const find_close        = proc(file : Handle) -> Bool                         #foreign kernel32 "FindClose";
+proc find_first_file_a(file_name : ^u8, data : ^FindData) -> Handle #foreign kernel32 "FindFirstFileA";
+proc find_next_file_a (file : Handle, data : ^FindData) -> Bool       #foreign kernel32 "FindNextFileA";
+proc find_close       (file : Handle) -> Bool                         #foreign kernel32 "FindClose";
 
 const MAX_PATH = 0x00000104;
 
@@ -313,10 +313,10 @@ const INVALID_SET_FILE_POINTER = ~u32(0);
 
 
 
-const heap_alloc       = proc (h: Handle, flags: u32, bytes: int) -> rawptr                 #foreign kernel32 "HeapAlloc";
-const heap_realloc     = proc (h: Handle, flags: u32, memory: rawptr, bytes: int) -> rawptr #foreign kernel32 "HeapReAlloc";
-const heap_free        = proc (h: Handle, flags: u32, memory: rawptr) -> Bool               #foreign kernel32 "HeapFree";
-const get_process_heap = proc () -> Handle                                                  #foreign kernel32 "GetProcessHeap";
+proc heap_alloc      ( h: Handle, flags: u32, bytes: int) -> rawptr                 #foreign kernel32 "HeapAlloc";
+proc heap_realloc    ( h: Handle, flags: u32, memory: rawptr, bytes: int) -> rawptr #foreign kernel32 "HeapReAlloc";
+proc heap_free       ( h: Handle, flags: u32, memory: rawptr) -> Bool               #foreign kernel32 "HeapFree";
+proc get_process_heap( ) -> Handle                                                  #foreign kernel32 "GetProcessHeap";
 
 
 const HEAP_ZERO_MEMORY = 0x00000008;
@@ -331,27 +331,27 @@ const Security_Attributes = struct #ordered {
 
 const INFINITE = 0xffffffff;
 
-const create_semaphore_a     = proc(attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: ^u8) -> Handle #foreign kernel32 "CreateSemaphoreA";
-const release_semaphore      = proc(semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool                        #foreign kernel32 "ReleaseSemaphore";
-const wait_for_single_object = proc(handle: Handle, milliseconds: u32) -> u32                                                   #foreign kernel32 "WaitForSingleObject";
+proc create_semaphore_a    (attributes: ^Security_Attributes, initial_count, maximum_count: i32, name: ^u8) -> Handle #foreign kernel32 "CreateSemaphoreA";
+proc release_semaphore     (semaphore: Handle, release_count: i32, previous_count: ^i32) -> Bool                        #foreign kernel32 "ReleaseSemaphore";
+proc wait_for_single_object(handle: Handle, milliseconds: u32) -> u32                                                   #foreign kernel32 "WaitForSingleObject";
 
 
-const interlocked_compare_exchange   = proc(dst: ^i32, exchange, comparand: i32) -> i32   #foreign kernel32 "InterlockedCompareExchange";
-const interlocked_exchange           = proc(dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedExchange";
-const interlocked_exchange_add       = proc(dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedExchangeAdd";
-const interlocked_and                = proc(dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedAnd";
-const interlocked_or                 = proc(dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedOr";
+proc interlocked_compare_exchange  (dst: ^i32, exchange, comparand: i32) -> i32   #foreign kernel32 "InterlockedCompareExchange";
+proc interlocked_exchange          (dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedExchange";
+proc interlocked_exchange_add      (dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedExchangeAdd";
+proc interlocked_and               (dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedAnd";
+proc interlocked_or                (dst: ^i32, desired: i32) -> i32               #foreign kernel32 "InterlockedOr";
 
-const interlocked_compare_exchange64 = proc(dst: ^i64, exchange, comparand: i64) -> i64   #foreign kernel32 "InterlockedCompareExchange64";
-const interlocked_exchange64         = proc(dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedExchange64";
-const interlocked_exchange_add64     = proc(dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedExchangeAdd64";
-const interlocked_and64              = proc(dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedAnd64";
-const interlocked_or64               = proc(dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedOr64";
+proc interlocked_compare_exchange64(dst: ^i64, exchange, comparand: i64) -> i64   #foreign kernel32 "InterlockedCompareExchange64";
+proc interlocked_exchange64        (dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedExchange64";
+proc interlocked_exchange_add64    (dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedExchangeAdd64";
+proc interlocked_and64             (dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedAnd64";
+proc interlocked_or64              (dst: ^i64, desired: i64) -> i64               #foreign kernel32 "InterlockedOr64";
 
-const mm_pause           = proc() #foreign kernel32 "_mm_pause";
-const read_write_barrier = proc() #foreign kernel32 "ReadWriteBarrier";
-const write_barrier      = proc() #foreign kernel32 "WriteBarrier";
-const read_barrier       = proc() #foreign kernel32 "ReadBarrier";
+proc mm_pause          () #foreign kernel32 "_mm_pause";
+proc read_write_barrier() #foreign kernel32 "ReadWriteBarrier";
+proc write_barrier     () #foreign kernel32 "WriteBarrier";
+proc read_barrier      () #foreign kernel32 "ReadBarrier";
 
 
 
@@ -390,24 +390,24 @@ const WindowPlacement = struct #ordered {
 	normal_pos: Rect,
 }
 
-const get_monitor_info_a    = proc(monitor: Hmonitor, mi: ^MonitorInfo) -> Bool                           #foreign user32 "GetMonitorInfoA";
-const monitor_from_window   = proc(wnd: Hwnd, flags : u32) -> Hmonitor                                    #foreign user32 "MonitorFromWindow";
+proc get_monitor_info_a   (monitor: Hmonitor, mi: ^MonitorInfo) -> Bool                           #foreign user32 "GetMonitorInfoA";
+proc monitor_from_window  (wnd: Hwnd, flags : u32) -> Hmonitor                                    #foreign user32 "MonitorFromWindow";
 
-const set_window_pos        = proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) #foreign user32 "SetWindowPos";
+proc set_window_pos       (wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: i32, flags: u32) #foreign user32 "SetWindowPos";
 
-const get_window_placement  = proc(wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool                            #foreign user32 "GetWindowPlacement";
-const set_window_placement  = proc(wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool                            #foreign user32 "SetWindowPlacement";
-const get_window_rect       = proc(wnd: Hwnd, rect: ^Rect) -> Bool                                        #foreign user32 "GetWindowRect";
+proc get_window_placement (wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool                            #foreign user32 "GetWindowPlacement";
+proc set_window_placement (wnd: Hwnd, wndpl: ^WindowPlacement) -> Bool                            #foreign user32 "SetWindowPlacement";
+proc get_window_rect      (wnd: Hwnd, rect: ^Rect) -> Bool                                        #foreign user32 "GetWindowRect";
 
-const get_window_long_ptr_a = proc(wnd: Hwnd, index: i32) -> i64                                          #foreign user32 "GetWindowLongPtrA";
-const set_window_long_ptr_a = proc(wnd: Hwnd, index: i32, new: i64) -> i64                                #foreign user32 "SetWindowLongPtrA";
+proc get_window_long_ptr_a(wnd: Hwnd, index: i32) -> i64                                          #foreign user32 "GetWindowLongPtrA";
+proc set_window_long_ptr_a(wnd: Hwnd, index: i32, new: i64) -> i64                                #foreign user32 "SetWindowLongPtrA";
 
-const get_window_text       = proc(wnd: Hwnd, str: ^u8, maxCount: i32) -> i32                           #foreign user32 "GetWindowText";
+proc get_window_text      (wnd: Hwnd, str: ^u8, maxCount: i32) -> i32                           #foreign user32 "GetWindowText";
 
-const HIWORD = proc(wParam: Wparam) -> u16 { return u16((u32(wParam) >> 16) & 0xffff); }
-const HIWORD = proc(lParam: Lparam) -> u16 { return u16((u32(lParam) >> 16) & 0xffff); }
-const LOWORD = proc(wParam: Wparam) -> u16 { return u16(wParam); }
-const LOWORD = proc(lParam: Lparam) -> u16 { return u16(lParam); }
+proc HIWORD(wParam: Wparam) -> u16 { return u16((u32(wParam) >> 16) & 0xffff); }
+proc HIWORD(lParam: Lparam) -> u16 { return u16((u32(lParam) >> 16) & 0xffff); }
+proc LOWORD(wParam: Wparam) -> u16 { return u16(wParam); }
+proc LOWORD(lParam: Lparam) -> u16 { return u16(lParam); }
 
 
 
@@ -442,7 +442,7 @@ const DIB_RGB_COLORS = 0x00;
 const SRCCOPY: u32   = 0x00cc0020;
 
 
-const stretch_dibits = proc (hdc: Hdc,
+proc stretch_dibits( hdc: Hdc,
                         x_dst, y_dst, width_dst, height_dst: i32,
                         x_src, y_src, width_src, header_src: i32,
                         bits: rawptr, bits_info: ^BitmapInfo,
@@ -451,11 +451,11 @@ const stretch_dibits = proc (hdc: Hdc,
 
 
 
-const load_library_a   = proc (c_str: ^u8) -> Hmodule          #foreign kernel32 "LoadLibraryA";
-const free_library     = proc (h: Hmodule)                     #foreign kernel32 "FreeLibrary";
-const get_proc_address = proc (h: Hmodule, c_str: ^u8) -> Proc #foreign kernel32 "GetProcAddress";
+proc load_library_a  ( c_str: ^u8) -> Hmodule          #foreign kernel32 "LoadLibraryA";
+proc free_library    ( h: Hmodule)                     #foreign kernel32 "FreeLibrary";
+proc get_proc_address( h: Hmodule, c_str: ^u8) -> Proc #foreign kernel32 "GetProcAddress";
 
-const get_client_rect  = proc(hwnd: Hwnd, rect: ^Rect) -> Bool #foreign user32 "GetClientRect";
+proc get_client_rect (hwnd: Hwnd, rect: ^Rect) -> Bool #foreign user32 "GetClientRect";
 
 // Windows OpenGL
 const PFD_TYPE_RGBA             = 0;
@@ -512,11 +512,11 @@ const PixelFormatDescriptor = struct #ordered {
 	damage_mask: u32,
 }
 
-const get_dc              = proc(h: Hwnd) -> Hdc                                                   #foreign user32 "GetDC";
-const set_pixel_format    = proc(hdc: Hdc, pixel_format: i32, pfd: ^PixelFormatDescriptor) -> Bool #foreign gdi32  "SetPixelFormat";
-const choose_pixel_format = proc(hdc: Hdc, pfd: ^PixelFormatDescriptor) -> i32                     #foreign gdi32  "ChoosePixelFormat";
-const swap_buffers        = proc(hdc: Hdc) -> Bool                                                 #foreign gdi32  "SwapBuffers";
-const release_dc          = proc(wnd: Hwnd, hdc: Hdc) -> i32                                       #foreign user32 "ReleaseDC";
+proc get_dc             (h: Hwnd) -> Hdc                                                   #foreign user32 "GetDC";
+proc set_pixel_format   (hdc: Hdc, pixel_format: i32, pfd: ^PixelFormatDescriptor) -> Bool #foreign gdi32  "SetPixelFormat";
+proc choose_pixel_format(hdc: Hdc, pfd: ^PixelFormatDescriptor) -> i32                     #foreign gdi32  "ChoosePixelFormat";
+proc swap_buffers       (hdc: Hdc) -> Bool                                                 #foreign gdi32  "SwapBuffers";
+proc release_dc         (wnd: Hwnd, hdc: Hdc) -> i32                                       #foreign user32 "ReleaseDC";
 
 
 const Proc  = type proc() #cc_c;
@@ -526,12 +526,12 @@ const MAPVK_VK_TO_VSC    = 0;
 const MAPVK_VSC_TO_VK    = 1;
 const MAPVK_VSC_TO_VK_EX = 3;
 
-const map_virtual_key = proc(scancode : u32, map_type : u32) -> u32 #foreign user32 "MapVirtualKeyA";
+proc map_virtual_key(scancode : u32, map_type : u32) -> u32 #foreign user32 "MapVirtualKeyA";
 
-const get_key_state       = proc(v_key: i32) -> i16 #foreign user32 "GetKeyState";
-const get_async_key_state = proc(v_key: i32) -> i16 #foreign user32 "GetAsyncKeyState";
+proc get_key_state      (v_key: i32) -> i16 #foreign user32 "GetKeyState";
+proc get_async_key_state(v_key: i32) -> i16 #foreign user32 "GetAsyncKeyState";
 
-const is_key_down = proc(key: KeyCode) -> bool #inline { return get_async_key_state(i32(key)) < 0; }
+proc is_key_down(key: KeyCode) -> bool #inline { return get_async_key_state(i32(key)) < 0; }
 
 const KeyCode = enum i32 {
 	Lbutton    = 0x01,

+ 19 - 19
core/types.odin

@@ -1,4 +1,4 @@
-const is_signed = proc(info: ^TypeInfo) -> bool {
+proc is_signed(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	match i in type_info_base(info) {
 	case TypeInfo.Integer: return i.signed;
@@ -6,92 +6,92 @@ const is_signed = proc(info: ^TypeInfo) -> bool {
 	}
 	return false;
 }
-const is_integer = proc(info: ^TypeInfo) -> bool {
+proc is_integer(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Integer);
 	return ok;
 }
-const is_float = proc(info: ^TypeInfo) -> bool {
+proc is_float(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Float);
 	return ok;
 }
-const is_complex = proc(info: ^TypeInfo) -> bool {
+proc is_complex(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Complex);
 	return ok;
 }
-const is_any = proc(info: ^TypeInfo) -> bool {
+proc is_any(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Any);
 	return ok;
 }
-const is_string = proc(info: ^TypeInfo) -> bool {
+proc is_string(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.String);
 	return ok;
 }
-const is_boolean = proc(info: ^TypeInfo) -> bool {
+proc is_boolean(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Boolean);
 	return ok;
 }
-const is_pointer = proc(info: ^TypeInfo) -> bool {
+proc is_pointer(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Pointer);
 	return ok;
 }
-const is_procedure = proc(info: ^TypeInfo) -> bool {
+proc is_procedure(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Procedure);
 	return ok;
 }
-const is_array = proc(info: ^TypeInfo) -> bool {
+proc is_array(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Array);
 	return ok;
 }
-const is_dynamic_array = proc(info: ^TypeInfo) -> bool {
+proc is_dynamic_array(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.DynamicArray);
 	return ok;
 }
-const is_dynamic_map = proc(info: ^TypeInfo) -> bool {
+proc is_dynamic_map(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Map);
 	return ok;
 }
-const is_slice = proc(info: ^TypeInfo) -> bool {
+proc is_slice(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Slice);
 	return ok;
 }
-const is_vector = proc(info: ^TypeInfo) -> bool {
+proc is_vector(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Vector);
 	return ok;
 }
-const is_tuple = proc(info: ^TypeInfo) -> bool {
+proc is_tuple(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Tuple);
 	return ok;
 }
-const is_struct = proc(info: ^TypeInfo) -> bool {
+proc is_struct(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Struct);
 	return ok;
 }
-const is_union = proc(info: ^TypeInfo) -> bool {
+proc is_union(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Union);
 	return ok;
 }
-const is_raw_union = proc(info: ^TypeInfo) -> bool {
+proc is_raw_union(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.RawUnion);
 	return ok;
 }
-const is_enum = proc(info: ^TypeInfo) -> bool {
+proc is_enum(info: ^TypeInfo) -> bool {
 	if info == nil { return false; }
 	var _, ok = type_info_base(info).(^TypeInfo.Enum);
 	return ok;

+ 4 - 4
core/utf16.odin

@@ -7,11 +7,11 @@ const _surr3           = 0xe000;
 const _surr_self       = 0x10000;
 
 
-const is_surrogate = proc(r: rune) -> bool {
+proc is_surrogate(r: rune) -> bool {
 	return _surr1 <= r && r < _surr3;
 }
 
-const decode_surrogate_pair = proc(r1, r2: rune) -> rune {
+proc decode_surrogate_pair(r1, r2: rune) -> rune {
 	if _surr1 <= r1 && r1 < _surr2 && _surr2 <= r2 && r2 < _surr3 {
 		return (r1-_surr1)<<10 | (r2 - _surr2) + _surr_self;
 	}
@@ -19,7 +19,7 @@ const decode_surrogate_pair = proc(r1, r2: rune) -> rune {
 }
 
 
-const encode_surrogate_pair = proc(r: rune) -> (r1, r2: rune) {
+proc encode_surrogate_pair(r: rune) -> (r1, r2: rune) {
 	if r < _surr_self || r > MAX_RUNE {
 		return REPLACEMENT_CHAR, REPLACEMENT_CHAR;
 	}
@@ -27,7 +27,7 @@ const encode_surrogate_pair = proc(r: rune) -> (r1, r2: rune) {
 	return _surr1 + (r>>10)&0x3ff, _surr2 + r&0x3ff;
 }
 
-const encode = proc(d: []u16, s: []rune) {
+proc encode(d: []u16, s: []rune) {
 	var n = len(s);
 	for r in s {
 		if r >= _surr_self {

+ 11 - 11
core/utf8.odin

@@ -58,7 +58,7 @@ immutable var accept_sizes = [256]u8{
 	0x34, 0x04, 0x04, 0x04, 0x44, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xf0-0xff
 };
 
-const encode_rune = proc(r: rune) -> ([4]u8, int) {
+proc encode_rune(r: rune) -> ([4]u8, int) {
 	var buf: [4]u8;
 	var i = u32(r);
 	const mask: u8 = 0x3f;
@@ -92,8 +92,8 @@ const encode_rune = proc(r: rune) -> ([4]u8, int) {
 	return buf, 4;
 }
 
-const decode_rune = proc(s: string) -> (rune, int) #inline { return decode_rune([]u8(s)); }
-const decode_rune = proc(s: []u8) -> (rune, int) {
+proc decode_rune(s: string) -> (rune, int) #inline { return decode_rune([]u8(s)); }
+proc decode_rune(s: []u8) -> (rune, int) {
 	var n = len(s);
 	if n < 1 {
 		return RUNE_ERROR, 0;
@@ -132,8 +132,8 @@ const decode_rune = proc(s: []u8) -> (rune, int) {
 
 
 
-const decode_last_rune = proc(s: string) -> (rune, int) #inline { return decode_last_rune([]u8(s)); }
-const decode_last_rune = proc(s: []u8) -> (rune, int) {
+proc decode_last_rune(s: string) -> (rune, int) #inline { return decode_last_rune([]u8(s)); }
+proc decode_last_rune(s: []u8) -> (rune, int) {
 	var r: rune;
 	var size: int;
 	var start, end, limit: int;
@@ -171,7 +171,7 @@ const decode_last_rune = proc(s: []u8) -> (rune, int) {
 
 
 
-const valid_rune = proc(r: rune) -> bool {
+proc valid_rune(r: rune) -> bool {
 	if r < 0 {
 		return false;
 	} else if SURROGATE_MIN <= r && r <= SURROGATE_MAX {
@@ -182,7 +182,7 @@ const valid_rune = proc(r: rune) -> bool {
 	return true;
 }
 
-const valid_string = proc(s: string) -> bool {
+proc valid_string(s: string) -> bool {
 	var n = len(s);
 	for var i = 0; i < n; {
 		var si = s[i];
@@ -215,10 +215,10 @@ const valid_string = proc(s: string) -> bool {
 	return true;
 }
 
-const rune_start = proc(b: u8) -> bool #inline { return b&0xc0 != 0x80; }
+proc rune_start(b: u8) -> bool #inline { return b&0xc0 != 0x80; }
 
-const rune_count = proc(s: string) -> int #inline { return rune_count([]u8(s)); }
-const rune_count = proc(s: []u8) -> int {
+proc rune_count(s: string) -> int #inline { return rune_count([]u8(s)); }
+proc rune_count(s: []u8) -> int {
 	var count = 0;
 	var n = len(s);
 
@@ -257,7 +257,7 @@ const rune_count = proc(s: []u8) -> int {
 }
 
 
-const rune_size = proc(r: rune) -> int {
+proc rune_size(r: rune) -> int {
 	match {
 	case r < 0:          return -1;
 	case r <= 1<<7  - 1: return 1;

+ 11 - 8
src/check_decl.cpp

@@ -251,17 +251,17 @@ bool are_signatures_similar_enough(Type *a_, Type *b_) {
 	return true;
 }
 
-void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) {
+void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
 	GB_ASSERT(e->type == NULL);
-	if (d->proc_lit->kind != AstNode_ProcLit) {
+	if (d->proc_decl->kind != AstNode_ProcDecl) {
 		// TOOD(bill): Better error message
-		error_node(d->proc_lit, "Expected a procedure to check");
+		error_node(d->proc_decl, "Expected a procedure to check");
 		return;
 	}
 
 	Type *proc_type = make_type_proc(c->allocator, e->scope, NULL, 0, NULL, 0, false, ProcCC_Odin);
 	e->type = proc_type;
-	ast_node(pd, ProcLit, d->proc_lit);
+	ast_node(pd, ProcDecl, d->proc_decl);
 
 	check_open_scope(c, pd->type);
 	check_procedure_type(c, proc_type, pd->type);
@@ -325,7 +325,7 @@ void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) {
 			name = pd->foreign_name;
 		}
 
-		AstNode *foreign_library = d->proc_lit->ProcLit.foreign_library;
+		AstNode *foreign_library = d->proc_decl->ProcDecl.foreign_library;
 		if (foreign_library == NULL) {
 			error(e->token, "#foreign procedures must declare which library they are from");
 		} else if (foreign_library->kind != AstNode_Ident) {
@@ -359,7 +359,7 @@ void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) {
 			Type *this_type = base_type(e->type);
 			Type *other_type = base_type(f->type);
 			if (!are_signatures_similar_enough(this_type, other_type)) {
-				error_node(d->proc_lit,
+				error_node(d->proc_decl,
 						   "Redeclaration of #foreign procedure `%.*s` with different type signatures\n"
 						   "\tat %.*s(%td:%td)",
 						   LIT(name), LIT(pos.file), pos.line, pos.column);
@@ -384,7 +384,7 @@ void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) {
 				Entity *f = *found;
 				TokenPos pos = f->token.pos;
 				// TODO(bill): Better error message?
-				error_node(d->proc_lit,
+				error_node(d->proc_decl,
 						   "Non unique linking name for procedure `%.*s`\n"
 						   "\tother at %.*s(%td:%td)",
 						   LIT(name), LIT(pos.file), pos.line, pos.column);
@@ -472,7 +472,7 @@ void check_entity_decl(Checker *c, Entity *e, DeclInfo *d, Type *named_type) {
 		check_type_decl(c, e, d->type_expr, named_type);
 		break;
 	case Entity_Procedure:
-		check_proc_lit(c, e, d);
+		check_proc_decl(c, e, d);
 		break;
 	}
 
@@ -482,6 +482,9 @@ void check_entity_decl(Checker *c, Entity *e, DeclInfo *d, Type *named_type) {
 
 
 void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNode *body) {
+	if (body == NULL) {
+		return;
+	}
 	GB_ASSERT(body->kind == AstNode_BlockStmt);
 
 	String proc_name = {};

+ 1 - 1
src/check_expr.cpp

@@ -5510,7 +5510,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 		check_open_scope(c, pl->type);
 		{
 			decl = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
-			decl->proc_lit = pl->type;
+			decl->proc_decl = pl->type;
 			c->context.decl = decl;
 
 			if (pl->tags != 0) {

+ 26 - 8
src/checker.cpp

@@ -193,7 +193,7 @@ struct DeclInfo {
 
 	AstNode *         type_expr;
 	AstNode *         init_expr;
-	AstNode *         proc_lit; // AstNode_ProcLit
+	AstNode *         proc_decl; // AstNode_ProcDecl
 
 	Map<bool>         deps; // Key: Entity *
 	Array<BlockLabel> labels;
@@ -340,9 +340,9 @@ bool decl_info_has_init(DeclInfo *d) {
 	if (d->init_expr != NULL) {
 		return true;
 	}
-	if (d->proc_lit != NULL) {
-		switch (d->proc_lit->kind) {
-		case_ast_node(pd, ProcLit, d->proc_lit);
+	if (d->proc_decl != NULL) {
+		switch (d->proc_decl->kind) {
+		case_ast_node(pd, ProcDecl, d->proc_decl);
 			if (pd->body != NULL) {
 				return true;
 			}
@@ -1542,10 +1542,10 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
 						d->type_expr = vd->type;
 						d->init_expr = up_init->Alias.expr;
 					#endif
-					} else if (init != NULL && up_init->kind == AstNode_ProcLit) {
-						e = make_entity_procedure(c->allocator, d->scope, name->Ident, NULL, up_init->ProcLit.tags);
-						d->proc_lit = up_init;
-						d->type_expr = vd->type;
+					// } else if (init != NULL && up_init->kind == AstNode_ProcLit) {
+						// e = make_entity_procedure(c->allocator, d->scope, name->Ident, NULL, up_init->ProcLit.tags);
+						// d->proc_lit = up_init;
+						// d->type_expr = vd->type;
 					} else {
 						e = make_entity_constant(c->allocator, d->scope, name->Ident, NULL, empty_exact_value);
 						d->type_expr = vd->type;
@@ -1561,6 +1561,24 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
 			}
 		case_end;
 
+		case_ast_node(pd, ProcDecl, decl);
+			AstNode *name = pd->name;
+			if (name->kind != AstNode_Ident) {
+				error_node(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind]));
+				break;
+			}
+
+
+			DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
+			Entity *e = NULL;
+
+			e = make_entity_procedure(c->allocator, d->scope, name->Ident, NULL, pd->tags);
+			d->proc_decl = decl;
+			d->type_expr = pd->type;
+			e->identifier = name;
+			add_entity_and_decl_info(c, name, e, d);
+		case_end;
+
 		case_ast_node(id, ImportDecl, decl);
 			if (!c->context.scope->is_file) {
 				if (id->is_import) {

+ 62 - 58
src/ir.cpp

@@ -5884,74 +5884,78 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
 					map_set(&proc->module->entity_names, hash_pointer(e), name);
 					ir_gen_global_type_name(proc->module, e, name);
 				} break;
-				case Entity_Procedure: {
-					DeclInfo **decl_info = map_get(&proc->module->info->entities, hash_pointer(e));
-					GB_ASSERT(decl_info != NULL);
-					DeclInfo *dl = *decl_info;
-					ast_node(pd, ProcLit, dl->proc_lit);
-					if (pd->body != NULL) {
-						CheckerInfo *info = proc->module->info;
-
-						if (map_get(&proc->module->min_dep_map, hash_pointer(e)) == NULL) {
-							// NOTE(bill): Nothing depends upon it so doesn't need to be built
-							break;
-						}
+				}
+			}
+		}
+	case_end;
 
-						// NOTE(bill): Generate a new name
-						// parent.name-guid
-						String original_name = e->token.string;
-						String pd_name = original_name;
-						if (pd->link_name.len > 0) {
-							pd_name = pd->link_name;
-						}
+	case_ast_node(pd, ProcDecl, node);
+		AstNode *ident = pd->name;
+		GB_ASSERT(ident->kind == AstNode_Ident);
+		Entity *e = entity_of_ident(proc->module->info, ident);
+		DeclInfo **decl_info = map_get(&proc->module->info->entities, hash_pointer(e));
+		GB_ASSERT(decl_info != NULL);
+		DeclInfo *dl = *decl_info;
 
-						isize name_len = proc->name.len + 1 + pd_name.len + 1 + 10 + 1;
-						u8 *name_text = gb_alloc_array(proc->module->allocator, u8, name_len);
-						i32 guid = cast(i32)proc->children.count;
-						name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(pd_name), guid);
-						String name = make_string(name_text, name_len-1);
+		if (pd->body != NULL) {
+			CheckerInfo *info = proc->module->info;
 
+			if (map_get(&proc->module->min_dep_map, hash_pointer(e)) == NULL) {
+				// NOTE(bill): Nothing depends upon it so doesn't need to be built
+				break;
+			}
 
-						irValue *value = ir_value_procedure(proc->module->allocator,
-						                                    proc->module, e, e->type, pd->type, pd->body, name);
+			// NOTE(bill): Generate a new name
+			// parent.name-guid
+			String original_name = e->token.string;
+			String pd_name = original_name;
+			if (pd->link_name.len > 0) {
+				pd_name = pd->link_name;
+			}
 
-						value->Proc.tags = pd->tags;
-						value->Proc.parent = proc;
+			isize name_len = proc->name.len + 1 + pd_name.len + 1 + 10 + 1;
+			u8 *name_text = gb_alloc_array(proc->module->allocator, u8, name_len);
+			i32 guid = cast(i32)proc->children.count;
+			name_len = gb_snprintf(cast(char *)name_text, name_len, "%.*s.%.*s-%d", LIT(proc->name), LIT(pd_name), guid);
+			String name = make_string(name_text, name_len-1);
 
-						ir_module_add_value(proc->module, e, value);
-						array_add(&proc->children, &value->Proc);
-						array_add(&proc->module->procs_to_generate, value);
-					} else {
-						CheckerInfo *info = proc->module->info;
 
-						// FFI - Foreign function interace
-						String original_name = e->token.string;
-						String name = original_name;
-						if (pd->foreign_name.len > 0) {
-							name = pd->foreign_name;
-						}
+			irValue *value = ir_value_procedure(proc->module->allocator,
+			                                    proc->module, e, e->type, pd->type, pd->body, name);
 
-						irValue *value = ir_value_procedure(proc->module->allocator,
-						                                           proc->module, e, e->type, pd->type, pd->body, name);
+			value->Proc.tags = pd->tags;
+			value->Proc.parent = proc;
 
-						value->Proc.tags = pd->tags;
+			ir_module_add_value(proc->module, e, value);
+			array_add(&proc->children, &value->Proc);
+			array_add(&proc->module->procs_to_generate, value);
+		} else {
+			CheckerInfo *info = proc->module->info;
 
-						ir_module_add_value(proc->module, e, value);
-						ir_build_proc(value, proc);
+			// FFI - Foreign function interace
+			String original_name = e->token.string;
+			String name = original_name;
+			if (pd->foreign_name.len > 0) {
+				name = pd->foreign_name;
+			}
 
-						if (value->Proc.tags & ProcTag_foreign) {
-							HashKey key = hash_string(name);
-							irValue **prev_value = map_get(&proc->module->members, key);
-							if (prev_value == NULL) {
-								// NOTE(bill): Don't do mutliple declarations in the IR
-								map_set(&proc->module->members, key, value);
-							}
-						} else {
-							array_add(&proc->children, &value->Proc);
-						}
-					}
-				} break;
+			irValue *value = ir_value_procedure(proc->module->allocator,
+			                                           proc->module, e, e->type, pd->type, pd->body, name);
+
+			value->Proc.tags = pd->tags;
+
+			ir_module_add_value(proc->module, e, value);
+			ir_build_proc(value, proc);
+
+			if (value->Proc.tags & ProcTag_foreign) {
+				HashKey key = hash_string(name);
+				irValue **prev_value = map_get(&proc->module->members, key);
+				if (prev_value == NULL) {
+					// NOTE(bill): Don't do mutliple declarations in the IR
+					map_set(&proc->module->members, key, value);
 				}
+			} else {
+				array_add(&proc->children, &value->Proc);
 			}
 		}
 	case_end;
@@ -7232,7 +7236,7 @@ void ir_gen_tree(irGen *s) {
 		} break;
 
 		case Entity_Procedure: {
-			ast_node(pd, ProcLit, decl->proc_lit);
+			ast_node(pd, ProcDecl, decl->proc_decl);
 			String original_name = name;
 			AstNode *body = pd->body;
 			if (e->Procedure.is_foreign) {
@@ -7245,7 +7249,7 @@ void ir_gen_tree(irGen *s) {
 				name = pd->link_name;
 			}
 
-			AstNode *type_expr = decl->proc_lit->ProcLit.type;
+			AstNode *type_expr = pd->type;
 
 			irValue *p = ir_value_procedure(a, m, e, e->type, type_expr, body, name);
 			p->Proc.tags = pd->tags;

+ 62 - 7
src/parser.cpp

@@ -304,6 +304,16 @@ AST_NODE_KIND(_DeclBegin,      "", i32) \
 		Array<AstNode *> values; \
 		u32              flags;  \
 	}) \
+	AST_NODE_KIND(ProcDecl, "procedure declaration", struct { \
+		Token    token;           \
+		AstNode *name;            \
+		AstNode *type;            \
+		AstNode *body;            \
+		u64      tags;            \
+		AstNode *foreign_library; \
+		String   foreign_name;    \
+		String   link_name;       \
+	}) \
 	AST_NODE_KIND(ImportDecl, "import declaration", struct { \
 		Token     token;        \
 		bool      is_import;    \
@@ -526,6 +536,7 @@ Token ast_node_token(AstNode *node) {
 
 	case AstNode_BadDecl:        return node->BadDecl.begin;
 	case AstNode_ValueDecl:      return node->ValueDecl.token;
+	case AstNode_ProcDecl:       return node->ProcDecl.token;
 	case AstNode_ImportDecl:     return node->ImportDecl.token;
 	case AstNode_ForeignLibrary: return node->ForeignLibrary.token;
 	case AstNode_Label:          return node->Label.token;
@@ -1421,6 +1432,20 @@ AstNode *ast_value_decl(AstFile *f, Token token, Array<AstNode *> names, AstNode
 	return result;
 }
 
+AstNode *ast_proc_decl(AstFile *f, Token token, AstNode *name, AstNode *type, AstNode *body,
+                       u64 tags, AstNode *foreign_library, String foreign_name, String link_name) {
+	AstNode *result = make_ast_node(f, AstNode_ProcDecl);
+	result->ProcDecl.token           = token;
+	result->ProcDecl.name            = name;
+	result->ProcDecl.type            = type;
+	result->ProcDecl.body            = body;
+	result->ProcDecl.tags            = tags;
+	result->ProcDecl.foreign_library = foreign_library;
+	result->ProcDecl.foreign_name    = foreign_name;
+	result->ProcDecl.link_name       = link_name;
+	return result;
+}
+
 
 AstNode *ast_import_decl(AstFile *f, Token token, bool is_import, Token relpath, Token import_name, AstNode *cond) {
 	AstNode *result = make_ast_node(f, AstNode_ImportDecl);
@@ -1644,6 +1669,8 @@ bool is_semicolon_optional_for_node(AstFile *f, AstNode *s) {
 		return true;
 	case AstNode_ProcLit:
 		return s->ProcLit.body != NULL;
+	case AstNode_ProcDecl:
+		return s->ProcDecl.body != NULL;
 
 	case AstNode_ValueDecl:
 		if (s->ValueDecl.token.kind != Token_var) {
@@ -1693,7 +1720,7 @@ void expect_semicolon(AstFile *f, AstNode *s) {
 
 
 AstNode *    parse_expr(AstFile *f, bool lhs);
-AstNode *    parse_proc_type(AstFile *f, AstNode **foreign_library, String *foreign_name, String *link_name);
+AstNode *    parse_proc_type(AstFile *f, Token proc_token, AstNode **foreign_library, String *foreign_name, String *link_name);
 Array<AstNode *> parse_stmt_list(AstFile *f);
 AstNode *    parse_stmt(AstFile *f);
 AstNode *    parse_body(AstFile *f);
@@ -2051,11 +2078,11 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
 
 	// Parse Procedure Type or Literal
 	case Token_proc: {
-		Token token = f->curr_token;
+		Token token = f->curr_token; next_token(f);
 		AstNode *foreign_library = NULL;
 		String foreign_name = {};
 		String link_name = {};
-		AstNode *type = parse_proc_type(f, &foreign_library, &foreign_name, &link_name);
+		AstNode *type = parse_proc_type(f, token, &foreign_library, &foreign_name, &link_name);
 		u64 tags = type->ProcType.tags;
 
 		if (f->curr_token.kind == Token_OpenBrace) {
@@ -2532,6 +2559,30 @@ AstNode *parse_value_decl(AstFile *f, Token token) {
 	return ast_value_decl(f, token, lhs, type, values);
 }
 
+AstNode *parse_proc_decl(AstFile *f) {
+	Token token = expect_token(f, Token_proc);
+	AstNode *body = NULL;
+	AstNode *foreign_library = NULL;
+	String foreign_name = {};
+	String link_name = {};
+
+	AstNode *name = parse_ident(f);
+	AstNode *type = parse_proc_type(f, token, &foreign_library, &foreign_name, &link_name);
+	u64 tags = type->ProcType.tags;
+
+	if (f->curr_token.kind == Token_OpenBrace) {
+		if ((tags & ProcTag_foreign) != 0) {
+			syntax_error(token, "A procedure tagged as `#foreign` cannot have a body");
+		}
+		AstNode *curr_proc = f->curr_proc;
+		f->curr_proc = type;
+		body = parse_body(f);
+		f->curr_proc = curr_proc;
+	}
+
+	return ast_proc_decl(f, token, name, type, body, tags, foreign_library, foreign_name, link_name);
+}
+
 
 
 AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) {
@@ -2671,11 +2722,10 @@ AstNode *parse_results(AstFile *f) {
 	return list;
 }
 
-AstNode *parse_proc_type(AstFile *f, AstNode **foreign_library_, String *foreign_name_, String *link_name_) {
+AstNode *parse_proc_type(AstFile *f, Token proc_token, AstNode **foreign_library_, String *foreign_name_, String *link_name_) {
 	AstNode *params = {};
 	AstNode *results = {};
 
-	Token proc_token = expect_token(f, Token_proc);
 	expect_token(f, Token_OpenParen);
 	params = parse_field_list(f, NULL, FieldFlag_Signature, Token_CloseParen);
 	expect_token_after(f, Token_CloseParen, "parameter list");
@@ -3243,8 +3293,8 @@ AstNode *parse_type_or_ident(AstFile *f) {
 	}
 
 	case Token_proc: {
-		Token token = f->curr_token;
-		AstNode *pt = parse_proc_type(f, NULL, NULL, NULL);
+		Token token = f->curr_token; next_token(f);
+		AstNode *pt = parse_proc_type(f, token, NULL, NULL, NULL);
 		if (pt->ProcType.tags != 0) {
 			syntax_error(token, "A procedure type cannot have tags");
 		}
@@ -3640,6 +3690,11 @@ AstNode *parse_stmt(AstFile *f) {
 		expect_semicolon(f, s);
 		return s;
 
+	case Token_proc:
+		s = parse_proc_decl(f);
+		expect_semicolon(f, s);
+		return s;
+
 
 	case Token_if:     return parse_if_stmt(f);
 	case Token_when:   return parse_when_stmt(f);

+ 4 - 4
src/ssa.cpp

@@ -2435,12 +2435,12 @@ void ssa_build_proc(ssaModule *m, ssaProc *p) {
 	p->module = m;
 	m->proc = p;
 
-	if (p->decl_info->proc_lit == NULL ||
-	    p->decl_info->proc_lit->kind != AstNode_ProcLit) {
+	if (p->decl_info->proc_decl == NULL ||
+	    p->decl_info->proc_decl->kind != AstNode_ProcDecl) {
 		return;
 	}
 
-	ast_node(pl, ProcLit, p->decl_info->proc_lit);
+	ast_node(pl, ProcLit, p->decl_info->proc_decl);
 	if (pl->body == NULL) {
 		return;
 	}
@@ -2553,7 +2553,7 @@ bool ssa_generate(Parser *parser, CheckerInfo *info) {
 		} break;
 
 		case Entity_Procedure: {
-			ast_node(pd, ProcLit, decl->proc_lit);
+			ast_node(pd, ProcDecl, decl->proc_decl);
 			String original_name = name;
 			AstNode *body = pd->body;
 			if (e->Procedure.is_foreign) {