]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'startup'
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 15 Nov 2009 21:07:07 +0000 (15:07 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 15 Nov 2009 21:07:07 +0000 (15:07 -0600)
basis/alien/c-types/c-types.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/specialized-arrays/specialized-arrays-tests.factor
extra/io/serial/unix/termios/bsd/bsd.factor
extra/io/serial/unix/termios/linux/linux.factor
extra/monotonic-clock/windows/windows.factor

index 027fe046b62aa9d82b05c0104f481b09d737dcf7..a029158be5015c345dcb2e2aba04e261133d27f7 100755 (executable)
@@ -218,13 +218,13 @@ M: c-type-name unbox-return c-type unbox-return ;
 
 : little-endian? ( -- ? ) 1 <int> *char 1 = ; foldable
 
-GENERIC: heap-size ( name -- size ) foldable
+GENERIC: heap-size ( name -- size )
 
 M: c-type-name heap-size c-type heap-size ;
 
 M: abstract-c-type heap-size size>> ;
 
-GENERIC: stack-size ( name -- size ) foldable
+GENERIC: stack-size ( name -- size )
 
 M: c-type-name stack-size c-type stack-size ;
 
index 5aa490bfd3c26a9219ec41d751fb3dba1098a7d0..809b51c6ef64128acb1e0d8360acc1f568bafc16 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences words fry generic accessors
+USING: alien.c-types kernel sequences words fry generic accessors
 classes.tuple classes classes.algebra definitions
 stack-checker.dependencies quotations classes.tuple.private math
 math.partial-dispatch math.private math.intervals sets.private
@@ -8,6 +8,7 @@ math.floats.private math.integers.private layouts math.order
 vectors hashtables combinators effects generalizations assocs
 sets combinators.short-circuit sequences.private locals growable
 stack-checker namespaces compiler.tree.propagation.info ;
+FROM: math => float ;
 IN: compiler.tree.propagation.transforms
 
 \ equal? [
@@ -307,3 +308,11 @@ CONSTANT: lookup-table-at-max 256
     in-d>> second value-info class>> growable class<=
     [ \ push def>> ] [ f ] if
 ] "custom-inlining" set-word-prop
+
+! We want to constant-fold calls to heap-size, and recompile those
+! calls when a C type is redefined
+\ heap-size [
+    dup word? [
+        [ inlined-dependency depends-on ] [ heap-size '[ _ ] ] bi
+    ] [ drop f ] if
+] 1 define-partial-eval
index bc293b19e0342a1c7b7d16e10a91888c6242c0d9..dd561e9d468e4b4ce0f8c9230af3381b6f797b39 100755 (executable)
@@ -153,3 +153,22 @@ SPECIALIZED-ARRAY: __does_not_exist__
         __does_not_exist__ specialized-array-vocab forget-vocab
     ] with-compilation-unit
 ] unit-test
+
+STRUCT: struct-resize-test { x int } ;
+
+SPECIALIZED-ARRAY: struct-resize-test
+
+[ 40 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+: struct-resize-test-usage ( seq -- seq )
+    [ struct-resize-test <struct> swap >>x ] map
+    >struct-resize-test-array
+    [ x>> ] { } map-as ;
+    
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
+
+[ ] [ "IN: specialized-arrays.tests USE: classes.struct USE: alien.c-types STRUCT: struct-resize-test { x int } { y int } ;" eval( -- ) ] unit-test
+
+[ 80 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
index 1d1e217ba0ce9ee9102749da0c1366fcd8e6b49d..172786126914ed5e37c54c1add614a6ce03964f0 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel sequences system ;
+USING: alien.c-types alien.syntax classes.struct kernel
+sequences system ;
 IN: io.serial.unix.termios
 
 CONSTANT: NCCS 20
index 0982339cf8994913072a4105f018ad86f858c191..1e9dce49c7174248846dfe570b2e31dd2cfaa4d8 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel system unix ;
+USING: alien.c-types alien.syntax classes.struct kernel system
+unix ;
 IN: io.serial.unix.termios
 
 CONSTANT: NCCS 32
index 85732e32fda35215aa1cbea8fd5e9a587ccad935..bb4794147990b7ea3073003e4c24236513c242f2 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types alien.data fry kernel monotonic-clock
-system windows.errors windows.kernel32 ;
+system windows.errors windows.kernel32 math ;
 IN: monotonic-clock.windows
 
 <PRIVATE
@@ -12,8 +12,9 @@ IN: monotonic-clock.windows
 
 PRIVATE>
 
-M: windows monotonic-count  ( -- n )
-    \ QueryPerformanceCounter execute-performance-query ;
-
 : cpu-frequency ( -- n )
     \ QueryPerformanceFrequency execute-performance-query ;
+
+M: windows monotonic-count  ( -- n )
+    \ QueryPerformanceCounter execute-performance-query
+    1000000000 * cpu-frequency /i ;