]> gitweb.factorcode.org Git - factor.git/blobdiff - core/words/words.factor
primitives: Change PRIMITIVE: to check that the word is in that vocabulary and the...
[factor.git] / core / words / words.factor
index b71e670e51da7cab6a14123aa9b46051cb8c4e5e..8c7946e2bb53611de0e6a05d4a9f1c92483fab80 100644 (file)
@@ -11,6 +11,13 @@ BUILTIN: word
 { def quotation initial: [ ] } props pic-def pic-tail-def
 { sub-primitive read-only } ;
 
+PRIMITIVE: optimized? ( word -- ? )
+PRIMITIVE: word-code ( word -- start end )
+
+<PRIVATE
+PRIMITIVE: (word) ( name vocab hashcode -- word )
+PRIVATE>
+
 ! 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
@@ -68,6 +75,14 @@ PREDICATE: primitive < word "primitive" word-prop ;
 M: primitive definer drop \ PRIMITIVE: f ;
 M: primitive definition drop f ;
 
+ERROR: invalid-primitive vocabulary word effect ;
+: ensure-primitive ( vocabulary word effect -- )
+    3dup
+    [ drop vocabulary>> = ]
+    [ drop nip primitive? ]
+    [ [ nip "declared-effect" word-prop ] dip = ] 3tri and and
+    [ 3drop ] [ invalid-primitive ] if ;
+
 : lookup-word ( name vocab -- word ) vocab-words-assoc at ;
 
 : target-word ( word -- target )