cgen: use more uniform format for automatic code generation (#7487)

pull/7489/head
yuyi 2020-12-23 14:01:41 +08:00 committed by GitHub
parent edefc9e2e4
commit d964dedbb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -2995,7 +2995,7 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
g.write('*')
}
g.expr(node.right)
g.write(',')
g.write(', ')
g.expr(node.left)
g.write('))')
return
@ -4534,7 +4534,7 @@ fn (mut g Gen) gen_struct_equality_fn(left table.Type) string {
return ptr_typ
}
g.struct_fn_definitions << ptr_typ
g.type_definitions.writeln('static bool ${ptr_typ}_struct_eq($ptr_typ a, $ptr_typ b);')
g.type_definitions.writeln('static bool ${ptr_typ}_struct_eq($ptr_typ a, $ptr_typ b); // auto')
mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_typ}_struct_eq($ptr_typ a, $ptr_typ b) {')
for field in info.fields {
@ -4586,9 +4586,9 @@ fn (mut g Gen) gen_array_equality_fn(left table.Type) string {
return ptr_typ
}
g.array_fn_definitions << ptr_typ
g.type_definitions.writeln('static bool ${ptr_typ}_arr_eq(array_$ptr_typ a, array_$ptr_typ b);')
g.type_definitions.writeln('static bool ${ptr_typ}_arr_eq(array_$ptr_typ a, array_$ptr_typ b); // auto')
mut fn_builder := strings.new_builder(512)
fn_builder.writeln('bool ${ptr_typ}_arr_eq(array_$ptr_typ a, array_$ptr_typ b) {')
fn_builder.writeln('static bool ${ptr_typ}_arr_eq(array_$ptr_typ a, array_$ptr_typ b) {')
fn_builder.writeln('\tif (a.len != b.len) {')
fn_builder.writeln('\t\treturn false;')
fn_builder.writeln('\t}')
@ -4624,9 +4624,9 @@ fn (mut g Gen) gen_map_equality_fn(left table.Type) string {
return ptr_typ
}
g.map_fn_definitions << ptr_typ
g.type_definitions.writeln('static bool ${ptr_typ}_map_eq($ptr_typ a, $ptr_typ b);')
g.type_definitions.writeln('static bool ${ptr_typ}_map_eq($ptr_typ a, $ptr_typ b); // auto')
mut fn_builder := strings.new_builder(512)
fn_builder.writeln('bool ${ptr_typ}_map_eq($ptr_typ a, $ptr_typ b) {')
fn_builder.writeln('static bool ${ptr_typ}_map_eq($ptr_typ a, $ptr_typ b) {')
fn_builder.writeln('\tif (a.len != b.len) {')
fn_builder.writeln('\t\treturn false;')
fn_builder.writeln('\t}')
@ -5252,7 +5252,7 @@ fn (mut g Gen) gen_array_contains(node ast.CallExpr) {
g.write('*')
}
g.expr(node.left)
g.write(',')
g.write(', ')
g.expr(node.args[0].expr)
g.write(')')
}