new words: browser words. vocab.; inspector supports outlining
parent
da134d62d8
commit
a5d1b36114
|
@ -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 -- )
|
||||
{
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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) ;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,8 +6,9 @@ DEFER: <tutorial-button>
|
|||
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
|
||||
|
|
|
@ -27,9 +27,6 @@ SYMBOL: commands
|
|||
: <command-button> ( gadget object -- button )
|
||||
[ nip command-menu ] curry <menu-button> ;
|
||||
|
||||
: <object-button> ( object -- button )
|
||||
[ unparse-short <label> ] keep <command-button> ;
|
||||
|
||||
: init-commands ( gadget -- gadget )
|
||||
dup presented paint-prop [ <command-button> ] when* ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue