#operator << macro (heap: Heap($T), v: T) do (package core.heap).insert(^heap, v);
-remove_top :: (use heap: ^Heap($T)) -> T {
+remove_top :: (use heap: ^Heap) -> heap.T {
x := data[0];
array.fast_delete(^data, 0);
shift_down(heap, 0);
heap_lchild :: macro (index) => (index * 2) + 1
heap_rchild :: macro (index) => (index * 2) + 2
- shift_down :: (use heap: ^Heap($T), idx: i32) {
+ shift_down :: (use heap: ^Heap, idx: i32) {
while true {
min_index := idx;
}
}
- shift_up :: (use heap: ^Heap($T), idx: i32) {
+ shift_up :: (use heap: ^Heap, idx: i32) {
while idx > 0 {
parent := heap_parent(idx);
if compare(data[parent], data[idx]) <= 0 do break;
array.init(^entries, 4, allocator=allocator);
}
-free :: (use set: ^Set($T)) {
+free :: (use set: ^Set) {
memory.free_slice(^hashes, allocator=allocator);
array.free(^entries);
}
else do hashes[last.hash_index] = lr.entry_index;
}
-clear :: (use set: ^Set($T)) {
+clear :: (use set: ^Set) {
array.fill(hashes, -1);
array.clear(^entries);
}
-empty :: (use set: ^Set($T)) -> bool {
+empty :: (use set: ^Set) -> bool {
return entries.count == 0;
}
return lr;
}
- full :: (use set: ^Set($T)) => entries.count >= ~~(0.75f * ~~hashes.count);
+ full :: (use set: ^Set) => entries.count >= ~~(0.75f * ~~hashes.count);
- grow :: (use set: ^Set($T)) {
+ grow :: (use set: ^Set) {
new_size := math.max(hashes.count << 1, 8);
rehash(set, new_size);
}
- rehash :: (use set: ^Set($T), new_size: i32) {
+ rehash :: (use set: ^Set, new_size: i32) {
memory.free_slice(^hashes, allocator);
memory.alloc_slice(^hashes, new_size, allocator);
memory.fill_slice(hashes, -1);
} \
} while (0)
+#define YIELD_ERROR(loc, msg) do { \
+ if (context.cycle_detected) { \
+ onyx_report_error(loc, Error_Critical, msg); \
+ return Check_Error; \
+ } else { \
+ return Check_Yield_Macro; \
+ } \
+ } while (0)
+
#define ERROR(loc, msg) do { \
onyx_report_error(loc, Error_Critical, msg); \
return Check_Error; \
if (*expected_return_type == &type_auto_return) {
resolve_expression_type(retnode->expr);
if (retnode->expr->type == NULL)
- YIELD(retnode->token->pos, "Trying to determine automatic return type.");
+ YIELD_ERROR(retnode->token->pos, "Unable to determine the automatic return type here.");
*expected_return_type = retnode->expr->type;
return Check_Success;