cgen: vfmt -live fix; add new to c_reserved
parent
170ee4312f
commit
7dc98120c0
|
@ -36,7 +36,8 @@ const (
|
||||||
'unsigned',
|
'unsigned',
|
||||||
'void',
|
'void',
|
||||||
'volatile',
|
'volatile',
|
||||||
'while'
|
'while',
|
||||||
|
'new'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -92,7 +93,6 @@ mut:
|
||||||
attr string
|
attr string
|
||||||
is_builtin_mod bool
|
is_builtin_mod bool
|
||||||
hotcode_fn_names []string
|
hotcode_fn_names []string
|
||||||
//
|
|
||||||
fn_main &ast.FnDecl // the FnDecl of the main function. Needed in order to generate the main function code *last*
|
fn_main &ast.FnDecl // the FnDecl of the main function. Needed in order to generate the main function code *last*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ pub fn (mut g Gen) finish() {
|
||||||
if g.fn_main != 0 {
|
if g.fn_main != 0 {
|
||||||
g.out.writeln('')
|
g.out.writeln('')
|
||||||
g.fn_decl = g.fn_main
|
g.fn_decl = g.fn_main
|
||||||
g.gen_fn_decl( g.fn_main )
|
g.gen_fn_decl(g.fn_main)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
// println(name)
|
// println(name)
|
||||||
// }
|
// }
|
||||||
// type_name := g.table.Type_to_str(it.return_type)
|
// type_name := g.table.Type_to_str(it.return_type)
|
||||||
|
|
||||||
// Live functions are protected by a mutex, because otherwise they
|
// Live functions are protected by a mutex, because otherwise they
|
||||||
// can be changed by the live reload thread, *while* they are
|
// can be changed by the live reload thread, *while* they are
|
||||||
// running, with unpredictable results (usually just crashing).
|
// running, with unpredictable results (usually just crashing).
|
||||||
|
@ -89,7 +88,7 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
g.definitions.write('$type_name ${impl_fn_name}(')
|
g.definitions.write('$type_name ${impl_fn_name}(')
|
||||||
g.write('$type_name ${impl_fn_name}(')
|
g.write('$type_name ${impl_fn_name}(')
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
g.definitions.write('$type_name ${name}(')
|
g.definitions.write('$type_name ${name}(')
|
||||||
g.write('$type_name ${name}(')
|
g.write('$type_name ${name}(')
|
||||||
}
|
}
|
||||||
|
@ -102,7 +101,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
}
|
}
|
||||||
g.definitions.writeln(');')
|
g.definitions.writeln(');')
|
||||||
g.writeln(') {')
|
g.writeln(') {')
|
||||||
|
|
||||||
if is_livemain {
|
if is_livemain {
|
||||||
// The live function just calls its implementation dual, while ensuring
|
// The live function just calls its implementation dual, while ensuring
|
||||||
// that the call is wrapped by the mutex lock & unlock calls.
|
// that the call is wrapped by the mutex lock & unlock calls.
|
||||||
|
@ -119,8 +117,9 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
live_fncall = '${type_name} res = ${live_fncall}'
|
live_fncall = '${type_name} res = ${live_fncall}'
|
||||||
live_fnreturn = 'return res;'
|
live_fnreturn = 'return res;'
|
||||||
}
|
}
|
||||||
g.definitions.writeln('$type_name ${name}('+fn_args_list.join(', ')+');')
|
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(' pthread_mutex_lock(&live_fn_mutex);')
|
||||||
g.hotcode_definitions.writeln(' $live_fncall')
|
g.hotcode_definitions.writeln(' $live_fncall')
|
||||||
g.hotcode_definitions.writeln(' pthread_mutex_unlock(&live_fn_mutex);')
|
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 {
|
if g.pref.is_livemain && is_main {
|
||||||
g.generate_hotcode_reloading_main_caller()
|
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])
|
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)
|
styp := g.typ(arg.typ) // g.table.get_type_symbol(arg.typ)
|
||||||
if exp_sym.kind == .interface_ {
|
if exp_sym.kind == .interface_ {
|
||||||
g.write('/*i*/I_${styp}_to_${exp_styp}(')
|
g.write('I_${styp}_to_${exp_styp}(')
|
||||||
is_interface = true
|
is_interface = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue