stack effects for all primitives, updated to do list, literal hashtable syntax {{ [ key | value ] ... }}

cvs
Slava Pestov 2004-11-11 21:45:55 +00:00
parent 26dd297e62
commit 7cebc2e469
5 changed files with 259 additions and 291 deletions

View File

@ -1,14 +1,22 @@
- add a socket timeout + inference/interpreter:
- compiling when*
- compiling unless* - : bin 5 [ 5 bin bin 5 ] [ 2drop ] ifte ;
- getenv/setenv: if literal arg, compile as a load/store - combinator inference
- inline words - generic/2generic inference
- alist -vs- assoc terminology - type inference
- compiler: drop literal peephole optimization
- [ 2 2 . ] run fails - [ 2 2 . ] run fails
- some way to step over a word in the stepper
- step: print NEXT word to execute, not word that JUST executed
- cache stack effects
- once generic inference is done, can-compile is "has stack effect!"
+ compiler/ffi: + compiler/ffi:
- compiling when*
- compiling each, etc.
- getenv/setenv: if literal arg, compile as a load/store
- inline words
- compiler: drop literal peephole optimization
- is signed -vs- unsigned pointers an issue? - is signed -vs- unsigned pointers an issue?
- bitfields in C structs - bitfields in C structs
- SDL_Rect** type - SDL_Rect** type
@ -16,23 +24,9 @@
- float types - float types
- compile word twice; no more 'cannot compile' error! - compile word twice; no more 'cannot compile' error!
- perhaps /i should work with all numbers - perhaps /i should work with all numbers
- assembler opcodes dispatch on operand types
+ docs: - lifting
- save code in image
- explain how log uses >polar and rect>
- simple i/o section
- unparse examples, and difference from prettyprint
- review doc formatting with latex2html
- recursion -vs- iteration in vectors chapter, and combinator
construction
- [, , ,] -- mention that , are usually in nested words
- finish namespaces docs
- mention word accessors/mutators
- to document:
continuations
streams
multitasking
unit testing
+ listener/plugin: + listener/plugin:
@ -48,7 +42,6 @@
- maple-like: press enter at old commands to evaluate there - maple-like: press enter at old commands to evaluate there
- completion in the listener - completion in the listener
- special completion for USE:/IN: - special completion for USE:/IN:
- inspector links when describe called without object path
+ kernel: + kernel:
@ -57,37 +50,38 @@
- better i/o scheduler - better i/o scheduler
- >lower, >upper for strings - >lower, >upper for strings
- don't rehash strings on every startup - don't rehash strings on every startup
- remove sbufs
- cat, reverse-cat primitives
- first-class hashtables
- hash words in stage 2 of bootstrap
- rewrite accessors and mutators in Factor, with slot/set-slot primitive
- replace -export-dynamic with sundry-xt
- add a socket timeout
+ misc: + misc:
- alist -vs- assoc terminology
- jedit ==> jedit-word, jedit takes a file name - jedit ==> jedit-word, jedit takes a file name
- 'cascading' styles - 'cascading' styles
- command line parsing cleanup - command line parsing cleanup
- nicer way to combine two paths - nicer way to combine two paths
- :get &get
- namestack, catchstack lists
- OOP
- room. prints code heap size
- refactor sort
- ditch java factor
- ditch object paths
- browser responder for word links in HTTPd; inspect responder for
objects
- use keep instead of tuck, try to remove usages of transp
- worddef props
- prettyprint: when unparse called due to recursion, write a link
- prettyprinter should output {{ ... }} syntax for hashtables
- FORGET: and forget
+ httpd: + httpd:
- wiki responder:
- port to native
- text styles
- log with date - log with date
basic authentication, using httpdAuth function from a config file - basic authentication, using httpdAuth function from a config file
- file responder; last-modified field - file responder; last-modified field
+ java factor is going away:
- compiled stack traces broken
- save classes to disk
- tail call optimization broken again
- don't compile inline words
- recursive words with code after ifte
- less unnecessary args to auxiliary methods
- inlining tail-recursive immediates
- direct stack access leaks memory on stack
- unnecessary local allocation: max is instance var, but several methods
get compiled.
- ditch expand
- when* compilation in jvm
- plugin should not exit jEdit on fatal errors
- java factor: equal numbers have non-equal hashcodes!
- FactorLib.equal() not very good

View File

@ -29,6 +29,7 @@ IN: parser
USE: combinators USE: combinators
USE: errors USE: errors
USE: hashtables
USE: kernel USE: kernel
USE: lists USE: lists
USE: logic USE: logic
@ -134,6 +135,10 @@ IN: syntax
: { f ; parsing : { f ; parsing
: } reverse list>vector parsed ; parsing : } reverse list>vector parsed ; parsing
! Hashtables
: {{ f ; parsing
: }} alist>hash parsed ; parsing
! Do not execute parsing word ! Do not execute parsing word
: POSTPONE: ( -- ) scan-word parsed ; parsing : POSTPONE: ( -- ) scan-word parsed ; parsing

View File

@ -45,193 +45,195 @@ USE: vectors
USE: words USE: words
[ [
[ execute | " word -- " ] [ execute " word -- " f ]
[ call | " quot -- " ] [ call " quot -- " [ 1 | 0 ] ]
[ ifte | " cond true false -- " ] [ ifte " cond true false -- " [ 3 | 0 ] ]
[ cons | " car cdr -- [ car | cdr ] " ] [ cons " car cdr -- [ car | cdr ] " [ 2 | 1 ] ]
[ car | " [ car | cdr ] -- car " ] [ car " [ car | cdr ] -- car " [ 1 | 1 ] ]
[ cdr | " [ car | cdr ] -- cdr " ] [ cdr " [ car | cdr ] -- cdr " [ 1 | 1 ] ]
[ <vector> | " capacity -- vector" ] [ <vector> " capacity -- vector" [ 1 | 1 ] ]
[ vector-length | " vector -- n " ] [ vector-length " vector -- n " [ 1 | 1 ] ]
[ set-vector-length | " n vector -- " ] [ set-vector-length " n vector -- " [ 2 | 0 ] ]
[ vector-nth | " n vector -- obj " ] [ vector-nth " n vector -- obj " [ 2 | 1 ] ]
[ set-vector-nth | " obj n vector -- " ] [ set-vector-nth " obj n vector -- " [ 3 | 0 ] ]
[ str-length | " str -- n " ] [ str-length " str -- n " [ 1 | 1 ] ]
[ str-nth | " n str -- ch " ] [ str-nth " n str -- ch " [ 2 | 1 ] ]
[ str-compare | " str str -- -1/0/1 " ] [ str-compare " str str -- -1/0/1 " [ 2 | 1 ] ]
[ str= | " str str -- ? " ] [ str= " str str -- ? " [ 2 | 1 ] ]
[ str-hashcode | " str -- n " ] [ str-hashcode " str -- n " [ 1 | 1 ] ]
[ index-of* | " n str/ch str -- n " ] [ index-of* " n str/ch str -- n " [ 3 | 1 ] ]
[ substring | " start end str -- str "] [ substring " start end str -- str " [ 3 | 1 ] ]
[ str-reverse | " str -- str " ] [ str-reverse " str -- str " [ 1 | 1 ] ]
[ <sbuf> | " capacity -- sbuf " ] [ <sbuf> " capacity -- sbuf " [ 1 | 1 ] ]
[ sbuf-length | " sbuf -- n " ] [ sbuf-length " sbuf -- n " [ 1 | 1 ] ]
[ set-sbuf-length | " n sbuf -- " ] [ set-sbuf-length " n sbuf -- " [ 2 | 1 ] ]
[ sbuf-nth | " n sbuf -- ch " ] [ sbuf-nth " n sbuf -- ch " [ 2 | 1 ] ]
[ set-sbuf-nth | " ch n sbuf -- " ] [ set-sbuf-nth " ch n sbuf -- " [ 3 | 0 ] ]
[ sbuf-append | " ch/str sbuf -- " ] [ sbuf-append " ch/str sbuf -- " [ 2 | 1 ] ]
[ sbuf>str | " sbuf -- str " ] [ sbuf>str " sbuf -- str " [ 1 | 1 ] ]
[ sbuf-reverse | " sbuf -- " ] [ sbuf-reverse " sbuf -- " [ 1 | 0 ] ]
[ sbuf-clone | " sbuf -- sbuf " ] [ sbuf-clone " sbuf -- sbuf " [ 1 | 1 ] ]
[ sbuf= | " sbuf sbuf -- ? " ] [ sbuf= " sbuf sbuf -- ? " [ 2 | 1 ] ]
[ sbuf-hashcode | " sbuf -- n " ] [ sbuf-hashcode " sbuf -- n " [ 1 | 1 ] ]
[ arithmetic-type | " n n -- type " ] [ arithmetic-type " n n -- type " [ 2 | 1 ] ]
[ number? | " obj -- ? " ] [ number? " obj -- ? " [ 1 | 1 ] ]
[ >fixnum | " n -- fixnum " ] [ >fixnum " n -- fixnum " [ 1 | 1 ] ]
[ >bignum | " n -- bignum " ] [ >bignum " n -- bignum " [ 1 | 1 ] ]
[ >float | " n -- float " ] [ >float " n -- float " [ 1 | 1 ] ]
[ numerator | " a/b -- a " ] [ numerator " a/b -- a " [ 1 | 1 ] ]
[ denominator | " a/b -- b " ] [ denominator " a/b -- b " [ 1 | 1 ] ]
[ fraction> | " a b -- a/b " ] [ fraction> " a b -- a/b " [ 1 | 1 ] ]
[ str>float | " str -- float " ] [ str>float " str -- float " [ 1 | 1 ] ]
[ unparse-float | " float -- str " ] [ unparse-float " float -- str " [ 1 | 1 ] ]
[ float>bits | " float -- n " ] [ float>bits " float -- n " [ 1 | 1 ] ]
[ real | " #{ re im } -- re " ] [ real " #{ re im } -- re " [ 1 | 1 ] ]
[ imaginary | " #{ re im } -- im " ] [ imaginary " #{ re im } -- im " [ 1 | 1 ] ]
[ rect> | " re im -- #{ re im } " ] [ rect> " re im -- #{ re im } " [ 2 | 1 ] ]
[ fixnum= | " x y -- ? " ] [ fixnum= " x y -- ? " [ 2 | 1 ] ]
[ fixnum+ | " x y -- x+y " ] [ fixnum+ " x y -- x+y " [ 2 | 1 ] ]
[ fixnum- | " x y -- x-y " ] [ fixnum- " x y -- x-y " [ 2 | 1 ] ]
[ fixnum* | " x y -- x*y " ] [ fixnum* " x y -- x*y " [ 2 | 1 ] ]
[ fixnum/i | " x y -- x/y " ] [ fixnum/i " x y -- x/y " [ 2 | 1 ] ]
[ fixnum/f | " x y -- x/y " ] [ fixnum/f " x y -- x/y " [ 2 | 1 ] ]
[ fixnum-mod | " x y -- x%y " ] [ fixnum-mod " x y -- x%y " [ 2 | 1 ] ]
[ fixnum/mod | " x y -- x/y x%y " ] [ fixnum/mod " x y -- x/y x%y " [ 2 | 2 ] ]
[ fixnum-bitand | " x y -- x&y " ] [ fixnum-bitand " x y -- x&y " [ 2 | 1 ] ]
[ fixnum-bitor | " x y -- x|y " ] [ fixnum-bitor " x y -- x|y " [ 2 | 1 ] ]
[ fixnum-bitxor | " x y -- x^y " ] [ fixnum-bitxor " x y -- x^y " [ 2 | 1 ] ]
[ fixnum-bitnot | " x -- ~x " ] [ fixnum-bitnot " x -- ~x " [ 1 | 1 ] ]
[ fixnum-shift | " x n -- x<<n" ] [ fixnum-shift " x n -- x<<n" [ 2 | 1 ] ]
[ fixnum< | " x y -- ? " ] [ fixnum< " x y -- ? " [ 2 | 1 ] ]
[ fixnum<= | " x y -- ? " ] [ fixnum<= " x y -- ? " [ 2 | 1 ] ]
[ fixnum> | " x y -- ? " ] [ fixnum> " x y -- ? " [ 2 | 1 ] ]
[ fixnum>= | " x y -- ? " ] [ fixnum>= " x y -- ? " [ 2 | 1 ] ]
[ bignum= | " x y -- ? " ] [ bignum= " x y -- ? " [ 2 | 1 ] ]
[ bignum+ | " x y -- x+y " ] [ bignum+ " x y -- x+y " [ 2 | 1 ] ]
[ bignum- | " x y -- x-y " ] [ bignum- " x y -- x-y " [ 2 | 1 ] ]
[ bignum* | " x y -- x*y " ] [ bignum* " x y -- x*y " [ 2 | 1 ] ]
[ bignum/i | " x y -- x/y " ] [ bignum/i " x y -- x/y " [ 2 | 1 ] ]
[ bignum/f | " x y -- x/y " ] [ bignum/f " x y -- x/y " [ 2 | 1 ] ]
[ bignum-mod | " x y -- x%y " ] [ bignum-mod " x y -- x%y " [ 2 | 1 ] ]
[ bignum/mod | " x y -- x/y x%y " ] [ bignum/mod " x y -- x/y x%y " [ 2 | 2 ] ]
[ bignum-bitand | " x y -- x&y " ] [ bignum-bitand " x y -- x&y " [ 2 | 1 ] ]
[ bignum-bitor | " x y -- x|y " ] [ bignum-bitor " x y -- x|y " [ 2 | 1 ] ]
[ bignum-bitxor | " x y -- x^y " ] [ bignum-bitxor " x y -- x^y " [ 2 | 1 ] ]
[ bignum-bitnot | " x -- ~x " ] [ bignum-bitnot " x -- ~x " [ 1 | 1 ] ]
[ bignum-shift | " x n -- x<<n" ] [ bignum-shift " x n -- x<<n" [ 2 | 1 ] ]
[ bignum< | " x y -- ? " ] [ bignum< " x y -- ? " [ 2 | 1 ] ]
[ bignum<= | " x y -- ? " ] [ bignum<= " x y -- ? " [ 2 | 1 ] ]
[ bignum> | " x y -- ? " ] [ bignum> " x y -- ? " [ 2 | 1 ] ]
[ bignum>= | " x y -- ? " ] [ bignum>= " x y -- ? " [ 2 | 1 ] ]
[ float= | " x y -- ? " ] [ float= " x y -- ? " [ 2 | 1 ] ]
[ float+ | " x y -- x+y " ] [ float+ " x y -- x+y " [ 2 | 1 ] ]
[ float- | " x y -- x-y " ] [ float- " x y -- x-y " [ 2 | 1 ] ]
[ float* | " x y -- x*y " ] [ float* " x y -- x*y " [ 2 | 1 ] ]
[ float/f | " x y -- x/y " ] [ float/f " x y -- x/y " [ 2 | 1 ] ]
[ float< | " x y -- ? " ] [ float< " x y -- ? " [ 2 | 1 ] ]
[ float<= | " x y -- ? " ] [ float<= " x y -- ? " [ 2 | 1 ] ]
[ float> | " x y -- ? " ] [ float> " x y -- ? " [ 2 | 1 ] ]
[ float>= | " x y -- ? " ] [ float>= " x y -- ? " [ 2 | 1 ] ]
[ facos | " x -- y " ] [ facos " x -- y " [ 1 | 1 ] ]
[ fasin | " x -- y " ] [ fasin " x -- y " [ 1 | 1 ] ]
[ fatan | " x -- y " ] [ fatan " x -- y " [ 1 | 1 ] ]
[ fatan2 | " x y -- z " ] [ fatan2 " x y -- z " [ 2 | 1 ] ]
[ fcos | " x -- y " ] [ fcos " x -- y " [ 1 | 1 ] ]
[ fexp | " x -- y " ] [ fexp " x -- y " [ 1 | 1 ] ]
[ fcosh | " x -- y " ] [ fcosh " x -- y " [ 1 | 1 ] ]
[ flog | " x -- y " ] [ flog " x -- y " [ 1 | 1 ] ]
[ fpow | " x y -- z " ] [ fpow " x y -- z " [ 2 | 1 ] ]
[ fsin | " x -- y " ] [ fsin " x -- y " [ 1 | 1 ] ]
[ fsinh | " x -- y " ] [ fsinh " x -- y " [ 1 | 1 ] ]
[ fsqrt | " x -- y " ] [ fsqrt " x -- y " [ 1 | 1 ] ]
[ <word> | " prim param plist -- word " ] [ <word> " prim param plist -- word " [ 3 | 1 ] ]
[ word-hashcode | " word -- n " ] [ word-hashcode " word -- n " [ 1 | 1 ] ]
[ word-xt | " word -- xt " ] [ word-xt " word -- xt " [ 1 | 1 ] ]
[ set-word-xt | " xt word -- " ] [ set-word-xt " xt word -- " [ 2 | 0 ] ]
[ word-primitive | " word -- n " ] [ word-primitive " word -- n " [ 1 | 1 ] ]
[ set-word-primitive | " n word -- " ] [ set-word-primitive " n word -- " [ 2 | 0 ] ]
[ word-parameter | " word -- obj " ] [ word-parameter " word -- obj " [ 1 | 1 ] ]
[ set-word-parameter | " obj word -- " ] [ set-word-parameter " obj word -- " [ 2 | 0 ] ]
[ word-plist | " word -- alist" ] [ word-plist " word -- alist" [ 1 | 1 ] ]
[ set-word-plist | " alist word -- " ] [ set-word-plist " alist word -- " [ 2 | 0 ] ]
[ drop | " x -- " ] [ drop " x -- " [ 1 | 0 ] ]
[ dup | " x -- x x " ] [ dup " x -- x x " [ 1 | 2 ] ]
[ swap | " x y -- y x " ] [ swap " x y -- y x " [ 2 | 2 ] ]
[ over | " x y -- x y x " ] [ over " x y -- x y x " [ 2 | 3 ] ]
[ pick | " x y z -- x y z x " ] [ pick " x y z -- x y z x " [ 3 | 4 ] ]
[ nip | " x y -- y " ] [ nip " x y -- y " [ 2 | 1 ] ]
[ tuck | " x y -- y x y " ] [ tuck " x y -- y x y " [ 2 | 3 ] ]
[ rot | " x y z -- y z x " ] [ rot " x y z -- y z x " [ 3 | 3 ] ]
[ >r | " x -- r:x " ] [ >r " x -- r:x " [ 1 | 0 ] ]
[ r> | " r:x -- x " ] [ r> " r:x -- x " [ 0 | 1 ] ]
[ eq? | " x y -- ? " ] [ eq? " x y -- ? " [ 2 | 1 ] ]
[ getenv | " n -- obj " ] [ getenv " n -- obj " [ 1 | 1 ] ]
[ setenv | " obj n -- " ] [ setenv " obj n -- " [ 2 | 0 ] ]
[ open-file | " path r w -- port " ] [ open-file " path r w -- port " [ 3 | 1 ] ]
[ stat | " path -- [ dir? perm size mtime ] " ] [ stat " path -- [ dir? perm size mtime ] " [ 1 | 1 ] ]
[ (directory) | " path -- list " ] [ (directory) " path -- list " [ 1 | 1 ] ]
[ garbage-collection | " -- " ] [ garbage-collection " -- " [ 0 | 0 ] ]
[ save-image | " path -- " ] [ save-image " path -- " [ 1 | 0 ] ]
[ datastack | " -- ds " ] [ datastack " -- ds " f ]
[ callstack | " -- cs " ] [ callstack " -- cs " f ]
[ set-datastack | " ds -- " ] [ set-datastack " ds -- " f ]
[ set-callstack | " cs -- " ] [ set-callstack " cs -- " f ]
[ exit* | " n -- " ] [ exit* " n -- " [ 1 | 0 ] ]
[ client-socket | " host port -- in out " ] [ client-socket " host port -- in out " [ 2 | 2 ] ]
[ server-socket | " port -- server " ] [ server-socket " port -- server " [ 1 | 1 ] ]
[ close-port | " port -- " ] [ close-port " port -- " [ 1 | 0 ] ]
[ add-accept-io-task | " server callback -- " ] [ add-accept-io-task " server callback -- " [ 2 | 0 ] ]
[ accept-fd | " server -- host port in out " ] [ accept-fd " server -- host port in out " [ 1 | 4 ] ]
[ can-read-line? | " port -- ? " ] [ can-read-line? " port -- ? " [ 1 | 1 ] ]
[ add-read-line-io-task | " port callback -- " ] [ add-read-line-io-task " port callback -- " [ 2 | 0 ] ]
[ read-line-fd-8 | " port -- sbuf " ] [ read-line-fd-8 " port -- sbuf " [ 1 | 1 ] ]
[ can-read-count? | " n port -- ? " ] [ can-read-count? " n port -- ? " [ 2 | 1 ] ]
[ add-read-count-io-task | " n port callback -- " ] [ add-read-count-io-task " n port callback -- " [ 3 | 0 ] ]
[ read-count-fd-8 | " n port -- sbuf " ] [ read-count-fd-8 " n port -- sbuf " [ 2 | 1 ] ]
[ can-write? | " n port -- ? " ] [ can-write? " n port -- ? " [ 2 | 1 ] ]
[ add-write-io-task | " port callback -- " ] [ add-write-io-task " port callback -- " [ 2 | 0 ] ]
[ write-fd-8 | " ch/str port -- " ] [ write-fd-8 " ch/str port -- " [ 2 | 0 ] ]
[ add-copy-io-task | " from to callback -- " ] [ add-copy-io-task " from to callback -- " [ 3 | 1 ] ]
[ pending-io-error | " -- " ] [ pending-io-error " -- " [ 0 | 0 ] ]
[ next-io-task | " -- callback " ] [ next-io-task " -- callback " [ 0 | 1 ] ]
[ room | " -- free total " ] [ room " -- free total " [ 0 | 2 ] ]
[ os-env | " str -- str " ] [ os-env " str -- str " [ 1 | 1 ] ]
[ millis | " -- n " ] [ millis " -- n " [ 0 | 1 ] ]
[ init-random | " -- " ] [ init-random " -- " [ 0 | 0 ] ]
[ (random-int) | " -- n " ] [ (random-int) " -- n " [ 0 | 1 ] ]
[ type | " obj -- n " ] [ type " obj -- n " [ 1 | 1 ] ]
[ size | " obj -- n " ] [ size " obj -- n " [ 1 | 1 ] ]
[ call-profiling | " depth -- " ] [ call-profiling " depth -- " [ 1 | 0 ] ]
[ call-count | " word -- n " ] [ call-count " word -- n " [ 1 | 1 ] ]
[ set-call-count | " n word -- " ] [ set-call-count " n word -- " [ 2 | 0 ] ]
[ allot-profiling | " depth -- " ] [ allot-profiling " depth -- " [ 1 | 0 ] ]
[ allot-count | " word -- n " ] [ allot-count " word -- n " [ 1 | 1 ] ]
[ set-allot-count | " n word -- n " ] [ set-allot-count " n word -- n " [ 2 | 1 ] ]
[ cwd | " -- dir " ] [ cwd " -- dir " [ 0 | 1 ] ]
[ cd | " dir -- " ] [ cd " dir -- " [ 1 | 0 ] ]
[ compiled-offset | " -- ptr " ] [ compiled-offset " -- ptr " [ 0 | 1 ] ]
[ set-compiled-offset | " ptr -- " ] [ set-compiled-offset " ptr -- " [ 1 | 0 ] ]
[ set-compiled-cell | " n ptr -- " ] [ set-compiled-cell " n ptr -- " [ 2 | 0 ] ]
[ set-compiled-byte | " n ptr -- " ] [ set-compiled-byte " n ptr -- " [ 2 | 0 ] ]
[ literal-top | " -- ptr " ] [ literal-top " -- ptr " [ 0 | 1 ] ]
[ set-literal-top | " ptr -- " ] [ set-literal-top " ptr -- " [ 1 | 0 ] ]
[ address | " obj -- ptr " ] [ address " obj -- ptr " [ 1 | 1 ] ]
[ dlopen | " path -- dll " ] [ dlopen " path -- dll " [ 1 | 1 ] ]
[ dlsym | " name dll -- ptr " ] [ dlsym " name dll -- ptr " [ 2 | 1 ] ]
[ dlsym-self | " name -- ptr " ] [ dlsym-self " name -- ptr " [ 1 | 1 ] ]
[ dlclose | " dll -- " ] [ dlclose " dll -- " [ 1 | 0 ] ]
[ <alien> | " ptr -- alien " ] [ <alien> " ptr -- alien " [ 1 | 1 ] ]
[ <local-alien> | " len -- alien " ] [ <local-alien> " len -- alien " [ 1 | 1 ] ]
[ alien-cell | " alien off -- n " ] [ alien-cell " alien off -- n " [ 2 | 1 ] ]
[ set-alien-cell | " n alien off -- " ] [ set-alien-cell " n alien off -- " [ 3 | 0 ] ]
[ alien-4 | " alien off -- n " ] [ alien-4 " alien off -- n " [ 2 | 1 ] ]
[ set-alien-4 | " n alien off -- " ] [ set-alien-4 " n alien off -- " [ 3 | 0 ] ]
[ alien-2 | " alien off -- n " ] [ alien-2 " alien off -- n " [ 2 | 1 ] ]
[ set-alien-2 | " n alien off -- " ] [ set-alien-2 " n alien off -- " [ 3 | 0 ] ]
[ alien-1 | " alien off -- n " ] [ alien-1 " alien off -- n " [ 2 | 1 ] ]
[ set-alien-1 | " n alien off -- " ] [ set-alien-1 " n alien off -- " [ 3 | 0 ] ]
[ heap-stats | " -- instances bytes " ] [ heap-stats " -- instances bytes " [ 0 | 2 ] ]
[ throw | " error -- " ] [ throw " error -- " [ 1 | 0 ] ]
] [ ] [
uncons "stack-effect" set-word-property uncons dupd uncons car ( word word stack-effect infer-effect )
>r "stack-effect" set-word-property r>
"infer-effect" set-word-property
] each ] each

View File

@ -88,24 +88,18 @@ DEFER: prettyprint*
dup prettyprint-newline dup prettyprint-newline
] unless ; ] unless ;
: check-recursion ( indent obj quot -- )
>r over prettyprint-limit >= [
r> drop drop "#< ... > " write
] [
r> call
] ifte ;
: prettyprint-[ ( indent -- indent ) : prettyprint-[ ( indent -- indent )
"[" write <prettyprint ; "[" write <prettyprint ;
: prettyprint-] ( indent -- indent ) : prettyprint-] ( indent -- indent )
prettyprint> "]" write ; prettyprint> "]" write ;
: (prettyprint-list) ( indent list -- indent ) : prettyprint-list ( indent list -- indent )
#! Pretty-print a list, without [ and ].
[ [
uncons >r prettyprint-element r> uncons >r prettyprint-element r>
dup cons? [ dup cons? [
(prettyprint-list) prettyprint-list
] [ ] [
[ [
"|" write prettyprint-space prettyprint-element "|" write prettyprint-space prettyprint-element
@ -113,10 +107,6 @@ DEFER: prettyprint*
] ifte ] ifte
] when* ; ] when* ;
: prettyprint-list ( indent list -- indent )
#! Pretty-print a list, without [ and ].
[ (prettyprint-list) ] check-recursion ;
: prettyprint-[] ( indent list -- indent ) : prettyprint-[] ( indent list -- indent )
swap prettyprint-[ swap prettyprint-list prettyprint-] ; swap prettyprint-[ swap prettyprint-list prettyprint-] ;
@ -128,7 +118,7 @@ DEFER: prettyprint*
: prettyprint-vector ( indent list -- indent ) : prettyprint-vector ( indent list -- indent )
#! Pretty-print a vector, without { and }. #! Pretty-print a vector, without { and }.
[ [ prettyprint-element ] vector-each ] check-recursion ; [ prettyprint-element ] vector-each ;
: prettyprint-{} ( indent vector -- indent ) : prettyprint-{} ( indent vector -- indent )
dup vector-length 0 = [ dup vector-length 0 = [
@ -181,6 +171,9 @@ DEFER: prettyprint*
unparse write ; unparse write ;
: prettyprint* ( indent obj -- indent ) : prettyprint* ( indent obj -- indent )
over prettyprint-limit >= [
unparse write
] [
[ [
[ f = ] [ prettyprint-object ] [ f = ] [ prettyprint-object ]
[ cons? ] [ prettyprint-[] ] [ cons? ] [ prettyprint-[] ]
@ -188,7 +181,8 @@ DEFER: prettyprint*
[ comment? ] [ prettyprint-comment ] [ comment? ] [ prettyprint-comment ]
[ word? ] [ prettyprint-word ] [ word? ] [ prettyprint-word ]
[ drop t ] [ prettyprint-object ] [ drop t ] [ prettyprint-object ]
] cond ; ] cond
] ifte ;
: prettyprint ( obj -- ) : prettyprint ( obj -- )
0 swap prettyprint* drop terpri ; 0 swap prettyprint* drop terpri ;
@ -203,15 +197,15 @@ DEFER: prettyprint*
dup vocab-attrs write-attr ; dup vocab-attrs write-attr ;
: prettyprint-IN: ( indent word -- ) : prettyprint-IN: ( indent word -- )
"IN:" write prettyprint-space \ IN: prettyprint-word prettyprint-space
word-vocabulary prettyprint-vocab prettyprint-newline ; word-vocabulary prettyprint-vocab prettyprint-newline ;
: prettyprint-: ( indent -- indent ) : prettyprint-: ( indent -- indent )
":" write prettyprint-space \ : prettyprint-word prettyprint-space
tab-size + ; tab-size + ;
: prettyprint-; ( indent -- indent ) : prettyprint-; ( indent -- indent )
";" write \ ; prettyprint-word
tab-size - ; tab-size - ;
: prettyprint-plist ( word -- ) : prettyprint-plist ( word -- )

View File

@ -258,43 +258,16 @@ DEFER: (infer)
[ init-inference (infer) effect ] with-scope ; [ init-inference (infer) effect ] with-scope ;
\ call [ pop-d (infer) ] "infer" set-word-property \ call [ pop-d (infer) ] "infer" set-word-property
\ call [ 1 | 0 ] "infer-effect" set-word-property
\ ifte [ 3 | 0 ] "infer-effect" set-word-property
\ ifte [ infer-ifte ] "infer" set-word-property \ ifte [ infer-ifte ] "infer" set-word-property
\ >r [ pop-d push-r ] "infer" set-word-property \ >r [ pop-d push-r ] "infer" set-word-property
\ >r [ 1 | 0 ] "infer-effect" set-word-property
\ r> [ pop-r push-d ] "infer" set-word-property \ r> [ pop-r push-d ] "infer" set-word-property
\ r> [ 0 | 1 ] "infer-effect" set-word-property
\ drop t "meta-infer" set-word-property \ drop t "meta-infer" set-word-property
\ drop [ 1 | 0 ] "infer-effect" set-word-property
\ nip t "meta-infer" set-word-property
\ nip [ 2 | 1 ] "infer-effect" set-word-property
\ dup t "meta-infer" set-word-property \ dup t "meta-infer" set-word-property
\ dup [ 1 | 2 ] "infer-effect" set-word-property
\ over t "meta-infer" set-word-property
\ over [ 2 | 3 ] "infer-effect" set-word-property
\ pick t "meta-infer" set-word-property
\ pick [ 3 | 4 ] "infer-effect" set-word-property
\ swap t "meta-infer" set-word-property \ swap t "meta-infer" set-word-property
\ swap [ 2 | 2 ] "infer-effect" set-word-property \ over t "meta-infer" set-word-property
\ pick t "meta-infer" set-word-property
\ nip t "meta-infer" set-word-property
\ tuck t "meta-infer" set-word-property
\ rot t "meta-infer" set-word-property \ rot t "meta-infer" set-word-property
\ rot [ 3 | 3 ] "infer-effect" set-word-property
\ type [ 1 | 1 ] "infer-effect" set-word-property
\ eq? [ 2 | 1 ] "infer-effect" set-word-property
\ car [ 1 | 1 ] "infer-effect" set-word-property
\ cdr [ 1 | 1 ] "infer-effect" set-word-property
\ cons [ 2 | 1 ] "infer-effect" set-word-property
\ fixnum+ [ 2 | 1 ] "infer-effect" set-word-property
\ fixnum- [ 2 | 1 ] "infer-effect" set-word-property
\ fixnum* [ 2 | 1 ] "infer-effect" set-word-property
\ vector-nth [ 2 | 1 ] "infer-effect" set-word-property
\ set-vector-nth [ 3 | 0 ] "infer-effect" set-word-property
\ vector-length [ 1 | 1 ] "infer-effect" set-word-property
\ set-vector-length [ 2 | 0 ] "infer-effect" set-word-property