diff --git a/factor/jedit/FactorOptionPane.java b/factor/jedit/FactorOptionPane.java new file mode 100644 index 0000000000..7f1b837de3 --- /dev/null +++ b/factor/jedit/FactorOptionPane.java @@ -0,0 +1,126 @@ +/* :folding=explicit:collapseFolds=1: */ + +/* + * $Id$ + * + * Copyright (C) 2004 Slava Pestov. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package factor.jedit; + +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; +import org.gjt.sp.jedit.browser.*; +import org.gjt.sp.jedit.gui.RolloverButton; +import org.gjt.sp.jedit.*; + +public class FactorOptionPane extends AbstractOptionPane +{ + //{{{ FactorOptionPane constructor + public FactorOptionPane() + { + super("factor"); + } //}}} + + //{{{ _init() method + protected void _init() + { + addComponent(jEdit.getProperty("options.factor.program"), + createProgramField(jEdit.getProperty("factor.external.program"))); + addComponent(jEdit.getProperty("options.factor.image"), + createImageField(jEdit.getProperty("factor.external.image"))); + } //}}} + + //{{{ _save() method + protected void _save() + { + jEdit.setProperty("factor.external.program",program.getText()); + jEdit.setProperty("factor.external.image",image.getText()); + } //}}} + + //{{{ Private members + private JTextField program; + private JTextField image; + + //{{{ createProgramField() metnod + private JComponent createProgramField(String text) + { + program = new JTextField(text); + return createFieldAndButton(program); + } //}}} + + //{{{ createImageField() metnod + private JComponent createImageField(String text) + { + image = new JTextField(text); + return createFieldAndButton(image); + } //}}} + + //{{{ createFieldAndButton() metnod + private JComponent createFieldAndButton(JTextField field) + { + Box h = new Box(BoxLayout.X_AXIS); + Box v = new Box(BoxLayout.Y_AXIS); + v.add(Box.createGlue()); + v.add(field); + Dimension size = field.getPreferredSize(); + size.width = Integer.MAX_VALUE; + field.setMaximumSize(size); + v.add(Box.createGlue()); + h.add(v); + h.add(Box.createHorizontalStrut(12)); + + JButton button = new RolloverButton( + GUIUtilities.loadIcon("Open.png")); + button.setToolTipText(jEdit.getProperty("options.factor.choose")); + button.addActionListener(new ActionHandler(field)); + + h.add(button); + return h; + } //}}} + + //{{{ ActionHandler class + class ActionHandler implements ActionListener + { + private JTextField field; + + ActionHandler(JTextField field) + { + this.field = field; + } + + public void actionPerformed(ActionEvent evt) + { + String[] paths = GUIUtilities.showVFSFileDialog( + GUIUtilities.getView(FactorOptionPane.this), + field.getText(), + VFSBrowser.OPEN_DIALOG, + false); + if(paths == null) + return; + field.setText(paths[0]); + } + } //}}} +} diff --git a/library/combinators.factor b/library/combinators.factor index 8c06f0bdfd..c0fe2ac852 100644 --- a/library/combinators.factor +++ b/library/combinators.factor @@ -31,13 +31,13 @@ USE: lists USE: stack : slip ( quot x -- x ) - >r call r> ; inline interpret-only + >r call r> ; inline : 2slip ( quot x y -- x y ) - >r >r call r> r> ; inline interpret-only + >r >r call r> r> ; inline : 3slip ( quot x y z -- x y z ) - >r >r >r call r> r> r> ; inline interpret-only + >r >r >r call r> r> r> ; inline : keep ( a quot -- a ) #! Execute the quotation with a on the stack, and restore a @@ -80,14 +80,14 @@ USE: stack ] ifte ] [ 2drop - ] ifte ; interpret-only + ] ifte ; : ifte* ( cond true false -- ) #! If the condition is not f, execute the 'true' quotation, #! with the condition on the stack. Otherwise, pop the #! condition and execute the 'false' quotation. pick [ drop call ] [ nip nip call ] ifte ; - inline interpret-only + inline : unless ( cond quot -- ) #! Execute a quotation only when the condition is f. The @@ -95,7 +95,7 @@ USE: stack #! #! In order to compile, the quotation must consume as many #! values as it produces. - [ ] swap ifte ; inline interpret-only + [ ] swap ifte ; inline : unless* ( cond quot -- ) #! If cond is f, pop it off the stack and evaluate the @@ -103,7 +103,7 @@ USE: stack #! #! In order to compile, the quotation must consume one less #! value than it produces. - over [ drop ] [ nip call ] ifte ; inline interpret-only + over [ drop ] [ nip call ] ifte ; inline : when ( cond quot -- ) #! Execute a quotation only when the condition is not f. The @@ -111,7 +111,7 @@ USE: stack #! #! In order to compile, the quotation must consume as many #! values as it produces. - [ ] ifte ; inline interpret-only + [ ] ifte ; inline : when* ( cond quot -- ) #! If the condition is true, it is left on the stack, and @@ -120,11 +120,11 @@ USE: stack #! #! In order to compile, the quotation must consume one more #! value than it produces. - over [ call ] [ 2drop ] ifte ; inline interpret-only + over [ call ] [ 2drop ] ifte ; inline : forever ( quot -- ) #! The code is evaluated in an infinite loop. Typically, a #! continuation is used to escape the infinite loop. #! #! This combinator will not compile. - dup slip forever ; interpret-only + dup slip forever ; diff --git a/library/lists.factor b/library/lists.factor index 747d3a7c7c..f75f1150a5 100644 --- a/library/lists.factor +++ b/library/lists.factor @@ -86,7 +86,7 @@ USE: vectors r> r> r> partition-iter ] [ 3drop - ] ifte ; inline interpret-only + ] ifte ; inline : partition ( ref list combinator -- list1 list2 ) #! Compare each element in a proper list against a @@ -96,7 +96,7 @@ USE: vectors #! The combinator must have stack effect: #! ( ref element -- ? ) swap >r >r >r [ ] [ ] r> r> r> partition-iter ; - inline interpret-only + inline : sort ( list comparator -- sorted ) #! Sort the elements in a proper list using a comparator. @@ -113,7 +113,7 @@ USE: vectors cons append ] [ drop - ] ifte ; inline interpret-only + ] ifte ; inline : num-sort ( list -- sorted ) #! Sorts the list into ascending numerical order. @@ -147,13 +147,13 @@ DEFER: tree-contains? 2dup contains? [ nip ] [ cons ] ifte ; : (each) ( list quot -- list quot ) - >r uncons r> tuck 2slip ; inline interpret-only + >r uncons r> tuck 2slip ; inline : each ( list quot -- ) #! Push each element of a proper list in turn, and apply a #! quotation with effect ( X -- ) to each element. over [ (each) each ] [ 2drop ] ifte ; - inline interpret-only + inline : reverse ( list -- list ) [ ] swap [ swons ] each ; @@ -163,7 +163,7 @@ DEFER: tree-contains? #! return values of applying a quotation with effect #! ( X -- Y ) to each element into a new list. over [ (each) rot >r map r> swons ] [ drop ] ifte ; - inline interpret-only + inline : subset ( list quot -- list ) #! Applies a quotation with effect ( X -- ? ) to each @@ -175,7 +175,7 @@ DEFER: tree-contains? rot >r subset r> [ r> swons ] [ r> drop ] ifte ] [ drop - ] ifte ; inline interpret-only + ] ifte ; inline : remove ( obj list -- list ) #! Remove all occurrences of the object from the list. diff --git a/library/math/math-combinators.factor b/library/math/math-combinators.factor index d1ee99fbe1..367e1dba33 100644 --- a/library/math/math-combinators.factor +++ b/library/math/math-combinators.factor @@ -36,14 +36,14 @@ USE: stack #! In order to compile, the code must produce as many values #! as it consumes. tuck >r dup 0 <= [ r> 3drop ] [ pred slip r> times ] ifte ; - inline interpret-only + inline : (times) ( limit n quot -- ) pick pick <= [ 3drop ] [ rot pick succ pick 3slip (times) - ] ifte ; inline interpret-only + ] ifte ; inline : times* ( n quot -- ) #! Evaluate a quotation n times, pushing the index at each @@ -51,7 +51,7 @@ USE: stack #! #! In order to compile, the code must consume one more value #! than it produces. - 0 swap (times) ; inline interpret-only + 0 swap (times) ; inline : 2times-succ ( #{ a b } #{ c d } -- z ) #! Lexicographically add #{ 0 1 } to a complex number. diff --git a/library/platform/jvm/arithmetic.factor b/library/platform/jvm/arithmetic.factor index 55130dc862..a6ed626879 100644 --- a/library/platform/jvm/arithmetic.factor +++ b/library/platform/jvm/arithmetic.factor @@ -96,7 +96,7 @@ USE: stack "factor.FactorLib" "branch3" jinvoke-static ; : compare ( x y [ if x < y ] [ if x = y ] [ if x > y ] -- ) - >=< call ; inline interpret-only + >=< call ; inline : bitand ( x y -- x&y ) #! Bitwise and. diff --git a/library/platform/jvm/boot-mini.factor b/library/platform/jvm/boot-mini.factor index 8949a0e33e..56a6d5790c 100644 --- a/library/platform/jvm/boot-mini.factor +++ b/library/platform/jvm/boot-mini.factor @@ -87,7 +87,6 @@ USE: parser "/library/tools/listener.factor" run-resource ! listener "/library/tools/inspector.factor" run-resource ! inspector "/library/tools/word-tools.factor" run-resource ! inspector -"/library/platform/jvm/compiler.factor" run-resource ! compiler "/library/platform/jvm/debugger.factor" run-resource ! debugger "/library/tools/debugger.factor" run-resource ! debugger diff --git a/library/platform/jvm/boot-sumo.factor b/library/platform/jvm/boot-sumo.factor index 5e2e9f682a..cff250600f 100644 --- a/library/platform/jvm/boot-sumo.factor +++ b/library/platform/jvm/boot-sumo.factor @@ -93,11 +93,9 @@ USE: parser "/library/tools/listener.factor" run-resource ! listener "/library/tools/inspector.factor" run-resource ! inspector "/library/tools/word-tools.factor" run-resource ! inspector -"/library/platform/jvm/compiler.factor" run-resource ! compiler "/library/platform/jvm/debugger.factor" run-resource ! debugger "/library/tools/debugger.factor" run-resource ! debugger "/library/test/test.factor" run-resource ! test -"/library/platform/jvm/test.factor" run-resource ! test "/library/ansi.factor" run-resource ! ansi "/library/tools/telnetd.factor" run-resource ! telnetd "/library/tools/inferior.factor" run-resource ! inferior diff --git a/library/platform/jvm/combinators.factor b/library/platform/jvm/combinators.factor index b2a13fc635..1846d0a4e1 100644 --- a/library/platform/jvm/combinators.factor +++ b/library/platform/jvm/combinators.factor @@ -40,4 +40,4 @@ USE: stack unit restack call - unstack ; interpret-only + unstack ; diff --git a/library/platform/jvm/compiler.factor b/library/platform/jvm/compiler.factor deleted file mode 100644 index c723bfe6ea..0000000000 --- a/library/platform/jvm/compiler.factor +++ /dev/null @@ -1,105 +0,0 @@ -! :folding=indent:collapseFolds=1: - -! $Id$ -! -! Copyright (C) 2003, 2004 Slava Pestov. -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, -! this list of conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, -! this list of conditions and the following disclaimer in the documentation -! and/or other materials provided with the distribution. -! -! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -IN: compiler -USE: combinators -USE: lists -USE: namespaces -USE: stack -USE: stdio -USE: words - -: class-name ( class -- name ) - [ ] "java.lang.Class" "getName" jinvoke ; - -: compile* ( word -- ) - interpreter swap - [ "factor.FactorInterpreter" ] "factor.FactorWord" "compile" - jinvoke ; - -: compile ( word -- ) - #! Compile a word. - intern dup worddef compiled? [ - drop - ] [ - compile* - ] ifte ; - -: compile-all ( -- ) - #! Compile all words. - vocabs [ words [ compile ] each ] each ; - -: compiled>compound ( word -- def ) - #! Convert a compiled word definition into the compound - #! definition which compiles to it. - dup word-parameter ; - -: decompile ( word -- ) - #! Decompiles a word; from now on, it will be interpreted - #! again. - intern dup worddef compiled? [ - dup compiled>compound redefine - ] [ - drop - ] ifte ; - -: recompile ( word -- ) - #! If a word is not compiled, behave like compile; otherwise - #! decompile the word and compile it again. - dup decompile compile ; - -: recompile-all ( -- ) - #! Recompile all words in the dictionary. - vocabs [ words [ compile ] each ] each ; - -: effect ( word -- effect ) - #! Push stack effect of a word. - interpreter swap worddef - [ "factor.FactorInterpreter" ] "factor.FactorWordDefinition" - "getStackEffect" jinvoke ; - -: effect>list ( effect -- list ) - [ "inD" "outD" "inR" "outR" ] - [ dupd "factor.compiler.StackEffect" swap jvar-get ] - map nip ; - -: effect>typelist ( effect -- list ) - [ "inDtypes" "outDtypes" "inRtypes" "outRtypes" ] - [ - dupd "factor.compiler.StackEffect" swap jvar-get - array>list [ class-name ] map - ] map nip ; - -: balance ( code -- effect ) - #! Push stack effect of a quotation. - no-name effect ; - -: balance>list ( quotation -- list ) - balance effect>list ; - -: balance>typelist ( quotation -- list ) - balance effect>typelist ; diff --git a/library/platform/jvm/init.factor b/library/platform/jvm/init.factor index 4bf3fb8d9b..f04dd0388e 100644 --- a/library/platform/jvm/init.factor +++ b/library/platform/jvm/init.factor @@ -27,7 +27,6 @@ IN: init USE: combinators -USE: compiler USE: continuations USE: kernel USE: lists @@ -64,7 +63,6 @@ USE: words ! Some flags are *on* by default, unless user specifies ! -no- CLI switch t "user-init" set - t "compile" set init-stdio init-environment @@ -72,10 +70,6 @@ USE: words "args" get parse-command-line run-user-init - "compile" get [ - compile-all - ] when - t "startup-done" set "interactive" get [ init-listener 1 exit* ] when ; diff --git a/library/platform/jvm/kernel.factor b/library/platform/jvm/kernel.factor index 9d8ce95af0..213308b644 100644 --- a/library/platform/jvm/kernel.factor +++ b/library/platform/jvm/kernel.factor @@ -33,14 +33,7 @@ IN: words IN: kernel -: inline ( -- ) - #! Marks the most recently defined word to be inlined. - t word "factor.FactorWord" "inline" jvar-set ; - -: interpret-only ( -- ) - #! Marks the most recently defined word as an interpret-only word; - #! attempting to compile it will raise an error. - t word "factor.FactorWord" "interpretOnly" jvar-set ; +: inline ; : hashcode ( obj -- hashcode ) #! If two objects are =, they must have equal hashcodes. @@ -73,7 +66,6 @@ IN: kernel : toplevel ( -- ) interpreter [ ] "factor.FactorInterpreter" "topLevel" jinvoke ; - interpret-only : exit* ( code -- ) [ "int" ] "java.lang.System" "exit" jinvoke-static ; diff --git a/library/platform/jvm/stack2.factor b/library/platform/jvm/stack2.factor index c148d66687..f19a8a6cfe 100644 --- a/library/platform/jvm/stack2.factor +++ b/library/platform/jvm/stack2.factor @@ -34,13 +34,13 @@ USE: vectors interpreter "factor.FactorInterpreter" "datastack" jvar-get ; : datastack ( -- datastack ) - datastack* clone ; interpret-only + datastack* clone ; : set-datastack* ( datastack -- ... ) interpreter "factor.FactorInterpreter" "datastack" jvar-set ; : set-datastack ( datastack -- ... ) - clone set-datastack* ; interpret-only + clone set-datastack* ; : callstack* ( -- callstack ) interpreter "factor.FactorInterpreter" "callstack" jvar-get ; @@ -57,13 +57,13 @@ USE: vectors ! word. [ clone ] call dup vector-pop drop - dup vector-pop drop ; interpret-only + dup vector-pop drop ; : set-callstack* ( callstack -- ... ) interpreter "factor.FactorInterpreter" "callstack" jvar-set ; : set-callstack ( callstack -- ... ) - clone set-callstack* ; interpret-only + clone set-callstack* ; : clear ( -- ) #! Clear the datastack. For interactive use only; invoking diff --git a/library/platform/jvm/test.factor b/library/platform/jvm/test.factor deleted file mode 100644 index 4302ab67cd..0000000000 --- a/library/platform/jvm/test.factor +++ /dev/null @@ -1,17 +0,0 @@ -IN: test -USE: combinators -USE: compiler -USE: namespaces -USE: stdio -USE: stack -USE: test -USE: words - -: must-compile ( word -- ) - "compile" get [ - "Checking if " write dup write " was compiled" print - dup compile - worddef compiled? assert - ] [ - drop - ] ifte ; diff --git a/library/platform/jvm/threads.factor b/library/platform/jvm/threads.factor index 70a3be6f17..119aca2bdf 100644 --- a/library/platform/jvm/threads.factor +++ b/library/platform/jvm/threads.factor @@ -54,7 +54,7 @@ USE: stack [ ] "factor.FactorInterpreter" jnew ; : fork* ( current new -- thread ) - dup >r clone-interpreter r> ; interpret-only + dup >r clone-interpreter r> ; : fork ( -- ? ) #! Spawn a new thread. In the original thread, push f. @@ -63,7 +63,7 @@ USE: stack drop t ] [ start-thread f - ] ifte ; interpret-only + ] ifte ; : in-thread ( quot -- ) #! Execute a quotation in a new thread. @@ -71,4 +71,4 @@ USE: stack [ call ] [ default-error-handler toplevel ] catch ] [ drop - ] ifte ; interpret-only + ] ifte ; diff --git a/library/platform/native/kernel.factor b/library/platform/native/kernel.factor index 06aaf46dee..2b631604f2 100644 --- a/library/platform/native/kernel.factor +++ b/library/platform/native/kernel.factor @@ -115,4 +115,3 @@ IN: kernel ! No compiler... : inline ; -: interpret-only ; diff --git a/library/test/test.factor b/library/test/test.factor index deb91a7940..741f62a5e4 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -4,7 +4,6 @@ IN: test USE: combinators -USE: compiler USE: errors USE: kernel USE: lists