diff --git a/cmd/tools/vast/vast.v b/cmd/tools/vast/vast.v index 912f89e3c1..7826262c6b 100644 --- a/cmd/tools/vast/vast.v +++ b/cmd/tools/vast/vast.v @@ -130,30 +130,30 @@ mut: // tree node pub type Node = C.cJSON -// add item to object node -[inline] -fn (node &Node) add(key string, child &Node) { - add_item_to_object(node, key, child) -} - -// add item to array node -[inline] -fn (node &Node) add_item(child &Node) { - add_item_to_array(node, child) -} - // create an object node [inline] fn new_object() &Node { return C.cJSON_CreateObject() } +// add item to object node +[inline] +fn (node &Node) add(key string, child &Node) { + add_item_to_object(node, key, child) +} + // create an array node [inline] fn new_array() &Node { return C.cJSON_CreateArray() } +// add item to array node +[inline] +fn (node &Node) add_item(child &Node) { + add_item_to_array(node, child) +} + // string type node fn (t Tree) string_node(val string) &Node { return create_string(val) @@ -200,9 +200,9 @@ fn (t Tree) enum_node(value T) &Node { // for [][]comment fn (t Tree) two_dimension_comment(node [][]ast.Comment) &Node { - comments := new_array() + mut comments := new_array() for n in node { - comment_array := new_array() + mut comment_array := new_array() for c in n { comment_array.add_item(t.comment(c)) } @@ -213,12 +213,12 @@ fn (t Tree) two_dimension_comment(node [][]ast.Comment) &Node { // ast file root node fn (t Tree) ast_file(node ast.File) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ast.File')) obj.add('path', t.string_node(node.path)) obj.add('path_base', t.string_node(node.path_base)) - obj.add('lines', t.number_node(node.nr_lines)) - obj.add('bytes', t.number_node(node.nr_bytes)) + obj.add('nr_lines', t.number_node(node.nr_lines)) + obj.add('nr_bytes', t.number_node(node.nr_bytes)) obj.add('mod', t.mod(node.mod)) obj.add('imports', t.imports(node.imports)) obj.add('global_scope', t.scope(node.global_scope)) @@ -227,13 +227,11 @@ fn (t Tree) ast_file(node ast.File) &Node { obj.add('warnings', t.warnings(node.warnings)) obj.add('notices', t.notices(node.notices)) obj.add('auto_imports', t.array_node_string(node.auto_imports)) - symbol_obj := new_object() for key, val in node.imported_symbols { symbol_obj.add(key, t.string_node(val)) } obj.add('imported_symbols', symbol_obj) - obj.add('generic_fns', t.array_node_generic_fns(node.generic_fns)) obj.add('embedded_files', t.array_node_embed_file(node.embedded_files)) obj.add('global_labels', t.array_node_string(node.global_labels)) @@ -244,7 +242,7 @@ fn (t Tree) ast_file(node ast.File) &Node { // embed files fn (t Tree) embed_file(node ast.EmbeddedFile) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EmbeddedFile')) obj.add('rpath', t.string_node(node.rpath)) obj.add('apath', t.string_node(node.apath)) @@ -253,18 +251,19 @@ fn (t Tree) embed_file(node ast.EmbeddedFile) &Node { // ast module node fn (t Tree) mod(node ast.Module) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Module')) obj.add('name', t.string_node(node.name)) obj.add('short_name', t.string_node(node.short_name)) - obj.add('is_skipped', t.bool_node(node.is_skipped)) obj.add('attrs', t.array_node_attr(node.attrs)) obj.add('pos', t.position(node.pos)) + obj.add('name_pos', t.position(node.name_pos)) + obj.add('is_skipped', t.bool_node(node.is_skipped)) return obj } fn (t Tree) scope(scope ast.Scope) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Scope')) obj.add('parent', t.string_node(ptr_str(scope.parent))) children_arr := new_array() @@ -284,7 +283,7 @@ fn (t Tree) scope(scope ast.Scope) &Node { } fn (t Tree) scope_struct_field(node ast.ScopeStructField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ScopeStructField')) obj.add('struct_type', t.type_node(node.struct_type)) obj.add('name', t.string_node(node.name)) @@ -296,7 +295,7 @@ fn (t Tree) scope_struct_field(node ast.ScopeStructField) &Node { } fn (t Tree) objects(so map[string]ast.ScopeObject) &Node { - obj := new_object() + mut obj := new_object() for key, val in so { obj.add(key, t.scope_object(val)) } @@ -304,7 +303,7 @@ fn (t Tree) objects(so map[string]ast.ScopeObject) &Node { } fn (t Tree) scope_object(node ast.ScopeObject) &Node { - obj := new_object() + mut obj := new_object() match node { ast.ConstField { t.const_field(node) } ast.GlobalField { t.global_field(node) } @@ -314,16 +313,16 @@ fn (t Tree) scope_object(node ast.ScopeObject) &Node { return obj } -fn (t Tree) imports(imports []ast.Import) &Node { - import_array := new_array() - for imp in imports { - import_array.add_item(t.import_module(imp)) +fn (t Tree) imports(nodes []ast.Import) &Node { + mut import_array := new_array() + for node in nodes { + import_array.add_item(t.import_module(node)) } return import_array } fn (t Tree) errors(errors []errors.Error) &Node { - errs := new_array() + mut errs := new_array() for e in errors { obj := new_object() obj.add('message', t.string_node(e.message)) @@ -337,9 +336,9 @@ fn (t Tree) errors(errors []errors.Error) &Node { } fn (t Tree) warnings(warnings []errors.Warning) &Node { - warns := new_array() + mut warns := new_array() for w in warnings { - obj := new_object() + mut obj := new_object() obj.add('message', t.string_node(w.message)) obj.add('file_path', t.string_node(w.file_path)) obj.add('pos', t.position(w.pos)) @@ -350,9 +349,9 @@ fn (t Tree) warnings(warnings []errors.Warning) &Node { } fn (t Tree) notices(notices []errors.Notice) &Node { - notice_array := new_array() + mut notice_array := new_array() for n in notices { - obj := new_object() + mut obj := new_object() obj.add('message', t.string_node(n.message)) obj.add('file_path', t.string_node(n.file_path)) obj.add('pos', t.position(n.pos)) @@ -364,7 +363,7 @@ fn (t Tree) notices(notices []errors.Notice) &Node { // stmt array node fn (t Tree) stmts(stmts []ast.Stmt) &Node { - stmt_array := new_array() + mut stmt_array := new_array() for s in stmts { stmt_array.add_item(t.stmt(s)) } @@ -405,7 +404,7 @@ fn (t Tree) stmt(node ast.Stmt) &Node { } fn (t Tree) import_module(node ast.Import) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Import')) obj.add('mod', t.string_node(node.mod)) obj.add('alias', t.string_node(node.alias)) @@ -420,14 +419,14 @@ fn (t Tree) import_module(node ast.Import) &Node { } fn (t Tree) import_symbol(node ast.ImportSymbol) &Node { - obj := new_object() + mut obj := new_object() obj.add('name', t.string_node(node.name)) obj.add('pos', t.position(node.pos)) return obj } fn (t Tree) position(p token.Position) &Node { - obj := new_object() + mut obj := new_object() obj.add('line_nr', t.number_node(p.line_nr)) obj.add('pos', t.number_node(p.pos)) obj.add('len', t.number_node(p.len)) @@ -435,7 +434,7 @@ fn (t Tree) position(p token.Position) &Node { } fn (t Tree) comment(node ast.Comment) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Comment')) obj.add('text', t.string_node(node.text)) obj.add('is_multi', t.bool_node(node.is_multi)) @@ -445,7 +444,7 @@ fn (t Tree) comment(node ast.Comment) &Node { } fn (t Tree) const_decl(node ast.ConstDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ConstDecl')) obj.add('is_pub', t.bool_node(node.is_pub)) obj.add('is_block', t.bool_node(node.is_block)) @@ -456,7 +455,7 @@ fn (t Tree) const_decl(node ast.ConstDecl) &Node { } fn (t Tree) const_field(node ast.ConstField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ConstField')) obj.add('mod', t.string_node(node.mod)) obj.add('name', t.string_node(node.name)) @@ -470,7 +469,7 @@ fn (t Tree) const_field(node ast.ConstField) &Node { // function declaration fn (t Tree) fn_decl(node ast.FnDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('FnDecl')) obj.add('name', t.string_node(node.name)) obj.add('mod', t.string_node(node.mod)) @@ -515,7 +514,7 @@ fn (t Tree) fn_decl(node ast.FnDecl) &Node { } fn (t Tree) anon_fn(node ast.AnonFn) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AnonFn')) obj.add('decl', t.fn_decl(node.decl)) obj.add('typ', t.type_node(node.typ)) @@ -524,7 +523,7 @@ fn (t Tree) anon_fn(node ast.AnonFn) &Node { } fn (t Tree) struct_decl(node ast.StructDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StructDecl')) obj.add('name', t.string_node(node.name)) obj.add('is_pub', t.bool_node(node.is_pub)) @@ -545,7 +544,7 @@ fn (t Tree) struct_decl(node ast.StructDecl) &Node { } fn (t Tree) struct_field(node ast.StructField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StructField')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -563,7 +562,7 @@ fn (t Tree) struct_field(node ast.StructField) &Node { } fn (t Tree) embed(node ast.Embed) &Node { - obj := new_object() + mut obj := new_object() obj.add('typ', t.type_node(node.typ)) obj.add('pos', t.position(node.pos)) obj.add('comments', t.array_node_comment(node.comments)) @@ -571,7 +570,7 @@ fn (t Tree) embed(node ast.Embed) &Node { } fn (t Tree) enum_decl(node ast.EnumDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EnumDecl')) obj.add('name', t.string_node(node.name)) obj.add('is_pub', t.bool_node(node.is_pub)) @@ -585,7 +584,7 @@ fn (t Tree) enum_decl(node ast.EnumDecl) &Node { } fn (t Tree) enum_field(node ast.EnumField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EnumField')) obj.add('name', t.string_node(node.name)) obj.add('has_expr', t.bool_node(node.has_expr)) @@ -597,7 +596,7 @@ fn (t Tree) enum_field(node ast.EnumField) &Node { } fn (t Tree) interface_decl(node ast.InterfaceDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('InterfaceDecl')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -616,7 +615,7 @@ fn (t Tree) interface_decl(node ast.InterfaceDecl) &Node { } fn (t Tree) interface_embedding(node ast.InterfaceEmbedding) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('InterfaceEmbedding')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -626,7 +625,7 @@ fn (t Tree) interface_embedding(node ast.InterfaceEmbedding) &Node { } fn (t Tree) attr(node ast.Attr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Attr')) obj.add('name', t.string_node(node.name)) obj.add('has_arg', t.bool_node(node.has_arg)) @@ -636,7 +635,7 @@ fn (t Tree) attr(node ast.Attr) &Node { } fn (t Tree) hash_stmt(node ast.HashStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('HashStmt')) obj.add('mod', t.string_node(node.mod)) obj.add('val', t.string_node(node.val)) @@ -649,7 +648,7 @@ fn (t Tree) hash_stmt(node ast.HashStmt) &Node { } fn (t Tree) comp_for(node ast.CompFor) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('CompFor')) obj.add('val_var', t.string_node(node.val_var)) obj.add('typ', t.type_node(node.typ)) @@ -661,7 +660,7 @@ fn (t Tree) comp_for(node ast.CompFor) &Node { } fn (t Tree) global_decl(node ast.GlobalDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('GlobalDecl')) obj.add('pos', t.position(node.pos)) obj.add('is_block', t.bool_node(node.is_block)) @@ -671,7 +670,7 @@ fn (t Tree) global_decl(node ast.GlobalDecl) &Node { } fn (t Tree) global_field(node ast.GlobalField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('GlobalField')) obj.add('name', t.string_node(node.name)) obj.add('expr', t.expr(node.expr)) @@ -684,7 +683,7 @@ fn (t Tree) global_field(node ast.GlobalField) &Node { } fn (t Tree) defer_stmt(node ast.DeferStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('DeferStmt')) obj.add('stmts', t.array_node_stmt(node.stmts)) obj.add('defer_vars', t.array_node_ident(node.defer_vars)) @@ -703,7 +702,7 @@ fn (t Tree) type_decl(node ast.TypeDecl) &Node { } fn (t Tree) alias_type_decl(node ast.AliasTypeDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AliasTypeDecl')) obj.add('name', t.string_node(node.name)) obj.add('is_pub', t.bool_node(node.is_pub)) @@ -714,7 +713,7 @@ fn (t Tree) alias_type_decl(node ast.AliasTypeDecl) &Node { } fn (t Tree) sum_type_decl(node ast.SumTypeDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SumTypeDecl')) obj.add('name', t.string_node(node.name)) obj.add('is_pub', t.bool_node(node.is_pub)) @@ -734,7 +733,7 @@ fn (t Tree) sum_type_decl(node ast.SumTypeDecl) &Node { } fn (t Tree) fn_type_decl(node ast.FnTypeDecl) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('FnTypeDecl')) obj.add('name', t.string_node(node.name)) obj.add('is_pub', t.bool_node(node.is_pub)) @@ -745,7 +744,7 @@ fn (t Tree) fn_type_decl(node ast.FnTypeDecl) &Node { } fn (t Tree) arg(node ast.Param) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Param')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -754,7 +753,7 @@ fn (t Tree) arg(node ast.Param) &Node { } fn (t Tree) goto_label(node ast.GotoLabel) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('GotoLabel')) obj.add('name', t.string_node(node.name)) obj.add('pos', t.position(node.pos)) @@ -762,7 +761,7 @@ fn (t Tree) goto_label(node ast.GotoLabel) &Node { } fn (t Tree) goto_stmt(node ast.GotoStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('GotoStmt')) obj.add('name', t.string_node(node.name)) obj.add('pos', t.position(node.pos)) @@ -770,7 +769,7 @@ fn (t Tree) goto_stmt(node ast.GotoStmt) &Node { } fn (t Tree) assign_stmt(node ast.AssignStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AssignStmt')) obj.add('left', t.array_node_expr(node.left)) obj.add('left_types', t.array_node_type(node.left_types)) @@ -787,7 +786,7 @@ fn (t Tree) assign_stmt(node ast.AssignStmt) &Node { } fn (t Tree) var(node ast.Var) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Var')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -810,7 +809,7 @@ fn (t Tree) var(node ast.Var) &Node { } fn (t Tree) return_(node ast.Return) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Return')) obj.add('exprs', t.array_node_expr(node.exprs)) obj.add('types', t.array_node_type(node.types)) @@ -819,7 +818,7 @@ fn (t Tree) return_(node ast.Return) &Node { } fn (t Tree) for_c_stmt(node ast.ForCStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ForCStmt')) obj.add('init', t.stmt(node.init)) obj.add('has_init', t.bool_node(node.has_init)) @@ -836,7 +835,7 @@ fn (t Tree) for_c_stmt(node ast.ForCStmt) &Node { } fn (t Tree) for_stmt(node ast.ForStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ForStmt')) obj.add('cond', t.expr(node.cond)) obj.add('is_inf', t.bool_node(node.is_inf)) @@ -848,7 +847,7 @@ fn (t Tree) for_stmt(node ast.ForStmt) &Node { } fn (t Tree) for_in_stmt(node ast.ForInStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ForInStmt')) obj.add('key_var', t.string_node(node.key_var)) obj.add('val_var', t.string_node(node.val_var)) @@ -868,7 +867,7 @@ fn (t Tree) for_in_stmt(node ast.ForInStmt) &Node { } fn (t Tree) branch_stmt(node ast.BranchStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('BranchStmt')) obj.add('kind', t.token_node(node.kind)) obj.add('label', t.string_node(node.label)) @@ -877,7 +876,7 @@ fn (t Tree) branch_stmt(node ast.BranchStmt) &Node { } fn (t Tree) assert_stmt(node ast.AssertStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AssertStmt')) obj.add('expr', t.expr(node.expr)) obj.add('is_used', t.bool_node(node.is_used)) @@ -886,7 +885,7 @@ fn (t Tree) assert_stmt(node ast.AssertStmt) &Node { } fn (t Tree) block(node ast.Block) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Block')) obj.add('stmts', t.array_node_stmt(node.stmts)) obj.add('is_unsafe', t.bool_node(node.is_unsafe)) @@ -895,7 +894,7 @@ fn (t Tree) block(node ast.Block) &Node { } fn (t Tree) comptime_call(node ast.ComptimeCall) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ComptimeCall')) obj.add('method_name', t.string_node(node.method_name)) obj.add('left', t.expr(node.left)) @@ -916,7 +915,7 @@ fn (t Tree) comptime_call(node ast.ComptimeCall) &Node { } fn (t Tree) comptime_selector(node ast.ComptimeSelector) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ComptimeSelector')) obj.add('has_parens', t.bool_node(node.has_parens)) obj.add('left', t.expr(node.left)) @@ -928,7 +927,7 @@ fn (t Tree) comptime_selector(node ast.ComptimeSelector) &Node { } fn (t Tree) expr_stmt(node ast.ExprStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ExprStmt')) obj.add('typ', t.type_node(node.typ)) obj.add('is_expr', t.bool_node(node.is_expr)) @@ -1093,7 +1092,7 @@ fn (t Tree) expr(expr ast.Expr) &Node { } fn (t Tree) integer_literal(node ast.IntegerLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IntegerLiteral')) obj.add('val', t.string_node(node.val)) obj.add('pos', t.position(node.pos)) @@ -1101,7 +1100,7 @@ fn (t Tree) integer_literal(node ast.IntegerLiteral) &Node { } fn (t Tree) float_literal(node ast.FloatLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('FloatLiteral')) obj.add('val', t.string_node(node.val)) obj.add('pos', t.position(node.pos)) @@ -1109,7 +1108,7 @@ fn (t Tree) float_literal(node ast.FloatLiteral) &Node { } fn (t Tree) string_literal(node ast.StringLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StringLiteral')) obj.add('val', t.string_node(node.val)) obj.add('is_raw', t.bool_node(node.is_raw)) @@ -1119,7 +1118,7 @@ fn (t Tree) string_literal(node ast.StringLiteral) &Node { } fn (t Tree) char_literal(node ast.CharLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('CharLiteral')) obj.add('val', t.string_node(node.val)) obj.add('pos', t.position(node.pos)) @@ -1127,7 +1126,7 @@ fn (t Tree) char_literal(node ast.CharLiteral) &Node { } fn (t Tree) bool_literal(node ast.BoolLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('BoolLiteral')) obj.add('val', t.bool_node(node.val)) obj.add('pos', t.position(node.pos)) @@ -1135,7 +1134,7 @@ fn (t Tree) bool_literal(node ast.BoolLiteral) &Node { } fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StringInterLiteral')) obj.add('vals', t.array_node_string(node.vals)) obj.add('exprs', t.array_node_expr(node.exprs)) @@ -1152,7 +1151,7 @@ fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node { } fn (t Tree) enum_val(node ast.EnumVal) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EnumVal')) obj.add('enum_name', t.string_node(node.enum_name)) obj.add('mod', t.string_node(node.mod)) @@ -1163,7 +1162,7 @@ fn (t Tree) enum_val(node ast.EnumVal) &Node { } fn (t Tree) assoc(node ast.Assoc) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Assoc')) obj.add('var_name', t.string_node(node.var_name)) obj.add('fields', t.array_node_string(node.fields)) @@ -1175,7 +1174,7 @@ fn (t Tree) assoc(node ast.Assoc) &Node { } fn (t Tree) at_expr(node ast.AtExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AtExpr')) obj.add('name', t.string_node(node.name)) obj.add('pos', t.position(node.pos)) @@ -1185,7 +1184,7 @@ fn (t Tree) at_expr(node ast.AtExpr) &Node { } fn (t Tree) cast_expr(node ast.CastExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('CastExpr')) obj.add('expr', t.expr(node.expr)) obj.add('arg', t.expr(node.arg)) @@ -1199,7 +1198,7 @@ fn (t Tree) cast_expr(node ast.CastExpr) &Node { } fn (t Tree) as_cast(node ast.AsCast) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsCast')) obj.add('expr', t.expr(node.expr)) obj.add('typ', t.type_node(node.typ)) @@ -1209,7 +1208,7 @@ fn (t Tree) as_cast(node ast.AsCast) &Node { } fn (t Tree) type_expr(node ast.TypeNode) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('TypeNode')) obj.add('typ', t.type_node(node.typ)) obj.add('pos', t.position(node.pos)) @@ -1217,7 +1216,7 @@ fn (t Tree) type_expr(node ast.TypeNode) &Node { } fn (t Tree) size_of(node ast.SizeOf) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SizeOf')) obj.add('is_type', t.bool_node(node.is_type)) obj.add('typ', t.type_node(node.typ)) @@ -1227,7 +1226,7 @@ fn (t Tree) size_of(node ast.SizeOf) &Node { } fn (t Tree) prefix_expr(node ast.PrefixExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('PrefixExpr')) obj.add('op', t.token_node(node.op)) obj.add('right', t.expr(node.right)) @@ -1239,7 +1238,7 @@ fn (t Tree) prefix_expr(node ast.PrefixExpr) &Node { } fn (t Tree) infix_expr(node ast.InfixExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('InfixExpr')) obj.add('op', t.token_node(node.op)) obj.add('left', t.expr(node.left)) @@ -1254,7 +1253,7 @@ fn (t Tree) infix_expr(node ast.InfixExpr) &Node { } fn (t Tree) index_expr(node ast.IndexExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IndexExpr')) obj.add('left', t.expr(node.left)) obj.add('left_type', t.type_node(node.left_type)) @@ -1266,7 +1265,7 @@ fn (t Tree) index_expr(node ast.IndexExpr) &Node { } fn (t Tree) postfix_expr(node ast.PostfixExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('PostfixExpr')) obj.add('op', t.token_node(node.op)) obj.add('expr', t.expr(node.expr)) @@ -1276,7 +1275,7 @@ fn (t Tree) postfix_expr(node ast.PostfixExpr) &Node { } fn (t Tree) selector_expr(node ast.SelectorExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SelectorExpr')) obj.add('expr', t.expr(node.expr)) obj.add('expr_type', t.type_node(node.expr_type)) @@ -1291,7 +1290,7 @@ fn (t Tree) selector_expr(node ast.SelectorExpr) &Node { } fn (t Tree) range_expr(node ast.RangeExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('RangeExpr')) obj.add('low', t.expr(node.low)) obj.add('high', t.expr(node.high)) @@ -1302,7 +1301,7 @@ fn (t Tree) range_expr(node ast.RangeExpr) &Node { } fn (t Tree) if_expr(node ast.IfExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IfExpr')) obj.add('is_comptime', t.bool_node(node.is_comptime)) obj.add('tok_kind', t.token_node(node.tok_kind)) @@ -1317,7 +1316,7 @@ fn (t Tree) if_expr(node ast.IfExpr) &Node { } fn (t Tree) if_branch(node ast.IfBranch) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IfBranch')) obj.add('cond', t.expr(node.cond)) obj.add('pos', t.position(node.pos)) @@ -1329,7 +1328,7 @@ fn (t Tree) if_branch(node ast.IfBranch) &Node { } fn (t Tree) ident(node ast.Ident) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Ident')) obj.add('mod', t.string_node(node.mod)) obj.add('name', t.string_node(node.name)) @@ -1346,15 +1345,15 @@ fn (t Tree) ident(node ast.Ident) &Node { return obj } -fn (t Tree) ident_info(info ast.IdentInfo) &Node { - match info { - ast.IdentVar { return t.ident_var(info) } - ast.IdentFn { return t.ident_fn(info) } +fn (t Tree) ident_info(node ast.IdentInfo) &Node { + match node { + ast.IdentVar { return t.ident_var(node) } + ast.IdentFn { return t.ident_fn(node) } } } fn (t Tree) ident_var(node ast.IdentVar) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IdentVar')) obj.add('typ', t.type_node(node.typ)) obj.add('is_mut', t.bool_node(node.is_mut)) @@ -1365,14 +1364,14 @@ fn (t Tree) ident_var(node ast.IdentVar) &Node { } fn (t Tree) ident_fn(node ast.IdentFn) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IdentFn')) obj.add('typ', t.type_node(node.typ)) return obj } fn (t Tree) call_expr(node ast.CallExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('CallExpr')) obj.add('left', t.expr(node.left)) obj.add('is_method', t.bool_node(node.is_method)) @@ -1398,7 +1397,7 @@ fn (t Tree) call_expr(node ast.CallExpr) &Node { } fn (t Tree) call_arg(node ast.CallArg) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('CallArg')) obj.add('typ', t.type_node(node.typ)) obj.add('is_mut', t.bool_node(node.is_mut)) @@ -1411,7 +1410,7 @@ fn (t Tree) call_arg(node ast.CallArg) &Node { } fn (t Tree) or_expr(node ast.OrExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('OrExpr')) obj.add('stmts', t.array_node_stmt(node.stmts)) obj.add('kind', t.enum_node(node.kind)) @@ -1420,7 +1419,7 @@ fn (t Tree) or_expr(node ast.OrExpr) &Node { } fn (t Tree) struct_init(node ast.StructInit) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StructInit')) obj.add('typ', t.type_node(node.typ)) obj.add('is_short', t.bool_node(node.is_short)) @@ -1438,7 +1437,7 @@ fn (t Tree) struct_init(node ast.StructInit) &Node { } fn (t Tree) struct_init_field(node ast.StructInitField) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StructInitField')) obj.add('name', t.string_node(node.name)) obj.add('expr', t.expr(node.expr)) @@ -1453,7 +1452,7 @@ fn (t Tree) struct_init_field(node ast.StructInitField) &Node { } fn (t Tree) struct_init_embed(node ast.StructInitEmbed) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('StructInitEmbed')) obj.add('name', t.string_node(node.name)) obj.add('expr', t.expr(node.expr)) @@ -1466,7 +1465,7 @@ fn (t Tree) struct_init_embed(node ast.StructInitEmbed) &Node { } fn (t Tree) array_init(node ast.ArrayInit) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ArrayInit')) obj.add('typ', t.type_node(node.typ)) obj.add('elem_type', t.type_node(node.elem_type)) @@ -1489,7 +1488,7 @@ fn (t Tree) array_init(node ast.ArrayInit) &Node { } fn (t Tree) map_init(node ast.MapInit) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('MapInit')) obj.add('typ', t.type_node(node.typ)) obj.add('key_type', t.type_node(node.key_type)) @@ -1503,14 +1502,14 @@ fn (t Tree) map_init(node ast.MapInit) &Node { } fn (t Tree) none_expr(node ast.None) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('None')) obj.add('pos', t.position(node.pos)) return obj } fn (t Tree) par_expr(node ast.ParExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ParExpr')) obj.add('expr', t.expr(node.expr)) obj.add('pos', t.position(node.pos)) @@ -1518,7 +1517,7 @@ fn (t Tree) par_expr(node ast.ParExpr) &Node { } fn (t Tree) if_guard_expr(node ast.IfGuardExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('IfGuardExpr')) obj.add('var_name', t.string_node(node.var_name)) obj.add('expr', t.expr(node.expr)) @@ -1528,7 +1527,7 @@ fn (t Tree) if_guard_expr(node ast.IfGuardExpr) &Node { } fn (t Tree) match_expr(node ast.MatchExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('MatchExpr')) obj.add('tok_kind', t.token_node(node.tok_kind)) obj.add('cond', t.expr(node.cond)) @@ -1544,7 +1543,7 @@ fn (t Tree) match_expr(node ast.MatchExpr) &Node { } fn (t Tree) match_branch(node ast.MatchBranch) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('MatchBranch')) obj.add('exprs', t.array_node_expr(node.exprs)) obj.add('ecmnts', t.two_dimension_comment(node.ecmnts)) @@ -1557,7 +1556,7 @@ fn (t Tree) match_branch(node ast.MatchBranch) &Node { } fn (t Tree) concat_expr(node ast.ConcatExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ConcatExpr')) obj.add('vals', t.array_node_expr(node.vals)) obj.add('return_type', t.type_node(node.return_type)) @@ -1566,7 +1565,7 @@ fn (t Tree) concat_expr(node ast.ConcatExpr) &Node { } fn (t Tree) type_of(node ast.TypeOf) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('TypeOf')) obj.add('expr', t.expr(node.expr)) obj.add('expr_type', t.type_node(node.expr_type)) @@ -1575,7 +1574,7 @@ fn (t Tree) type_of(node ast.TypeOf) &Node { } fn (t Tree) likely(node ast.Likely) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('Likely')) obj.add('expr', t.expr(node.expr)) obj.add('is_likely', t.bool_node(node.is_likely)) @@ -1584,7 +1583,7 @@ fn (t Tree) likely(node ast.Likely) &Node { } fn (t Tree) sql_expr(node ast.SqlExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SqlExpr')) obj.add('type', t.type_node(node.typ)) obj.add('is_count', t.bool_node(node.is_count)) @@ -1611,7 +1610,7 @@ fn (t Tree) sql_expr(node ast.SqlExpr) &Node { } fn (t Tree) sql_stmt(node ast.SqlStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SqlStmt')) obj.add('db_expr', t.expr(node.db_expr)) obj.add('pos', t.position(node.pos)) @@ -1620,7 +1619,7 @@ fn (t Tree) sql_stmt(node ast.SqlStmt) &Node { } fn (t Tree) sql_stmt_line(node ast.SqlStmtLine) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SqlStmtLine')) obj.add('kind', t.enum_node(node.kind)) obj.add('table_expr', t.type_expr(node.table_expr)) @@ -1639,20 +1638,20 @@ fn (t Tree) sql_stmt_line(node ast.SqlStmtLine) &Node { return obj } -fn (t Tree) lock_expr(node ast.LockExpr) &Node { - obj := new_object() +fn (t Tree) lock_expr(expr ast.LockExpr) &Node { + mut obj := new_object() obj.add('ast_type', t.string_node('LockExpr')) - obj.add('is_expr', t.bool_node(node.is_expr)) - obj.add('typ', t.type_node(node.typ)) - obj.add('pos', t.position(node.pos)) - obj.add('stmts', t.array_node_stmt(node.stmts)) - obj.add('lockeds', t.array_node_expr(node.lockeds)) - obj.add('r_lock', t.array_node_bool(node.is_rlock)) + obj.add('is_expr', t.bool_node(expr.is_expr)) + obj.add('typ', t.type_node(expr.typ)) + obj.add('pos', t.position(expr.pos)) + obj.add('stmts', t.array_node_stmt(expr.stmts)) + obj.add('lockeds', t.array_node_expr(expr.lockeds)) + obj.add('r_lock', t.array_node_bool(expr.is_rlock)) return obj } fn (t Tree) unsafe_expr(expr ast.UnsafeExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('UnsafeExpr')) obj.add('expr', t.expr(expr.expr)) obj.add('pos', t.position(expr.pos)) @@ -1660,7 +1659,7 @@ fn (t Tree) unsafe_expr(expr ast.UnsafeExpr) &Node { } fn (t Tree) chan_init(expr ast.ChanInit) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ChanInit')) obj.add('has_cap', t.bool_node(expr.has_cap)) obj.add('cap_expr', t.expr(expr.cap_expr)) @@ -1671,7 +1670,7 @@ fn (t Tree) chan_init(expr ast.ChanInit) &Node { } fn (t Tree) select_expr(expr ast.SelectExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SelectExpr')) obj.add('branches', t.array_node_select_branch(expr.branches)) obj.add('is_expr', t.bool_node(expr.is_expr)) @@ -1682,7 +1681,7 @@ fn (t Tree) select_expr(expr ast.SelectExpr) &Node { } fn (t Tree) select_branch(expr ast.SelectBranch) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('SelectBranch')) obj.add('stmt', t.stmt(expr.stmt)) obj.add('stmts', t.array_node_stmt(expr.stmts)) @@ -1695,7 +1694,7 @@ fn (t Tree) select_branch(expr ast.SelectBranch) &Node { } fn (t Tree) array_decompose(expr ast.ArrayDecompose) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('ArrayDecompose')) obj.add('expr', t.expr(expr.expr)) obj.add('expr_type', t.type_node(expr.expr_type)) @@ -1705,7 +1704,7 @@ fn (t Tree) array_decompose(expr ast.ArrayDecompose) &Node { } fn (t Tree) go_expr(expr ast.GoExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('GoExpr')) obj.add('call_expr', t.call_expr(expr.call_expr)) obj.add('is_expr', t.bool_node(expr.is_expr)) @@ -1714,7 +1713,7 @@ fn (t Tree) go_expr(expr ast.GoExpr) &Node { } fn (t Tree) offset_of(expr ast.OffsetOf) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('OffsetOf')) obj.add('struct_type', t.type_node(expr.struct_type)) obj.add('field', t.string_node('field')) @@ -1723,7 +1722,7 @@ fn (t Tree) offset_of(expr ast.OffsetOf) &Node { } fn (t Tree) dump_expr(expr ast.DumpExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('DumpExpr')) obj.add('expr', t.expr(expr.expr)) obj.add('expr_type', t.type_node(expr.expr_type)) @@ -1732,7 +1731,7 @@ fn (t Tree) dump_expr(expr ast.DumpExpr) &Node { } fn (t Tree) node_error(expr ast.NodeError) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('NodeError')) obj.add('idx', t.number_node(expr.idx)) obj.add('pos', t.position(expr.pos)) @@ -1740,21 +1739,21 @@ fn (t Tree) node_error(expr ast.NodeError) &Node { } fn (t Tree) empty_expr(expr ast.EmptyExpr) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EmptyExpr')) // obj.add('x', t.number_node(expr.x)) return obj } fn (t Tree) empty_stmt(node ast.EmptyStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('EmptyStmt')) obj.add('pos', t.position(node.pos)) return obj } fn (t Tree) asm_stmt(node ast.AsmStmt) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmStmt')) obj.add('arch', t.enum_node(node.arch)) obj.add('is_top_level', t.bool_node(node.is_top_level)) @@ -1773,7 +1772,7 @@ fn (t Tree) asm_stmt(node ast.AsmStmt) &Node { } fn (t Tree) asm_register(node ast.AsmRegister) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmRegister')) obj.add('name', t.string_node(node.name)) obj.add('typ', t.type_node(node.typ)) @@ -1782,7 +1781,7 @@ fn (t Tree) asm_register(node ast.AsmRegister) &Node { } fn (t Tree) asm_template(node ast.AsmTemplate) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmTemplate')) obj.add('name', t.string_node(node.name)) obj.add('is_label', t.bool_node(node.is_label)) @@ -1794,7 +1793,7 @@ fn (t Tree) asm_template(node ast.AsmTemplate) &Node { } fn (t Tree) asm_addressing(node ast.AsmAddressing) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmAddressing')) obj.add('scale', t.number_node(node.scale)) obj.add('mode', t.enum_node(node.mode)) @@ -1838,7 +1837,7 @@ fn (t Tree) asm_arg(node ast.AsmArg) &Node { } fn (t Tree) asm_alias(node ast.AsmAlias) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmAlias')) obj.add('name', t.string_node(node.name)) obj.add('pos', t.position(node.pos)) @@ -1846,7 +1845,7 @@ fn (t Tree) asm_alias(node ast.AsmAlias) &Node { } fn (t Tree) asm_disp(node ast.AsmDisp) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmDisp')) obj.add('val', t.string_node(node.val)) obj.add('pos', t.position(node.pos)) @@ -1854,7 +1853,7 @@ fn (t Tree) asm_disp(node ast.AsmDisp) &Node { } fn (t Tree) asm_clobbered(node ast.AsmClobbered) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmClobbered')) obj.add('reg', t.asm_register(node.reg)) obj.add('comments', t.array_node_comment(node.comments)) @@ -1862,7 +1861,7 @@ fn (t Tree) asm_clobbered(node ast.AsmClobbered) &Node { } fn (t Tree) asm_io(node ast.AsmIO) &Node { - obj := new_object() + mut obj := new_object() obj.add('ast_type', t.string_node('AsmIO')) obj.add('alias', t.string_node(node.alias)) obj.add('constraint', t.string_node(node.constraint))