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
|
// single file copy
|
||||||
if !os.is_dir(source_path) {
|
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 }
|
adjusted_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) {
|
if os.exists(adjusted_path) {
|
||||||
if overwrite {
|
if overwrite {
|
||||||
os.rm(adjasted_path)
|
os.rm(adjusted_path)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return error('Destination file path already exist')
|
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 error(err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -438,6 +438,9 @@ fn (g mut Gen) stmt(node ast.Stmt) {
|
||||||
ast.GotoLabel {
|
ast.GotoLabel {
|
||||||
g.writeln('$it.name:')
|
g.writeln('$it.name:')
|
||||||
}
|
}
|
||||||
|
ast.GotoStmt {
|
||||||
|
g.writeln('goto $it.name;')
|
||||||
|
}
|
||||||
ast.HashStmt {
|
ast.HashStmt {
|
||||||
// #include etc
|
// #include etc
|
||||||
typ := it.val.all_before(' ')
|
typ := it.val.all_before(' ')
|
||||||
|
@ -2081,6 +2084,8 @@ fn (g mut Gen) call_expr(it ast.CallExpr) {
|
||||||
// `foo() or { return }`
|
// `foo() or { return }`
|
||||||
g.writeln(';') // or')
|
g.writeln(';') // or')
|
||||||
g.writeln('if (!${g.expr_var_name}.ok) {')
|
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.stmts(it.or_block.stmts)
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue