F32 is default float, operator overloads turn literals into default types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
VariadicArguments :: (string: *char, args: ..): Any
|
||||
VariadicArguments :: (string: *char, args: []Any): Any
|
||||
return args[0]
|
||||
|
||||
AnyArguments :: (values: []Any)
|
||||
@@ -39,8 +39,6 @@ IntegerToString :: (value: S64, result: *U8, base: S64): *U8
|
||||
*ptr1++ = tmp_char
|
||||
return result
|
||||
|
||||
|
||||
|
||||
StringToDouble :: (s: String): F64
|
||||
sign: F64 = 1.0
|
||||
i := 0
|
||||
@@ -56,7 +54,7 @@ StringToDouble :: (s: String): F64
|
||||
|
||||
return 0
|
||||
|
||||
FormatString :: (buffer: *U8, buffer_len: U64, string: String, args: ..)
|
||||
FormatString :: (buffer: *U8, buffer_len: U64, string: String, args: []Any)
|
||||
// @todo(krzosa): Add consideration of buffer SIZE! Add some function to handle this OutStr or something
|
||||
arg_counter := 0
|
||||
out_buffer_len := 0
|
||||
|
||||
@@ -8,9 +8,29 @@ len : S64
|
||||
*(result.data->*S64) = *(a.data->*S64) + *(b.data->*S64)
|
||||
return result
|
||||
|
||||
"+" :: (a: Any, b: S64): Any
|
||||
result: Any = storage[len++]
|
||||
if a.type == S64
|
||||
*(result.data->*S64) = *(a.data->*S64) + b
|
||||
return result
|
||||
|
||||
"==" :: (a: Any, b: S64): Bool
|
||||
result := false
|
||||
if a.type == S64
|
||||
result = *(a.data->*S64) == b
|
||||
return result
|
||||
|
||||
"==" :: (a: Any, b: Any): Bool
|
||||
result := false
|
||||
if a.type == S64 && b.type == S64
|
||||
result = *(a.data->*S64) == *(b.data->*S64)
|
||||
return result
|
||||
|
||||
main :: (): int
|
||||
a: Any = 10
|
||||
b: Any = 20
|
||||
c := a + b
|
||||
Assert(c.type == S64 && *(c.data->*S64) == 30)
|
||||
Assert(c.type == S64 && c == 30)
|
||||
Assert(a+b+a==c+(5+5))
|
||||
|
||||
return 0
|
||||
@@ -29,13 +29,13 @@ main :: (): int
|
||||
|
||||
// We can also tell the compiler to infer the type
|
||||
this_is_s64_by_default := 10
|
||||
this_is_f64_by_default := 10.1251
|
||||
this_is_f32_by_default := 10.1251
|
||||
this_is_string_by_default := "Thing"
|
||||
|
||||
// Reassigning values is exactly like in other languages
|
||||
this_is_s64_by_default = 20
|
||||
this_is_string_by_default = "Other_Thing"
|
||||
this_is_f64_by_default = 15.1255
|
||||
this_is_f32_by_default = 15.1255
|
||||
|
||||
// @todo: Add type_of operator!!!
|
||||
// Assert(type_of(this_is_string_by_default) == String)
|
||||
@@ -51,7 +51,7 @@ main :: (): int
|
||||
|
||||
// When it comes to runtime variables it's a bit different
|
||||
// To do this we need a cast
|
||||
combining_types := this_is_s64_by_default->F64 + this_is_f64_by_default
|
||||
combining_types := this_is_s64_by_default->F32 + this_is_f32_by_default
|
||||
|
||||
Assert(s64val == 0 && s32val == 0 && s16val == 0 && s8val == 0 && intval == 0 && u64val == 0 && u32val == 0 && u16val == 0 && u8val == 0 && f64val == 0 && f32val == 0)
|
||||
Assert(string_val[0] == 'S')
|
||||
@@ -59,7 +59,7 @@ main :: (): int
|
||||
Assert(signed_variable == 10 && unsigned_variable == 10)
|
||||
Assert(INT_VALUE == 10)
|
||||
Assert(FLOAT_VALUE == 124.125)
|
||||
Assert(this_is_f64_by_default == 15.1255)
|
||||
Assert(this_is_f32_by_default == 15.1255)
|
||||
Assert(combining_types == 15.1255 + 20)
|
||||
|
||||
// Compound statements
|
||||
|
||||
@@ -141,7 +141,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
window_dc := GetDC(window)
|
||||
bitmap := CreateBitmap(screen_size)
|
||||
|
||||
requested_time_per_frame := 1.0 / 60.0
|
||||
requested_time_per_frame: F64 = 1.0 / 60.0
|
||||
frame_start_time := Time()
|
||||
frame_number: S64
|
||||
for AppIsRunning
|
||||
|
||||
Reference in New Issue
Block a user