]> gitweb.factorcode.org Git - factor.git/commitdiff
some bug fixes and ffi updates
authorSlava Pestov <slava@factorcode.org>
Sat, 25 Sep 2004 03:22:44 +0000 (03:22 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 25 Sep 2004 03:22:44 +0000 (03:22 +0000)
Makefile
TODO.FACTOR.txt
factor/FactorNamespace.java
library/combinators.factor
library/compiler/alien-macros.factor
library/inspect-vocabularies.factor
library/math/math-combinators.factor
library/platform/jvm/listener.factor
library/platform/native/parse-syntax.factor
library/stdio.factor
library/test/combinators.factor

index 7582c93a58996792da57deb3dc8ed66f3a84ce95..e166402b4b020a5a4a3eb1c42e81d05d7af2ed5a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 CC = gcc
 
 # On FreeBSD, to use SDL and other libc_r libs:
-CFLAGS = -g -Wall -pthread -export-dynamic
+CFLAGS = -g -Wall -export-dynamic -pthread
 # On PowerPC G5:
 # CFLAGS = -mcpu=970 -mtune=970 -mpowerpc64 -ffast-math -O3
 # On Pentium 4:
index 15d0c18c308d47e4ff4ced2fdd156d70c526ec1f..f4a9a2dc781a57c40a35dec7fa49dde729ac0d63 100644 (file)
@@ -4,26 +4,22 @@ FFI:
 [error] SideKick$BufferChangeHandler: We have cplusplus.xml (/home/slava/jEdit/modes/) but got event for DefaultInputHandler.java (/home/slava/jEdit/org/gjt/sp/jedit/gui/)\r
 [error] SideKick$BufferChangeHandler: We have cplusplus.xml (/home/slava/jEdit/modes/) but got event for DefaultInputHandler.java (/home/slava/jEdit/org/gjt/sp/jedit/gui/)\r
 \r
-- fix responder generated links\r
+- perhaps /i should work with all numbers\r
 - profiler is inaccurate: wrong word on cs\r
 - buffer change handler in sidekick is screwed\r
 - dec> bin> oct> hex> throw errors\r
 - parse-number doesn't\r
 - eval with multilien strings and #!\r
-- redefining a word doesn't clear comments\r
 - quit responder breaks with multithreading\r
 - nicer way to combine two paths\r
 - don't show listener on certain commands\r
 - plugin should not exit jEdit on fatal errors\r
 - wordpreview: don't show for string literals and comments\r
 - alist -vs- assoc terminology\r
-- write-icon kind of messy; " " should be output by the listener\r
-- f usages. --> don't print all words\r
 - file responder: don't show full path in title\r
 \r
 - clean up listener's action popups\r
 - jedit ==> jedit-word, jedit takes a file name\r
-- namespace clone drops static var bindings\r
 - add a socket timeout\r
 - fix error postoning -- not all errors thrown by i/o code are\r
   postponed\r
index a9462948a33b535f61d7b8a7820aae0884f93706..1d456b0dcd899cecf63ba37dc09aa17b0d7e4458 100644 (file)
@@ -93,8 +93,14 @@ public class FactorNamespace implements PublicCloneable, FactorObject
                                Map.Entry entry = (Map.Entry)iter.next();
                                Object key = entry.getKey();
                                Object value = entry.getValue();
-                               if(!(value instanceof VarBinding))
-                                       this.words.put(key,value);
+                               if(value instanceof VarBinding)
+                               {
+                                       VarBinding b = (VarBinding)value;
+                                       if(b.instance != null)
+                                               continue;
+                               }
+
+                               this.words.put(key,value);
                        }
                }
 
index de52ff0e5b79c39b813056e91501f00f91085e5f..abfbbba525edece838c43e02ad6dbe9f45dee81f 100644 (file)
@@ -42,6 +42,15 @@ USE: stack
     #! If the quotation compiles, this combinator compiles.
     >r over >r call r> r> call ; inline interpret-only
 
+: slip ( quot x -- x )
+    >r call r> ; inline interpret-only
+
+: 2slip ( quot x y -- x y )
+    >r >r call r> r> ; inline interpret-only
+
+: 3slip ( quot x y z -- x y z )
+    >r >r >r call r> r> r> ; inline interpret-only
+
 : dip ( a [ b ] -- b a )
     #! Call b as if b was not present on the stack.
     #!
index 77b5dd7b36e0777bf5a3cafa5102429429cd4185..8e0da8fd9db592fc6c827a5fc7be7ebc5afbbcf8 100644 (file)
@@ -66,7 +66,7 @@ USE: stack
     ] ifte ;
 
 : ALIEN-CALL ( return func dll params -- )
-    PARAMETERS >r
+    reverse PARAMETERS >r
     dlsym CALL drop
     r> CLEANUP
     RETURNS ;
index c5b83e4ab4d8aae731abe0c235185540b11d7977..5c50c68cbdd310b30a06bb1a6ceb68146987793a 100644 (file)
@@ -64,7 +64,11 @@ USE: unparser
 
 : usages. ( word -- )
     #! List all usages of a word in all vocabularies.
-    intern vocabs [ dupd usages-in-vocab. ] each drop ;
+    intern [
+        vocabs [ dupd usages-in-vocab. ] each drop
+    ] [
+        "Not defined" print
+    ] ifte* ;
 
 : vocab-apropos ( substring vocab -- list )
     #! Push a list of all words in a vocabulary whose names
index 297297933915573259f31211523773fe4f107915..a3a4c2649e840ebec9b73ce75289b14a1d396a23 100644 (file)
@@ -38,14 +38,14 @@ USE: stack
     tuck >r dup 0 <= [
         r> 3drop
     ] [
-        pred >r call r> r> times
+        pred slip r> times
     ] ifte ; inline interpret-only
 
 : (times) ( limit n quot -- )
     pick pick <= [
         3drop
     ] [
-        tuck >r tuck >r rot >r call r> r> succ r> (times)
+        rot pick succ pick 3slip (times)
     ] ifte ; inline interpret-only
 
 : times* ( n quot -- )
@@ -55,3 +55,27 @@ USE: stack
     #! In order to compile, the code must consume one more value
     #! than it produces.
     0 swap (times) ; inline interpret-only
+
+: 2times-succ ( #{ a b } #{ c d } -- z )
+    #! Lexicographically add #{ 0 1 } to a complex number.
+    #! If d + 1 == b, return #{ c+1 0 }. Otherwise, #{ c d+1 }.
+    2dup imaginary succ swap imaginary = [
+        nip real succ
+    ] [
+        nip >rect succ rect>
+    ] ifte ;
+
+: 2times<= ( #{ a b } #{ c d } -- ? )
+    swap real swap real <= ;
+
+: (2times) ( limit n quot -- )
+    pick pick 2times<= [
+        3drop
+    ] [
+        rot pick dupd 2times-succ pick 3slip (2times)
+    ] ifte ;
+
+: 2times* ( #{ w h } quot -- )
+    #! Apply a quotation to each pair of complex numbers
+    #! #{ a b } such that a < w, b < h.
+    0 swap (2times) ;
index 004cf6d562b0b5b356d83f24ffea3f955369c1c4..51244310d22a5ec92398c05ee29d1db34f50055e 100644 (file)
@@ -120,7 +120,13 @@ USE: unparser
     over underline-attribute
     <file-actions-menu> actions-key attribute+ ;
 
-: style>attribute-set ( style -- attribute-set )
+: icon-attribute ( string style value -- )
+    dupd <icon> set-icon-style
+    >r drop " " r> ;
+
+: style>attribute-set ( string style -- string attribute-set )
+    #! We need the string, since outputting an icon changes the
+    #! string to " ".
     <attribute-set> swap [
         [ "object-link" dupd object-link-attribute ]
         [ "file-link"   dupd file-link-attribute ]
@@ -131,7 +137,7 @@ USE: unparser
         [ "bg"          dupd >color "Background" swing-attribute+ ]
         [ "font"        dupd "FontFamily" swing-attribute+ ]
         [ "size"        dupd "FontSize" swing-attribute+ ]
-        [ "icon"        dupd <icon> set-icon-style ]
+        [ "icon"        icon-attribute ]
     ] assoc-apply ;
 
 : set-character-attrs ( attrs -- )
@@ -149,7 +155,8 @@ USE: unparser
     jinvoke ;
 
 : reset-attrs ( -- )
-    default-style style>attribute-set set-character-attrs ;
+    f default-style style>attribute-set set-character-attrs
+    drop ;
 
 : listener-readln* ( continuation -- )
     "listener" get
index b16659cba8e2e7f58c93ee5d95667cfa86734cf0..5b4e332adc0e1ae4e49e729f883cb8be35b8774e 100644 (file)
@@ -68,7 +68,8 @@ USE: unparser
 ! Colon defs
 : CREATE ( -- word )
     scan "in" get create dup set-word
-    f "documentation" pick set-word-property ;
+    f "documentation" pick set-word-property
+    f "stack-effect" pick set-word-property ;
 
 : remember-where ( word -- )
     "line-number" get "line" pick set-word-property
@@ -81,14 +82,14 @@ USE: unparser
     CREATE dup remember-where [ ]
     "in-definition" on ; parsing
 
-: ;-hook ( -- quot )
-    ";-hook" get [ [ define-compound ] ] unless* ;
+: ;-hook ( word def -- )
+    ";-hook" get [ call ] [ define-compound ] ifte* ;
 
 : ;
     #! End a word definition.
     "in-definition" off
     nreverse
-    ;-hook call ; parsing
+    ;-hook ; parsing
 
 ! Vocabularies
 : DEFER: CREATE drop ; parsing
index 6469c22d31f34c85fc78753ede63544d539e8e7c..0638cf1fad85c1bce6b9faec5d819c51acadbb01 100644 (file)
@@ -69,7 +69,7 @@ USE: streams
 
 : write-icon ( resource -- )
     #! Write an icon. Eg, /library/icons/File.png
-    "icon" swons unit " " swap write-attr ;
+    "icon" swons unit "" swap write-attr ;
 
 : print ( string -- )
     "stdio" get fprint ;
index 535467d16f33a72394262d9820872b3f36909c75..2a733d55a32035ebd3e2a6126f238bc1344104cb 100644 (file)
@@ -1,8 +1,25 @@
 IN: scratchpad
 USE: combinators
 USE: kernel
+USE: math
 USE: stack
 USE: test
 
 [   ] [ 3 [ ] cond ] unit-test
 [ t ] [ 4 [ [ 1 = ] [ ] [ 4 = ] [ drop t ] [ 2 = ] [ ] ] cond ] unit-test
+
+[ 0 1 2 3 4 ] [ 5 [ ] times* ] unit-test
+[ ] [ 0 [ ] times* ] unit-test
+
+[ #{ 1 1 } ] [ #{ 2 3 } #{ 1 0 } 2times-succ ] unit-test
+[ #{ 1 2 } ] [ #{ 2 3 } #{ 1 1 } 2times-succ ] unit-test
+[ #{ 2 0 } ] [ #{ 3 3 } #{ 1 2 } 2times-succ ] unit-test
+[ #{ 2 1 } ] [ #{ 3 3 } #{ 2 0 } 2times-succ ] unit-test
+[ #{ 2 0 } ] [ #{ 2 2 } #{ 1 1 } 2times-succ ] unit-test
+
+[ #{ 0 0 } #{ 0 1 } #{ 1 0 } #{ 1 1 } ]
+[ #{ 2 2 } [ ] 2times* ] unit-test
+
+[ #{ 0 0 } #{ 0 1 } #{ 0 2 } #{ 1 0 } #{ 1 1 } #{ 1 2 } 
+  #{ 2 0 } #{ 2 1 } #{ 2 2 } ]
+[ #{ 3 3 } [ ] 2times* ] unit-test