! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays continuations debugger fuel.pprint io
+USING: accessors arrays continuations debugger fry fuel.pprint io
io.streams.string kernel listener namespaces parser.notes
prettyprint.config sequences sets vocabs.parser ;
IN: fuel.eval
SYMBOL: restarts-stack
V{ } clone restarts-stack set-global
-SYMBOL: eval-result
-f eval-result set-global
-
SYMBOL: eval-res-flag
t eval-res-flag set-global
"<~FUEL~>" write nl flush ;
: begin-eval ( -- )
- f eval-result set-global push-status ;
+ push-status ;
-: end-eval ( error/f output -- )
- eval-result get-global swap send-retort pop-status ;
+: end-eval ( result error/f output -- )
+ swapd send-retort pop-status ;
-: eval ( lines -- error/f )
- [ parse-lines-interactive call( -- ) f ] curry
- [ dup print-error ] recover ;
+: eval ( lines -- result error/f )
+ '[ _ parse-lines-interactive call( -- x ) f ]
+ [ dup print-error f swap ] recover ;
: eval-usings ( usings -- )
[ [ use-vocab ] curry ignore-errors ] each ;