diff --git a/bootstrap/stage0.c b/bootstrap/stage0.c index 9183208..d5945f2 100644 --- a/bootstrap/stage0.c +++ b/bootstrap/stage0.c @@ -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); @@ -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; } @@ -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; @@ -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); } } diff --git a/std/math.oc b/std/math.oc index 37feb5e..cc01f90 100644 --- a/std/math.oc +++ b/std/math.oc @@ -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 @@ -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 diff --git a/std/sv.oc b/std/sv.oc index 55caa53..f9a3607 100644 --- a/std/sv.oc +++ b/std/sv.oc @@ -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 = "" diff --git a/std/vec.oc b/std/vec.oc index c2779fc..fef4290 100644 --- a/std/vec.oc +++ b/std/vec.oc @@ -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] \ No newline at end of file diff --git a/tests/random.oc b/tests/random.oc deleted file mode 100644 index 832674c..0000000 --- a/tests/random.oc +++ /dev/null @@ -1,10 +0,0 @@ -/// out: "2835837810 3948290883 3142253504 3924124932 2079000489" - -import std::random as rng - -def main() { - let rs = rng::RandomState::make(5) - for let i = 0; i < 5; ++i { - print(`{rng::randint(&rs)} `) - } -} \ No newline at end of file