Merge git://factorcode.org/git/factor

release
Doug Coleman 2007-10-10 03:16:53 -05:00
commit e4af48791b
49 changed files with 1086 additions and 68 deletions

View File

@ -27,11 +27,11 @@ GENERIC: alien-node-abi ( node -- str )
: alien-node-return* ( node -- ctype )
alien-node-return dup large-struct? [ drop "void" ] when ;
: c-type-stack-align ( type -- align )
dup c-type-stack-align? [ c-type-align ] [ drop cell ] if ;
: parameter-align ( n type -- n delta )
over >r
dup c-type-stack-align? [ c-type-align ] [ drop cell ] if
align
dup r> - ;
over >r c-type-stack-align align dup r> - ;
: parameter-sizes ( types -- total offsets )
#! Compute stack frame locations.
@ -91,24 +91,33 @@ M: float-regs inc-reg-class
[ dup class get swap inc-reg-class ] keep ;
: alloc-parameter ( parameter -- reg reg-class )
c-type c-type-reg-class dup reg-class-full?
c-type-reg-class dup reg-class-full?
[ spill-param ] [ fastcall-param ] if
[ param-reg ] keep ;
: (flatten-int-type) ( size -- )
cell /i "void*" <repetition> % ;
cell /i "void*" c-type <repetition> % ;
: flatten-int-type ( n type -- n )
[ parameter-align (flatten-int-type) ] keep
stack-size cell align dup (flatten-int-type) + ;
GENERIC: flatten-value-type ( type -- )
: flatten-value-type ( n type -- n )
dup c-type c-type-reg-class T{ int-regs } =
[ flatten-int-type ] [ , ] if ;
M: object flatten-value-type , ;
M: struct-type flatten-value-type ( type -- )
stack-size cell align (flatten-int-type) ;
M: long-long-type flatten-value-type ( type -- )
stack-size cell align (flatten-int-type) ;
: flatten-value-types ( params -- params )
#! Convert value type structs to consecutive void*s.
[ 0 [ flatten-value-type ] reduce drop ] { } make ;
[
0 [
c-type
[ parameter-align (flatten-int-type) ] keep
[ stack-size cell align + ] keep
flatten-value-type
] reduce drop
] { } make ;
: each-parameter ( parameters quot -- )
>r [ parameter-sizes nip ] keep r> 2each ; inline
@ -127,11 +136,11 @@ M: float-regs inc-reg-class
#! Moves values from C stack to registers (if word is
#! %load-param-reg) and registers to C stack (if word is
#! %save-param-reg).
swap
>r
alien-node-parameters*
flatten-value-types
[ pick >r alloc-parameter r> execute ] each-parameter
drop ; inline
r> [ >r alloc-parameter r> execute ] curry each-parameter ;
inline
: if-void ( type true false -- )
pick "void" = [ drop nip call ] [ nip call ] if ; inline

View File

@ -260,7 +260,7 @@ H{ } clone update-map set
{ "<tuple>" "tuples.private" }
{ "tuple>array" "tuples" }
{ "profiling" "tools.profiler.private" }
{ "become" "tuples.private" }
{ "become" "kernel.private" }
{ "(sleep)" "threads.private" }
{ "<float-array>" "float-arrays" }
{ "curry" "kernel" }
@ -271,6 +271,7 @@ H{ } clone update-map set
{ "innermost-frame-scan" "kernel.private" }
{ "set-innermost-frame-quot" "kernel.private" }
{ "call-clear" "kernel" }
{ "strip-compiled-quotations" "quotations" }
}
dup length [ >r first2 r> make-primitive ] 2each

View File

@ -234,6 +234,50 @@ FUNCTION: test-struct-7 ffi_test_30 ;
[ B{ 1 2 3 4 5 6 7 } ] [ ffi_test_30 ] unit-test
C-STRUCT: test-struct-8 { "double" "x" } { "double" "y" } ;
FUNCTION: double ffi_test_32 test-struct-8 x int y ;
[ 9.0 ] [
"test-struct-8" <c-object>
1.0 over set-test-struct-8-x
2.0 over set-test-struct-8-y
3 ffi_test_32
] unit-test
C-STRUCT: test-struct-9 { "float" "x" } { "float" "y" } ;
FUNCTION: double ffi_test_33 test-struct-9 x int y ;
[ 9.0 ] [
"test-struct-9" <c-object>
1.0 over set-test-struct-9-x
2.0 over set-test-struct-9-y
3 ffi_test_33
] unit-test
C-STRUCT: test-struct-10 { "float" "x" } { "int" "y" } ;
FUNCTION: double ffi_test_34 test-struct-10 x int y ;
[ 9.0 ] [
"test-struct-10" <c-object>
1.0 over set-test-struct-10-x
2 over set-test-struct-10-y
3 ffi_test_34
] unit-test
C-STRUCT: test-struct-11 { "int" "x" } { "int" "y" } ;
FUNCTION: double ffi_test_35 test-struct-11 x int y ;
[ 9.0 ] [
"test-struct-11" <c-object>
1 over set-test-struct-11-x
2 over set-test-struct-11-y
3 ffi_test_35
] unit-test
! Test callbacks
: callback-1 "void" { } "cdecl" [ ] alien-callback ;

View File

@ -273,3 +273,9 @@ USE: sorting.private
10 20 >vector <flat-slice>
[ [ - ] swap old-binsearch ] compile-1 2nip
] unit-test
! Regression
[ 1 2 { real imaginary } ] [
C{ 1 2 }
[ { real imaginary } [ get-slots ] keep ] compile-1
] unit-test

View File

@ -4,7 +4,7 @@ USING: alien.c-types arrays cpu.x86.assembler
cpu.x86.architecture cpu.x86.intrinsics cpu.x86.sse2
cpu.x86.allot cpu.architecture kernel kernel.private math
namespaces sequences generator.registers generator.fixup system
alien ;
alien alien.compiler alien.structs slots splitting math.functions ;
IN: cpu.x86.64
PREDICATE: x86-backend amd64-backend
@ -175,3 +175,32 @@ USE: cpu.x86.intrinsics
\ set-alien-signed-4 small-reg-32 define-setter
T{ x86-backend f 8 } compiler-backend set-global
! The ABI for passing structs by value is pretty messed up
"void*" c-type clone "__stack_value" define-primitive-type
T{ stack-params } "__stack_value" c-type set-c-type-reg-class
: struct-types&offset ( struct-type -- pairs )
struct-type-fields [
dup slot-spec-type swap slot-spec-offset 2array
] map ;
: split-struct ( pairs -- seq )
[
[ first2 8 mod zero? [ t , ] when , ] each
] { } make { t } split [ empty? not ] subset ;
: flatten-large-struct ( type -- )
heap-size cell align
cell /i "__stack_value" c-type <repetition> % ;
M: struct-type flatten-value-type ( type -- seq )
dup heap-size 16 > [
flatten-large-struct
] [
struct-types&offset split-struct [
[ c-type c-type-reg-class ] map
T{ int-regs } swap member?
"void*" "double" ? c-type ,
] each
] if ;

View File

@ -0,0 +1,39 @@
IN: temporary
USING: tools.test generic kernel definitions sequences ;
TUPLE: combination-1 ;
M: combination-1 perform-combination 2drop { } [ ] each [ ] ;
SYMBOL: generic-1
generic-1 T{ combination-1 } define-generic
[ ] <method> object \ generic-1 define-method
[ ] [ { combination-1 { object generic-1 } } forget-all ] unit-test
GENERIC: some-generic
USE: arrays
M: array some-generic ;
USE: bit-arrays
M: bit-array some-generic ;
USE: byte-arrays
M: byte-array some-generic ;
TUPLE: some-class ;
M: some-class some-generic ;
TUPLE: another-class some-generic ;
[ ] [
{ some-generic some-class { another-class some-generic } }
forget-all
] unit-test

View File

@ -13,6 +13,8 @@ GENERIC: forget ( defspec -- )
M: object forget drop ;
: forget-all ( definitions -- ) [ forget ] each ;
GENERIC: synopsis* ( defspec -- )
GENERIC: definer ( defspec -- start end )

View File

@ -14,6 +14,15 @@ M: generic definition drop f ;
GENERIC: perform-combination ( word combination -- quot )
M: object perform-combination
#! We delay the invalid method combination error for a
#! reason. If we call forget-vocab on a vocabulary which
#! defines a method combination, a generic using this
#! method combination, and a method on the generic, and the
#! method combination is forgotten first, then forgetting
#! the method will throw an error. We don't want that.
nip [ "Invalid method combination" throw ] curry ;
: make-generic ( word -- )
dup
dup "combination" word-prop perform-combination
@ -94,7 +103,7 @@ M: method-spec forget first2 [ delete-at ] with-methods ;
dup associate implementors* ;
: forget-methods ( class -- )
[ implementors ] keep [ swap 2array forget ] curry each ;
[ implementors ] keep [ swap 2array ] curry map forget-all ;
M: class forget ( class -- )
dup forget-methods

View File

@ -347,6 +347,9 @@ DEFER: bar
[ t ] [ [ [ r> ] infer short-effect ] catch inference-error? ] unit-test
! Regression
[ t ] [ [ [ get-slots ] infer ] catch inference-error? ] unit-test
! Test some curry stuff
[ { 1 1 } ] [ [ 3 [ ] curry 4 [ ] curry if ] infer short-effect ] unit-test

View File

@ -6,12 +6,11 @@ inference.dataflow tuples.private ;
IN: inference.transforms
: pop-literals ( n -- rstate seq )
dup zero? [ drop recursive-state get f ] [
[ ensure-values ] keep
[ d-tail ] keep
(consume-values)
dup [ value-literal ] map
swap first value-recursion swap
dup zero? [
drop recursive-state get { }
] [
dup ensure-values
f swap [ 2drop pop-literal ] map reverse
] if ;
: transform-quot ( quot n -- newquot )

View File

@ -1,7 +1,9 @@
! Copyright (C) 2005, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: memory
USING: arrays kernel sequences vectors system ;
USING: arrays kernel sequences vectors system hashtables
kernel.private sbufs growable assocs namespaces quotations
math strings combinators ;
: (each-object) ( quot -- )
next-object dup
@ -14,3 +16,29 @@ USING: arrays kernel sequences vectors system ;
pusher >r each-object r> >array ; inline
: save ( -- ) image save-image ;
<PRIVATE
: intern-objects ( predicate -- )
instances
dup H{ } clone [ [ ] cache ] curry map
become ; inline
: prepare-compress-image ( -- seq )
[ sbuf? ] instances [ underlying ] map ;
PRIVATE>
: compress-image ( -- )
prepare-compress-image "bad-strings" [
[
{
{ [ dup quotation? ] [ t ] }
{ [ dup wrapper? ] [ t ] }
{ [ dup fixnum? ] [ f ] }
{ [ dup number? ] [ t ] }
{ [ dup string? ] [ dup "bad-strings" get memq? not ] }
{ [ t ] [ f ] }
} cond nip
] intern-objects
] with-variable ;

View File

@ -416,7 +416,7 @@ SYMBOL: parse-hook
] keep ;
: forget-smudged ( -- )
smudged-usage [ forget ] each
smudged-usage forget-all
over empty? [ 2dup smudged-usage-warning ] unless 2drop ;
: record-definitions ( file -- )

View File

@ -299,3 +299,7 @@ unit-test
[ 2 break 2 \ + (step-into) . ] (remove-breakpoints)
] unit-test
[ [ 2 . ] ] [
[ 2 \ break (step-into) . ] (remove-breakpoints)
] unit-test

View File

@ -99,7 +99,12 @@ SYMBOL: ->
building get dup empty? [
drop \ (step-into) ,
] [
pop dup wrapper? [ wrapped ] when ,
pop dup wrapper? [
wrapped dup \ break eq?
[ drop ] [ , ] if
] [
,
] if
] if ;
: (remove-breakpoints) ( quot -- newquot )

View File

@ -71,7 +71,7 @@ M: pathname where pathname-string 1 2array ;
: forget-source ( path -- )
dup source-file
dup unxref-source
source-file-definitions [ drop forget ] assoc-each
source-file-definitions keys forget-all
source-files get delete-at ;
M: pathname forget pathname-string forget-source ;

View File

@ -76,7 +76,7 @@ SYMBOL: load-vocab-hook
[ ] subset ;
: forget-vocab ( vocab -- )
dup vocab-words [ nip forget ] assoc-each
dup vocab-words values forget-all
vocab-name dictionary get delete-at ;
: child-vocab? ( prefix name -- ? )

View File

@ -6,14 +6,14 @@ slots.private math namespaces sequences strings vectors sbufs
quotations assocs hashtables sorting math.parser words.private
vocabs ;
GENERIC: execute ( word -- )
M: word execute (execute) ;
: word ( -- word ) \ word get-global ;
: set-word ( word -- ) \ word set-global ;
GENERIC: execute ( word -- )
M: word execute (execute) ;
! Used by the compiler
SYMBOL: changed-words
@ -201,7 +201,6 @@ M: word (forget-word)
reveal ;
: forget-word ( word -- )
dup f "methods" set-word-prop
dup delete-xref
dup unchanged-word
(forget-word) ;

View File

@ -0,0 +1,16 @@
USING: tools.deploy.config ;
V{
{ strip-prettyprint? t }
{ strip-globals? t }
{ strip-word-props? t }
{ strip-word-names? t }
{ strip-dictionary? t }
{ strip-debugger? t }
{ strip-c-types? t }
{ deploy-math? t }
{ deploy-compiled? t }
{ deploy-io? f }
{ deploy-ui? t }
{ "stop-after-last-window?" t }
{ "bundle-name" "Cellular Automata.app" }
}

View File

@ -0,0 +1,13 @@
USING: tools.deploy.config ;
V{
{ strip-word-props? t }
{ strip-word-names? t }
{ strip-dictionary? t }
{ strip-debugger? t }
{ strip-c-types? t }
{ deploy-math? t }
{ deploy-compiled? t }
{ deploy-io? f }
{ deploy-ui? t }
{ "bundle-name" "Boids.app" }
}

View File

@ -69,13 +69,15 @@ cond ;
! : handle-client ( client -- ) <user> dup users> push
! dup [ >user [ handle-user-loop ] with-stream* ] with-scope ;
: handle-client ( client -- ) <user> dup users> push
: handle-client ( client -- )
<user> dup users> push
dup [ >user [ handle-user-loop ] with-stream ] with-scope ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: accept-client-loop ( server -- )
dup >r accept [ handle-client ] in-thread r> accept-client-loop ;
[ accept [ handle-client ] curry in-thread ] keep
accept-client-loop ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -1,12 +1,17 @@
USING: tools.deploy.config ;
V{
{ strip-io? t }
{ strip-prettyprint? t }
{ strip-globals? t }
{ strip-word-props? t }
{ strip-word-names? t }
{ strip-dictionary? t }
{ strip-debugger? t }
{ strip-c-types? t }
{ deploy-math? t }
{ deploy-compiled? t }
{ deploy-io? f }
{ deploy-ui? t }
{ "stop-after-last-window?" t }
{ "bundle-name" "Golden Section.app" }
}

View File

@ -1,12 +1,16 @@
USING: tools.deploy.config ;
V{
{ strip-prettyprint? t }
{ strip-globals? t }
{ strip-word-props? t }
{ strip-word-names? t }
{ strip-word-names? f }
{ strip-dictionary? t }
{ strip-debugger? t }
{ strip-c-types? t }
{ deploy-math? t }
{ deploy-compiled? t }
{ deploy-io? f }
{ deploy-ui? t }
{ "stop-after-last-window?" t }
{ "bundle-name" "Hello World.app" }
}

View File

@ -1,11 +1,15 @@
USING: tools.deploy.config ;
V{
{ strip-prettyprint? t }
{ strip-globals? t }
{ strip-word-props? t }
{ strip-word-names? t }
{ strip-dictionary? t }
{ strip-debugger? t }
{ strip-c-types? t }
{ deploy-math? f }
{ deploy-compiled? f }
{ deploy-io? f }
{ deploy-ui? f }
{ "stop-after-last-window?" t }
}

View File

@ -0,0 +1,168 @@
USING: kernel namespaces arrays sequences threads math ui random bake
springies springies.ui ;
IN: springies.models.3snake
: random-range ( a b -- n ) 1+ over - random + ;
: model ( -- )
{ } clone >nodes
{ } clone >springs
0.001 >time-slice
gravity off
1 19.0 328.0 0.0 0.0 1.0 1.0 mass
2 36.0 328.0 0.0 0.0 1.0 1.0 mass
3 54.0 328.0 0.0 0.0 1.0 1.0 mass
4 72.0 328.0 0.0 0.0 1.0 1.0 mass
5 90.0 328.0 0.0 0.0 1.0 1.0 mass
6 108.0 328.0 0.0 0.0 1.0 1.0 mass
7 126.0 328.0 0.0 0.0 1.0 1.0 mass
8 144.0 328.0 0.0 0.0 1.0 1.0 mass
9 162.0 328.0 0.0 0.0 1.0 1.0 mass
10 180.0 328.0 0.0 0.0 1.0 1.0 mass
11 198.0 328.0 0.0 0.0 1.0 1.0 mass
12 216.0 328.0 0.0 0.0 1.0 1.0 mass
13 234.0 328.0 0.0 0.0 1.0 1.0 mass
14 252.0 328.0 0.0 0.0 1.0 1.0 mass
15 270.0 328.0 0.0 0.0 1.0 1.0 mass
16 288.0 328.0 0.0 0.0 1.0 1.0 mass
17 306.0 328.0 0.0 0.0 1.0 1.0 mass
18 324.0 328.0 0.0 0.0 1.0 1.0 mass
19 342.0 328.0 0.0 0.0 1.0 1.0 mass
20 360.0 328.0 0.0 0.0 1.0 1.0 mass
21 378.0 328.0 0.0 0.0 1.0 1.0 mass
22 396.0 328.0 0.0 0.0 1.0 1.0 mass
23 414.0 328.0 0.0 0.0 1.0 1.0 mass
24 432.0 328.0 0.0 0.0 1.0 1.0 mass
25 450.0 328.0 0.0 0.0 1.0 1.0 mass
26 468.0 328.0 0.0 0.0 1.0 1.0 mass
27 504.0 328.0 0.0 0.0 1.0 1.0 mass
28 486.0 328.0 0.0 0.0 1.0 1.0 mass
29 522.0 328.0 0.0 0.0 1.0 1.0 mass
30 540.0 328.0 0.0 0.0 1.0 1.0 mass
31 558.0 328.0 0.0 0.0 1.0 1.0 mass
32 576.0 328.0 0.0 0.0 1.0 1.0 mass
33 594.0 328.0 0.0 0.0 1.0 1.0 mass
34 612.0 328.0 0.0 0.0 1.0 1.0 mass
35 626.0 328.0 0.0 0.0 1.0 1.0 mass
1 1 2 200.0 1.500000 18.0 spng
2 3 2 200.0 1.500000 18.0 spng
3 3 4 200.0 1.500000 18.0 spng
4 4 5 200.0 1.500000 18.0 spng
5 5 6 200.0 1.500000 18.0 spng
6 6 7 200.0 1.500000 18.0 spng
7 7 8 200.0 1.500000 18.0 spng
8 8 9 200.0 1.500000 18.0 spng
9 9 10 200.0 1.500000 18.0 spng
10 10 11 200.0 1.500000 18.0 spng
11 11 12 200.0 1.500000 18.0 spng
12 12 13 200.0 1.500000 18.0 spng
13 13 14 200.0 1.500000 18.0 spng
14 14 15 200.0 1.500000 18.0 spng
15 15 16 200.0 1.500000 18.0 spng
16 16 17 200.0 1.500000 18.0 spng
17 17 18 200.0 1.500000 18.0 spng
18 18 19 200.0 1.500000 18.0 spng
19 19 20 200.0 1.500000 18.0 spng
20 20 21 200.0 1.500000 18.0 spng
21 21 22 200.0 1.500000 18.0 spng
22 22 23 200.0 1.500000 18.0 spng
23 23 24 200.0 1.500000 18.0 spng
24 24 25 200.0 1.500000 18.0 spng
25 25 26 200.0 1.500000 18.0 spng
26 26 28 200.0 1.500000 18.0 spng
27 28 27 200.0 1.500000 18.0 spng
28 27 29 200.0 1.500000 18.0 spng
29 29 30 200.0 1.500000 18.0 spng
30 30 31 200.0 1.500000 18.0 spng
31 31 32 200.0 1.500000 18.0 spng
32 32 33 200.0 1.500000 18.0 spng
33 33 34 200.0 1.500000 18.0 spng
34 34 35 200.0 1.500000 18.0 spng
35 1 3 200.0 1.500000 36.0 spng
36 2 4 200.0 1.500000 36.0 spng
37 3 5 200.0 1.500000 36.0 spng
38 4 6 200.0 1.500000 36.0 spng
39 5 7 200.0 1.500000 36.0 spng
40 6 8 200.0 1.500000 36.0 spng
41 7 9 200.0 1.500000 36.0 spng
42 8 10 200.0 1.500000 36.0 spng
43 9 11 200.0 1.500000 36.0 spng
44 10 12 200.0 1.500000 36.0 spng
45 11 13 200.0 1.500000 36.0 spng
46 12 14 200.0 1.500000 36.0 spng
47 13 15 200.0 1.500000 36.0 spng
48 14 16 200.0 1.500000 36.0 spng
49 15 17 200.0 1.500000 36.0 spng
50 16 18 200.0 1.500000 36.0 spng
51 17 19 200.0 1.500000 36.0 spng
52 18 20 200.0 1.500000 36.0 spng
53 19 21 200.0 1.500000 36.0 spng
54 20 22 200.0 1.500000 36.0 spng
55 21 23 200.0 1.500000 36.0 spng
56 22 24 200.0 1.500000 36.0 spng
57 23 25 200.0 1.500000 36.0 spng
58 24 26 200.0 1.500000 36.0 spng
59 25 28 200.0 1.500000 36.0 spng
60 26 27 200.0 1.500000 36.0 spng
61 28 29 200.0 1.500000 36.0 spng
62 27 30 200.0 1.500000 36.0 spng
63 29 31 200.0 1.500000 36.0 spng
64 30 32 200.0 1.500000 36.0 spng
65 31 33 200.0 1.500000 36.0 spng
66 32 34 200.0 1.500000 36.0 spng
67 33 35 200.0 1.500000 36.0 spng
68 1 4 200.0 1.500000 53.0 spng
69 2 5 200.0 1.500000 54.0 spng
70 3 6 200.0 1.500000 54.0 spng
71 4 7 200.0 1.500000 54.0 spng
72 5 8 200.0 1.500000 54.0 spng
73 6 9 200.0 1.500000 54.0 spng
74 7 10 200.0 1.500000 54.0 spng
75 8 11 200.0 1.500000 54.0 spng
76 9 12 200.0 1.500000 54.0 spng
77 10 13 200.0 1.500000 54.0 spng
78 11 14 200.0 1.500000 54.0 spng
79 12 15 200.0 1.500000 54.0 spng
80 13 16 200.0 1.500000 54.0 spng
81 14 17 200.0 1.500000 54.0 spng
82 15 18 200.0 1.500000 54.0 spng
83 16 19 200.0 1.500000 54.0 spng
84 17 20 200.0 1.500000 54.0 spng
85 18 21 200.0 1.500000 54.0 spng
86 19 22 200.0 1.500000 54.0 spng
87 20 23 200.0 1.500000 54.0 spng
88 21 24 200.0 1.500000 54.0 spng
89 22 25 200.0 1.500000 54.0 spng
90 23 26 200.0 1.500000 54.0 spng
91 24 28 200.0 1.500000 54.0 spng
92 25 27 200.0 1.500000 54.0 spng
93 26 29 200.0 1.500000 54.0 spng
94 28 30 200.0 1.500000 54.0 spng
95 27 31 200.0 1.500000 54.0 spng
96 29 32 200.0 1.500000 54.0 spng
97 30 33 200.0 1.500000 54.0 spng
98 31 34 200.0 1.500000 54.0 spng
99 32 35 200.0 1.500000 50.0 spng
10
[
-400 400 random-range -400 400 random-range 2array
nodes> random
set-node-vel
]
times
;
: go* ( quot -- )
[ [ [ springies-window* 1000 sleep % ] with-scope ] with-ui ] bake call ;
! : go ( -- ) [ [ springies-window* 1000 sleep model ] with-scope ] with-ui ;
: go ( -- ) [ model ] go* ;
MAIN: go

View File

@ -0,0 +1,307 @@
USING: kernel namespaces arrays sequences threads math ui random bake
springies springies.ui ;
IN: springies.models.belt-tire
: model ( -- )
{ } clone >nodes
{ } clone >springs
0.008 >time-slice
gravity on
1 274.078806900597328 346.307117178664043 0 0 1 0.5 mass
2 284.142891110742823 329.83402842231834 0 0 1 0.5 mass
3 295.307158356938658 355.695013578746227 0 0 1 0.5 mass
4 300.698527801927128 337.003548930923216 0 0 1 0.5 mass
5 318.093036910029696 359.203044347904552 0 0 1 0.5 mass
6 318.542098798246286 339.592403450546044 0 0 1 0.5 mass
7 340.949296214486822 356.831259237330983 0 0 1 0.5 mass
8 336.494524828869885 337.754019325244656 0 0 1 0.5 mass
9 362.534986907234952 348.770558940029559 0 0 1 0.5 mass
10 353.491265306914897 331.642140359094469 0 0 1 0.5 mass
11 381.368850422101502 335.37878701564847 0 0 1 0.5 mass
12 368.085531061140216 321.055018811315335 0 0 1 0.5 mass
13 396.117634938806759 317.519287773537314 0 0 1 0.5 mass
14 379.675208211408915 307.277961968837246 0 0 1 0.5 mass
15 405.655157991023771 296.391903048606025 0 0 1 0.5 mass
16 387.124676448692242 290.862310093183567 0 0 1 0.5 mass
17 409.337178964708642 273.594658653786666 0 0 1 0.5 mass
18 389.76569804010461 273.012494879567555 0 0 1 0.5 mass
19 407.11203230551871 250.712646124396059 0 0 1 0.5 mass
20 387.966228461346304 255.061007930370067 0 0 1 0.5 mass
21 399.188308328902735 229.098161823607285 0 0 1 0.5 mass
22 381.896222954111181 238.073977723246998 0 0 1 0.5 mass
23 385.883224011375262 210.148208473511374 0 0 1 0.5 mass
24 371.614761646970464 223.279700317395225 0 0 1 0.5 mass
25 367.955378160003875 195.334436550727929 0 0 1 0.5 mass
26 357.817091674528911 211.717360072075536 0 0 1 0.5 mass
27 346.743525482831387 185.884698478394085 0 0 1 0.5 mass
28 341.291169697238729 204.55711005838188 0 0 1 0.5 mass
29 323.935265230381788 182.330460182137188 0 0 1 0.5 mass
30 323.466187791799882 201.937076877994031 0 0 1 0.5 mass
31 301.04141769400843 184.703602685435726 0 0 1 0.5 mass
32 305.532794735419941 203.763859300438838 0 0 1 0.5 mass
33 279.442362700896183 192.851996602076866 0 0 1 0.5 mass
34 288.551113492738239 209.893932668644339 0 0 1 0.5 mass
35 260.65997798024199 206.334196608396638 0 0 1 0.5 mass
36 273.960657978745814 220.516324161880476 0 0 1 0.5 mass
37 246.029909853431349 224.197583023911335 0 0 1 0.5 mass
38 262.719165304227545 234.58428660123181 0 0 1 0.5 mass
39 236.458142984593252 245.235572499606377 0 0 1 0.5 mass
40 254.870454491934908 250.81914136861181 0 0 1 0.5 mass
41 232.703447579492519 268.042376651164432 0 0 1 0.5 mass
42 252.226120754560156 268.679895159358864 0 0 1 0.5 mass
43 234.96767702938331 291.007702051922024 0 0 1 0.5 mass
44 254.040589506795527 286.621843971355872 0 0 1 0.5 mass
45 242.759412026738119 312.577114225657738 0 0 1 0.5 mass
46 260.111088599530603 303.593264087352964 0 0 1 0.5 mass
47 256.101782779606651 331.52509923420655 0 0 1 0.5 mass
48 270.373388641766439 318.366074596339615 0 0 1 0.5 mass
49 320.448537383965288 270.292364746678743 0 0 10 0.5 mass
1 1 4 200 2 28.284271247461902 spng
2 4 5 200 2 28.284271247461902 spng
3 5 8 200 2 28.284271247461902 spng
4 8 9 200 2 28.284271247461902 spng
5 9 12 200 2 28.284271247461902 spng
6 12 13 200 2 28.284271247461902 spng
7 13 16 200 2 28.284271247461902 spng
8 16 17 200 2 28.284271247461902 spng
9 17 20 200 2 28.284271247461902 spng
10 20 21 200 2 28.284271247461902 spng
11 21 24 200 2 28.284271247461902 spng
12 24 25 200 2 28.284271247461902 spng
13 25 28 200 2 28.284271247461902 spng
14 28 29 200 2 28.284271247461902 spng
15 29 32 200 2 28.284271247461902 spng
16 32 33 200 2 28.284271247461902 spng
17 33 36 200 2 28.284271247461902 spng
18 36 37 200 2 28.284271247461902 spng
19 37 40 200 2 28.284271247461902 spng
20 40 41 200 2 28.284271247461902 spng
21 41 44 200 2 28.284271247461902 spng
22 44 45 200 2 28.284271247461902 spng
23 45 48 200 2 28.284271247461902 spng
24 3 6 200 2 28.284271247461902 spng
25 7 10 200 2 28.284271247461902 spng
26 11 14 200 2 28.284271247461902 spng
27 15 18 200 2 28.284271247461902 spng
28 19 22 200 2 28.284271247461902 spng
29 23 26 200 2 28.284271247461902 spng
30 27 30 200 2 28.284271247461902 spng
31 31 34 200 2 28.284271247461902 spng
32 35 38 200 2 28.284271247461902 spng
33 39 44 200 2 44.7213595499957961 spng
34 39 42 200 2 28.284271247461902 spng
35 43 46 200 2 28.284271247461902 spng
36 47 46 200 2 28.284271247461902 spng
37 43 42 200 2 28.284271247461902 spng
38 39 38 200 2 28.284271247461902 spng
39 35 34 200 2 28.284271247461902 spng
40 2 3 200 2 28.284271247461902 spng
41 6 7 200 2 28.284271247461902 spng
42 10 11 200 2 28.284271247461902 spng
43 14 15 200 2 28.284271247461902 spng
44 18 19 200 2 28.284271247461902 spng
45 22 23 200 2 28.284271247461902 spng
46 26 27 200 2 28.284271247461902 spng
47 30 31 200 2 28.284271247461902 spng
48 1 6 200 2 44.7213595499957961 spng
49 3 8 200 2 44.7213595499957961 spng
50 5 10 200 2 44.7213595499957961 spng
51 7 12 200 2 44.7213595499957961 spng
52 9 14 200 2 44.7213595499957961 spng
53 11 16 200 2 44.7213595499957961 spng
54 13 18 200 2 44.7213595499957961 spng
55 15 20 200 2 44.7213595499957961 spng
56 17 22 200 2 44.7213595499957961 spng
57 19 24 200 2 44.7213595499957961 spng
58 21 26 200 2 44.7213595499957961 spng
59 23 28 200 2 44.7213595499957961 spng
60 25 30 200 2 44.7213595499957961 spng
61 27 32 200 2 44.7213595499957961 spng
62 29 34 200 2 44.7213595499957961 spng
63 31 36 200 2 44.7213595499957961 spng
64 33 38 200 2 44.7213595499957961 spng
65 35 40 200 2 44.7213595499957961 spng
66 37 42 200 2 44.7213595499957961 spng
67 41 46 200 2 44.7213595499957961 spng
68 43 48 200 2 44.7213595499957961 spng
69 2 5 200 2 44.7213595499957961 spng
70 4 7 200 2 44.7213595499957961 spng
71 6 9 200 2 44.7213595499957961 spng
72 8 11 200 2 44.7213595499957961 spng
73 10 13 200 2 44.7213595499957961 spng
74 12 15 200 2 44.7213595499957961 spng
75 14 17 200 2 44.7213595499957961 spng
76 16 19 200 2 44.7213595499957961 spng
77 18 21 200 2 44.7213595499957961 spng
78 20 23 200 2 44.7213595499957961 spng
79 22 25 200 2 44.7213595499957961 spng
80 24 27 200 2 44.7213595499957961 spng
81 26 29 200 2 44.7213595499957961 spng
82 28 31 200 2 44.7213595499957961 spng
83 30 33 200 2 44.7213595499957961 spng
84 32 35 200 2 44.7213595499957961 spng
85 34 37 200 2 44.7213595499957961 spng
86 36 39 200 2 44.7213595499957961 spng
87 38 41 200 2 44.7213595499957961 spng
88 40 43 200 2 44.7213595499957961 spng
89 42 45 200 2 44.7213595499957961 spng
90 44 47 200 2 44.7213595499957961 spng
91 1 8 200 2 63.2455532033675851 spng
92 3 10 200 2 63.2455532033675851 spng
93 5 12 200 2 63.2455532033675851 spng
94 7 14 200 2 63.2455532033675851 spng
95 9 16 200 2 63.2455532033675851 spng
96 11 18 200 2 63.2455532033675851 spng
97 13 20 200 2 63.2455532033675851 spng
98 15 22 200 2 63.2455532033675851 spng
99 17 24 200 2 63.2455532033675851 spng
100 19 26 200 2 63.2455532033675851 spng
101 21 28 200 2 63.2455532033675851 spng
102 23 30 200 2 63.2455532033675851 spng
103 25 32 200 2 63.2455532033675851 spng
104 27 34 200 2 63.2455532033675851 spng
105 29 36 200 2 63.2455532033675851 spng
106 31 38 200 2 63.2455532033675851 spng
107 33 40 200 2 63.2455532033675851 spng
108 35 42 200 2 63.2455532033675851 spng
109 37 44 200 2 63.2455532033675851 spng
110 39 46 200 2 63.2455532033675851 spng
111 48 41 200 2 63.2455532033675851 spng
112 2 7 200 2 63.2455532033675851 spng
113 4 9 200 2 63.2455532033675851 spng
114 6 11 200 2 63.2455532033675851 spng
115 8 13 200 2 63.2455532033675851 spng
116 10 15 200 2 63.2455532033675851 spng
117 12 17 200 2 63.2455532033675851 spng
118 14 19 200 2 63.2455532033675851 spng
119 16 21 200 2 63.2455532033675851 spng
120 18 23 200 2 63.2455532033675851 spng
121 20 25 200 2 63.2455532033675851 spng
122 22 27 200 2 63.2455532033675851 spng
123 24 29 200 2 63.2455532033675851 spng
124 26 31 200 2 63.2455532033675851 spng
125 28 33 200 2 63.2455532033675851 spng
126 30 35 200 2 63.2455532033675851 spng
127 32 37 200 2 63.2455532033675851 spng
128 34 39 200 2 63.2455532033675851 spng
129 36 41 200 2 63.2455532033675851 spng
130 38 43 200 2 63.2455532033675851 spng
131 40 45 200 2 63.2455532033675851 spng
132 42 47 200 2 63.2455532033675851 spng
133 1 3 200 2 20 spng
134 3 5 200 2 20 spng
135 5 7 200 2 20 spng
136 7 9 200 2 20 spng
137 9 11 200 2 20 spng
138 11 13 200 2 20 spng
139 13 15 200 2 20 spng
140 15 17 200 2 20 spng
141 17 19 200 2 20 spng
142 19 21 200 2 20 spng
143 21 23 200 2 20 spng
144 23 25 200 2 20 spng
145 25 27 200 2 20 spng
146 27 29 200 2 20 spng
147 29 31 200 2 20 spng
148 31 33 200 2 20 spng
149 33 35 200 2 20 spng
150 35 37 200 2 20 spng
151 37 39 200 2 20 spng
152 39 41 200 2 20 spng
153 41 43 200 2 20 spng
154 43 45 200 2 20 spng
155 45 47 200 2 20 spng
156 2 4 200 2 20 spng
157 4 6 200 2 20 spng
158 6 8 200 2 20 spng
159 8 10 200 2 20 spng
160 10 12 200 2 20 spng
161 12 14 200 2 20 spng
162 14 16 200 2 20 spng
163 16 18 200 2 20 spng
164 18 20 200 2 20 spng
165 20 22 200 2 20 spng
166 22 24 200 2 20 spng
167 24 26 200 2 20 spng
168 26 28 200 2 20 spng
169 28 30 200 2 20 spng
170 30 32 200 2 20 spng
171 32 34 200 2 20 spng
172 34 36 200 2 20 spng
173 36 38 200 2 20 spng
174 38 40 200 2 20 spng
175 40 42 200 2 20 spng
176 42 44 200 2 20 spng
177 44 46 200 2 20 spng
178 46 48 200 2 20 spng
179 1 2 200 2 20 spng
180 3 4 200 2 20 spng
181 5 6 200 2 20 spng
182 7 8 200 2 20 spng
183 9 10 200 2 20 spng
184 11 12 200 2 20 spng
185 13 14 200 2 20 spng
186 15 16 200 2 20 spng
187 17 18 200 2 20 spng
188 19 20 200 2 20 spng
189 21 22 200 2 20 spng
190 23 24 200 2 20 spng
191 25 26 200 2 20 spng
192 27 28 200 2 20 spng
193 29 30 200 2 20 spng
194 31 32 200 2 20 spng
195 33 34 200 2 20 spng
196 35 36 200 2 20 spng
197 37 38 200 2 20 spng
198 39 40 200 2 20 spng
199 41 42 200 2 20 spng
200 43 44 200 2 20 spng
201 45 46 200 2 20 spng
202 47 48 200 2 20 spng
203 47 2 200 2 28.284271247461902 spng
204 1 48 200 2 28.284271247461902 spng
205 1 46 200 2 44.7213595499957961 spng
206 1 44 200 2 63.2455532033675851 spng
207 47 4 200 2 44.7213595499957961 spng
208 48 3 200 2 44.7213595499957961 spng
209 47 6 200 2 63.2455532033675851 spng
210 48 5 200 2 63.2455532033675851 spng
211 46 3 200 2 63.2455532033675851 spng
212 45 4 200 2 63.2455532033675851 spng
213 47 1 200 2 20 spng
214 48 2 200 2 20 spng
215 18 49 300 3 69.2603782836911677 spng
216 49 20 300 3 69.050706006528273 spng
217 22 49 300 3 69.3541635375988079 spng
218 49 24 300 3 69.5269731830747872 spng
219 26 49 300 3 69.6347614342147381 spng
220 49 28 300 3 68.9492567037527948 spng
221 30 49 300 3 68.2641926635040477 spng
222 49 32 300 3 68.0661443009665419 spng
223 34 49 300 3 68.4470598345904051 spng
224 49 36 300 3 68.1175454637056106 spng
225 38 49 300 3 67.6756972627545252 spng
226 49 40 300 3 68.6221538571910514 spng
227 42 49 300 3 68.1835757349231386 spng
228 49 44 300 3 68.249542123006222 spng
229 46 49 300 3 68.8767014308902503 spng
230 49 48 300 3 69.4262198308391305 spng
231 2 49 300 3 69.8927750200262068 spng
232 49 4 300 3 69.5701085237043486 spng
233 6 49 300 3 69.1809222257119103 spng
234 8 49 300 3 69.2314957226839027 spng
235 49 10 300 3 69.7782200976780445 spng
236 12 49 300 3 69.5269731830747872 spng
237 49 14 300 3 69.8927750200262068 spng
238 16 49 300 3 69.8927750200262068 spng
nodes> 200 random -100 + 100 2array [ swap set-node-vel ] curry each ;
: go ( -- ) [ model ] go* ;
MAIN: go

View File

@ -0,0 +1,80 @@
USING: kernel namespaces arrays sequences threads math math.vectors
ui random bake springies springies.ui ;
IN: springies.models.nifty
: model ( -- )
{ } clone >nodes
{ } clone >springs
0.007 >time-slice
gravity off
1 148.581450999999987 350.573888000000011 0 -7.75 1 0.1 mass
2 168.564277000000004 351.402524000000028 0 -7.75 1 0.1 mass
3 188.54710399999999 352.231158999999991 0 -7.75 1 0.1 mass
4 208.529931000000005 353.059794000000011 0 -7.75 1 0.1 mass
5 228.512757999999991 353.888428999999974 0 -7.75 1 0.1 mass
6 248.495584000000008 354.717063999999993 0 -7.75 1 0.1 mass
7 149.410086000000007 330.591061000000025 0 -7.75 1 0.1 mass
8 150.238720999999998 310.608234999999979 0 -7.75 1 0.1 mass
9 151.06735599999999 290.625407999999993 0 -7.75 1 0.1 mass
10 151.895991000000009 270.642581000000007 0 -7.75 1 0.1 mass
11 152.724626000000001 250.65975499999999 0 -7.75 1 0.1 mass
12 172.707452999999987 251.48839000000001 0 -7.749999 1 0.1 mass
13 192.690280000000001 252.317025000000001 0 -7.75 1 0.1 mass
14 212.67310599999999 253.145659999999992 0 -7.75 1 0.1 mass
15 232.655933000000005 253.974295000000012 0 -7.75 1 0.1 mass
16 252.638759999999991 254.802930000000003 0 -7.75 1 0.1 mass
17 251.810124999999999 274.78575699999999 0 -7.75 1 0.1 mass
18 250.98148900000001 294.768583999999976 0 -7.75 1 0.1 mass
19 249.324218999999999 334.734237000000007 0 -7.75 1 0.1 mass
20 250.152853999999991 314.751410000000021 0 -7.75 1 0.1 mass
1 1 2 200 1.5 20 spng
2 2 3 200 1.5 20 spng
3 3 4 200 1.5 20 spng
4 4 5 200 1.5 20 spng
5 5 6 200 1.5 20 spng
6 6 19 200 1.5 20 spng
7 19 20 200 1.5 20 spng
8 20 18 200 1.5 20 spng
9 18 17 200 1.5 20 spng
10 17 16 200 1.5 20 spng
11 16 15 200 1.5 20 spng
12 15 14 200 1.5 20 spng
13 14 13 200 1.5 20 spng
14 13 12 200 1.5 20 spng
15 12 11 200 1.5 20 spng
16 11 10 200 1.5 20 spng
17 10 9 200 1.5 20 spng
18 9 8 200 1.5 20 spng
19 8 7 200 1.5 20 spng
20 7 1 200 1.5 20 spng
21 1 19 200 1.5 101.98039 spng
22 19 14 200 1.5 89.4427189999999968 spng
23 14 8 200 1.5 84.8528139999999951 spng
24 8 5 200 1.5 89.4427189999999968 spng
25 5 16 200 1.5 101.98039 spng
26 16 10 200 1.5 101.98039 spng
27 10 3 200 1.5 89.4427189999999968 spng
28 3 18 200 1.5 84.8528139999999951 spng
29 18 12 200 1.5 89.4427189999999968 spng
30 12 1 200 1.5 101.98039 spng
31 2 20 200 1.5 89.4427189999999968 spng
32 20 13 200 1.5 84.8528139999999951 spng
33 13 7 200 1.5 89.4427189999999968 spng
34 7 6 200 1.5 101.98039 spng
35 6 15 200 1.5 101.98039 spng
36 15 9 200 1.5 89.4427189999999968 spng
37 9 4 200 1.5 84.8528139999999951 spng
38 4 17 200 1.5 89.4427189999999968 spng
39 17 11 200 1.5 101.98039 spng
40 11 2 200 1.5 101.98039 spng
nodes> 200 random -100 + 200 random -100 + 2array [ swap set-node-vel ] curry
each ;
: go ( -- ) [ model ] go* ;
MAIN: go

View File

@ -0,0 +1,113 @@
USING: kernel namespaces arrays sequences threads math math.vectors
ui random bake
springies springies.ui ;
IN: springies.models.urchin
: model ( -- )
{ } clone >nodes
{ } clone >springs
0.007 >time-slice
gravity on
1 507.296953 392.174236 -11.451186 -71.267273 1.0 1.0 mass
2 514.879820 372.128025 11.950035 -70.858717 1.0 1.0 mass
3 536.571268 364.423706 18.394466 -41.159445 1.0 1.0 mass
4 554.886966 369.953895 15.173664 -11.009243 1.0 1.0 mass
5 572.432935 379.927626 8.228103 -1.120846 1.0 1.0 mass
6 585.774508 392.380791 5.443281 -8.186599 1.0 1.0 mass
7 584.650543 411.934530 -15.582843 -24.911756 1.0 1.0 mass
8 569.409148 424.155713 -24.100159 -42.285960 1.0 1.0 mass
9 553.751996 434.663690 -26.069217 -41.610454 1.0 1.0 mass
10 536.684374 444.915694 -30.702349 -45.021926 1.0 1.0 mass
11 516.677286 435.936238 -33.128410 -60.977340 1.0 1.0 mass
12 514.170680 414.649472 -24.471518 -64.104425 1.0 1.0 mass
13 602.101547 478.298945 1.612646 -53.040881 1.0 1.0 mass
14 637.0 427.598266 0.0 0.0 1.0 1.0 mass
15 608.000171 350.425575 31.812856 23.456940 1.0 1.0 mass
16 484.367809 332.414622 42.575378 -91.238351 1.0 1.0 mass
17 480.857379 475.215663 -24.240991 -53.909049 1.0 1.0 mass
18 548.580015 492.173168 -34.565312 -52.436468 1.0 1.0 mass
19 578.155338 487.173526 22.544495 -71.920721 1.0 1.0 mass
20 630.992588 379.333707 16.662115 37.873709 1.0 1.0 mass
21 591.256916 324.817423 63.036114 27.988433 1.0 1.0 mass
22 539.051461 311.597938 159.501014 -27.955219 1.0 1.0 mass
23 448.396171 396.882674 -15.045910 -138.652372 1.0 1.0 mass
24 448.194414 419.993896 -27.625008 -84.936708 1.0 1.0 mass
1 1 2 200.0 3.0 20.0 spng
2 2 3 200.0 3.0 20.0 spng
3 3 4 200.0 3.0 20.0 spng
4 4 5 200.0 3.0 20.0 spng
5 5 6 200.0 3.0 20.0 spng
6 6 7 200.0 3.0 20.0 spng
7 7 8 200.0 3.0 20.0 spng
8 8 9 200.0 3.0 20.0 spng
9 9 10 200.0 3.0 20.0 spng
10 10 11 200.0 3.0 20.0 spng
11 11 12 200.0 3.0 20.0 spng
12 1 3 200.0 3.0 40.0 spng
13 2 4 200.0 3.0 40.0 spng
14 3 5 200.0 3.0 40.0 spng
15 4 6 200.0 3.0 40.0 spng
16 6 8 200.0 3.0 40.0 spng
17 7 9 200.0 3.0 40.0 spng
18 8 10 200.0 3.0 40.0 spng
19 9 11 200.0 3.0 40.0 spng
20 10 12 200.0 3.0 40.0 spng
21 12 1 200.0 3.0 21.0 spng
22 12 2 200.0 3.0 41.0 spng
23 11 1 200.0 3.0 41.0 spng
24 6 12 200.0 3.0 72.681733 spng
25 5 11 200.0 3.0 81.191259 spng
26 10 4 200.0 3.0 76.026311 spng
27 3 9 200.0 3.0 72.615425 spng
28 8 2 200.0 3.0 74.966659 spng
29 1 7 200.0 3.0 80.280757 spng
30 17 11 200.0 3.0 55.036352 spng
31 10 18 200.0 3.0 49.819675 spng
32 19 9 200.0 3.0 54.918121 spng
33 8 13 200.0 3.0 62.201286 spng
34 14 7 200.0 3.0 58.600341 spng
35 6 20 200.0 3.0 46.400431 spng
36 15 5 200.0 3.0 44.045431 spng
37 4 21 200.0 3.0 57.454330 spng
38 22 3 200.0 3.0 53.823787 spng
39 2 16 200.0 3.0 51.039201 spng
40 23 1 200.0 3.0 58.668561 spng
41 12 24 200.0 3.0 64.404969 spng
42 24 11 200.0 3.0 71.217975 spng
43 17 12 200.0 3.0 65.0 spng
44 11 18 200.0 3.0 60.745370 spng
45 18 9 200.0 3.0 60.406953 spng
46 9 13 200.0 3.0 67.779053 spng
47 13 7 200.0 3.0 66.708320 spng
48 7 20 200.0 3.0 55.659680 spng
49 20 5 200.0 3.0 60.0 spng
50 5 21 200.0 3.0 61.846584 spng
51 21 3 200.0 3.0 64.031242 spng
52 3 16 200.0 3.0 63.568860 spng
53 16 1 200.0 3.0 59.774577 spng
54 1 24 200.0 3.0 65.802736 spng
55 17 10 200.0 3.0 64.845971 spng
56 10 19 200.0 3.0 58.249464 spng
57 19 8 200.0 3.0 67.268120 spng
58 8 14 200.0 3.0 67.268120 spng
59 14 6 200.0 3.0 64.629715 spng
60 6 15 200.0 3.0 50.089919 spng
61 15 4 200.0 3.0 56.320511 spng
62 4 22 200.0 3.0 60.728906 spng
63 22 2 200.0 3.0 61.032778 spng
64 2 23 200.0 3.0 66.528190 spng
65 23 12 200.0 3.0 72.277244 spng
nodes>
75 random -75 + 0 2array [ over node-vel v+ swap set-node-vel ]
curry each
;
: go ( -- ) [ model ] go* ;
MAIN: go

View File

@ -1,7 +1,7 @@
USING: kernel namespaces threads sequences math math.vectors combinators.lib
opengl.gl opengl colors ui ui.gadgets ui.gadgets.slate
rewrite-closures vars springies ;
bake rewrite-closures vars springies ;
IN: springies.ui
@ -51,7 +51,7 @@ DEFER: maybe-loop
: springies-window* ( -- )
C[ display ] <slate> >slate
{ 500 500 } slate> set-slate-dim
{ 700 500 } slate> set-slate-dim
C[ { 500 500 } >world-size loop on [ run ] in-thread ]
slate> set-slate-graft
C[ loop off ] slate> set-slate-ungraft
@ -59,3 +59,8 @@ DEFER: maybe-loop
slate> "Springies" open-window ;
: springies-window ( -- ) [ [ springies-window* ] with-scope ] with-ui ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: go* ( quot -- )
[ [ [ springies-window* 1000 sleep % ] with-scope ] with-ui ] bake call ;

View File

@ -4,6 +4,7 @@ USING: vocabs.loader io.files io kernel sequences assocs
splitting parser prettyprint ;
IN: tools.deploy.config
SYMBOL: strip-io?
SYMBOL: strip-globals?
SYMBOL: strip-word-props?
SYMBOL: strip-word-names?
@ -22,6 +23,7 @@ SYMBOL: deploy-image
: default-config ( -- assoc )
V{
{ strip-io? f }
{ strip-prettyprint? t }
{ strip-globals? t }
{ strip-word-props? t }

View File

@ -57,4 +57,5 @@ PRIVATE>
deploy-command-line stage2 ;
: deploy ( vocab -- )
"" resource-path cd
vm over ".image" append rot dup deploy-config deploy* ;

View File

@ -15,19 +15,20 @@ IN: tools.deploy.shaker
: strip-init-hooks ( -- )
"Stripping startup hooks" show
"command-line" init-hooks get delete-at ;
"command-line" init-hooks get delete-at
strip-io? get [ "io.backend" init-hooks get delete-at ] when ;
: strip-debugger ( -- )
strip-debugger? get [
"Stripping debugger" show
"resource:extra/tools/deploy/strip-debugger.factor"
"resource:extra/tools/deploy/shaker/strip-debugger.factor"
run-file
] when ;
: strip-cocoa ( -- )
"cocoa" vocab [
"Stripping unused Cocoa methods" show
"resource:extra/tools/deploy/strip-cocoa.factor"
"resource:extra/tools/deploy/shaker/strip-cocoa.factor"
run-file
] when ;
@ -90,6 +91,8 @@ USING: bit-arrays byte-arrays io.streams.nested ;
{ } set-retainstack
V{ } set-namestack
V{ } set-catchstack
"Stripping compiled quotations" show
strip-compiled-quotations
"Saving final image" show
[ save-image-and-exit ] call-clear ;
@ -100,14 +103,14 @@ SYMBOL: deploy-vocab
\ boot ,
init-hooks get values concat %
,
"io.backend" init-hooks get at [ \ flush , ] when
strip-io? get [ \ flush , ] unless
] [ ] make "Boot quotation: " write dup . flush
set-boot-quot ;
: retained-globals ( -- seq )
[
builtins ,
io-backend ,
strip-io? get [ io-backend , ] unless
strip-dictionary? get [
{
@ -178,6 +181,8 @@ SYMBOL: deploy-vocab
deploy-vocab get require
r> [ call ] when*
strip
"Compressing image" show
compress-image
finish-deploy
] [
print-error flush 1 exit

View File

@ -1,4 +1,6 @@
USING: kernel ;
IN: debugger
: print-error die ;
: error. die ;

View File

@ -65,12 +65,14 @@ M: word (step-into) (step-into-execute) ;
{
>n ndrop >c c>
continue continue-with
(continue-with) stop break
(continue-with) stop
} [
dup [ execute break ] curry
"step-into" set-word-prop
] each
\ break [ break ] "step-into" set-word-prop
! Stepping
: change-innermost-frame ( quot interpreter -- )
interpreter-continuation [

View File

@ -1,6 +1,6 @@
USING: ui.gadgets.editors tools.test kernel io io.streams.plain
io.streams.string definitions namespaces ui.gadgets
ui.gadgets.grids prettyprint documents ;
ui.gadgets.grids prettyprint documents ui.gestures ;
[ t ] [
<editor> "editor" set
@ -27,3 +27,12 @@ ui.gadgets.grids prettyprint documents ;
"editor" get gadget-selection
"editor" get ungraft*
] unit-test
[ ] [
<editor> "editor" set
"editor" get graft*
"foo bar\nbaz quux" "editor" get set-editor-string
4 hand-click# set
"editor" get position-caret
"editor" get ungraft*
] unit-test

View File

@ -5,7 +5,7 @@ ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labels
ui.gadgets.scrollers ui.gadgets.theme ui.gadgets.controls
ui.render ui.gestures io kernel math models namespaces opengl
opengl.gl sequences strings io.styles math.vectors sorting
colors ;
colors combinators ;
IN: ui.gadgets.editors
TUPLE: editor
@ -292,11 +292,11 @@ M: editor gadget-text* editor-string % ;
: position-caret ( editor -- )
hand-click# get {
[ ]
[ dup (position-caret) ]
[ dup T{ one-word-elt } select-elt ]
[ dup T{ one-line-elt } select-elt ]
} ?nth call drop ;
{ 1 [ (position-caret) ] }
{ 2 [ T{ one-word-elt } select-elt ] }
{ 3 [ T{ one-line-elt } select-elt ] }
[ 2drop ]
} case ;
: insert-newline "\n" swap user-input ;

View File

@ -65,4 +65,10 @@ IN: temporary
[ ] [ yield ] unit-test
[ t ] [ walker get-tool walker-active? ] unit-test
[ ] [ "walker" get com-continue ] unit-test
[ ] [ "walker" get com-continue ] unit-test
[ ] [ "walker" get com-continue ] unit-test
] with-scope

View File

@ -67,7 +67,11 @@ M: walker call-tool* ( continuation walker -- )
: com-continue ( walker -- )
#! Reset walker first, in case step-all ends up calling
#! the walker again.
dup walker-interpreter swap reset-walker step-all ;
dup walker-active? [
dup walker-interpreter swap reset-walker step-all
] [
drop
] if ;
: walker-help "ui-walker" help-window ;

View File

@ -93,8 +93,12 @@ M: world button-up-event
send-button-up ;
: mouse-event>scroll-direction ( event -- pair )
#! Reminder for myself: 4 is up, 5 is down
XButtonEvent-button 5 = 1 -1 ? 0 swap 2array ;
XButtonEvent-button {
{ 4 { 0 -1 } }
{ 5 { 0 1 } }
{ 6 { -1 0 } }
{ 7 { 1 0 } }
} at ;
M: world wheel-event
>r dup mouse-event>scroll-direction swap mouse-event-loc r>

View File

@ -42,7 +42,7 @@ GENERIC: client-event ( event window -- )
: events-queued ( mode -- n ) >r dpy get r> XEventsQueued ;
: wheel? ( event -- ? ) XButtonEvent-button { 4 5 } member? ;
: wheel? ( event -- ? ) XButtonEvent-button 4 7 between? ;
: button-down-event$ ( event window -- )
over wheel? [ wheel-event ] [ button-down-event ] if ;

View File

@ -446,6 +446,7 @@ INLINE void *copy_untagged_object(void *pointer, CELL size)
INLINE void forward_object(CELL pointer, CELL newpointer)
{
if(pointer != newpointer)
put(UNTAG(pointer),RETAG(newpointer,GC_COLLECTED));
}

View File

@ -1,14 +1,23 @@
#include "master.h"
void print_chars(F_STRING* str)
{
CELL i;
for(i = 0; i < string_capacity(str); i++)
putchar(cget(SREF(str,i)));
}
void print_word(F_WORD* word, CELL nesting)
{
if(type_of(word->name) == STRING_TYPE)
if(type_of(word->vocabulary) == STRING_TYPE)
{
F_STRING *string = untag_string(word->name);
CELL i;
for(i = 0; i < string_capacity(string); i++)
putchar(cget(SREF(string,i)));
print_chars(untag_string(word->vocabulary));
printf(":");
}
if(type_of(word->name) == STRING_TYPE)
print_chars(untag_string(word->name));
else
{
printf("#<not a string: ");
@ -20,9 +29,7 @@ void print_word(F_WORD* word, CELL nesting)
void print_string(F_STRING* str)
{
putchar('"');
CELL i;
for(i = 0; i < string_capacity(str); i++)
putchar(cget(SREF(str,i)));
print_chars(str);
putchar('"');
}
@ -181,6 +188,24 @@ void dump_generations(void)
(CELL)(data_heap->cards_end - data_heap->cards));
}
void dump_objects(F_FIXNUM type)
{
begin_scan();
CELL obj;
while((obj = next_object()) != F)
{
if(type == -1 || type_of(obj) == type)
{
print_nested_obj(obj,3);
printf("\n");
}
}
/* end scan */
gc_off = false;
}
void factorbug(void)
{
reset_stdio();
@ -200,6 +225,8 @@ void factorbug(void)
printf("g -- dump generations\n");
printf("card <addr> -- print card containing address\n");
printf("addr <card> -- print address containing card\n");
printf("data -- data heap dump\n");
printf("words -- words dump\n");
printf("code -- code heap dump\n");
for(;;)
@ -268,6 +295,10 @@ void factorbug(void)
exit(1);
else if(strcmp(cmd,"im") == 0)
save_image(STR_FORMAT("fep.image"));
else if(strcmp(cmd,"data") == 0)
dump_objects(-1);
else if(strcmp(cmd,"words") == 0)
dump_objects(WORD_TYPE);
else if(strcmp(cmd,"code") == 0)
dump_heap(&code_heap);
else

View File

@ -19,6 +19,7 @@ void default_parameters(F_PARAMETERS *p)
p->young_size = 2 * CELLS;
p->aging_size = 4 * CELLS;
p->secure_gc = false;
p->fep = false;
}
/* Get things started */
@ -101,6 +102,8 @@ void init_factor_from_args(F_CHAR *image, int argc, F_CHAR **argv, bool embedded
else if(factor_arg(argv[i],STR_FORMAT("-codeheap=%d"),&p.code_size));
else if(STRCMP(argv[i],STR_FORMAT("-securegc")) == 0)
p.secure_gc = true;
else if(STRCMP(argv[i],STR_FORMAT("-fep")) == 0)
p.fep = true;
else if(STRNCMP(argv[i],STR_FORMAT("-i="),3) == 0)
p.image = argv[i] + 3;
}
@ -127,6 +130,10 @@ void init_factor_from_args(F_CHAR *image, int argc, F_CHAR **argv, bool embedded
userenv[EMBEDDED_ENV] = (embedded ? T : F);
nest_stacks();
if(p.fep)
factorbug();
c_to_factor_toplevel(userenv[BOOT_ENV]);
unnest_stacks();

View File

@ -225,3 +225,23 @@ struct test_struct_7 ffi_test_30(void)
}
void ffi_test_31(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x13, int x14, int x15, int x16, int x17, int x18, int x19, int x20, int x21, int x22, int x23, int x24, int x25, int x26, int x27, int x28, int x29, int x30, int x31, int x32, int x33, int x34, int x35, int x36, int x37, int x38, int x39, int x40, int x41) { }
double ffi_test_32(struct test_struct_8 x, int y)
{
return (x.x + x.y) * y;
}
double ffi_test_33(struct test_struct_9 x, int y)
{
return (x.x + x.y) * y;
}
double ffi_test_34(struct test_struct_10 x, int y)
{
return (x.x + x.y) * y;
}
double ffi_test_35(struct test_struct_11 x, int y)
{
return (x.x + x.y) * y;
}

View File

@ -49,3 +49,11 @@ DLLEXPORT struct test_struct_6 ffi_test_29(void);
struct test_struct_7 { char x, y, z, a, b, c, d; };
DLLEXPORT struct test_struct_7 ffi_test_30(void);
DLLEXPORT void ffi_test_31(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x13, int x14, int x15, int x16, int x17, int x18, int x19, int x20, int x21, int x22, int x23, int x24, int x25, int x26, int x27, int x28, int x29, int x30, int x31, int x32, int x33, int x34, int x35, int x36, int x37, int x38, int x39, int x40, int x41);
struct test_struct_8 { double x; double y; };
DLLEXPORT double ffi_test_32(struct test_struct_8 x, int y);
struct test_struct_9 { float x; float y; };
DLLEXPORT double ffi_test_33(struct test_struct_9 x, int y);
struct test_struct_10 { float x; int y; };
DLLEXPORT double ffi_test_34(struct test_struct_10 x, int y);
struct test_struct_11 { int x; int y; };
DLLEXPORT double ffi_test_35(struct test_struct_11 x, int y);

View File

@ -31,6 +31,7 @@ typedef struct {
CELL gen_count, young_size, aging_size;
CELL code_size;
bool secure_gc;
bool fep;
} F_PARAMETERS;
void load_image(F_PARAMETERS *p);

View File

@ -194,4 +194,5 @@ void *primitives[] = {
primitive_innermost_stack_frame_scan,
primitive_set_innermost_stack_frame_quot,
primitive_call_clear,
primitive_strip_compiled_quotations,
};

View File

@ -231,3 +231,22 @@ DEFINE_PRIMITIVE(quotation_xt)
F_QUOTATION *quot = untag_quotation(dpeek());
drepl(allot_cell((CELL)quot->xt));
}
DEFINE_PRIMITIVE(strip_compiled_quotations)
{
begin_scan();
CELL obj;
while((obj = next_object()) != F)
{
if(type_of(obj) == QUOTATION_TYPE)
{
F_QUOTATION *quot = untag_object(obj);
quot->compiled = F;
quot->xt = lazy_jit_compile;
}
}
/* end scan */
gc_off = false;
}

View File

@ -6,3 +6,4 @@ DECLARE_PRIMITIVE(curry);
DECLARE_PRIMITIVE(array_to_quotation);
DECLARE_PRIMITIVE(quotation_xt);
DECLARE_PRIMITIVE(uncurry);
DECLARE_PRIMITIVE(strip_compiled_quotations);