diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index 1a7c109bc3bf34..4b3e3ee8a7e2eb 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -125,6 +125,14 @@ pub fn (n int) str() string { return n.str_l(12) } +// str returns the value of the `int` as a `string`. +// Example: assert int(-2020).str() == '-2020' +/* +pub fn int_str(n int) string { + return i64(n).str() +} +*/ + // str returns the value of the `u32` as a `string`. // Example: assert u32(20000).str() == '20000' [direct_array_access; inline] diff --git a/vlib/builtin/wasm/wasi/int.v b/vlib/builtin/wasm/wasi/int.v index eef4f64e5b57b1..05520efcd888f1 100644 --- a/vlib/builtin/wasm/wasi/int.v +++ b/vlib/builtin/wasm/wasi/int.v @@ -1,7 +1,8 @@ module builtin type byte = u8 -type i32 = int + +// type i32 = int const ( // digit pairs in reverse order diff --git a/vlib/v/ast/types.v b/vlib/v/ast/types.v index 36183af05c0511..037ea5643cd4b3 100644 --- a/vlib/v/ast/types.v +++ b/vlib/v/ast/types.v @@ -981,8 +981,8 @@ pub fn (t &TypeSymbol) is_pointer() bool { [inline] pub fn (t &TypeSymbol) is_int() bool { - res := t.kind in [.i8, .i16, .int, .i64, .isize, .u8, .u16, .u32, .u64, .usize, .int_literal, - .rune] + res := t.kind in [.i8, .i16, .int, .i64, .i32, .isize, .u8, .u16, .u32, .u64, .usize, + .int_literal, .rune] if !res && t.kind == .alias { return (t.info as Alias).parent_type.is_number() } @@ -1047,10 +1047,24 @@ pub fn (t &Table) type_size(typ Type) (int, int) { size = 2 align = 2 } - .int, .i32, .u32, .rune, .f32, .enum_ { + .i32, .u32, .rune, .f32, .enum_ { size = 4 align = 4 } + .int { + $if new_int ? { + $if arm64 || amd64 { + size = 8 + align = 8 + } $else { + size = 4 + align = 4 + } + } $else { + size = 4 + align = 4 + } + } .i64, .u64, .int_literal, .f64, .float_literal { size = 8 align = 8 diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index c375967c603422..20037e70b058ac 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1002,12 +1002,14 @@ fn (mut g Gen) base_type(_t ast.Type) string { return 'u64' } } + /* // On 64 bit systems int is an i64 $if amd64 || arm64 { if g.pref.use_64_int && t == ast.int_type { return 'i64' } } + */ share := t.share() mut styp := if share == .atomic_t { t.atomic_typename() } else { g.cc_type(t, true) } if t.has_flag(.shared_f) { diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 733c6284c471f9..82daad5cddde2d 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -242,7 +242,7 @@ pub mut: wasm_stack_top int = 1024 + (16 * 1024) // stack size for webassembly backend wasm_validate bool // validate webassembly code, by calling `wasm-validate` // temp - use_64_int bool + // use_64_int bool } pub struct LineInfo { @@ -409,9 +409,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin // processed by testing tools in cmd/tools/modules/testing/common.v continue } - '-i64' { - res.use_64_int = true - } + //'-i64' { + // res.use_64_int = true + //} '-Wimpure-v' { res.warn_impure_v = true }