Remove compiler-hook which was just a workaround for the old batch compilation model
parent
5378c05508
commit
8189e33b2b
|
@ -13,14 +13,15 @@ vocabs.loader system ;
|
|||
|
||||
"resource:core/bootstrap/primitives.factor" run-file
|
||||
|
||||
! Create a boot quotation
|
||||
! Create a boot quotation for the target
|
||||
[
|
||||
! Rehash hashtables, since core/tools/image creates them
|
||||
! using the host image's hashing algorithms
|
||||
[
|
||||
! Rehash hashtables, since bootstrap.image creates them
|
||||
! using the host image's hashing algorithms
|
||||
[ hashtable? ] instances [ rehash ] each
|
||||
|
||||
[ [ hashtable? ] instances [ rehash ] each ] %
|
||||
|
||||
\ boot ,
|
||||
boot
|
||||
] %
|
||||
|
||||
"math.integers" require
|
||||
"math.floats" require
|
||||
|
|
|
@ -14,7 +14,7 @@ IN: bootstrap.stage2
|
|||
vm file-name windows? [ >lower ".exe" ?tail drop ] when
|
||||
".image" append "output-image" set-global
|
||||
|
||||
"math compiler tools help ui ui.tools io" "include" set-global
|
||||
"math tools compiler help ui ui.tools io" "include" set-global
|
||||
"" "exclude" set-global
|
||||
|
||||
parse-command-line
|
||||
|
@ -43,9 +43,6 @@ IN: bootstrap.stage2
|
|||
seq-diff
|
||||
[ "bootstrap." swap append require ] each
|
||||
|
||||
init-io
|
||||
init-stdio
|
||||
|
||||
run-bootstrap-init
|
||||
|
||||
"Compiling remaining words..." print
|
||||
|
|
|
@ -3,23 +3,14 @@ assocs words.private sequences ;
|
|||
IN: compiler
|
||||
|
||||
ARTICLE: "compiler-usage" "Calling the optimizing compiler"
|
||||
"The main entry point to the optimizing compiler is a single word taking a word as input:"
|
||||
"The main entry points to the optimizing compiler:"
|
||||
{ $subsection compile }
|
||||
{ $subsection recompile }
|
||||
{ $subsection recompile-all }
|
||||
"Removing a word's optimized definition:"
|
||||
{ $subsection decompile }
|
||||
"The optimizing compiler can also compile and call a single quotation:"
|
||||
{ $subsection compile-call }
|
||||
"Three utility words for bulk compilation:"
|
||||
{ $subsection compile-batch }
|
||||
{ $subsection compile-vocabs }
|
||||
"Bulk compilation saves compile warnings and errors in a global variable, instead of printing them as they arise:"
|
||||
{ $subsection compile-errors }
|
||||
"The warnings and errors can be viewed later:"
|
||||
{ $subsection :warnings }
|
||||
{ $subsection :errors }
|
||||
{ $subsection forget-errors } ;
|
||||
|
||||
ARTICLE: "recompile" "Automatic recompilation"
|
||||
"When a word is redefined, you can recompile all affected words automatically:"
|
||||
{ $subsection recompile } ;
|
||||
{ $subsection compile-call } ;
|
||||
|
||||
ARTICLE: "compiler" "Optimizing compiler"
|
||||
"Factor is a fully compiled language implementation with two distinct compilers:"
|
||||
|
@ -27,79 +18,31 @@ ARTICLE: "compiler" "Optimizing compiler"
|
|||
{ "The " { $emphasis "non-optimizing quotation compiler" } " compiles quotations to naive machine code very quickly. The non-optimizing quotation compiler is part of the VM." }
|
||||
{ "The " { $emphasis "optimizing word compiler" } " compiles whole words at a time while performing extensive data and control flow analysis. This provides greater performance for generated code, but incurs a much longer compile time. The optimizing compiler is written in Factor." }
|
||||
}
|
||||
"While the quotation compiler is transparent to the developer, the optimizing compiler is invoked explicitly. It differs in two important ways from the non-optimizing compiler:"
|
||||
{ $list
|
||||
{ "The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect; for otherwise, most of the system would be compiled with the non-optimizing compiler. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "." }
|
||||
{ "The optimizing compiler performs " { $emphasis "early binding" } "; if a compiled word " { $snippet "A" } " calls another compiled word " { $snippet "B" } " and " { $snippet "B" } " is subsequently redefined, the compiled definition of " { $snippet "A" } " will still refer to the earlier compiled definition of " { $snippet "B" } ", until " { $snippet "A" } " explicitly recompiled." }
|
||||
}
|
||||
"The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect; for otherwise, most of the system would be compiled with the non-optimizing compiler. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "."
|
||||
{ $subsection "compiler-usage" }
|
||||
{ $subsection "recompile" } ;
|
||||
{ $subsection "compiler-errors" } ;
|
||||
|
||||
ABOUT: "compiler"
|
||||
|
||||
HELP: compile-error
|
||||
{ $values { "word" word } { "error" "an error" } }
|
||||
{ $description "If inside a " { $link compile-batch } ", saves the error for future persual via " { $link :errors } " and " { $link :warnings } ", otherwise reports the error to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: begin-batch
|
||||
{ $values { "seq" "a sequence of words" } }
|
||||
{ $description "Begins batch compilation. Any compile errors reported until a call to " { $link end-batch } " are stored in the " { $link compile-errors } " global variable." }
|
||||
$low-level-note ;
|
||||
|
||||
HELP: compile-error.
|
||||
{ $values { "pair" "a " { $snippet "{ word error }" } " pair" } }
|
||||
{ $description "Prints a compiler error to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: (:errors)
|
||||
{ $values { "seq" "an alist" } }
|
||||
{ $description "Outputs all serious compiler errors from the most recent compile batch as a sequence of " { $snippet "{ word error }" } " pairs." } ;
|
||||
|
||||
HELP: :errors
|
||||
{ $description "Prints all serious compiler errors from the most recent compile batch to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: (:warnings)
|
||||
{ $values { "seq" "an alist" } }
|
||||
{ $description "Outputs all ignorable compiler warnings from the most recent compile batch as a sequence of " { $snippet "{ word error }" } " pairs." } ;
|
||||
|
||||
HELP: :warnings
|
||||
{ $description "Prints all ignorable compiler warnings from the most recent compile batch to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: end-batch
|
||||
{ $description "Ends batch compilation, printing a summary of the errors and warnings produced to the " { $link stdio } " stream." }
|
||||
$low-level-note ;
|
||||
|
||||
HELP: compile
|
||||
{ $values { "word" word } }
|
||||
{ $description "Compiles a word together with any uncompiled dependencies. Does nothing if the word is already compiled." } ;
|
||||
|
||||
HELP: compile-failed
|
||||
{ $values { "word" word } { "error" "an error" } }
|
||||
{ $description "Called when the optimizing compiler fails to compile a word. The word is removed from the set of words pending compilation, and it's un-optimized compiled definition will be used. The error is reported by calling " { $link compile-error } "." } ;
|
||||
|
||||
HELP: compile-batch
|
||||
{ $values { "seq" "a sequence of words" } }
|
||||
{ $description "Compiles a batch of words. Any compile errors are summarized at the end and can be viewed with " { $link :warnings } " and " { $link :errors } "." } ;
|
||||
{ $description "Compiles a set of words. Ignores words which are already compiled." } ;
|
||||
|
||||
{ :errors (:errors) :warnings (:warnings) } related-words
|
||||
|
||||
HELP: compile-vocabs
|
||||
{ $values { "seq" "a sequence of strings" } }
|
||||
{ $description "Compiles all words which have not been compiled yet from the given vocabularies." } ;
|
||||
HELP: recompile
|
||||
{ $values { "seq" "a sequence of words" } }
|
||||
{ $description "Compiles a set of words. Re-compiles words which are already compiled." } ;
|
||||
|
||||
HELP: compile-call
|
||||
{ $values { "quot" "a quotation" } }
|
||||
{ $description "Compiles and runs a quotation." }
|
||||
{ $errors "Throws an error if the stack effect of the quotation cannot be inferred." } ;
|
||||
|
||||
HELP: recompile
|
||||
{ $description "Recompiles words whose compiled definitions have become out of date as a result of dependent words being redefined." } ;
|
||||
|
||||
HELP: compile-all
|
||||
HELP: recompile-all
|
||||
{ $description "Recompiles all words." } ;
|
||||
|
||||
HELP: compile-begins
|
||||
HELP: decompile
|
||||
{ $values { "word" word } }
|
||||
{ $description "Prints a message stating the word is being compiled, unless we are inside a " { $link compile-batch } "." } ;
|
||||
{ $description "Removes a word's optimized definition. The word will be compiled with the non-optimizing compiler until recompiled with the optimizing compiler again." } ;
|
||||
|
||||
HELP: (compile)
|
||||
{ $values { "word" word } }
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
USING: kernel namespaces arrays sequences io inference.backend
|
||||
generator debugger math.parser prettyprint words words.private
|
||||
continuations vocabs assocs alien.compiler dlists optimizer
|
||||
definitions math compiler.errors ;
|
||||
definitions math compiler.errors threads ;
|
||||
IN: compiler
|
||||
|
||||
SYMBOL: compiler-hook
|
||||
|
||||
: compile-begins ( -- )
|
||||
compiler-hook get [ ] or call ;
|
||||
|
||||
: compiled-usage ( word -- seq )
|
||||
#! XXX
|
||||
usage [ word? ] subset ;
|
||||
|
@ -28,7 +23,7 @@ SYMBOL: compiler-hook
|
|||
"compiled-effect" set-word-prop ;
|
||||
|
||||
: (compile) ( word -- )
|
||||
compile-begins
|
||||
yield
|
||||
[
|
||||
dup word-dataflow optimize >r over dup r> generate
|
||||
] [
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
IN: compiler.errors
|
||||
USING: help.markup help.syntax vocabs.loader words io
|
||||
quotations ;
|
||||
|
||||
ARTICLE: "compiler-errors" "Compiler warnings and errors"
|
||||
"The compiler saves compile warnings and errors in a global variable:"
|
||||
{ $subsection compiler-errors }
|
||||
"The warnings and errors can be viewed later:"
|
||||
{ $subsection :warnings }
|
||||
{ $subsection :errors }
|
||||
"Normally, all warnings and errors are displayed at the end of a batch compilation, such as a call to " { $link require } " or " { $link refresh-all } ". This can be controlled with a combinator:"
|
||||
{ $link with-compiler-errors } ;
|
||||
|
||||
HELP: compiler-errors
|
||||
{ $var-description "Global variable holding an assoc mapping words to compiler errors. This variable is set by " { $link with-compiler-errors } "." } ;
|
||||
|
||||
HELP: compiler-error
|
||||
{ $values { "error" "an error" } { "word" word } }
|
||||
{ $description "If inside a " { $link with-compiler-errors } ", saves the error for future persual via " { $link :errors } " and " { $link :warnings } ", otherwise ignores the error." } ;
|
||||
|
||||
HELP: compiler-error.
|
||||
{ $values { "error" "an error" } { "word" word } }
|
||||
{ $description "Prints a compiler error to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: compiler-errors.
|
||||
{ $values { "errors" "an assoc mapping words to errors" } }
|
||||
{ $description "Prints a set of compiler errors to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: (:errors)
|
||||
{ $values { "seq" "an alist" } }
|
||||
{ $description "Outputs all serious compiler errors from the most recent compile." } ;
|
||||
|
||||
HELP: :errors
|
||||
{ $description "Prints all serious compiler errors from the most recent compile to the " { $link stdio } " stream." } ;
|
||||
|
||||
HELP: (:warnings)
|
||||
{ $values { "seq" "an alist" } }
|
||||
{ $description "Outputs all ignorable compiler warnings from the most recent compile." } ;
|
||||
|
||||
HELP: :warnings
|
||||
{ $description "Prints all ignorable compiler warnings from the most recent compile to the " { $link stdio } " stream." } ;
|
||||
|
||||
{ :errors (:errors) :warnings (:warnings) } related-words
|
||||
|
||||
HELP: with-compiler-errors
|
||||
{ $values { "quot" quotation } }
|
||||
{ $description "Calls the quotation and collects any compiler warnings and errors. Compiler warnings and errors are summarized at the end and can be viewed with " { $link :warnings } " and " { $link :errors } "." }
|
||||
{ $notes "Nested calls to " { $link with-compiler-errors } " are ignored, and only the outermost call collects warnings and errors." } ;
|
|
@ -6,7 +6,7 @@ kernel models namespaces parser quotations sequences ui.commands
|
|||
ui.gadgets ui.gadgets.editors ui.gadgets.labelled
|
||||
ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
|
||||
ui.gadgets.tracks ui.gestures ui.operations vocabs words
|
||||
prettyprint listener debugger threads compiler ;
|
||||
prettyprint listener debugger threads ;
|
||||
IN: ui.tools.listener
|
||||
|
||||
TUPLE: listener-gadget input output stack ;
|
||||
|
@ -129,7 +129,6 @@ M: stack-display tool-scroller
|
|||
dup [ ui-listener-hook ] curry listener-hook set
|
||||
dup [ ui-error-hook ] curry error-hook set
|
||||
[ ui-inspector-hook ] curry inspector-hook set
|
||||
[ yield ] compiler-hook set
|
||||
welcome.
|
||||
listener
|
||||
] with-stream* ;
|
||||
|
|
Loading…
Reference in New Issue