heap_u32 :: __heap_start as ^u32;
curr_offset := *heap_u32;
- if curr_offset == 0 as u32 curr_offset = 8 as u32;
+ if curr_offset == 0 curr_offset = 8;
*heap_u32 = curr_offset + size;
return ((__heap_start as u32) + curr_offset) as rawptr;
}
-
+alloc_2darr :: proc (rows: u32, cols: u32) -> ^^i32 {
+ arr := alloc(rows * 4) as ^^i32;
+ for i: 0, cols arr[i] = alloc(cols * 4) as ^i32;
+ return arr;
+}
multi_arr_test :: proc #export "main" {
- arrs := alloc((10 * 4) as u32) as ^^i32;
-
- for i: 0, 10 {
- arrs[i] = alloc((10 * 4) as u32) as ^i32;
- }
+ arrs := alloc_2darr(10, 10);
for y: 0, 10 for x: 0, 10 arrs[y][x] = x + y * 10;
for y: 0, 10 for x: 0, 10 print(arrs[x][y]);
if (check_expression(fornode->step)) return 1;
// HACK
- if (fornode->start->type != &basic_types[Basic_Kind_I32]) {
+ if (!types_are_compatible(fornode->start->type, &basic_types[Basic_Kind_I32])) {
onyx_message_add(Msg_Type_Literal,
fornode->start->token->pos,
"expected expression of type i32 for start");
return 1;
}
- if (fornode->end->type != &basic_types[Basic_Kind_I32]) {
+ if (!types_are_compatible(fornode->end->type, &basic_types[Basic_Kind_I32])) {
onyx_message_add(Msg_Type_Literal,
fornode->end->token->pos,
"expected expression of type i32 for end");
return 1;
}
+ if (fornode->step)
+ if (!types_are_compatible(fornode->step->type, &basic_types[Basic_Kind_I32])) {
+ onyx_message_add(Msg_Type_Literal,
+ fornode->start->token->pos,
+ "expected expression of type i32 for step");
+ return 1;
+ }
+
+
if (check_statement(fornode->stmt)) return 1;
return 0;
case Type_Kind_Basic:
if (t2->kind == Type_Kind_Basic) {
// HACK: Not sure if this is right way to check this?
- return t1 == t2;
+ if (t1 == t2) return 1;
+
+ if ((t1->Basic.flags & Basic_Flag_Integer) && (t2->Basic.flags & Basic_Flag_Integer)) {
+ return t1->Basic.size == t2->Basic.size;
+ }
}
break;