for i: 0 .. arr.count do new_arr.data[i] = arr.data[i];
return new_arr;
- },
+ },
(arr: [] $T, allocator := context.allocator) -> [] T {
- new_arr := make([] T, arr.count);
+ new_arr := make([] T, arr.count);
for i: 0 .. arr.count do new_arr.data[i] = arr.data[i];
return new_arr;
}
fold_idx_elem :: (arr: [] $T, cmp: (T, T) -> bool) -> (i32, T) {
idx := 0;
elem := arr[0];
-
+
for i: 1 .. arr.count {
if cmp(arr[i], elem) {
idx = i;
elem = arr[i];
}
}
-
+
return idx, elem;
}
return count;
},
}
-
if this.data == 0 do return null;
wasm :: package core.intrinsics.wasm
- mem_base_ptr := __cptr_make(0);
- assert(mem_base_ptr <= this.data && this.data <= mem_base_ptr + (wasm.memory_size() << 16), "Invalid conversion from cptr to rawptr: pointer value out of Onyx memory range.");
- return ~~(this.data - mem_base_ptr);
+ // Using 1 instead of 0 because a null pointer (0) converts
+ // to the memory address 0, not the base address for the WASM
+ // memory.
+ mem_base_ptr := __cptr_make(cast(rawptr) 1);
+ assert(mem_base_ptr <= this.data + 1 && this.data + 1 <= mem_base_ptr + ~~(wasm.memory_size() << 16), "Invalid conversion from cptr to rawptr: pointer value out of Onyx memory range.");
+ return ~~(this.data - mem_base_ptr + 1);
}
}
let s:cpo_save = &cpo
set cpo&vim
-syn keyword onyxKeyword package struct enum proc use global macro
+syn keyword onyxKeyword package struct enum use global macro
syn keyword onyxKeyword if elseif else where interface
syn keyword onyxKeyword for while do
syn keyword onyxKeyword switch case
syn keyword onyxType i8x16 i16x8 i32x4 i64x2 f32x4 f64x2 v128
syn keyword onyxType type_expr any
-syn keyword onyxConstant true false null null_proc
+syn keyword onyxConstant true false null null_proc it
syn match onyxNumber "\<0x[a-fA-F0-9]\+\>"
syn match onyxNumber "\<\d\+[lf]\=\>"
// Symbols
if (char_is_alpha(*tk.text) || *tokenizer->curr == '_') {
u64 len = 0;
- while (char_is_alphanum(*tokenizer->curr) || charset_contains("_$", *tokenizer->curr)) {
+ while (char_is_alphanum(*tokenizer->curr) || *tokenizer->curr == '_') {
len++;
INCREMENT_CURR_TOKEN(tokenizer);
}