remove JVM compiler stuff from library
parent
8e51df2c81
commit
be291d09fb
|
@ -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]);
|
||||||
|
}
|
||||||
|
} //}}}
|
||||||
|
}
|
|
@ -31,13 +31,13 @@ USE: lists
|
||||||
USE: stack
|
USE: stack
|
||||||
|
|
||||||
: slip ( quot x -- x )
|
: slip ( quot x -- x )
|
||||||
>r call r> ; inline interpret-only
|
>r call r> ; inline
|
||||||
|
|
||||||
: 2slip ( quot x y -- x y )
|
: 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 )
|
: 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 )
|
: keep ( a quot -- a )
|
||||||
#! Execute the quotation with a on the stack, and restore a
|
#! Execute the quotation with a on the stack, and restore a
|
||||||
|
@ -80,14 +80,14 @@ USE: stack
|
||||||
] ifte
|
] ifte
|
||||||
] [
|
] [
|
||||||
2drop
|
2drop
|
||||||
] ifte ; interpret-only
|
] ifte ;
|
||||||
|
|
||||||
: ifte* ( cond true false -- )
|
: ifte* ( cond true false -- )
|
||||||
#! If the condition is not f, execute the 'true' quotation,
|
#! If the condition is not f, execute the 'true' quotation,
|
||||||
#! with the condition on the stack. Otherwise, pop the
|
#! with the condition on the stack. Otherwise, pop the
|
||||||
#! condition and execute the 'false' quotation.
|
#! condition and execute the 'false' quotation.
|
||||||
pick [ drop call ] [ nip nip call ] ifte ;
|
pick [ drop call ] [ nip nip call ] ifte ;
|
||||||
inline interpret-only
|
inline
|
||||||
|
|
||||||
: unless ( cond quot -- )
|
: unless ( cond quot -- )
|
||||||
#! Execute a quotation only when the condition is f. The
|
#! 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
|
#! In order to compile, the quotation must consume as many
|
||||||
#! values as it produces.
|
#! values as it produces.
|
||||||
[ ] swap ifte ; inline interpret-only
|
[ ] swap ifte ; inline
|
||||||
|
|
||||||
: unless* ( cond quot -- )
|
: unless* ( cond quot -- )
|
||||||
#! If cond is f, pop it off the stack and evaluate the
|
#! 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
|
#! In order to compile, the quotation must consume one less
|
||||||
#! value than it produces.
|
#! value than it produces.
|
||||||
over [ drop ] [ nip call ] ifte ; inline interpret-only
|
over [ drop ] [ nip call ] ifte ; inline
|
||||||
|
|
||||||
: when ( cond quot -- )
|
: when ( cond quot -- )
|
||||||
#! Execute a quotation only when the condition is not f. The
|
#! 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
|
#! In order to compile, the quotation must consume as many
|
||||||
#! values as it produces.
|
#! values as it produces.
|
||||||
[ ] ifte ; inline interpret-only
|
[ ] ifte ; inline
|
||||||
|
|
||||||
: when* ( cond quot -- )
|
: when* ( cond quot -- )
|
||||||
#! If the condition is true, it is left on the stack, and
|
#! 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
|
#! In order to compile, the quotation must consume one more
|
||||||
#! value than it produces.
|
#! value than it produces.
|
||||||
over [ call ] [ 2drop ] ifte ; inline interpret-only
|
over [ call ] [ 2drop ] ifte ; inline
|
||||||
|
|
||||||
: forever ( quot -- )
|
: forever ( quot -- )
|
||||||
#! The code is evaluated in an infinite loop. Typically, a
|
#! The code is evaluated in an infinite loop. Typically, a
|
||||||
#! continuation is used to escape the infinite loop.
|
#! continuation is used to escape the infinite loop.
|
||||||
#!
|
#!
|
||||||
#! This combinator will not compile.
|
#! This combinator will not compile.
|
||||||
dup slip forever ; interpret-only
|
dup slip forever ;
|
||||||
|
|
|
@ -86,7 +86,7 @@ USE: vectors
|
||||||
r> r> r> partition-iter
|
r> r> r> partition-iter
|
||||||
] [
|
] [
|
||||||
3drop
|
3drop
|
||||||
] ifte ; inline interpret-only
|
] ifte ; inline
|
||||||
|
|
||||||
: partition ( ref list combinator -- list1 list2 )
|
: partition ( ref list combinator -- list1 list2 )
|
||||||
#! Compare each element in a proper list against a
|
#! Compare each element in a proper list against a
|
||||||
|
@ -96,7 +96,7 @@ USE: vectors
|
||||||
#! The combinator must have stack effect:
|
#! The combinator must have stack effect:
|
||||||
#! ( ref element -- ? )
|
#! ( ref element -- ? )
|
||||||
swap >r >r >r [ ] [ ] r> r> r> partition-iter ;
|
swap >r >r >r [ ] [ ] r> r> r> partition-iter ;
|
||||||
inline interpret-only
|
inline
|
||||||
|
|
||||||
: sort ( list comparator -- sorted )
|
: sort ( list comparator -- sorted )
|
||||||
#! Sort the elements in a proper list using a comparator.
|
#! Sort the elements in a proper list using a comparator.
|
||||||
|
@ -113,7 +113,7 @@ USE: vectors
|
||||||
cons append
|
cons append
|
||||||
] [
|
] [
|
||||||
drop
|
drop
|
||||||
] ifte ; inline interpret-only
|
] ifte ; inline
|
||||||
|
|
||||||
: num-sort ( list -- sorted )
|
: num-sort ( list -- sorted )
|
||||||
#! Sorts the list into ascending numerical order.
|
#! Sorts the list into ascending numerical order.
|
||||||
|
@ -147,13 +147,13 @@ DEFER: tree-contains?
|
||||||
2dup contains? [ nip ] [ cons ] ifte ;
|
2dup contains? [ nip ] [ cons ] ifte ;
|
||||||
|
|
||||||
: (each) ( list quot -- list quot )
|
: (each) ( list quot -- list quot )
|
||||||
>r uncons r> tuck 2slip ; inline interpret-only
|
>r uncons r> tuck 2slip ; inline
|
||||||
|
|
||||||
: each ( list quot -- )
|
: each ( list quot -- )
|
||||||
#! Push each element of a proper list in turn, and apply a
|
#! Push each element of a proper list in turn, and apply a
|
||||||
#! quotation with effect ( X -- ) to each element.
|
#! quotation with effect ( X -- ) to each element.
|
||||||
over [ (each) each ] [ 2drop ] ifte ;
|
over [ (each) each ] [ 2drop ] ifte ;
|
||||||
inline interpret-only
|
inline
|
||||||
|
|
||||||
: reverse ( list -- list )
|
: reverse ( list -- list )
|
||||||
[ ] swap [ swons ] each ;
|
[ ] swap [ swons ] each ;
|
||||||
|
@ -163,7 +163,7 @@ DEFER: tree-contains?
|
||||||
#! return values of applying a quotation with effect
|
#! return values of applying a quotation with effect
|
||||||
#! ( X -- Y ) to each element into a new list.
|
#! ( X -- Y ) to each element into a new list.
|
||||||
over [ (each) rot >r map r> swons ] [ drop ] ifte ;
|
over [ (each) rot >r map r> swons ] [ drop ] ifte ;
|
||||||
inline interpret-only
|
inline
|
||||||
|
|
||||||
: subset ( list quot -- list )
|
: subset ( list quot -- list )
|
||||||
#! Applies a quotation with effect ( X -- ? ) to each
|
#! Applies a quotation with effect ( X -- ? ) to each
|
||||||
|
@ -175,7 +175,7 @@ DEFER: tree-contains?
|
||||||
rot >r subset r> [ r> swons ] [ r> drop ] ifte
|
rot >r subset r> [ r> swons ] [ r> drop ] ifte
|
||||||
] [
|
] [
|
||||||
drop
|
drop
|
||||||
] ifte ; inline interpret-only
|
] ifte ; inline
|
||||||
|
|
||||||
: remove ( obj list -- list )
|
: remove ( obj list -- list )
|
||||||
#! Remove all occurrences of the object from the list.
|
#! Remove all occurrences of the object from the list.
|
||||||
|
|
|
@ -36,14 +36,14 @@ USE: stack
|
||||||
#! In order to compile, the code must produce as many values
|
#! In order to compile, the code must produce as many values
|
||||||
#! as it consumes.
|
#! as it consumes.
|
||||||
tuck >r dup 0 <= [ r> 3drop ] [ pred slip r> times ] ifte ;
|
tuck >r dup 0 <= [ r> 3drop ] [ pred slip r> times ] ifte ;
|
||||||
inline interpret-only
|
inline
|
||||||
|
|
||||||
: (times) ( limit n quot -- )
|
: (times) ( limit n quot -- )
|
||||||
pick pick <= [
|
pick pick <= [
|
||||||
3drop
|
3drop
|
||||||
] [
|
] [
|
||||||
rot pick succ pick 3slip (times)
|
rot pick succ pick 3slip (times)
|
||||||
] ifte ; inline interpret-only
|
] ifte ; inline
|
||||||
|
|
||||||
: times* ( n quot -- )
|
: times* ( n quot -- )
|
||||||
#! Evaluate a quotation n times, pushing the index at each
|
#! 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
|
#! In order to compile, the code must consume one more value
|
||||||
#! than it produces.
|
#! than it produces.
|
||||||
0 swap (times) ; inline interpret-only
|
0 swap (times) ; inline
|
||||||
|
|
||||||
: 2times-succ ( #{ a b } #{ c d } -- z )
|
: 2times-succ ( #{ a b } #{ c d } -- z )
|
||||||
#! Lexicographically add #{ 0 1 } to a complex number.
|
#! Lexicographically add #{ 0 1 } to a complex number.
|
||||||
|
|
|
@ -96,7 +96,7 @@ USE: stack
|
||||||
"factor.FactorLib" "branch3" jinvoke-static ;
|
"factor.FactorLib" "branch3" jinvoke-static ;
|
||||||
|
|
||||||
: compare ( x y [ if x < y ] [ if x = y ] [ if x > y ] -- )
|
: compare ( x y [ if x < y ] [ if x = y ] [ if x > y ] -- )
|
||||||
>=< call ; inline interpret-only
|
>=< call ; inline
|
||||||
|
|
||||||
: bitand ( x y -- x&y )
|
: bitand ( x y -- x&y )
|
||||||
#! Bitwise and.
|
#! Bitwise and.
|
||||||
|
|
|
@ -87,7 +87,6 @@ USE: parser
|
||||||
"/library/tools/listener.factor" run-resource ! listener
|
"/library/tools/listener.factor" run-resource ! listener
|
||||||
"/library/tools/inspector.factor" run-resource ! inspector
|
"/library/tools/inspector.factor" run-resource ! inspector
|
||||||
"/library/tools/word-tools.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/platform/jvm/debugger.factor" run-resource ! debugger
|
||||||
"/library/tools/debugger.factor" run-resource ! debugger
|
"/library/tools/debugger.factor" run-resource ! debugger
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,9 @@ USE: parser
|
||||||
"/library/tools/listener.factor" run-resource ! listener
|
"/library/tools/listener.factor" run-resource ! listener
|
||||||
"/library/tools/inspector.factor" run-resource ! inspector
|
"/library/tools/inspector.factor" run-resource ! inspector
|
||||||
"/library/tools/word-tools.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/platform/jvm/debugger.factor" run-resource ! debugger
|
||||||
"/library/tools/debugger.factor" run-resource ! debugger
|
"/library/tools/debugger.factor" run-resource ! debugger
|
||||||
"/library/test/test.factor" run-resource ! test
|
"/library/test/test.factor" run-resource ! test
|
||||||
"/library/platform/jvm/test.factor" run-resource ! test
|
|
||||||
"/library/ansi.factor" run-resource ! ansi
|
"/library/ansi.factor" run-resource ! ansi
|
||||||
"/library/tools/telnetd.factor" run-resource ! telnetd
|
"/library/tools/telnetd.factor" run-resource ! telnetd
|
||||||
"/library/tools/inferior.factor" run-resource ! inferior
|
"/library/tools/inferior.factor" run-resource ! inferior
|
||||||
|
|
|
@ -40,4 +40,4 @@ USE: stack
|
||||||
unit
|
unit
|
||||||
restack
|
restack
|
||||||
call
|
call
|
||||||
unstack ; interpret-only
|
unstack ;
|
||||||
|
|
|
@ -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 <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 ;
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
IN: init
|
IN: init
|
||||||
USE: combinators
|
USE: combinators
|
||||||
USE: compiler
|
|
||||||
USE: continuations
|
USE: continuations
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
|
@ -64,7 +63,6 @@ USE: words
|
||||||
! Some flags are *on* by default, unless user specifies
|
! Some flags are *on* by default, unless user specifies
|
||||||
! -no-<flag> CLI switch
|
! -no-<flag> CLI switch
|
||||||
t "user-init" set
|
t "user-init" set
|
||||||
t "compile" set
|
|
||||||
|
|
||||||
init-stdio
|
init-stdio
|
||||||
init-environment
|
init-environment
|
||||||
|
@ -72,10 +70,6 @@ USE: words
|
||||||
"args" get parse-command-line
|
"args" get parse-command-line
|
||||||
run-user-init
|
run-user-init
|
||||||
|
|
||||||
"compile" get [
|
|
||||||
compile-all
|
|
||||||
] when
|
|
||||||
|
|
||||||
t "startup-done" set
|
t "startup-done" set
|
||||||
|
|
||||||
"interactive" get [ init-listener 1 exit* ] when ;
|
"interactive" get [ init-listener 1 exit* ] when ;
|
||||||
|
|
|
@ -33,14 +33,7 @@ IN: words
|
||||||
|
|
||||||
IN: kernel
|
IN: kernel
|
||||||
|
|
||||||
: inline ( -- )
|
: 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 ;
|
|
||||||
|
|
||||||
: hashcode ( obj -- hashcode )
|
: hashcode ( obj -- hashcode )
|
||||||
#! If two objects are =, they must have equal hashcodes.
|
#! If two objects are =, they must have equal hashcodes.
|
||||||
|
@ -73,7 +66,6 @@ IN: kernel
|
||||||
: toplevel ( -- )
|
: toplevel ( -- )
|
||||||
interpreter
|
interpreter
|
||||||
[ ] "factor.FactorInterpreter" "topLevel" jinvoke ;
|
[ ] "factor.FactorInterpreter" "topLevel" jinvoke ;
|
||||||
interpret-only
|
|
||||||
|
|
||||||
: exit* ( code -- )
|
: exit* ( code -- )
|
||||||
[ "int" ] "java.lang.System" "exit" jinvoke-static ;
|
[ "int" ] "java.lang.System" "exit" jinvoke-static ;
|
||||||
|
|
|
@ -34,13 +34,13 @@ USE: vectors
|
||||||
interpreter "factor.FactorInterpreter" "datastack" jvar-get ;
|
interpreter "factor.FactorInterpreter" "datastack" jvar-get ;
|
||||||
|
|
||||||
: datastack ( -- datastack )
|
: datastack ( -- datastack )
|
||||||
datastack* clone ; interpret-only
|
datastack* clone ;
|
||||||
|
|
||||||
: set-datastack* ( datastack -- ... )
|
: set-datastack* ( datastack -- ... )
|
||||||
interpreter "factor.FactorInterpreter" "datastack" jvar-set ;
|
interpreter "factor.FactorInterpreter" "datastack" jvar-set ;
|
||||||
|
|
||||||
: set-datastack ( datastack -- ... )
|
: set-datastack ( datastack -- ... )
|
||||||
clone set-datastack* ; interpret-only
|
clone set-datastack* ;
|
||||||
|
|
||||||
: callstack* ( -- callstack )
|
: callstack* ( -- callstack )
|
||||||
interpreter "factor.FactorInterpreter" "callstack" jvar-get ;
|
interpreter "factor.FactorInterpreter" "callstack" jvar-get ;
|
||||||
|
@ -57,13 +57,13 @@ USE: vectors
|
||||||
! word.
|
! word.
|
||||||
[ clone ] call
|
[ clone ] call
|
||||||
dup vector-pop drop
|
dup vector-pop drop
|
||||||
dup vector-pop drop ; interpret-only
|
dup vector-pop drop ;
|
||||||
|
|
||||||
: set-callstack* ( callstack -- ... )
|
: set-callstack* ( callstack -- ... )
|
||||||
interpreter "factor.FactorInterpreter" "callstack" jvar-set ;
|
interpreter "factor.FactorInterpreter" "callstack" jvar-set ;
|
||||||
|
|
||||||
: set-callstack ( callstack -- ... )
|
: set-callstack ( callstack -- ... )
|
||||||
clone set-callstack* ; interpret-only
|
clone set-callstack* ;
|
||||||
|
|
||||||
: clear ( -- )
|
: clear ( -- )
|
||||||
#! Clear the datastack. For interactive use only; invoking
|
#! Clear the datastack. For interactive use only; invoking
|
||||||
|
|
|
@ -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 ;
|
|
|
@ -54,7 +54,7 @@ USE: stack
|
||||||
[ ] "factor.FactorInterpreter" jnew ;
|
[ ] "factor.FactorInterpreter" jnew ;
|
||||||
|
|
||||||
: fork* ( current new -- thread )
|
: fork* ( current new -- thread )
|
||||||
dup <thread> >r clone-interpreter r> ; interpret-only
|
dup <thread> >r clone-interpreter r> ;
|
||||||
|
|
||||||
: fork ( -- ? )
|
: fork ( -- ? )
|
||||||
#! Spawn a new thread. In the original thread, push f.
|
#! Spawn a new thread. In the original thread, push f.
|
||||||
|
@ -63,7 +63,7 @@ USE: stack
|
||||||
drop t
|
drop t
|
||||||
] [
|
] [
|
||||||
start-thread f
|
start-thread f
|
||||||
] ifte ; interpret-only
|
] ifte ;
|
||||||
|
|
||||||
: in-thread ( quot -- )
|
: in-thread ( quot -- )
|
||||||
#! Execute a quotation in a new thread.
|
#! Execute a quotation in a new thread.
|
||||||
|
@ -71,4 +71,4 @@ USE: stack
|
||||||
[ call ] [ default-error-handler toplevel ] catch
|
[ call ] [ default-error-handler toplevel ] catch
|
||||||
] [
|
] [
|
||||||
drop
|
drop
|
||||||
] ifte ; interpret-only
|
] ifte ;
|
||||||
|
|
|
@ -115,4 +115,3 @@ IN: kernel
|
||||||
|
|
||||||
! No compiler...
|
! No compiler...
|
||||||
: inline ;
|
: inline ;
|
||||||
: interpret-only ;
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
IN: test
|
IN: test
|
||||||
USE: combinators
|
USE: combinators
|
||||||
USE: compiler
|
|
||||||
USE: errors
|
USE: errors
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
|
|
Loading…
Reference in New Issue