pop_matrix :: () do global_renderer->pop_matrix();
identity :: () do global_renderer->identity();
apply_transform :: (transform: Transform) do global_renderer->apply_transform(transform);
+
+
+
+save_matrix :: #code {
+ (package immediate_mode).push_matrix();
+ defer (package immediate_mode).pop_matrix();
+}
\ No newline at end of file
state := map.get(^scrollable_region_states, hash);
mx, my := get_mouse_position();
- contained := false;
if Rectangle.contains(r, mx, my) {
- // if hot_item == 0 do set_hot_item(hash);
- contained = true;
+ set_hot_item(hash);
}
- if contained { // is_hot_item(hash) {
+ if is_hot_item(hash) {
speed :: 30.0f; @ThemeConfiguration
if is_key_down(38) do state.transform.translation.y += speed;
mx, my := get_mouse_position();
if Rectangle.contains(r, mx, my) {
- if hot_item == 0 do set_hot_item(hash);
+ set_hot_item(hash);
}
if is_hot_item(hash) {
// This function should be called at the end of drawing a frame, after all of the UI elements
// had a chance to interact with the hardware events.
+
end_frame :: () {
mouse_state.left_button_just_up = false;
mouse_state.left_button_just_down = false;
keyboard_state.keys_down_this_frame = 0;
keyboard_state.keys_up_this_frame = 0;
+ hot_item_depth_needed = hot_item_depth;
if !hot_item_was_set do set_hot_item(0);
+ hot_item_depth = 0;
hot_item_was_set = false;
for ^s: keyboard_state.state {
return true;
}
-set_hot_item :: (id: UI_Id) -> bool {
+#private_file hot_item_depth := 0;
+#private_file hot_item_depth_needed := 0;
+
+set_hot_item :: (id: UI_Id, force := false) -> bool {
if active_item != 0 do return false;
- hot_item_was_set = true;
+ if force {
+ hot_item_was_set = true;
+ hot_item = id;
+ return true;
+ }
- hot_item = id;
- return true;
+ hot_item_depth += 1;
+ if hot_item_depth >= hot_item_depth_needed {
+ hot_item_was_set = true;
+ hot_item = id;
+ return true;
+ } else {
+ return false;
+ }
}
is_active_item :: (id: UI_Id) -> bool {
"ARRAY ACCESS",
"SLICE",
"FIELD ACCESS",
- "UNARY FIELD ACCESS"
+ "UNARY FIELD ACCESS",
"PIPE",
"METHOD_CALL",
"RANGE",
AstNumLit* operand = (AstNumLit *) ast_reduce(a, unop->expr);
unop->expr = (AstTyped *) operand;
- // while (operand->kind == Ast_Kind_Alias) operand = (AstNumLit *) ((AstAlias *) operand)->alias;
-
if (operand->kind != Ast_Kind_NumLit) {
return (AstTyped *) unop;
}
}
case Unary_Op_Bitwise_Not: REDUCE_UNOP_INT(~);
+ case Unary_Op_Cast: {
+ #if 0
+ Type* from = operand->type;
+ Type* to = unop->type;
+
+ if (from->kind == Type_Kind_Enum) from = from->Enum.backing;
+ if (to->kind == Type_Kind_Enum) to = to->Enum.backing;
+
+ if (from->kind != Type_Kind_Pointer && from->kind != Type_Kind_Basic) return (AstTyped *) unop;
+ if (to->kind != Type_Kind_Pointer && to->kind != Type_Kind_Basic) return (AstTyped *) unop;
+
+ b32 from_is_int=0, to_is_int=0;
+ i32 from_size, to_size;
+
+ from_size = type_size_of(from);
+ to_size = type_size_of(to);
+
+ if (from->kind == Type_Kind_Basic) from_is_int = (from->flags & (Basic_Flag_Integer | Basic_Flag_Pointer)) != 0;
+ if (to->kind == Type_Kind_Basic) to_is_int = (to->flags & (Basic_Flag_Integer | Basic_Flag_Pointer)) != 0;
+
+ if (from->kind == Type_Kind_Pointer) from_is_int = 1;
+ if (to->kind == Type_Kind_Pointer) to_is_int = 1;
+
+ if (from_is_int == to_is_int && from_size == to_size) {
+ // If they are already equal, nothing to do
+ return (AstTyped *) res;
+ }
+
+ if (from_is_int && !to_is_int) {
+ if (from_size == to_size) {
+ if (from_size == 4) {
+ res->value.f = (f32) operand->value.i;
+ }
+ else if (from_size == 8) {
+ res->value.d = (f64) operand->value.l;
+ }
+ } else {
+ if (from_size == 4) {
+ res->value.d = (f64) operand->value.i;
+ }
+ else if (from_size == 8) {
+ res->value.f = (f32) operand->value.l;
+ }
+ }
+ } else {
+ if (from_size == to_size) {
+ if (from_size == 4) {
+ res->value.i = (i32) operand->value.f;
+ }
+ else if (from_size == 8) {
+ res->value.l = (i64) operand->value.d;
+ }
+ } else {
+ if (from_size == 4) {
+ res->value.l = (i64) operand->value.f;
+ }
+ else if (from_size == 8) {
+ res->value.i = (i32) operand->value.d;
+ }
+ }
+ }
+ break;
+
+ #endif
+ }
+
default: return (AstTyped *) unop;
}
assert(code_block->kind == Ast_Kind_Code_Block);
AstNode* cloned_block = ast_clone(context.ast_alloc, code_block->code);
+ cloned_block->next = insert->next;
if (cloned_block->kind == Ast_Kind_Block) {
AstNode* next = insert->next;
Type* sl_type = sl->type;
// ROBUSTNESS: Handle cases for slices and dynamic arrays
- if (sl_type->kind != Type_Kind_Struct) {
+ if (sl_type->kind != Type_Kind_Struct && sl_type->kind != Type_Kind_Slice && sl_type->kind != Type_Kind_DynArray) {
retval = 0;
break;
}
- i32 i = 0;
- bh_arr_each(AstTyped *, expr, sl->args.values) {
- retval &= emit_raw_data_(mod, bh_pointer_add(data, sl_type->Struct.memarr[i]->offset), *expr);
- i++;
+ i32 mem_count = type_structlike_mem_count(sl_type);
+ StructMember smem;
+
+ fori (i, 0, mem_count) {
+ type_lookup_member_by_idx(sl_type, i, &smem);
+ retval &= emit_raw_data_(mod, bh_pointer_add(data, smem.offset), sl->args.values[i]);
}
break;
file := reader.make(contents);
- cubes := map.make(CubePos, CubeState, .{}, 1021);
+ cubes := map.make(CubePos, CubeState, .{}, 2047);
defer map.free(^cubes);
z := 0;
}
dlp_bsgs :: (n: u32, a: u32, b: u32) -> u32 {
- use package core.intrinsics.wasm { ceil_f64, sqrt_f64 }
- m := cast(u32) ceil_f64(sqrt_f64(~~n));
+ m := cast(u32) math.ceil(math.sqrt(cast(f64) n));
t := map.make(u32, u32, default=0, hash_count=m/2);
defer map.free(^t);
tmp = ~~b;
for i: 0 .. m {
- if map.has(^t, cast(u32) tmp) {
- v := map.get(^t, cast(u32) tmp);
+ if map.has(^t, ~~tmp) {
+ v := map.get(^t, ~~tmp);
return i * m + v;
}
for ch: line do array.push(^forest, ch);
}
- lis : [5] LineInterp;
- lis[0] = .{ 0, 0, 1, 1 };
- lis[1] = .{ 0, 0, 3, 1 };
- lis[2] = .{ 0, 0, 5, 1 };
- lis[3] = .{ 0, 0, 7, 1 };
- lis[4] = .{ 0, 0, 1, 2 };
+ lis := LineInterp.[
+ .{ 0, 0, 1, 1 },
+ .{ 0, 0, 3, 1 },
+ .{ 0, 0, 5, 1 },
+ .{ 0, 0, 7, 1 },
+ .{ 0, 0, 1, 2 },
+ ];
tree_prod: u64 = 1;