From 7070b1cda9193a533b4a62c7b954525f77f2d5e1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 25 Mar 2020 17:24:55 +0100 Subject: [PATCH] cgen: GotoStmt, err variable --- vlib/os/os.v | 8 ++++---- vlib/v/gen/cgen.v | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/vlib/os/os.v b/vlib/os/os.v index 200d92795b..15ad1cc78d 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -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 diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index dd443a1552..6b7963b566 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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('}') }