cgen: fix print(struct); use automatic referencing
parent
078f498b17
commit
6b571155f4
|
@ -13,7 +13,7 @@ pub fn compile(command string, args []string) {
|
||||||
// Construct the V object from command line arguments
|
// Construct the V object from command line arguments
|
||||||
parse_and_output_new_format(args)
|
parse_and_output_new_format(args)
|
||||||
prefs, remaining := parse_arguments(args)
|
prefs, remaining := parse_arguments(args)
|
||||||
check_for_common_mistake(args, &prefs)
|
check_for_common_mistake(args, prefs)
|
||||||
mut v := compiler.new_v(prefs)
|
mut v := compiler.new_v(prefs)
|
||||||
if v.pref.verbosity.is_higher_or_equal(.level_two) {
|
if v.pref.verbosity.is_higher_or_equal(.level_two) {
|
||||||
println(args)
|
println(args)
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn parse_arguments(args []string) (pref.Preferences, []string) {
|
||||||
} else {
|
} else {
|
||||||
p.backend = .c
|
p.backend = .c
|
||||||
}
|
}
|
||||||
mut remaining := flag.parse_pref(args, parse_options, &p) or {
|
mut remaining := flag.parse_pref(args, parse_options, p) or {
|
||||||
println('V error: Error while parsing flags.')
|
println('V error: Error while parsing flags.')
|
||||||
println(err)
|
println(err)
|
||||||
println('Args:')
|
println('Args:')
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
if prefs.verbosity.is_higher_or_equal(.level_three) {
|
if prefs.verbosity.is_higher_or_equal(.level_three) {
|
||||||
println('Parsed preferences: ')
|
println('Parsed preferences: ')
|
||||||
println(prefs)
|
//println(prefs) // QTODO
|
||||||
println('Remaining: $values')
|
println('Remaining: $values')
|
||||||
}
|
}
|
||||||
// Do a quick check for `v -v`. Too much error has been made this way.
|
// Do a quick check for `v -v`. Too much error has been made this way.
|
||||||
|
|
|
@ -1330,7 +1330,7 @@ fn (p mut Parser) fn_call_args(f mut Fn, generic_param_types []string) {
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
if f.is_generic && !p.scanner.is_fmt {
|
if f.is_generic && !p.scanner.is_fmt {
|
||||||
type_map := p.extract_type_inst(f, saved_args)
|
type_map := p.extract_type_inst(f, saved_args)
|
||||||
p.dispatch_generic_fn_instance(mut f, &type_map)
|
p.dispatch_generic_fn_instance(mut f, type_map)
|
||||||
}
|
}
|
||||||
if f.is_variadic {
|
if f.is_variadic {
|
||||||
p.fn_gen_caller_vargs(f, varg_type, varg_values)
|
p.fn_gen_caller_vargs(f, varg_type, varg_values)
|
||||||
|
|
|
@ -365,7 +365,7 @@ fn (p mut Parser) struct_init(typ_ string) string {
|
||||||
t = p.table.find_type(t.name)
|
t = p.table.find_type(t.name)
|
||||||
typ = t.name
|
typ = t.name
|
||||||
}
|
}
|
||||||
if p.gen_struct_init(typ, &t) {
|
if p.gen_struct_init(typ, t) {
|
||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
ptr := typ.contains('*')
|
ptr := typ.contains('*')
|
||||||
|
|
|
@ -648,8 +648,9 @@ fn (g mut Gen) expr(node ast.Expr) {
|
||||||
g.write('${name}(')
|
g.write('${name}(')
|
||||||
if name == 'println' && it.args[0].typ != table.string_type_idx {
|
if name == 'println' && it.args[0].typ != table.string_type_idx {
|
||||||
// `println(int_str(10))`
|
// `println(int_str(10))`
|
||||||
sym := g.table.get_type_symbol(it.args[0].typ)
|
// sym := g.table.get_type_symbol(it.args[0].typ)
|
||||||
g.write('${sym.name}_str(')
|
styp := g.typ(it.args[0].typ)
|
||||||
|
g.write('${styp}_str(')
|
||||||
g.expr(it.args[0].expr)
|
g.expr(it.args[0].expr)
|
||||||
g.write('))')
|
g.write('))')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue