]> gitweb.factorcode.org Git - factor.git/commitdiff
assorted enhancements, started 64-bit image output
authorSlava Pestov <slava@factorcode.org>
Sat, 4 Sep 2004 05:05:50 +0000 (05:05 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 4 Sep 2004 05:05:50 +0000 (05:05 +0000)
26 files changed:
Makefile
TODO.FACTOR.txt
actions.xml
factor/jedit/EditWordDialog.java
factor/jedit/FactorAsset.java
factor/jedit/FactorCompletion.java
factor/jedit/FactorParsedData.java
factor/jedit/FactorPlugin.java
factor/jedit/FactorSideKickParser.java
factor/jedit/FactorWordRenderer.java
factor/jedit/InsertUseDialog.java
factor/jedit/WordListDialog.java
factor/jedit/WordPreview.java
library/cross-compiler.factor
library/httpd/html-tags.factor
library/image.factor
library/math/arithmetic.factor
library/math/trig-hyp.factor
library/platform/jvm/boot-sumo.factor
library/platform/native/boot-stage2.factor
library/sbuf.factor
library/stdio-binary.factor
library/test/strings.factor
native/error.c
native/fixnum.c
native/float.h

index 4ed97ccb129ac1b2fd9ce649b09668796abae417..95a2560c88975f0843996ea6f824dc6c5cc44b87 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 CC = gcc
-CFLAGS = -g -Wall
+CFLAGS = -Os -mpentiumpro -g -Wall
 LIBS = -lm
 STRIP = strip
 
index 5bb69abb7557e7d0786f7136fd1c2861f10141b6..a4c6d51fdcd4692e293b0020c08c657104ef5d6f 100644 (file)
@@ -6,7 +6,8 @@
 - plugin should not exit jEdit on fatal errors\r
 - IN: format base: work with all types of numbers\r
 - wordpreview: don't show for string literals and comments\r
-- eliminate usage of long long\r
+- NPE in activate()/deactivate()\r
+- NPE in ErrorHighlight\r
 - 64 bit support\r
 - alist -vs- assoc terminology\r
 - clean up listener's action popups\r
@@ -53,6 +54,7 @@
 \r
 + listener/plugin:\r
 \r
+- don't use jEdit's word finding API\r
 - some way to not have previous definitions from a source file\r
   clutter the namespace\r
 - use inferior.factor for everything not just listener\r
@@ -89,6 +91,8 @@
 \r
 + misc:\r
 \r
+- telnetd: init-history\r
+- str-reverse primitive\r
 - some way to run httpd from command line\r
 - don't rehash strings on every startup\r
 - 'cascading' styles\r
index 4e729bca10409dda5a65ee1864dea5c12787f9e7..d2b8c2226cafe7027423fc6733c64bdea4b31c54 100644 (file)
@@ -48,7 +48,8 @@
        </ACTION>
        <ACTION NAME="factor-edit-dialog">
                <CODE>
-                       new EditWordDialog(view,FactorPlugin.getInterpreter());
+                       new EditWordDialog(view,FactorPlugin
+                               .getSideKickParser());
                </CODE>
        </ACTION>
        <ACTION NAME="factor-usages">
index 9c855f1c217414dffe1669b5f7e8e1e946c03654..49733068d0b1e64b61798b1f5a020f1a090040bd 100644 (file)
@@ -46,9 +46,9 @@ public class EditWordDialog extends WordListDialog
        private Timer timer;
 
        //{{{ EditWordDialog constructor
-       public EditWordDialog(View view, FactorInterpreter interp)
+       public EditWordDialog(View view, FactorSideKickParser parser)
        {
-               super(view,interp,jEdit.getProperty("factor.edit-word.title"));
+               super(view,parser,jEdit.getProperty("factor.edit-word.title"));
 
                Box top = new Box(BoxLayout.X_AXIS);
                top.add(new JLabel(jEdit.getProperty(
index a5abc7047995914087c1ecaa806680e5531a506a..5080889a93160aa1abdc9b067b08affd85f61b4a 100644 (file)
@@ -30,6 +30,7 @@
 package factor.jedit;
 
 import factor.FactorWord;
+import factor.FactorWordDefinition;
 import javax.swing.Icon;
 import javax.swing.text.Position;
 import org.gjt.sp.jedit.Buffer;
@@ -38,12 +39,15 @@ import sidekick.*;
 public class FactorAsset extends Asset
 {
        private FactorWord word;
+       private FactorWordDefinition def;
 
-       public FactorAsset(FactorWord word, Position start)
+       public FactorAsset(FactorWord word, FactorWordDefinition def,
+               Position start)
        {
                super(word.name);
                this.start = start;
                this.word = word;
+               this.def = def;
        }
 
        public Icon getIcon()
@@ -59,6 +63,6 @@ public class FactorAsset extends Asset
        public String getLongString()
        {
                return FactorWordRenderer.getWordHTMLString(
-                       FactorPlugin.getInterpreter(),word,false);
+                       FactorPlugin.getInterpreter(),word,def,false);
        }
 }
index d62aba94cfe0d7f4b86e8e3b430f7a31754fbaaf..ae14cb83457957eb66436c6e85ad3e024549f229 100644 (file)
@@ -98,8 +98,6 @@ public class FactorCompletion extends SideKickCompletion
 
        public ListCellRenderer getRenderer()
        {
-               return new FactorWordRenderer(
-                       FactorPlugin.getInterpreter(),
-                       false);
+               return new FactorWordRenderer(data.parser,false);
        }
 }
index 20daf62ccf935869ddc248cc9327cd0038693f0c..d42102851dd775949d7ab732a205120f69a3005d 100644 (file)
@@ -34,13 +34,13 @@ import sidekick.*;
 
 public class FactorParsedData extends SideKickParsedData
 {
-       public FactorInterpreter interp;
+       public FactorSideKickParser parser;
        public String in;
        public Cons use;
        
-       FactorParsedData(FactorInterpreter interp, String fileName)
+       FactorParsedData(FactorSideKickParser parser, String fileName)
        {
                super(fileName);
-               this.interp = interp;
+               this.parser = parser;
        }
 }
index 6cf8a886568bb1dae22b5ff99508529cdfca4ac0..8b3bdd724a8bfe28c3e0b51cc4d7821444f7c4fb 100644 (file)
@@ -66,6 +66,13 @@ public class FactorPlugin extends EditPlugin
                return interp;
        } //}}}
        
+       //{{{ getSideKickParser() method
+       public static FactorSideKickParser getSideKickParser()
+       {
+               return (FactorSideKickParser)ServiceManager.getService(
+                       "sidekick.SideKickParser","factor");
+       } //}}}
+       
        //{{{ eval() method
        public static void eval(View view, String cmd)
        {
@@ -261,7 +268,7 @@ public class FactorPlugin extends EditPlugin
                else if(words.length == 1)
                        insertUse(view,words[0].vocabulary);
                else
-                       new InsertUseDialog(view,getInterpreter(),words);
+                       new InsertUseDialog(view,getSideKickParser(),words);
        } //}}}
 
        //{{{ insertUse() method
@@ -279,17 +286,24 @@ public class FactorPlugin extends EditPlugin
                for(int i = 0; i < buffer.getLineCount(); i++)
                {
                        String text = buffer.getLineText(i).trim();
-                       if(text.startsWith("IN:") || text.startsWith("USE:")
-                               || text.startsWith("!")
-                               || text.length() == 0)
+                       if(text.startsWith("IN:") || text.startsWith("USE:"))
+                       {
+                               lastUseOffset = buffer.getLineEndOffset(i) - 1;
+                       }
+                       else if(text.startsWith("!") || text.length() == 0)
                        {
-                               lastUseOffset = buffer.getLineStartOffset(i);
+                               if(i == 0)
+                                       lastUseOffset = 0;
+                               else
+                                       lastUseOffset = buffer.getLineEndOffset(i-1) - 1;
                        }
                        else
                                break;
                }
 
-               String decl = "USE: " + vocab + "\n";
+               String decl = "USE: " + vocab;
+               if(lastUseOffset != 0)
+                       decl = "\n" + decl;
                buffer.insert(lastUseOffset,decl);
                showStatus(view,"inserted-use",decl);
        } //}}}
index 7f1ae03d5d63a91e5f13752b9a8feecda6839d76..b5474b8074ffd2f25be3de5e1b95afa6f4a2febc 100644 (file)
@@ -40,6 +40,7 @@ import sidekick.*;
 
 public class FactorSideKickParser extends SideKickParser
 {
+       private FactorInterpreter interp;
        private WordPreview wordPreview;
 
        /**
@@ -53,10 +54,32 @@ public class FactorSideKickParser extends SideKickParser
        public FactorSideKickParser()
        {
                super("factor");
-               wordPreview = new WordPreview();
+               interp = FactorPlugin.getInterpreter();
+               wordPreview = new WordPreview(this);
                worddefs = new HashMap();
        } //}}}
 
+       //{{{ getInterpreter() method
+       public FactorInterpreter getInterpreter()
+       {
+               return interp;
+       } //}}}
+
+       //{{{ getWordDefinition() method
+       /**
+        * Check for a word definition from a parsed source file. If one is
+        * found, return it, otherwise return interpreter's definition.
+        */
+       public FactorWordDefinition getWordDefinition(FactorWord word)
+       {
+               FactorWordDefinition def = (FactorWordDefinition)
+                       worddefs.get(word);
+               if(def != null)
+                       return def;
+               else
+                       return word.def;
+       } //}}}
+
        //{{{ activate() method
        /**
         * This method is called when a buffer using this parser is selected
@@ -95,9 +118,8 @@ public class FactorSideKickParser extends SideKickParser
        public SideKickParsedData parse(Buffer buffer,
                DefaultErrorSource errorSource)
        {
-               FactorInterpreter interp = FactorPlugin.getInterpreter();
                FactorParsedData d = new FactorParsedData(
-                       interp,buffer.getPath());
+                       this,buffer.getPath());
 
                String text;
 
@@ -176,7 +198,7 @@ public class FactorSideKickParser extends SideKickParser
                                if(last != null)
                                        last.end = buffer.createPosition(start - 1);
 
-                               last = new FactorAsset(word,
+                               last = new FactorAsset(word,def,
                                        buffer.createPosition(start));
                                d.root.add(new DefaultMutableTreeNode(last));
                        }
index 50bd616ef8c05ba80c7b25c5a9852a80125e30a5..900b0bffcd7708081feba7bb69b33b7b72c9fbd9 100644 (file)
@@ -38,40 +38,40 @@ public class FactorWordRenderer extends DefaultListCellRenderer
 {
        //{{{ getWordHTMLString() method
        public static String getWordHTMLString(FactorInterpreter interp,
-               FactorWord word, boolean showIn)
+               FactorWord word, FactorWordDefinition def, boolean showIn)
        {
                String prop = "factor.completion.plain";
                String stackEffect = null;
 
-               if(word.def == null)
+               if(def == null)
                {
                        if(word.parsing != null)
                                prop = "factor.completion.parsing";
                        else
                                prop = "factor.completion.defer";
                }
-               else if(word.def instanceof FactorShuffleDefinition)
+               else if(def instanceof FactorShuffleDefinition)
                {
                        prop = "factor.completion.shuffle";
                        StringBuffer buf = new StringBuffer();
-                       Cons def = word.def.toList(interp);
-                       while(def != null)
+                       Cons d = def.toList(interp);
+                       while(d != null)
                        {
                                if(buf.length() != 0)
                                        buf.append(' ');
 
-                               buf.append(def.car);
-                               def = def.next();
+                               buf.append(d.car);
+                               d = d.next();
                        }
                        stackEffect = buf.toString();
                }
                else
                {
-                       Cons def = word.def.toList(interp);
-                       if(def != null && def.car instanceof FactorDocComment)
+                       Cons d = def.toList(interp);
+                       if(d != null && d.car instanceof FactorDocComment)
                        {
                                FactorDocComment comment = (FactorDocComment)
-                                       def.car;
+                                       d.car;
                                if(comment.isStackComment())
                                {
                                        prop = "factor.completion.stack";
@@ -100,13 +100,13 @@ public class FactorWordRenderer extends DefaultListCellRenderer
                        });
        } //}}}
 
-       private FactorInterpreter interp;
+       private FactorSideKickParser parser;
        private boolean showIn;
 
        //{{{ FactorWordRenderer constructor
-       public FactorWordRenderer(FactorInterpreter interp, boolean showIn)
+       public FactorWordRenderer(FactorSideKickParser parser, boolean showIn)
        {
-               this.interp = interp;
+               this.parser = parser;
                this.showIn = showIn;
        } //}}}
 
@@ -124,7 +124,11 @@ public class FactorWordRenderer extends DefaultListCellRenderer
                if(!(value instanceof FactorWord))
                        return this;
 
-               setText(getWordHTMLString(interp,(FactorWord)value,showIn));
+               FactorWord word = (FactorWord)value;
+               setText(getWordHTMLString(parser.getInterpreter(),
+                       word,
+                       parser.getWordDefinition(word),
+                       showIn));
 
                return this;
        } //}}}
index 2b818e6d308c8afc4e65866914b1334e4a8b8e07..bb1ddb9aefbc6ef596f75c39330ddf76d7b08ec1 100644 (file)
@@ -40,10 +40,10 @@ import org.gjt.sp.jedit.*;
 public class InsertUseDialog extends WordListDialog
 {
        //{{{ InsertUseDialog constructor
-       public InsertUseDialog(View view, FactorInterpreter interp,
+       public InsertUseDialog(View view, FactorSideKickParser parser,
                FactorWord[] words)
        {
-               super(view,interp,jEdit.getProperty("factor.insert-use.title"));
+               super(view,parser,jEdit.getProperty("factor.insert-use.title"));
 
                getContentPane().add(BorderLayout.NORTH,new JLabel(
                        jEdit.getProperty("factor.insert-use.caption",
index b3921396939cd32c4cf866faad8e3d65c410f095..4b2f0f8967997cd3a3482036b63b61eb0b548ef3 100644 (file)
@@ -44,7 +44,8 @@ public abstract class WordListDialog extends EnhancedDialog
        protected JButton ok, cancel;
 
        //{{{ WordListDialog constructor
-       public WordListDialog(View view, FactorInterpreter interp, String title)
+       public WordListDialog(View view, FactorSideKickParser parser,
+               String title)
        {
                super(view,title,true);
 
@@ -56,7 +57,7 @@ public abstract class WordListDialog extends EnhancedDialog
 
                content.add(BorderLayout.CENTER,new JScrollPane(
                        list = new JList()));
-               list.setCellRenderer(new FactorWordRenderer(interp,true));
+               list.setCellRenderer(new FactorWordRenderer(parser,true));
 
                content.add(BorderLayout.SOUTH,createButtonPanel());
        } //}}}
index 0d3d3343bba28be4af58baf4517fa5e710c56d14..49b2c1e1effe7eb7e8a9b94f137ca0ec7ac8b71c 100644 (file)
@@ -39,11 +39,21 @@ import sidekick.*;
 
 public class WordPreview implements CaretListener
 {
+       private FactorSideKickParser parser;
+
+       //{{{ WordPreview constructor
+       public WordPreview(FactorSideKickParser parser)
+       {
+               this.parser = parser;
+       } //}}}
+       
+       //{{{ caretUpdate() method
        public void caretUpdate(CaretEvent e)
        {
                showPreview((JEditTextArea)e.getSource());
-       }
+       } //}}}
 
+       //{{{ showPreview() method
        private void showPreview(JEditTextArea textArea)
        {
                View view = textArea.getView();
@@ -55,14 +65,15 @@ public class WordPreview implements CaretListener
                if(data instanceof FactorParsedData)
                {
                        FactorParsedData fdata = (FactorParsedData)data;
-                       FactorWord w = fdata.interp
-                               .searchVocabulary(fdata.use,word);
+                       FactorInterpreter interp = fdata.parser
+                               .getInterpreter();
+                       FactorWord w = interp.searchVocabulary(fdata.use,word);
                        if(w != null)
                        {
                                view.getStatus().setMessageAndClear(
                                        FactorWordRenderer.getWordHTMLString(
-                                       fdata.interp,w,true));
+                                       interp,w,fdata.parser.getWordDefinition(w),true));
                        }
                }
-       }
+       } //}}}
 }
index 2d115962bc62f433b7594f4d3a651b06a14b70e3..e90314eee58bff17e28212a256e69577f0a6eb62 100644 (file)
@@ -280,7 +280,9 @@ IN: cross-compiler
     swap write-image ;
 
 : make-images ( -- )
-    "big-endian" off "boot.image.le" make-image
-    "big-endian" on  "boot.image.be" make-image
-    "boot.image.le and boot.image.be have been generated." print
-    ;
+    "64-bits" off
+    "big-endian" off "boot.image.le32" make-image
+    "big-endian" on  "boot.image.be32" make-image
+    "64-bits" on
+    "big-endian" off "boot.image.le64" make-image
+    "big-endian" on  "boot.image.be64" make-image ;
index 39ca530690e6e2b86b8db81212cb133aab289cae..6d668d2f8ea0e7d78893ed5f1adcd1b4266a4c9d 100644 (file)
@@ -223,5 +223,5 @@ USE: logic
     "size" "href" "class" "border" "rows" "cols" 
     "id" "onclick" "style" "valign" "accesskey"
     "src" "language" "colspan" "onchange" "rel"
-    "width" "src"
+    "width"
 ] [ define-attribute-word ] each 
index bb830ea1b6aebc1da9811f7d7a54bce9d8f79f2a..2fc54f555c9985788de0f6d4748481ecd0d83b8b 100644 (file)
@@ -49,16 +49,6 @@ USE: words
 : image "image" get ;
 : emit ( cell -- ) image vector-push ;
 
-: lo/hi64 ( long -- hi lo )
-    dup
-    -32 shift
-    HEX: ffffffff bitand
-    swap
-    HEX: ffffffff bitand ;
-
-: emit64 ( bignum -- )
-    lo/hi64 "big-endian" get [ swap ] when emit emit ;
-
 : fixup ( value offset -- ) image set-vector-nth ;
 
 ( Object memory )
@@ -66,7 +56,8 @@ USE: words
 : image-magic HEX: 0f0e0d0c ;
 : image-version 0 ;
 
-: cell ( we're compiling for a 32-bit system ) 4 ;
+: cell "64-bits" get 8 4 ? ;
+: char "64-bits" get 4 2 ? ;
 
 : tag-mask BIN: 111 ;
 : tag-bits 3 ;
@@ -129,14 +120,6 @@ USE: words
 
 : 'fixnum ( n -- tagged ) fixnum-tag immediate ;
 
-( Floats )
-
-: 'float ( f -- tagged )
-    object-tag here-as >r
-    float-type >header emit
-    0 emit ( alignment -- FIXME 64-bit arch )
-    float>bits emit64 r> ;
-
 ( Bignums )
 
 : 'bignum ( bignum -- tagged )
@@ -222,24 +205,22 @@ DEFER: '
 
 ( Strings )
 
-: pack ( n n -- )
-    "big-endian" get [ swap ] when 16 shift bitor emit ;
+: pad-string ( n str -- )
+    tuck str-length - CHAR: \0 fill cat2 ;
 
-: pack-at ( n str -- )
-    2dup str-nth rot succ rot str-nth pack ;
+: emit-string ( str -- )
+    "big-endian" get [ str-reverse ] unless
+    0 swap [ swap 16 shift + ] str-each emit ;
 
-: (pack-string) ( n str -- )
-    2dup str-length >= [
-        2drop
-    ] [
-        2dup str-length pred = [
-            2dup str-nth 0 pack
-        ] [
-            2dup pack-at
-        ] ifte >r 2 + r> (pack-string)
-    ] ifte ;
+: (pack-string) ( n list -- )
+    #! Emit bytes for a string, with n characters per word.
+    [
+        2dup str-length < [ dupd pad-string ] when
+        emit-string
+    ] each drop ;
 
-: pack-string ( str -- ) 0 swap (pack-string) ;
+: pack-string ( string -- )
+    char tuck swap split-n (pack-string) ;
 
 : string, ( string -- )
     object-tag here-as swap
@@ -327,7 +308,6 @@ IN: cross-compiler
     [
         [ fixnum?  ] [ 'fixnum      ]
         [ bignum?  ] [ 'bignum      ]
-        [ float?   ] [ 'float       ]
         [ ratio?   ] [ 'ratio       ]
         [ complex? ] [ 'complex     ]
         [ word?    ] [ 'word        ]
@@ -355,10 +335,18 @@ IN: cross-compiler
 ( Image output )
 
 : write-word ( word -- )
-    "big-endian" get [
-        write-big-endian-32
+    "64-bits" get [
+        "big-endian" get [
+            write-big-endian-64
+        ] [
+            write-little-endian-64
+        ] ifte
     ] [
-        write-little-endian-32
+         "big-endian" get [
+            write-big-endian-32
+        ] [
+            write-little-endian-32
+        ] ifte
     ] ifte ;
 
 : write-image ( image file -- )
index 78286e5d76d4a550edfbcff3f472d6a313074789..389e6e6716aaa692e55ac6ac1627a09ea65d8b87 100644 (file)
@@ -38,14 +38,6 @@ USE: stack
 : odd? 2 mod 1 = ;
 : even? 2 mod 0 = ;
 
-: i #{ 0 1 } ; inline
-: -i #{ 0 -1 } ; inline
-: inf 1.0 0.0 / ; inline
-: -inf -1.0 0.0 / ; inline
-: e 2.7182818284590452354 ; inline
-: pi 3.14159265358979323846 ; inline
-: pi/2 1.5707963267948966 ; inline
-
 : f>0 ( obj -- obj )
     #! If f at the top of the stack, turn it into 0.
     f 0 replace ;
@@ -71,7 +63,3 @@ USE: stack
 
 : neg 0 swap - ; inline
 : recip 1 swap / ; inline
-
-: deg2rad pi * 180 / ;
-
-: rad2deg 180 * pi / ;
index e7509f127ce37dbe2ebe9999a6c165d61dc6139b..44576af3b0c8a378af814ada502a9d537affe375 100644 (file)
@@ -38,6 +38,9 @@ USE: stack
 ! Hyperbolic functions:
 !    cosh sech sinh cosech tanh coth
 
+: deg2rad pi * 180 / ;
+: rad2deg 180 * pi / ;
+
 : cos ( z -- cos )
     >rect 2dup
     fcosh swap fcos * -rot
index b986dffe552b3cdb7f1405d9493e954a451f7bb2..b49932627d555212265a85e2789dddda45eb6b48 100644 (file)
@@ -77,6 +77,7 @@ USE: parser
 
 !!! Math library.
 "/library/platform/jvm/real-math.factor" run-resource ! real-math
+"/library/math/constants.factor"         run-resource ! math
 "/library/math/math.factor"              run-resource ! math
 "/library/math/pow.factor"               run-resource ! math
 "/library/math/trig-hyp.factor"          run-resource ! math
index 11c3ed665eabebb07cd6d6c1004f08d1497784a7..b38d0a12892631d2c0b13fff347edf24153f1a8e 100644 (file)
@@ -81,6 +81,7 @@ USE: stdio
     "/library/debugger.factor"
     "/library/platform/native/init.factor"
 
+    "/library/math/constants.factor"
     "/library/math/math.factor"
     "/library/platform/native/math.factor"
     "/library/math/pow.factor"
index 17542bcac5fc22c753dd2fa3c86ac24a78182895..9e724952eaab5cc8515d32b05ec3f3fba5fb3fdf 100644 (file)
@@ -87,3 +87,20 @@ USE: stack
     #! Split the string at each occurrence of split, and push a
     #! list of the pieces.
     [, 0 -rot (split) ,] ;
+
+: split-n-advance substring , >r tuck + swap r> ;
+: split-n-finish nip dup str-length swap substring , ;
+
+: (split-n) ( start n str -- )
+    3dup >r dupd + r> 2dup str-length < [
+        split-n-advance (split-n)
+    ] [
+        split-n-finish 3drop
+    ] ifte ;
+
+: split-n ( n str -- list )
+    #! Split a string into n-character chunks.
+    [, 0 -rot (split-n) ,] ;
+
+: str-reverse ( str -- str )
+    str>sbuf dup sbuf-reverse sbuf>str ;
index 51e0296a75bd5094d1d1e7f4c90ceea6d185e040..52b3112a96132b95ed47040507af090111c238a1 100644 (file)
@@ -43,11 +43,35 @@ USE: strings
     read1 8  shift bitor
     read1          bitor ;
 
+: byte7 ( num -- byte ) -56 shift HEX: ff bitand ;
+: byte6 ( num -- byte ) -48 shift HEX: ff bitand ;
+: byte5 ( num -- byte ) -40 shift HEX: ff bitand ;
+: byte4 ( num -- byte ) -32 shift HEX: ff bitand ;
 : byte3 ( num -- byte ) -24 shift HEX: ff bitand ;
 : byte2 ( num -- byte ) -16 shift HEX: ff bitand ;
 : byte1 ( num -- byte )  -8 shift HEX: ff bitand ;
 : byte0 ( num -- byte )           HEX: ff bitand ;
 
+: write-little-endian-64 ( word -- )
+    dup byte0 >char write
+    dup byte1 >char write
+    dup byte2 >char write
+    dup byte3 >char write
+    dup byte4 >char write
+    dup byte5 >char write
+    dup byte6 >char write
+        byte7 >char write ;
+
+: write-big-endian-64 ( word -- )
+    dup byte7 >char write
+    dup byte6 >char write
+    dup byte5 >char write
+    dup byte4 >char write
+    dup byte3 >char write
+    dup byte2 >char write
+    dup byte1 >char write
+        byte0 >char write ;
+
 : write-little-endian-32 ( word -- )
     dup byte0 >char write
     dup byte1 >char write
index 84909640520dca6cb54c4a6aa2528c932b857efb..07fa8e6ccc6b135bce7da8edd75a2a7218fd79a5 100644 (file)
@@ -85,8 +85,8 @@ unit-test
 [ t ] [ "abc" "abd" str-compare 0 < ] unit-test
 [ t ] [ "z" "abd" str-compare 0 > ] unit-test
 
-[ "fedcba" ] [ "abcdef" str>sbuf dup sbuf-reverse sbuf>str ] unit-test
-[ "edcba" ] [ "abcde" str>sbuf dup sbuf-reverse sbuf>str ] unit-test
+[ "fedcba" ] [ "abcdef" str-reverse ] unit-test
+[ "edcba" ] [ "abcde" str-reverse ] unit-test
 
 native? [
     [ t ] [ "Foo" str>sbuf "Foo" str>sbuf = ] unit-test
@@ -103,3 +103,5 @@ native? [
 ] when
 
 [ f ] [ [ 0 10 "hello" substring ] [ not ] catch ] unit-test
+
+[ [ "hell" "o wo" "rld" ] ] [ 4 "hello world" split-n ] unit-test
index 0df4f2cf2dbc67efb70ded6a579c32384b4c2072..f6f650751744f65aa10069a8d8177c41c9c11d37 100644 (file)
@@ -37,7 +37,7 @@ void throw_error(CELL error)
 
 void general_error(CELL error, CELL tagged)
 {
-       CELL c = cons(error,tag_cons(cons(tagged,F)));
+       CELL c = cons(error,cons(tagged,F));
        if(userenv[BREAK_ENV] == 0)
        {
                /* Crash at startup */
@@ -57,7 +57,7 @@ void general_error(CELL error, CELL tagged)
 
 void type_error(CELL type, CELL tagged)
 {
-       CELL c = cons(tag_fixnum(type),tag_cons(cons(tagged,F)));
+       CELL c = cons(tag_fixnum(type),cons(tagged,F));
        general_error(ERROR_TYPE,c);
 }
 
index 5740fdedbd4e3fcfd36103298da6171c065a39bc..ac1e1468d28b510fea1df4fc5590b31d2aaa832a 100644 (file)
@@ -54,14 +54,15 @@ CELL subtract_fixnum(FIXNUM x, FIXNUM y)
  */
 CELL multiply_fixnum(FIXNUM x, FIXNUM y)
 {
+       FIXNUM prod;
+
        if(x == 0 || y == 0)
                return tag_fixnum(0);
-       else
-       {
-               FIXNUM prod = x * y;
-               if(prod / x == y)
-                       return tag_integer(prod);
-       }
+
+       prod = x * y;
+       /* if this is not equal, we have overflow */
+       if(prod / x == y)
+               return tag_integer(prod);
 
        return tag_object(
                s48_bignum_multiply(
index 86bccaa21d49312e5c4731c825733b241f4e3c98..07b7c4bdb9c036fbb6d17f42c0366e989d557ebe 100644 (file)
@@ -1,9 +1,5 @@
 typedef struct {
        CELL header;
-/* FIXME */
-#ifndef FACTOR_64
-       CELL alignment;
-#endif
        double n;
 } FLOAT;