temp_state : ring.RingState;
temp_allocator : Allocator;
-init :: proc () {
+init :: () {
heap.init();
temp_buffer := raw_alloc(heap_allocator, TEMPORARY_ALLOCATOR_SIZE);
Arena :: struct { next : ^Arena; }
#private_file
-arena_alloc_proc :: proc (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
+arena_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
alloc_arena := cast(^ArenaState) data;
if aa == AllocationAction.Alloc {
}
// NOTE: `arena_size` must be at least 4
-make :: proc (backing: Allocator, arena_size: u32) -> ArenaState {
+make :: (backing: Allocator, arena_size: u32) -> ArenaState {
initial_arena := cast(^Arena) raw_alloc(backing, arena_size);
initial_arena.next = null;
};
}
-make_allocator :: proc (rs: ^ArenaState) -> Allocator {
+make_allocator :: (rs: ^ArenaState) -> Allocator {
return Allocator.{
func = arena_alloc_proc,
data = rs,
};
}
-free :: proc (arena: ^ArenaState) {
+free :: (arena: ^ArenaState) {
walker := arena.first_arena;
trailer := walker;
while walker != null {
}
#private_file
-fixed_allocator_proc :: proc (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
+fixed_allocator_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
fa_data := cast(^FixedAllocatorData) data;
if aa != AllocationAction.Alloc do return null;
return fa_data.ptr;
}
-make :: proc (ptr: rawptr, size: u32) -> FixedAllocatorData {
+make :: (ptr: rawptr, size: u32) -> FixedAllocatorData {
return FixedAllocatorData.{
ptr = ptr,
size = size,
};
}
-make_allocator :: proc (fa_data: ^FixedAllocatorData) -> Allocator {
+make_allocator :: (fa_data: ^FixedAllocatorData) -> Allocator {
return Allocator.{
func = fixed_allocator_proc,
data = fa_data,
}
#private_file
-heap_alloc :: proc (size_: u32, align: u32) -> rawptr {
+heap_alloc :: (size_: u32, align: u32) -> rawptr {
if size_ == 0 do return null;
size := size_ + sizeof heap_block;
}
#private_file
-heap_free :: proc (ptr: rawptr) {
+heap_free :: (ptr: rawptr) {
hb_ptr := cast(^heap_block) (cast(u32) ptr - sizeof heap_block);
// DEBUGGING: Fills freed memory with 0's
}
#private_file
-heap_resize :: proc (ptr: rawptr, new_size: u32, align: u32) -> rawptr {
+heap_resize :: (ptr: rawptr, new_size: u32, align: u32) -> rawptr {
if ptr == null do return null;
hb_ptr := cast(^heap_block) (cast(u32) ptr - sizeof heap_block);
}
#private_file
-heap_alloc_proc :: proc (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
+heap_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
if aa == AllocationAction.Alloc do return heap_alloc(size, align);
if aa == AllocationAction.Resize do return heap_resize(oldptr, size, align);
if aa == AllocationAction.Free {
return null;
}
-init :: proc () {
+init :: () {
heap_state.free_list = null;
heap_state.next_alloc = __heap_start;
heap_state.remaining_space = (memory_size() << 16) - cast(u32) __heap_start;
}
#private_file
-pool_allocator_proc :: proc (pool: ^PoolAllocator($Elem), aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
+pool_allocator_proc :: (pool: ^PoolAllocator($Elem), aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
switch aa {
case AllocationAction.Alloc {
assert(size == sizeof Elem, "Allocating wrong size from pool allocator.");
return null;
}
-pool_alloc :: proc (pool: ^PoolAllocator($Elem)) -> ^Elem {
+pool_alloc :: (pool: ^PoolAllocator($Elem)) -> ^Elem {
if pool.first_free == null do return null;
defer pool.first_free = cast(^Elem) *(cast(^rawptr) pool.first_free);
return pool.first_free;
}
-pool_free :: proc (pool: ^PoolAllocator($Elem), elem: ^Elem) {
+pool_free :: (pool: ^PoolAllocator($Elem), elem: ^Elem) {
// TODO: Maybe add a check that the elem pointer is actually in the buffer??
*(cast(^rawptr) elem) = cast(rawptr) pool.first_free;
pool.first_free = elem;
// This could become: proc (buffer: [] u8, $Elem: type_expr) -> PoolAllocator(Elem)
// when that feature is implemented.
-make :: proc (buffer: [] $Elem) -> PoolAllocator(Elem) {
+make :: (buffer: [] $Elem) -> PoolAllocator(Elem) {
assert(sizeof Elem >= sizeof rawptr, "Cannot have a pool allocator of a type less than a rawptr in size.");
for i: 0 .. buffer.count - 1 {
};
}
-make_allocator :: proc (pool: ^PoolAllocator($Elem)) -> Allocator {
+make_allocator :: (pool: ^PoolAllocator($Elem)) -> Allocator {
return Allocator.{
func = #solidify pool_allocator_proc { Elem = Elem },
data = pool,
}
#private_file
-ring_alloc_proc :: proc (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
+ring_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
ss := cast(^RingState) data;
if aa == AllocationAction.Alloc {
return null;
}
-make :: proc (buffer: rawptr, length: u32) -> RingState {
+make :: (buffer: rawptr, length: u32) -> RingState {
return RingState.{
base_ptr = buffer,
curr_ptr = buffer,
};
}
-make_allocator :: proc (rs: ^RingState) -> Allocator {
+make_allocator :: (rs: ^RingState) -> Allocator {
return Allocator.{
func = ring_alloc_proc,
data = rs,
// ---------------------------------
// Dynamic Arrays
// ---------------------------------
-make :: proc ($T: type_expr, initial_cap := 4) -> [..] T {
+make :: ($T: type_expr, initial_cap := 4) -> [..] T {
arr : [..] T;
init(^arr, initial_cap);
return arr;
}
-init :: proc (arr: ^[..] $T, initial_cap := 4) {
+init :: (arr: ^[..] $T, initial_cap := 4) {
arr.count = 0;
arr.capacity = initial_cap;
arr.data = calloc(sizeof T * arr.capacity);
}
-free :: proc (arr: ^[..] $T) {
+free :: (arr: ^[..] $T) {
arr.count = 0;
arr.capacity = 0;
arr.data = null;
}
-copy :: proc (arr: ^[..] $T) -> [..] T {
+copy :: (arr: ^[..] $T) -> [..] T {
new_arr : [..] T;
init(^new_arr, arr.count);
new_arr.count = arr.count;
return new_arr;
}
-copy_range :: proc (arr: ^[..] $T, r: range) -> [..] T {
+copy_range :: (arr: ^[..] $T, r: range) -> [..] T {
new_arr : [..] T;
init(^new_arr, r.high - r.low);
new_arr.count = r.high - r.low;
return new_arr;
}
-clear :: proc (arr: ^[..] $T) {
+clear :: (arr: ^[..] $T) {
arr.count = 0;
}
-ensure_capacity :: proc (arr: ^[..] $T, cap: u32) -> bool {
+ensure_capacity :: (arr: ^[..] $T, cap: u32) -> bool {
if arr.capacity >= cap do return true;
while cap > arr.capacity do arr.capacity <<= 1;
return true;
}
-push :: proc (arr: ^[..] $T, x: T) -> bool {
+push :: (arr: ^[..] $T, x: T) -> bool {
if !ensure_capacity(arr, arr.count + 1) do return false;
arr.data[arr.count] = x;
arr.count += 1;
return true;
}
-insert :: proc (arr: ^[..] $T, idx: u32, x: T) -> bool {
+insert :: (arr: ^[..] $T, idx: u32, x: T) -> bool {
if !ensure_capacity(arr, arr.count + 1) do return false;
arr.count += 1;
return true;
}
-remove :: proc (arr: ^[..] $T, elem: T) {
+remove :: (arr: ^[..] $T, elem: T) {
move := 0;
while i := 0; i < arr.count - move {
arr.count -= move;
}
-delete :: proc (arr: ^[..] $T, idx: u32) {
+delete :: (arr: ^[..] $T, idx: u32) {
if idx >= arr.count do return;
for i: idx .. arr.count - 1 {
arr.count -= 1;
}
-fast_delete :: proc (arr: ^[..] $T, idx: u32) {
+fast_delete :: (arr: ^[..] $T, idx: u32) {
if idx >= arr.count do return;
arr.data[idx] = arr.data[arr.count - 1];
arr.count -= 1;
}
-contains :: proc (arr: ^[..] $T, x: T) -> bool {
+contains :: (arr: ^[..] $T, x: T) -> bool {
for it: *arr do if it == x do return true;
return false;
}
-pop :: proc (arr: ^[..] $T) -> T {
+pop :: (arr: ^[..] $T) -> T {
arr.count -= 1;
return arr.data[arr.count];
}
-average :: proc (arr: ^[..] $T) -> T {
+average :: (arr: ^[..] $T) -> T {
sum := cast(T) 0;
for it: *arr do sum += it;
return sum / cast(T) arr.count;
}
-to_slice :: proc (arr: ^[..] $T) -> [] T {
+to_slice :: (arr: ^[..] $T) -> [] T {
return arr.data[0 .. arr.count];
}
** Simple insertion sort
** cmp should return >0 if left > right
*/
-sort :: proc (arr: ^[..] $T, cmp: proc (T, T) -> i32) {
+sort :: (arr: ^[..] $T, cmp: (T, T) -> i32) {
for i: 1 .. arr.count {
x := arr.data[i];
j := i - 1;
}
}
-fold :: proc (arr: ^[..] $T, init: $R, f: proc (T, R) -> R) -> R {
+fold :: (arr: ^[..] $T, init: $R, f: (T, R) -> R) -> R {
val := init;
for it: *arr do val = f(it, val);
return val;
}
// CLEANUP: :slice Move this elsewhere when more slice functionality is added
-fold_slice :: proc (arr: [] $T, init: $R, f: proc (T, R) -> R) -> R {
+fold_slice :: (arr: [] $T, init: $R, f: (T, R) -> R) -> R {
val := init;
for it: arr do val = f(it, val);
return val;
}
-map :: proc (arr: ^[..] $T, data: $R, f: proc (T, R) -> T) {
+map :: (arr: ^[..] $T, data: $R, f: (T, R) -> T) {
for ^it: *arr do *it = f(*it, data);
}
count: i32;
}
-vararg_get :: proc (va: vararg, ret: ^$T) -> bool {
+vararg_get :: (va: vararg, ret: ^$T) -> bool {
if va.count <= 0 do return false;
*ret = *cast(^T) va.data;
va.data = cast(rawptr) (cast(^u8) va.data + sizeof T);
allocator : Allocator;
temp_allocator : Allocator;
- assert_handler : proc (msg: str, file: str);
+ assert_handler : (msg: str, file: str) -> void;
}
context : OnyxContext;
-assert :: proc (cond: bool, msg: str, file: str = str.{ null, 0 }) {
+assert :: (cond: bool, msg: str, file: str = str.{ null, 0 }) {
if !cond do context.assert_handler(msg, file);
}
Resize;
}
-allocator_proc :: #type proc (data: rawptr, action: AllocationAction, size: u32, align: u32, old_ptr: rawptr) -> rawptr;
+allocator_proc :: #type (data: rawptr, action: AllocationAction, size: u32, align: u32, old_ptr: rawptr) -> rawptr;
Allocator :: struct {
data: rawptr;
func: allocator_proc;
}
-raw_alloc :: proc (use a: Allocator, size: u32, alignment := __DEFAULT_ALLOCATION_ALIGNMENT) -> rawptr {
+raw_alloc :: (use a: Allocator, size: u32, alignment := __DEFAULT_ALLOCATION_ALIGNMENT) -> rawptr {
return func(data, AllocationAction.Alloc, size, alignment, null);
}
-raw_resize :: proc (use a: Allocator, ptr: rawptr, size: u32, alignment := __DEFAULT_ALLOCATION_ALIGNMENT) -> rawptr {
+raw_resize :: (use a: Allocator, ptr: rawptr, size: u32, alignment := __DEFAULT_ALLOCATION_ALIGNMENT) -> rawptr {
return func(data, AllocationAction.Resize, size, alignment, ptr);
}
-raw_free :: proc (use a: Allocator, ptr: rawptr) {
+raw_free :: (use a: Allocator, ptr: rawptr) {
func(data, AllocationAction.Free, 0, 0, ptr);
}
// Allocators using the context structure.
-calloc :: proc (size: u32) -> rawptr do return raw_alloc(context.allocator, size);
-cresize :: proc (ptr: rawptr, size: u32) -> rawptr do return raw_resize(context.allocator, ptr, size);
-cfree :: proc (ptr: rawptr) do raw_free(context.allocator, ptr);
+calloc :: (size: u32) -> rawptr do return raw_alloc(context.allocator, size);
+cresize :: (ptr: rawptr, size: u32) -> rawptr do return raw_resize(context.allocator, ptr, size);
+cfree :: (ptr: rawptr) do raw_free(context.allocator, ptr);
// @CLEANUP: These need to move to somewhere else eventually
-cmp_asc :: proc (a: $T, b: T) -> i32 do return cast(i32) (a - b);
-cmp_dec :: proc (a: $T, b: T) -> i32 do return cast(i32) (b - a);
+cmp_asc :: (a: $T, b: T) -> i32 do return cast(i32) (a - b);
+cmp_dec :: (a: $T, b: T) -> i32 do return cast(i32) (b - a);
package core.conv
-i64_to_str :: proc (n: i64, base: u64, buf: [] u8, min_length := 0) -> str {
+i64_to_str :: (n: i64, base: u64, buf: [] u8, min_length := 0) -> str {
is_neg := false;
if n < 0 && base == 10 {
is_neg = true;
}
// NOTE: This is a big hack but it will work for now
-f64_to_str :: proc (f: f64, buf: [] u8) -> str {
+f64_to_str :: (f: f64, buf: [] u8) -> str {
f *= 10000.0;
v := cast(i64) f;
return str.{ buf.data, len };
}
-str_format :: proc (format: str, buffer: [] u8, va: ...) -> str {
+str_format :: (format: str, buffer: [] u8, va: ...) -> str {
return str_format_va(format, buffer, va);
}
-str_format_va :: proc (format: str, buffer: [] u8, va: vararg) -> str {
+str_format_va :: (format: str, buffer: [] u8, va: vararg) -> str {
len := 0;
state := 0;
v128 :: #type simd.v128
// NOTE: These u8 values must be compile time known values.
-v128_const :: proc (b1: u8, b2: u8, b3: u8, b4: u8,
+v128_const :: (b1: u8, b2: u8, b3: u8, b4: u8,
b5: u8, b6: u8, b7: u8, b8: u8,
b9: u8, b10: u8, b11: u8, b12: u8,
b13: u8, b14: u8, b15: u8, b16: u8) -> v128 #intrinsic ---
-i8x16_const :: proc (b1: i8, b2: i8, b3: i8, b4: i8,
+i8x16_const :: (b1: i8, b2: i8, b3: i8, b4: i8,
b5: i8, b6: i8, b7: i8, b8: i8,
b9: i8, b10: i8, b11: i8, b12: i8,
b13: i8, b14: i8, b15: i8, b16: i8) -> i8x16 #intrinsic ---
-i16x8_const :: proc (b1: i16, b2: i16, b3: i16, b4: i16,
+i16x8_const :: (b1: i16, b2: i16, b3: i16, b4: i16,
b5: i16, b6: i16, b7: i16, b8: i16) -> i16x8 #intrinsic ---
-i32x4_const :: proc (b1: i32, b2: i32, b3: i32, b4: i32) -> i32x4 #intrinsic ---
-i64x2_const :: proc (b1: i64, b2: i64) -> i64x2 #intrinsic ---
-f32x4_const :: proc (b1: f32, b2: f32, b3: f32, b4: f32) -> f32x4 #intrinsic ---
-f64x2_const :: proc (b1: f64, b2: f64) -> f64x2 #intrinsic ---
+i32x4_const :: (b1: i32, b2: i32, b3: i32, b4: i32) -> i32x4 #intrinsic ---
+i64x2_const :: (b1: i64, b2: i64) -> i64x2 #intrinsic ---
+f32x4_const :: (b1: f32, b2: f32, b3: f32, b4: f32) -> f32x4 #intrinsic ---
+f64x2_const :: (b1: f64, b2: f64) -> f64x2 #intrinsic ---
// NOTE: These u8 values must be compile time known values.
-i8x16_shuffle :: proc (a: v128, b: v128,
+i8x16_shuffle :: (a: v128, b: v128,
b1: u8, b2: u8, b3: u8, b4: u8,
b5: u8, b6: u8, b7: u8, b8: u8,
b9: u8, b10: u8, b11: u8, b12: u8,
b13: u8, b14: u8, b15: u8, b16: u8) -> v128 #intrinsic ---
-i8x16_extract_lane_s :: proc (v: i8x16, l: u32) -> i8 #intrinsic ---
-i8x16_extract_lane_u :: proc (v: i8x16, l: u32) -> u8 #intrinsic ---
-i8x16_replace_lane :: proc (v: i8x16, l: u32, val: i8) -> i8x16 #intrinsic ---
-i16x8_extract_lane_s :: proc (v: i16x8, l: u32) -> i16 #intrinsic ---
-i16x8_extract_lane_u :: proc (v: i16x8, l: u32) -> u16 #intrinsic ---
-i16x8_replace_lane :: proc (v: i16x8, l: u32, val: i16) -> i16x8 #intrinsic ---
-i32x4_extract_lane :: proc (v: i32x4, l: u32) -> i32 #intrinsic ---
-i32x4_replace_lane :: proc (v: i32x4, l: u32, val: i32) -> i32x4 #intrinsic ---
-i64x2_extract_lane :: proc (v: i64x2, l: u32) -> i64 #intrinsic ---
-i64x2_replace_lane :: proc (v: i64x2, l: u32, val: i64) -> i64x2 #intrinsic ---
-f32x4_extract_lane :: proc (v: f32x4, l: u32) -> f32 #intrinsic ---
-f32x4_replace_lane :: proc (v: f32x4, l: u32, val: f32) -> f32x4 #intrinsic ---
-f64x2_extract_lane :: proc (v: f64x2, l: u32) -> f64 #intrinsic ---
-f64x2_replace_lane :: proc (v: f64x2, l: u32, val: f64) -> f64x2 #intrinsic ---
-
-i8x16_swizzle :: proc (v: v128, s: v128) -> v128 #intrinsic ---
-i8x16_splat :: proc (val: i8) -> i8x16 #intrinsic ---
-i16x8_splat :: proc (val: i16) -> i16x8 #intrinsic ---
-i32x4_splat :: proc (val: i32) -> i32x4 #intrinsic ---
-i64x2_splat :: proc (val: i64) -> i64x2 #intrinsic ---
-f32x4_splat :: proc (val: f32) -> f32x4 #intrinsic ---
-f64x2_splat :: proc (val: f64) -> f64x2 #intrinsic ---
-
-i8x16_eq :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_neq :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_lt_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_lt_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_gt_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_gt_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_le_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_le_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_ge_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_ge_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-
-i16x8_eq :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_neq :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_lt_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_lt_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_gt_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_gt_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_le_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_le_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_ge_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_ge_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-
-i32x4_eq :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_neq :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_lt_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_lt_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_gt_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_gt_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_le_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_le_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_ge_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_ge_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-
-f32x4_eq :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-f32x4_neq :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-f32x4_lt :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-f32x4_gt :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-f32x4_le :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-f32x4_ge :: proc (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
-
-f64x2_eq :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_neq :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_lt :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_gt :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_le :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_ge :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-
-v128_not :: proc (v: v128) -> v128 #intrinsic ---
-v128_and :: proc (a: v128, b: v128) -> v128 #intrinsic ---
-v128_andnot :: proc (a: v128, b: v128) -> v128 #intrinsic ---
-v128_or :: proc (a: v128, b: v128) -> v128 #intrinsic ---
-v128_xor :: proc (a: v128, b: v128) -> v128 #intrinsic ---
-v128_bitselect :: proc (a: v128, b: v128, c: v128) -> v128 #intrinsic ---
-
-i8x16_abs :: proc (a: i8x16) -> i8x16 #intrinsic ---
-i8x16_neg :: proc (a: i8x16) -> i8x16 #intrinsic ---
-i8x16_any_true :: proc (a: i8x16) -> bool #intrinsic ---
-i8x16_all_true :: proc (a: i8x16) -> bool #intrinsic ---
-i8x16_bitmask :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_narrow_i16x8_s :: proc (a: i16x8) -> i8x16 #intrinsic ---
-i8x16_narrow_i16x8_u :: proc (a: i16x8) -> i8x16 #intrinsic ---
-i8x16_shl :: proc (a: i8x16, s: i32) -> i8x16 #intrinsic ---
-i8x16_shr_s :: proc (a: i8x16, s: i32) -> i8x16 #intrinsic ---
-i8x16_shr_u :: proc (a: i8x16, s: i32) -> i8x16 #intrinsic ---
-i8x16_add :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_add_sat_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_add_sat_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_sub :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_sub_sat_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_sub_sat_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_min_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_min_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_max_s :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_max_u :: proc (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
-i8x16_avgr_u :: proc (a: i8x16) -> i8x16 #intrinsic ---
-
-i16x8_abs :: proc (a: i16x8) -> i16x8 #intrinsic ---
-i16x8_neg :: proc (a: i16x8) -> i16x8 #intrinsic ---
-i16x8_any_true :: proc (a: i16x8) -> bool #intrinsic ---
-i16x8_all_true :: proc (a: i16x8) -> bool #intrinsic ---
-i16x8_bitmask :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_narrow_i32x4_s :: proc (a: i32x4) -> i16x8 #intrinsic ---
-i16x8_narrow_i32x4_u :: proc (a: i32x4) -> i16x8 #intrinsic ---
-i16x8_widen_low_i8x16_s :: proc (a: i8x16) -> i16x8 #intrinsic ---
-i16x8_widen_high_i8x16_s :: proc (a: i8x16) -> i16x8 #intrinsic ---
-i16x8_widen_low_i8x16_u :: proc (a: i8x16) -> i16x8 #intrinsic ---
-i16x8_widen_high_i8x16_u :: proc (a: i8x16) -> i16x8 #intrinsic ---
-i16x8_shl :: proc (a: i16x8, s: i32) -> i16x8 #intrinsic ---
-i16x8_shr_s :: proc (a: i16x8, s: i32) -> i16x8 #intrinsic ---
-i16x8_shr_u :: proc (a: i16x8, s: i32) -> i16x8 #intrinsic ---
-i16x8_add :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_add_sat_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_add_sat_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_sub :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_sub_sat_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_sub_sat_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_mul :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_min_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_min_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_max_s :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_max_u :: proc (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
-i16x8_avgr_u :: proc (a: i16x8) -> i16x8 #intrinsic ---
-
-i32x4_abs :: proc (a: i32x4) -> i32x4 #intrinsic ---
-i32x4_neg :: proc (a: i32x4) -> i32x4 #intrinsic ---
-i32x4_any_true :: proc (a: i32x4) -> bool #intrinsic ---
-i32x4_all_true :: proc (a: i32x4) -> bool #intrinsic ---
-i32x4_bitmask :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_widen_low_i16x8_s :: proc (a: i16x8) -> i32x4 #intrinsic ---
-i32x4_widen_high_i16x8_s :: proc (a: i16x8) -> i32x4 #intrinsic ---
-i32x4_widen_low_i16x8_u :: proc (a: i16x8) -> i32x4 #intrinsic ---
-i32x4_widen_high_i16x8_u :: proc (a: i16x8) -> i32x4 #intrinsic ---
-i32x4_shl :: proc (a: i32x4, s: i32) -> i32x4 #intrinsic ---
-i32x4_shr_s :: proc (a: i32x4, s: i32) -> i32x4 #intrinsic ---
-i32x4_shl_u :: proc (a: i32x4, s: i32) -> i32x4 #intrinsic ---
-i32x4_add :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_sub :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_mul :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_min_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_min_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_max_s :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-i32x4_max_u :: proc (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
-
-i64x2_neg :: proc (a: i64x2) -> i64x2 #intrinsic ---
-i64x2_shl :: proc (a: i64x2, s: i32) -> i64x2 #intrinsic ---
-i64x2_shr_s :: proc (a: i64x2, s: i32) -> i64x2 #intrinsic ---
-i64x2_shr_u :: proc (a: i64x2, s: i32) -> i64x2 #intrinsic ---
-i64x2_add :: proc (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
-i64x2_sub :: proc (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
-i64x2_mul :: proc (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
-
-f32x4_abs :: proc (a: f32x4) -> f32x4 #intrinsic ---
-f32x4_neg :: proc (a: f32x4) -> f32x4 #intrinsic ---
-f32x4_sqrt :: proc (a: f32x4) -> f32x4 #intrinsic ---
-f32x4_add :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-f32x4_sub :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-f32x4_mul :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-f32x4_div :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-f32x4_min :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-f32x4_max :: proc (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
-
-f64x2_abs :: proc (a: f64x2) -> f64x2 #intrinsic ---
-f64x2_neg :: proc (a: f64x2) -> f64x2 #intrinsic ---
-f64x2_sqrt :: proc (a: f64x2) -> f64x2 #intrinsic ---
-f64x2_add :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_sub :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_mul :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_div :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_min :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
-f64x2_max :: proc (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+i8x16_extract_lane_s :: (v: i8x16, l: u32) -> i8 #intrinsic ---
+i8x16_extract_lane_u :: (v: i8x16, l: u32) -> u8 #intrinsic ---
+i8x16_replace_lane :: (v: i8x16, l: u32, val: i8) -> i8x16 #intrinsic ---
+i16x8_extract_lane_s :: (v: i16x8, l: u32) -> i16 #intrinsic ---
+i16x8_extract_lane_u :: (v: i16x8, l: u32) -> u16 #intrinsic ---
+i16x8_replace_lane :: (v: i16x8, l: u32, val: i16) -> i16x8 #intrinsic ---
+i32x4_extract_lane :: (v: i32x4, l: u32) -> i32 #intrinsic ---
+i32x4_replace_lane :: (v: i32x4, l: u32, val: i32) -> i32x4 #intrinsic ---
+i64x2_extract_lane :: (v: i64x2, l: u32) -> i64 #intrinsic ---
+i64x2_replace_lane :: (v: i64x2, l: u32, val: i64) -> i64x2 #intrinsic ---
+f32x4_extract_lane :: (v: f32x4, l: u32) -> f32 #intrinsic ---
+f32x4_replace_lane :: (v: f32x4, l: u32, val: f32) -> f32x4 #intrinsic ---
+f64x2_extract_lane :: (v: f64x2, l: u32) -> f64 #intrinsic ---
+f64x2_replace_lane :: (v: f64x2, l: u32, val: f64) -> f64x2 #intrinsic ---
+
+i8x16_swizzle :: (v: v128, s: v128) -> v128 #intrinsic ---
+i8x16_splat :: (val: i8) -> i8x16 #intrinsic ---
+i16x8_splat :: (val: i16) -> i16x8 #intrinsic ---
+i32x4_splat :: (val: i32) -> i32x4 #intrinsic ---
+i64x2_splat :: (val: i64) -> i64x2 #intrinsic ---
+f32x4_splat :: (val: f32) -> f32x4 #intrinsic ---
+f64x2_splat :: (val: f64) -> f64x2 #intrinsic ---
+
+i8x16_eq :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_neq :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_lt_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_lt_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_gt_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_gt_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_le_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_le_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_ge_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_ge_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+
+i16x8_eq :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_neq :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_lt_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_lt_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_gt_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_gt_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_le_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_le_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_ge_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_ge_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+
+i32x4_eq :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_neq :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_lt_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_lt_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_gt_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_gt_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_le_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_le_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_ge_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_ge_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+
+f32x4_eq :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+f32x4_neq :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+f32x4_lt :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+f32x4_gt :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+f32x4_le :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+f32x4_ge :: (a: f32x4, b: f32x4) -> i32x4 #intrinsic ---
+
+f64x2_eq :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_neq :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_lt :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_gt :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_le :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_ge :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+
+v128_not :: (v: v128) -> v128 #intrinsic ---
+v128_and :: (a: v128, b: v128) -> v128 #intrinsic ---
+v128_andnot :: (a: v128, b: v128) -> v128 #intrinsic ---
+v128_or :: (a: v128, b: v128) -> v128 #intrinsic ---
+v128_xor :: (a: v128, b: v128) -> v128 #intrinsic ---
+v128_bitselect :: (a: v128, b: v128, c: v128) -> v128 #intrinsic ---
+
+i8x16_abs :: (a: i8x16) -> i8x16 #intrinsic ---
+i8x16_neg :: (a: i8x16) -> i8x16 #intrinsic ---
+i8x16_any_true :: (a: i8x16) -> bool #intrinsic ---
+i8x16_all_true :: (a: i8x16) -> bool #intrinsic ---
+i8x16_bitmask :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_narrow_i16x8_s :: (a: i16x8) -> i8x16 #intrinsic ---
+i8x16_narrow_i16x8_u :: (a: i16x8) -> i8x16 #intrinsic ---
+i8x16_shl :: (a: i8x16, s: i32) -> i8x16 #intrinsic ---
+i8x16_shr_s :: (a: i8x16, s: i32) -> i8x16 #intrinsic ---
+i8x16_shr_u :: (a: i8x16, s: i32) -> i8x16 #intrinsic ---
+i8x16_add :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_add_sat_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_add_sat_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_sub :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_sub_sat_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_sub_sat_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_min_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_min_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_max_s :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_max_u :: (a: i8x16, b: i8x16) -> i8x16 #intrinsic ---
+i8x16_avgr_u :: (a: i8x16) -> i8x16 #intrinsic ---
+
+i16x8_abs :: (a: i16x8) -> i16x8 #intrinsic ---
+i16x8_neg :: (a: i16x8) -> i16x8 #intrinsic ---
+i16x8_any_true :: (a: i16x8) -> bool #intrinsic ---
+i16x8_all_true :: (a: i16x8) -> bool #intrinsic ---
+i16x8_bitmask :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_narrow_i32x4_s :: (a: i32x4) -> i16x8 #intrinsic ---
+i16x8_narrow_i32x4_u :: (a: i32x4) -> i16x8 #intrinsic ---
+i16x8_widen_low_i8x16_s :: (a: i8x16) -> i16x8 #intrinsic ---
+i16x8_widen_high_i8x16_s :: (a: i8x16) -> i16x8 #intrinsic ---
+i16x8_widen_low_i8x16_u :: (a: i8x16) -> i16x8 #intrinsic ---
+i16x8_widen_high_i8x16_u :: (a: i8x16) -> i16x8 #intrinsic ---
+i16x8_shl :: (a: i16x8, s: i32) -> i16x8 #intrinsic ---
+i16x8_shr_s :: (a: i16x8, s: i32) -> i16x8 #intrinsic ---
+i16x8_shr_u :: (a: i16x8, s: i32) -> i16x8 #intrinsic ---
+i16x8_add :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_add_sat_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_add_sat_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_sub :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_sub_sat_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_sub_sat_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_mul :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_min_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_min_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_max_s :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_max_u :: (a: i16x8, b: i16x8) -> i16x8 #intrinsic ---
+i16x8_avgr_u :: (a: i16x8) -> i16x8 #intrinsic ---
+
+i32x4_abs :: (a: i32x4) -> i32x4 #intrinsic ---
+i32x4_neg :: (a: i32x4) -> i32x4 #intrinsic ---
+i32x4_any_true :: (a: i32x4) -> bool #intrinsic ---
+i32x4_all_true :: (a: i32x4) -> bool #intrinsic ---
+i32x4_bitmask :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_widen_low_i16x8_s :: (a: i16x8) -> i32x4 #intrinsic ---
+i32x4_widen_high_i16x8_s :: (a: i16x8) -> i32x4 #intrinsic ---
+i32x4_widen_low_i16x8_u :: (a: i16x8) -> i32x4 #intrinsic ---
+i32x4_widen_high_i16x8_u :: (a: i16x8) -> i32x4 #intrinsic ---
+i32x4_shl :: (a: i32x4, s: i32) -> i32x4 #intrinsic ---
+i32x4_shr_s :: (a: i32x4, s: i32) -> i32x4 #intrinsic ---
+i32x4_shl_u :: (a: i32x4, s: i32) -> i32x4 #intrinsic ---
+i32x4_add :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_sub :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_mul :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_min_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_min_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_max_s :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+i32x4_max_u :: (a: i32x4, b: i32x4) -> i32x4 #intrinsic ---
+
+i64x2_neg :: (a: i64x2) -> i64x2 #intrinsic ---
+i64x2_shl :: (a: i64x2, s: i32) -> i64x2 #intrinsic ---
+i64x2_shr_s :: (a: i64x2, s: i32) -> i64x2 #intrinsic ---
+i64x2_shr_u :: (a: i64x2, s: i32) -> i64x2 #intrinsic ---
+i64x2_add :: (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
+i64x2_sub :: (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
+i64x2_mul :: (a: i64x2, b: i64x2) -> i64x2 #intrinsic ---
+
+f32x4_abs :: (a: f32x4) -> f32x4 #intrinsic ---
+f32x4_neg :: (a: f32x4) -> f32x4 #intrinsic ---
+f32x4_sqrt :: (a: f32x4) -> f32x4 #intrinsic ---
+f32x4_add :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+f32x4_sub :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+f32x4_mul :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+f32x4_div :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+f32x4_min :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+f32x4_max :: (a: f32x4, b: f32x4) -> f32x4 #intrinsic ---
+
+f64x2_abs :: (a: f64x2) -> f64x2 #intrinsic ---
+f64x2_neg :: (a: f64x2) -> f64x2 #intrinsic ---
+f64x2_sqrt :: (a: f64x2) -> f64x2 #intrinsic ---
+f64x2_add :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_sub :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_mul :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_div :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_min :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
+f64x2_max :: (a: f64x2, b: f64x2) -> f64x2 #intrinsic ---
// NOTE: These may be backwards
-i32x4_trunc_sat_f32x4_s :: proc (v: f32x4) -> i32x4 #intrinsic ---
-i32x4_trunc_sat_f32x4_u :: proc (v: f32x4) -> i32x4 #intrinsic ---
-f32x4_convert_i32x4_s :: proc (v: i32x4) -> f32x4 #intrinsic ---
-f32x4_convert_i32x4_u :: proc (v: i32x4) -> f32x4 #intrinsic ---
+i32x4_trunc_sat_f32x4_s :: (v: f32x4) -> i32x4 #intrinsic ---
+i32x4_trunc_sat_f32x4_u :: (v: f32x4) -> i32x4 #intrinsic ---
+f32x4_convert_i32x4_s :: (v: i32x4) -> f32x4 #intrinsic ---
+f32x4_convert_i32x4_u :: (v: i32x4) -> f32x4 #intrinsic ---
package core.intrinsics.wasm
-memory_size :: proc () -> i32 #intrinsic ---
-memory_grow :: proc (val: i32) -> i32 #intrinsic ---
+memory_size :: () -> i32 #intrinsic ---
+memory_grow :: (val: i32) -> i32 #intrinsic ---
-clz_i32 :: proc (val: i32) -> i32 #intrinsic ---
-ctz_i32 :: proc (val: i32) -> i32 #intrinsic ---
-popcnt_i32 :: proc (val: i32) -> i32 #intrinsic ---
-and_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-or_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-xor_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-shl_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-slr_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-sar_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-rotl_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-rotr_i32 :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+clz_i32 :: (val: i32) -> i32 #intrinsic ---
+ctz_i32 :: (val: i32) -> i32 #intrinsic ---
+popcnt_i32 :: (val: i32) -> i32 #intrinsic ---
+and_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+or_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+xor_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+shl_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+slr_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+sar_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+rotl_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+rotr_i32 :: (lhs: i32, rhs: i32) -> i32 #intrinsic ---
-clz_i64 :: proc (val: i64) -> i64 #intrinsic ---
-ctz_i64 :: proc (val: i64) -> i64 #intrinsic ---
-popcnt_i64 :: proc (val: i64) -> i64 #intrinsic ---
-and_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-or_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-xor_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-shl_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-slr_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-sar_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-rotl_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-rotr_i64 :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+clz_i64 :: (val: i64) -> i64 #intrinsic ---
+ctz_i64 :: (val: i64) -> i64 #intrinsic ---
+popcnt_i64 :: (val: i64) -> i64 #intrinsic ---
+and_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+or_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+xor_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+shl_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+slr_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+sar_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+rotl_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+rotr_i64 :: (lhs: i64, rhs: i64) -> i64 #intrinsic ---
-abs_f32 :: proc (val: f32) -> f32 #intrinsic ---
-ceil_f32 :: proc (val: f32) -> f32 #intrinsic ---
-floor_f32 :: proc (val: f32) -> f32 #intrinsic ---
-trunc_f32 :: proc (val: f32) -> f32 #intrinsic ---
-nearest_f32 :: proc (val: f32) -> f32 #intrinsic ---
-sqrt_f32 :: proc (val: f32) -> f32 #intrinsic ---
-min_f32 :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
-max_f32 :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
-copysign_f32 :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
+abs_f32 :: (val: f32) -> f32 #intrinsic ---
+ceil_f32 :: (val: f32) -> f32 #intrinsic ---
+floor_f32 :: (val: f32) -> f32 #intrinsic ---
+trunc_f32 :: (val: f32) -> f32 #intrinsic ---
+nearest_f32 :: (val: f32) -> f32 #intrinsic ---
+sqrt_f32 :: (val: f32) -> f32 #intrinsic ---
+min_f32 :: (lhs: f32, rhs: f32) -> f32 #intrinsic ---
+max_f32 :: (lhs: f32, rhs: f32) -> f32 #intrinsic ---
+copysign_f32 :: (lhs: f32, rhs: f32) -> f32 #intrinsic ---
-abs_f64 :: proc (val: f64) -> f64 #intrinsic ---
-ceil_f64 :: proc (val: f64) -> f64 #intrinsic ---
-floor_f64 :: proc (val: f64) -> f64 #intrinsic ---
-trunc_f64 :: proc (val: f64) -> f64 #intrinsic ---
-nearest_f64 :: proc (val: f64) -> f64 #intrinsic ---
-sqrt_f64 :: proc (val: f64) -> f64 #intrinsic ---
-min_f64 :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
-max_f64 :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
-copysign_f64 :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
+abs_f64 :: (val: f64) -> f64 #intrinsic ---
+ceil_f64 :: (val: f64) -> f64 #intrinsic ---
+floor_f64 :: (val: f64) -> f64 #intrinsic ---
+trunc_f64 :: (val: f64) -> f64 #intrinsic ---
+nearest_f64 :: (val: f64) -> f64 #intrinsic ---
+sqrt_f64 :: (val: f64) -> f64 #intrinsic ---
+min_f64 :: (lhs: f64, rhs: f64) -> f64 #intrinsic ---
+max_f64 :: (lhs: f64, rhs: f64) -> f64 #intrinsic ---
+copysign_f64 :: (lhs: f64, rhs: f64) -> f64 #intrinsic ---
stream : ^Stream;
}
-reader_make :: proc (s: ^Stream) -> Reader {
+reader_make :: (s: ^Stream) -> Reader {
assert(s.vtable != null, "Stream vtable was not setup correctly.");
return Reader.{ s };
}
-read_u32 :: proc (use reader: ^Reader) -> u32 {
+read_u32 :: (use reader: ^Reader) -> u32 {
n: u32 = 0;
skip_whitespace(reader);
return n;
}
-read_u64 :: proc (use reader: ^Reader) -> u64 {
+read_u64 :: (use reader: ^Reader) -> u64 {
n: u64 = 0;
skip_whitespace(reader);
return n;
}
-read_line :: proc (use reader: ^Reader, allocator := context.allocator) -> str {
+read_line :: (use reader: ^Reader, allocator := context.allocator) -> str {
_, curr_pos := stream_tell(stream);
count := 0;
return out;
}
-read_word :: proc (use reader: ^Reader, allocator := context.allocator) -> str {
+read_word :: (use reader: ^Reader, allocator := context.allocator) -> str {
skip_whitespace(reader);
_, curr_pos := stream_tell(stream);
return out;
}
-advance_line :: proc (use reader: ^Reader) {
+advance_line :: (use reader: ^Reader) {
err, curr := stream_read_byte(stream);
if err != Error.None do return;
err, curr = stream_read_byte(stream);
}
-skip_whitespace :: proc (use reader: ^Reader) {
+skip_whitespace :: (use reader: ^Reader) {
while true {
err, byte := stream_peek_byte(stream);
if err == Error.EOF do break;
stream : ^Stream;
}
-writer_make :: proc (s: ^Stream) -> Writer {
+writer_make :: (s: ^Stream) -> Writer {
assert(s.vtable != null, "Stream vtable was not setup correctly.");
return Writer.{ s };
}
-write_str :: proc (use writer: ^Writer, s: str) {
+write_str :: (use writer: ^Writer, s: str) {
stream_write(stream, s);
}
-write_cstr :: proc (use writer: ^Writer, cs: cstr) {
+write_cstr :: (use writer: ^Writer, cs: cstr) {
use package core
s := string.make(cs);
write_str(writer, s);
}
-write_i32 :: proc (use writer: ^Writer, n: i32, base: u32 = 10) {
+write_i32 :: (use writer: ^Writer, n: i32, base: u32 = 10) {
use package core
buf : [256] u8;
write_str(writer, s);
}
-write_i64 :: proc (use writer: ^Writer, n: i64, base: u64 = 10) {
+write_i64 :: (use writer: ^Writer, n: i64, base: u64 = 10) {
use package core
buf : [256] u8;
write_str(writer, s);
}
-write_f32 :: proc (use writer: ^Writer, f: f32) {
+write_f32 :: (use writer: ^Writer, f: f32) {
use package core
buf : [256] u8;
write_str(writer, s);
}
-write_f64 :: proc (use writer: ^Writer, f: f64) {
+write_f64 :: (use writer: ^Writer, f: f64) {
use package core
buf : [256] u8;
write_str(writer, s);
}
-write_bool :: proc (use writer: ^Writer, b: bool) {
+write_bool :: (use writer: ^Writer, b: bool) {
if b do write_str(writer, "true");
else do write_str(writer, "false");
}
-write_ptr :: proc (use writer: ^Writer, p: ^void) {
+write_ptr :: (use writer: ^Writer, p: ^void) {
write_i64(writer, cast(i64) p, 16);
}
-write_range :: proc (use writer: ^Writer, r: range, sep := " ") {
+write_range :: (use writer: ^Writer, r: range, sep := " ") {
for i: r {
write_i32(writer, i);
if i + r.step < r.high do write_str(writer, sep);
}
}
-write_format :: proc (use writer: ^Writer, format: str, va: ...) {
+write_format :: (use writer: ^Writer, format: str, va: ...) {
// POTENTIAL BUG: this buffer will need to be bigger (or dynamic).
buffer: [2048] u8;
write_str(writer, conv.str_format_va(format, buffer[0 .. 2048], va));
GLMat3 :: #type [9] GLfloat
GLMat4 :: #type [16] GLfloat
-activeTexture :: proc (texture: GLenum) #foreign "gl" "activeTexture" ---
-attachShader :: proc (program: GLProgram, shader: GLShader) -> GLProgram #foreign "gl" "attachShader" ---
-bindAttribLocation :: proc (program: GLProgram, index: GLuint, name: str) #foreign "gl" "bindAttribLocation" ---
-bindBuffer :: proc (target: GLenum, buffer: GLBuffer) #foreign "gl" "bindBuffer" ---
-bindFramebuffer :: proc (target: GLenum, framebuffer: GLFramebuffer) #foreign "gl" "bindFramebuffer" ---
-bindRenderbuffer :: proc (target: GLenum, renderbuffer: GLRenderbuffer) #foreign "gl" "bindRenderbuffer" ---
-bindTexture :: proc (target: GLenum, texture: GLTexture) #foreign "gl" "bindTexture" ---
-bindVertexArray :: proc (vertexArray: GLVertexArrayObject) #foreign "gl" "bindVertexArray" ---
-blendColor :: proc (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) #foreign "gl" "blendColor" ---
-blendEquation :: proc (mode: GLenum) #foreign "gl" "blendEquation" ---
-blendEquationSeparate :: proc (modeRGB: GLenum, modeAlpha: GLenum) #foreign "gl" "blendEquationSeparate" ---
-blendFunc :: proc (sfactor: GLenum, dfactor: GLenum) #foreign "gl" "blendFunc" ---
-blendFuncSeparate :: proc (srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) #foreign "gl" "blendFuncSeparate" ---
-blitFramebuffer :: proc (sx0: GLint, sy0: GLint, sx1: GLint, sy1: GLint, dx0: GLint, dy0: GLint, dx1: GLint, dy1: GLint, mask: GLbitfield, filter: GLenum) #foreign "gl" "blitFramebuffer" ---
-bufferDataWithData :: proc (target: GLenum, buffer: [] void, usage: GLenum) #foreign "gl" "bufferDataWithData" ---
-bufferDataNoData :: proc (target: GLenum, size: GLsizeiptr, usage: GLenum) #foreign "gl" "bufferDataNoData" ---
-bufferData :: proc { bufferDataWithData, bufferDataNoData }
-bufferSubData :: proc (target: GLenum, offset: GLsizei, data: [] void) #foreign "gl" "bufferSubData" ---
-canvasSize :: proc (width: GLsizei, height: GLsizei) #foreign "gl" "canvasSize" ---
-checkFrameBufferStatus :: proc (target: GLenum) -> GLenum #foreign "gl" "checkFrameBufferStatus" ---
-clear :: proc (mask: GLbitfield) #foreign "gl" "clear" ---
-clearColor :: proc (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) #foreign "gl" "clearColor" ---
-clearDepth :: proc (depth: GLclampf) #foreign "gl" "clearDepth" ---
-clearStencil :: proc (s: GLint) #foreign "gl" "clearStencil" ---
-colorMask :: proc (red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) #foreign "gl" "colorMask" ---
-compileShader :: proc (shader: GLShader) #foreign "gl" "compileShader" ---
-compressedTexImage2D :: proc (target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: str) #foreign "gl" "compressedTexImage2D" ---
-compressedTexSubImage2D :: proc (target: GLenum, level: GLint, internalformat: GLenum, xoff: GLint, yoff: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: str) #foreign "gl" "compressedTexSubImage2D" ---
-copyBufferSubData :: proc (readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) #foreign "gl" "copyBufferSubData" ---
-copyTexImage2D :: proc (target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) #foreign "gl" "copyTexImage2D" ---
-copyTexSubImage2D :: proc (target: GLenum, level: GLint, xoff: GLint, yoff: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) #foreign "gl" "copyTexSubImage2D" ---
-createBuffer :: proc () -> GLBuffer #foreign "gl" "createBuffer" ---
-createFramebuffer :: proc () -> GLFramebuffer #foreign "gl" "createFramebuffer" ---
-createProgram :: proc () -> GLProgram #foreign "gl" "createProgram" ---
-createRenderbuffer :: proc () -> GLRenderbuffer #foreign "gl" "createRenderbuffer" ---
-createShader :: proc (type: GLenum) -> GLShader #foreign "gl" "createShader" ---
-createTexture :: proc () -> GLTexture #foreign "gl" "createTexture" ---
-createVertexArray :: proc () -> GLVertexArrayObject #foreign "gl" "createVertexArray" ---
-cullFace :: proc (mode: GLenum) #foreign "gl" "cullFace" ---
-deleteBuffer :: proc (buffer: GLBuffer) #foreign "gl" "deleteBuffer" ---
-deleteFramebuffer :: proc (framebuffer: GLFramebuffer) #foreign "gl" "deleteFramebuffer" ---
-deleteProgram :: proc (program: GLProgram) #foreign "gl" "deleteProgram" ---
-deleteRenderbuffer :: proc (renderbuffer: GLRenderbuffer) #foreign "gl" "deleteRenderbuffer" ---
-deleteShader :: proc (shader: GLShader) #foreign "gl" "deleteShader" ---
-deleteTexture :: proc (texture: GLTexture) #foreign "gl" "deleteTexture" ---
-deleteVertexArray :: proc (vertexArray: GLVertexArrayObject) #foreign "gl" "deleteVertexArray" ---
-depthFunc :: proc (func: GLenum) #foreign "gl" "depthFunc" ---
-depthMask :: proc (flag: GLboolean) #foreign "gl" "depthMask" ---
-depthRange :: proc (zNear: GLclampf, zFar: GLclampf) #foreign "gl" "depthRange" ---
-detachShader :: proc (program: GLProgram, shader: GLShader) #foreign "gl" "detachShader" ---
-disable :: proc (cap: GLenum) #foreign "gl" "disable" ---
-disableVertexAttribArray :: proc (index: GLuint) #foreign "gl" "disableVertexAttribArray" ---
-drawArrays :: proc (mode: GLenum, first: GLint, count: GLsizei) #foreign "gl" "drawArrays" ---
-drawArraysInstanced :: proc (mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) #foreign "gl" "drawArraysInstanced" ---
-drawElements :: proc (mode: GLenum, count: GLsizei, type: GLenum, offset: GLint) #foreign "gl" "drawElements" ---
-drawElementsInstanced :: proc (mode: GLenum, count: GLsizei, type: GLenum, offset: GLint, instanceCount: GLsizei) #foreign "gl" "drawElementsInstanced" ---
-enable :: proc (cap: GLenum) #foreign "gl" "enable" ---
-enableVertexAttribArray :: proc (index: GLuint) #foreign "gl" "enableVertexAttribArray" ---
-finish :: proc () #foreign "gl" "finish" ---
-flush :: proc () #foreign "gl" "flush" ---
-framebufferRenderbuffer :: proc (target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: GLRenderbuffer) #foreign "gl" "framebufferRenderbuffer" ---
-framebufferTexture2D :: proc (target: GLenum, attachment: GLenum, textarget: GLenum, texture: GLTexture, level: GLint) #foreign "gl" "framebufferTexture2D" ---
-framebufferTextureLayer :: proc (target: GLenum, attachment: GLenum, texture: GLTexture, level: GLint, layer: GLint) #foreign "gl" "framebufferTextureLayer" ---
-frontFace :: proc (mode: GLenum) #foreign "gl" "frontFace" ---
-generateMipmap :: proc (target: GLenum) #foreign "gl" "generateMipmap" ---
-getActiveAttrib :: proc (program: GLProgram, index: GLuint, out: ^GLActiveInfo) #foreign "gl" "getActiveAttrib" ---
-getActiveUniform :: proc (program: GLProgram, index: GLuint, out: ^GLActiveInfo) #foreign "gl" "getActiveUniform" ---
+activeTexture :: (texture: GLenum) -> void #foreign "gl" "activeTexture" ---
+attachShader :: (program: GLProgram, shader: GLShader) -> GLProgram #foreign "gl" "attachShader" ---
+bindAttribLocation :: (program: GLProgram, index: GLuint, name: str) -> void #foreign "gl" "bindAttribLocation" ---
+bindBuffer :: (target: GLenum, buffer: GLBuffer) -> void #foreign "gl" "bindBuffer" ---
+bindFramebuffer :: (target: GLenum, framebuffer: GLFramebuffer) -> void #foreign "gl" "bindFramebuffer" ---
+bindRenderbuffer :: (target: GLenum, renderbuffer: GLRenderbuffer) -> void #foreign "gl" "bindRenderbuffer" ---
+bindTexture :: (target: GLenum, texture: GLTexture) -> void #foreign "gl" "bindTexture" ---
+bindVertexArray :: (vertexArray: GLVertexArrayObject) -> void #foreign "gl" "bindVertexArray" ---
+blendColor :: (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) -> void #foreign "gl" "blendColor" ---
+blendEquation :: (mode: GLenum) -> void #foreign "gl" "blendEquation" ---
+blendEquationSeparate :: (modeRGB: GLenum, modeAlpha: GLenum) -> void #foreign "gl" "blendEquationSeparate" ---
+blendFunc :: (sfactor: GLenum, dfactor: GLenum) -> void #foreign "gl" "blendFunc" ---
+blendFuncSeparate :: (srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) -> void #foreign "gl" "blendFuncSeparate" ---
+blitFramebuffer :: (sx0: GLint, sy0: GLint, sx1: GLint, sy1: GLint, dx0: GLint, dy0: GLint, dx1: GLint, dy1: GLint, mask: GLbitfield, filter: GLenum) -> void #foreign "gl" "blitFramebuffer" ---
+bufferDataWithData :: (target: GLenum, buffer: [] void, usage: GLenum) -> void #foreign "gl" "bufferDataWithData" ---
+bufferDataNoData :: (target: GLenum, size: GLsizeiptr, usage: GLenum) -> void #foreign "gl" "bufferDataNoData" ---
+bufferData :: { bufferDataWithData, bufferDataNoData }
+bufferSubData :: (target: GLenum, offset: GLsizei, data: [] void) -> void #foreign "gl" "bufferSubData" ---
+canvasSize :: (width: GLsizei, height: GLsizei) -> void #foreign "gl" "canvasSize" ---
+checkFrameBufferStatus :: (target: GLenum) -> GLenum #foreign "gl" "checkFrameBufferStatus" ---
+clear :: (mask: GLbitfield) -> void #foreign "gl" "clear" ---
+clearColor :: (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) -> void #foreign "gl" "clearColor" ---
+clearDepth :: (depth: GLclampf) -> void #foreign "gl" "clearDepth" ---
+clearStencil :: (s: GLint) -> void #foreign "gl" "clearStencil" ---
+colorMask :: (red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) -> void #foreign "gl" "colorMask" ---
+compileShader :: (shader: GLShader) -> void #foreign "gl" "compileShader" ---
+compressedTexImage2D :: (target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: str) -> void #foreign "gl" "compressedTexImage2D" ---
+compressedTexSubImage2D :: (target: GLenum, level: GLint, internalformat: GLenum, xoff: GLint, yoff: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: str) -> void #foreign "gl" "compressedTexSubImage2D" ---
+copyBufferSubData :: (readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) -> void #foreign "gl" "copyBufferSubData" ---
+copyTexImage2D :: (target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) -> void #foreign "gl" "copyTexImage2D" ---
+copyTexSubImage2D :: (target: GLenum, level: GLint, xoff: GLint, yoff: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) -> void #foreign "gl" "copyTexSubImage2D" ---
+createBuffer :: () -> GLBuffer #foreign "gl" "createBuffer" ---
+createFramebuffer :: () -> GLFramebuffer #foreign "gl" "createFramebuffer" ---
+createProgram :: () -> GLProgram #foreign "gl" "createProgram" ---
+createRenderbuffer :: () -> GLRenderbuffer #foreign "gl" "createRenderbuffer" ---
+createShader :: (type: GLenum) -> GLShader #foreign "gl" "createShader" ---
+createTexture :: () -> GLTexture #foreign "gl" "createTexture" ---
+createVertexArray :: () -> GLVertexArrayObject #foreign "gl" "createVertexArray" ---
+cullFace :: (mode: GLenum) -> void #foreign "gl" "cullFace" ---
+deleteBuffer :: (buffer: GLBuffer) -> void #foreign "gl" "deleteBuffer" ---
+deleteFramebuffer :: (framebuffer: GLFramebuffer) -> void #foreign "gl" "deleteFramebuffer" ---
+deleteProgram :: (program: GLProgram) -> void #foreign "gl" "deleteProgram" ---
+deleteRenderbuffer :: (renderbuffer: GLRenderbuffer) -> void #foreign "gl" "deleteRenderbuffer" ---
+deleteShader :: (shader: GLShader) -> void #foreign "gl" "deleteShader" ---
+deleteTexture :: (texture: GLTexture) -> void #foreign "gl" "deleteTexture" ---
+deleteVertexArray :: (vertexArray: GLVertexArrayObject) -> void #foreign "gl" "deleteVertexArray" ---
+depthFunc :: (func: GLenum) -> void #foreign "gl" "depthFunc" ---
+depthMask :: (flag: GLboolean) -> void #foreign "gl" "depthMask" ---
+depthRange :: (zNear: GLclampf, zFar: GLclampf) -> void #foreign "gl" "depthRange" ---
+detachShader :: (program: GLProgram, shader: GLShader) -> void #foreign "gl" "detachShader" ---
+disable :: (cap: GLenum) -> void #foreign "gl" "disable" ---
+disableVertexAttribArray :: (index: GLuint) -> void #foreign "gl" "disableVertexAttribArray" ---
+drawArrays :: (mode: GLenum, first: GLint, count: GLsizei) -> void #foreign "gl" "drawArrays" ---
+drawArraysInstanced :: (mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) -> void #foreign "gl" "drawArraysInstanced" ---
+drawElements :: (mode: GLenum, count: GLsizei, type: GLenum, offset: GLint) -> void #foreign "gl" "drawElements" ---
+drawElementsInstanced :: (mode: GLenum, count: GLsizei, type: GLenum, offset: GLint, instanceCount: GLsizei) -> void #foreign "gl" "drawElementsInstanced" ---
+enable :: (cap: GLenum) -> void #foreign "gl" "enable" ---
+enableVertexAttribArray :: (index: GLuint) -> void #foreign "gl" "enableVertexAttribArray" ---
+finish :: () -> void #foreign "gl" "finish" ---
+flush :: () -> void #foreign "gl" "flush" ---
+framebufferRenderbuffer :: (target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: GLRenderbuffer) -> void #foreign "gl" "framebufferRenderbuffer" ---
+framebufferTexture2D :: (target: GLenum, attachment: GLenum, textarget: GLenum, texture: GLTexture, level: GLint) -> void #foreign "gl" "framebufferTexture2D" ---
+framebufferTextureLayer :: (target: GLenum, attachment: GLenum, texture: GLTexture, level: GLint, layer: GLint) -> void #foreign "gl" "framebufferTextureLayer" ---
+frontFace :: (mode: GLenum) -> void #foreign "gl" "frontFace" ---
+generateMipmap :: (target: GLenum) -> void #foreign "gl" "generateMipmap" ---
+getActiveAttrib :: (program: GLProgram, index: GLuint, out: ^GLActiveInfo) -> void #foreign "gl" "getActiveAttrib" ---
+getActiveUniform :: (program: GLProgram, index: GLuint, out: ^GLActiveInfo) -> void #foreign "gl" "getActiveUniform" ---
// getAttachedShaders does not work yet because we can't return a list of things
-getAttribLocation :: proc (program: GLProgram, name: str) -> GLint #foreign "gl" "getAttribLocation" ---
-getBufferSubData :: proc (target: GLenum, srcByteOffset: GLintptr, dstBuffer: str, dstOffset: GLuint, length: GLuint) #foreign "gl" "getBufferSubData" ---
+getAttribLocation :: (program: GLProgram, name: str) -> GLint #foreign "gl" "getAttribLocation" ---
+getBufferSubData :: (target: GLenum, srcByteOffset: GLintptr, dstBuffer: str, dstOffset: GLuint, length: GLuint) -> void #foreign "gl" "getBufferSubData" ---
// getBufferParameter and getParameter do not work
-getError :: proc () -> GLenum #foreign "gl" "getError" ---
-getInternalformatParameter :: proc (target: GLenum, internalFormat: GLenum, pname: GLenum) -> GLenum #foreign "gl" "getInternalformatParameter" ---
+getError :: () -> GLenum #foreign "gl" "getError" ---
+getInternalformatParameter :: (target: GLenum, internalFormat: GLenum, pname: GLenum) -> GLenum #foreign "gl" "getInternalformatParameter" ---
// many of the 'gets' don't work yet because they return very javascripty things
-getProgramParameter :: proc (program: GLProgram, pname: GLenum) -> GLenum #foreign "gl" "getProgramParameter" ---
-getShaderParameter :: proc (shader: GLShader, pname: GLenum) -> GLenum #foreign "gl" "getShaderParameter" ---
-getUniformLocation :: proc (program: GLProgram, name: str) -> GLUniformLocation #foreign "gl" "getUniformLocation" ---
-getVertexAttribOffset :: proc (index: GLuint, pname: GLenum) #foreign "gl" "getVertexAttribOffset" ---
-hint :: proc (target: GLenum, mode: GLenum) #foreign "gl" "hint" ---
-init :: proc (canvasname: str) -> GLboolean #foreign "gl" "init" ---
-invalidateFramebuffer :: proc (target: GLenum, attachments: str) #foreign "gl" "invalidateFramebuffer" ---
-invalidateSubFramebuffer :: proc (target: GLenum, attachments: str, x: GLint, y: GLint, width: GLsizei, height: GLsizei) #foreign "gl" "invalidateSubFramebuffer" ---
-isEnabled :: proc (cap: GLenum) -> GLboolean #foreign "gl" "isEnabled" ---
-lineWidth :: proc (width: GLfloat) #foreign "gl" "lineWidth" ---
-linkProgram :: proc (program: GLProgram) #foreign "gl" "linkProgram" ---
-pixelStorei :: proc (pname: GLenum, param: GLenum) #foreign "gl" "pixelStorei" ---
-polygonOffset :: proc (factor: GLfloat, units: GLfloat) #foreign "gl" "polygonOffset" ---
-printProgramInfoLog :: proc (program: GLProgram) #foreign "gl" "printProgramInfoLog" ---
-printShaderInfoLog :: proc (shader: GLShader) #foreign "gl" "printShaderInfoLog" ---
-readBuffer :: proc (src: GLenum) #foreign "gl" "readBuffer" ---
-readPixels :: proc (x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: str) #foreign "gl" "readPixels" ---
-renderbufferStorageMultisample :: proc (target: GLenum, samples: GLsizei, internalforamt: GLenum, width: GLsizei, height: GLsizei) #foreign "gl" "renderbufferStorageMultisample" ---
-sampleCoverage :: proc (value: GLclampf, invert: GLboolean) #foreign "gl" "sampleCoverage" ---
-scissor :: proc (x: GLint, y: GLint, width: GLsizei, height: GLsizei) #foreign "gl" "scissor" ---
-shaderSource :: proc (shader: GLShader, source: str) #foreign "gl" "shaderSource" ---
-stencilFunc :: proc (func: GLenum, ref: GLint, mask: GLuint) #foreign "gl" "stencilFunc" ---
-stencilFuncSeparate :: proc (face: GLenum, func: GLenum, ref: GLint, mask: GLuint) #foreign "gl" "stencilFuncSeparate" ---
-stencilMask :: proc (mask: GLuint) #foreign "gl" "stencilMask" ---
-stencilMaskSeparate :: proc (face: GLenum, mask: GLenum) #foreign "gl" "stencilMaskSeparate" ---
-stencilOp :: proc (fail: GLenum, zfail: GLenum, zpass: GLenum) #foreign "gl" "stencilOp" ---
-stencilOpSeparate :: proc (face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) #foreign "gl" "stencilOpSeparate" ---
-texImage2D :: proc (target: GLenum, level: GLint, internalFormat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: str) #foreign "gl" "texImage2D" ---
-texParameterf :: proc (target: GLenum, pname: GLenum, param: GLfloat) #foreign "gl" "texParameterf" ---
-texParameteri :: proc (target: GLenum, pname: GLenum, param: GLint) #foreign "gl" "texParameteri" ---
-texSubImage2D :: proc (target: GLenum, level: GLint, xoff: GLint, yoff: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: str) #foreign "gl" "texSubImage2D" ---
-uniform1f :: proc (loc: GLUniformLocation, x: GLfloat) #foreign "gl" "uniform1f" ---
-uniform1i :: proc (loc: GLUniformLocation, x: GLint) #foreign "gl" "uniform1i" ---
-uniform2f :: proc (loc: GLUniformLocation, x: GLfloat, y: GLfloat) #foreign "gl" "uniform2f" ---
-uniform2i :: proc (loc: GLUniformLocation, x: GLint, y: GLint) #foreign "gl" "uniform2i" ---
-uniform3f :: proc (loc: GLUniformLocation, x: GLfloat, y: GLfloat, z: GLfloat) #foreign "gl" "uniform3f" ---
-uniform3i :: proc (loc: GLUniformLocation, x: GLint, y: GLint, z: GLint) #foreign "gl" "uniform3i" ---
-uniform4f :: proc (loc: GLUniformLocation, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) #foreign "gl" "uniform4f" ---
-uniform4i :: proc (loc: GLUniformLocation, x: GLint, y: GLint, z: GLint, w: GLint) #foreign "gl" "uniform4i" ---
-uniformMatrix2 :: proc (loc: GLUniformLocation, transpose: GLboolean, value: GLMat2) #foreign "gl" "uniformMatrix2" ---
-uniformMatrix3 :: proc (loc: GLUniformLocation, transpose: GLboolean, value: GLMat3) #foreign "gl" "uniformMatrix3" ---
-uniformMatrix4 :: proc (loc: GLUniformLocation, transpose: GLboolean, value: GLMat4) #foreign "gl" "uniformMatrix4" ---
-useProgram :: proc (program: GLProgram) #foreign "gl" "useProgram" ---
-validateProgram :: proc (program: GLProgram) #foreign "gl" "validateProgram" ---
-vertexAttrib1f :: proc (idx: GLuint, x: GLfloat) #foreign "gl" "vertexAttrib1f" ---
-vertexAttrib2f :: proc (idx: GLuint, x: GLfloat, y: GLfloat) #foreign "gl" "vertexAttrib2f" ---
-vertexAttrib3f :: proc (idx: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) #foreign "gl" "vertexAttrib3f" ---
-vertexAttrib4f :: proc (idx: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) #foreign "gl" "vertexAttrib4f" ---
-vertexAttribPointer :: proc (idx: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLint) #foreign "gl" "vertexAttribPointer" ---
-vertexAttribDivisor :: proc (idx: GLuint, divisor: GLuint) #foreign "gl" "vertexAttribDivisor" ---
-viewport :: proc (x: GLint, y: GLint, width: GLsizei, height: GLsizei) #foreign "gl" "viewport" ---
+getProgramParameter :: (program: GLProgram, pname: GLenum) -> GLenum #foreign "gl" "getProgramParameter" ---
+getShaderParameter :: (shader: GLShader, pname: GLenum) -> GLenum #foreign "gl" "getShaderParameter" ---
+getUniformLocation :: (program: GLProgram, name: str) -> GLUniformLocation #foreign "gl" "getUniformLocation" ---
+getVertexAttribOffset :: (index: GLuint, pname: GLenum) -> void #foreign "gl" "getVertexAttribOffset" ---
+hint :: (target: GLenum, mode: GLenum) -> void #foreign "gl" "hint" ---
+init :: (canvasname: str) -> GLboolean #foreign "gl" "init" ---
+invalidateFramebuffer :: (target: GLenum, attachments: str) -> void #foreign "gl" "invalidateFramebuffer" ---
+invalidateSubFramebuffer :: (target: GLenum, attachments: str, x: GLint, y: GLint, width: GLsizei, height: GLsizei) -> void #foreign "gl" "invalidateSubFramebuffer" ---
+isEnabled :: (cap: GLenum) -> GLboolean #foreign "gl" "isEnabled" ---
+lineWidth :: (width: GLfloat) -> void #foreign "gl" "lineWidth" ---
+linkProgram :: (program: GLProgram) -> void #foreign "gl" "linkProgram" ---
+pixelStorei :: (pname: GLenum, param: GLenum) -> void #foreign "gl" "pixelStorei" ---
+polygonOffset :: (factor: GLfloat, units: GLfloat) -> void #foreign "gl" "polygonOffset" ---
+printProgramInfoLog :: (program: GLProgram) -> void #foreign "gl" "printProgramInfoLog" ---
+printShaderInfoLog :: (shader: GLShader) -> void #foreign "gl" "printShaderInfoLog" ---
+readBuffer :: (src: GLenum) -> void #foreign "gl" "readBuffer" ---
+readPixels :: (x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: str) -> void #foreign "gl" "readPixels" ---
+renderbufferStorageMultisample :: (target: GLenum, samples: GLsizei, internalforamt: GLenum, width: GLsizei, height: GLsizei) -> void #foreign "gl" "renderbufferStorageMultisample" ---
+sampleCoverage :: (value: GLclampf, invert: GLboolean) -> void #foreign "gl" "sampleCoverage" ---
+scissor :: (x: GLint, y: GLint, width: GLsizei, height: GLsizei) -> void #foreign "gl" "scissor" ---
+shaderSource :: (shader: GLShader, source: str) -> void #foreign "gl" "shaderSource" ---
+stencilFunc :: (func: GLenum, ref: GLint, mask: GLuint) -> void #foreign "gl" "stencilFunc" ---
+stencilFuncSeparate :: (face: GLenum, func: GLenum, ref: GLint, mask: GLuint) -> void #foreign "gl" "stencilFuncSeparate" ---
+stencilMask :: (mask: GLuint) -> void #foreign "gl" "stencilMask" ---
+stencilMaskSeparate :: (face: GLenum, mask: GLenum) -> void #foreign "gl" "stencilMaskSeparate" ---
+stencilOp :: (fail: GLenum, zfail: GLenum, zpass: GLenum) -> void #foreign "gl" "stencilOp" ---
+stencilOpSeparate :: (face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) -> void #foreign "gl" "stencilOpSeparate" ---
+texImage2D :: (target: GLenum, level: GLint, internalFormat: GLenum, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: str) -> void #foreign "gl" "texImage2D" ---
+texParameterf :: (target: GLenum, pname: GLenum, param: GLfloat) -> void #foreign "gl" "texParameterf" ---
+texParameteri :: (target: GLenum, pname: GLenum, param: GLint) -> void #foreign "gl" "texParameteri" ---
+texSubImage2D :: (target: GLenum, level: GLint, xoff: GLint, yoff: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: str) -> void #foreign "gl" "texSubImage2D" ---
+uniform1f :: (loc: GLUniformLocation, x: GLfloat) -> void #foreign "gl" "uniform1f" ---
+uniform1i :: (loc: GLUniformLocation, x: GLint) -> void #foreign "gl" "uniform1i" ---
+uniform2f :: (loc: GLUniformLocation, x: GLfloat, y: GLfloat) -> void #foreign "gl" "uniform2f" ---
+uniform2i :: (loc: GLUniformLocation, x: GLint, y: GLint) -> void #foreign "gl" "uniform2i" ---
+uniform3f :: (loc: GLUniformLocation, x: GLfloat, y: GLfloat, z: GLfloat) -> void #foreign "gl" "uniform3f" ---
+uniform3i :: (loc: GLUniformLocation, x: GLint, y: GLint, z: GLint) -> void #foreign "gl" "uniform3i" ---
+uniform4f :: (loc: GLUniformLocation, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) -> void #foreign "gl" "uniform4f" ---
+uniform4i :: (loc: GLUniformLocation, x: GLint, y: GLint, z: GLint, w: GLint) -> void #foreign "gl" "uniform4i" ---
+uniformMatrix2 :: (loc: GLUniformLocation, transpose: GLboolean, value: GLMat2) -> void #foreign "gl" "uniformMatrix2" ---
+uniformMatrix3 :: (loc: GLUniformLocation, transpose: GLboolean, value: GLMat3) -> void #foreign "gl" "uniformMatrix3" ---
+uniformMatrix4 :: (loc: GLUniformLocation, transpose: GLboolean, value: GLMat4) -> void #foreign "gl" "uniformMatrix4" ---
+useProgram :: (program: GLProgram) -> void #foreign "gl" "useProgram" ---
+validateProgram :: (program: GLProgram) -> void #foreign "gl" "validateProgram" ---
+vertexAttrib1f :: (idx: GLuint, x: GLfloat) -> void #foreign "gl" "vertexAttrib1f" ---
+vertexAttrib2f :: (idx: GLuint, x: GLfloat, y: GLfloat) -> void #foreign "gl" "vertexAttrib2f" ---
+vertexAttrib3f :: (idx: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) -> void #foreign "gl" "vertexAttrib3f" ---
+vertexAttrib4f :: (idx: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) -> void #foreign "gl" "vertexAttrib4f" ---
+vertexAttribPointer :: (idx: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLint) -> void #foreign "gl" "vertexAttribPointer" ---
+vertexAttribDivisor :: (idx: GLuint, divisor: GLuint) -> void #foreign "gl" "vertexAttribDivisor" ---
+viewport :: (x: GLint, y: GLint, width: GLsizei, height: GLsizei) -> void #foreign "gl" "viewport" ---
value : V;
}
-make :: proc ($Key: type_expr, $Value: type_expr, default: Value = 0, hash_count: i32 = 16) -> Map(Key, Value) {
+make :: ($Key: type_expr, $Value: type_expr, default: Value = 0, hash_count: i32 = 16) -> Map(Key, Value) {
map : Map(Key, Value);
init(^map, default = default, hash_count = hash_count);
return map;
}
-init :: proc (use map: ^Map($K, $V), default: V = ~~0, hash_count: i32 = 16) {
+init :: (use map: ^Map($K, $V), default: V = ~~0, hash_count: i32 = 16) {
array.init(^hashes, hash_count);
array.init(^entries, 4);
for i: 0 .. hash_count do array.push(^hashes, -1);
}
-free :: proc (use map: ^Map($K, $V)) {
+free :: (use map: ^Map($K, $V)) {
array.free(^hashes);
array.free(^entries);
}
-put :: proc (use map: ^Map($K, $V), key: K, value: V) {
+put :: (use map: ^Map($K, $V), key: K, value: V) {
lr := lookup(map, key);
if lr.entry_index >= 0 {
hashes[lr.hash_index] = entries.count - 1;
}
-has :: proc (use map: ^Map($K, $V), key: K) -> bool {
+has :: (use map: ^Map($K, $V), key: K) -> bool {
lr := lookup(map, key);
return lr.entry_index >= 0;
}
-get :: proc (use map: ^Map($K, $V), key: K) -> V {
+get :: (use map: ^Map($K, $V), key: K) -> V {
lr := lookup(map, key);
if lr.entry_index >= 0 do return entries[lr.entry_index].value;
return default_value;
}
-delete :: proc (use map: ^Map($K, $V), key: K) {
+delete :: (use map: ^Map($K, $V), key: K) {
lr := lookup(map, key);
if lr.entry_index < 0 do return;
else do hashes[last.hash_index] = lr.entry_index;
}
-update :: proc (use map: ^Map($K, $V), key: K, f: proc (^V)) {
+update :: (use map: ^Map($K, $V), key: K, f: (^V) -> void) {
lr := lookup(map, key);
if lr.entry_index < 0 do return;
f(^entries[lr.entry_index].value);
}
-clear :: proc (use map: ^Map($K, $V)) {
+clear :: (use map: ^Map($K, $V)) {
for i: 0 .. hashes.count do hashes.data[i] = -1;
entries.count = 0;
}
-empty :: proc (use map: ^Map($K, $V)) -> bool {
+empty :: (use map: ^Map($K, $V)) -> bool {
return entries.count == 0;
}
hash_function :: proc {
- proc (key: rawptr) -> u32 { return 0xcbf29ce7 ^ cast(u32) key; },
- proc (key: i32) -> u32 { return 0xcbf29ce7 ^ cast(u32) key; },
- proc (key: i64) -> u32 { return cast(u32) (cast(u64) 0xcbf29ce7 ^ cast(u64) key); },
+ (key: rawptr) -> u32 { return 0xcbf29ce7 ^ cast(u32) key; },
+ (key: i32) -> u32 { return 0xcbf29ce7 ^ cast(u32) key; },
+ (key: i64) -> u32 { return cast(u32) (cast(u64) 0xcbf29ce7 ^ cast(u64) key); },
- proc (key: str) -> u32 {
+ (key: str) -> u32 {
hash: u32 = 5381;
for ch: key do hash += (hash << 5) + ~~ch;
return hash;
},
}
+// CLEANUP: This could be replaced with operator overloading of '=='
cmp_function :: proc {
- proc (a: rawptr, b: rawptr) -> bool { return a == b; },
- proc (a: i32, b: i32) -> bool { return a == b; },
- proc (a: i64, b: i64) -> bool { return a == b; },
+ (a: rawptr, b: rawptr) -> bool { return a == b; },
+ (a: i32, b: i32) -> bool { return a == b; },
+ (a: i64, b: i64) -> bool { return a == b; },
string.equal,
}
}
#private_file
-lookup :: proc (use map: ^Map($K, $V), key: K) -> MapLookupResult {
+lookup :: (use map: ^Map($K, $V), key: K) -> MapLookupResult {
lr := MapLookupResult.{};
hash: u32 = hash_function(key); // You cannot use this type for the key, unless you add an overload.
TAU :: 6.28318330f;
// Simple taylor series approximation of sin(t)
-sin :: proc (t_: f32) -> f32 {
+sin :: (t_: f32) -> f32 {
t := t_;
while t >= PI do t -= TAU;
while t <= -PI do t += TAU;
}
// Simple taylor series approximation of cos(t)
-cos :: proc (t_: f32) -> f32 {
+cos :: (t_: f32) -> f32 {
t := t_;
while t >= PI do t -= TAU;
while t <= -PI do t += TAU;
return res;
}
-max :: proc (a: $T, b: T) -> T {
+max :: (a: $T, b: T) -> T {
if a >= b do return a;
return b;
}
-min :: proc (a: $T, b: T) -> T {
+min :: (a: $T, b: T) -> T {
if a <= b do return a;
return b;
}
-sqrt_i32 :: proc (x: i32) -> i32 do return ~~sqrt_f32(~~x);
-sqrt_i64 :: proc (x: i64) -> i64 do return ~~sqrt_f64(~~x);
+sqrt_i32 :: (x: i32) -> i32 do return ~~sqrt_f32(~~x);
+sqrt_i64 :: (x: i64) -> i64 do return ~~sqrt_f64(~~x);
sqrt :: proc { sqrt_f32, sqrt_f64, sqrt_i32, sqrt_i64 }
copysign :: proc { copysign_f32, copysign_f64 }
-abs_i32 :: proc (x: i32) -> i32 {
+abs_i32 :: (x: i32) -> i32 {
if x >= 0 do return x;
return -x;
}
-abs_i64 :: proc (x: i64) -> i64 {
+abs_i64 :: (x: i64) -> i64 {
if x >= 0 do return x;
return -x;
}
abs :: proc { abs_i32, abs_i64, abs_f32, abs_f64 }
-pow_int :: proc (base: $T, p: i32) -> T {
+pow_int :: (base: $T, p: i32) -> T {
if base == 0 do return 0;
if p == 0 do return 1;
return a;
}
-pow_float :: proc (base: $T, p: T) -> T {
+pow_float :: (base: $T, p: T) -> T {
if p == 0 do return 1;
if p < 0 do return 1 / pow_float(base, -p);
}
pow :: proc { pow_int, pow_float }
-exp :: proc (p: $T) -> T do return pow(base = cast(T) E, p = p);
+exp :: (p: $T) -> T do return pow(base = cast(T) E, p = p);
-ln :: proc (a: f32) -> f32 {
+ln :: (a: f32) -> f32 {
}
-log :: proc (a: $T, b: $R) ->T {
+log :: (a: $T, b: $R) ->T {
}
package core.memory
-copy :: proc (dst_: rawptr, src_: rawptr, len: u32) {
+copy :: (dst_: rawptr, src_: rawptr, len: u32) {
dst := cast(^u8) dst_;
src := cast(^u8) src_;
for i: 0 .. len do dst[i] = src[i];
}
-set :: proc (start: rawptr, length: u32, value: u8) {
+set :: (start: rawptr, length: u32, value: u8) {
s := cast(^u8) start;
for i: 0 .. length do s[i] = value;
}
-alloc_slice :: proc (sl: ^[] $T, count: i32, allocator := context.allocator) {
+alloc_slice :: (sl: ^[] $T, count: i32, allocator := context.allocator) {
sl.data = raw_alloc(allocator, sizeof T * count);
sl.count = count;
}
-make_slice :: proc ($T: type_expr, count: i32, allocator := context.allocator) -> [] T {
+make_slice :: ($T: type_expr, count: i32, allocator := context.allocator) -> [] T {
return <[] T>.{
data = raw_alloc(allocator, sizeof T * count),
count = count
#private_file RANDOM_INCREMENT :: 1013904223
// #private_file RANDOM_MODULUS :: 1 << 32
-set_seed :: proc (s: u32) do seed = s;
+set_seed :: (s: u32) do seed = s;
-int :: proc (s := ^seed) -> u32 {
+int :: (s := ^seed) -> u32 {
*s = *s * RANDOM_MULTIPLIER + RANDOM_INCREMENT;
return *s;
}
-between :: proc (lo: i32, hi: i32) -> i32 do return int () % (hi + 1 - lo) + lo;
+between :: (lo: i32, hi: i32) -> i32 do return int () % (hi + 1 - lo) + lo;
-float :: proc (lo := 0.0f, hi := 1.0f) -> f32 {
+float :: (lo := 0.0f, hi := 1.0f) -> f32 {
return (cast(f32) (int() % (1 << 20)) / cast(f32) (1 << 20)) * (hi - lo) + lo;
}
#private_file print_stream : io.DynamicStringStream;
#private_file print_writer : io.Writer;
-stdio_init :: proc () {
+stdio_init :: () {
print_stream = io.dynamic_string_stream_make(2048, context.allocator);
print_writer = io.writer_make(^print_stream);
}
print :: proc {
- proc (x: str) {
+ (x: str) {
io.write(^print_writer, x);
if x[x.count - 1] == #char "\n" do print_stream_flush();
},
- proc (x: $T) { io.write(^print_writer, x); },
- proc (x: $T, y: $R) { io.write(^print_writer, x, y); },
+ (x: $T) { io.write(^print_writer, x); },
+ (x: $T, y: $R) { io.write(^print_writer, x, y); },
}
-println :: proc (x: $T) {
+println :: (x: $T) {
print(x);
print("\n");
}
-printf :: proc (format: str, va: ...) {
+printf :: (format: str, va: ...) {
buffer: [2048] u8;
print(conv.str_format_va(format, buffer[0 .. 2048], va));
}
// This works on both slices and arrays
print_array :: proc {
- proc (arr: [$N] $T, sep := " ") {
+ (arr: [$N] $T, sep := " ") {
for i: 0 .. N {
print(arr[i]);
if i != N - 1 do print(sep);
print("\n");
},
- proc (arr: $T, sep := " ") {
+ (arr: $T, sep := " ") {
for i: 0 .. arr.count {
print(arr.data[i]);
if i != arr.count - 1 do print(sep);
}
}
-print_stream_flush :: proc () {
+print_stream_flush :: () {
if print_stream.data.count == 0 do return;
^print_stream
package core.string
-make :: proc (s: cstr) -> str {
+make :: (s: cstr) -> str {
len := length(s);
return str.{ count = len, data = s };
}
length :: proc {
- proc (s: cstr) -> u32 {
+ (s: cstr) -> u32 {
len := 0;
c := s;
while *c != #char "\0" {
return len;
},
- proc (s: str) -> u32 {
+ (s: str) -> u32 {
return s.count;
},
}
-alloc_copy :: proc (orig: str) -> str {
+alloc_copy :: (orig: str) -> str {
new_str : str;
new_str.data = calloc(sizeof u8 * orig.count);
new_str.count = orig.count;
return new_str;
}
-copy :: proc (orig: str, dest: str) {
+copy :: (orig: str, dest: str) {
len := orig.count;
if dest.count < len do len = dest.count;
for i: 0 .. len do dest.data[i] = orig.data[i];
}
-concat :: proc (s1: str, s2: str) -> str {
+concat :: (s1: str, s2: str) -> str {
len1 := length(s1);
len2 := length(s2);
return str.{ data, len1 + len2 };
}
-free :: proc (s: str) do cfree(s.data);
+free :: (s: str) do cfree(s.data);
// This is an example doc str
// You can have as many comments as you want
// It documents the split function
-split :: proc (s: str, delim: u8) -> []str {
+split :: (s: str, delim: u8) -> []str {
delim_count := 0;
for i: 0 .. s.count do if s[i] == delim do delim_count += 1;
// return str.data[0 .. 0];
// }
-contains :: proc (s: str, c: u8) -> bool {
+contains :: (s: str, c: u8) -> bool {
for ch: s do if ch == c do return true;
return false;
}
-// TODO: Check this proc for edge cases and other bugs. I'm not confident
+// TODO: Check this for edge cases and other bugs. I'm not confident
// it will work perfectly yet. - brendanfh 2020/12/21
-compare :: proc (str1: str, str2: str) -> i32 {
+compare :: (str1: str, str2: str) -> i32 {
i := 0;
while i < str1.count && i < str2.count && str1[i] == str2[i] do i += 1;
return ~~(str1[i] - str2[i]);
}
-equal :: proc (str1: str, str2: str) -> bool #operator== {
+equal :: (str1: str, str2: str) -> bool #operator== {
if str1.count != str2.count do return false;
while i := 0; i < str1.count {
if str1[i] != str2[i] do return false;
return true;
}
-starts_with :: proc (str1: str, str2: str) -> bool {
+starts_with :: (str1: str, str2: str) -> bool {
if str1.count < str2.count do return false;
while i := 0; i < str2.count {
if str1[i] != str2[i] do return false;
return true;
}
-strip_leading_whitespace :: proc (s: ^str) {
+strip_leading_whitespace :: (s: ^str) {
while true do switch s.data[0] {
case #char " ", #char "\t", #char "\n", #char "\r" {
s.data += 1;
}
}
-strip_trailing_whitespace :: proc (s: ^str) {
+strip_trailing_whitespace :: (s: ^str) {
while true do switch s.data[s.count - 1] {
case #char " ", #char "\t", #char "\n", #char "\r" {
s.count -= 1;
}
-read_u32 :: proc (s: ^str, out: ^u32) {
+read_u32 :: (s: ^str, out: ^u32) {
n := 0;
strip_leading_whitespace(s);
*out = n;
}
-read_char :: proc (s: ^str, out: ^u8) {
+read_char :: (s: ^str, out: ^u8) {
*out = s.data[0];
s.data += 1;
s.count -= 1;
}
-read_chars :: proc (s: ^str, out: ^str, char_count := 1) {
+read_chars :: (s: ^str, out: ^str, char_count := 1) {
out.data = s.data;
out.count = char_count;
s.data += char_count;
s.count -= char_count;
}
-discard_chars :: proc (s: ^str, char_count := 1) {
+discard_chars :: (s: ^str, char_count := 1) {
s.data += char_count;
s.count -= char_count;
}
// Goes up to but not including the closest newline or EOF
-read_line :: proc (s: ^str, out: ^str) {
+read_line :: (s: ^str, out: ^str) {
out.data = s.data;
out.count = 0;
}
}
-read_until :: proc (s: ^str, upto: u8, skip := 0) -> str {
+read_until :: (s: ^str, upto: u8, skip := 0) -> str {
if s.count == 0 do return "";
out : str;
return out;
}
-read_until_either :: proc (s: ^str, skip: u32, uptos: ..u8) -> str {
+read_until_either :: (s: ^str, skip: u32, uptos: ..u8) -> str {
if s.count == 0 do return "";
out : str;
return out;
}
-advance_line :: proc (s: ^str) {
+advance_line :: (s: ^str) {
if s.count == 0 do return;
adv := 0;
use package core
use package main as main
-output_str :: proc (s: str) -> u32 #foreign "host" "print_str" ---
+output_str :: (s: str) -> u32 #foreign "host" "print_str" ---
-assert_handler :: proc (msg: str, file: str) {
+assert_handler :: (msg: str, file: str) {
output_str("Assert failed: ");
output_str(msg);
STDOUT_FILENO :: 1
-output_str :: proc (s: str) -> u32 {
+output_str :: (s: str) -> u32 {
vec := IOVec.{ buf = cast(u32) s.data, len = s.count };
tmp : Size;
fd_write(STDOUT_FILENO, IOVecArray.{ cast(u32) ^vec, 1 }, ^tmp);
return tmp;
}
-assert_handler :: proc (msg: str, file: str) {
+assert_handler :: (msg: str, file: str) {
output_str("Assert failed: ");
output_str(msg);
// FUNCTIONS
-args_get :: proc (argv: ^^u8, argv_buf: ^u8) -> Errno #foreign "wasi_unstable" "args_get"---
-args_sizes_get :: proc (argc: ^Size, argv_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "args_sizes_get" ---
-
-environ_get :: proc (environ: ^^u8, environ_buf: ^u8) -> Errno #foreign "wasi_unstable" "environ_get" ---
-environ_sizes_get :: proc (environc: ^Size, environ_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "environ_sizes_get" ---
-
-clock_res_get :: proc (id: ClockID, resolution: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_res_get" ---
-clock_time_get :: proc (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_time_get" ---
-
-fd_advise :: proc (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno #foreign "wasi_unstable" "fd_advise" ---
-fd_allocate :: proc (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno #foreign "wasi_unstable" "fd_allocate" ---
-fd_close :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_close" ---
-fd_datasync :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_datasync" ---
-fd_fdstat_get :: proc (fd: FileDescriptor, stat: ^FDStat) -> Errno #foreign "wasi_unstable" "fd_fdstat_get" ---
-fd_fdstat_set_flags :: proc (fd: FileDescriptor, flags: FDFlags) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_flags" ---
-fd_fdstat_set_rights :: proc (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_rights" ---
-fd_filestat_get :: proc (fd: FileDescriptor, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "fd_filestat_get" ---
-fd_filestat_set_size :: proc (fd: FileDescriptor, size: Filesize) -> Errno #foreign "wasi_unstable" "fd_filestat_set_size" ---
-fd_filestat_set_times :: proc (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "fd_filestat_set_times" ---
-fd_pread :: proc (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_pread" ---
-fd_prestat_get :: proc (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno #foreign "wasi_unstable" "fd_prestat_get" ---
-fd_prestat_dir_name :: proc (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "fd_prestat_dir_name" ---
-fd_pwrite :: proc (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_pwrite" ---
-fd_read :: proc (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_read" ---
-fd_readdir :: proc (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno #foreign "wasi_unstable" "fd_readdir" ---
-fd_renumber :: proc (fd: FileDescriptor, to: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_renumber" ---
-fd_seek :: proc (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_seek" ---
-fd_sync :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_sync" ---
-fd_tell :: proc (fd: FileDescriptor, offset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_tell" ---
-fd_write :: proc (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_write" ---
-
-path_create_directory :: proc (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_create_directory" ---
-path_filestat_get :: proc (fd: FileDescriptor, flags: LookupFlags, path: str, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "path_filestat_get" ---
-path_filestat_set_times :: proc (fd: FileDescriptor, flags: LookupFlags, path: str, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "path_filestat_set_times" ---
-
-path_link :: proc (fd: FileDescriptor, old_flags: LookupFlags, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_link" ---
-path_open :: proc
- ( fd: FileDescriptor
+args_get :: (argv: ^^u8, argv_buf: ^u8) -> Errno #foreign "wasi_unstable" "args_get"---
+args_sizes_get :: (argc: ^Size, argv_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "args_sizes_get" ---
+
+environ_get :: (environ: ^^u8, environ_buf: ^u8) -> Errno #foreign "wasi_unstable" "environ_get" ---
+environ_sizes_get :: (environc: ^Size, environ_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "environ_sizes_get" ---
+
+clock_res_get :: (id: ClockID, resolution: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_res_get" ---
+clock_time_get :: (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_time_get" ---
+
+fd_advise :: (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno #foreign "wasi_unstable" "fd_advise" ---
+fd_allocate :: (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno #foreign "wasi_unstable" "fd_allocate" ---
+fd_close :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_close" ---
+fd_datasync :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_datasync" ---
+fd_fdstat_get :: (fd: FileDescriptor, stat: ^FDStat) -> Errno #foreign "wasi_unstable" "fd_fdstat_get" ---
+fd_fdstat_set_flags :: (fd: FileDescriptor, flags: FDFlags) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_flags" ---
+fd_fdstat_set_rights :: (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_rights" ---
+fd_filestat_get :: (fd: FileDescriptor, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "fd_filestat_get" ---
+fd_filestat_set_size :: (fd: FileDescriptor, size: Filesize) -> Errno #foreign "wasi_unstable" "fd_filestat_set_size" ---
+fd_filestat_set_times :: (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "fd_filestat_set_times" ---
+fd_pread :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_pread" ---
+fd_prestat_get :: (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno #foreign "wasi_unstable" "fd_prestat_get" ---
+fd_prestat_dir_name :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "fd_prestat_dir_name" ---
+fd_pwrite :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_pwrite" ---
+fd_read :: (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_read" ---
+fd_readdir :: (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno #foreign "wasi_unstable" "fd_readdir" ---
+fd_renumber :: (fd: FileDescriptor, to: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_renumber" ---
+fd_seek :: (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_seek" ---
+fd_sync :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_sync" ---
+fd_tell :: (fd: FileDescriptor, offset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_tell" ---
+fd_write :: (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_write" ---
+
+path_create_directory :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_create_directory" ---
+path_filestat_get :: (fd: FileDescriptor, flags: LookupFlags, path: str, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "path_filestat_get" ---
+path_filestat_set_times :: (fd: FileDescriptor, flags: LookupFlags, path: str, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "path_filestat_set_times" ---
+
+path_link :: (fd: FileDescriptor, old_flags: LookupFlags, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_link" ---
+path_open :: (fd: FileDescriptor
, dirflags: LookupFlags
, path: str
, oflags: OFlags
) -> Errno
#foreign "wasi_unstable" "path_open" ---
-path_readlink :: proc (fd: FileDescriptor, path: str, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno #foreign "wasi_unstable" "path_readlink" ---
-path_remove_directory :: proc (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_remove_directory" ---
-path_rename :: proc (fd: FileDescriptor, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_rename" ---
-path_symlink :: proc (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_symlink" ---
-path_unlink_file :: proc (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_unlink_file" ---
+path_readlink :: (fd: FileDescriptor, path: str, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno #foreign "wasi_unstable" "path_readlink" ---
+path_remove_directory :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_remove_directory" ---
+path_rename :: (fd: FileDescriptor, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_rename" ---
+path_symlink :: (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_symlink" ---
+path_unlink_file :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_unlink_file" ---
-poll_oneoff :: proc (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno #foreign "wasi_unstable" "poll_oneoff" ---
+poll_oneoff :: (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno #foreign "wasi_unstable" "poll_oneoff" ---
-proc_exit :: proc (rval: ExitCode) #foreign "wasi_unstable" "proc_exit" ---
-proc_raise :: proc (sig: Signal) -> Errno #foreign "wasi_unstable" "proc_raise" ---
+proc_exit :: (rval: ExitCode) -> void #foreign "wasi_unstable" "proc_exit" ---
+proc_raise :: (sig: Signal) -> Errno #foreign "wasi_unstable" "proc_raise" ---
-sched_yield :: proc () -> Errno #foreign "wasi_unstable" "sched_yield" ---
+sched_yield :: () -> Errno #foreign "wasi_unstable" "sched_yield" ---
-random_get :: proc (buf: ^u8, buf_len: Size) -> Errno #foreign "wasi_unstable" "random_get" ---
+random_get :: (buf: ^u8, buf_len: Size) -> Errno #foreign "wasi_unstable" "random_get" ---
-sock_recv :: proc (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno #foreign "wasi_unstable" "sock_recv" ---
-sock_send :: proc (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno #foreign "wasi_unstable" "sock_send" ---
-sock_shutdown :: proc (fd: FileDescriptor, how: SDFlags) -> Errno #foreign "wasi_unstable" "sock_shutdown" ---
+sock_recv :: (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno #foreign "wasi_unstable" "sock_recv" ---
+sock_send :: (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno #foreign "wasi_unstable" "sock_send" ---
+sock_shutdown :: (fd: FileDescriptor, how: SDFlags) -> Errno #foreign "wasi_unstable" "sock_shutdown" ---
-List of known bugs:
-
-[X] Using an auto-cast on an argument when calling an overloaded proc leads
- to an unexpected error. Take the following example:
- ```
- overloaded :: proc {
- proc (x: f32, y: str) ---,
- proc (x: i32, y: i32) ---,
- }
-
- foo :: proc () {
- x: i32 = 1234;
- overloaded(~~x, 4);
- }
- ```
- Compiles with the following error:
- ```
- (/home/brendan/dev/c/onyx/a.onyx:8,15) unable to match overloaded function with provided argument types: (f32, unsized int)
- 8 | overloaded(~~x, 4);
- ```
-
- This is because in trying the first overload, the auto-cast is consumed
- and converted to a cast(f32). Then, when it doesn't match the first one
- and it tries the second, the parameter types are f32 and unsized int,
- which is doesn't match the second one, when the original parameters would
- have matched correctly.
-
-[X] `defer` statements are not executed at the end of a loop if the loop is
- exited using a `break` statement, or a `continue` statement. The semantics
- of this need to change because it is not expected behaviour. Also it would
- prevent the usefulness of this pattern:
- ```
- while i := 0; i < 10 {
- defer i += 1;
- ...
- }
- ```
- Since `continue`ing or `break`ing would skip the deferred statement, causing
- an infinite loop.
-
-[X] The following code causes an infinite loop somewhere.
- ```
- get_neighbor_count :: proc (grid: ^map.Map(Vec2, Cell), pos: Vec2) -> u32 {
- count := 0;
-
- for ^dir: Hex_Directions {
- pos := Vec2.{ x = pos.x + dir.x, y = pos.y + dir.y };
- cell := map.get(grid, pos, Cell.{});
- if cell.alive do count += 1;
- }
-
- return count;
- }
- ```
-
-[X] Polymorphic structs do not recognize default values for members.
-
-[X] `use` on struct members does not work correctly if the type is a union.
- ```
- BadUnion :: struct {
- use container : struct #union {
- int: i32;
- float: f32;
- };
- }
-
- test :: proc () do print(sizeof BadUnion == 4);
- ```
-
-[X] `use` on struct members breaks struct literals.
- ```
- Vec2 :: struct { x: i32; y: i32; }
- Entity :: struct { use pos: Vec2; }
-
- e := Entity.{ pos = Vec2.{ 1, 2 } };
-
- // This does work already.
- e2 := Entity.{ x = 1, y = 2 };
- ```
-
-[X] `TileData :: [TILE_DATA_WIDTH * TILE_DATA_HEIGHT] bool;` results in a
- segfault because it is an invalid top level node, but that is not checked
- before it is tried to be used.
-
-[X] `TileData :: #type [TILE_DATA_WIDTH * TILE_DATA_HEIGHT] bool;` produces the
- following error:
- ```
- (/home/brendan/dev/onyx/aoc/day20.onyx:25,19) Array type expects type 'i32' for size, got 'unsized int'.
- 25 | TileData :: #type [TILE_DATA_WIDTH * TILE_DATA_HEIGHT] bool;
- ```
-
- This because the expression for the array size is not reducing and getting
- converted to the fixed size integer. I suspect this is because for sizeof
- and alignof expression, `fill_in_type` is not used, and that function has
- the logic to handle the array subscript reduction and type resolution.
-
-[X] The following struct is causing a seg fault in the compiler. I believe it
- is because of the duplicate struct member names and failing to get the position
- in the file to report the error.
- ```
- Tile :: struct {
- id : u32;
- orientation : TileOrientation;
- data : [] bool;
- edges : [] u32;
-
- pos_x : u32 = 0;
- pos_x : u32 = 0;
- }
- ```
+List of known bugs:
\ No newline at end of file
+++ /dev/null
-The state of the hash implementation right now:
-
- (allocator + 1021 ptrs = 8192 bytes (HUGE))
- +---------------------------------------------------------
-table ----> | allocator | ptr | ptr | ptr | ptr | ptr | ptr | ptr ...
- +-------------||------------------------------------------
- \/
- +--------------+------------------------------------------------------
- | Array header | key (64-bytes) | value | key (64-bytes) | value | ...
- +--------------+------------------------------------------------------
-
-There are a couple of issues with this implementation:
- * The table of pointers is absolutely huge.
- It takes up about 2 pages of memory and we are randomly accessing it
- so it will not be cache efficient.
- * The keys are always the same size.
- They are normally way too large, but also they would cut off if you
- needed a large key.
-
-
-
-THIS WORKED VERY WELL!
-Attempt 1 to fix these issues:
-
- (user defined number of ptrs)
- +-----------------------------------------------------------
-table ----> | allocator | hash size | ptr | ptr | ptr | ptr | ptr | ...
- +-------------------------||--------------------------------
- \/
- +--------------+------------------------------------------------------------------------
- | Array header | length | value | key_length | key (null terminated) | v | kl | k | ...
- +--------------+------------------------------------------------------------------------
-
-GOOD:
- * This implementation would allow for any size of key.
- Initial thoughts:
- - Alignment is going to be very important.
- - Alignment will need to be by hand.
- - Aligning to 8 bytes should be sufficient.
- - The array would just be considered as a u8 array, since each element
- wouldn't be the same size.
- - Random access into the array would not be allowed for the same reason.
- - Random access will not be needed however.
- * This implementation still allows for easy iterator traversal, which is
- important for the immediate use case.
-
-BAD:
- * The fact that the number of pointers is user defined, the hashing algorithm could
- be drastically slowed / crippled if they choose a bad number of pointers.
- * This implementation still takes a very large number of allocations.
[X] Remove old code from CLI logic
[X] Add statistic printing
[ ] Fix documentation generation (broken since compiler architecture change)
- [ ] Fix AST printing (broken for a long time)
[ ] Add automated running component
- Store to temporary file (OS independent)
- Detect / choose WASM backend
it conflicts with 'builtin.string'. These two should be switched. Type
name should be 'str' and package name should be 'string'
- [ ] Expand capabilities of file api on WASI.
+ [X] Expand capabilities of file api on WASI.
+ [ ] Add file capabilities to JS backend
[ ] Add clock / time api for both backends
+ [ ] Environment variables for both backends
[ ] Better random number api
[ ] Better string formatting and parsing api
// end it simply calls main.main, which is this procedure. By convention, main takes a slice
// of cstr's, which were the arguments passed from the command line. We will talk about
// slices later.
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// This is the actual call to print, which will print the message 'Hello World!\n' onto the screen.
// It is not too important to know how this works, but if you are interested you can find the
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// This is the syntax for declaring a local variable in a procedure.
foo: i32;
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// Here is a list of all the builtin types:
// void
// bool
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// The following declares a fixed-size array of 10 i32s on the stack. Currently,
// it is not guaranteed that `arr` will be zero initialized, so we will do that
// with a for loop. Note, the `^` after the for keyword means we are iterating by
// Fixed-size arrays are passed to procedures by reference. In the following example,
// the array `arr` is passed by reference so when the for loop changes the
// contents of `array_param`, the contents of `arr` are changed as well.
- array_proc :: proc (array_param: [10] i32) {
+ array_proc :: (array_param: [10] i32) {
for i: 0 .. 10 {
array_param[i] = 1000 + i;
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// A dummy array to demonstrate.
arr := i32.[ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ];
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// Declaring dynamic arrays in Onyx looks like this. The
// '..' makes it a dynamic array, as opposed to a slice
// or fixed size array.
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// This is the basic struct syntax. Members are declared just like
// local variables in procedures.
}
// Structs can be passed by value to procedures.
- print_person :: proc (person: Person) {
+ print_person :: (person: Person) {
printf("Person(%s, %i, %i)\n", person.name, person.age, person.height);
}
y : f32 = 34;
}
- print_vector2f :: proc (vec: Vector2f) {
+ print_vector2f :: (vec: Vector2f) {
printf("Vector2f(%f, %f)", vec.x, vec.y);
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// To declare a simple, use the enum keyword.
SimpleEnum :: enum {
Value1; Value2; Value3;
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// Currently, for loops can iterate over four kinds of data structures in Onyx:
// * Ranges
// * Fixed arrays
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
x := 10 + 3 * 5;
// The basic syntax of a switch statement:
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// Onyx does not have map type built into the language semantics,
// but using polymorphic structs and overloaded procedures, it does
// provide an 'any-to-any' hash map in it's core libraries.
map.put(^ages, "Pam", 24);
// To retrieve an entry's value, use the map.get procedure.
- print_age :: proc (ages: ^map.Map(str, u32), name: str) {
+ print_age :: (ages: ^map.Map(str, u32), name: str) {
age := map.get(ages, name);
printf("%s's age is %i.\n", name, age);
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
}
use package core
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
}
use package core { println }
-main :: proc (args: [] cstr) {
+main :: (args: [] cstr) {
// These functions will be used to demo the pipe operator.
Num :: #type i32;
- double :: proc (v: Num) -> Num do return v * 2;
- add :: proc (a: Num, b: Num) -> Num do return a + b;
- square :: proc (v: Num) -> Num do return v * v;
+ double :: (v: Num) -> Num do return v * 2;
+ add :: (a: Num, b: Num) -> Num do return a + b;
+ square :: (v: Num) -> Num do return v * v;
// Something you may find yourself doing often is changing function
// calls together likes this: