diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 58daa72d80..6b1c76572d 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -65,8 +65,8 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string { } is_last_arg := i == node.params.len - 1 is_type_only := arg.name == '' - should_add_type := is_last_arg || is_type_only || node.params[i + 1].typ != arg.typ || - (node.is_variadic && i == node.params.len - 2) + should_add_type := true // is_last_arg || is_type_only || node.params[i + 1].typ != arg.typ || + // (node.is_variadic && i == node.params.len - 2) if arg.is_mut { f.write(arg.typ.share().str() + ' ') } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 4447d3948a..9c30e89783 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -247,7 +247,7 @@ fn (mut c Checker) check_file_in_main(file ast.File) bool { return has_main_fn } -fn (mut c Checker) check_valid_snake_case(name, identifier string, pos token.Position) { +fn (mut c Checker) check_valid_snake_case(name string, identifier string, pos token.Position) { if !c.pref.is_vweb && (name[0] == `_` || name.contains('._')) { c.error('$identifier `$name` cannot start with `_`', pos) } @@ -264,7 +264,7 @@ fn stripped_name(name string) string { return name[(idx + 1)..] } -fn (mut c Checker) check_valid_pascal_case(name, identifier string, pos token.Position) { +fn (mut c Checker) check_valid_pascal_case(name string, identifier string, pos token.Position) { sname := stripped_name(name) if !sname[0].is_capital() && !c.pref.translated { c.error('$identifier `$name` must begin with capital letter', pos) @@ -1531,7 +1531,7 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type { return f.return_type } -fn (mut c Checker) type_implements(typ, inter_typ table.Type, pos token.Position) bool { +fn (mut c Checker) type_implements(typ table.Type, inter_typ table.Type, pos token.Position) bool { typ_sym := c.table.get_type_symbol(typ) inter_sym := c.table.get_type_symbol(inter_typ) styp := c.table.type_to_str(typ) @@ -3854,7 +3854,7 @@ pub fn (mut c Checker) error(message string, pos token.Position) { } // check_struct_signature checks if both structs has the same signature / fields for casting -fn (c Checker) check_struct_signature(from, to table.Struct) bool { +fn (c Checker) check_struct_signature(from table.Struct, to table.Struct) bool { if from.fields.len != to.fields.len { return false } diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index b29a21b548..1eb0094db9 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -419,7 +419,7 @@ fn (mut g Gen) optional_type_name(t table.Type) (string, string) { return styp, base } -fn (g &Gen) optional_type_text(styp, base string) string { +fn (g &Gen) optional_type_text(styp string, base string) string { x := styp // .replace('*', '_ptr') // handle option ptrs // replace void with something else size := if base == 'void' { 'int' } else { base } @@ -469,7 +469,7 @@ fn (mut g Gen) find_or_register_shared(t table.Type, base string) string { return sh_typ } -fn (mut g Gen) register_chan_pop_optional_call(opt_el_type, styp string) { +fn (mut g Gen) register_chan_pop_optional_call(opt_el_type string, styp string) { if opt_el_type !in g.chan_pop_optionals { g.chan_pop_optionals << opt_el_type g.channel_definitions.writeln(' @@ -1180,7 +1180,7 @@ fn (mut g Gen) for_in(it ast.ForInStmt) { } // use instead of expr() when you need to cast to sum type (can add other casts also) -fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type, expected_type table.Type) { +fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type table.Type, expected_type table.Type) { // cast to sum type if expected_type != table.void_type { expected_is_ptr := expected_type.is_ptr() @@ -3688,7 +3688,7 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) { } } -fn (mut g Gen) const_decl_simple_define(name, val string) { +fn (mut g Gen) const_decl_simple_define(name string, val string) { // Simple expressions should use a #define // so that we don't pollute the binary with unnecessary global vars // Do not do this when building a module, otherwise the consts @@ -3697,7 +3697,7 @@ fn (mut g Gen) const_decl_simple_define(name, val string) { g.definitions.writeln(val) } -fn (mut g Gen) const_decl_init_later(mod, name, val string, typ table.Type) { +fn (mut g Gen) const_decl_init_later(mod string, name string, val string, typ table.Type) { // Initialize more complex consts in `void _vinit(){}` // (C doesn't allow init expressions that can't be resolved at compile time). styp := g.typ(typ) @@ -5144,7 +5144,7 @@ fn (mut g Gen) gen_str_for_type(typ table.Type) string { return g.gen_str_for_type_with_styp(typ, styp) } -fn (mut g Gen) gen_str_default(sym table.TypeSymbol, styp, str_fn_name string) { +fn (mut g Gen) gen_str_default(sym table.TypeSymbol, styp string, str_fn_name string) { mut convertor := '' mut typename_ := '' if sym.parent_idx in table.integer_type_idxs { @@ -5441,7 +5441,7 @@ fn (mut g Gen) array_init(it ast.ArrayInit) { // `ui.foo(button)` => // `ui__foo(I_ui__Button_to_ui__Widget(` ... -fn (mut g Gen) interface_call(typ, interface_type table.Type) { +fn (mut g Gen) interface_call(typ table.Type, interface_type table.Type) { interface_styp := g.cc_type(interface_type) styp := g.cc_type(typ) mut cast_fn_name := 'I_${styp}_to_Interface_$interface_styp' diff --git a/vlib/v/gen/x64/gen.v b/vlib/v/gen/x64/gen.v index 2e43bd4779..47f2ed7df8 100644 --- a/vlib/v/gen/x64/gen.v +++ b/vlib/v/gen/x64/gen.v @@ -147,7 +147,7 @@ fn (mut g Gen) write64(n i64) { g.buf << byte(n >> 56) } -fn (mut g Gen) write64_at(n, at i64) { +fn (mut g Gen) write64_at(n i64, at i64) { // write 8 bytes g.buf[at] = byte(n) g.buf[at + 1] = byte(n >> 8) @@ -469,7 +469,7 @@ pub fn (mut g Gen) gen_loop_start(from int) int { return label } -pub fn (mut g Gen) gen_loop_end(to, label int) { +pub fn (mut g Gen) gen_loop_end(to int, label int) { g.cmp(.r12, ._8, to) g.jl(label) } @@ -540,7 +540,7 @@ fn (mut g Gen) mov(reg Register, val int) { g.println('mov $reg, $val') } -fn (mut g Gen) mov_reg(a, b Register) { +fn (mut g Gen) mov_reg(a Register, b Register) { match a { .rbp { g.write8(0x48) @@ -677,7 +677,7 @@ fn (mut g Gen) expr(node ast.Expr) { } } -fn (mut g Gen) allocate_var(name string, size, initial_val int) { +fn (mut g Gen) allocate_var(name string, size int, initial_val int) { // `a := 3` => // `move DWORD [rbp-0x4],0x3` match size { diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 2687b5cd52..edfb1cad1d 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -79,7 +79,7 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt { return p.stmt(false) } -pub fn parse_text(text string, b_table &table.Table, pref &pref.Preferences, scope, global_scope &ast.Scope) ast.File { +pub fn parse_text(text string, b_table &table.Table, pref &pref.Preferences, scope &ast.Scope, global_scope &ast.Scope) ast.File { s := scanner.new_scanner(text, .skip_comments, pref) mut p := Parser{ scanner: s @@ -2054,7 +2054,7 @@ fn (mut p Parser) unsafe_stmt() ast.Stmt { } } -fn (mut p Parser) trace(fbase, message string) { +fn (mut p Parser) trace(fbase string, message string) { if p.file_base == fbase { println('> p.trace | ${fbase:-10s} | $message') } diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 78381f6511..3f8afa7a33 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -309,7 +309,7 @@ fn (s &Scanner) ident_struct_name() string { return struct_name } -fn filter_num_sep(txt byteptr, start, end int) string { +fn filter_num_sep(txt byteptr, start int, end int) string { unsafe { mut b := malloc(end - start + 1) // add a byte for the endstring 0 mut i1 := 0 diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index 8b2cf1f269..446c20a3d4 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -419,7 +419,7 @@ pub fn (t &Table) array_source_name(elem_type Type) string { } [inline] -pub fn (t &Table) array_fixed_name(elem_type Type, size, nr_dims int) string { +pub fn (t &Table) array_fixed_name(elem_type Type, size int, nr_dims int) string { elem_type_sym := t.get_type_symbol(elem_type) mut res := '' if elem_type.is_ptr() { @@ -465,7 +465,7 @@ pub fn (t &Table) chan_source_name(elem_type Type, is_mut bool) string { } [inline] -pub fn (t &Table) map_name(key_type, value_type Type) string { +pub fn (t &Table) map_name(key_type Type, value_type Type) string { key_type_sym := t.get_type_symbol(key_type) value_type_sym := t.get_type_symbol(value_type) suffix := if value_type.is_ptr() { '_ptr' } else { '' } @@ -476,7 +476,7 @@ pub fn (t &Table) map_name(key_type, value_type Type) string { // map_source_name generates the original name for the v source. // e. g. map[string]int [inline] -pub fn (t &Table) map_source_name(key_type, value_type Type) string { +pub fn (t &Table) map_source_name(key_type Type, value_type Type) string { key_type_sym := t.get_type_symbol(key_type) value_type_sym := t.get_type_symbol(value_type) ptr := if value_type.is_ptr() { '&' } else { '' } @@ -505,7 +505,7 @@ pub fn (mut t Table) find_or_register_chan(elem_type Type, is_mut bool) int { return t.register_type_symbol(chan_typ) } -pub fn (mut t Table) find_or_register_map(key_type, value_type Type) int { +pub fn (mut t Table) find_or_register_map(key_type Type, value_type Type) int { name := t.map_name(key_type, value_type) source_name := t.map_source_name(key_type, value_type) // existing @@ -550,7 +550,7 @@ pub fn (mut t Table) find_or_register_array(elem_type Type, nr_dims int, mod str return t.register_type_symbol(array_type) } -pub fn (mut t Table) find_or_register_array_fixed(elem_type Type, size, nr_dims int) int { +pub fn (mut t Table) find_or_register_array_fixed(elem_type Type, size int, nr_dims int) int { name := t.array_fixed_name(elem_type, size, nr_dims) source_name := t.array_fixed_source_name(elem_type, size) // existing @@ -601,7 +601,7 @@ pub fn (mut t Table) find_or_register_multi_return(mr_typs []Type) int { return t.register_type_symbol(mr_type) } -pub fn (mut t Table) find_or_register_fn_type(mod string, f Fn, is_anon, has_decl bool) int { +pub fn (mut t Table) find_or_register_fn_type(mod string, f Fn, is_anon bool, has_decl bool) int { name := if f.name.len == 0 { 'anon_fn_$f.signature()' } else { f.name.clone() } source_name := if f.name.len == 0 { 'fn $f.source_signature()' } else { f.name.clone() } anon := f.name.len == 0 || is_anon @@ -683,7 +683,7 @@ pub fn (t &Table) mktyp(typ Type) Type { // Once we have a module format we can read from module file instead // this is not optimal -pub fn (table &Table) qualify_module(mod, file_path string) string { +pub fn (table &Table) qualify_module(mod string, file_path string) string { for m in table.imports { // if m.contains('gen') { println('qm=$m') } if m.contains('.') && m.contains(mod) { @@ -710,7 +710,7 @@ pub fn (mut table Table) register_fn_gen_type(fn_name string, typ Type) { // TODO: there is a bug when casting sumtype the other way if its pointer // so until fixed at least show v (not C) error `x(variant) = y(SumType*)` -pub fn (table &Table) sumtype_has_variant(parent, variant Type) bool { +pub fn (table &Table) sumtype_has_variant(parent Type, variant Type) bool { parent_sym := table.get_type_symbol(parent) if parent_sym.kind == .sum_type { parent_info := parent_sym.info as SumType