GENERIC: optimized. ( quot/word -- )
-M: method-spec optimized. first2 method optimized. ;
-
M: word optimized. specialized-def optimized. ;
M: callable optimized. build-tree optimize-tree nodes>quot . ;
"A word's documentation:"
{ $code "\\ foo >link edit" }
"A method definition:"
- { $code "{ editor draw-gadget* } edit" }
+ { $code "M\\ fixnum + edit" }
"A help article:"
{ $code "\"handbook\" >link edit" }
} ;
SYNTAX: HINTS:
scan-object
- dup method-spec? [ first2 method ] when
[ redefined ]
[ parse-definition "specializer" set-word-prop ] bi ;
\ >be { { bignum fixnum } { fixnum fixnum } } "specializer" set-word-prop
-\ hashtable \ at* method { { fixnum object } { word object } } "specializer" set-word-prop
+M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-prop
-\ hashtable \ set-at method { { object fixnum object } { object word object } } "specializer" set-word-prop
+M\ hashtable set-at { { object fixnum object } { object word object } } "specializer" set-word-prop
HELP: see
{ $values { "defspec" "a definition specifier" } }
-{ $contract "Prettyprints a definition." } ;
+{ $contract "Prettyprints a definition." }
+{ $examples
+ "A word:" { $code "\\ append see" }
+ "A method:" { $code "USE: arrays" "M\\ array length see" }
+ "A help article:" { $code "USE: help.topics" "\"help\" >link see" }
+} ;
HELP: see-methods
{ $values { "word" "a " { $link generic } " or a " { $link class } } }
[ stack-effect. ]
} cleave ;
-M: method-spec synopsis*
- first2 method synopsis* ;
-
M: method-body synopsis*
[ definer. ]
[ "method-class" word-prop pprint-word ]
block>
] with-use ;
-M: method-spec see*
- first2 method see* ;
-
GENERIC: see-class* ( word -- )
M: union-class see-class*
f "unannotated-def" set-word-prop
] [ drop ] if ;
-M: method-spec reset
- first2 method reset ;
-
ERROR: cannot-annotate-twice word ;
<PRIVATE
cannot-annotate-twice
] when ;
-: method-spec>word ( obj -- word )
- dup method-spec? [ first2 method ] when ;
-
: save-unannotated-def ( word -- )
dup def>> "unannotated-def" set-word-prop ;
PRIVATE>
: annotate ( word quot -- )
- [ method-spec>word check-annotate-twice ] dip
+ [ check-annotate-twice ] dip
[ over save-unannotated-def (annotate) ] with-compilation-unit ;
<PRIVATE
M: word annotate-methods
annotate ;
-M: method-spec annotate-methods
- annotate ;
-
: breakpoint ( word -- )
[ add-breakpoint ] annotate-methods ;
strip-prettyprint? [
{
- "break-before"
- "break-after"
"delimiter"
"flushable"
"foldable"
M: word disassemble word-xt 2array disassemble ;
-M: method-spec disassemble first2 method disassemble ;
-
cpu x86?
"tools.disassembler.udis"
"tools.disassembler.gdb" ?
: method ( class generic -- method/f )
"methods" word-prop at ;
-PREDICATE: method-spec < pair
- first2 generic? swap class? and ;
-
-INSTANCE: method-spec definition
-
: order ( generic -- seq )
"methods" word-prop keys sort-classes ;
PREDICATE: method-body < word
"method-generic" word-prop >boolean ;
-M: method-spec stack-effect
- first2 method stack-effect ;
-
M: method-body stack-effect
"method-generic" word-prop stack-effect ;
dupd <default-method> "default-method" set-word-prop ;
! Definition protocol
-M: method-spec where
- dup first2 method [ ] [ second ] ?if where ;
-
-M: method-spec set-where
- first2 method set-where ;
-
-M: method-spec definer
- first2 method definer ;
-
-M: method-spec definition
- first2 method definition ;
-
-M: method-spec forget*
- first2 method [ forgotten-definition ] [ forget* ] bi ;
-
-M: method-spec smart-usage
- second smart-usage ;
-
M: method-body definer
drop \ M: \ ; ;