1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast: clean up ast.StructInit (#18387)

This commit is contained in:
yuyi 2023-06-09 22:43:21 +08:00 committed by GitHub
parent 7a25c03aa7
commit dd1d5bca1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 41 deletions

View File

@ -1567,7 +1567,6 @@ fn (t Tree) struct_init(node ast.StructInit) &Node {
obj.add('name_pos', t.pos(node.name_pos)) obj.add('name_pos', t.pos(node.name_pos))
obj.add('update_expr_comments', t.array_node_comment(node.update_expr_comments)) obj.add('update_expr_comments', t.array_node_comment(node.update_expr_comments))
obj.add_terse('fields', t.array_node_struct_init_field(node.fields)) obj.add_terse('fields', t.array_node_struct_init_field(node.fields))
obj.add_terse('embeds', t.array_node_struct_init_embed(node.embeds))
obj.add('pre_comments', t.array_node_comment(node.pre_comments)) obj.add('pre_comments', t.array_node_comment(node.pre_comments))
return obj return obj
} }
@ -1587,19 +1586,6 @@ fn (t Tree) struct_init_field(node ast.StructInitField) &Node {
return obj return obj
} }
fn (t Tree) struct_init_embed(node ast.StructInitEmbed) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('StructInitEmbed'))
obj.add_terse('name', t.string_node(node.name))
obj.add_terse('expr', t.expr(node.expr))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('expected_type', t.type_node(node.expected_type))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('next_comments', t.array_node_comment(node.next_comments))
obj.add('pos', t.pos(node.pos))
return obj
}
fn (t Tree) array_init(node ast.ArrayInit) &Node { fn (t Tree) array_init(node ast.ArrayInit) &Node {
mut obj := new_object() mut obj := new_object()
obj.add_terse('ast_type', t.string_node('ArrayInit')) obj.add_terse('ast_type', t.string_node('ArrayInit'))
@ -2306,14 +2292,6 @@ fn (t Tree) array_node_if_guard_var(nodes []ast.IfGuardVar) &Node {
return arr return arr
} }
fn (t Tree) array_node_struct_init_embed(nodes []ast.StructInitEmbed) &Node {
mut arr := new_array()
for node in nodes {
arr.add_item(t.struct_init_embed(node))
}
return arr
}
fn (t Tree) array_node_match_branch(nodes []ast.MatchBranch) &Node { fn (t Tree) array_node_match_branch(nodes []ast.MatchBranch) &Node {
mut arr := new_array() mut arr := new_array()
for node in nodes { for node in nodes {

View File

@ -437,18 +437,6 @@ pub mut:
parent_type Type parent_type Type
} }
pub struct StructInitEmbed {
pub:
pos token.Pos
comments []Comment
next_comments []Comment
pub mut:
expr Expr
name string
typ Type
expected_type Type
}
// `s := Foo{ // `s := Foo{
// ...a // ...a
// field1: 'hello' // field1: 'hello'
@ -473,7 +461,6 @@ pub mut:
is_update_embed bool is_update_embed bool
has_update_expr bool // has `...a` has_update_expr bool // has `...a`
fields []StructInitField fields []StructInitField
embeds []StructInitEmbed
generic_types []Type generic_types []Type
} }

View File

@ -418,9 +418,6 @@ fn (mut w Walker) expr(node_ ast.Expr) {
for sif in node.fields { for sif in node.fields {
w.expr(sif.expr) w.expr(sif.expr)
} }
for sie in node.embeds {
w.expr(sie.expr)
}
} }
ast.TypeOf { ast.TypeOf {
w.expr(node.expr) w.expr(node.expr)

View File

@ -662,9 +662,6 @@ pub fn (mut t Transformer) expr(mut node ast.Expr) ast.Expr {
for mut field in node.fields { for mut field in node.fields {
field.expr = t.expr(mut field.expr) field.expr = t.expr(mut field.expr)
} }
for mut embed in node.embeds {
embed.expr = t.expr(mut embed.expr)
}
} }
ast.UnsafeExpr { ast.UnsafeExpr {
node.expr = t.expr(mut node.expr) node.expr = t.expr(mut node.expr)