Permalink
Browse files

refactor the way we handle quit() so that it actually works from inte…

…ractive mode. exit() is now a toolbox function that calls quit, instead of a builtin
  • Loading branch information...
1 parent 38bc659 commit ee102b71d508e9a1a48f26a3f040cfe532f4b5cd @Whiteknight committed Feb 2, 2010
Showing with 23 additions and 9 deletions.
  1. +1 −1 src/builtins/quit.pir
  2. +14 −0 src/internals/parser.pir
  3. +1 −1 src/internals/system.pir
  4. +4 −7 src/parser/actions.pm
  5. +3 −0 toolbox/exit.m
View
2 src/builtins/quit.pir
@@ -1,5 +1,5 @@
.sub 'quit'
.param int nargout
.param int nargin
- exit 0
+ die 5, 0
.end
View
14 src/internals/parser.pir
@@ -8,3 +8,17 @@
has_semicolon:
.return(1)
.end
+
+.sub '!_final_exception_handler'
+ .param pmc ex
+ $I0 = ex["severity"]
+ if $I0 >= 6 goto really_exit
+ $S0 = ex["message"]
+ print "error: "
+ say $S0
+ # TODO: Print backtrace here
+ .return()
+
+ really_exit:
+ exit 0
+.end
View
2 src/internals/system.pir
@@ -15,7 +15,7 @@ do secret system stuff.
.namespace []
-.sub '_system'
+.sub '!_system'
.param pmc args :slurpy
$P0 = get_hll_global ["_Matrixy";"builtins"], 'system'
View
11 src/parser/actions.pm
@@ -48,10 +48,7 @@ method TOP($/, $key) {
:pasttype('inline'),
:inline(
" .get_results(%r)\n" ~
- " .local string __matrixy_msg\n" ~
- " __matrixy_msg = %r['message']\n" ~
- " print 'error: '\n" ~
- " say __matrixy_msg\n"
+ " '!_final_exception_handler'(%r)\n"
)
)
)
@@ -156,7 +153,7 @@ method control_statement($/, $key) {
method system_call($/) {
make PAST::Op.new(
- :name("_system"),
+ :name("!_system"),
:pasttype('call'),
:node($/),
PAST::Val.new(
@@ -557,11 +554,11 @@ method func_sig($/) {
}
my $param := $( $_ );
if $param.name() eq "varargout" {
- _disp_all("has varargout");
+ #_disp_all("has varargout");
$hasvarargout := 1;
}
else {
- _disp_all("a normal parameter ", $param.name());
+ #_disp_all("a normal parameter ", $param.name());
$param.scope('lexical');
$param.isdecl(1);
$past.symbol($param.name(), :scope('lexical'));
View
3 toolbox/exit.m
@@ -0,0 +1,3 @@
+function exit()
+ quit;
+end

0 comments on commit ee102b7

Please sign in to comment.