--- /dev/null
+/* :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]);
+ }
+ } //}}}
+}
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
] 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
#!
#! 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
#!
#! 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
#!
#! 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
#!
#! 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 ;
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
#! 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.
cons append
] [
drop
- ] ifte ; inline interpret-only
+ ] ifte ; inline
: num-sort ( list -- sorted )
#! Sorts the list into ascending numerical order.
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 ;
#! 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
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.
#! 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
#!
#! 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.
"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.
"/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/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
unit
restack
call
- unstack ; interpret-only
+ unstack ;
+++ /dev/null
-! :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 <compound> ;
-
-: 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 ;
IN: init
USE: combinators
-USE: compiler
USE: continuations
USE: kernel
USE: lists
! Some flags are *on* by default, unless user specifies
! -no-<flag> CLI switch
t "user-init" set
- t "compile" set
init-stdio
init-environment
"args" get parse-command-line
run-user-init
- "compile" get [
- compile-all
- ] when
-
t "startup-done" set
"interactive" get [ init-listener 1 exit* ] when ;
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.
: toplevel ( -- )
interpreter
[ ] "factor.FactorInterpreter" "topLevel" jinvoke ;
- interpret-only
: exit* ( code -- )
[ "int" ] "java.lang.System" "exit" jinvoke-static ;
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 ;
! 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
+++ /dev/null
-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 ;
[ ] "factor.FactorInterpreter" jnew ;
: fork* ( current new -- thread )
- dup <thread> >r clone-interpreter r> ; interpret-only
+ dup <thread> >r clone-interpreter r> ;
: fork ( -- ? )
#! Spawn a new thread. In the original thread, push f.
drop t
] [
start-thread f
- ] ifte ; interpret-only
+ ] ifte ;
: in-thread ( quot -- )
#! Execute a quotation in a new thread.
[ call ] [ default-error-handler toplevel ] catch
] [
drop
- ] ifte ; interpret-only
+ ] ifte ;
! No compiler...
: inline ;
-: interpret-only ;
IN: test
USE: combinators
-USE: compiler
USE: errors
USE: kernel
USE: lists