Merge branch 'master' of git://factorcode.org/git/factor
commit
a6ce1fdfda
|
@ -1,12 +1,14 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
|
! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel namespaces sequences sequences.private assocs math
|
USING: kernel namespaces sequences sequences.private assocs math
|
||||||
parser words quotations debugger macros arrays macros splitting
|
vectors strings generalizations
|
||||||
combinators prettyprint.backend definitions prettyprint
|
parser words quotations debugger macros arrays macros splitting
|
||||||
hashtables prettyprint.sections sets sequences.private effects
|
combinators prettyprint.backend definitions prettyprint
|
||||||
effects.parser generic generic.parser compiler.units accessors
|
hashtables prettyprint.sections sets sequences.private effects
|
||||||
locals.backend memoize macros.expander lexer
|
effects.parser generic generic.parser compiler.units accessors
|
||||||
stack-checker.known-words ;
|
locals.backend memoize macros.expander lexer
|
||||||
|
stack-checker.known-words ;
|
||||||
|
|
||||||
IN: locals
|
IN: locals
|
||||||
|
|
||||||
! Inspired by
|
! Inspired by
|
||||||
|
@ -198,6 +200,40 @@ M: object lambda-rewrite* , ;
|
||||||
|
|
||||||
M: object local-rewrite* , ;
|
M: object local-rewrite* , ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
! Broil is used to support locals in literals
|
||||||
|
|
||||||
|
DEFER: [broil]
|
||||||
|
|
||||||
|
: broil-element ( obj -- quot )
|
||||||
|
{
|
||||||
|
{ [ dup number? ] [ 1quotation ] }
|
||||||
|
{ [ dup string? ] [ 1quotation ] }
|
||||||
|
{ [ dup sequence? ] [ [broil] ] }
|
||||||
|
{ [ dup local? ] [ 1quotation ] }
|
||||||
|
{ [ dup word? ] [ literalize 1quotation ] }
|
||||||
|
{ [ t ] [ 1quotation ] }
|
||||||
|
}
|
||||||
|
cond ;
|
||||||
|
|
||||||
|
: [broil] ( seq -- quot )
|
||||||
|
[ [ broil-element ] map concat >quotation ]
|
||||||
|
[ length ]
|
||||||
|
[ ]
|
||||||
|
tri
|
||||||
|
[ nsequence ] curry curry compose ;
|
||||||
|
|
||||||
|
MACRO: broil ( seq -- quot ) [broil] ;
|
||||||
|
|
||||||
|
! Engage broil on arrays and vectors. Can't do it on 'sequence'
|
||||||
|
! because that will pick up strings and integers. What do do...
|
||||||
|
|
||||||
|
M: array local-rewrite* ( array -- ) [broil] % ;
|
||||||
|
M: vector local-rewrite* ( vector -- ) [broil] % ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
: make-local ( name -- word )
|
: make-local ( name -- word )
|
||||||
"!" ?tail [
|
"!" ?tail [
|
||||||
<local-reader>
|
<local-reader>
|
||||||
|
|
Loading…
Reference in New Issue