Skip to content

Commit

Permalink
fix exit code handling. On EXCEPT_EXIT we jump directly out using the…
Browse files Browse the repository at this point in the history
… exception exit code. Otherwise, we force a non-zero exit, taking hints from the exception if possible. Also, fix the -V option to pull values out of the config hash
  • Loading branch information
Whiteknight committed Aug 7, 2011
1 parent eae2c1b commit d0b907d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/gen/makefiles/root.in
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ runtime/parrot/include/config.fpmc : myconfig config_lib.pir \
$(MINIPARROT) -Iruntime/parrot/include config_lib.pir > $@

frontend/parrot2/prt0.pbc : frontend/parrot2/prt0.pir $(MINIPARROT)
$(MINIPARROT) -o frontend/parrot2/prt0.pbc frontend/parrot2/prt0.pir
$(MINIPARROT) -Iruntime/parrot/include -o frontend/parrot2/prt0.pbc frontend/parrot2/prt0.pir

$(PARROT) : frontend/parrot2/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
src/parrot_config$(O) src/longopt$(O) \
Expand Down
30 changes: 24 additions & 6 deletions frontend/parrot2/prt0.pir
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,16 @@
init_loop_bottom:
.end

.include "except_severity.pasm"
.sub '__handle_error_and_exit' :anon
.param pmc exception
.local pmc bts, bts_iter, stderr_pmc, interp
.local string message
.local int severity, exit_code

severity = exception["severity"]
if severity == .EXCEPT_EXIT goto __direct_exit

interp = getinterp
stderr_pmc = interp.'stderr_handle'()
message = exception["message"]
Expand All @@ -182,20 +188,30 @@
stderr_pmc.'print'("\n")
goto __backtrace_loop_top
__backtrace_loop_bottom:
.local int exit_code

exit_code = exception["exit_code"]
unless exit_code == 0 goto __really_exit
exit_code = 1
__really_exit:
exit exit_code

__direct_exit:
exit_code = exception["exit_code"]
exit exit_code
.end

.include "iglobals.pasm"
.sub '__show_version'
.local pmc interp
.local string version_str, archname_str
# TODO: Get version_str and archname_str, probably from config
.local pmc interp, config
.local string version_str, devel_str, cpuarch_str, platform_str
interp = getinterp
config = interp[.IGLOBALS_CONFIG_HASH]
version_str = config["VERSION"]
devel_str = config["DEVEL"]
cpuarch_str = config["cpuarch"]
platform_str = config["platform"]
$S0 = <<'END_OF_VERSION'
This is Parrot version %s built for %s
This is Parrot version %s%s built for %s-%s
Copyright (C) 2001-2011, Parrot Foundation.

This code is distributed under the terms of the Artistic License 2.0.
Expand All @@ -204,7 +220,9 @@ included in the Parrot source tree
END_OF_VERSION
$P0 = new ['ResizableStringArray']
$P0[0] = version_str
$P0[1] = archname_str
$P0[1] = devel_str
$P0[2] = cpuarch_str
$P0[3] = platform_str
$S1 = sprintf $S0, $P0
say $S1
.end
Expand Down

0 comments on commit d0b907d

Please sign in to comment.