generic: rename method-body predicate class to method

db4
Slava Pestov 2010-02-01 20:08:24 +13:00
parent fbf078d4b3
commit df55fed478
20 changed files with 37 additions and 39 deletions

View File

@ -54,7 +54,7 @@ SYMBOL: compiled
GENERIC: no-compile? ( word -- ? ) GENERIC: no-compile? ( word -- ? )
M: method-body no-compile? "method-generic" word-prop no-compile? ; M: method no-compile? "method-generic" word-prop no-compile? ;
M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ; M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ;
@ -63,7 +63,7 @@ M: word no-compile?
GENERIC: combinator? ( word -- ? ) GENERIC: combinator? ( word -- ? )
M: method-body combinator? "method-generic" word-prop combinator? ; M: method combinator? "method-generic" word-prop combinator? ;
M: predicate-engine-word combinator? "owner-generic" word-prop combinator? ; M: predicate-engine-word combinator? "owner-generic" word-prop combinator? ;

View File

@ -77,8 +77,8 @@ M: integer test-7 + ;
! Indirect dependency on an unoptimized word ! Indirect dependency on an unoptimized word
: test-9 ( -- ) ; : test-9 ( -- ) ;
<< SYMBOL: quot << SYMBOL: quot
[ test-9 ] quot set-global >> [ test-9 ] quot set-global
MACRO: test-10 ( -- quot ) quot get ; MACRO: test-10 ( -- quot ) quot get ; >>
: test-11 ( -- ) test-10 ; : test-11 ( -- ) test-10 ;
[ ] [ test-11 ] unit-test [ ] [ test-11 ] unit-test

View File

@ -3,7 +3,7 @@ IN: compiler.tests.redefine13
: breakage-word ( a b -- c ) + ; : breakage-word ( a b -- c ) + ;
MACRO: breakage-macro ( a -- ) '[ _ breakage-word ] ; << MACRO: breakage-macro ( a -- ) '[ _ breakage-word ] ; >>
GENERIC: breakage-caller ( a -- c ) GENERIC: breakage-caller ( a -- c )

View File

@ -5,7 +5,7 @@ IN: compiler.tests.stack-trace
: symbolic-stack-trace ( -- newseq ) : symbolic-stack-trace ( -- newseq )
error-continuation get call>> callstack>array error-continuation get call>> callstack>array
2 group flip first ; 3 group flip first ;
: foo ( -- * ) 3 throw 7 ; : foo ( -- * ) 3 throw 7 ;
: bar ( -- * ) foo 4 ; : bar ( -- * ) foo 4 ;

View File

@ -159,7 +159,7 @@ SYMBOL: node-count
word>> { word>> {
{ [ dup "intrinsic" word-prop ] [ intrinsics-called ] } { [ dup "intrinsic" word-prop ] [ intrinsics-called ] }
{ [ dup generic? ] [ generics-called ] } { [ dup generic? ] [ generics-called ] }
{ [ dup method-body? ] [ methods-called ] } { [ dup method? ] [ methods-called ] }
[ words-called ] [ words-called ]
} cond get inc-at } cond get inc-at
] [ drop ] if ] [ drop ] if

View File

@ -39,7 +39,7 @@ TUPLE: consultation group class quot loc ;
[ class>> swap first create-method dup fake-definition ] keep [ class>> swap first create-method dup fake-definition ] keep
[ drop ] [ "consultation" set-word-prop ] 2bi ; [ drop ] [ "consultation" set-word-prop ] 2bi ;
PREDICATE: consult-method < method-body "consultation" word-prop ; PREDICATE: consult-method < method "consultation" word-prop ;
M: consult-method reset-word M: consult-method reset-word
[ call-next-method ] [ f "consultation" set-word-prop ] bi ; [ call-next-method ] [ f "consultation" set-word-prop ] bi ;

View File

@ -37,7 +37,7 @@ M: array (fake-quotations>)
[ [ (fake-quotations>) ] each ] { } make , ; [ [ (fake-quotations>) ] each ] { } make , ;
M: fake-call-next-method (fake-quotations>) M: fake-call-next-method (fake-quotations>)
drop method-body get literalize , \ (call-next-method) , ; drop \ method get literalize , \ (call-next-method) , ;
M: object (fake-quotations>) , ; M: object (fake-quotations>) , ;
@ -74,7 +74,7 @@ FUNCTOR-SYNTAX: MIXIN:
FUNCTOR-SYNTAX: M: FUNCTOR-SYNTAX: M:
scan-param suffix! scan-param suffix!
scan-param suffix! scan-param suffix!
[ create-method-in dup method-body set ] append! [ create-method-in dup \ method set ] append!
parse-definition* parse-definition*
\ define* suffix! ; \ define* suffix! ;

View File

@ -52,7 +52,7 @@ M: object specializer-declaration class ;
specializer [ specialize-quot ] when* ; specializer [ specialize-quot ] when* ;
: standard-method? ( method -- ? ) : standard-method? ( method -- ? )
dup method-body? [ dup method? [
"method-generic" word-prop standard-generic? "method-generic" word-prop standard-generic?
] [ drop f ] if ; ] [ drop f ] if ;

View File

@ -24,7 +24,7 @@ M: lambda-macro definition
M: lambda-macro reset-word M: lambda-macro reset-word
[ call-next-method ] [ f "lambda" set-word-prop ] bi ; [ call-next-method ] [ f "lambda" set-word-prop ] bi ;
INTERSECTION: lambda-method method-body lambda-word ; INTERSECTION: lambda-method method lambda-word ;
M: lambda-method definer drop \ M:: \ ; ; M: lambda-method definer drop \ M:: \ ; ;

View File

@ -37,7 +37,7 @@ M: parsing-word pprint*
M: word pprint* M: word pprint*
[ pprint-word ] [ ?start-group ] [ ?end-group ] tri ; [ pprint-word ] [ ?start-group ] [ ?end-group ] tri ;
M: method-body pprint* M: method pprint*
[ [
[ [
[ "M\\ " % "method-class" word-prop word-name* % ] [ "M\\ " % "method-class" word-prop word-name* % ]
@ -229,7 +229,7 @@ M: compose pprint* pprint-object ;
M: wrapper pprint* M: wrapper pprint*
{ {
{ [ dup wrapped>> method-body? ] [ wrapped>> pprint* ] } { [ dup wrapped>> method? ] [ wrapped>> pprint* ] }
{ [ dup wrapped>> word? ] [ <block \ \ pprint-word wrapped>> pprint-word block> ] } { [ dup wrapped>> word? ] [ <block \ \ pprint-word wrapped>> pprint-word block> ] }
[ pprint-object ] [ pprint-object ]
} cond ; } cond ;

View File

@ -78,7 +78,7 @@ SYMBOL: ->
first3 first3
[ [
{ {
{ [ dup method-body? ] [ "Method: " write . ] } { [ dup method? ] [ "Method: " write . ] }
{ [ dup word? ] [ "Word: " write . ] } { [ dup word? ] [ "Word: " write . ] }
[ drop ] [ drop ]
} cond } cond

View File

@ -76,7 +76,7 @@ M: hook-generic synopsis*
[ stack-effect. ] [ stack-effect. ]
} cleave ; } cleave ;
M: method-body synopsis* M: method synopsis*
[ definer. ] [ definer. ]
[ "method-class" word-prop pprint-word ] [ "method-class" word-prop pprint-word ]
[ "method-generic" word-prop pprint-word ] tri ; [ "method-generic" word-prop pprint-word ] tri ;

View File

@ -103,7 +103,7 @@ GENERIC: smart-usage ( defspec -- seq )
M: object smart-usage usage [ irrelevant? not ] filter ; M: object smart-usage usage [ irrelevant? not ] filter ;
M: method-body smart-usage "method-generic" word-prop smart-usage ; M: method smart-usage "method-generic" word-prop smart-usage ;
M: f smart-usage drop \ f smart-usage ; M: f smart-usage drop \ f smart-usage ;
@ -124,7 +124,7 @@ M: f smart-usage drop \ f smart-usage ;
[ [ vocab-name ] [ words [ generic? not ] filter ] bi ] dip map [ [ vocab-name ] [ words [ generic? not ] filter ] bi ] dip map
[ [
[ [ word? ] [ generic? not ] bi and ] filter [ [ [ word? ] [ generic? not ] bi and ] filter [
dup method-body? dup method?
[ "method-generic" word-prop ] when [ "method-generic" word-prop ] when
vocabulary>> vocabulary>>
] map ] map

View File

@ -119,7 +119,7 @@ M: object completion-string present ;
: method-completion-string ( word -- string ) : method-completion-string ( word -- string )
"method-generic" word-prop present ; "method-generic" word-prop present ;
M: method-body completion-string method-completion-string ; M: method completion-string method-completion-string ;
GENERIC# accept-completion-hook 1 ( item popup -- ) GENERIC# accept-completion-hook 1 ( item popup -- )

View File

@ -60,7 +60,7 @@ SINGLETON: method-renderer
M: method-renderer column-alignment drop { 0 0 1 } ; M: method-renderer column-alignment drop { 0 0 1 } ;
M: method-renderer filled-column drop 1 ; M: method-renderer filled-column drop 1 ;
! Value is a { method-body count } pair ! Value is a { method count } pair
M: method-renderer row-columns M: method-renderer row-columns
drop [ drop [
[ [ definition-icon <image-name> ] [ synopsis ] bi ] [ [ definition-icon <image-name> ] [ synopsis ] bi ]

View File

@ -131,12 +131,10 @@ HELP: M\
{ $class-description "Pushes a method on the stack." } { $class-description "Pushes a method on the stack." }
{ $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets ui.gadgets.editors ;" "M\\ editor draw-gadget* edit" } } ; { $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets ui.gadgets.editors ;" "M\\ editor draw-gadget* edit" } } ;
HELP: method-body
{ $class-description "The class of method bodies, which are words with special word properties set." } ;
HELP: method HELP: method
{ $values { "class" class } { "generic" generic } { "method/f" { $maybe method-body } } } { $values { "class" class } { "generic" generic } { "method/f" { $maybe method } } }
{ $description "Looks up a method definition." } ; { $description "Looks up a method definition." }
{ $class-description "The class of method bodies, which are words with special word properties set." } ;
{ method create-method POSTPONE: M: } related-words { method create-method POSTPONE: M: } related-words
@ -159,14 +157,14 @@ HELP: with-methods
$low-level-note ; $low-level-note ;
HELP: create-method HELP: create-method
{ $values { "class" class } { "generic" generic } { "method" method-body } } { $values { "class" class } { "generic" generic } { "method" method } }
{ $description "Creates a method or returns an existing one. This is the runtime equivalent of " { $link POSTPONE: M: } "." } { $description "Creates a method or returns an existing one. This is the runtime equivalent of " { $link POSTPONE: M: } "." }
{ $notes "To define a method, pass the output value to " { $link define } "." } ; { $notes "To define a method, pass the output value to " { $link define } "." } ;
{ sort-classes order } related-words { sort-classes order } related-words
HELP: (call-next-method) HELP: (call-next-method)
{ $values { "method" method-body } } { $values { "method" method } }
{ $description "Low-level word implementing " { $link POSTPONE: call-next-method } "." } { $description "Low-level word implementing " { $link POSTPONE: call-next-method } "." }
{ $notes "In most cases, " { $link POSTPONE: call-next-method } " should be used instead." } ; { $notes "In most cases, " { $link POSTPONE: call-next-method } " should be used instead." } ;

View File

@ -207,7 +207,7 @@ M: integer forget-test 3 + ;
[ ] [ "IN: generic.tests USE: math FORGET: M\\ integer forget-test" eval( -- ) ] unit-test [ ] [ "IN: generic.tests USE: math FORGET: M\\ integer forget-test" eval( -- ) ] unit-test
[ { } ] [ [ { } ] [
\ + effect-dependencies-of keys [ method-body? ] filter \ + effect-dependencies-of keys [ method? ] filter
[ "method-generic" word-prop \ forget-test eq? ] filter [ "method-generic" word-prop \ forget-test eq? ] filter
] unit-test ] unit-test

View File

@ -21,6 +21,9 @@ M: generic definition drop f ;
[ dup "combination" word-prop perform-combination ] [ dup "combination" word-prop perform-combination ]
bi ; bi ;
PREDICATE: method < word
"method-generic" word-prop >boolean ;
: method ( class generic -- method/f ) : method ( class generic -- method/f )
"methods" word-prop at ; "methods" word-prop at ;
@ -101,16 +104,13 @@ GENERIC: update-generic ( class generic -- )
: method-word-name ( class generic -- string ) : method-word-name ( class generic -- string )
[ name>> ] bi@ "=>" glue ; [ name>> ] bi@ "=>" glue ;
PREDICATE: method-body < word M: method flushable?
"method-generic" word-prop >boolean ;
M: method-body flushable?
"method-generic" word-prop flushable? ; "method-generic" word-prop flushable? ;
M: method-body stack-effect M: method stack-effect
"method-generic" word-prop stack-effect ; "method-generic" word-prop stack-effect ;
M: method-body crossref? M: method crossref?
"forgotten" word-prop not ; "forgotten" word-prop not ;
: method-word-props ( class generic -- assoc ) : method-word-props ( class generic -- assoc )
@ -150,10 +150,10 @@ PREDICATE: default-method < word "default" word-prop ;
dupd <default-method> "default-method" set-word-prop ; dupd <default-method> "default-method" set-word-prop ;
! Definition protocol ! Definition protocol
M: method-body definer M: method definer
drop \ M: \ ; ; drop \ M: \ ; ;
M: method-body forget* M: method forget*
dup "forgotten" word-prop [ drop ] [ dup "forgotten" word-prop [ drop ] [
[ [
dup default-method? [ drop ] [ dup default-method? [ drop ] [

View File

@ -10,11 +10,11 @@ TUPLE: slot-spec name offset class initial read-only ;
PREDICATE: reader < word "reader" word-prop ; PREDICATE: reader < word "reader" word-prop ;
PREDICATE: reader-method < method-body "reading" word-prop ; PREDICATE: reader-method < method "reading" word-prop ;
PREDICATE: writer < word "writer" word-prop ; PREDICATE: writer < word "writer" word-prop ;
PREDICATE: writer-method < method-body "writing" word-prop ; PREDICATE: writer-method < method "writing" word-prop ;
: <slot-spec> ( -- slot-spec ) : <slot-spec> ( -- slot-spec )
slot-spec new slot-spec new

View File

@ -18,7 +18,7 @@ GENERIC: word-vocabulary ( word -- vocabulary )
M: word word-vocabulary vocabulary>> ; M: word word-vocabulary vocabulary>> ;
M: method-body word-vocabulary "method-generic" word-prop word-vocabulary ; M: method word-vocabulary "method-generic" word-prop word-vocabulary ;
:: do-step ( errors summary-file details-file -- ) :: do-step ( errors summary-file details-file -- )
errors errors