Throw a nice error at parse time if an attempt is made to declare a GENERIC: or MACRO: word inline. Such words cannot be inlined, and doing this before previously result in confusing error messages
parent
3237e48b2d
commit
ca19d44350
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2004, 2009 Slava Pestov.
|
! Copyright (C) 2004, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: slots arrays definitions generic hashtables summary io kernel
|
USING: slots arrays definitions generic hashtables summary io kernel
|
||||||
math namespaces make prettyprint prettyprint.config sequences assocs
|
math namespaces make prettyprint prettyprint.config sequences assocs
|
||||||
|
@ -252,6 +252,8 @@ M: decode-error summary drop "Character decoding error" ;
|
||||||
|
|
||||||
M: bad-create summary drop "Bad parameters to create" ;
|
M: bad-create summary drop "Bad parameters to create" ;
|
||||||
|
|
||||||
|
M: cannot-be-inline summary drop "This type of word cannot be inlined" ;
|
||||||
|
|
||||||
M: attempt-all-error summary drop "Nothing to attempt" ;
|
M: attempt-all-error summary drop "Nothing to attempt" ;
|
||||||
|
|
||||||
M: already-disposed summary drop "Attempting to operate on disposed object" ;
|
M: already-disposed summary drop "Attempting to operate on disposed object" ;
|
||||||
|
|
|
@ -21,3 +21,5 @@ unit-test
|
||||||
|
|
||||||
[ ] [ "USING: macros stack-checker kernel ; IN: hanging-macro MACRO: c ( quot -- ) infer drop [ ] ; : a ( -- ) [ a ] c ;" eval( -- ) ] unit-test
|
[ ] [ "USING: macros stack-checker kernel ; IN: hanging-macro MACRO: c ( quot -- ) infer drop [ ] ; : a ( -- ) [ a ] c ;" eval( -- ) ] unit-test
|
||||||
|
|
||||||
|
[ ] [ "IN: macros.tests USE: macros MACRO: foo ( -- x ) [ ] ;" eval( -- ) ] unit-test
|
||||||
|
[ "IN: macros.tests USE: macros MACRO: foo ( -- x ) [ ] ; inline" eval( -- ) ] must-fail
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2007, 2009 Slava Pestov.
|
! Copyright (C) 2007, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: parser kernel sequences words effects combinators assocs
|
USING: parser kernel sequences words effects combinators assocs
|
||||||
definitions quotations namespaces memoize accessors
|
definitions quotations namespaces memoize accessors
|
||||||
|
@ -23,6 +23,8 @@ SYNTAX: MACRO: (:) define-macro ;
|
||||||
|
|
||||||
PREDICATE: macro < word "macro" word-prop >boolean ;
|
PREDICATE: macro < word "macro" word-prop >boolean ;
|
||||||
|
|
||||||
|
M: macro make-inline cannot-be-inline ;
|
||||||
|
|
||||||
M: macro definer drop \ MACRO: \ ; ;
|
M: macro definer drop \ MACRO: \ ; ;
|
||||||
|
|
||||||
M: macro definition "macro" word-prop ;
|
M: macro definition "macro" word-prop ;
|
||||||
|
|
|
@ -282,3 +282,6 @@ M: growable call-next-hooker call-next-method "growable " prepend ;
|
||||||
[ "IN: generic.single.tests GENERIC# broken-generic# -1 ( a -- b )" eval( -- ) ]
|
[ "IN: generic.single.tests GENERIC# broken-generic# -1 ( a -- b )" eval( -- ) ]
|
||||||
[ error>> bad-dispatch-position? ]
|
[ error>> bad-dispatch-position? ]
|
||||||
must-fail-with
|
must-fail-with
|
||||||
|
|
||||||
|
[ ] [ "IN: generic.single.tests GENERIC: foo ( -- x )" eval( -- ) ] unit-test
|
||||||
|
[ "IN: generic.single.tests GENERIC: foo ( -- x ) inline" eval( -- ) ] must-fail
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs classes classes.algebra
|
USING: accessors arrays assocs classes classes.algebra
|
||||||
combinators definitions generic hashtables kernel
|
combinators definitions generic hashtables kernel
|
||||||
|
@ -16,6 +16,8 @@ TUPLE: single-combination ;
|
||||||
PREDICATE: single-generic < generic
|
PREDICATE: single-generic < generic
|
||||||
"combination" word-prop single-combination? ;
|
"combination" word-prop single-combination? ;
|
||||||
|
|
||||||
|
M: single-generic make-inline cannot-be-inline ;
|
||||||
|
|
||||||
GENERIC: dispatch# ( word -- n )
|
GENERIC: dispatch# ( word -- n )
|
||||||
|
|
||||||
M: generic dispatch# "combination" word-prop dispatch# ;
|
M: generic dispatch# "combination" word-prop dispatch# ;
|
||||||
|
|
|
@ -87,7 +87,11 @@ M: word subwords drop f ;
|
||||||
: make-deprecated ( word -- )
|
: make-deprecated ( word -- )
|
||||||
t "deprecated" set-word-prop ;
|
t "deprecated" set-word-prop ;
|
||||||
|
|
||||||
: make-inline ( word -- )
|
ERROR: cannot-be-inline word ;
|
||||||
|
|
||||||
|
GENERIC: make-inline ( word -- )
|
||||||
|
|
||||||
|
M: word make-inline
|
||||||
dup inline? [ drop ] [
|
dup inline? [ drop ] [
|
||||||
[ t "inline" set-word-prop ]
|
[ t "inline" set-word-prop ]
|
||||||
[ changed-effect ]
|
[ changed-effect ]
|
||||||
|
|
Loading…
Reference in New Issue