: (CREATE-C-TYPE) ( word -- word )
validate-c-type-name current-vocab create {
[ fake-definition ]
- [ set-word ]
+ [ set-last-word ]
[ reset-c-type ]
[ ]
} cleave ;
fixup-header
"Image length: " write image get length .
"Object cache size: " write objects get assoc-size .
- \ word global delete-at
+ \ last-word-symbol global delete-at
image get ;
! Image output
: scan-c-type-param ( -- c-type/param )
scan-token dup "{" = [ drop \ } parse-until >array ] [ >string-param ] if ;
-: define* ( word def -- ) over set-word define ;
+: define* ( word def -- ) over set-last-word define ;
: define-declared* ( word def effect -- )
- pick set-word define-declared ;
+ pick set-last-word define-declared ;
: define-simple-generic* ( word effect -- )
- over set-word define-simple-generic ;
+ over set-last-word define-simple-generic ;
: define-tuple-class* ( class superclass slots -- )
- pick set-word define-tuple-class ;
+ pick set-last-word define-tuple-class ;
\ define-tuple-class* suffix! ;
FUNCTOR-SYNTAX: final
- [ word make-final ] append! ;
+ [ last-word make-final ] append! ;
FUNCTOR-SYNTAX: SINGLETON:
scan-param suffix!
parse-declared*
\ define-macro suffix! ;
-FUNCTOR-SYNTAX: inline [ word make-inline ] append! ;
+FUNCTOR-SYNTAX: inline [ last-word make-inline ] append! ;
FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ;
: define-typed ( word def effect -- )
[ [ 2drop ] [ typed-def ] [ 2nip ] 3tri define-inline ]
[ drop "typed-def" set-word-prop ]
- [ 2drop "typed-word" word-prop \ word set-global ] 3tri ;
+ [ 2drop "typed-word" word-prop set-last-word ] 3tri ;
SYNTAX: TYPED:
(:) define-typed ;
: create-class-in ( string -- word )
current-vocab create
dup t "defining-class" set-word-prop
- dup set-word
+ dup set-last-word
dup save-class-location
dup create-predicate-word save-location ;
[ scan-new-generic ] dip call scan-effect define-generic ; inline
: create-method-in ( class generic -- method )
- create-method dup set-word dup save-location ;
+ create-method dup set-last-word dup save-location ;
: define-inline-method ( class generic quot -- )
[ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
ERROR: bad-method-effect ;
: check-method-effect ( effect -- )
- word generic-effect method-effect= [ bad-method-effect ] unless ;
+ last-word generic-effect method-effect= [ bad-method-effect ] unless ;
: ?execute-parsing ( word/number -- seq )
dup parsing-word?
M: parsing-word stack-effect drop ( parsed -- parsed ) ;
: create-in ( str -- word )
- current-vocab create dup set-word dup save-location ;
+ current-vocab create dup set-last-word dup save-location ;
SYMBOL: auto-use?
"POSTPONE:" [ scan-word suffix! ] define-core-syntax
"\\" [ scan-word <wrapper> suffix! ] define-core-syntax
"M\\" [ scan-word scan-word lookup-method <wrapper> suffix! ] define-core-syntax
- "inline" [ word make-inline ] define-core-syntax
- "recursive" [ word make-recursive ] define-core-syntax
- "foldable" [ word make-foldable ] define-core-syntax
- "flushable" [ word make-flushable ] define-core-syntax
- "delimiter" [ word t "delimiter" set-word-prop ] define-core-syntax
- "deprecated" [ word make-deprecated ] define-core-syntax
+ "inline" [ last-word make-inline ] define-core-syntax
+ "recursive" [ last-word make-recursive ] define-core-syntax
+ "foldable" [ last-word make-foldable ] define-core-syntax
+ "flushable" [ last-word make-flushable ] define-core-syntax
+ "delimiter" [ last-word t "delimiter" set-word-prop ] define-core-syntax
+ "deprecated" [ last-word make-deprecated ] define-core-syntax
"SYNTAX:" [
scan-new-word parse-definition define-syntax
"DEFER:" [
scan-token current-vocab create
- [ fake-definition ] [ set-word ] [ undefined-def define ] tri
+ [ fake-definition ] [ set-last-word ] [ undefined-def define ] tri
] define-core-syntax
"ALIAS:" [
] define-core-syntax
"final" [
- word make-final
+ last-word make-final
] define-core-syntax
"SLOT:" [
HELP: bootstrapping?
{ $var-description "Set by the library while bootstrap is in progress. Some parsing words need to behave differently during bootstrap." } ;
-HELP: word
+HELP: last-word
{ $values { "word" word } }
{ $description "Outputs the most recently defined word." }
{ $class-description "The class of words. One notable subclass is " { $link class } ", the class of class words." } ;
-{ word set-word save-location } related-words
+{ last-word set-last-word save-location } related-words
-HELP: set-word
+HELP: set-last-word
{ $values { "word" word } }
{ $description "Sets the recently defined word." } ;
[ f ] [ "no-loc-2" "words.tests" lookup-word where ] unit-test
[ ] [ "IN: words.tests : test-last ( -- ) ;" eval( -- ) ] unit-test
-[ "test-last" ] [ word name>> ] unit-test
+[ "test-last" ] [ last-word name>> ] unit-test
"undef-test" "words.tests" lookup-word [
[ forget ] with-compilation-unit
{ def quotation initial: [ ] } props pic-def pic-tail-def
{ sub-primitive read-only } ;
-: word ( -- word ) \ word get-global ;
+! Need a dummy word here because BUILTIN: word is not a real word
+! and parse-datum looks for things that are actually words instead of
+! also looking for classes
+: word ( -- * ) "dummy word" throw ;
-: set-word ( word -- ) \ word set-global ;
+SYMBOL: last-word-symbol
+
+: last-word ( -- word ) \ last-word-symbol get-global ;
+
+: set-last-word ( word -- ) \ last-word-symbol set-global ;
M: word execute (execute) ;
parse-definition [ 2 tail ] [ second ] [ first ] tri ;
: create-method-in ( specializer generic -- method )
- create-method dup save-location f set-word ;
+ create-method dup save-location f set-last-word ;
: scan-new-method ( -- method )
scan-word scan-object swap create-method-in ;