renaming word-parameter to word-def; renaming word-property to word-prop

cvs
Slava Pestov 2005-03-05 19:45:23 +00:00
parent 76efdb2f1d
commit f0dfb77690
56 changed files with 359 additions and 329 deletions

View File

@ -6,6 +6,13 @@
+ ui: + ui:
- resizing a gadget should probably relayout children
- when halo is shown, rollovers don't disappear
- halo outline should be the clipped rect
- sometimes releasing moving gadget doesn't work
- after moving halo, halo is underneath the gadget
- resizing: drag relative to initial click pos
- thumb gadgetry breaks with halo sometimes
- mouse enter onto overlapping with interior, but not child, gadget - mouse enter onto overlapping with interior, but not child, gadget
- menu dragging - menu dragging
- scrollable inspector - scrollable inspector
@ -17,7 +24,6 @@
- console: scroll to bottom - console: scroll to bottom
- split preferred size and layouting - split preferred size and layouting
- remove shelf/pile duplication - remove shelf/pile duplication
- resizing gadgets
- faster layout - faster layout
- faster repaint - faster repaint
- closing inspectors - closing inspectors

View File

@ -68,7 +68,7 @@ vocabularies get [
"syntax" get [ "syntax" get [
cdr dup word? [ cdr dup word? [
"syntax" "vocabulary" set-word-property "syntax" "vocabulary" set-word-prop
] [ ] [
drop drop
] ifte ] ifte

View File

@ -191,7 +191,7 @@ M: f ' ( obj -- ptr )
dup hashcode fixnum-tag immediate , dup hashcode fixnum-tag immediate ,
0 , 0 ,
dup word-primitive , dup word-primitive ,
dup word-parameter ' , dup word-def ' ,
dup word-props ' , dup word-props ' ,
0 , 0 ,
0 , 0 ,

View File

@ -198,8 +198,8 @@ vocabularies get [
] [ ] [
3unlist >r create >r 1 + r> 2dup swap f define r> 3unlist >r create >r 1 + r> 2dup swap f define r>
dup string? [ dup string? [
"stack-effect" set-word-property "stack-effect" set-word-prop
] [ ] [
"infer-effect" set-word-property "infer-effect" set-word-prop
] ifte ] ifte
] each drop ] each drop

View File

@ -126,7 +126,7 @@ SYMBOL: alien-parameters
r> swap [ drop ] [ #cleanup swons , ] ifte r> swap [ drop ] [ #cleanup swons , ] ifte
linearize-returns ; linearize-returns ;
#alien-invoke [ linearize-alien ] "linearizer" set-word-property #alien-invoke [ linearize-alien ] "linearizer" set-word-prop
: alien-invoke ( ... returns library function parameters -- ... ) : alien-invoke ( ... returns library function parameters -- ... )
#! Call a C library function. #! Call a C library function.
@ -140,9 +140,9 @@ SYMBOL: alien-parameters
] make-string throw ; ] make-string throw ;
\ alien-invoke [ [ object object object object ] [ ] ] \ alien-invoke [ [ object object object object ] [ ] ]
"infer-effect" set-word-property "infer-effect" set-word-prop
\ alien-invoke [ infer-alien ] "infer" set-word-property \ alien-invoke [ infer-alien ] "infer" set-word-prop
global [ global [
"libraries" get [ <namespace> "libraries" set ] unless "libraries" get [ <namespace> "libraries" set ] unless

View File

@ -56,7 +56,7 @@ USE: test
"verbose-compile" get [ "verbose-compile" get [
"Compiling " write dup . flush "Compiling " write dup . flush
] when ] when
dup word-parameter ; dup word-def ;
GENERIC: (compile) ( word -- ) GENERIC: (compile) ( word -- )
@ -69,7 +69,7 @@ M: compound (compile) ( word -- )
: precompile ( word -- ) : precompile ( word -- )
#! Print linear IR of word. #! Print linear IR of word.
[ [
word-parameter dataflow optimize linearize simplify [.] word-def dataflow optimize linearize simplify [.]
] with-scope ; ] with-scope ;
: compile-postponed ( -- ) : compile-postponed ( -- )

View File

@ -34,7 +34,7 @@ SYMBOL: relocation-table
: generate-node ( [[ op params ]] -- ) : generate-node ( [[ op params ]] -- )
#! Generate machine code for a node. #! Generate machine code for a node.
unswons dup "generator" word-property [ unswons dup "generator" word-prop [
call call
] [ ] [
"No generator" throw "No generator" throw
@ -76,9 +76,9 @@ SYMBOL: previous-offset
] when* ] when*
] catch ; ] catch ;
#label [ save-xt ] "generator" set-word-property #label [ save-xt ] "generator" set-word-prop
#end-dispatch [ drop ] "generator" set-word-property #end-dispatch [ drop ] "generator" set-word-prop
: type-tag ( type -- tag ) : type-tag ( type -- tag )
#! Given a type number, return the tag number. #! Given a type number, return the tag number.

View File

@ -62,13 +62,13 @@ SYMBOL: #end-dispatch
[ node-param get ] bind [ node-param get ] bind
dup immediate? #push-immediate #push-indirect ? dup immediate? #push-immediate #push-indirect ?
swons , swons ,
] "linearizer" set-word-property ] "linearizer" set-word-prop
: <label> ( -- label ) : <label> ( -- label )
gensym dup t "label" set-word-property ; gensym dup t "label" set-word-prop ;
: label? ( obj -- ? ) : label? ( obj -- ? )
dup word? [ "label" word-property ] [ drop f ] ifte ; dup word? [ "label" word-prop ] [ drop f ] ifte ;
: label, ( label -- ) : label, ( label -- )
#label swons , ; #label swons , ;
@ -81,7 +81,7 @@ SYMBOL: #end-dispatch
#simple-label [ #simple-label [
linearize-simple-label linearize-simple-label
] "linearizer" set-word-property ] "linearizer" set-word-prop
: linearize-label ( node -- ) : linearize-label ( node -- )
#! Labels are tricky, because they might contain non-tail #! Labels are tricky, because they might contain non-tail
@ -97,7 +97,7 @@ SYMBOL: #end-dispatch
#label [ #label [
linearize-label linearize-label
] "linearizer" set-word-property ] "linearizer" set-word-prop
: linearize-ifte ( param -- ) : linearize-ifte ( param -- )
#! The parameter is a list of two lists, each one a dataflow #! The parameter is a list of two lists, each one a dataflow
@ -112,7 +112,7 @@ SYMBOL: #end-dispatch
\ ifte [ \ ifte [
[ node-param get ] bind linearize-ifte [ node-param get ] bind linearize-ifte
] "linearizer" set-word-property ] "linearizer" set-word-prop
: dispatch-head ( vtable -- end label/code ) : dispatch-head ( vtable -- end label/code )
#! Output the jump table insn and return a list of #! Output the jump table insn and return a list of
@ -133,6 +133,6 @@ SYMBOL: #end-dispatch
\ dispatch [ \ dispatch [
[ node-param get ] bind linearize-dispatch [ node-param get ] bind linearize-dispatch
] "linearizer" set-word-property ] "linearizer" set-word-prop
#values [ drop ] "linearizer" set-word-property #values [ drop ] "linearizer" set-word-prop

View File

@ -131,43 +131,43 @@ SYMBOL: branch-returns
node-param [ [ dupd kill-nodes ] map nip ] change node-param [ [ dupd kill-nodes ] map nip ] change
] extend , ; ] extend , ;
#push [ [ node-param get ] bind , ] "scan-literal" set-word-property #push [ [ node-param get ] bind , ] "scan-literal" set-word-prop
#push [ consumes-literal? not ] "can-kill" set-word-property #push [ consumes-literal? not ] "can-kill" set-word-prop
#push [ kill-node ] "kill-node" set-word-property #push [ kill-node ] "kill-node" set-word-prop
#label [ #label [
[ node-param get ] bind (scan-literals) [ node-param get ] bind (scan-literals)
] "scan-literal" set-word-property ] "scan-literal" set-word-prop
#label [ #label [
[ node-param get ] bind can-kill? [ node-param get ] bind can-kill?
] "can-kill" set-word-property ] "can-kill" set-word-prop
#call-label [ #call-label [
[ node-param get ] bind = [ node-param get ] bind =
] "calls-label" set-word-property ] "calls-label" set-word-prop
: calls-label? ( label list -- ? ) : calls-label? ( label list -- ? )
[ "calls-label" [ 2drop f ] apply-dataflow ] some-with? ; [ "calls-label" [ 2drop f ] apply-dataflow ] some-with? ;
#label [ #label [
[ node-param get ] bind calls-label? [ node-param get ] bind calls-label?
] "calls-label" set-word-property ] "calls-label" set-word-prop
#simple-label [ #simple-label [
[ node-param get ] bind calls-label? [ node-param get ] bind calls-label?
] "calls-label" set-word-property ] "calls-label" set-word-prop
: branches-call-label? ( label list -- ? ) : branches-call-label? ( label list -- ? )
[ calls-label? ] some-with? ; [ calls-label? ] some-with? ;
\ ifte [ \ ifte [
[ node-param get ] bind branches-call-label? [ node-param get ] bind branches-call-label?
] "calls-label" set-word-property ] "calls-label" set-word-prop
\ dispatch [ \ dispatch [
[ node-param get ] bind branches-call-label? [ node-param get ] bind branches-call-label?
] "calls-label" set-word-property ] "calls-label" set-word-prop
: optimize-label ( -- op ) : optimize-label ( -- op )
#! Does the label node contain calls to itself? #! Does the label node contain calls to itself?
@ -179,7 +179,7 @@ SYMBOL: branch-returns
optimize-label node-op set optimize-label node-op set
node-param [ kill-nodes ] change node-param [ kill-nodes ] change
] extend , ] extend ,
] "kill-node" set-word-property ] "kill-node" set-word-prop
#values [ #values [
dupd consumes-literal? [ dupd consumes-literal? [
@ -187,25 +187,25 @@ SYMBOL: branch-returns
] [ ] [
drop t drop t
] ifte ] ifte
] "can-kill" set-word-property ] "can-kill" set-word-prop
\ ifte [ scan-branches ] "scan-literal" set-word-property \ ifte [ scan-branches ] "scan-literal" set-word-prop
\ ifte [ can-kill-branches? ] "can-kill" set-word-property \ ifte [ can-kill-branches? ] "can-kill" set-word-prop
\ ifte [ kill-branches ] "kill-node" set-word-property \ ifte [ kill-branches ] "kill-node" set-word-prop
\ dispatch [ scan-branches ] "scan-literal" set-word-property \ dispatch [ scan-branches ] "scan-literal" set-word-prop
\ dispatch [ can-kill-branches? ] "can-kill" set-word-property \ dispatch [ can-kill-branches? ] "can-kill" set-word-prop
\ dispatch [ kill-branches ] "kill-node" set-word-property \ dispatch [ kill-branches ] "kill-node" set-word-prop
! Don't care about inputs to recursive combinator calls ! Don't care about inputs to recursive combinator calls
#call-label [ 2drop t ] "can-kill" set-word-property #call-label [ 2drop t ] "can-kill" set-word-prop
\ drop [ 2drop t ] "can-kill" set-word-property \ drop [ 2drop t ] "can-kill" set-word-prop
\ drop [ kill-node ] "kill-node" set-word-property \ drop [ kill-node ] "kill-node" set-word-prop
\ dup [ 2drop t ] "can-kill" set-word-property \ dup [ 2drop t ] "can-kill" set-word-prop
\ dup [ kill-node ] "kill-node" set-word-property \ dup [ kill-node ] "kill-node" set-word-prop
\ swap [ 2drop t ] "can-kill" set-word-property \ swap [ 2drop t ] "can-kill" set-word-prop
\ swap [ kill-node ] "kill-node" set-word-property \ swap [ kill-node ] "kill-node" set-word-prop
: kill-mask ( killing inputs -- mask ) : kill-mask ( killing inputs -- mask )
[ over [ over value= ] some? >boolean nip ] map nip ; [ over [ over value= ] some? >boolean nip ] map nip ;
@ -219,15 +219,15 @@ SYMBOL: branch-returns
] keep ] keep
over [ [ node-op set ] extend , ] [ 2drop ] ifte ; over [ [ node-op set ] extend , ] [ 2drop ] ifte ;
\ over [ 2drop t ] "can-kill" set-word-property \ over [ 2drop t ] "can-kill" set-word-prop
\ over [ \ over [
[ [
[[ [ f f ] over ]] [[ [ f f ] over ]]
[[ [ f t ] dup ]] [[ [ f t ] dup ]]
] reduce-stack-op ] reduce-stack-op
] "kill-node" set-word-property ] "kill-node" set-word-prop
\ pick [ 2drop t ] "can-kill" set-word-property \ pick [ 2drop t ] "can-kill" set-word-prop
\ pick [ \ pick [
[ [
[[ [ f f f ] pick ]] [[ [ f f f ] pick ]]
@ -235,9 +235,9 @@ SYMBOL: branch-returns
[[ [ f t f ] over ]] [[ [ f t f ] over ]]
[[ [ f t t ] dup ]] [[ [ f t t ] dup ]]
] reduce-stack-op ] reduce-stack-op
] "kill-node" set-word-property ] "kill-node" set-word-prop
\ >r [ 2drop t ] "can-kill" set-word-property \ >r [ 2drop t ] "can-kill" set-word-prop
\ >r [ kill-node ] "kill-node" set-word-property \ >r [ kill-node ] "kill-node" set-word-prop
\ r> [ 2drop t ] "can-kill" set-word-property \ r> [ 2drop t ] "can-kill" set-word-prop
\ r> [ kill-node ] "kill-node" set-word-property \ r> [ kill-node ] "kill-node" set-word-prop

View File

@ -11,7 +11,7 @@ SYMBOL: simplifying
#! A list of quotations with stack effect #! A list of quotations with stack effect
#! ( linear -- linear ? ) that can simplify the first node #! ( linear -- linear ? ) that can simplify the first node
#! in the linear IR. #! in the linear IR.
car car "simplifiers" word-property ; car car "simplifiers" word-prop ;
: simplify-node ( linear list -- linear ? ) : simplify-node ( linear list -- linear ? )
dup [ dup [
@ -45,7 +45,7 @@ SYMBOL: simplifying
dup car cdr simplifying get label-called? dup car cdr simplifying get label-called?
[ f ] [ cdr t ] ifte [ f ] [ cdr t ] ifte
] ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
: next-physical? ( op linear -- ? ) : next-physical? ( op linear -- ? )
cdr dup [ car car = ] [ 2drop f ] ifte ; cdr dup [ car car = ] [ 2drop f ] ifte ;
@ -55,10 +55,10 @@ SYMBOL: simplifying
#! its param. #! its param.
over next-physical? [ cdr unswons cdr t ] [ f f ] ifte ; over next-physical? [ cdr unswons cdr t ] [ f f ] ifte ;
\ >r [ [ \ r> cancel nip ] ] "simplifiers" set-word-property \ >r [ [ \ r> cancel nip ] ] "simplifiers" set-word-prop
\ r> [ [ \ >r cancel nip ] ] "simplifiers" set-word-property \ r> [ [ \ >r cancel nip ] ] "simplifiers" set-word-prop
\ dup [ [ \ drop cancel nip ] ] "simplifiers" set-word-property \ dup [ [ \ drop cancel nip ] ] "simplifiers" set-word-prop
\ swap [ [ \ swap cancel nip ] ] "simplifiers" set-word-property \ swap [ [ \ swap cancel nip ] ] "simplifiers" set-word-prop
\ drop [ \ drop [
[ [
@ -70,7 +70,7 @@ SYMBOL: simplifying
#replace-indirect swons swons t #replace-indirect swons swons t
] when ] when
] ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
: find-label ( label -- rest ) : find-label ( label -- rest )
simplifying get [ simplifying get [
@ -78,19 +78,19 @@ SYMBOL: simplifying
] some? nip ; ] some? nip ;
: next-logical ( linear -- linear ) : next-logical ( linear -- linear )
dup car car "next-logical" word-property call ; dup car car "next-logical" word-prop call ;
#label [ #label [
cdr next-logical cdr next-logical
] "next-logical" set-word-property ] "next-logical" set-word-prop
#jump-label [ #jump-label [
car cdr find-label cdr car cdr find-label cdr
] "next-logical" set-word-property ] "next-logical" set-word-prop
#target-label [ #target-label [
car cdr find-label cdr car cdr find-label cdr
] "next-logical" set-word-property ] "next-logical" set-word-prop
: next-logical? ( op linear -- ? ) : next-logical? ( op linear -- ? )
next-logical dup [ car car = ] [ 2drop f ] ifte ; next-logical dup [ car car = ] [ 2drop f ] ifte ;
@ -104,11 +104,11 @@ SYMBOL: simplifying
#call [ #call [
[ #return #jump reduce ] [ #return #jump reduce ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
#call-label [ #call-label [
[ #return #jump-label reduce ] [ #return #jump-label reduce ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
: double-jump ( linear op1 op2 -- linear ? ) : double-jump ( linear op1 op2 -- linear ? )
#! A jump to a jump is just a jump. If the next logical node #! A jump to a jump is just a jump. If the next logical node
@ -145,13 +145,13 @@ SYMBOL: simplifying
[ #jump #jump double-jump ] [ #jump #jump double-jump ]
[ useless-jump ] [ useless-jump ]
[ dead-code ] [ dead-code ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
#target-label [ #target-label [
[ #jump-label #target-label double-jump ] [ #jump-label #target-label double-jump ]
[ #jump #target double-jump ] [ #jump #target double-jump ]
] "simplifiers" set-word-property ] "simplifiers" set-word-prop
#jump [ [ dead-code ] ] "simplifiers" set-word-property #jump [ [ dead-code ] ] "simplifiers" set-word-prop
#return [ [ dead-code ] ] "simplifiers" set-word-property #return [ [ dead-code ] ] "simplifiers" set-word-prop
#end-dispatch [ [ dead-code ] ] "simplifiers" set-word-property #end-dispatch [ [ dead-code ] ] "simplifiers" set-word-prop

View File

@ -87,7 +87,7 @@ GENERIC: displacement ( op -- )
( Register operands -- eg, ECX ) ( Register operands -- eg, ECX )
: REGISTER: : REGISTER:
CREATE dup define-symbol CREATE dup define-symbol
scan-word "register" set-word-property ; parsing scan-word "register" set-word-prop ; parsing
REGISTER: EAX 0 REGISTER: EAX 0
REGISTER: ECX 1 REGISTER: ECX 1
@ -98,10 +98,10 @@ REGISTER: EBP 5
REGISTER: ESI 6 REGISTER: ESI 6
REGISTER: EDI 7 REGISTER: EDI 7
PREDICATE: word register "register" word-property ; PREDICATE: word register "register" word-prop ;
M: register modifier drop BIN: 11 ; M: register modifier drop BIN: 11 ;
M: register register "register" word-property ; M: register register "register" word-prop ;
M: register displacement drop ; M: register displacement drop ;
( Indirect register operands -- eg, [ ECX ] ) ( Indirect register operands -- eg, [ ECX ] )

View File

@ -43,7 +43,7 @@ USE: math-internals
! prototype to test the assembler. ! prototype to test the assembler.
: self ( word -- ) : self ( word -- )
f swap dup "infer-effect" word-property (consume/produce) ; f swap dup "infer-effect" word-prop (consume/produce) ;
: fixnum-insn ( overflow opcode -- ) : fixnum-insn ( overflow opcode -- )
#! This needs to be factored. #! This needs to be factored.
@ -59,15 +59,15 @@ USE: math-internals
\ fixnum+ [ \ fixnum+ [
drop \ fixnum+ \ ADD fixnum-insn drop \ fixnum+ \ ADD fixnum-insn
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum+ [ \ fixnum+ self ] "infer" set-word-property \ fixnum+ [ \ fixnum+ self ] "infer" set-word-prop
\ fixnum- [ \ fixnum- [
drop \ fixnum- \ SUB fixnum-insn drop \ fixnum- \ SUB fixnum-insn
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum- [ \ fixnum- self ] "infer" set-word-property \ fixnum- [ \ fixnum- self ] "infer" set-word-prop
\ fixnum* [ \ fixnum* [
drop drop
@ -81,9 +81,9 @@ USE: math-internals
ESI 4 SUB ESI 4 SUB
[ ESI ] EAX MOV [ ESI ] EAX MOV
r> compiled-offset swap patch r> compiled-offset swap patch
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum* [ \ fixnum* self ] "infer" set-word-property \ fixnum* [ \ fixnum* self ] "infer" set-word-prop
\ fixnum/i [ \ fixnum/i [
drop drop
@ -98,9 +98,9 @@ USE: math-internals
ESI 4 SUB ESI 4 SUB
[ ESI ] EAX MOV [ ESI ] EAX MOV
r> compiled-offset swap patch r> compiled-offset swap patch
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum/i [ \ fixnum/i self ] "infer" set-word-property \ fixnum/i [ \ fixnum/i self ] "infer" set-word-prop
\ fixnum-mod [ \ fixnum-mod [
drop drop
@ -115,9 +115,9 @@ USE: math-internals
ESI 4 SUB ESI 4 SUB
[ ESI ] EDX MOV [ ESI ] EDX MOV
r> compiled-offset swap patch r> compiled-offset swap patch
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum-mod [ \ fixnum-mod self ] "infer" set-word-property \ fixnum-mod [ \ fixnum-mod self ] "infer" set-word-prop
\ fixnum/mod [ \ fixnum/mod [
drop drop
@ -132,9 +132,9 @@ USE: math-internals
[ ESI -4 ] EAX MOV [ ESI -4 ] EAX MOV
[ ESI ] EDX MOV [ ESI ] EDX MOV
r> compiled-offset swap patch r> compiled-offset swap patch
] "generator" set-word-property ] "generator" set-word-prop
\ fixnum/mod [ \ fixnum/mod self ] "infer" set-word-property \ fixnum/mod [ \ fixnum/mod self ] "infer" set-word-prop
\ arithmetic-type [ \ arithmetic-type [
drop drop
@ -150,6 +150,6 @@ USE: math-internals
EAX 3 SHL EAX 3 SHL
PUSH-DS PUSH-DS
compiled-offset swap patch compiled-offset swap patch
] "generator" set-word-property ] "generator" set-word-prop
\ arithmetic-type [ \ arithmetic-type self ] "infer" set-word-property \ arithmetic-type [ \ arithmetic-type self ] "infer" set-word-prop

View File

@ -8,7 +8,7 @@ math memory namespaces words ;
PEEK-DS PEEK-DS
2unlist type-tag >r cell * r> - EAX swap 2list EAX swap MOV 2unlist type-tag >r cell * r> - EAX swap 2list EAX swap MOV
[ ESI ] EAX MOV [ ESI ] EAX MOV
] "generator" set-word-property ] "generator" set-word-prop
: compile-call-label ( label -- ) : compile-call-label ( label -- )
0 CALL fixup compiled-offset defer-xt ; 0 CALL fixup compiled-offset defer-xt ;
@ -24,21 +24,21 @@ math memory namespaces words ;
#call [ #call [
compile-call compile-call
] "generator" set-word-property ] "generator" set-word-prop
#jump [ #jump [
dup dup postpone-word dup dup postpone-word
compile-jump-label compile-jump-label
t rel-word t rel-word
] "generator" set-word-property ] "generator" set-word-prop
#call-label [ #call-label [
compile-call-label compile-call-label
] "generator" set-word-property ] "generator" set-word-prop
#jump-label [ #jump-label [
compile-jump-label compile-jump-label
] "generator" set-word-property ] "generator" set-word-prop
: compile-jump-t ( word -- ) : compile-jump-t ( word -- )
POP-DS POP-DS
@ -49,11 +49,11 @@ math memory namespaces words ;
#jump-t-label [ #jump-t-label [
compile-jump-t compile-jump-t
] "generator" set-word-property ] "generator" set-word-prop
#jump-t [ #jump-t [
dup compile-jump-t t rel-word dup compile-jump-t t rel-word
] "generator" set-word-property ] "generator" set-word-prop
: compile-jump-f ( word -- ) : compile-jump-f ( word -- )
POP-DS POP-DS
@ -64,17 +64,17 @@ math memory namespaces words ;
#jump-f-label [ #jump-f-label [
compile-jump-f compile-jump-f
] "generator" set-word-property ] "generator" set-word-prop
#jump-f [ #jump-f [
dup compile-jump-f t rel-word dup compile-jump-f t rel-word
] "generator" set-word-property ] "generator" set-word-prop
#return-to [ #return-to [
0 PUSH fixup 0 defer-xt rel-address 0 PUSH fixup 0 defer-xt rel-address
] "generator" set-word-property ] "generator" set-word-prop
#return [ drop RET ] "generator" set-word-property #return [ drop RET ] "generator" set-word-prop
\ dispatch [ \ dispatch [
#! Compile a piece of code that jumps to an offset in a #! Compile a piece of code that jumps to an offset in a
@ -87,33 +87,33 @@ math memory namespaces words ;
[ EAX ] JMP [ EAX ] JMP
compile-aligned compile-aligned
compiled-offset swap set-compiled-cell ( fixup -- ) compiled-offset swap set-compiled-cell ( fixup -- )
] "generator" set-word-property ] "generator" set-word-prop
#target-label [ #target-label [
#! Jump table entries are absolute addresses. #! Jump table entries are absolute addresses.
compile-target rel-address compile-target rel-address
] "generator" set-word-property ] "generator" set-word-prop
#target [ #target [
#! Jump table entries are absolute addresses. #! Jump table entries are absolute addresses.
dup dup postpone-word compile-target f rel-word dup dup postpone-word compile-target f rel-word
] "generator" set-word-property ] "generator" set-word-prop
#c-call [ #c-call [
uncons load-dll 2dup dlsym CALL t rel-dlsym uncons load-dll 2dup dlsym CALL t rel-dlsym
] "generator" set-word-property ] "generator" set-word-prop
#unbox [ #unbox [
dup f dlsym CALL f t rel-dlsym dup f dlsym CALL f t rel-dlsym
EAX PUSH EAX PUSH
] "generator" set-word-property ] "generator" set-word-prop
#box [ #box [
EAX PUSH EAX PUSH
dup f dlsym CALL f t rel-dlsym dup f dlsym CALL f t rel-dlsym
ESP 4 ADD ESP 4 ADD
] "generator" set-word-property ] "generator" set-word-prop
#cleanup [ #cleanup [
dup 0 = [ drop ] [ ESP swap ADD ] ifte dup 0 = [ drop ] [ ESP swap ADD ] ifte
] "generator" set-word-property ] "generator" set-word-prop

View File

@ -52,32 +52,32 @@ USING: inference kernel assembler words lists alien memory ;
#push-immediate [ #push-immediate [
ESI 4 ADD ESI 4 ADD
immediate-literal immediate-literal
] "generator" set-word-property ] "generator" set-word-prop
#push-indirect [ #push-indirect [
indirect-literal indirect-literal
PUSH-DS PUSH-DS
] "generator" set-word-property ] "generator" set-word-prop
#replace-immediate [ #replace-immediate [
immediate-literal immediate-literal
] "generator" set-word-property ] "generator" set-word-prop
#replace-indirect [ #replace-indirect [
indirect-literal indirect-literal
[ ESI ] EAX MOV [ ESI ] EAX MOV
] "generator" set-word-property ] "generator" set-word-prop
\ drop [ \ drop [
drop drop
ESI 4 SUB ESI 4 SUB
] "generator" set-word-property ] "generator" set-word-prop
\ dup [ \ dup [
drop drop
PEEK-DS PEEK-DS
PUSH-DS PUSH-DS
] "generator" set-word-property ] "generator" set-word-prop
\ swap [ \ swap [
drop drop
@ -85,29 +85,29 @@ USING: inference kernel assembler words lists alien memory ;
EDX [ ESI -4 ] MOV EDX [ ESI -4 ] MOV
[ ESI ] EDX MOV [ ESI ] EDX MOV
[ ESI -4 ] EAX MOV [ ESI -4 ] EAX MOV
] "generator" set-word-property ] "generator" set-word-prop
\ over [ \ over [
drop drop
EAX [ ESI -4 ] MOV EAX [ ESI -4 ] MOV
PUSH-DS PUSH-DS
] "generator" set-word-property ] "generator" set-word-prop
\ pick [ \ pick [
drop drop
EAX [ ESI -8 ] MOV EAX [ ESI -8 ] MOV
PUSH-DS PUSH-DS
] "generator" set-word-property ] "generator" set-word-prop
\ >r [ \ >r [
drop drop
POP-DS POP-DS
ECX CS> ECX CS>
PUSH-CS PUSH-CS
] "generator" set-word-property ] "generator" set-word-prop
\ r> [ \ r> [
drop drop
POP-CS POP-CS
PUSH-DS PUSH-DS
] "generator" set-word-property ] "generator" set-word-prop

View File

@ -57,7 +57,7 @@ SYMBOL: compiled-xts
compiled-offset swap compiled-xts [ acons ] change ; compiled-offset swap compiled-xts [ acons ] change ;
: commit-xt ( xt word -- ) : commit-xt ( xt word -- )
dup t "compiled" set-word-property set-word-xt ; dup t "compiled" set-word-prop set-word-xt ;
: commit-xts ( -- ) : commit-xts ( -- )
compiled-xts get [ unswons commit-xt ] each compiled-xts get [ unswons commit-xt ] each

View File

@ -8,32 +8,32 @@ words vectors ;
SYMBOL: builtin SYMBOL: builtin
builtin [ builtin [
"builtin-type" word-property unit "builtin-type" word-prop unit
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
builtin [ builtin [
( generic vtable definition class -- ) ( generic vtable definition class -- )
rot set-vtable drop rot set-vtable drop
] "add-method" set-word-property ] "add-method" set-word-prop
builtin 50 "priority" set-word-property builtin 50 "priority" set-word-prop
! All builtin types are equivalent in ordering ! All builtin types are equivalent in ordering
builtin [ 2drop t ] "class<" set-word-property builtin [ 2drop t ] "class<" set-word-prop
: builtin-predicate ( type# symbol -- ) : builtin-predicate ( type# symbol -- )
#! We call search here because we have to know if the symbol #! We call search here because we have to know if the symbol
#! is t or f, and cannot compare type numbers or symbol #! is t or f, and cannot compare type numbers or symbol
#! identity during bootstrapping. #! identity during bootstrapping.
dup "f" [ "syntax" ] search = [ dup "f" [ "syntax" ] search = [
nip [ not ] "predicate" set-word-property nip [ not ] "predicate" set-word-prop
] [ ] [
dup "t" [ "syntax" ] search = [ dup "t" [ "syntax" ] search = [
nip [ ] "predicate" set-word-property nip [ ] "predicate" set-word-prop
] [ ] [
dup predicate-word dup predicate-word
[ rot [ swap type eq? ] cons define-compound ] keep [ rot [ swap type eq? ] cons define-compound ] keep
unit "predicate" set-word-property unit "predicate" set-word-prop
] ifte ] ifte
] ifte ; ] ifte ;
@ -41,7 +41,7 @@ builtin [ 2drop t ] "class<" set-word-property
>r swap >r swap
dup intern-symbol dup intern-symbol
2dup builtin-predicate 2dup builtin-predicate
[ swap "builtin-type" set-word-property ] keep [ swap "builtin-type" set-word-prop ] keep
dup builtin define-class r> define-slots ; dup builtin define-class r> define-slots ;
: builtin-type ( n -- symbol ) : builtin-type ( n -- symbol )

View File

@ -9,10 +9,10 @@ vectors words ;
SYMBOL: complement SYMBOL: complement
complement [ complement [
"complement" word-property builtin-supertypes "complement" word-prop builtin-supertypes
num-types count num-types count
difference difference
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
complement [ complement [
( generic vtable definition class -- ) ( generic vtable definition class -- )
@ -22,20 +22,20 @@ complement [
dup [ add-method ] [ 2drop 2drop ] ifte dup [ add-method ] [ 2drop 2drop ] ifte
] keep ] keep
] repeat 3drop ] repeat 3drop
] "add-method" set-word-property ] "add-method" set-word-prop
complement 90 "priority" set-word-property complement 90 "priority" set-word-prop
complement [ complement [
swap "complement" word-property swap "complement" word-prop
swap "complement" word-property swap "complement" word-prop
class< not class< not
] "class<" set-word-property ] "class<" set-word-prop
: complement-predicate ( complement -- list ) : complement-predicate ( complement -- list )
"predicate" word-property [ not ] append ; "predicate" word-prop [ not ] append ;
: define-complement ( class complement -- ) : define-complement ( class complement -- )
2dup "complement" set-word-property 2dup "complement" set-word-prop
dupd complement-predicate "predicate" set-word-property dupd complement-predicate "predicate" set-word-prop
complement define-class ; complement define-class ;

View File

@ -23,33 +23,33 @@ namespaces parser strings words vectors math math-internals ;
! methods are added to the vtable. ! methods are added to the vtable.
: metaclass ( class -- metaclass ) : metaclass ( class -- metaclass )
"metaclass" word-property ; "metaclass" word-prop ;
: builtin-supertypes ( class -- list ) : builtin-supertypes ( class -- list )
#! A list of builtin supertypes of the class. #! A list of builtin supertypes of the class.
dup metaclass "builtin-supertypes" word-property call ; dup metaclass "builtin-supertypes" word-prop call ;
: set-vtable ( definition class vtable -- ) : set-vtable ( definition class vtable -- )
>r "builtin-type" word-property r> set-vector-nth ; >r "builtin-type" word-prop r> set-vector-nth ;
: class-ord ( class -- n ) metaclass "priority" word-property ; : class-ord ( class -- n ) metaclass "priority" word-prop ;
: class< ( cls1 cls2 -- ? ) : class< ( cls1 cls2 -- ? )
#! Test if class1 is a subclass of class2. #! Test if class1 is a subclass of class2.
over metaclass over metaclass = [ over metaclass over metaclass = [
dup metaclass "class<" word-property call dup metaclass "class<" word-prop call
] [ ] [
swap class-ord swap class-ord < swap class-ord swap class-ord <
] ifte ; ] ifte ;
: methods ( generic -- alist ) : methods ( generic -- alist )
"methods" word-property hash>alist [ 2car class< ] sort ; "methods" word-prop hash>alist [ 2car class< ] sort ;
: add-method ( generic vtable definition class -- ) : add-method ( generic vtable definition class -- )
#! Add the method entry to the vtable. Unlike define-method, #! Add the method entry to the vtable. Unlike define-method,
#! this is called at vtable build time, and in the sorted #! this is called at vtable build time, and in the sorted
#! order. #! order.
dup metaclass "add-method" word-property [ dup metaclass "add-method" word-prop [
[ "Metaclass is missing add-method" throw ] [ "Metaclass is missing add-method" throw ]
] unless* call ; ] unless* call ;
@ -65,18 +65,20 @@ namespaces parser strings words vectors math math-internals ;
] each nip ; ] each nip ;
: make-generic ( word vtable -- ) : make-generic ( word vtable -- )
over "combination" word-property cons define-compound ; #! (define-compound) is used to avoid resetting generic
#! word properties.
over "combination" word-prop cons (define-compound) ;
: define-method ( class generic definition -- ) : define-method ( class generic definition -- )
-rot -rot
[ "methods" word-property set-hash ] keep dup <vtable> [ "methods" word-prop set-hash ] keep dup <vtable>
make-generic ; make-generic ;
: init-methods ( word -- ) : init-methods ( word -- )
dup "methods" word-property [ dup "methods" word-prop [
drop drop
] [ ] [
<namespace> "methods" set-word-property <namespace> "methods" set-word-prop
] ifte ; ] ifte ;
! Defining generic words ! Defining generic words
@ -84,8 +86,8 @@ namespaces parser strings words vectors math math-internals ;
#! Takes a combination parameter. A combination is a #! Takes a combination parameter. A combination is a
#! quotation that takes some objects and a vtable from the #! quotation that takes some objects and a vtable from the
#! stack, and calls the appropriate row of the vtable. #! stack, and calls the appropriate row of the vtable.
[ swap "definer" set-word-property ] keep [ swap "definer" set-word-prop ] keep
[ swap "combination" set-word-property ] keep [ swap "combination" set-word-prop ] keep
dup init-methods dup init-methods
dup <vtable> make-generic ; dup <vtable> make-generic ;
@ -93,7 +95,7 @@ namespaces parser strings words vectors math math-internals ;
>r dup type r> dispatch ; inline >r dup type r> dispatch ; inline
PREDICATE: compound generic ( word -- ? ) PREDICATE: compound generic ( word -- ? )
"combination" word-property [ single-combination ] = ; "combination" word-prop [ single-combination ] = ;
: arithmetic-combination ( n n vtable -- ) : arithmetic-combination ( n n vtable -- )
#! Note that the numbers remain on the stack, possibly after #! Note that the numbers remain on the stack, possibly after
@ -101,7 +103,7 @@ PREDICATE: compound generic ( word -- ? )
>r arithmetic-type r> dispatch ; inline >r arithmetic-type r> dispatch ; inline
PREDICATE: compound 2generic ( word -- ? ) PREDICATE: compound 2generic ( word -- ? )
"combination" word-property [ arithmetic-combination ] = ; "combination" word-prop [ arithmetic-combination ] = ;
! Maps lists of builtin type numbers to class objects. ! Maps lists of builtin type numbers to class objects.
SYMBOL: classes SYMBOL: classes
@ -134,7 +136,7 @@ SYMBOL: object
intersection lookup-union ; intersection lookup-union ;
: define-class ( class metaclass -- ) : define-class ( class metaclass -- )
dupd "metaclass" set-word-property dupd "metaclass" set-word-prop
dup builtin-supertypes [ > ] sort dup builtin-supertypes [ > ] sort
classes get set-hash ; classes get set-hash ;

View File

@ -5,9 +5,9 @@ USING: kernel words ;
! Null metaclass with no instances. ! Null metaclass with no instances.
SYMBOL: null SYMBOL: null
null [ drop [ ] ] "builtin-supertypes" set-word-property null [ drop [ ] ] "builtin-supertypes" set-word-prop
null [ 2drop 2drop ] "add-method" set-word-property null [ 2drop 2drop ] "add-method" set-word-prop
null [ drop f ] "predicate" set-word-property null [ drop f ] "predicate" set-word-prop
null 100 "priority" set-word-property null 100 "priority" set-word-prop
null [ 2drop t ] "class<" set-word-property null [ 2drop t ] "class<" set-word-prop
null null define-class null null define-class

View File

@ -8,19 +8,19 @@ SYMBOL: object
object [ object [
drop num-types count drop num-types count
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
object [ object [
( generic vtable definition class -- ) ( generic vtable definition class -- )
drop over vector-length [ drop over vector-length [
3dup rot set-vector-nth 3dup rot set-vector-nth
] repeat 3drop ] repeat 3drop
] "add-method" set-word-property ] "add-method" set-word-prop
object [ drop t ] "predicate" set-word-property object [ drop t ] "predicate" set-word-prop
object 100 "priority" set-word-property object 100 "priority" set-word-prop
object [ 2drop t ] "class<" set-word-property object [ 2drop t ] "class<" set-word-prop
object object define-class object object define-class

View File

@ -9,7 +9,7 @@ SYMBOL: predicate
: predicate-dispatch ( existing definition class -- dispatch ) : predicate-dispatch ( existing definition class -- dispatch )
[ [
\ dup , "predicate" word-property append, , , \ ifte , \ dup , "predicate" word-prop append, , , \ ifte ,
] make-list ; ] make-list ;
: predicate-method ( vtable definition class type# -- ) : predicate-method ( vtable definition class type# -- )
@ -20,8 +20,8 @@ SYMBOL: predicate
] 2keep set-vector-nth ; ] 2keep set-vector-nth ;
predicate [ predicate [
"superclass" word-property builtin-supertypes "superclass" word-prop builtin-supertypes
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
predicate [ predicate [
( generic vtable definition class -- ) ( generic vtable definition class -- )
@ -29,20 +29,20 @@ predicate [
( vtable definition class type# ) ( vtable definition class type# )
>r 3dup r> predicate-method >r 3dup r> predicate-method
] each 2drop 2drop ] each 2drop 2drop
] "add-method" set-word-property ] "add-method" set-word-prop
predicate 25 "priority" set-word-property predicate 25 "priority" set-word-prop
predicate [ predicate [
2dup = [ 2dup = [
2drop t 2drop t
] [ ] [
>r "superclass" word-property r> class< >r "superclass" word-prop r> class<
] ifte ] ifte
] "class<" set-word-property ] "class<" set-word-prop
: define-predicate ( class predicate definition -- ) : define-predicate ( class predicate definition -- )
pick "superclass" word-property "predicate" word-property pick "superclass" word-prop "predicate" word-prop
[ \ dup , append, , [ drop f ] , \ ifte , ] make-list [ \ dup , append, , [ drop f ] , \ ifte , ] make-list
define-compound define-compound
predicate "metaclass" set-word-property ; predicate "metaclass" set-word-prop ;

View File

@ -43,7 +43,7 @@ strings words ;
#! the form [ slot reader writer ]. slot is an integer, #! the form [ slot reader writer ]. slot is an integer,
#! reader and writer are either words, strings or f. #! reader and writer are either words, strings or f.
intern-slots intern-slots
2dup "slots" set-word-property 2dup "slots" set-word-prop
[ 3unlist define-slot ] each-with ; [ 3unlist define-slot ] each-with ;
: reader-word ( class name -- word ) : reader-word ( class name -- word )
@ -63,7 +63,7 @@ strings words ;
#! the benefit of tuples. Built-in types do not have #! the benefit of tuples. Built-in types do not have
#! delegate slots. #! delegate slots.
swap >r [ "delegate" = dup [ >r 1 + r> ] unless ] some? [ swap >r [ "delegate" = dup [ >r 1 + r> ] unless ] some? [
r> swap "delegate-slot" set-word-property r> swap "delegate-slot" set-word-prop
] [ ] [
r> 2drop r> 2drop
] ifte ; ] ifte ;

View File

@ -30,7 +30,7 @@ UNION: arrayed array tuple ;
] repeat nip ; ] repeat nip ;
: literal-tuple ( list -- tuple ) : literal-tuple ( list -- tuple )
dup car "tuple-size" word-property over length over = [ dup car "tuple-size" word-prop over length over = [
(literal-tuple) (literal-tuple)
] [ ] [
"Incorrect tuple length" throw "Incorrect tuple length" throw
@ -46,14 +46,14 @@ UNION: arrayed array tuple ;
#! If the new list of slots is different from the previous, #! If the new list of slots is different from the previous,
#! forget the old definition. #! forget the old definition.
>r "use" get search dup [ >r "use" get search dup [
dup "tuple-size" word-property r> length 1 + = dup "tuple-size" word-prop r> length 1 + =
[ drop ] [ forget ] ifte [ drop ] [ forget ] ifte
] [ ] [
r> 2drop r> 2drop
] ifte ; ] ifte ;
: tuple-slots ( tuple slots -- ) : tuple-slots ( tuple slots -- )
2dup length 1 + "tuple-size" set-word-property 2dup length 1 + "tuple-size" set-word-prop
3 -rot simple-slots ; 3 -rot simple-slots ;
: constructor-word ( word -- word ) : constructor-word ( word -- word )
@ -61,12 +61,12 @@ UNION: arrayed array tuple ;
: define-constructor ( word def -- ) : define-constructor ( word def -- )
>r [ constructor-word ] keep [ >r [ constructor-word ] keep [
dup literal, "tuple-size" word-property , \ make-tuple , dup literal, "tuple-size" word-prop , \ make-tuple ,
] make-list r> append define-compound ; ] make-list r> append define-compound ;
: default-constructor ( tuple -- ) : default-constructor ( tuple -- )
dup [ dup [
"slots" word-property "slots" word-prop
reverse [ last unit , \ keep , ] each reverse [ last unit , \ keep , ] each
] make-list define-constructor ; ] make-list define-constructor ;
@ -76,13 +76,13 @@ UNION: arrayed array tuple ;
dup save-location dup save-location
dup intern-symbol dup intern-symbol
dup tuple-predicate dup tuple-predicate
dup tuple "metaclass" set-word-property dup tuple "metaclass" set-word-prop
dup r> tuple-slots dup r> tuple-slots
default-constructor ; default-constructor ;
: tuple-delegate ( tuple -- obj ) : tuple-delegate ( tuple -- obj )
dup tuple? [ dup tuple? [
dup class "delegate-slot" word-property dup [ dup class "delegate-slot" word-prop dup [
>fixnum slot >fixnum slot
] [ ] [
2drop f 2drop f
@ -123,7 +123,7 @@ UNION: arrayed array tuple ;
: default-tuple-method ( generic -- quot ) : default-tuple-method ( generic -- quot )
#! If the generic does not define a specific method for a #! If the generic does not define a specific method for a
#! tuple, execute the return value of this. #! tuple, execute the return value of this.
dup "methods" word-property dup "methods" word-prop
tuple over hash* dup [ tuple over hash* dup [
2nip cdr 2nip cdr
] [ ] [
@ -141,7 +141,7 @@ UNION: arrayed array tuple ;
#! Generate a quotation that performs tuple class dispatch #! Generate a quotation that performs tuple class dispatch
#! for methods defined on the given generic. #! for methods defined on the given generic.
dup default-tuple-method \ drop swons dup default-tuple-method \ drop swons
swap "methods" word-property hash>quot swap "methods" word-prop hash>quot
[ dup class ] swap append ; [ dup class ] swap append ;
: add-tuple-dispatch ( word vtable -- ) : add-tuple-dispatch ( word vtable -- )
@ -153,7 +153,7 @@ UNION: arrayed array tuple ;
dup array-capacity dup <tuple> [ -rot copy-array ] keep ; dup array-capacity dup <tuple> [ -rot copy-array ] keep ;
: clone-delegate ( tuple -- ) : clone-delegate ( tuple -- )
dup class "delegate-slot" word-property dup [ dup class "delegate-slot" word-prop dup [
[ >fixnum slot clone ] 2keep set-slot [ >fixnum slot clone ] 2keep set-slot
] [ ] [
2drop 2drop
@ -187,12 +187,12 @@ M: tuple hashcode ( vec -- n )
tuple [ tuple [
( generic vtable definition class -- ) ( generic vtable definition class -- )
2drop add-tuple-dispatch 2drop add-tuple-dispatch
] "add-method" set-word-property ] "add-method" set-word-prop
tuple [ tuple [
drop tuple "builtin-type" word-property unit drop tuple "builtin-type" word-prop unit
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
tuple 10 "priority" set-word-property tuple 10 "priority" set-word-prop
tuple [ 2drop t ] "class<" set-word-property tuple [ 2drop t ] "class<" set-word-prop

View File

@ -8,25 +8,25 @@ words vectors ;
SYMBOL: union SYMBOL: union
union [ union [
[ ] swap "members" word-property [ [ ] swap "members" word-prop [
builtin-supertypes append builtin-supertypes append
] each ] each
] "builtin-supertypes" set-word-property ] "builtin-supertypes" set-word-prop
union [ union [
( generic vtable definition class -- ) ( generic vtable definition class -- )
"members" word-property [ >r 3dup r> add-method ] each 3drop "members" word-prop [ >r 3dup r> add-method ] each 3drop
] "add-method" set-word-property ] "add-method" set-word-prop
union 30 "priority" set-word-property union 30 "priority" set-word-prop
union [ 2drop t ] "class<" set-word-property union [ 2drop t ] "class<" set-word-prop
: union-predicate ( definition -- list ) : union-predicate ( definition -- list )
[ [
[ [
\ dup , \ dup ,
unswons "predicate" word-property append, unswons "predicate" word-prop append,
[ drop t ] , [ drop t ] ,
union-predicate , union-predicate ,
\ ifte , \ ifte ,
@ -46,5 +46,5 @@ union [ 2drop t ] "class<" set-word-property
] keep ? ] keep ?
] map ] map
[ union-predicate define-compound ] keep [ union-predicate define-compound ] keep
dupd "members" set-word-property dupd "members" set-word-prop
union define-class ; union define-class ;

View File

@ -123,7 +123,7 @@ errors unparser logging listener url-encoding hashtables memory ;
: word-uses ( word -- list ) : word-uses ( word -- list )
#! Return a list of vocabularies that the given word uses. #! Return a list of vocabularies that the given word uses.
word-parameter flatten [ word? ] subset [ word-def flatten [ word? ] subset [
word-vocabulary word-vocabulary
] map ; ] map ;

View File

@ -210,7 +210,7 @@ SYMBOL: cloned
dynamic-ifte dynamic-ifte
] ifte ; ] ifte ;
\ ifte [ infer-ifte ] "infer" set-word-property \ ifte [ infer-ifte ] "infer" set-word-prop
: vtable>list ( value -- list ) : vtable>list ( value -- list )
dup value-recursion swap literal-value vector>list dup value-recursion swap literal-value vector>list
@ -247,6 +247,6 @@ USE: kernel-internals
dynamic-dispatch dynamic-dispatch
] ifte ; ] ifte ;
\ dispatch [ infer-dispatch ] "infer" set-word-property \ dispatch [ infer-dispatch ] "infer" set-word-prop
\ dispatch [ [ fixnum vector ] [ ] ] \ dispatch [ [ fixnum vector ] [ ] ]
"infer-effect" set-word-property "infer-effect" set-word-prop

View File

@ -110,7 +110,7 @@ SYMBOL: node-param
#! if its not defined, apply default quotation to #! if its not defined, apply default quotation to
#! ( node ) otherwise apply property quotation to #! ( node ) otherwise apply property quotation to
#! ( node ). #! ( node ).
>r >r dup [ node-op get ] bind r> word-property dup [ >r >r dup [ node-op get ] bind r> word-prop dup [
call r> drop call r> drop
] [ ] [
drop r> call drop r> call

View File

@ -156,7 +156,7 @@ M: object apply-object apply-literal ;
: terminator? ( obj -- ? ) : terminator? ( obj -- ? )
#! Does it throw an error? #! Does it throw an error?
dup word? [ "terminator" word-property ] [ drop f ] ifte ; dup word? [ "terminator" word-prop ] [ drop f ] ifte ;
: handle-terminator ( quot -- ) : handle-terminator ( quot -- )
#! If the quotation throws an error, do not count its stack #! If the quotation throws an error, do not count its stack

View File

@ -36,22 +36,22 @@ USE: words
f \ >r dataflow, [ 1 0 node-inputs ] extend f \ >r dataflow, [ 1 0 node-inputs ] extend
pop-d push-r pop-d push-r
[ 0 1 node-outputs ] bind [ 0 1 node-outputs ] bind
] "infer" set-word-property ] "infer" set-word-prop
\ r> [ \ r> [
f \ r> dataflow, [ 0 1 node-inputs ] extend f \ r> dataflow, [ 0 1 node-inputs ] extend
pop-r push-d pop-r push-d
[ 1 0 node-outputs ] bind [ 1 0 node-outputs ] bind
] "infer" set-word-property ] "infer" set-word-prop
: partial-eval ( word -- ) : partial-eval ( word -- )
#! Partially evaluate a word. #! Partially evaluate a word.
f over dup f over dup
"infer-effect" word-property "infer-effect" word-prop
[ host-word ] with-dataflow ; [ host-word ] with-dataflow ;
\ drop [ \ drop partial-eval ] "infer" set-word-property \ drop [ \ drop partial-eval ] "infer" set-word-prop
\ dup [ \ dup partial-eval ] "infer" set-word-property \ dup [ \ dup partial-eval ] "infer" set-word-prop
\ swap [ \ swap partial-eval ] "infer" set-word-property \ swap [ \ swap partial-eval ] "infer" set-word-prop
\ over [ \ over partial-eval ] "infer" set-word-property \ over [ \ over partial-eval ] "infer" set-word-prop
\ pick [ \ pick partial-eval ] "infer" set-word-property \ pick [ \ pick partial-eval ] "infer" set-word-prop

View File

@ -18,12 +18,12 @@ lists math namespaces strings vectors words stdio prettyprint ;
: computed-slot ( -- ) : computed-slot ( -- )
"Computed slot access is slower" inference-warning "Computed slot access is slower" inference-warning
\ slot dup "infer-effect" word-property consume/produce ; \ slot dup "infer-effect" word-prop consume/produce ;
\ slot [ \ slot [
[ object fixnum ] ensure-d [ object fixnum ] ensure-d
fast-slot? [ fast-slot ] [ computed-slot ] ifte fast-slot? [ fast-slot ] [ computed-slot ] ifte
] "infer" set-word-property ] "infer" set-word-prop
: type-value-map ( value -- ) : type-value-map ( value -- )
num-types num-types
@ -47,4 +47,4 @@ lists math namespaces strings vectors words stdio prettyprint ;
\ type [ \ type [
[ object ] ensure-d [ object ] ensure-d
literal-type? [ literal-type ] [ computed-type ] ifte literal-type? [ literal-type ] [ computed-type ] ifte
] "infer" set-word-property ] "infer" set-word-prop

View File

@ -32,15 +32,12 @@ strings vectors words hashtables parser prettyprint ;
: no-effect ( word -- ) : no-effect ( word -- )
"Unknown stack effect: " swap word-name cat2 inference-error ; "Unknown stack effect: " swap word-name cat2 inference-error ;
: recursive? ( word -- ? )
dup word-parameter tree-contains? ;
: inline-compound ( word -- effect node ) : inline-compound ( word -- effect node )
#! Infer the stack effect of a compound word in the current #! Infer the stack effect of a compound word in the current
#! inferencer instance. If the word in question is recursive #! inferencer instance. If the word in question is recursive
#! we infer its stack effect inside a new block. #! we infer its stack effect inside a new block.
gensym over word-parameter cons [ gensym over word-def cons [
word-parameter infer-quot effect word-def infer-quot effect
] with-block ; ] with-block ;
: infer-compound ( word -- ) : infer-compound ( word -- )
@ -50,14 +47,14 @@ strings vectors words hashtables parser prettyprint ;
[ [
recursive-state get init-inference recursive-state get init-inference
dup dup inline-compound drop present-effect dup dup inline-compound drop present-effect
[ "infer-effect" set-word-property ] keep [ "infer-effect" set-word-prop ] keep
] with-scope consume/produce ] with-scope consume/produce
] [ ] [
[ [
>r branches-can-fail? [ >r branches-can-fail? [
drop drop
] [ ] [
t "no-effect" set-word-property t "no-effect" set-word-prop
] ifte r> rethrow ] ifte r> rethrow
] when* ] when*
] catch ; ] catch ;
@ -70,7 +67,7 @@ M: object (apply-word) ( word -- )
M: compound (apply-word) ( word -- ) M: compound (apply-word) ( word -- )
#! Infer a compound word's stack effect. #! Infer a compound word's stack effect.
dup "no-effect" word-property [ dup "no-effect" word-prop [
no-effect no-effect
] [ ] [
infer-compound infer-compound
@ -82,8 +79,8 @@ M: symbol (apply-word) ( word -- )
GENERIC: apply-word GENERIC: apply-word
: apply-default ( word -- ) : apply-default ( word -- )
dup "infer-effect" word-property [ dup "infer-effect" word-prop [
over "infer" word-property [ over "infer" word-prop [
swap car ensure-d call drop swap car ensure-d call drop
] [ ] [
consume/produce consume/produce
@ -96,7 +93,7 @@ M: word apply-word ( word -- )
apply-default ; apply-default ;
M: compound apply-word ( word -- ) M: compound apply-word ( word -- )
dup "inline" word-property [ dup "inline" word-prop [
inline-compound 2drop inline-compound 2drop
] [ ] [
apply-default apply-default
@ -168,15 +165,15 @@ M: word apply-object ( word -- )
[ general-list ] ensure-d [ general-list ] ensure-d
dataflow-drop, pop-d infer-quot-value ; dataflow-drop, pop-d infer-quot-value ;
\ call [ infer-call ] "infer" set-word-property \ call [ infer-call ] "infer" set-word-prop
! These hacks will go away soon ! These hacks will go away soon
\ * [ [ number number ] [ number ] ] "infer-effect" set-word-property \ * [ [ number number ] [ number ] ] "infer-effect" set-word-prop
\ - [ [ number number ] [ number ] ] "infer-effect" set-word-property \ - [ [ number number ] [ number ] ] "infer-effect" set-word-prop
\ + [ [ number number ] [ number ] ] "infer-effect" set-word-property \ + [ [ number number ] [ number ] ] "infer-effect" set-word-prop
\ = [ [ object object ] [ object ] ] "infer-effect" set-word-property \ = [ [ object object ] [ object ] ] "infer-effect" set-word-prop
\ undefined-method t "terminator" set-word-property \ undefined-method t "terminator" set-word-prop
\ undefined-method [ [ object word ] [ ] ] "infer-effect" set-word-property \ undefined-method [ [ object word ] [ ] ] "infer-effect" set-word-prop
\ not-a-number t "terminator" set-word-property \ not-a-number t "terminator" set-word-prop
\ throw t "terminator" set-word-property \ throw t "terminator" set-word-prop

View File

@ -39,6 +39,7 @@ SYMBOL: surface
swap bitor ; swap bitor ;
: black [ 0 0 0 ] ; : black [ 0 0 0 ] ;
: gray [ 128 128 128 ] ;
: white [ 255 255 255 ] ; : white [ 255 255 255 ] ;
: red [ 255 0 0 ] ; : red [ 255 0 0 ] ;
: green [ 0 255 0 ] ; : green [ 0 255 0 ] ;

View File

@ -34,16 +34,16 @@ USING: syntax generic kernel lists namespaces parser words ;
CREATE CREATE
dup intern-symbol dup intern-symbol
dup predicate-word dup predicate-word
[ dupd unit "predicate" set-word-property ] keep [ dupd unit "predicate" set-word-prop ] keep
[ define-union ] [ ] ; parsing [ define-union ] [ ] ; parsing
: PREDICATE: ( -- class predicate definition ) : PREDICATE: ( -- class predicate definition )
#! Followed by a superclass name, then a class name. #! Followed by a superclass name, then a class name.
scan-word scan-word
CREATE dup intern-symbol CREATE dup intern-symbol
dup rot "superclass" set-word-property dup rot "superclass" set-word-prop
dup predicate-word dup predicate-word
[ dupd unit "predicate" set-word-property ] keep [ dupd unit "predicate" set-word-prop ] keep
[ define-predicate ] [ ] ; parsing [ define-predicate ] [ ] ; parsing
: TUPLE: : TUPLE:

View File

@ -10,11 +10,11 @@ math namespaces parser strings words vectors unparse ;
#! Mark the most recently defined word to execute at parse #! Mark the most recently defined word to execute at parse
#! time, rather than run time. The word can use 'scan' to #! time, rather than run time. The word can use 'scan' to
#! read ahead in the input stream. #! read ahead in the input stream.
word t "parsing" set-word-property ; parsing word t "parsing" set-word-prop ; parsing
: inline ( -- ) : inline ( -- )
#! Mark the last word to be inlined. #! Mark the last word to be inlined.
word t "inline" set-word-property ; parsing word t "inline" set-word-prop ; parsing
! The variable "in-definition" is set inside a : ... ;. ! The variable "in-definition" is set inside a : ... ;.
! ( and #! then add "stack-effect" and "documentation" ! ( and #! then add "stack-effect" and "documentation"

View File

@ -15,7 +15,7 @@ unparser ;
! immediately. Otherwise it is appended to the parse tree. ! immediately. Otherwise it is appended to the parse tree.
: parsing? ( word -- ? ) : parsing? ( word -- ? )
dup word? [ "parsing" word-property ] [ drop f ] ifte ; dup word? [ "parsing" word-prop ] [ drop f ] ifte ;
: skip ( n line quot -- n ) : skip ( n line quot -- n )
#! Find the next character that satisfies the quotation, #! Find the next character that satisfies the quotation,
@ -109,9 +109,9 @@ global [ string-mode off ] bind
: save-location ( word -- ) : save-location ( word -- )
#! Remember where this word was defined. #! Remember where this word was defined.
dup set-word dup set-word
dup line-number get "line" set-word-property dup line-number get "line" set-word-prop
dup "col" get "col" set-word-property dup "col" get "col" set-word-prop
file get "file" set-word-property ; file get "file" set-word-prop ;
: create-in "in" get create ; : create-in "in" get create ;
@ -150,20 +150,20 @@ global [ string-mode off ] bind
: parsed-stack-effect ( parsed str -- parsed ) : parsed-stack-effect ( parsed str -- parsed )
over doc-comment-here? [ over doc-comment-here? [
word "stack-effect" word-property [ word "stack-effect" word-prop [
drop drop
] [ ] [
word swap "stack-effect" set-word-property word swap "stack-effect" set-word-prop
] ifte ] ifte
] [ ] [
drop drop
] ifte ; ] ifte ;
: documentation+ ( word str -- ) : documentation+ ( word str -- )
over "documentation" word-property [ over "documentation" word-prop [
swap "\n" swap cat3 swap "\n" swap cat3
] when* ] when*
"documentation" set-word-property ; "documentation" set-word-prop ;
: parsed-documentation ( parsed str -- parsed ) : parsed-documentation ( parsed str -- parsed )
over doc-comment-here? [ over doc-comment-here? [

View File

@ -33,7 +33,7 @@ presentation unparser words ;
tab-size get - ; tab-size get - ;
: prettyprint-prop ( word prop -- ) : prettyprint-prop ( word prop -- )
tuck word-name word-property [ tuck word-name word-prop [
" " write prettyprint-word " " write prettyprint-word
] [ ] [
drop drop
@ -57,12 +57,12 @@ presentation unparser words ;
] make-string comment. ; ] make-string comment. ;
: stack-effect. ( indent word -- indent ) : stack-effect. ( indent word -- indent )
dup "stack-effect" word-property [ dup "stack-effect" word-prop [
" " write " " write
[ CHAR: ( , , CHAR: ) , ] make-string [ CHAR: ( , , CHAR: ) , ] make-string
comment. comment.
] [ ] [
"infer-effect" word-property dup [ "infer-effect" word-prop dup [
infer-effect. infer-effect.
] [ ] [
drop drop
@ -70,7 +70,7 @@ presentation unparser words ;
] ?ifte ; ] ?ifte ;
: documentation. ( indent word -- indent ) : documentation. ( indent word -- indent )
"documentation" word-property [ "documentation" word-prop [
"\n" split [ "\n" split [
"#!" swap cat2 comment. "#!" swap cat2 comment.
dup prettyprint-newline dup prettyprint-newline
@ -92,10 +92,7 @@ M: compound see ( word -- )
0 prettyprint-: swap 0 prettyprint-: swap
[ prettyprint-word ] keep [ prettyprint-word ] keep
[ prettyprint-docs ] keep [ prettyprint-docs ] keep
[ [ word-def prettyprint-elements prettyprint-; ] keep
word-parameter prettyprint-elements
prettyprint-;
] keep
prettyprint-plist prettyprint-newline ; prettyprint-plist prettyprint-newline ;
: see-method ( indent word class method -- indent ) : see-method ( indent word class method -- indent )

View File

@ -7,4 +7,4 @@ USE: words
: foo [ drop ] each-word ; : foo [ drop ] each-word ;
[ ] [ \ foo word-parameter dataflow linearize drop ] unit-test [ ] [ \ foo word-def dataflow linearize drop ] unit-test

View File

@ -9,7 +9,7 @@ USE: lists
: foo 1 2 3 ; : foo 1 2 3 ;
[ [ ] ] [ \ foo word-parameter dataflow kill-set ] unit-test [ [ ] ] [ \ foo word-def dataflow kill-set ] unit-test
[ [ [ + ] [ - ] ] ] [ [ 3 4 1 2 > [ + ] [ - ] ifte ] dataflow kill-set ] unit-test [ [ [ + ] [ - ] ] ] [ [ 3 4 1 2 > [ + ] [ - ] ifte ] dataflow kill-set ] unit-test

View File

@ -73,7 +73,7 @@ USE: generic
SYMBOL: #test SYMBOL: #test
#test f "foobar" set-word-property #test f "foobar" set-word-prop
[ 6 ] [ [ 6 ] [
{{ {{
@ -82,7 +82,7 @@ SYMBOL: #test
}} "foobar" [ [ node-param get ] bind 1 + ] apply-dataflow }} "foobar" [ [ node-param get ] bind 1 + ] apply-dataflow
] unit-test ] unit-test
#test [ [ node-param get ] bind sq ] "foobar" set-word-property #test [ [ node-param get ] bind sq ] "foobar" set-word-prop
[ 25 ] [ [ 25 ] [
{{ {{

View File

@ -4,7 +4,7 @@ USING: generic kernel lists math memory words ;
num-types [ num-types [
[ [
builtin-type [ builtin-type [
"predicate" word-property instances [ "predicate" word-prop instances [
class drop class drop
] each ] each
] when* ] when*

View File

@ -19,5 +19,5 @@ DEFER: foo
! Test > 1 ( ) comment; only the first one should be used. ! Test > 1 ( ) comment; only the first one should be used.
[ t ] [ [ t ] [
"a" ": foo ( a ) ( b ) ;" parse drop word "a" ": foo ( a ) ( b ) ;" parse drop word
"stack-effect" word-property str-contains? "stack-effect" word-prop str-contains?
] unit-test ] unit-test

View File

@ -1,10 +1,5 @@
IN: scratchpad IN: scratchpad
USE: math USING: generic kernel lists math namespaces test words ;
USE: test
USE: words
USE: namespaces
USE: lists
USE: kernel
[ 4 ] [ [ 4 ] [
"poo" "scratchpad" create [ 2 2 + ] define-compound "poo" "scratchpad" create [ 2 2 + ] define-compound
@ -16,20 +11,20 @@ USE: kernel
DEFER: plist-test DEFER: plist-test
[ t ] [ [ t ] [
\ plist-test t "sample-property" set-word-property \ plist-test t "sample-property" set-word-prop
\ plist-test "sample-property" word-property \ plist-test "sample-property" word-prop
] unit-test ] unit-test
[ f ] [ [ f ] [
\ plist-test f "sample-property" set-word-property \ plist-test f "sample-property" set-word-prop
\ plist-test "sample-property" word-property \ plist-test "sample-property" word-prop
] unit-test ] unit-test
[ f ] [ 5 compound? ] unit-test [ f ] [ 5 compound? ] unit-test
"create-test" "scratchpad" create { 1 2 } "testing" set-word-property "create-test" "scratchpad" create { 1 2 } "testing" set-word-prop
[ { 1 2 } ] [ [ { 1 2 } ] [
"create-test" [ "scratchpad" ] search "testing" word-property "create-test" [ "scratchpad" ] search "testing" word-prop
] unit-test ] unit-test
[ [
@ -56,6 +51,14 @@ SYMBOL: a-symbol
[ f ] [ \ a-symbol compound? ] unit-test [ f ] [ \ a-symbol compound? ] unit-test
[ t ] [ \ a-symbol symbol? ] unit-test [ t ] [ \ a-symbol symbol? ] unit-test
! See if redefining a generic as a colon def clears some
! word props.
GENERIC: testing
: testing ;
[ f ] [ \ testing generic? ] unit-test
! This has to be the last test in the file.
: test-last ( -- ) ; : test-last ( -- ) ;
word word-name "last-word-test" set word word-name "last-word-test" set

View File

@ -63,21 +63,17 @@ SYMBOL: meta-cf
meta-cf [ [ push-r ] when* ] change ; meta-cf [ [ push-r ] when* ] change ;
: meta-word ( word -- ) : meta-word ( word -- )
dup "meta-word" word-property [ dup "meta-word" word-prop [
call call
] [ ] [
dup compound? [ dup compound? [ word-def meta-call ] [ host-word ] ifte
word-parameter meta-call
] [
host-word
] ifte
] ?ifte ; ] ?ifte ;
: do ( obj -- ) : do ( obj -- )
dup word? [ meta-word ] [ push-d ] ifte ; dup word? [ meta-word ] [ push-d ] ifte ;
: meta-word-1 ( word -- ) : meta-word-1 ( word -- )
dup "meta-word" word-property [ call ] [ host-word ] ?ifte ; dup "meta-word" word-prop [ call ] [ host-word ] ?ifte ;
: do-1 ( obj -- ) : do-1 ( obj -- )
dup word? [ meta-word-1 ] [ push-d ] ifte ; dup word? [ meta-word-1 ] [ push-d ] ifte ;
@ -89,7 +85,7 @@ SYMBOL: meta-cf
: run ( -- ) [ do ] interpret ; : run ( -- ) [ do ] interpret ;
: set-meta-word ( word quot -- ) : set-meta-word ( word quot -- )
"meta-word" set-word-property ; "meta-word" set-word-prop ;
\ datastack [ meta-d get clone push-d ] set-meta-word \ datastack [ meta-d get clone push-d ] set-meta-word
\ set-datastack [ pop-d clone meta-d set ] set-meta-word \ set-datastack [ pop-d clone meta-d set ] set-meta-word

View File

@ -108,7 +108,7 @@ C: jedit-stream ( stream -- stream )
"name" "name"
"stack-effect" "stack-effect"
] [ ] [
word-property word-prop
] map-with ] map-with
] when ; ] when ;

View File

@ -40,7 +40,7 @@ strings unparser words ;
: jedit ( word -- ) : jedit ( word -- )
#! Note that line numbers here start from 1 #! Note that line numbers here start from 1
dup word-file dup [ dup word-file dup [
swap "line" word-property jedit-line/file swap "line" word-prop jedit-line/file
] [ ] [
2drop "Unknown source" print 2drop "Unknown source" print
] ifte ; ] ifte ;

View File

@ -50,7 +50,7 @@ M: arrayed (each-slot) ( quot array -- )
] repeat 2drop ; ] repeat 2drop ;
M: object (each-slot) ( quot obj -- ) M: object (each-slot) ( quot obj -- )
dup class "slots" word-property [ dup class "slots" word-prop [
pick pick >r >r car slot swap call r> r> pick pick >r >r car slot swap call r> r>
] each 2drop ; ] each 2drop ;

View File

@ -8,19 +8,14 @@ parser ;
GENERIC: word-uses? ( of in -- ? ) GENERIC: word-uses? ( of in -- ? )
M: word word-uses? 2drop f ; M: word word-uses? 2drop f ;
M: compound word-uses? ( of in -- ? ) M: compound word-uses? ( of in -- ? )
2dup = [ #! Don't say that a word uses itself.
2drop f ! Don't say that a word uses itself 2dup = [ 2drop f ] [ word-def tree-contains? ] ifte ;
] [
word-parameter tree-contains?
] ifte ;
: generic-uses? ( of in -- ? ) : generic-uses? ( of in -- ? )
"methods" word-property hash>alist tree-contains? ; "methods" word-prop hash>alist tree-contains? ;
M: generic word-uses? ( of in -- ? ) M: generic word-uses? ( of in -- ? ) generic-uses? ;
generic-uses? ; M: 2generic word-uses? ( of in -- ? ) generic-uses? ;
M: 2generic word-uses? ( of in -- ? )
generic-uses? ;
: usages-in-vocab ( of vocab -- usages ) : usages-in-vocab ( of vocab -- usages )
#! Push a list of all usages of a word in a vocabulary. #! Push a list of all usages of a word in a vocabulary.
@ -82,7 +77,7 @@ M: 2generic word-uses? ( of in -- ? )
words . ; words . ;
: word-file ( word -- file ) : word-file ( word -- file )
"file" word-property dup [ "file" word-prop dup [
"resource:/" ?str-head [ "resource:/" ?str-head [
resource-path swap path+ resource-path swap path+
] when ] when

View File

@ -94,7 +94,7 @@ C: gadget ( shape -- gadget )
#! The position of the gadget on the screen. #! The position of the gadget on the screen.
0 swap [ shape-pos + t ] each-parent drop ; 0 swap [ shape-pos + t ] each-parent drop ;
: relative ( g1 g2 -- g2-p1 ) : relative ( g1 g2 -- g2-g1 )
shape-pos swap screen-pos - ; shape-pos swap screen-pos - ;
: child? ( parent child -- ? ) : child? ( parent child -- ? )

View File

@ -3,7 +3,23 @@
IN: gadgets IN: gadgets
USING: kernel math namespaces prettyprint sdl ; USING: kernel math namespaces prettyprint sdl ;
TUPLE: halo selected delegate ; : drag-sizer ( sizer -- )
gadget-parent ( - halo) [
dup hand relative >rect
rot halo-selected resize-gadget
] keep relayout ;
: sizer-actions ( sizer -- )
dup [ drop ] [ button-down 1 ] set-action
[ drag-sizer ] [ drag 1 ] set-action ;
: <sizer> ( -- sizer )
0 0 10 10 <plain-rect> <gadget>
dup sizer-actions ;
! A halo retains the gadget its surrounding, as well as the
! resizing gadget and a delegate.
TUPLE: halo selected sizer delegate ;
: show-halo* ( gadget -- ) : show-halo* ( gadget -- )
#! Show the halo on a specific gadget. #! Show the halo on a specific gadget.
@ -39,13 +55,25 @@ DEFER: halo-menu
C: halo ( -- halo ) C: halo ( -- halo )
0 0 0 0 <hollow-rect> <gadget> over set-halo-delegate 0 0 0 0 <hollow-rect> <gadget> over set-halo-delegate
dup red foreground set-paint-property dup red foreground set-paint-property
dup red background set-paint-property
<sizer> over 2dup set-halo-sizer add-gadget
dup halo-actions ; dup halo-actions ;
M: halo layout* ( halo -- ) : halo-update ( halo -- )
#! Move the halo to the position of its selected gadget.
dup halo-selected dup halo-selected
2dup screen-pos >rect rot move-gadget 2dup screen-pos >rect rot move-gadget
dup shape-w swap shape-h rot resize-gadget ; dup shape-w swap shape-h rot resize-gadget ;
: sizer-layout ( halo -- )
#! Position the sizer to the bottom right corner.
dup halo-sizer
over shape-h over shape-h -
>r over shape-w over shape-w - r> rot move-gadget drop ;
M: halo layout* ( halo -- )
dup halo-update sizer-layout ;
: default-actions ( gadget -- ) : default-actions ( gadget -- )
[ show-halo ] [ button-down 2 ] set-action ; [ show-halo ] [ button-down 2 ] set-action ;

View File

@ -29,7 +29,7 @@ lists namespaces strings unparser vectors words ;
<line-pile> [ add-gadget ] keep [ add-gadget ] keep ; <line-pile> [ add-gadget ] keep [ add-gadget ] keep ;
: object>alist ( obj -- assoc ) : object>alist ( obj -- assoc )
dup class "slots" word-property [ dup class "slots" word-prop [
cdr car [ execute ] keep swons cdr car [ execute ] keep swons
] map-with ; ] map-with ;
@ -43,7 +43,7 @@ GENERIC: custom-sheet ( obj -- gadget )
over top-sheet over add-gadget over top-sheet over add-gadget
over slot-sheet over add-gadget over slot-sheet over add-gadget
swap custom-sheet over add-gadget swap custom-sheet over add-gadget
line-border ; <scroller> line-border ;
M: object custom-sheet drop <empty-gadget> ; M: object custom-sheet drop <empty-gadget> ;

View File

@ -59,8 +59,8 @@ IN: words USING: hashtables kernel lists namespaces strings ;
#! returned. #! returned.
2dup (search) [ 2dup (search) [
nip nip
dup f "documentation" set-word-property dup f "documentation" set-word-prop
dup f "stack-effect" set-word-property dup f "stack-effect" set-word-prop
] [ ] [
(create) dup reveal (create) dup reveal
] ?ifte ; ] ?ifte ;

View File

@ -6,7 +6,7 @@ namespaces strings ;
BUILTIN: word 17 BUILTIN: word 17
[ 1 hashcode f ] [ 1 hashcode f ]
[ 4 "word-parameter" "set-word-parameter" ] [ 4 "word-def" "set-word-def" ]
[ 5 "word-props" "set-word-props" ] ; [ 5 "word-props" "set-word-props" ] ;
GENERIC: word-xt GENERIC: word-xt
@ -32,11 +32,8 @@ M: word set-allot-count ( n w -- ) 7 set-integer-slot ;
SYMBOL: vocabularies SYMBOL: vocabularies
: word-property ( word pname -- pvalue ) : word-prop ( word name -- value ) swap word-props hash ;
swap word-props hash ; : set-word-prop ( word value name -- ) rot word-props set-hash ;
: set-word-property ( word pvalue pname -- )
rot word-props set-hash ;
PREDICATE: word compound ( obj -- ? ) word-primitive 1 = ; PREDICATE: word compound ( obj -- ? ) word-primitive 1 = ;
PREDICATE: word primitive ( obj -- ? ) word-primitive 2 > ; PREDICATE: word primitive ( obj -- ? ) word-primitive 2 > ;
@ -44,16 +41,24 @@ PREDICATE: word symbol ( obj -- ? ) word-primitive 2 = ;
PREDICATE: word undefined ( obj -- ? ) word-primitive 0 = ; PREDICATE: word undefined ( obj -- ? ) word-primitive 0 = ;
: define ( word primitive parameter -- ) : define ( word primitive parameter -- )
pick set-word-parameter pick set-word-def
over set-word-primitive over set-word-primitive
f "parsing" set-word-property ; f "parsing" set-word-prop ;
: define-compound ( word def -- ) 1 swap define ; : (define-compound) ( word def -- ) 1 swap define ;
: define-symbol ( word -- ) 2 over define ;
: define-compound ( word def -- )
#! If the word is a generic word, clear the properties
#! involved so that 'see' can work properly.
over f "definer" set-word-prop
over f "methods" set-word-prop
over f "combination" set-word-prop
(define-compound) ;
: define-symbol ( word -- ) 2 over define ;
: intern-symbol ( word -- ) : intern-symbol ( word -- )
dup undefined? [ define-symbol ] [ drop ] ifte ; dup undefined? [ define-symbol ] [ drop ] ifte ;
: word-name ( word -- str ) "name" word-property ; : word-name ( word -- str ) "name" word-prop ;
: word-vocabulary ( word -- str ) "vocabulary" word-prop ;
: word-vocabulary ( word -- str ) "vocabulary" word-property ;

View File

@ -94,7 +94,7 @@ void print_cons(CELL cons)
void print_word(F_WORD* word) void print_word(F_WORD* word)
{ {
CELL name = hash(word->plist,tag_object(from_c_string("name"))); CELL name = hash(word->props,tag_object(from_c_string("name")));
if(type_of(name) == STRING_TYPE) if(type_of(name) == STRING_TYPE)
fprintf(stderr,"%s",to_c_string(untag_string(name))); fprintf(stderr,"%s",to_c_string(untag_string(name)));
else else

View File

@ -69,14 +69,14 @@ void undefined(F_WORD* word)
/* XT of compound definitions */ /* XT of compound definitions */
void docol(F_WORD* word) void docol(F_WORD* word)
{ {
call(word->parameter); call(word->def);
executing = tag_object(word); executing = tag_object(word);
} }
/* pushes word parameter */ /* pushes word parameter */
void dosym(F_WORD* word) void dosym(F_WORD* word)
{ {
dpush(word->parameter); dpush(word->def);
} }
void primitive_execute(void) void primitive_execute(void)

View File

@ -19,8 +19,8 @@ void primitive_word(void)
word->hashcode = tag_fixnum((CELL)word); /* initial address */ word->hashcode = tag_fixnum((CELL)word); /* initial address */
word->xt = (CELL)undefined; word->xt = (CELL)undefined;
word->primitive = 0; word->primitive = 0;
word->parameter = F; word->def = F;
word->plist = F; word->props = F;
word->call_count = 0; word->call_count = 0;
word->allot_count = 0; word->allot_count = 0;
dpush(tag_object(word)); dpush(tag_object(word));
@ -46,12 +46,12 @@ void fixup_word(F_WORD* word)
else else
update_xt(word); update_xt(word);
data_fixup(&word->parameter); data_fixup(&word->def);
data_fixup(&word->plist); data_fixup(&word->props);
} }
void collect_word(F_WORD* word) void collect_word(F_WORD* word)
{ {
COPY_OBJECT(word->parameter); COPY_OBJECT(word->def);
COPY_OBJECT(word->plist); COPY_OBJECT(word->props);
} }

View File

@ -8,9 +8,9 @@ typedef struct {
/* untagged on-disk primitive number */ /* untagged on-disk primitive number */
CELL primitive; CELL primitive;
/* TAGGED parameter to xt; used for colon definitions */ /* TAGGED parameter to xt; used for colon definitions */
CELL parameter; CELL def;
/* TAGGED property list for library code */ /* TAGGED property hash for library code */
CELL plist; CELL props;
/* UNTAGGED call count incremented by profiler */ /* UNTAGGED call count incremented by profiler */
CELL call_count; CELL call_count;
/* UNTAGGED amount of memory allocated in word */ /* UNTAGGED amount of memory allocated in word */