FactorPlugin.getExternalInstance());
</CODE>
</ACTION>
+ <ACTION NAME="factor-compile-all">
+ <CODE>
+ wm.showDockableWindow("console");
+ CompileBufferProcessor.compileWordsInBuffer(view,buffer,
+ FactorPlugin.getExternalInstance(),
+ wm.getDockableWindow("console"));
+ </CODE>
+ </ACTION>
</ACTIONS>
!
! ./f boot.image.le32
! -libraries:sdl:name=libSDL.so
-! -libraries:sdl-gfx:name=libSDL_gfx.
+! -libraries:sdl-gfx:name=libSDL_gfx.so
!
! (But all on one line)
!
: next-x ( x y -- x ) a get * sin swap b get * cos - ;
: next-y ( x y -- y ) swap c get * sin swap d get * cos - ;
-: white ( -- rgb )
- HEX: ffffffff ;
-
: pixel ( #{ x y }# color -- )
>r >r surface get r> >rect r> pixelColor ;
: draw-dejong ( x0 y0 iterations -- )
[
iterate-dejong 2dup scale-dejong rect> white pixel
- ] times 2drop ;
+ ] times 2drop ; compiled
: dejong ( -- )
! Fiddle with these four values!
- 1.4 a set
- -2.3 b set
- 2.4 c set
+ 1.0 a set
+ -1.3 b set
+ 0.8 c set
-2.1 d set
- 640 480 32 SDL_HWSURFACE [
- [ 0 0 100000 draw-dejong ] with-surface
+ 1024 768 0 SDL_HWSURFACE [
+ [ 0 0 200000 [ draw-dejong ] time ] with-surface
<event> event-loop
SDL_Quit
- ] with-screen ; compiled
+ ] with-screen ;
-[ dejong ] time
+dejong
FactorWord word;
if(define)
- {
word = lookup.define(getIn(),name);
- definedWords = new Cons(word,definedWords);
- }
else
{
word = searchVocabulary(getUse(),name);
FactorWord w = intern((String)next,define);
if(define && w != null)
{
+ definedWords = new Cons(w,definedWords);
w.line = line;
w.col = col;
w.file = scanner.getFileName();
--- /dev/null
+/* :folding=explicit:collapseFolds=1: */
+
+/*
+ * $Id$
+ *
+ * Copyright (C) 2005 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 console.Output;
+import factor.*;
+import java.io.IOException;
+import java.util.*;
+import org.gjt.sp.jedit.*;
+import org.gjt.sp.util.*;
+
+public class CompileBufferProcessor extends FactorBufferProcessor
+{
+ //{{{ compileWordsInBuffer() method
+ public static void compileWordsInBuffer(View view,
+ Buffer buffer,
+ ExternalFactor factor,
+ Output output) throws Exception
+ {
+ String results = new CompileBufferProcessor(
+ buffer,factor).getResults();
+ output.print(null,results);
+ } //}}}
+
+ //{{{ CompileBufferProcessor constructor
+ public CompileBufferProcessor(Buffer buffer, ExternalFactor factor)
+ throws Exception
+ {
+ super(buffer,factor);
+ } //}}}
+
+ //{{{ processWord() method
+ /**
+ * @return Code to process the word.
+ */
+ public String processWord(FactorWord word)
+ {
+ StringBuffer expression = new StringBuffer();
+ expression.append(FactorPlugin.factorWord(word));
+ expression.append(" try-compile");
+ return expression.toString();
+ } //}}}
+}
package factor.jedit;
import factor.*;
-import java.io.IOException;
-import java.util.*;
import org.gjt.sp.jedit.Buffer;
/**
*/
public abstract class FactorBufferProcessor
{
- private LinkedHashMap results;
+ private String results;
//{{{ FactorBufferProcessor constructor
public FactorBufferProcessor(Buffer buffer, ExternalFactor factor)
throws Exception
{
- results = new LinkedHashMap();
+ StringBuffer buf = new StringBuffer();
Cons words = (Cons)buffer.getProperty(
FactorSideKickParser.WORDS_PROPERTY);
{
FactorWord word = (FactorWord)words.car;
String expr = processWord(word);
- System.err.println(expr);
- results.put(word,factor.eval(expr));
+ buf.append("! ");
+ buf.append(expr);
+ buf.append('\n');
+ buf.append(factor.eval(expr));
words = words.next();
}
+
+ results = buf.toString();
} //}}}
/**
*/
public abstract String processWord(FactorWord word);
- //{{{ insertResults() method
- public void insertResults(Buffer buffer, int offset)
- throws Exception
+ //{{{ getResults() method
+ public String getResults()
{
- StringBuffer result = new StringBuffer();
- Iterator iter = results.values().iterator();
- while(iter.hasNext())
- result.append(iter.next());
- buffer.insert(offset,result.toString().trim());
+ return results;
} //}}}
}
*/
public static void stopExternalInstance()
{
- getFactorShell().closeStreams();
+ if(getFactorShell() != null)
+ getFactorShell().closeStreams();
if(external != null)
{
factor-extract-word \
- \
factor-infer-effect \
- factor-compile \
- - \
factor-infer-effects \
- \
+ factor-compile \
+ factor-compile-all \
+ - \
factor-restart
factor-listener.label=Listener
factor-usages.label=Word usages at caret
factor-extract-word.label=Extract word...
factor-infer-effect.label=Infer word at caret
-factor-compile.label=Compile word at caret
factor-infer-effects.label=Infer all words in buffer
+factor-compile.label=Compile word at caret
+factor-compile-all.label=Compile all words in buffer
factor-restart.label=Restart Factor
# SideKick stuff
/*
* $Id$
*
- * Copyright (C) 2004 Slava Pestov.
+ * Copyright (C) 2004, 2005 Slava Pestov.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
public static void createInferUnitTests(View view,
final Buffer buffer,
final ExternalFactor factor)
+ throws Exception
{
+ final String results = new InferBufferProcessor(buffer,factor)
+ .getResults();
+
final Buffer newBuffer = jEdit.newFile(view);
VFSManager.runInAWTThread(new Runnable()
{
newBuffer.setMode("factor");
try
{
- new InferBufferProcessor(buffer,factor)
- .insertResults(newBuffer,0);
+ newBuffer.insert(0,results);
}
catch(Exception e)
{
-! :folding=indent:collapseFolds=1:sidekick.parser=none:
+! :folding=indent:collapseFolds=1:
! $Id$
!
: TTF_FontFaceStyleName ( font -- n )
"char*" "sdl-ttf" "TTF_FontFaceStyleName" [ "void*" ] alien-invoke ;
-: TTF_RenderText_Solid ( font text fg bg -- surface )
- "surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "char*" "int" "int" ] alien-invoke ;
+: TTF_RenderText_Solid ( font text fg -- surface )
+ "surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "char*" "int" ] alien-invoke ;
: TTF_RenderGlyph_Shaded ( font text fg bg -- surface )
"surface*" "sdl-ttf" "TTF_RenderGlyph_Shaded" [ "void*" "ushort" "int" "int" ] alien-invoke ;
"newPlainView" off
] extend make-jedit-request send-jedit-request ;
-: resource-path ( -- path )
- global [ "resource-path" get ] bind [ "." ] unless* ;
-
: word-file ( path -- dir file )
dup [
"resource:/" ?str-head [