! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
-
-USING: accessors assocs compiler.units continuations fuel.eval fuel.help
-fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser
-sequences tools.scaffold vocabs.loader vocabs.parser words ;
-
+USING: accessors assocs compiler.units continuations fry fuel.eval
+fuel.help fuel.xref help.topics io.pathnames kernel namespaces parser
+parser.notes sequences source-files tools.scaffold vocabs vocabs.files
+vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ;
IN: fuel
! Evaluation
-
: fuel-eval-restartable ( -- )
- t fuel-eval-res-flag set-global ; inline
+ t eval-res-flag set-global ; inline
: fuel-eval-non-restartable ( -- )
- f fuel-eval-res-flag set-global ; inline
+ f eval-res-flag set-global ; inline
: fuel-eval-in-context ( lines in usings -- )
- (fuel-eval-in-context) ;
-
-: fuel-eval-set-result ( obj -- )
- clone fuel-eval-result set-global ; inline
+ eval-in-context ;
-: fuel-retort ( -- ) fuel-send-retort ; inline
+: fuel-retort ( -- ) f f "" send-retort ; inline
! Loading files
SYMBOL: :uses
SYMBOL: :uses-suggestions
-: is-use-restart ( restart -- ? )
+: is-use-restart? ( restart -- ? )
name>> [ "Use the " head? ] [ " vocabulary" tail? ] bi and ;
: get-restart-vocab ( restart -- vocab/f )
obj>> dup word? [ vocabulary>> ] [ drop f ] if ;
-: is-suggested-restart ( restart -- ? )
- dup is-use-restart [
+: is-suggested-restart? ( restart -- ? )
+ dup is-use-restart? [
get-restart-vocab :uses-suggestions get member?
] [ drop f ] if ;
: try-suggested-restarts ( -- )
- restarts get [ is-suggested-restart ] filter
- dup length 1 = [ first restart ] [ drop ] if ;
+ restarts get [ is-suggested-restart? ] filter
+ dup length 1 = [ first continue-restart ] [ drop ] if ;
-: fuel-set-use-hook ( -- )
- [ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ]
- print-use-hook set ;
+SYMBOL: auto-uses
-: (fuel-get-uses) ( lines -- )
- [ parse-fresh drop ] curry with-compilation-unit ; inline
+: set-use-hook ( -- )
+ [
+ manifest get auto-used>> clone :uses prefix
+ clone auto-uses set-global
+ ] print-use-hook set ;
PRIVATE>
-: fuel-use-suggested-vocabs ( suggestions quot -- ... )
+: fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b )
+ -- ..b result )
+ f auto-uses set-global
[ :uses-suggestions set ] dip
- [ try-suggested-restarts rethrow ] recover ; inline
-
-: fuel-run-file ( path -- )
- [ fuel-set-use-hook run-file ] curry with-scope ; inline
-
-: fuel-with-autouse ( ... quot: ( ... -- ... ) -- ... )
- [ auto-use? on fuel-set-use-hook call ] curry with-scope ; inline
-
-: fuel-get-uses ( lines -- )
- [ (fuel-get-uses) ] curry fuel-with-autouse ;
+ [ try-suggested-restarts rethrow ] recover
+ auto-uses get-global ; inline
+
+: fuel-run-file ( path -- result )
+ f auto-uses set-global
+ '[ set-use-hook _ run-file ] with-scope
+ auto-uses get-global ; inline
+
+: fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b )
+ '[ set-use-hook _ call ] with-scope ; inline
+
+: fuel-get-uses ( name lines -- )
+ '[
+ [
+ _ [
+ parser-quiet? on
+ _ parse-fresh drop
+ ] with-source-file
+ ] with-compilation-unit
+ ] fuel-with-autouse ;
! Edit locations
+: fuel-get-word-location ( word -- result )
+ word-location ;
-: fuel-get-word-location ( word -- )
- word-location fuel-eval-set-result ;
+: fuel-get-vocab-location ( vocab -- result )
+ vocab-location ;
-: fuel-get-vocab-location ( vocab -- )
- vocab-location fuel-eval-set-result ;
+: fuel-get-doc-location ( word -- result )
+ doc-location ;
-: fuel-get-doc-location ( word -- )
- doc-location fuel-eval-set-result ;
+: fuel-get-article-location ( name -- result )
+ article-location ;
-: fuel-get-article-location ( name -- )
- article-location fuel-eval-set-result ;
+: fuel-get-vocabs ( -- reuslt )
+ all-disk-vocab-names ;
-: fuel-get-vocabs ( -- )
- get-vocabs fuel-eval-set-result ;
+: fuel-get-vocabs/prefix ( prefix -- result )
+ get-vocabs/prefix ;
-: fuel-get-vocabs/prefix ( prefix -- )
- get-vocabs/prefix fuel-eval-set-result ;
-
-: fuel-get-words ( prefix names -- )
- get-vocabs-words/prefix fuel-eval-set-result ;
+: fuel-get-words ( prefix names -- result )
+ get-vocabs-words/prefix ;
! Cross-references
-: fuel-callers-xref ( word -- ) callers-xref fuel-eval-set-result ;
+: fuel-callers-xref ( word -- result ) callers-xref ;
-: fuel-callees-xref ( word -- ) callees-xref fuel-eval-set-result ;
+: fuel-callees-xref ( word -- result ) callees-xref ;
-: fuel-apropos-xref ( str -- ) apropos-xref fuel-eval-set-result ;
+: fuel-apropos-xref ( str -- result ) apropos-xref ;
-: fuel-vocab-xref ( vocab -- ) vocab-xref fuel-eval-set-result ;
+: fuel-vocab-xref ( vocab -- result ) vocab-xref ;
-: fuel-vocab-uses-xref ( vocab -- ) vocab-uses-xref fuel-eval-set-result ;
+: fuel-vocab-uses-xref ( vocab -- result ) vocab-uses-xref ;
-: fuel-vocab-usage-xref ( vocab -- ) vocab-usage-xref fuel-eval-set-result ;
+: fuel-vocab-usage-xref ( vocab -- result ) vocab-usage-xref ;
! Help support
-: fuel-get-article ( name -- ) article fuel-eval-set-result ;
-
-: fuel-get-article-title ( name -- )
- articles get at [ article-title ] [ f ] if* fuel-eval-set-result ;
+: fuel-get-article ( name -- result )
+ fuel.help:get-article ;
-: fuel-word-help ( name -- ) (fuel-word-help) fuel-eval-set-result ;
+: fuel-get-article-title ( name -- result )
+ articles get at [ article-title ] [ f ] if* ;
-: fuel-word-see ( name -- ) (fuel-word-see) fuel-eval-set-result ;
+: fuel-word-help ( name -- result ) word-help ;
-: fuel-word-def ( name -- ) (fuel-word-def) fuel-eval-set-result ;
+: fuel-word-def ( name -- result ) word-def ;
-: fuel-vocab-help ( name -- ) (fuel-vocab-help) fuel-eval-set-result ;
+: fuel-vocab-help ( name -- result ) fuel.help:vocab-help ;
-: fuel-word-synopsis ( word usings -- ) (fuel-word-synopsis) fuel-eval-set-result ;
+: fuel-word-synopsis ( word -- synopsis )
+ word-synopsis ;
-: fuel-vocab-summary ( name -- )
- (fuel-vocab-summary) fuel-eval-set-result ;
+: fuel-vocab-summary ( name -- summary )
+ fuel.help:vocab-summary ;
-: fuel-index ( quot -- ) call( -- seq ) format-index fuel-eval-set-result ;
+: fuel-index ( quot -- result )
+ call( -- seq ) format-index ;
-: fuel-get-vocabs/tag ( tag -- )
- (fuel-get-vocabs/tag) fuel-eval-set-result ;
+: fuel-get-vocabs/tag ( tag -- result )
+ get-vocabs/tag ;
-: fuel-get-vocabs/author ( author -- )
- (fuel-get-vocabs/author) fuel-eval-set-result ;
+: fuel-get-vocabs/author ( author -- result )
+ get-vocabs/author ;
! Scaffold support
-: fuel-scaffold-name ( devname -- )
+: scaffold-name ( devname -- )
[ developer-name set ] when* ;
-: fuel-scaffold-vocab ( root name devname -- )
- [ fuel-scaffold-name dup [ scaffold-vocab ] dip ] with-scope
- dup require vocab-source-path absolute-path fuel-eval-set-result ;
-
-: fuel-scaffold-help ( name devname -- )
- [ fuel-scaffold-name dup require dup scaffold-help ] with-scope
- vocab-docs-path absolute-path fuel-eval-set-result ;
-
-: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;
-
-! Remote connection
-
-MAIN: fuel-start-remote-listener*
+: fuel-scaffold-vocab ( root name devname -- result )
+ [ scaffold-name dup [ scaffold-vocab ] dip ] with-scope
+ dup require vocab-source-path absolute-path ;
+
+: fuel-scaffold-help ( name devname -- result )
+ [ scaffold-name dup require dup scaffold-docs ] with-scope
+ vocab-docs-path absolute-path ;
+
+: fuel-scaffold-tests ( name devname -- result )
+ [ scaffold-name dup require dup scaffold-tests ] with-scope
+ vocab-tests-file absolute-path ;
+
+: fuel-scaffold-authors ( name devname -- result )
+ [ scaffold-name dup require dup scaffold-authors ] with-scope
+ [ vocab-authors-path ] keep swap vocab-append-path absolute-path ;
+
+: fuel-scaffold-tags ( name tags -- result )
+ [ scaffold-tags ]
+ [
+ drop [ vocab-tags-path ] keep swap
+ vocab-append-path absolute-path
+ ] 2bi ;
+
+: fuel-scaffold-summary ( name summary -- result )
+ [ scaffold-summary ]
+ [
+ drop [ vocab-summary-path ] keep swap
+ vocab-append-path absolute-path
+ ] 2bi ;
+
+: fuel-scaffold-platforms ( name platforms -- result )
+ [ scaffold-platforms ]
+ [
+ drop [ vocab-platforms-path ] keep swap
+ vocab-append-path absolute-path
+ ] 2bi ;
+
+: fuel-scaffold-get-root ( name -- result )
+ find-vocab-root ;