mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: vfmt -live fix; add new to c_reserved
This commit is contained in:
parent
170ee4312f
commit
7dc98120c0
|
@ -36,7 +36,8 @@ const (
|
|||
'unsigned',
|
||||
'void',
|
||||
'volatile',
|
||||
'while'
|
||||
'while',
|
||||
'new'
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -92,7 +93,6 @@ mut:
|
|||
attr string
|
||||
is_builtin_mod bool
|
||||
hotcode_fn_names []string
|
||||
//
|
||||
fn_main &ast.FnDecl // the FnDecl of the main function. Needed in order to generate the main function code *last*
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
// println(name)
|
||||
// }
|
||||
// type_name := g.table.Type_to_str(it.return_type)
|
||||
|
||||
// Live functions are protected by a mutex, because otherwise they
|
||||
// can be changed by the live reload thread, *while* they are
|
||||
// running, with unpredictable results (usually just crashing).
|
||||
|
@ -102,7 +101,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
}
|
||||
g.definitions.writeln(');')
|
||||
g.writeln(') {')
|
||||
|
||||
if is_livemain {
|
||||
// The live function just calls its implementation dual, while ensuring
|
||||
// that the call is wrapped by the mutex lock & unlock calls.
|
||||
|
@ -120,7 +118,8 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
live_fnreturn = 'return res;'
|
||||
}
|
||||
g.definitions.writeln('$type_name ${name}(' + fn_args_list.join(', ') + ');')
|
||||
g.hotcode_definitions.writeln('$type_name ${name}('+fn_args_list.join(', ')+'){')
|
||||
g.hotcode_definitions.writeln('$type_name ${name}(' + fn_args_list.join(', ') +
|
||||
'){')
|
||||
g.hotcode_definitions.writeln(' pthread_mutex_lock(&live_fn_mutex);')
|
||||
g.hotcode_definitions.writeln(' $live_fncall')
|
||||
g.hotcode_definitions.writeln(' pthread_mutex_unlock(&live_fn_mutex);')
|
||||
|
@ -148,7 +147,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if g.pref.is_livemain && is_main {
|
||||
g.generate_hotcode_reloading_main_caller()
|
||||
}
|
||||
|
@ -513,7 +511,7 @@ fn (mut g Gen) call_args(args []ast.CallArg, expected_types []table.Type) {
|
|||
exp_styp := g.typ(expected_types[arg_no]) // g.table.get_type_symbol(expected_types[arg_no])
|
||||
styp := g.typ(arg.typ) // g.table.get_type_symbol(arg.typ)
|
||||
if exp_sym.kind == .interface_ {
|
||||
g.write('/*i*/I_${styp}_to_${exp_styp}(')
|
||||
g.write('I_${styp}_to_${exp_styp}(')
|
||||
is_interface = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user