diff --git a/cmd/tools/vast/vast.v b/cmd/tools/vast/vast.v index 3d814b5bd6..53c1673b3a 100644 --- a/cmd/tools/vast/vast.v +++ b/cmd/tools/vast/vast.v @@ -405,7 +405,7 @@ fn (t Tree) stmt(node ast.Stmt) &Node { ast.EnumDecl { return t.enum_decl(node) } ast.InterfaceDecl { return t.interface_decl(node) } ast.HashStmt { return t.hash_stmt(node) } - ast.CompFor { return t.comptime_for(node) } + ast.ComptimeFor { return t.comptime_for(node) } ast.GlobalDecl { return t.global_decl(node) } ast.DeferStmt { return t.defer_stmt(node) } ast.TypeDecl { return t.type_decl(node) } @@ -700,9 +700,9 @@ fn (t Tree) hash_stmt(node ast.HashStmt) &Node { return obj } -fn (t Tree) comptime_for(node ast.CompFor) &Node { +fn (t Tree) comptime_for(node ast.ComptimeFor) &Node { mut obj := new_object() - obj.add('ast_type', t.string_node('CompFor')) + obj.add('ast_type', t.string_node('ComptimeFor')) obj.add('val_var', t.string_node(node.val_var)) obj.add('typ', t.type_node(node.typ)) obj.add('kind', t.enum_node(node.kind)) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 88eed350f1..5ad9f8c265 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -65,7 +65,7 @@ pub type Stmt = AsmStmt | AssignStmt | Block | BranchStmt - | CompFor + | ComptimeFor | ConstDecl | DeferStmt | EmptyStmt @@ -898,17 +898,17 @@ pub: post_comments []Comment } -pub enum CompForKind { +pub enum ComptimeForKind { methods fields attributes } -pub struct CompFor { +pub struct ComptimeFor { pub: val_var string stmts []Stmt - kind CompForKind + kind ComptimeForKind pos token.Position typ_pos token.Position pub mut: @@ -1904,7 +1904,7 @@ pub fn (node Node) children() []Node { } } else if node is Stmt { match node { - Block, DeferStmt, ForCStmt, ForInStmt, ForStmt, CompFor { + Block, DeferStmt, ForCStmt, ForInStmt, ForStmt, ComptimeFor { return node.stmts.map(Node(it)) } ExprStmt, AssertStmt { diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 8e06323ce4..16c33b8c54 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -580,7 +580,7 @@ fn field_to_string(f ConstField) string { return '$x = $f.expr' } -pub fn (e CompForKind) str() string { +pub fn (e ComptimeForKind) str() string { match e { .methods { return 'methods' } .fields { return 'fields' } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index e82db9d75a..c995117c9b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -4606,7 +4606,7 @@ fn (mut c Checker) stmt(node ast.Stmt) { ast.BranchStmt { c.branch_stmt(node) } - ast.CompFor { + ast.ComptimeFor { c.comptime_for(node) } ast.ConstDecl { @@ -4783,7 +4783,7 @@ fn (mut c Checker) for_c_stmt(node ast.ForCStmt) { c.in_for_count-- } -fn (mut c Checker) comptime_for(node ast.CompFor) { +fn (mut c Checker) comptime_for(node ast.ComptimeFor) { typ := c.unwrap_generic(node.typ) sym := c.table.get_type_symbol(typ) if sym.kind == .placeholder || typ.has_flag(.generic) { diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index dcade74b6c..ba1fdf2a6b 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -430,7 +430,7 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) { ast.BranchStmt { f.branch_stmt(node) } - ast.CompFor { + ast.ComptimeFor { f.comptime_for(node) } ast.ConstDecl { @@ -762,7 +762,7 @@ pub fn (mut f Fmt) branch_stmt(node ast.BranchStmt) { f.writeln(node.str()) } -pub fn (mut f Fmt) comptime_for(node ast.CompFor) { +pub fn (mut f Fmt) comptime_for(node ast.ComptimeFor) { typ := f.no_cur_mod(f.table.type_to_str_using_aliases(node.typ, f.mod2alias)) f.write('\$for $node.val_var in ${typ}.$node.kind.str() {') f.mark_types_import_as_used(node.typ) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index aa84c135ca..e96b64819c 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1568,7 +1568,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.const_decl(node) // } } - ast.CompFor { + ast.ComptimeFor { g.comptime_for(node) } ast.DeferStmt { diff --git a/vlib/v/gen/c/comptime.v b/vlib/v/gen/c/comptime.v index f623604618..e3ebc6513d 100644 --- a/vlib/v/gen/c/comptime.v +++ b/vlib/v/gen/c/comptime.v @@ -406,7 +406,7 @@ fn (mut g Gen) comptime_if_cond(cond ast.Expr, pkg_exist bool) bool { } } -fn (mut g Gen) comptime_for(node ast.CompFor) { +fn (mut g Gen) comptime_for(node ast.ComptimeFor) { sym := g.table.get_type_symbol(g.unwrap_generic(node.typ)) g.writeln('/* \$for $node.val_var in ${sym.name}($node.kind.str()) */ {') g.indent++ diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index 32f6082c51..e10d8d6111 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -637,7 +637,7 @@ fn (mut g JsGen) stmt_no_semi(node ast.Stmt) { g.write_v_source_line_info(node.pos) g.gen_branch_stmt(node) } - ast.CompFor {} + ast.ComptimeFor {} ast.ConstDecl { g.write_v_source_line_info(node.pos) g.gen_const_decl(node) @@ -740,7 +740,7 @@ fn (mut g JsGen) stmt(node ast.Stmt) { g.write_v_source_line_info(node.pos) g.gen_branch_stmt(node) } - ast.CompFor {} + ast.ComptimeFor {} ast.ConstDecl { g.write_v_source_line_info(node.pos) g.gen_const_decl(node) diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index 6089d44a88..54a5a25c7f 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -92,7 +92,7 @@ pub fn (mut w Walker) stmt(node ast.Stmt) { ast.Block { w.stmts(node.stmts) } - ast.CompFor { + ast.ComptimeFor { w.stmts(node.stmts) } ast.ConstDecl { diff --git a/vlib/v/parser/comptime.v b/vlib/v/parser/comptime.v index 3a9d06c69d..184442e8dd 100644 --- a/vlib/v/parser/comptime.v +++ b/vlib/v/parser/comptime.v @@ -232,7 +232,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall { } } -fn (mut p Parser) comptime_for() ast.CompFor { +fn (mut p Parser) comptime_for() ast.ComptimeFor { // p.comptime_for() handles these special forms: // $for method in App(methods) { // $for field in App(fields) { @@ -247,7 +247,7 @@ fn (mut p Parser) comptime_for() ast.CompFor { typ_pos = typ_pos.extend(p.prev_tok.position()) p.check(.dot) for_val := p.check_name() - mut kind := ast.CompForKind.methods + mut kind := ast.ComptimeForKind.methods p.open_scope() if for_val == 'methods' { p.scope.register(ast.Var{ @@ -272,12 +272,12 @@ fn (mut p Parser) comptime_for() ast.CompFor { } else { p.error_with_pos('unknown kind `$for_val`, available are: `methods`, `fields` or `attributes`', p.prev_tok.position()) - return ast.CompFor{} + return ast.ComptimeFor{} } spos := p.tok.position() stmts := p.parse_block() p.close_scope() - return ast.CompFor{ + return ast.ComptimeFor{ val_var: val_var stmts: stmts kind: kind diff --git a/vlib/v/transformer/transformer.v b/vlib/v/transformer/transformer.v index 06d2a9bc06..6072fe16f5 100644 --- a/vlib/v/transformer/transformer.v +++ b/vlib/v/transformer/transformer.v @@ -43,7 +43,7 @@ pub fn (t Transformer) stmt(mut node ast.Stmt) { } } ast.BranchStmt {} - ast.CompFor {} + ast.ComptimeFor {} ast.ConstDecl { for mut field in node.fields { expr := t.expr(field.expr)