cgen: GotoStmt, err variable
parent
26fab9b274
commit
7070b1cda9
|
@ -178,16 +178,16 @@ pub fn cp_all(osource_path, odest_path string, overwrite bool) ?bool {
|
|||
}
|
||||
// single file copy
|
||||
if !os.is_dir(source_path) {
|
||||
adjasted_path := if os.is_dir(dest_path) { os.join_path(dest_path,os.file_name(source_path)) } else { dest_path }
|
||||
if os.exists(adjasted_path) {
|
||||
adjusted_path := if os.is_dir(dest_path) {os.join_path(dest_path,os.file_name(source_path)) } else { dest_path }
|
||||
if os.exists(adjusted_path) {
|
||||
if overwrite {
|
||||
os.rm(adjasted_path)
|
||||
os.rm(adjusted_path)
|
||||
}
|
||||
else {
|
||||
return error('Destination file path already exist')
|
||||
}
|
||||
}
|
||||
os.cp(source_path, adjasted_path) or {
|
||||
os.cp(source_path, adjusted_path) or {
|
||||
return error(err)
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -438,6 +438,9 @@ fn (g mut Gen) stmt(node ast.Stmt) {
|
|||
ast.GotoLabel {
|
||||
g.writeln('$it.name:')
|
||||
}
|
||||
ast.GotoStmt {
|
||||
g.writeln('goto $it.name;')
|
||||
}
|
||||
ast.HashStmt {
|
||||
// #include etc
|
||||
typ := it.val.all_before(' ')
|
||||
|
@ -2081,6 +2084,8 @@ fn (g mut Gen) call_expr(it ast.CallExpr) {
|
|||
// `foo() or { return }`
|
||||
g.writeln(';') // or')
|
||||
g.writeln('if (!${g.expr_var_name}.ok) {')
|
||||
g.writeln('string err = ${g.expr_var_name}.v_error;')
|
||||
g.writeln('int errcode = ${g.expr_var_name}.ecode;')
|
||||
g.stmts(it.or_block.stmts)
|
||||
g.writeln('}')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue