all: new int fixes

This commit is contained in:
Alexander Medvednikov 2023-10-08 14:12:38 +03:00
parent 05d940ac2a
commit 4f85b49bb5
4 changed files with 27 additions and 7 deletions

View File

@ -115,7 +115,7 @@ mut:
// gg context for drawing
gg &gg.Context = unsafe { nil }
font_loaded bool
show_ghost bool = true
show_ghost bool
// frame/time counters:
frame int
frame_old int
@ -159,9 +159,7 @@ fn frame(mut game Game) {
}
fn main() {
mut game := &Game{
gg: 0
}
mut game := &Game{}
mut fpath := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
$if android {
fpath = 'fonts/RobotoMono-Regular.ttf'
@ -322,7 +320,6 @@ fn (mut g Game) get_tetro() {
g.tetro = g.tetros_cache[idx..idx + tetro_size].clone()
}
// TODO mut
fn (mut g Game) drop_tetro() {
for i in 0 .. tetro_size {
tetro := g.tetro[i]

View File

@ -7,6 +7,7 @@ pub type ComptTimeConstValue = EmptyExpr
| i32
| i64
| i8
| int
| rune
| string
| u16
@ -55,7 +56,7 @@ pub fn (val ComptTimeConstValue) i32() ?i32 {
pub fn (val ComptTimeConstValue) voidptr() ?voidptr {
match val {
i8, i16, i32, i64 { return voidptr(i64(val)) }
i8, i16, i32, i64, int { return voidptr(i64(val)) }
u8, u16, u32, u64 { return voidptr(u64(val)) }
rune { return voidptr(u64(val)) }
voidptr { return val }
@ -75,7 +76,7 @@ pub fn (val ComptTimeConstValue) i64() ?i64 {
i32 {
return i64(val)
}
i64 {
i64, int {
return i64(val)
}
u8 {
@ -164,6 +165,11 @@ pub fn (val ComptTimeConstValue) u64() ?u64 {
return u64(val)
}
}
int {
if val >= 0 {
return u64(val)
}
}
u8 {
return u64(val)
}
@ -217,6 +223,9 @@ pub fn (val ComptTimeConstValue) f64() ?f64 {
i64 {
return f64(val)
}
int {
return f64(val)
}
u8 {
return f64(val)
}
@ -259,6 +268,9 @@ pub fn (val ComptTimeConstValue) string() ?string {
i64 {
return val.str()
}
int {
return val.str()
}
u8 {
return val.str()
}

View File

@ -46,6 +46,13 @@ vlib/v/checker/tests/compare_unsigned_signed.vv:20:13: error: `int` cannot be co
| ~~
21 | _ = i32(0) == u64(0) // FIXME
22 | // swap order
vlib/v/checker/tests/compare_unsigned_signed.vv:21:13: error: `i32` cannot be compared with `u64`
19 | _ = i16(0) != u32(0)
20 | _ = int(0) == u64(0)
21 | _ = i32(0) == u64(0) // FIXME
| ~~
22 | // swap order
23 | _ = u16(0) == i8(0)
vlib/v/checker/tests/compare_unsigned_signed.vv:23:13: error: `u16` cannot be compared with `i8`
21 | _ = i32(0) == u64(0) // FIXME
22 | // swap order

View File

@ -5390,6 +5390,10 @@ fn (mut g Gen) const_decl_precomputed(mod string, name string, field_name string
i32 {
g.const_decl_write_precomputed(mod, styp, cname, field_name, ct_value.str())
}
int {
// XTODO int64
g.const_decl_write_precomputed(mod, styp, cname, field_name, ct_value.str())
}
i64 {
if typ == ast.i64_type {
return false