compiler.crossref: changes the way in which dependencies are stored on words
Previosly, they were stored in three sequences in the properties "conditional-dependencies" "effect-dependencies" and "definition-dependencies". It seem to better to store all three types in one big property called "dependencies".char-rename
parent
ef269c493c
commit
e629f7b289
|
@ -1,13 +1,21 @@
|
|||
USING: assocs help.markup help.syntax words ;
|
||||
USING: assocs help.markup help.syntax sequences words ;
|
||||
IN: compiler.crossref
|
||||
|
||||
HELP: compiled-crossref
|
||||
{ $var-description "A hashtable that maps words to other words that depend on them. It also stores the types of the dependencies." } ;
|
||||
{ $var-description "A hashtable that maps words to other words that depend on them and their dependency types." } ;
|
||||
|
||||
HELP: delete-compiled-xref
|
||||
{ $values { "word" word } }
|
||||
{ $description "Deletes cross-referencing data for a word. Used when the optimizing compiler forgets a word." } ;
|
||||
|
||||
HELP: load-dependencies
|
||||
{ $values { "word" word } { "assoc" assoc } }
|
||||
{ $description "Creates an assoc where keys are the words the word depends on and values are the dependency type." } ;
|
||||
{ $values { "word" word } { "seq" sequence } }
|
||||
{ $description "Outputs a sequence of the words dependencies." } ;
|
||||
|
||||
HELP: remove-xref
|
||||
{ $values { "word" word } { "dependencies" sequence } { "crossref" assoc } }
|
||||
{ $description "Removes a set of dependencies from the cross referencing table." } ;
|
||||
|
||||
HELP: store-dependencies
|
||||
{ $values { "word" word } { "assoc" assoc } }
|
||||
{ $description "Stores the dependencies in 'assoc' in the word attributes named \"effect-dependencies\", \"conditional-dependencies\" and \"definition-dependencies\"." } ;
|
||||
{ $description "Stores the dependencies in 'assoc' in the word attribute \"dependencies\"." } ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: accessors assocs compiler.crossref fry kernel namespaces
|
||||
sequences stack-checker.dependencies tools.test vocabs words ;
|
||||
USING: assocs compiler.crossref fry io kernel namespaces sequences
|
||||
stack-checker.dependencies tools.test vocabs words ;
|
||||
IN: compiler.crossref.tests
|
||||
|
||||
! Dependencies of all words should always be satisfied unless we're
|
||||
|
@ -21,6 +21,19 @@ IN: compiler.crossref.tests
|
|||
}
|
||||
} clone ;
|
||||
|
||||
! compiled-unxref
|
||||
SYMBOL: kolobi
|
||||
{ f f } [
|
||||
! Setup a fake dependency; kolobi -> print
|
||||
+effect+ kolobi compiled-crossref get \ print of set-at
|
||||
kolobi { print } "dependencies" set-word-prop
|
||||
|
||||
! Ensure it is being forgotten
|
||||
kolobi compiled-unxref
|
||||
kolobi "dependencies" word-prop
|
||||
compiled-crossref get \ print of kolobi of
|
||||
] unit-test
|
||||
|
||||
! dependencies-of
|
||||
{
|
||||
H{ { 20 +definition+ } }
|
||||
|
@ -38,18 +51,15 @@ IN: compiler.crossref.tests
|
|||
] with-variable
|
||||
] unit-test
|
||||
|
||||
! join-dependencies
|
||||
! remove-xref
|
||||
SYMBOLS: foo1 bar ;
|
||||
{
|
||||
H{
|
||||
{ 1 +effect+ }
|
||||
{ 2 +effect+ }
|
||||
{ 3 +conditional+ }
|
||||
{ 4 +conditional+ }
|
||||
{ 5 +definition+ }
|
||||
{ 6 +definition+ }
|
||||
}
|
||||
H{ { foo1 H{ } } }
|
||||
} [
|
||||
{ 1 2 } { 3 4 } { 5 6 } join-dependencies
|
||||
bar { foo1 }
|
||||
H{
|
||||
{ foo1 H{ { bar +definition+ } } }
|
||||
} clone [ remove-xref ] keep
|
||||
] unit-test
|
||||
|
||||
! store-dependencies
|
||||
|
@ -63,10 +73,8 @@ IN: compiler.crossref.tests
|
|||
|
||||
SYMBOL: foo
|
||||
{
|
||||
{ 20 } { 40 50 } { 30 }
|
||||
{ 40 50 20 30 }
|
||||
} [
|
||||
foo [ setup-deps store-dependencies ] keep props>>
|
||||
[ "definition-dependencies" of ]
|
||||
[ "effect-dependencies" of ]
|
||||
[ "conditional-dependencies" of ] tri
|
||||
foo [ setup-deps store-dependencies ] keep "dependencies" word-prop
|
||||
foo delete-compiled-xref
|
||||
] unit-test
|
||||
|
|
|
@ -47,11 +47,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
|
|||
[ rot '[ nip _ = ] assoc-filter keys ] dip set-word-prop ;
|
||||
|
||||
: store-dependencies ( word assoc -- )
|
||||
{
|
||||
{ +effect+ "effect-dependencies" }
|
||||
{ +conditional+ "conditional-dependencies" }
|
||||
{ +definition+ "definition-dependencies" }
|
||||
} [ store-dependencies-of-type ] 2with assoc-each ;
|
||||
keys "dependencies" set-word-prop ;
|
||||
|
||||
: add-xref ( word dependencies crossref -- )
|
||||
rot '[
|
||||
|
@ -59,7 +55,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
|
|||
] assoc-each ;
|
||||
|
||||
: remove-xref ( word dependencies crossref -- )
|
||||
[ keys ] dip '[ _ at delete-at ] with each ;
|
||||
'[ _ at delete-at ] with each ;
|
||||
|
||||
: (compiled-xref) ( word dependencies generic-dependencies -- )
|
||||
compiled-crossref generic-call-site-crossref
|
||||
|
@ -72,21 +68,8 @@ generic-call-site-crossref [ H{ } clone ] initialize
|
|||
[ (compiled-xref) ]
|
||||
3tri ;
|
||||
|
||||
: set-at-each ( keys assoc value -- )
|
||||
'[ _ [ _ ] 2dip set-at ] each ;
|
||||
|
||||
: join-dependencies ( effect-deps cond-deps def-deps -- assoc )
|
||||
H{ } clone [
|
||||
[ +effect+ set-at-each ]
|
||||
[ +conditional+ set-at-each ]
|
||||
[ +definition+ set-at-each ] tri-curry tri*
|
||||
] keep ;
|
||||
|
||||
: load-dependencies ( word -- assoc )
|
||||
[ "effect-dependencies" word-prop ]
|
||||
[ "conditional-dependencies" word-prop ]
|
||||
[ "definition-dependencies" word-prop ] tri
|
||||
join-dependencies ;
|
||||
: load-dependencies ( word -- seq )
|
||||
"dependencies" word-prop ;
|
||||
|
||||
: (compiled-unxref) ( word dependencies variable -- )
|
||||
get remove-xref ;
|
||||
|
@ -98,9 +81,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
|
|||
{
|
||||
[ dup load-dependencies compiled-crossref (compiled-unxref) ]
|
||||
[ dup generic-call-sites generic-call-site-crossref (compiled-unxref) ]
|
||||
[ "effect-dependencies" remove-word-prop ]
|
||||
[ "conditional-dependencies" remove-word-prop ]
|
||||
[ "definition-dependencies" remove-word-prop ]
|
||||
[ "dependencies" remove-word-prop ]
|
||||
[ "generic-call-sites" remove-word-prop ]
|
||||
} cleave ;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
USING: accessors compiler compiler.units tools.test math parser
|
||||
kernel sequences sequences.private classes.mixin generic
|
||||
definitions arrays words assocs eval grouping ;
|
||||
USING: arrays classes.mixin compiler.crossref compiler.units eval
|
||||
generic kernel sequences tools.test words ;
|
||||
IN: compiler.tests.redefine3
|
||||
|
||||
GENERIC: sheeple ( obj -- x )
|
||||
|
@ -14,7 +13,7 @@ M: empty-mixin sheeple drop "wake up" ; inline
|
|||
: sheeple-test ( -- string ) { } sheeple ;
|
||||
|
||||
: compiled-use? ( key word -- ? )
|
||||
"definition-dependencies" word-prop member-eq? ;
|
||||
load-dependencies member-eq? ;
|
||||
|
||||
[ "sheeple" ] [ sheeple-test ] unit-test
|
||||
[ t ] [ \ sheeple-test word-optimized? ] unit-test
|
||||
|
|
|
@ -127,7 +127,6 @@ IN: tools.deploy.shaker
|
|||
"boa-check"
|
||||
"coercer"
|
||||
"combination"
|
||||
"conditional-dependencies"
|
||||
"constant"
|
||||
"constraints"
|
||||
"custom-inlining"
|
||||
|
@ -136,11 +135,10 @@ IN: tools.deploy.shaker
|
|||
"default"
|
||||
"default-method"
|
||||
"default-output-classes"
|
||||
"definition-dependencies"
|
||||
"dependencies"
|
||||
"dependency-checks"
|
||||
"derived-from"
|
||||
"ebnf-parser"
|
||||
"effect-dependencies"
|
||||
"engines"
|
||||
"forgotten"
|
||||
|
||||
|
|
|
@ -148,6 +148,17 @@ $nl
|
|||
{ $snippet "\"specializer\"" }
|
||||
{ $link "hints" }
|
||||
}
|
||||
{
|
||||
{
|
||||
{ $snippet "\"dependencies\"" } ", "
|
||||
|
||||
}
|
||||
{ "Used by the optimizing compiler when forgetting words for fast dependency lookup. See " { $link "compilation-units" } "." }
|
||||
}
|
||||
{
|
||||
{ $snippet "\"generic-call-sites\"" }
|
||||
{ "Set on some generic words." }
|
||||
}
|
||||
}
|
||||
"Properties which are defined for classes only:"
|
||||
{ $table
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
USING: accessors arrays compiler.units definitions eval generic
|
||||
io.streams.string kernel math namespaces parser sequences tools.test
|
||||
vocabs words words.private words.symbol ;
|
||||
USING: accessors arrays compiler.crossref compiler.units definitions
|
||||
eval generic io.streams.string kernel math namespaces parser sequences
|
||||
tools.test vocabs words words.private words.symbol ;
|
||||
IN: words.tests
|
||||
|
||||
{ 4 } [
|
||||
|
@ -125,11 +125,9 @@ DEFER: deferred
|
|||
|
||||
{ { } }
|
||||
[
|
||||
! No word can have dependencies to forgotten words.
|
||||
all-words [
|
||||
[ "effect-dependencies" word-prop ]
|
||||
[ "definition-dependencies" word-prop ]
|
||||
[ "conditional-dependencies" word-prop ] tri
|
||||
3append [ "forgotten" word-prop ] filter
|
||||
load-dependencies [ "forgotten" word-prop ] filter
|
||||
] map harvest
|
||||
] unit-test
|
||||
|
||||
|
|
Loading…
Reference in New Issue