diff --git a/library/inference/inference.factor b/library/inference/inference.factor index 26a670170f..8ce7029641 100644 --- a/library/inference/inference.factor +++ b/library/inference/inference.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: inference -USING: arrays errors generic interpreter io kernel lists math -namespaces parser prettyprint sequences strings vectors words ; +USING: arrays errors generic inspector interpreter io kernel +lists math namespaces parser prettyprint sequences strings +vectors words ; ! This variable takes a boolean value. SYMBOL: inferring-base-case @@ -21,7 +22,7 @@ M: inference-error error. ( error -- ) "! Inference error:" print dup inference-error-message print "! Recursive state:" print - inference-error-rstate sequence. ; + inference-error-rstate describe ; M: value literal-value ( value -- ) { diff --git a/library/syntax/prettyprint.factor b/library/syntax/prettyprint.factor index 279822782a..c102ccafcb 100644 --- a/library/syntax/prettyprint.factor +++ b/library/syntax/prettyprint.factor @@ -316,10 +316,10 @@ M: wrapper pprint* ( wrapper -- ) : pprint ( object -- ) [ pprint* ] with-pprint ; -: unparse ( object -- str ) [ pprint ] string-out ; - : . ( obj -- ) pprint terpri ; +: unparse ( object -- str ) [ pprint ] string-out ; + : pprint-short ( object -- string ) [ 1 line-limit set @@ -329,17 +329,7 @@ M: wrapper pprint* ( wrapper -- ) pprint ] with-scope ; -: unparse-short ( object -- str ) [ pprint-short ] string-out ; - -: short. ( object -- ) - dup unparse-short swap write-object terpri ; - -: sequence. ( sequence -- ) [ short. ] each ; - -: stack. ( sequence -- ) reverse-slice sequence. ; - -: .s datastack stack. ; -: .r callstack stack. ; +: short. ( object -- ) pprint-short terpri ; ! For integers only : .b >bin print ; diff --git a/library/tools/debugger.factor b/library/tools/debugger.factor index c7493294eb..7adf8b100b 100644 --- a/library/tools/debugger.factor +++ b/library/tools/debugger.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: errors -USING: generic kernel kernel-internals lists math namespaces -parser prettyprint sequences io sequences-internals +USING: generic inspector kernel kernel-internals lists math +namespaces parser prettyprint sequences io sequences-internals strings vectors words ; : expired-error. ( obj -- ) @@ -100,8 +100,8 @@ M: string error. ( error -- ) print ; M: object error. ( error -- ) . ; -: :s ( -- ) "error-datastack" get stack. ; -: :r ( -- ) "error-callstack" get stack. ; +: :s ( -- ) "error-datastack" stack. ; +: :r ( -- ) "error-callstack" stack. ; : :get ( var -- value ) "error-namestack" get (get) ; diff --git a/library/tools/inspector.factor b/library/tools/inspector.factor index dddbb0e5ae..40e0885bbe 100644 --- a/library/tools/inspector.factor +++ b/library/tools/inspector.factor @@ -22,22 +22,34 @@ M: array sheet 1array ; M: hashtable sheet dup hash-keys swap hash-values 2array ; : format-column ( list -- list ) - [ unparse-short ] map + [ [ pprint-short ] string-out ] map [ 0 [ length max ] reduce ] keep [ swap CHAR: \s pad-right ] map-with ; -: sheet-numbers ( sheet -- sheet ) - dup first length >array 1array swap append ; - -SYMBOL: inspector-slots - : format-sheet ( sheet -- list ) - sheet-numbers - dup peek inspector-slots set - [ format-column ] map - flip - [ " | " join ] map ; + [ format-column ] map flip [ " " join ] map ; +: describe ( object -- ) + sheet dup format-sheet swap peek + [ dup [ describe ] curry write-outliner ] 2each ; + +: word. ( word -- ) + dup word-name swap dup [ see ] curry write-outliner ; + +: vocab. ( vocab -- ) + f over [ words [ word. ] each ] curry write-outliner ; + +: browser ( -- ) + #! Outlining word browser. + vocabs [ vocab. ] each ; + +: stack. ( seq -- seq ) + reverse-slice >array describe ; + +: .s datastack stack. ; +: .r callstack stack. ; + +! Interactive inspector GENERIC: extra-banner ( obj -- ) M: word extra-banner ( word -- ) @@ -63,9 +75,11 @@ M: object extra-banner ( obj -- ) drop ; "It takes up " write dup size pprint " bytes of memory." print extra-banner ; -: describe ( obj -- ) - sheet dup format-sheet swap peek - [ write-object terpri ] 2each ; +SYMBOL: inspector-slots + +: sheet-numbers ( sheet -- sheet ) + dup first length >array 1array swap append + dup peek inspector-slots set ; SYMBOL: inspector-stack @@ -73,7 +87,8 @@ SYMBOL: inspector-stack : (inspect) ( obj -- ) dup inspector-stack get push - dup inspect-banner describe ; + dup inspect-banner + sheet sheet-numbers sheet. ; : inspector-help ( -- ) "Object inspector." print diff --git a/library/tools/walker.factor b/library/tools/walker.factor index 5aa0ca39d4..2df49cddaa 100644 --- a/library/tools/walker.factor +++ b/library/tools/walker.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: interpreter -USING: errors kernel listener lists math namespaces prettyprint -sequences io strings vectors words ; +USING: errors inspector kernel listener lists math namespaces +prettyprint sequences io strings vectors words ; ! The single-stepper simulates Factor in Factor to allow ! single-stepping through the execution of a quotation. It can diff --git a/library/ui/listener.factor b/library/ui/listener.factor index af60dc39ab..a228f38bf1 100644 --- a/library/ui/listener.factor +++ b/library/ui/listener.factor @@ -6,8 +6,9 @@ DEFER: IN: gadgets-listener USING: gadgets gadgets-labels gadgets-layouts gadgets-panes gadgets-presentations gadgets-scrolling gadgets-splitters -generic hashtables help io kernel listener lists math namespaces -prettyprint sdl sequences shells styles threads words ; +generic hashtables help inspector io kernel listener lists math +namespaces prettyprint sdl sequences shells styles threads +words ; SYMBOL: datastack-display SYMBOL: callstack-display diff --git a/library/ui/presentations.factor b/library/ui/presentations.factor index 6a560b36fb..127b32bd37 100644 --- a/library/ui/presentations.factor +++ b/library/ui/presentations.factor @@ -27,9 +27,6 @@ SYMBOL: commands : ( gadget object -- button ) [ nip command-menu ] curry ; -: ( object -- button ) - [ unparse-short