]> gitweb.factorcode.org Git - factor.git/commitdiff
don't use esi for data stack anymore; os word pushes unix or win32; don't use ansi...
authorSlava Pestov <slava@factorcode.org>
Mon, 13 Dec 2004 20:37:50 +0000 (20:37 +0000)
committerSlava Pestov <slava@factorcode.org>
Mon, 13 Dec 2004 20:37:50 +0000 (20:37 +0000)
TODO.FACTOR.txt
library/bootstrap/init-stage2.factor
library/compiler/generator-x86.factor
library/kernel.factor
library/test/words.factor
library/tools/listener.factor
native/factor.c
native/factor.h
native/run.h

index 6506c2c6b0bb3d2982af1ae27dbde5fea6968332..757b6651fde3fe3730a5b86c33af5a5a9907712e 100644 (file)
 - save code in image\r
 - compile word twice; no more 'cannot compile' error!\r
 \r
++ oop:
+
+- union metaclass
+- make M: order-independent
+- bootstrapping generic words
+- 2generic
+- move generic, 2generic from kernel vocabulary
+- generic = hashcode and math ops
+
 + ffi:\r
 \r
 - is signed -vs- unsigned pointers an issue?\r
@@ -66,7 +75,6 @@
 - jedit ==> jedit-word, jedit takes a file name\r
 - command line parsing cleanup\r
 - nicer way to combine two paths\r
-- finish OOP\r
 - ditch object paths\r
 - browser responder for word links in HTTPd; inspect responder for\r
   objects\r
index e2ac48460406c22823a2869964530b6d05846129..f8efb60347b75fe8d75df81d18e57a60546622a3 100644 (file)
@@ -58,7 +58,8 @@ USE: unparser
     ! -no-<flag> CLI switch
     t "user-init" set
     t "interactive" set
-    t "ansi" set
+    ! We don't want ANSI escape codes on Windows
+    os "unix" = "ansi" set
     t "compile" set
 
     ! The first CLI arg is the image name.
index 2a840b6e48bf78aafc3dd0b42895bbc9ea0b4054..8b3ae3228289a81472a9228ecba97fd91a1b0e54 100644 (file)
@@ -37,26 +37,50 @@ USE: strings
 USE: words
 USE: vectors
 
+: DS ( -- address ) "ds" dlsym-self ;
+
 : PUSH-DS ( -- )
     #! Push contents of EAX onto datastack.
-    4 ESI R+I
-    EAX ESI R>[R] ;
+    DS ECX [I]>R
+    4 ECX R+I
+    EAX ECX R>[R]
+    ECX DS R>[I] ;
 
 : POP-DS ( -- )
-    #! Pop datastack, store pointer to datastack top in EAX.
-    ESI EAX [R]>R
-    4 ESI R-I ;
+    #! Pop datastack to EAX.
+    DS ECX [I]>R
+    ECX EAX [R]>R
+    4 ECX R-I
+    ECX DS R>[I] ;
+
+: PEEK-DS ( -- )
+    #! Peek datastack to EAX.
+    DS ECX [I]>R
+    ECX EAX [R]>R ;
+
+: PEEK-2-DS ( -- )
+    #! Peek second value on datastack to EAX.
+    DS ECX [I]>R
+    4 ECX R-I
+    ECX EAX [R]>R ;
 
 : SELF-CALL ( name -- )
     #! Call named C function in Factor interpreter executable.
     dlsym-self CALL JUMP-FIXUP ;
 
 #push-immediate [
-    address  4 ESI R+I  ESI I>[R]
+    DS ECX [I]>R
+    4 ECX R+I
+    address  ECX I>[R]
+    ECX DS R>[I]
 ] "generator" set-word-property
 
 #push-indirect [
-    intern-literal 4 ESI R+I  EAX [I]>R  EAX ESI R>[R]
+    DS ECX [I]>R
+    4 ECX R+I
+    intern-literal EAX [I]>R
+    EAX ECX R>[R]
+    ECX DS R>[I]
 ] "generator" set-word-property
 
 #call [
@@ -86,20 +110,19 @@ USE: vectors
 
 #return [ drop RET ] "generator" set-word-property
 
-#drop [ drop  4 ESI R-I ] "generator" set-word-property
-#dup [
-    drop
-    ESI EAX [R]>R
-    4 ESI R+I
-    EAX ESI R>[R]
-] "generator" set-word-property
-
-! This is crap
-#swap [ drop \ swap CALL compiled-offset defer-xt ] "generator" set-word-property
-#over [ drop \ over CALL compiled-offset defer-xt ] "generator" set-word-property
-#pick [ drop \ pick CALL compiled-offset defer-xt ] "generator" set-word-property
-#>r [ drop \ >r CALL compiled-offset defer-xt ] "generator" set-word-property
-#r> [ drop \ r> CALL compiled-offset defer-xt ] "generator" set-word-property
+[
+    [ #drop drop ]
+    [ #dup  dup  ]
+    [ #swap swap ]
+    [ #over over ]
+    [ #pick pick ]
+    [ #>r   >r   ]
+    [ #r>   r>   ]
+] [
+    uncons [
+        car CALL compiled-offset defer-xt drop
+    ] cons "generator" set-word-property
+] each
 
 : begin-jump-table ( -- )
     #! Compile a piece of code that jumps to an offset in a
@@ -130,7 +153,8 @@ USE: vectors
 
 : TYPE ( -- )
     #! Peek datastack, store type # in EAX.
-    ESI PUSH-[R]
+    PEEK-DS
+    EAX PUSH-R
     "type_of" SELF-CALL
     4 ESP R+I ;
 
@@ -144,10 +168,10 @@ USE: vectors
 
 : ARITHMETIC-TYPE ( -- )
     #! Peek top two on datastack, store arithmetic type # in EAX.
-    ESI EAX R>R
-    EAX PUSH-[R]
-    4 EAX R-I
-    EAX PUSH-[R]
+    PEEK-DS
+    EAX PUSH-R
+    PEEK-2-DS
+    EAX PUSH-R
     "arithmetic_type" SELF-CALL
     8 ESP R+I ;
 
index 16af76fa482f11ae4cf71384998cfb8306f84b04..47c8df51eb786272c8f97a994db85ba14194e12e 100644 (file)
@@ -42,6 +42,10 @@ USE: vectors
     #! Returns one of "x86" or "unknown".
     7 getenv ;
 
+: os ( -- arch )
+    #! Returns one of "unix" or "win32".
+    11 getenv ;
+
 ! The 'fake vtable' used here speeds things up a lot.
 ! It is quite clumsy, however. A higher-level CLOS-style
 ! 'generic words' system will be built later.
index 783b571b23563542bd4372ba6e77d9c0336cce68..92a159aed7c416c4a1d23f71f3b0e5bf05eebf77 100644 (file)
@@ -28,10 +28,6 @@ DEFER: plist-test
     \ plist-test "sample-property" word-property
 ] unit-test
 
-: test-last ( -- ) ;
-word word-name "last-word-test" set
-
-[ "test-last" ] [ ] [ "last-word-test" get ] test-word
 [ f ] [ 5 ] [ compound? ] test-word
 
 "create-test" "scratchpad" create { 1 2 } "testing" set-word-property
@@ -64,3 +60,8 @@ word word-name "last-word-test" set
 SYMBOL: a-symbol
 [ f ] [ \ a-symbol compound? ] unit-test
 [ t ] [ \ a-symbol symbol? ] unit-test
+
+: test-last ( -- ) ;
+word word-name "last-word-test" set
+
+[ "test-last" ] [ ] [ "last-word-test" get ] test-word
index e18333780d42b9ce608aa0b6bfcaa9a8d397107d..97ff6c200d03fd4cfa15dfcf9de1e4b60c597957 100644 (file)
@@ -100,7 +100,10 @@ global [
     "Code space: " write (room.) ;
 
 : print-banner ( -- )
-    "Factor " write version print
+    "Factor " write version write
+    " (OS: " write os write
+    " CPU: " write cpu write
+    ")" print
     "Copyright (C) 2003, 2004 Slava Pestov" print
     "Copyright (C) 2004 Chris Double" print
     "Copyright (C) 2004 Mackenzie Straight" print
index f18c56b25998452862a07e67647c1c66a197142a..644b045e25c04e8f250df0ed9430f009d06a4249 100644 (file)
@@ -17,6 +17,12 @@ void init_factor(char* image)
 #else
        userenv[CPU_ENV] = tag_object(from_c_string("unknown"));
 #endif
+
+#ifdef WIN32
+       userenv[OS_ENV] = tag_object(from_c_string("win32"));
+#else
+       userenv[OS_ENV] = tag_object(from_c_string("unix"));
+#endif
 }
 
 int main(int argc, char** argv)
index 051e56a68643bfc22d4a6ea428cfcabdae7687a5..78c56fe4ac94ad0bc1b3f6badbe1797291716e1b 100644 (file)
@@ -13,11 +13,7 @@ typedef unsigned long int CELL;
 CELL ds_bot;
 
 /* raw pointer to datastack top */
-#ifdef FACTOR_X86
-register CELL ds asm("%esi");
-#else
 CELL ds;
-#endif
 
 /* raw pointer to callstack bottom */
 CELL cs_bot;
index 3d44de60a4207e5f099621a586e2cbb31a0fc86e..2a5d4691f4cce22ce7f1a2ca98ca169830c936c5 100644 (file)
@@ -11,6 +11,7 @@
 #define BOOT_ENV       8
 #define RUNQUEUE_ENV   9 /* used by library only */
 #define ARGS_ENV       10
+#define OS_ENV         11
 
 /* Profiling timer */
 #ifndef WIN32