Merge branch 'master' of git://factorcode.org/git/factor
commit
0cab0bab24
|
@ -5,7 +5,7 @@ namespaces parser kernel kernel.private classes classes.private
|
||||||
arrays hashtables vectors tuples sbufs inference.dataflow
|
arrays hashtables vectors tuples sbufs inference.dataflow
|
||||||
hashtables.private sequences.private math tuples.private
|
hashtables.private sequences.private math tuples.private
|
||||||
growable namespaces.private assocs words generator command-line
|
growable namespaces.private assocs words generator command-line
|
||||||
vocabs io prettyprint libc definitions ;
|
vocabs io prettyprint libc compiler.units ;
|
||||||
IN: bootstrap.compiler
|
IN: bootstrap.compiler
|
||||||
|
|
||||||
! Don't bring this in when deploying, since it will store a
|
! Don't bring this in when deploying, since it will store a
|
||||||
|
|
|
@ -459,5 +459,8 @@ PRIVATE>
|
||||||
|
|
||||||
: make-images ( -- )
|
: make-images ( -- )
|
||||||
{
|
{
|
||||||
"x86.32" "x86.64" "linux-ppc" "macosx-ppc" "arm"
|
"x86.32"
|
||||||
|
! "x86.64"
|
||||||
|
"linux-ppc" "macosx-ppc"
|
||||||
|
! "arm"
|
||||||
} [ make-image ] each ;
|
} [ make-image ] each ;
|
||||||
|
|
|
@ -34,6 +34,7 @@ call
|
||||||
"bit-arrays"
|
"bit-arrays"
|
||||||
"byte-arrays"
|
"byte-arrays"
|
||||||
"classes.private"
|
"classes.private"
|
||||||
|
"compiler.units"
|
||||||
"continuations.private"
|
"continuations.private"
|
||||||
"float-arrays"
|
"float-arrays"
|
||||||
"generator"
|
"generator"
|
||||||
|
@ -521,7 +522,7 @@ builtins get num-tags get tail f union-class define-class
|
||||||
{ "tag" "kernel.private" }
|
{ "tag" "kernel.private" }
|
||||||
{ "cwd" "io.files" }
|
{ "cwd" "io.files" }
|
||||||
{ "cd" "io.files" }
|
{ "cd" "io.files" }
|
||||||
{ "modify-code-heap" "words.private" }
|
{ "modify-code-heap" "compiler.units" }
|
||||||
{ "dlopen" "alien" }
|
{ "dlopen" "alien" }
|
||||||
{ "dlsym" "alien" }
|
{ "dlsym" "alien" }
|
||||||
{ "dlclose" "alien" }
|
{ "dlclose" "alien" }
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: init command-line namespaces words debugger io
|
||||||
kernel.private math memory continuations kernel io.files
|
kernel.private math memory continuations kernel io.files
|
||||||
io.backend system parser vocabs sequences prettyprint
|
io.backend system parser vocabs sequences prettyprint
|
||||||
vocabs.loader combinators splitting source-files strings
|
vocabs.loader combinators splitting source-files strings
|
||||||
definitions assocs compiler.errors ;
|
definitions assocs compiler.errors compiler.units ;
|
||||||
IN: bootstrap.stage2
|
IN: bootstrap.stage2
|
||||||
|
|
||||||
! Wrap everything in a catch which starts a listener so
|
! Wrap everything in a catch which starts a listener so
|
||||||
|
|
|
@ -255,6 +255,8 @@ PRIVATE>
|
||||||
>r dup word-props r> union over set-word-props
|
>r dup word-props r> union over set-word-props
|
||||||
t "class" set-word-prop ;
|
t "class" set-word-prop ;
|
||||||
|
|
||||||
|
GENERIC: update-methods ( class -- )
|
||||||
|
|
||||||
: define-class ( word members superclass metaclass -- )
|
: define-class ( word members superclass metaclass -- )
|
||||||
#! If it was already a class, update methods after.
|
#! If it was already a class, update methods after.
|
||||||
define-class-props
|
define-class-props
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USING: help.markup help.syntax help words definitions classes ;
|
USING: help.markup help.syntax help words compiler.units
|
||||||
|
classes ;
|
||||||
IN: classes.mixin
|
IN: classes.mixin
|
||||||
|
|
||||||
ARTICLE: "mixins" "Mixin classes"
|
ARTICLE: "mixins" "Mixin classes"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: generic help.markup help.syntax kernel kernel.private
|
USING: generic help.markup help.syntax kernel kernel.private
|
||||||
namespaces sequences words arrays layouts help effects math
|
namespaces sequences words arrays layouts help effects math
|
||||||
layouts classes.private classes definitions ;
|
layouts classes.private classes compiler.units ;
|
||||||
IN: classes.predicate
|
IN: classes.predicate
|
||||||
|
|
||||||
ARTICLE: "predicates" "Predicate classes"
|
ARTICLE: "predicates" "Predicate classes"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: generic help.markup help.syntax kernel kernel.private
|
USING: generic help.markup help.syntax kernel kernel.private
|
||||||
namespaces sequences words arrays layouts help effects math
|
namespaces sequences words arrays layouts help effects math
|
||||||
layouts classes.private classes definitions ;
|
layouts classes.private classes compiler.units ;
|
||||||
IN: classes.union
|
IN: classes.union
|
||||||
|
|
||||||
ARTICLE: "unions" "Union classes"
|
ARTICLE: "unions" "Union classes"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel namespaces arrays sequences io inference.backend
|
USING: kernel namespaces arrays sequences io inference.backend
|
||||||
inference.state generator debugger math.parser prettyprint words
|
inference.state generator debugger math.parser prettyprint words
|
||||||
words.private continuations vocabs assocs alien.compiler dlists
|
compiler.units continuations vocabs assocs alien.compiler dlists
|
||||||
optimizer definitions math compiler.errors threads graphs
|
optimizer definitions math compiler.errors threads graphs
|
||||||
generic ;
|
generic ;
|
||||||
IN: compiler
|
IN: compiler
|
||||||
|
@ -49,7 +49,10 @@ compiled-crossref global [ H{ } assoc-like ] change-at
|
||||||
"compiled-effect" set-word-prop ;
|
"compiled-effect" set-word-prop ;
|
||||||
|
|
||||||
: finish-compile ( word effect dependencies -- )
|
: finish-compile ( word effect dependencies -- )
|
||||||
>r dupd save-effect r> over compiled-unxref compiled-xref ;
|
>r dupd save-effect r>
|
||||||
|
f pick compiler-error
|
||||||
|
over compiled-unxref
|
||||||
|
compiled-xref ;
|
||||||
|
|
||||||
: compile-succeeded ( word -- effect dependencies )
|
: compile-succeeded ( word -- effect dependencies )
|
||||||
[
|
[
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
USING: help.markup help.syntax words math source-files
|
||||||
|
parser quotations definitions ;
|
||||||
|
IN: compiler.units
|
||||||
|
|
||||||
|
ARTICLE: "compilation-units" "Compilation units"
|
||||||
|
"A " { $emphasis "compilation unit" } " scopes a group of related definitions. They are compiled and entered into the system in one atomic operation."
|
||||||
|
$nl
|
||||||
|
"Words defined in a compilation unit may not be called until the compilation unit is finished. The parser detects this case for parsing words and throws a " { $link staging-violation } "; calling any other word from within its own compilation unit throws an " { $link undefined } " error."
|
||||||
|
$nl
|
||||||
|
"The parser groups all definitions in a source file into one compilation unit, and parsing words do not need to concern themselves with compilation units. However, if definitions are being created at run time, a compilation unit must be created explicitly:"
|
||||||
|
{ $subsection with-compilation-unit }
|
||||||
|
"Words called to associate a definition with a source file location:"
|
||||||
|
{ $subsection remember-definition }
|
||||||
|
{ $subsection remember-class }
|
||||||
|
"Forward reference checking (see " { $link "definition-checking" } "):"
|
||||||
|
{ $subsection forward-reference? }
|
||||||
|
"A hook to be called at the end of the compilation unit. If the optimizing compiler is loaded, this compiles new words with the " { $link "compiler" } ":"
|
||||||
|
{ $subsection recompile-hook }
|
||||||
|
"Low-level compiler interface exported by the Factor VM:"
|
||||||
|
{ $subsection modify-code-heap } ;
|
||||||
|
|
||||||
|
ABOUT: "compilation-units"
|
||||||
|
|
||||||
|
HELP: redefine-error
|
||||||
|
{ $values { "definition" "a definition specifier" } }
|
||||||
|
{ $description "Throws a " { $link redefine-error } "." }
|
||||||
|
{ $error-description "Indicates that a single source file contains two definitions for the same artifact, one of which shadows the other. This is an error since it indicates a likely mistake, such as two words accidentally named the same by the developer; the error is restartable." } ;
|
||||||
|
|
||||||
|
HELP: remember-definition
|
||||||
|
{ $values { "definition" "a definition specifier" } { "loc" "a " { $snippet "{ path line# }" } " pair" } }
|
||||||
|
{ $description "Saves the location of a definition and associates this definition with the current source file."
|
||||||
|
$nl
|
||||||
|
"This is the book-keeping required to detect " { $link redefine-error } " and " { $link forward-error } "." } ;
|
||||||
|
|
||||||
|
HELP: old-definitions
|
||||||
|
{ $var-description "Stores an assoc where the keys form the set of definitions which were defined by " { $link file } " the most recent time it was loaded." } ;
|
||||||
|
|
||||||
|
HELP: new-definitions
|
||||||
|
{ $var-description "Stores an assoc where the keys form the set of definitions which were defined so far by the current parsing of " { $link file } "." } ;
|
||||||
|
|
||||||
|
HELP: forward-error
|
||||||
|
{ $values { "word" word } }
|
||||||
|
{ $description "Throws a " { $link forward-error } "." }
|
||||||
|
{ $description "Indicates a word is being referenced prior to the location of its most recent definition. This can only happen if a source file is loaded, and subsequently edited such that two dependent definitions are reversed." } ;
|
||||||
|
|
||||||
|
HELP: with-compilation-unit
|
||||||
|
{ $values { "quot" quotation } }
|
||||||
|
{ $description "Calls a quotation in a new compilation unit. The quotation can define new words and classes, as well as forget words. When the quotation returns, any changed words are recompiled, and changes are applied atomically." }
|
||||||
|
{ $notes "Compilation units may be nested."
|
||||||
|
$nl
|
||||||
|
"The parser wraps every source file in a compilation unit, so parsing words may define new words without having to perform extra work; to define new words at any other time, you must wrap your defining code with this combinator."
|
||||||
|
$nl
|
||||||
|
"Since compilation is relatively expensive, you should try to batch up as many definitions into one compilation unit as possible." } ;
|
||||||
|
|
||||||
|
HELP: recompile-hook
|
||||||
|
{ $var-description "Quotation with stack effect " { $snippet "( words -- )" } ", called at the end of " { $link with-compilation-unit } "." } ;
|
||||||
|
|
||||||
|
HELP: no-compilation-unit
|
||||||
|
{ $values { "word" word } }
|
||||||
|
{ $description "Throws a " { $link no-compilation-unit } " error." }
|
||||||
|
{ $error-description "Thrown when an attempt is made to define a word outside of a " { $link with-compilation-unit } " combinator." } ;
|
||||||
|
|
||||||
|
HELP: modify-code-heap ( alist -- )
|
||||||
|
{ $values { "alist" "an alist" } }
|
||||||
|
{ $description "Stores compiled code definitions in the code heap. The alist maps words to the following:"
|
||||||
|
{ $list
|
||||||
|
{ { $link f } " - in this case, the word is compiled with the non-optimizing compiler part of the VM." }
|
||||||
|
{ { $snippet "{ code labels rel words literals }" } " - in this case, a code heap block is allocated with the given data." }
|
||||||
|
} }
|
||||||
|
{ $notes "This word is called at the end of " { $link with-compilation-unit } "." } ;
|
|
@ -0,0 +1,85 @@
|
||||||
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: kernel continuations assocs namespaces sequences words
|
||||||
|
vocabs definitions hashtables ;
|
||||||
|
IN: compiler.units
|
||||||
|
|
||||||
|
SYMBOL: old-definitions
|
||||||
|
SYMBOL: new-definitions
|
||||||
|
|
||||||
|
TUPLE: redefine-error def ;
|
||||||
|
|
||||||
|
: redefine-error ( definition -- )
|
||||||
|
\ redefine-error construct-boa
|
||||||
|
{ { "Continue" t } } throw-restarts drop ;
|
||||||
|
|
||||||
|
: add-once ( key assoc -- )
|
||||||
|
2dup key? [ over redefine-error ] when dupd set-at ;
|
||||||
|
|
||||||
|
: (remember-definition) ( definition loc assoc -- )
|
||||||
|
>r over set-where r> add-once ;
|
||||||
|
|
||||||
|
: remember-definition ( definition loc -- )
|
||||||
|
new-definitions get first (remember-definition) ;
|
||||||
|
|
||||||
|
: remember-class ( class loc -- )
|
||||||
|
over new-definitions get first key? [ dup redefine-error ] when
|
||||||
|
new-definitions get second (remember-definition) ;
|
||||||
|
|
||||||
|
TUPLE: forward-error word ;
|
||||||
|
|
||||||
|
: forward-error ( word -- )
|
||||||
|
\ forward-error construct-boa throw ;
|
||||||
|
|
||||||
|
: forward-reference? ( word -- ? )
|
||||||
|
dup old-definitions get assoc-stack
|
||||||
|
[ new-definitions get assoc-stack not ]
|
||||||
|
[ drop f ] if ;
|
||||||
|
|
||||||
|
SYMBOL: recompile-hook
|
||||||
|
|
||||||
|
: <definitions> ( -- pair ) { H{ } H{ } } [ clone ] map ;
|
||||||
|
|
||||||
|
SYMBOL: definition-observers
|
||||||
|
|
||||||
|
definition-observers global [ V{ } like ] change-at
|
||||||
|
|
||||||
|
GENERIC: definitions-changed ( assoc obj -- )
|
||||||
|
|
||||||
|
: add-definition-observer ( obj -- )
|
||||||
|
definition-observers get push ;
|
||||||
|
|
||||||
|
: remove-definition-observer ( obj -- )
|
||||||
|
definition-observers get delete ;
|
||||||
|
|
||||||
|
: notify-definition-observers ( assoc -- )
|
||||||
|
definition-observers get
|
||||||
|
[ definitions-changed ] curry* each ;
|
||||||
|
|
||||||
|
: changed-vocabs ( -- assoc )
|
||||||
|
changed-words get
|
||||||
|
[ drop word-vocabulary dup [ vocab ] when dup ] assoc-map ;
|
||||||
|
|
||||||
|
: changed-definitions ( -- assoc )
|
||||||
|
H{ } clone
|
||||||
|
dup new-definitions get first update
|
||||||
|
dup new-definitions get second update
|
||||||
|
dup changed-words get update
|
||||||
|
dup changed-vocabs update ;
|
||||||
|
|
||||||
|
: finish-compilation-unit ( -- )
|
||||||
|
changed-definitions notify-definition-observers
|
||||||
|
changed-words get keys recompile-hook get call ;
|
||||||
|
|
||||||
|
: with-compilation-unit ( quot -- )
|
||||||
|
[
|
||||||
|
H{ } clone changed-words set
|
||||||
|
<definitions> new-definitions set
|
||||||
|
<definitions> old-definitions set
|
||||||
|
[ finish-compilation-unit ]
|
||||||
|
[ ] cleanup
|
||||||
|
] with-scope ; inline
|
||||||
|
|
||||||
|
recompile-hook global
|
||||||
|
[ [ [ f ] { } map>assoc modify-code-heap ] or ]
|
||||||
|
change-at
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007 Slava Pestov.
|
! Copyright (C) 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: bootstrap.image.private kernel namespaces system
|
USING: bootstrap.image.private kernel namespaces system
|
||||||
cpu.arm.assembler math layouts words vocabs ;
|
cpu.arm.assembler math layouts words compiler.units ;
|
||||||
IN: bootstrap.arm
|
IN: bootstrap.arm
|
||||||
|
|
||||||
! We generate ARM3 code
|
! We generate ARM3 code
|
||||||
|
@ -116,4 +116,4 @@ big-endian off
|
||||||
|
|
||||||
[ LR BX ] { } make jit-return set
|
[ LR BX ] { } make jit-return set
|
||||||
|
|
||||||
"bootstrap.arm" forget-vocab
|
[ "bootstrap.arm" forget-vocab ] with-compilation-unit
|
||||||
|
|
|
@ -106,4 +106,4 @@ big-endian on
|
||||||
|
|
||||||
[ BLR ] f f f jit-return jit-define
|
[ BLR ] f f f jit-return jit-define
|
||||||
|
|
||||||
"bootstrap.ppc" forget-vocab
|
[ "bootstrap.ppc" forget-vocab ] with-compilation-unit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007 Slava Pestov.
|
! Copyright (C) 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: bootstrap.image.private kernel namespaces system
|
USING: bootstrap.image.private kernel namespaces system
|
||||||
cpu.x86.assembler layouts vocabs math generator.fixup
|
cpu.x86.assembler layouts compiler.units math generator.fixup
|
||||||
compiler.constants ;
|
compiler.constants ;
|
||||||
IN: bootstrap.x86
|
IN: bootstrap.x86
|
||||||
|
|
||||||
|
@ -75,4 +75,4 @@ big-endian off
|
||||||
|
|
||||||
[ 0 RET ] f f f jit-return jit-define
|
[ 0 RET ] f f f jit-return jit-define
|
||||||
|
|
||||||
"bootstrap.x86" forget-vocab
|
[ "bootstrap.x86" forget-vocab ] with-compilation-unit
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: arrays definitions generic hashtables inspector io kernel
|
||||||
math namespaces prettyprint sequences assocs sequences.private
|
math namespaces prettyprint sequences assocs sequences.private
|
||||||
strings io.styles vectors words system splitting math.parser
|
strings io.styles vectors words system splitting math.parser
|
||||||
tuples continuations continuations.private combinators
|
tuples continuations continuations.private combinators
|
||||||
generic.math io.streams.duplex classes
|
generic.math io.streams.duplex classes compiler.units
|
||||||
generic.standard ;
|
generic.standard ;
|
||||||
IN: debugger
|
IN: debugger
|
||||||
|
|
||||||
|
@ -228,5 +228,7 @@ M: forward-error error.
|
||||||
M: undefined summary
|
M: undefined summary
|
||||||
drop "Calling a deferred word before it has been defined" ;
|
drop "Calling a deferred word before it has been defined" ;
|
||||||
|
|
||||||
M: no-compilation-unit summary
|
M: no-compilation-unit error.
|
||||||
drop "Defining a word outside of a compilation unit" ;
|
"Attempting to define " write
|
||||||
|
no-compilation-unit-word pprint
|
||||||
|
" outside of a compilation unit" print ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: help.markup help.syntax words math source-files
|
USING: help.markup help.syntax words math source-files
|
||||||
parser quotations ;
|
parser quotations compiler.units ;
|
||||||
IN: definitions
|
IN: definitions
|
||||||
|
|
||||||
ARTICLE: "definition-protocol" "Definition protocol"
|
ARTICLE: "definition-protocol" "Definition protocol"
|
||||||
|
@ -59,21 +59,6 @@ $nl
|
||||||
"The parser also catches duplicate definitions. If an artifact is defined twice in the same source file, the earlier definition will never be accessible, and this is almost always a mistake, perhaps due to a bad choice of word names, or a copy and paste error. The parser raises an error in this case."
|
"The parser also catches duplicate definitions. If an artifact is defined twice in the same source file, the earlier definition will never be accessible, and this is almost always a mistake, perhaps due to a bad choice of word names, or a copy and paste error. The parser raises an error in this case."
|
||||||
{ $subsection redefine-error } ;
|
{ $subsection redefine-error } ;
|
||||||
|
|
||||||
ARTICLE: "compilation-units" "Compilation units"
|
|
||||||
"A " { $emphasis "compilation unit" } " scopes a group of related definitions. They are compiled and entered into the system in one atomic operation."
|
|
||||||
$nl
|
|
||||||
"Words defined in a compilation unit may not be called until the compilation unit is finished. The parser detects this case for parsing words and throws a " { $link staging-violation } "; calling any other word from within its own compilation unit throws an " { $link undefined } " error."
|
|
||||||
$nl
|
|
||||||
"The parser groups all definitions in a source file into one compilation unit, and parsing words do not need to concern themselves with compilation units. However, if definitions are being created at run time, a compilation unit must be created explicitly:"
|
|
||||||
{ $subsection with-compilation-unit }
|
|
||||||
"Words called to associate a definition with a source file location:"
|
|
||||||
{ $subsection remember-definition }
|
|
||||||
{ $subsection remember-class }
|
|
||||||
"Forward reference checking (see " { $link "definition-checking" } "):"
|
|
||||||
{ $subsection forward-reference? }
|
|
||||||
"A hook to be called at the end of the compilation unit. If the optimizing compiler is loaded, this compiles new words with the " { $link "compiler" } ":"
|
|
||||||
{ $subsection recompile-hook } ;
|
|
||||||
|
|
||||||
ARTICLE: "definitions" "Definitions"
|
ARTICLE: "definitions" "Definitions"
|
||||||
"A " { $emphasis "definition" } " is an artifact read from a source file. This includes words, methods, and help articles. Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary. Implementations of the definition protocol include pathnames, words, methods, and help articles."
|
"A " { $emphasis "definition" } " is an artifact read from a source file. This includes words, methods, and help articles. Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary. Implementations of the definition protocol include pathnames, words, methods, and help articles."
|
||||||
{ $subsection "definition-protocol" }
|
{ $subsection "definition-protocol" }
|
||||||
|
@ -140,42 +125,3 @@ HELP: delete-xref
|
||||||
{ $description "Remove the vertex which represents the definition from the " { $link crossref } " graph." }
|
{ $description "Remove the vertex which represents the definition from the " { $link crossref } " graph." }
|
||||||
{ $notes "This word is called before a word is forgotten." }
|
{ $notes "This word is called before a word is forgotten." }
|
||||||
{ $see-also forget } ;
|
{ $see-also forget } ;
|
||||||
|
|
||||||
HELP: redefine-error
|
|
||||||
{ $values { "definition" "a definition specifier" } }
|
|
||||||
{ $description "Throws a " { $link redefine-error } "." }
|
|
||||||
{ $error-description "Indicates that a single source file contains two definitions for the same artifact, one of which shadows the other. This is an error since it indicates a likely mistake, such as two words accidentally named the same by the developer; the error is restartable." } ;
|
|
||||||
|
|
||||||
HELP: remember-definition
|
|
||||||
{ $values { "definition" "a definition specifier" } { "loc" "a " { $snippet "{ path line# }" } " pair" } }
|
|
||||||
{ $description "Saves the location of a definition and associates this definition with the current source file."
|
|
||||||
$nl
|
|
||||||
"This is the book-keeping required to detect " { $link redefine-error } " and " { $link forward-error } "." } ;
|
|
||||||
|
|
||||||
HELP: old-definitions
|
|
||||||
{ $var-description "Stores an assoc where the keys form the set of definitions which were defined by " { $link file } " the most recent time it was loaded." } ;
|
|
||||||
|
|
||||||
HELP: new-definitions
|
|
||||||
{ $var-description "Stores an assoc where the keys form the set of definitions which were defined so far by the current parsing of " { $link file } "." } ;
|
|
||||||
|
|
||||||
HELP: forward-error
|
|
||||||
{ $values { "word" word } }
|
|
||||||
{ $description "Throws a " { $link forward-error } "." }
|
|
||||||
{ $description "Indicates a word is being referenced prior to the location of its most recent definition. This can only happen if a source file is loaded, and subsequently edited such that two dependent definitions are reversed." } ;
|
|
||||||
|
|
||||||
HELP: with-compilation-unit
|
|
||||||
{ $values { "quot" quotation } }
|
|
||||||
{ $description "Calls a quotation in a new compilation unit. The quotation can define new words and classes, as well as forget words. When the quotation returns, any changed words are recompiled, and changes are applied atomically." }
|
|
||||||
{ $notes "Compilation units may be nested."
|
|
||||||
$nl
|
|
||||||
"The parser wraps every source file in a compilation unit, so parsing words may define new words without having to perform extra work; to define new words at any other time, you must wrap your defining code with this combinator."
|
|
||||||
$nl
|
|
||||||
"Since compilation is relatively expensive, you should try to batch up as many definitions into one compilation unit as possible." } ;
|
|
||||||
|
|
||||||
HELP: recompile-hook
|
|
||||||
{ $var-description "Quotation with stack effect " { $snippet "( words -- )" } ", called at the end of " { $link with-compilation-unit } "." } ;
|
|
||||||
|
|
||||||
HELP: no-compilation-unit
|
|
||||||
{ $values { "word" word } }
|
|
||||||
{ $description "Throws a " { $link no-compilation-unit } " error." }
|
|
||||||
{ $error-description "Thrown when an attempt is made to define a word outside of a " { $link with-compilation-unit } " combinator." } ;
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2006, 2007 Slava Pestov.
|
! Copyright (C) 2006, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: definitions
|
IN: definitions
|
||||||
USING: kernel sequences namespaces assocs graphs continuations ;
|
USING: kernel sequences namespaces assocs graphs ;
|
||||||
|
|
||||||
GENERIC: where ( defspec -- loc )
|
GENERIC: where ( defspec -- loc )
|
||||||
|
|
||||||
|
@ -43,61 +43,3 @@ M: object redefined* drop ;
|
||||||
|
|
||||||
: delete-xref ( defspec -- )
|
: delete-xref ( defspec -- )
|
||||||
dup unxref crossref get delete-at ;
|
dup unxref crossref get delete-at ;
|
||||||
|
|
||||||
GENERIC: update-methods ( class -- )
|
|
||||||
|
|
||||||
SYMBOL: changed-words
|
|
||||||
SYMBOL: old-definitions
|
|
||||||
SYMBOL: new-definitions
|
|
||||||
|
|
||||||
TUPLE: redefine-error def ;
|
|
||||||
|
|
||||||
: redefine-error ( definition -- )
|
|
||||||
\ redefine-error construct-boa
|
|
||||||
{ { "Continue" t } } throw-restarts drop ;
|
|
||||||
|
|
||||||
: add-once ( key assoc -- )
|
|
||||||
2dup key? [ over redefine-error ] when dupd set-at ;
|
|
||||||
|
|
||||||
: (remember-definition) ( definition loc assoc -- )
|
|
||||||
>r over set-where r> add-once ;
|
|
||||||
|
|
||||||
: remember-definition ( definition loc -- )
|
|
||||||
new-definitions get first (remember-definition) ;
|
|
||||||
|
|
||||||
: remember-class ( class loc -- )
|
|
||||||
over new-definitions get first key? [ dup redefine-error ] when
|
|
||||||
new-definitions get second (remember-definition) ;
|
|
||||||
|
|
||||||
TUPLE: forward-error word ;
|
|
||||||
|
|
||||||
: forward-error ( word -- )
|
|
||||||
\ forward-error construct-boa throw ;
|
|
||||||
|
|
||||||
: forward-reference? ( word -- ? )
|
|
||||||
dup old-definitions get assoc-stack
|
|
||||||
[ new-definitions get assoc-stack not ]
|
|
||||||
[ drop f ] if ;
|
|
||||||
|
|
||||||
SYMBOL: recompile-hook
|
|
||||||
|
|
||||||
: <definitions> ( -- pair ) { H{ } H{ } } [ clone ] map ;
|
|
||||||
|
|
||||||
TUPLE: no-compilation-unit word ;
|
|
||||||
|
|
||||||
: no-compilation-unit ( word -- * )
|
|
||||||
\ no-compilation-unit construct-boa throw ;
|
|
||||||
|
|
||||||
: changed-word ( word -- )
|
|
||||||
dup changed-words get
|
|
||||||
[ no-compilation-unit ] unless*
|
|
||||||
set-at ;
|
|
||||||
|
|
||||||
: with-compilation-unit ( quot -- )
|
|
||||||
[
|
|
||||||
H{ } clone changed-words set
|
|
||||||
<definitions> new-definitions set
|
|
||||||
<definitions> old-definitions set
|
|
||||||
[ changed-words get keys recompile-hook get call ]
|
|
||||||
[ ] cleanup
|
|
||||||
] with-scope ; inline
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
USING: io io.streams.string io.streams.duplex listener
|
USING: io io.streams.string io.streams.duplex listener
|
||||||
tools.test parser math namespaces continuations vocabs kernel ;
|
tools.test parser math namespaces continuations vocabs kernel
|
||||||
|
compiler.units ;
|
||||||
IN: temporary
|
IN: temporary
|
||||||
|
|
||||||
: hello "Hi" print ; parsing
|
: hello "Hi" print ; parsing
|
||||||
|
@ -28,7 +29,9 @@ IN: temporary
|
||||||
] with-file-vocabs
|
] with-file-vocabs
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
[
|
||||||
"vocabs.loader.test.c" forget-vocab
|
"vocabs.loader.test.c" forget-vocab
|
||||||
|
] with-compilation-unit
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -36,7 +39,9 @@ IN: temporary
|
||||||
] unit-test-fails
|
] unit-test-fails
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
[
|
||||||
"vocabs.loader.test.c" forget-vocab
|
"vocabs.loader.test.c" forget-vocab
|
||||||
|
] with-compilation-unit
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: arrays hashtables io kernel math memory namespaces
|
USING: arrays hashtables io kernel math memory namespaces
|
||||||
parser sequences strings io.styles io.streams.lines
|
parser sequences strings io.styles io.streams.lines
|
||||||
io.streams.duplex vectors words generic system combinators
|
io.streams.duplex vectors words generic system combinators
|
||||||
tuples continuations debugger definitions ;
|
tuples continuations debugger definitions compiler.units ;
|
||||||
IN: listener
|
IN: listener
|
||||||
|
|
||||||
SYMBOL: quit-flag
|
SYMBOL: quit-flag
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: help.markup help.syntax kernel sequences words
|
USING: help.markup help.syntax kernel sequences words
|
||||||
math strings vectors quotations generic effects classes
|
math strings vectors quotations generic effects classes
|
||||||
vocabs.loader definitions io vocabs source-files
|
vocabs.loader definitions io vocabs source-files
|
||||||
quotations namespaces ;
|
quotations namespaces compiler.units ;
|
||||||
IN: parser
|
IN: parser
|
||||||
|
|
||||||
ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
|
ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespaces prettyprint sequences strings vectors words
|
||||||
quotations inspector io.styles io combinators sorting
|
quotations inspector io.styles io combinators sorting
|
||||||
splitting math.parser effects continuations debugger
|
splitting math.parser effects continuations debugger
|
||||||
io.files io.streams.string io.streams.lines vocabs
|
io.files io.streams.string io.streams.lines vocabs
|
||||||
source-files classes hashtables compiler.errors ;
|
source-files classes hashtables compiler.errors compiler.units ;
|
||||||
IN: parser
|
IN: parser
|
||||||
|
|
||||||
TUPLE: lexer text line column ;
|
TUPLE: lexer text line column ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: help.markup help.syntax vocabs.loader io.files strings
|
USING: help.markup help.syntax vocabs.loader io.files strings
|
||||||
definitions quotations ;
|
definitions quotations compiler.units ;
|
||||||
IN: source-files
|
IN: source-files
|
||||||
|
|
||||||
ARTICLE: "source-files" "Source files"
|
ARTICLE: "source-files" "Source files"
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespaces prettyprint sequences strings vectors words
|
||||||
quotations inspector io.styles io combinators sorting
|
quotations inspector io.styles io combinators sorting
|
||||||
splitting math.parser effects continuations debugger
|
splitting math.parser effects continuations debugger
|
||||||
io.files io.crc32 io.streams.string io.streams.lines vocabs
|
io.files io.crc32 io.streams.string io.streams.lines vocabs
|
||||||
hashtables graphs ;
|
hashtables graphs compiler.units ;
|
||||||
IN: source-files
|
IN: source-files
|
||||||
|
|
||||||
SYMBOL: source-files
|
SYMBOL: source-files
|
||||||
|
|
|
@ -4,7 +4,8 @@ USING: alien arrays bit-arrays byte-arrays definitions generic
|
||||||
hashtables kernel math namespaces parser sequences strings sbufs
|
hashtables kernel math namespaces parser sequences strings sbufs
|
||||||
vectors words quotations io assocs splitting tuples
|
vectors words quotations io assocs splitting tuples
|
||||||
generic.standard generic.math classes io.files vocabs
|
generic.standard generic.math classes io.files vocabs
|
||||||
float-arrays classes.union classes.mixin classes.predicate ;
|
float-arrays classes.union classes.mixin classes.predicate
|
||||||
|
compiler.units ;
|
||||||
IN: bootstrap.syntax
|
IN: bootstrap.syntax
|
||||||
|
|
||||||
! These words are defined as a top-level form, instead of with
|
! These words are defined as a top-level form, instead of with
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: generic help.markup help.syntax kernel
|
USING: generic help.markup help.syntax kernel
|
||||||
tuples.private classes slots quotations words arrays
|
tuples.private classes slots quotations words arrays
|
||||||
generic.standard sequences definitions ;
|
generic.standard sequences definitions compiler.units ;
|
||||||
IN: tuples
|
IN: tuples
|
||||||
|
|
||||||
ARTICLE: "tuple-constructors" "Constructors and slots"
|
ARTICLE: "tuple-constructors" "Constructors and slots"
|
||||||
|
|
|
@ -7,7 +7,9 @@ debugger ;
|
||||||
|
|
||||||
! This vocab should not exist, but just in case...
|
! This vocab should not exist, but just in case...
|
||||||
[ ] [
|
[ ] [
|
||||||
|
[
|
||||||
"vocabs.loader.test" forget-vocab
|
"vocabs.loader.test" forget-vocab
|
||||||
|
] with-compilation-unit
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ T{ vocab-link f "vocabs.loader.test" } ]
|
[ T{ vocab-link f "vocabs.loader.test" } ]
|
||||||
|
@ -17,7 +19,7 @@ debugger ;
|
||||||
[ "kernel" f >vocab-link "kernel" vocab = ] unit-test
|
[ "kernel" f >vocab-link "kernel" vocab = ] unit-test
|
||||||
|
|
||||||
! This vocab should not exist, but just in case...
|
! This vocab should not exist, but just in case...
|
||||||
[ ] [ "core" forget-vocab ] unit-test
|
[ ] [ [ "core" forget-vocab ] with-compilation-unit ] unit-test
|
||||||
|
|
||||||
2 [
|
2 [
|
||||||
[ T{ no-vocab f "core" } ]
|
[ T{ no-vocab f "core" } ]
|
||||||
|
@ -50,7 +52,7 @@ IN: temporary
|
||||||
|
|
||||||
"resource:core/vocabs/loader/test/a/a.factor" forget-source
|
"resource:core/vocabs/loader/test/a/a.factor" forget-source
|
||||||
|
|
||||||
"vocabs.loader.test.a" forget-vocab
|
[ "vocabs.loader.test.a" forget-vocab ] with-compilation-unit
|
||||||
|
|
||||||
0 "count-me" set-global
|
0 "count-me" set-global
|
||||||
|
|
||||||
|
@ -81,7 +83,9 @@ IN: temporary
|
||||||
0 "count-me" set-global
|
0 "count-me" set-global
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
[
|
||||||
"vocabs.loader.test.b" forget-vocab
|
"vocabs.loader.test.b" forget-vocab
|
||||||
|
] with-compilation-unit
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
@ -125,8 +129,12 @@ IN: temporary
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
: forget-junk
|
: forget-junk
|
||||||
|
[
|
||||||
{ "2" "a" "b" "d" "e" "f" }
|
{ "2" "a" "b" "d" "e" "f" }
|
||||||
[ "vocabs.loader.test." swap append forget-vocab ] each ;
|
[
|
||||||
|
"vocabs.loader.test." swap append forget-vocab
|
||||||
|
] each
|
||||||
|
] with-compilation-unit ;
|
||||||
|
|
||||||
forget-junk
|
forget-junk
|
||||||
|
|
||||||
|
@ -134,6 +142,6 @@ forget-junk
|
||||||
"IN: xabbabbja" eval "xabbabbja" vocab-files
|
"IN: xabbabbja" eval "xabbabbja" vocab-files
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
"xabbabbja" forget-vocab
|
[ "xabbabbja" forget-vocab ] with-compilation-unit
|
||||||
|
|
||||||
forget-junk
|
forget-junk
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: help.markup help.syntax strings words ;
|
USING: help.markup help.syntax strings words compiler.units ;
|
||||||
IN: vocabs
|
IN: vocabs
|
||||||
|
|
||||||
ARTICLE: "vocabularies" "Vocabularies"
|
ARTICLE: "vocabularies" "Vocabularies"
|
||||||
|
@ -76,7 +76,8 @@ HELP: all-words
|
||||||
|
|
||||||
HELP: forget-vocab
|
HELP: forget-vocab
|
||||||
{ $values { "vocab" string } }
|
{ $values { "vocab" string } }
|
||||||
{ $description "Removes a vocabulary. All words in the vocabulary become uninterned." } ;
|
{ $description "Removes a vocabulary. All words in the vocabulary become uninterned." }
|
||||||
|
{ $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
|
||||||
|
|
||||||
HELP: load-vocab-hook
|
HELP: load-vocab-hook
|
||||||
{ $var-description "a quotation with stack effect " { $snippet "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functinality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
|
{ $var-description "a quotation with stack effect " { $snippet "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functinality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
|
||||||
|
|
|
@ -12,6 +12,8 @@ words
|
||||||
main help
|
main help
|
||||||
source-loaded? docs-loaded? ;
|
source-loaded? docs-loaded? ;
|
||||||
|
|
||||||
|
M: vocab equal? 2drop f ;
|
||||||
|
|
||||||
: <vocab> ( name -- vocab )
|
: <vocab> ( name -- vocab )
|
||||||
H{ } clone t
|
H{ } clone t
|
||||||
{ set-vocab-name set-vocab-words set-vocab-source-loaded? }
|
{ set-vocab-name set-vocab-words set-vocab-source-loaded? }
|
||||||
|
@ -91,9 +93,8 @@ M: vocab-link vocab-name vocab-link-name ;
|
||||||
|
|
||||||
UNION: vocab-spec vocab vocab-link ;
|
UNION: vocab-spec vocab vocab-link ;
|
||||||
|
|
||||||
M: vocab-spec forget
|
: forget-vocab ( vocab -- )
|
||||||
dup vocab-words values forget-all
|
dup vocab-words values forget-all
|
||||||
vocab-name dictionary get delete-at ;
|
vocab-name dictionary get delete-at ;
|
||||||
|
|
||||||
: forget-vocab ( vocab -- )
|
M: vocab-spec forget forget-vocab ;
|
||||||
[ f >vocab-link forget ] with-compilation-unit ;
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: definitions help.markup help.syntax kernel
|
USING: definitions help.markup help.syntax kernel
|
||||||
kernel.private parser words.private vocabs classes quotations
|
kernel.private parser words.private vocabs classes quotations
|
||||||
strings effects ;
|
strings effects compiler.units ;
|
||||||
IN: words
|
IN: words
|
||||||
|
|
||||||
ARTICLE: "interned-words" "Looking up and creating words"
|
ARTICLE: "interned-words" "Looking up and creating words"
|
||||||
|
@ -165,9 +165,7 @@ ARTICLE: "word.private" "Word implementation details"
|
||||||
{ $subsection word-def }
|
{ $subsection word-def }
|
||||||
{ $subsection set-word-def }
|
{ $subsection set-word-def }
|
||||||
"An " { $emphasis "XT" } " (execution token) is the machine code address of a word:"
|
"An " { $emphasis "XT" } " (execution token) is the machine code address of a word:"
|
||||||
{ $subsection word-xt }
|
{ $subsection word-xt } ;
|
||||||
"Low-level compiler interface exported by the Factor VM:"
|
|
||||||
{ $subsection modify-code-heap } ;
|
|
||||||
|
|
||||||
ARTICLE: "words" "Words"
|
ARTICLE: "words" "Words"
|
||||||
"Words are the Factor equivalent of functions or procedures; a word is essentially a named quotation."
|
"Words are the Factor equivalent of functions or procedures; a word is essentially a named quotation."
|
||||||
|
@ -402,12 +400,3 @@ HELP: define-inline
|
||||||
{ $values { "word" word } { "quot" quotation } }
|
{ $values { "word" word } { "quot" quotation } }
|
||||||
{ $description "Defines a word and makes it " { $link POSTPONE: inline } "." }
|
{ $description "Defines a word and makes it " { $link POSTPONE: inline } "." }
|
||||||
{ $side-effects "word" } ;
|
{ $side-effects "word" } ;
|
||||||
|
|
||||||
HELP: modify-code-heap ( alist -- )
|
|
||||||
{ $values { "alist" "an alist" } }
|
|
||||||
{ $description "Stores compiled code definitions in the code heap. The alist maps words to the following:"
|
|
||||||
{ $list
|
|
||||||
{ { $link f } " - in this case, the word is compiled with the non-optimizing compiler part of the VM." }
|
|
||||||
{ { $snippet "{ code labels rel words literals }" } " - in this case, a code heap block is allocated with the given data." }
|
|
||||||
} }
|
|
||||||
{ $notes "This word is called at the end of " { $link with-compilation-unit } "." } ;
|
|
||||||
|
|
|
@ -90,6 +90,18 @@ M: word uses ( word -- seq )
|
||||||
M: word redefined* ( word -- )
|
M: word redefined* ( word -- )
|
||||||
{ "inferred-effect" "base-case" "no-effect" } reset-props ;
|
{ "inferred-effect" "base-case" "no-effect" } reset-props ;
|
||||||
|
|
||||||
|
SYMBOL: changed-words
|
||||||
|
|
||||||
|
TUPLE: no-compilation-unit word ;
|
||||||
|
|
||||||
|
: no-compilation-unit ( word -- * )
|
||||||
|
\ no-compilation-unit construct-boa throw ;
|
||||||
|
|
||||||
|
: changed-word ( word -- )
|
||||||
|
dup changed-words get
|
||||||
|
[ no-compilation-unit ] unless*
|
||||||
|
set-at ;
|
||||||
|
|
||||||
: define ( word def -- )
|
: define ( word def -- )
|
||||||
[ ] like
|
[ ] like
|
||||||
over unxref
|
over unxref
|
||||||
|
@ -192,7 +204,3 @@ M: word literalize <wrapper> ;
|
||||||
: ?word-name dup word? [ word-name ] when ;
|
: ?word-name dup word? [ word-name ] when ;
|
||||||
|
|
||||||
: xref-words ( -- ) all-words [ xref ] each ;
|
: xref-words ( -- ) all-words [ xref ] each ;
|
||||||
|
|
||||||
recompile-hook global
|
|
||||||
[ [ [ f ] { } map>assoc modify-code-heap ] or ]
|
|
||||||
change-at
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: compiler io kernel cocoa.runtime cocoa.subclassing
|
USING: compiler io kernel cocoa.runtime cocoa.subclassing
|
||||||
cocoa.messages cocoa.types sequences words vocabs parser
|
cocoa.messages cocoa.types sequences words vocabs parser
|
||||||
core-foundation namespaces assocs hashtables definitions ;
|
core-foundation namespaces assocs hashtables compiler.units ;
|
||||||
IN: cocoa
|
IN: cocoa
|
||||||
|
|
||||||
: (remember-send) ( selector variable -- )
|
: (remember-send) ( selector variable -- )
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2006, 2007 Slava Pestov
|
! Copyright (C) 2006, 2008 Slava Pestov
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien alien.c-types arrays assocs combinators compiler
|
USING: alien alien.c-types arrays assocs combinators compiler
|
||||||
hashtables kernel libc math namespaces parser sequences words
|
hashtables kernel libc math namespaces parser sequences words
|
||||||
cocoa.messages cocoa.runtime definitions ;
|
cocoa.messages cocoa.runtime compiler.units ;
|
||||||
IN: cocoa.subclassing
|
IN: cocoa.subclassing
|
||||||
|
|
||||||
: init-method ( method alien -- )
|
: init-method ( method alien -- )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays kernel parser sequences words help help.topics
|
USING: arrays kernel parser sequences words help help.topics
|
||||||
namespaces vocabs definitions ;
|
namespaces vocabs definitions compiler.units ;
|
||||||
IN: help.syntax
|
IN: help.syntax
|
||||||
|
|
||||||
: HELP:
|
: HELP:
|
||||||
|
|
|
@ -70,6 +70,9 @@ GENERIC: update-model ( model -- )
|
||||||
|
|
||||||
M: model update-model drop ;
|
M: model update-model drop ;
|
||||||
|
|
||||||
|
: notify-connections ( model -- )
|
||||||
|
dup model-connections [ model-changed ] curry* each ;
|
||||||
|
|
||||||
: set-model ( value model -- )
|
: set-model ( value model -- )
|
||||||
dup model-locked? [
|
dup model-locked? [
|
||||||
2drop
|
2drop
|
||||||
|
@ -77,7 +80,7 @@ M: model update-model drop ;
|
||||||
dup [
|
dup [
|
||||||
[ set-model-value ] keep
|
[ set-model-value ] keep
|
||||||
[ update-model ] keep
|
[ update-model ] keep
|
||||||
dup model-connections [ model-changed ] curry* each
|
notify-connections
|
||||||
] with-locked-model
|
] with-locked-model
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel words parser io inspector quotations sequences
|
USING: kernel words parser io inspector quotations sequences
|
||||||
prettyprint continuations effects definitions ;
|
prettyprint continuations effects definitions compiler.units ;
|
||||||
IN: tools.annotations
|
IN: tools.annotations
|
||||||
|
|
||||||
: reset ( word -- )
|
: reset ( word -- )
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io io.files io.launcher kernel namespaces sequences
|
USING: io io.files io.launcher kernel namespaces sequences
|
||||||
system tools.deploy.backend tools.deploy.config assocs
|
system tools.deploy.backend tools.deploy.config assocs
|
||||||
hashtables prettyprint io.unix.backend cocoa cocoa.plists
|
hashtables prettyprint io.unix.backend cocoa
|
||||||
cocoa.application cocoa.classes qualified ;
|
cocoa.application cocoa.classes qualified ;
|
||||||
QUALIFIED: unix
|
QUALIFIED: unix
|
||||||
IN: tools.deploy.macosx
|
IN: tools.deploy.macosx
|
||||||
|
@ -43,7 +43,7 @@ IN: tools.deploy.macosx
|
||||||
|
|
||||||
dup "CFBundleExecutable" set
|
dup "CFBundleExecutable" set
|
||||||
"org.factor." swap append "CFBundleIdentifier" set
|
"org.factor." swap append "CFBundleIdentifier" set
|
||||||
] H{ } make-assoc print-plist ;
|
] H{ } make-assoc drop ; ! print-plist ;
|
||||||
|
|
||||||
: create-app-plist ( vocab bundle-name -- )
|
: create-app-plist ( vocab bundle-name -- )
|
||||||
dup "Contents/Info.plist" path+ <file-writer>
|
dup "Contents/Info.plist" path+ <file-writer>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
! Copyright (C) 2006, 2007 Slava Pestov.
|
! Copyright (C) 2006, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: debugger ui.tools.workspace help help.topics kernel
|
USING: debugger ui.tools.workspace help help.topics kernel
|
||||||
models ui.commands ui.gadgets ui.gadgets.panes
|
models ui.commands ui.gadgets ui.gadgets.panes
|
||||||
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures
|
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures
|
||||||
ui.gadgets.buttons ;
|
ui.gadgets.buttons compiler.units assocs words ;
|
||||||
IN: ui.tools.browser
|
IN: ui.tools.browser
|
||||||
|
|
||||||
TUPLE: browser-gadget pane history ;
|
TUPLE: browser-gadget pane history ;
|
||||||
|
@ -17,7 +17,7 @@ TUPLE: browser-gadget pane history ;
|
||||||
[ [ dup help ] try drop ] <pane-control> ;
|
[ [ dup help ] try drop ] <pane-control> ;
|
||||||
|
|
||||||
: init-history ( browser-gadget -- )
|
: init-history ( browser-gadget -- )
|
||||||
"handbook" <history>
|
"handbook" >link <history>
|
||||||
swap set-browser-gadget-history ;
|
swap set-browser-gadget-history ;
|
||||||
|
|
||||||
: <browser-gadget> ( -- gadget )
|
: <browser-gadget> ( -- gadget )
|
||||||
|
@ -33,6 +33,24 @@ M: browser-gadget call-tool* show-help ;
|
||||||
M: browser-gadget tool-scroller
|
M: browser-gadget tool-scroller
|
||||||
browser-gadget-pane find-scroller ;
|
browser-gadget-pane find-scroller ;
|
||||||
|
|
||||||
|
M: browser-gadget graft*
|
||||||
|
dup add-definition-observer
|
||||||
|
delegate graft* ;
|
||||||
|
|
||||||
|
M: browser-gadget ungraft*
|
||||||
|
dup delegate ungraft*
|
||||||
|
remove-definition-observer ;
|
||||||
|
|
||||||
|
: showing-definition? ( defspec assoc -- ? )
|
||||||
|
2dup key? >r
|
||||||
|
>r dup word-link? [ link-name ] when r> key?
|
||||||
|
r> or ;
|
||||||
|
|
||||||
|
M: browser-gadget definitions-changed ( assoc browser -- )
|
||||||
|
browser-gadget-history
|
||||||
|
dup model-value rot showing-definition?
|
||||||
|
[ notify-connections ] [ drop ] if ;
|
||||||
|
|
||||||
: help-action ( browser-gadget -- link )
|
: help-action ( browser-gadget -- link )
|
||||||
browser-gadget-history model-value >link ;
|
browser-gadget-history model-value >link ;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespaces parser prettyprint quotations tools.annotations
|
||||||
editors tools.profiler tools.test tools.time tools.interpreter
|
editors tools.profiler tools.test tools.time tools.interpreter
|
||||||
ui.commands ui.gadgets.editors ui.gestures ui.operations
|
ui.commands ui.gadgets.editors ui.gestures ui.operations
|
||||||
ui.tools.deploy vocabs vocabs.loader words sequences
|
ui.tools.deploy vocabs vocabs.loader words sequences
|
||||||
tools.browser classes ;
|
tools.browser classes compiler.units ;
|
||||||
IN: ui.tools.operations
|
IN: ui.tools.operations
|
||||||
|
|
||||||
V{ } clone operations set-global
|
V{ } clone operations set-global
|
||||||
|
|
Loading…
Reference in New Issue