Walker: step directly into the effective method

db4
Slava Pestov 2008-04-03 17:33:06 -05:00
parent d2fc408c1b
commit e006aca541
3 changed files with 14 additions and 10 deletions

View File

@ -29,6 +29,8 @@ PREDICATE: method-spec < pair
: order ( generic -- seq )
"methods" word-prop keys sort-classes ;
GENERIC: effective-method ( ... generic -- method )
: next-method-class ( class generic -- class/f )
order [ class< ] with subset reverse dup length 1 =
[ drop f ] [ second ] if ;

View File

@ -118,6 +118,10 @@ M: standard-combination perform-combination
M: standard-combination dispatch# #>> ;
M: standard-generic effective-method
[ dispatch# (picker) call ] keep
[ order [ instance? ] with find-last nip ] keep method ;
ERROR: inconsistent-next-method object class generic ;
ERROR: no-next-method class generic ;

View File

@ -3,7 +3,8 @@
USING: threads kernel namespaces continuations combinators
sequences math namespaces.private continuations.private
concurrency.messaging quotations kernel.private words
sequences.private assocs models arrays accessors ;
sequences.private assocs models arrays accessors
generic generic.standard ;
IN: tools.walker
SYMBOL: show-walker-hook ! ( status continuation thread -- )
@ -68,15 +69,12 @@ M: object add-breakpoint ;
: (step-into-dispatch) nth (step-into-quot) ;
: (step-into-execute) ( word -- )
dup "step-into" word-prop [
call
] [
dup primitive? [
execute break
] [
word-def (step-into-quot)
] if
] ?if ;
{
{ [ dup "step-into" word-prop ] [ "step-into" word-prop call ] }
{ [ dup standard-generic? ] [ effective-method (step-into-execute) ] }
{ [ dup primitive? ] [ execute break ] }
{ [ t ] [ word-def (step-into-quot) ] }
} cond ;
\ (step-into-execute) t "step-into?" set-word-prop