minor improvements to the plugin

cvs
Slava Pestov 2005-06-08 22:11:53 +00:00
parent 01e7a2a820
commit d66e281af7
10 changed files with 115 additions and 71 deletions

View File

@ -39,6 +39,11 @@ HTTP server now supports virtual hosting.
You can now set timeouts for I/O operations with the set-timeout generic You can now set timeouts for I/O operations with the set-timeout generic
word. The HTTP server sets a timeout of 60 seconds for client requests. word. The HTTP server sets a timeout of 60 seconds for client requests.
The Factor plugin now supports connecting to Factor instances on
arbitrary host and port names. This allows interactive development on
one machine while testing on another. A new command was added to
evaluate the word definition at the caret in the listener.
Factor 0.74: Factor 0.74:
------------ ------------

View File

@ -23,6 +23,11 @@
FactorPlugin.evalInListener(view,sel); FactorPlugin.evalInListener(view,sel);
</CODE> </CODE>
</ACTION> </ACTION>
<ACTION NAME="factor-eval-word-def">
<CODE>
FactorPlugin.evalWordDef(view);
</CODE>
</ACTION>
<ACTION NAME="factor-run-file"> <ACTION NAME="factor-run-file">
<CODE> <CODE>
buffer.save(view,null); buffer.save(view,null);

View File

@ -38,9 +38,25 @@ public class FactorParsedData extends SideKickParsedData
public String in; public String in;
public Cons use; public Cons use;
FactorParsedData(FactorSideKickParser parser, String fileName) public FactorParsedData(FactorSideKickParser parser, String fileName)
{ {
super(fileName); super(fileName);
this.parser = parser; this.parser = parser;
} }
public String getVocabularyDeclarations()
{
StringBuffer buf = new StringBuffer("IN: ");
buf.append(in);
buf.append("\nUSING: ");
Cons u = use;
while(u != null)
{
buf.append(" ");
buf.append(u.car);
u = u.next();
}
buf.append(" ;");
return buf.toString();
}
} }

View File

@ -123,9 +123,9 @@ public class FactorPlugin extends EditPlugin
argsArray, null, new File(MiscUtilities argsArray, null, new File(MiscUtilities
.getParentOfPath(imagePath))); .getParentOfPath(imagePath)));
process.getOutputStream().close(); /* process.getOutputStream().close();
process.getInputStream().close(); process.getInputStream().close();
process.getErrorStream().close(); process.getErrorStream().close(); */
} }
catch(Exception e) catch(Exception e)
{ {
@ -691,4 +691,32 @@ public class FactorPlugin extends EditPlugin
return token.rules.getName(); return token.rules.getName();
} //}}} } //}}}
//{{{ evalWordDef() method
public static void evalWordDef(View view)
{
FactorParsedData data = getParsedData(view);
if(data == null)
{
view.getToolkit().beep();
return;
}
JEditTextArea textArea = view.getTextArea();
IAsset asset = data.getAssetAtOffset(textArea.getCaretPosition());
if(asset == null || asset.getEnd() == null)
{
view.getToolkit().beep();
return;
}
int start = asset.getStart().getOffset();
String text = textArea.getBuffer().getText(start,
asset.getEnd().getOffset() - start);
String eval = data.getVocabularyDeclarations() + "\n" + text;
evalInListener(view,eval);
} //}}}
} }

View File

@ -15,6 +15,7 @@ plugin.factor.jedit.FactorPlugin.depend.3=plugin console.ConsolePlugin 4.0.2
plugin.factor.jedit.FactorPlugin.menu=factor-listener \ plugin.factor.jedit.FactorPlugin.menu=factor-listener \
factor-run-file \ factor-run-file \
factor-eval-selection \ factor-eval-selection \
factor-eval-word-def \
- \ - \
sidekick-tree \ sidekick-tree \
- \ - \
@ -40,6 +41,7 @@ plugin.factor.jedit.FactorPlugin.menu=factor-listener \
factor-listener.label=Listener factor-listener.label=Listener
factor-run-file.label=Run current file factor-run-file.label=Run current file
factor-eval-selection.label=Evaluate selection factor-eval-selection.label=Evaluate selection
factor-eval-word-def.label=Evaluate word definition
factor-apropos.label=Apropos at caret factor-apropos.label=Apropos at caret
factor-insert-use.label=Use word at caret factor-insert-use.label=Use word at caret
factor-see.label=See word at caret factor-see.label=See word at caret

View File

@ -25,8 +25,10 @@ BUILTIN: array 8 array? ;
: set-array-nth ( obj n a -- ) swap 2 fixnum+ set-slot ; inline : set-array-nth ( obj n a -- ) swap 2 fixnum+ set-slot ; inline
: dispatch ( n vtable -- ) 2 slot array-nth call ; : dispatch ( n vtable -- ) 2 slot array-nth call ;
: copy-array ( to from n -- ) : copy-array ( to from -- )
[ 3dup swap array-nth pick rot set-array-nth ] repeat 2drop ; dup array-capacity [
3dup swap array-nth pick rot set-array-nth
] repeat 2drop ;
M: array length array-capacity ; M: array length array-capacity ;
M: array nth array-nth ; M: array nth array-nth ;

View File

@ -38,6 +38,10 @@ IN: kernel-internals
[ array-nth swap call ] 2keep [ array-nth swap call ] 2keep
set-array-nth ; inline set-array-nth ; inline
: each-bucket ( hash quot -- | quot: n hash -- )
over bucket-count [ [ -rot call ] 3keep ] repeat 2drop ;
inline
: hash-size+ ( hash -- ) dup hash-size 1 + swap set-hash-size ; : hash-size+ ( hash -- ) dup hash-size 1 + swap set-hash-size ;
: hash-size- ( hash -- ) dup hash-size 1 - swap set-hash-size ; : hash-size- ( hash -- ) dup hash-size 1 - swap set-hash-size ;
@ -76,17 +80,9 @@ IN: hashtables
: grow-hash? ( hash -- ? ) : grow-hash? ( hash -- ? )
dup bucket-count 3 * 2 /i swap hash-size < ; dup bucket-count 3 * 2 /i swap hash-size < ;
: (hash>alist) ( alist n hash -- alist )
2dup bucket-count >= [
2drop
] [
[ hash-bucket [ swons ] each ] 2keep
>r 1 + r> (hash>alist)
] ifte ;
: hash>alist ( hash -- alist ) : hash>alist ( hash -- alist )
#! Push a list of key/value pairs in a hashtable. #! Push a list of key/value pairs in a hashtable.
[ ] 0 rot (hash>alist) ; [ ] swap [ hash-bucket [ swons ] each ] each-bucket ;
: (set-hash) ( value key hash -- ) : (set-hash) ( value key hash -- )
dup hash-size+ [ set-assoc ] set-hash* ; dup hash-size+ [ set-assoc ] set-hash* ;
@ -116,10 +112,7 @@ IN: hashtables
: hash-clear ( hash -- ) : hash-clear ( hash -- )
#! Remove all entries from a hashtable. #! Remove all entries from a hashtable.
0 over set-hash-size 0 over set-hash-size [ f -rot set-hash-bucket ] each-bucket ;
dup bucket-count [
[ f swap pick set-hash-bucket ] keep
] repeat drop ;
: buckets>list ( hash -- list ) : buckets>list ( hash -- list )
#! Push a list of key/value pairs in a hashtable. #! Push a list of key/value pairs in a hashtable.
@ -146,9 +139,8 @@ IN: hashtables
M: hashtable clone ( hash -- hash ) M: hashtable clone ( hash -- hash )
dup bucket-count <hashtable> dup bucket-count <hashtable>
over hash-size over set-hash-size [ over hash-size over set-hash-size
hash-array swap hash-array dup length copy-array [ hash-array swap hash-array copy-array ] keep ;
] keep ;
M: hashtable = ( obj hash -- ? ) M: hashtable = ( obj hash -- ? )
2dup eq? [ 2dup eq? [

View File

@ -46,7 +46,7 @@ sequences strings words ;
[ 3unlist define-slot ] each-with ; [ 3unlist define-slot ] each-with ;
: reader-word ( class name -- word ) : reader-word ( class name -- word )
[ swap word-name , "-" , , ] make-string create-in ; >r word-name "-" r> append3 create-in ;
: writer-word ( class name -- word ) : writer-word ( class name -- word )
[ swap "set-" , word-name , "-" , , ] make-string create-in ; [ swap "set-" , word-name , "-" , , ] make-string create-in ;

View File

@ -100,7 +100,6 @@ UNION: arrayed array tuple ;
: define-tuple ( tuple slots -- ) : define-tuple ( tuple slots -- )
2dup check-shape 2dup check-shape
>r create-in >r create-in
dup save-location
dup intern-symbol dup intern-symbol
dup tuple-predicate dup tuple-predicate
dup tuple "metaclass" set-word-prop dup tuple "metaclass" set-word-prop
@ -190,7 +189,7 @@ M: mirror length ( mirror -- len )
: clone-tuple ( tuple -- tuple ) : clone-tuple ( tuple -- tuple )
#! Make a shallow copy of a tuple, without cloning its #! Make a shallow copy of a tuple, without cloning its
#! delegate. #! delegate.
dup array-capacity dup <tuple> [ -rot copy-array ] keep ; [ array-capacity <tuple> dup ] keep copy-array ;
M: tuple clone ( tuple -- tuple ) M: tuple clone ( tuple -- tuple )
#! Clone a tuple and its delegate. #! Clone a tuple and its delegate.

View File

@ -62,8 +62,17 @@ SYMBOL: failures
failures off failures off
vocabularies get [ "temporary" off ] bind ; vocabularies get [ "temporary" off ] bind ;
: eligible-tests ( -- list ) : passed.
[ "Tests passed:" print . ;
: failed.
"Tests failed:" print
failures get [ unswons write ": " write error. ] each ;
: run-tests ( list -- )
prepare-tests [ test ] subset terpri passed. failed. ;
: tests
[ [
"lists/cons" "lists/lists" "lists/assoc" "lists/cons" "lists/lists" "lists/assoc"
"lists/namespaces" "lists/combinators" "combinators" "lists/namespaces" "lists/combinators" "combinators"
@ -81,38 +90,24 @@ SYMBOL: failures
"inference" "dataflow" "interpreter" "alien" "inference" "dataflow" "interpreter" "alien"
"line-editor" "gadgets" "memory" "redefine" "line-editor" "gadgets" "memory" "redefine"
"annotate" "sequences" "annotate" "sequences"
] % ] run-tests ;
os "win32" = [
"buffer" ,
] when
cpu "unknown" = not "compile" get and [
[
"io/buffer" "compiler/optimizer"
"compiler/simple"
"compiler/stack" "compiler/ifte"
"compiler/generic" "compiler/bail-out"
"compiler/linearizer" "compiler/intrinsics"
] %
] when
: benchmarks
[ [
"benchmark/empty-loop" "benchmark/fac" "benchmark/empty-loop" "benchmark/fac"
"benchmark/fib" "benchmark/sort" "benchmark/fib" "benchmark/sort"
"benchmark/continuations" "benchmark/ack" "benchmark/continuations" "benchmark/ack"
"benchmark/hashtables" "benchmark/strings" "benchmark/hashtables" "benchmark/strings"
"benchmark/vectors" "benchmark/prettyprint" "benchmark/vectors" "benchmark/prettyprint"
] % ] run-tests ;
] make-list ;
: passed. : compiler-tests
"Tests passed:" print . ; [
"io/buffer" "compiler/optimizer"
"compiler/simple"
"compiler/stack" "compiler/ifte"
"compiler/generic" "compiler/bail-out"
"compiler/linearizer" "compiler/intrinsics"
] run-tests ;
: failed. : all-tests tests compiler-tests benchmarks ;
"Tests failed:" print
failures get [ unswons write ": " write error. ] each ;
: all-tests ( -- )
prepare-tests eligible-tests [ test ] subset
terpri passed. failed. ;