generic: rename method-body predicate class to method
parent
fbf078d4b3
commit
df55fed478
|
@ -54,7 +54,7 @@ SYMBOL: compiled
|
|||
|
||||
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? ;
|
||||
|
||||
|
@ -63,7 +63,7 @@ M: word no-compile?
|
|||
|
||||
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? ;
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ M: integer test-7 + ;
|
|||
! Indirect dependency on an unoptimized word
|
||||
: test-9 ( -- ) ;
|
||||
<< SYMBOL: quot
|
||||
[ test-9 ] quot set-global >>
|
||||
MACRO: test-10 ( -- quot ) quot get ;
|
||||
[ test-9 ] quot set-global
|
||||
MACRO: test-10 ( -- quot ) quot get ; >>
|
||||
: test-11 ( -- ) test-10 ;
|
||||
|
||||
[ ] [ test-11 ] unit-test
|
||||
|
|
|
@ -3,7 +3,7 @@ IN: compiler.tests.redefine13
|
|||
|
||||
: breakage-word ( a b -- c ) + ;
|
||||
|
||||
MACRO: breakage-macro ( a -- ) '[ _ breakage-word ] ;
|
||||
<< MACRO: breakage-macro ( a -- ) '[ _ breakage-word ] ; >>
|
||||
|
||||
GENERIC: breakage-caller ( a -- c )
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ IN: compiler.tests.stack-trace
|
|||
|
||||
: symbolic-stack-trace ( -- newseq )
|
||||
error-continuation get call>> callstack>array
|
||||
2 group flip first ;
|
||||
3 group flip first ;
|
||||
|
||||
: foo ( -- * ) 3 throw 7 ;
|
||||
: bar ( -- * ) foo 4 ;
|
||||
|
|
|
@ -159,7 +159,7 @@ SYMBOL: node-count
|
|||
word>> {
|
||||
{ [ dup "intrinsic" word-prop ] [ intrinsics-called ] }
|
||||
{ [ dup generic? ] [ generics-called ] }
|
||||
{ [ dup method-body? ] [ methods-called ] }
|
||||
{ [ dup method? ] [ methods-called ] }
|
||||
[ words-called ]
|
||||
} cond get inc-at
|
||||
] [ drop ] if
|
||||
|
|
|
@ -39,7 +39,7 @@ TUPLE: consultation group class quot loc ;
|
|||
[ class>> swap first create-method dup fake-definition ] keep
|
||||
[ 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
|
||||
[ call-next-method ] [ f "consultation" set-word-prop ] bi ;
|
||||
|
|
|
@ -37,7 +37,7 @@ M: array (fake-quotations>)
|
|||
[ [ (fake-quotations>) ] each ] { } make , ;
|
||||
|
||||
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>) , ;
|
||||
|
||||
|
@ -74,7 +74,7 @@ FUNCTOR-SYNTAX: MIXIN:
|
|||
FUNCTOR-SYNTAX: M:
|
||||
scan-param suffix!
|
||||
scan-param suffix!
|
||||
[ create-method-in dup method-body set ] append!
|
||||
[ create-method-in dup \ method set ] append!
|
||||
parse-definition*
|
||||
\ define* suffix! ;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ M: object specializer-declaration class ;
|
|||
specializer [ specialize-quot ] when* ;
|
||||
|
||||
: standard-method? ( method -- ? )
|
||||
dup method-body? [
|
||||
dup method? [
|
||||
"method-generic" word-prop standard-generic?
|
||||
] [ drop f ] if ;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ M: lambda-macro definition
|
|||
M: lambda-macro reset-word
|
||||
[ 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:: \ ; ;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ M: parsing-word pprint*
|
|||
M: word pprint*
|
||||
[ pprint-word ] [ ?start-group ] [ ?end-group ] tri ;
|
||||
|
||||
M: method-body pprint*
|
||||
M: method pprint*
|
||||
[
|
||||
[
|
||||
[ "M\\ " % "method-class" word-prop word-name* % ]
|
||||
|
@ -229,7 +229,7 @@ M: compose pprint* pprint-object ;
|
|||
|
||||
M: wrapper pprint*
|
||||
{
|
||||
{ [ dup wrapped>> method-body? ] [ wrapped>> pprint* ] }
|
||||
{ [ dup wrapped>> method? ] [ wrapped>> pprint* ] }
|
||||
{ [ dup wrapped>> word? ] [ <block \ \ pprint-word wrapped>> pprint-word block> ] }
|
||||
[ pprint-object ]
|
||||
} cond ;
|
||||
|
|
|
@ -78,7 +78,7 @@ SYMBOL: ->
|
|||
first3
|
||||
[
|
||||
{
|
||||
{ [ dup method-body? ] [ "Method: " write . ] }
|
||||
{ [ dup method? ] [ "Method: " write . ] }
|
||||
{ [ dup word? ] [ "Word: " write . ] }
|
||||
[ drop ]
|
||||
} cond
|
||||
|
|
|
@ -76,7 +76,7 @@ M: hook-generic synopsis*
|
|||
[ stack-effect. ]
|
||||
} cleave ;
|
||||
|
||||
M: method-body synopsis*
|
||||
M: method synopsis*
|
||||
[ definer. ]
|
||||
[ "method-class" word-prop pprint-word ]
|
||||
[ "method-generic" word-prop pprint-word ] tri ;
|
||||
|
|
|
@ -103,7 +103,7 @@ GENERIC: smart-usage ( defspec -- seq )
|
|||
|
||||
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 ;
|
||||
|
||||
|
@ -124,7 +124,7 @@ M: f smart-usage drop \ f smart-usage ;
|
|||
[ [ vocab-name ] [ words [ generic? not ] filter ] bi ] dip map
|
||||
[
|
||||
[ [ word? ] [ generic? not ] bi and ] filter [
|
||||
dup method-body?
|
||||
dup method?
|
||||
[ "method-generic" word-prop ] when
|
||||
vocabulary>>
|
||||
] map
|
||||
|
|
|
@ -119,7 +119,7 @@ M: object completion-string present ;
|
|||
: method-completion-string ( word -- string )
|
||||
"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 -- )
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ SINGLETON: method-renderer
|
|||
M: method-renderer column-alignment drop { 0 0 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
|
||||
drop [
|
||||
[ [ definition-icon <image-name> ] [ synopsis ] bi ]
|
||||
|
|
|
@ -131,12 +131,10 @@ HELP: M\
|
|||
{ $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" } } ;
|
||||
|
||||
HELP: method-body
|
||||
{ $class-description "The class of method bodies, which are words with special word properties set." } ;
|
||||
|
||||
HELP: method
|
||||
{ $values { "class" class } { "generic" generic } { "method/f" { $maybe method-body } } }
|
||||
{ $description "Looks up a method definition." } ;
|
||||
{ $values { "class" class } { "generic" generic } { "method/f" { $maybe method } } }
|
||||
{ $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
|
||||
|
||||
|
@ -159,14 +157,14 @@ HELP: with-methods
|
|||
$low-level-note ;
|
||||
|
||||
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: } "." }
|
||||
{ $notes "To define a method, pass the output value to " { $link define } "." } ;
|
||||
|
||||
{ sort-classes order } related-words
|
||||
|
||||
HELP: (call-next-method)
|
||||
{ $values { "method" method-body } }
|
||||
{ $values { "method" method } }
|
||||
{ $description "Low-level word implementing " { $link POSTPONE: call-next-method } "." }
|
||||
{ $notes "In most cases, " { $link POSTPONE: call-next-method } " should be used instead." } ;
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ M: integer forget-test 3 + ;
|
|||
[ ] [ "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
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ M: generic definition drop f ;
|
|||
[ dup "combination" word-prop perform-combination ]
|
||||
bi ;
|
||||
|
||||
PREDICATE: method < word
|
||||
"method-generic" word-prop >boolean ;
|
||||
|
||||
: method ( class generic -- method/f )
|
||||
"methods" word-prop at ;
|
||||
|
||||
|
@ -101,16 +104,13 @@ GENERIC: update-generic ( class generic -- )
|
|||
: method-word-name ( class generic -- string )
|
||||
[ name>> ] bi@ "=>" glue ;
|
||||
|
||||
PREDICATE: method-body < word
|
||||
"method-generic" word-prop >boolean ;
|
||||
|
||||
M: method-body flushable?
|
||||
M: method flushable?
|
||||
"method-generic" word-prop flushable? ;
|
||||
|
||||
M: method-body stack-effect
|
||||
M: method stack-effect
|
||||
"method-generic" word-prop stack-effect ;
|
||||
|
||||
M: method-body crossref?
|
||||
M: method crossref?
|
||||
"forgotten" word-prop not ;
|
||||
|
||||
: 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 ;
|
||||
|
||||
! Definition protocol
|
||||
M: method-body definer
|
||||
M: method definer
|
||||
drop \ M: \ ; ;
|
||||
|
||||
M: method-body forget*
|
||||
M: method forget*
|
||||
dup "forgotten" word-prop [ drop ] [
|
||||
[
|
||||
dup default-method? [ drop ] [
|
||||
|
|
|
@ -10,11 +10,11 @@ TUPLE: slot-spec name offset class initial read-only ;
|
|||
|
||||
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-method < method-body "writing" word-prop ;
|
||||
PREDICATE: writer-method < method "writing" word-prop ;
|
||||
|
||||
: <slot-spec> ( -- slot-spec )
|
||||
slot-spec new
|
||||
|
|
|
@ -18,7 +18,7 @@ GENERIC: word-vocabulary ( word -- 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 -- )
|
||||
errors
|
||||
|
|
Loading…
Reference in New Issue