Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaquraish committed Apr 4, 2024
1 parent 2a96275 commit eb8c436
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
9 changes: 3 additions & 6 deletions bootstrap/stage0.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,6 @@ u32 std_traits_hash_pair_hash(u32 a, u32 b);
u32 str_hash(char *this);
u32 u32_hash(u32 this);
u32 u64_hash(u64 this);
char *std_value_ValueType_str(std_value_ValueType this);
std_value_Value *std_value_Value_new(std_value_ValueType type);
std_value_Value *std_value_Value_new_str(char *s);
std_value_Value *std_value_Value_new_bool(bool bul);
Expand Down Expand Up @@ -10051,6 +10050,8 @@ compiler_ast_operators_Operator compiler_ast_operators_Operator_from_operator_ov
__yield_0 = compiler_ast_operators_Operator_LeftShiftEquals;
} else if (!strcmp(__match_str, ">>=")) {
__yield_0 = compiler_ast_operators_Operator_RightShiftEquals;
} else if (!strcmp(__match_str, "%")) {
__yield_0 = compiler_ast_operators_Operator_Modulus;
} else {
__yield_0 = compiler_ast_operators_Operator_Error;
}
Expand Down Expand Up @@ -13185,10 +13186,6 @@ u32 u64_hash(u64 this) {
return std_traits_hash_pair_hash(u32_hash(((u32)this)), u32_hash(((u32)(this >> ((u64)32)))));
}

char *std_value_ValueType_str(std_value_ValueType this) {
return std_value_ValueType_dbg(this);
}

std_value_Value *std_value_Value_new(std_value_ValueType type) {
std_value_Value *val = std_new__24(1);
val->type=type;
Expand Down Expand Up @@ -13226,7 +13223,7 @@ std_value_Value *std_value_Value_new_int(i64 num) {

void std_value_Value_ensure(std_value_Value *this, std_value_ValueType type) {
if ((this->type != type)) {
printf("Value type mismatch, expected %s but got %s""\n", std_value_ValueType_str(this->type), std_value_ValueType_str(type));
printf("%s:%u:%u: Value type mismatch, expected %s but got %s\n", (this->span.start).filename, (this->span.start).line, (this->span.start).col, std_value_ValueType_dbg(this->type), std_value_ValueType_dbg(type));
exit(1);
}
}
Expand Down
5 changes: 4 additions & 1 deletion std/math.oc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
[extern "ceilf"] def f32::ceil(this): f32
[extern "floorf"] def f32::floor(this): f32

[extern "INFINITY"] const INFINITY: f64
def f32::inf(): f32 => INFINITY as f32
def f64::inf(): f64 => INFINITY

[extern "sqrt"] def f64::sqrt(this): f64
[extern "cos"] def f64::cos(this): f64
[extern "sin"] def f64::sin(this): f64
Expand All @@ -24,7 +28,6 @@
[extern "ceil"] def f64::ceil(this): f64
[extern "floor"] def f64::floor(this): f64


[extern "fabsf"] def f32::abs(this): f32
[extern "fabs"] def f64::abs(this): f64
[extern "rand"] def randint(): i32
Expand Down
8 changes: 8 additions & 0 deletions std/sv.oc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ def SV::chop_u16(&this): u16 => .chop_unsigned("SV::chop_u16") as u16
//* Chop off a u8 from the beginning of the string and return it. Fails if there is no number
def SV::chop_u8(&this): u8 => .chop_unsigned("SV::chop_u8") as u8

def SV::chop_f32(&this): f32 {
let endptr = ""
let res = std::libc::strtod(.data, &endptr)
assert endptr != .data, "Failed to parse number in SV::chop_f32"
.only_chop_left((endptr - .data) as u32)
return res as f32
}

//* Helper function for parsing signed numbers
def SV::chop_signed(&this, fn_name: str): i64 {
let endptr = ""
Expand Down
3 changes: 3 additions & 0 deletions std/vec.oc
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,6 @@ def Vec3::to_u32(this): Vec3u => Vec3u(.x as u32, .y as u32, .z as u32)
def Vec3::to_f64(this): Vec3f64 => Vec3f64(.x as f64, .y as f64, .z as f64)
def Vec3::to_i64(this): Vec3i64 => Vec3i64(.x as i64, .y as i64, .z as i64)
def Vec3::to_u64(this): Vec3u64 => Vec3u64(.x as u64, .y as u64, .z as u64)
[operator "[]"]
def Vec3::index(this, idx: u32): T => (&this as &T)[idx]
10 changes: 0 additions & 10 deletions tests/random.oc

This file was deleted.

0 comments on commit eb8c436

Please sign in to comment.