factor: add inlined quotations in stack effects

modern-harvey2
Doug Coleman 2017-12-02 16:38:11 -06:00
parent b45af1dcd6
commit 7616f6e95d
3 changed files with 36 additions and 11 deletions

View File

@ -12,7 +12,8 @@ interpolate io.pathnames kernel lexer locals.errors
locals.parser locals.types macros math memoize multiline
namespaces parser quotations sbufs sequences slots source-files
splitting stack-checker strings strings.parser typed vectors
vocabs.parser words words.alias words.constant words.symbol ;
vocabs.parser words words.alias words.constant words.symbol
words.inlined ;
IN: bootstrap.syntax
! These words are defined as a top-level form, instead of with
@ -175,7 +176,7 @@ IN: bootstrap.syntax
] define-core-syntax
":" [
(:) define-declared
(:) apply-inlined-effects define-declared
] define-core-syntax
"GENERIC:" [
@ -306,17 +307,17 @@ IN: bootstrap.syntax
"IH{" [ \ } [ >identity-hashtable ] parse-literal ] define-core-syntax
"::" [ (::) define-declared ] define-core-syntax
"::" [ (::) apply-inlined-effects define-declared ] define-core-syntax
"M::" [ (M::) define ] define-core-syntax
"MACRO:" [ (:) define-macro ] define-core-syntax
"MACRO::" [ (::) define-macro ] define-core-syntax
"TYPED:" [ (:) define-typed ] define-core-syntax
"TYPED::" [ (::) define-typed ] define-core-syntax
"MEMO:" [ (:) define-memoized ] define-core-syntax
"MEMO::" [ (::) define-memoized ] define-core-syntax
"MACRO:" [ (:) apply-inlined-effects define-macro ] define-core-syntax
"MACRO::" [ (::) apply-inlined-effects define-macro ] define-core-syntax
"TYPED:" [ (:) apply-inlined-effects define-typed ] define-core-syntax
"TYPED::" [ (::) apply-inlined-effects define-typed ] define-core-syntax
"MEMO:" [ (:) apply-inlined-effects define-memoized ] define-core-syntax
"MEMO::" [ (::) apply-inlined-effects define-memoized ] define-core-syntax
"MEMO[" [ parse-quotation dup infer memoize-quot suffix! ] define-core-syntax
"IDENTITY-MEMO:" [ (:) define-identity-memoized ] define-core-syntax
"IDENTITY-MEMO::" [ (::) define-identity-memoized ] define-core-syntax
"IDENTITY-MEMO:" [ (:) apply-inlined-effects define-identity-memoized ] define-core-syntax
"IDENTITY-MEMO::" [ (::) apply-inlined-effects define-identity-memoized ] define-core-syntax
"'[" [ parse-quotation fry append! ] define-core-syntax

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,23 @@
! Copyright (C) 2017 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays combinators combinators.short-circuit
kernel math quotations sequences ;
IN: words.inlined
: inline-quotation? ( obj -- ? )
{
[ dup array? [ length>> 2 >= ] [ drop f ] if ]
[ second quotation? ]
} 1&& ;
: effect>inline-quotations ( effect -- quot/f )
in>>
[ dup inline-quotation? [ last ] [ drop [ ] ] if ] map
dup [ length 0 > ] any? [ '[ _ spread ] ] [ drop f ] if ;
: apply-inlined-effects ( def effect -- def effect )
dup effect>inline-quotations dup [
swap [ prepose ] dip
] [
drop
] if ;