Skip to content

Commit fe41bda

Browse files
committed
pref: temporary 64 bit int option
1 parent 49b8c2f commit fe41bda

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

vlib/builtin/option.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module builtin
55

66
// Option is the base of V's internal option return system.
77
struct Option {
8-
state u8
8+
state u8 // 0 - ok; 2 - none; 1 - ?
99
err IError = none__
1010
// Data is trailing after err
1111
// and is not included in here but in the

vlib/v/ast/ast.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import v.pref
99

1010
pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl
1111

12+
pub const int_type_name = $if amd64 || arm64 {
13+
'i32'
14+
//'i64'
15+
} $else {
16+
'i32'
17+
}
18+
1219
pub type Expr = AnonFn
1320
| ArrayDecompose
1421
| ArrayInit

vlib/v/gen/c/cgen.v

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ fn (mut g Gen) base_type(_t ast.Type) string {
10061006
}
10071007
// On 64 bit systems int is an i64
10081008
$if amd64 || arm64 {
1009-
if t == ast.int_type {
1010-
// return 'i64'
1009+
if g.pref.use_64_int && t == ast.int_type {
1010+
return 'i64'
10111011
}
10121012
}
10131013
share := t.share()
@@ -1115,6 +1115,8 @@ fn (g Gen) option_type_text(styp string, base string) string {
11151115
// replace void with something else
11161116
size := if base == 'void' {
11171117
'u8'
1118+
} else if base == 'int' {
1119+
ast.int_type_name
11181120
} else if base.starts_with('anon_fn') {
11191121
'void*'
11201122
} else if base.starts_with('_option_') {
@@ -1134,6 +1136,8 @@ fn (g Gen) result_type_text(styp string, base string) string {
11341136
// replace void with something else
11351137
size := if base == 'void' {
11361138
'u8'
1139+
} else if base == 'int' {
1140+
ast.int_type_name
11371141
} else if base.starts_with('anon_fn') {
11381142
'void*'
11391143
} else if base.starts_with('_option_') {

vlib/v/pref/pref.v

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ pub mut:
241241
// wasm settings:
242242
wasm_stack_top int = 1024 + (16 * 1024) // stack size for webassembly backend
243243
wasm_validate bool // validate webassembly code, by calling `wasm-validate`
244+
// temp
245+
use_64_int bool
244246
}
245247

246248
pub struct LineInfo {
@@ -407,6 +409,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
407409
// processed by testing tools in cmd/tools/modules/testing/common.v
408410
continue
409411
}
412+
'-i64' {
413+
res.use_64_int = true
414+
}
410415
'-Wimpure-v' {
411416
res.warn_impure_v = true
412417
}

0 commit comments

Comments
 (0)