autofree: make -experimental the default
parent
f135a9949c
commit
fcd127ed87
|
@ -1028,8 +1028,7 @@ pub fn (mut c Checker) call_expr(mut call_expr ast.CallExpr) table.Type {
|
||||||
// Now call `call_method` or `call_fn` for specific checks.
|
// Now call `call_method` or `call_fn` for specific checks.
|
||||||
typ := if call_expr.is_method { c.call_method(mut call_expr) } else { c.call_fn(mut call_expr) }
|
typ := if call_expr.is_method { c.call_method(mut call_expr) } else { c.call_fn(mut call_expr) }
|
||||||
// autofree: mark args that have to be freed (after saving them in tmp exprs)
|
// autofree: mark args that have to be freed (after saving them in tmp exprs)
|
||||||
free_tmp_arg_vars := c.pref.autofree && c.pref.experimental && !c.is_builtin_mod &&
|
free_tmp_arg_vars := c.pref.autofree && !c.is_builtin_mod && call_expr.args.len > 0 && !call_expr.args[0].typ.has_flag(.optional)
|
||||||
call_expr.args.len > 0 && !call_expr.args[0].typ.has_flag(.optional)
|
|
||||||
if free_tmp_arg_vars && !c.inside_const {
|
if free_tmp_arg_vars && !c.inside_const {
|
||||||
for i, arg in call_expr.args {
|
for i, arg in call_expr.args {
|
||||||
if arg.typ != table.string_type {
|
if arg.typ != table.string_type {
|
||||||
|
|
|
@ -747,7 +747,7 @@ fn (mut g Gen) stmts_with_tmp_var(stmts []ast.Stmt, tmp_var string) {
|
||||||
g.write('')
|
g.write('')
|
||||||
g.write(')')
|
g.write(')')
|
||||||
}
|
}
|
||||||
if g.pref.autofree && g.pref.experimental && !g.inside_vweb_tmpl && stmts.len > 0 {
|
if g.pref.autofree && !g.inside_vweb_tmpl && stmts.len > 0 {
|
||||||
// use the first stmt to get the scope
|
// use the first stmt to get the scope
|
||||||
stmt := stmts[0]
|
stmt := stmts[0]
|
||||||
// stmt := stmts[stmts.len-1]
|
// stmt := stmts[stmts.len-1]
|
||||||
|
|
|
@ -638,8 +638,7 @@ fn (mut g Gen) autofree_call_pregen(node ast.CallExpr) {
|
||||||
// g.writeln('// autofree_call_pregen()')
|
// g.writeln('// autofree_call_pregen()')
|
||||||
// Create a temporary var before fn call for each argument in order to free it (only if it's a complex expression,
|
// Create a temporary var before fn call for each argument in order to free it (only if it's a complex expression,
|
||||||
// like `foo(get_string())` or `foo(a + b)`
|
// like `foo(get_string())` or `foo(a + b)`
|
||||||
mut free_tmp_arg_vars := g.autofree && g.pref.experimental && !g.is_builtin_mod &&
|
mut free_tmp_arg_vars := g.autofree && !g.is_builtin_mod && node.args.len > 0 && !node.args[0].typ.has_flag(.optional) // TODO copy pasta checker.v
|
||||||
node.args.len > 0 && !node.args[0].typ.has_flag(.optional) // TODO copy pasta checker.v
|
|
||||||
if !free_tmp_arg_vars {
|
if !free_tmp_arg_vars {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -778,8 +777,8 @@ fn (mut g Gen) call_args(node ast.CallExpr) {
|
||||||
if gen_vargs && i == expected_types.len - 1 {
|
if gen_vargs && i == expected_types.len - 1 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
use_tmp_var_autofree := g.autofree && g.pref.experimental && arg.typ == table.string_type &&
|
use_tmp_var_autofree := g.autofree && arg.typ == table.string_type && arg.is_tmp_autofree &&
|
||||||
arg.is_tmp_autofree && !g.inside_const
|
!g.inside_const
|
||||||
// g.write('/* af=$arg.is_tmp_autofree */')
|
// g.write('/* af=$arg.is_tmp_autofree */')
|
||||||
mut is_interface := false
|
mut is_interface := false
|
||||||
// some c fn definitions dont have args (cfns.v) or are not updated in checker
|
// some c fn definitions dont have args (cfns.v) or are not updated in checker
|
||||||
|
|
Loading…
Reference in New Issue