Compare commits
272 Commits
modern-har
...
master
Author | SHA1 | Date |
---|---|---|
|
cbdd559a75 | |
|
ff6b75d030 | |
|
8fd437d877 | |
|
36b2ac97ef | |
|
f2a40f88dc | |
|
fed5fd7c50 | |
|
dc3a11bfc4 | |
|
ae1890e0d7 | |
|
7bd1adb1c3 | |
|
5a71d98d29 | |
|
09829bd506 | |
|
840159710e | |
|
dbdf4540bc | |
|
96d7da0169 | |
|
7789bbc79c | |
|
9f8a791a3b | |
|
16b144eaf5 | |
|
11f060719a | |
|
c200cfb8ca | |
|
cc08ad38a4 | |
|
03e62f3bc5 | |
|
979c13e156 | |
|
bc0789ca91 | |
|
115b7b62df | |
|
f2deb82829 | |
|
f3ae869536 | |
|
946bbd1597 | |
|
0b5cb42d95 | |
|
c7959f2cb2 | |
|
46be019527 | |
|
ce3049decd | |
|
87cce0ba6a | |
|
13b366e88b | |
|
97d828a7f5 | |
|
ec490587e7 | |
|
3eb6e55ae4 | |
|
a861c4c732 | |
|
00fc565111 | |
|
3fdb0325ca | |
|
1ac7e08f59 | |
|
699ebc960b | |
|
ce871f99dd | |
|
60dd083bcb | |
|
5176b270d2 | |
|
d535b62f50 | |
|
8cc090950a | |
|
997aaf005e | |
|
6e83e00d22 | |
|
e1085ffef4 | |
|
f21deee3df | |
|
0c0647f12c | |
|
8eb78b9212 | |
|
995d717277 | |
|
5eaaaf06d6 | |
|
bb827a1565 | |
|
6bfc54b15c | |
|
24e1080362 | |
|
126f3acf63 | |
|
70687a0eb3 | |
|
40aedcb346 | |
|
564720281d | |
|
53d741a6ef | |
|
42855b4c44 | |
|
0bee527143 | |
|
bfe2140148 | |
|
28bdbf8a2c | |
|
8a3d7a9d7f | |
|
21a1a6e7a1 | |
|
c496feb256 | |
|
5d0827ed4e | |
|
92b7c32e19 | |
|
27d38225f4 | |
|
fbeb409979 | |
|
9c60c202e9 | |
|
2c488736e4 | |
|
d1782a23cc | |
|
671aa228f3 | |
|
5c3efc5cee | |
|
464bd705f4 | |
|
3a091577ae | |
|
d8f7bd067d | |
|
35719d11b6 | |
|
87022ea3b9 | |
|
be6d8cae27 | |
|
b6373caa4f | |
|
8aa76be5ed | |
|
6c02569916 | |
|
0b7122350e | |
|
d88ed6ce63 | |
|
e9ab963df9 | |
|
a7b058bed1 | |
|
c87811f611 | |
|
8efe213273 | |
|
8bc4a3f2b8 | |
|
a67f2a4a05 | |
|
d59cb0a672 | |
|
c6f634d6a6 | |
|
0dd87cc282 | |
|
17e862b801 | |
|
f3bd6dd183 | |
|
440b56a9f0 | |
|
d9210f738d | |
|
b0b5c31821 | |
|
70cf73b032 | |
|
f70ce01b51 | |
|
35b8621306 | |
|
0a8cb5f2c1 | |
|
61635500f2 | |
|
ddf498d5ad | |
|
14b1418f6a | |
|
35799f8d2d | |
|
686f707078 | |
|
11757d87fb | |
|
710b54869a | |
|
35681032d9 | |
|
02386eebcc | |
|
4f51adf8bf | |
|
e446f34280 | |
|
5c04baf757 | |
|
43c2ffead2 | |
|
a9ad206edc | |
|
9c3908e003 | |
|
9287b05d57 | |
|
09c867f747 | |
|
6e23222187 | |
|
046d128c97 | |
|
928b4c6abc | |
|
32fa577368 | |
|
258d7e05d6 | |
|
82a34fe4b8 | |
|
c781933d6b | |
|
f2189a32f4 | |
|
c8afb239a0 | |
|
d0a694a7fe | |
|
75d5a8a8f9 | |
|
3ee93ee68d | |
|
10e19a3944 | |
|
0fb44180c0 | |
|
130c1d8dd6 | |
|
8f3ce6f49a | |
|
b1f29dc497 | |
|
131c91b786 | |
|
02dd86a37d | |
|
0db8b2d012 | |
|
ad1e4dcd11 | |
|
409ce057f3 | |
|
150c6a6554 | |
|
655f54af19 | |
|
802bb073b0 | |
|
e2fa0a6392 | |
|
61102548f4 | |
|
eded28cc74 | |
|
27215982e6 | |
|
da8a378b38 | |
|
4e498ad3b7 | |
|
2e2f1d673a | |
|
868d970784 | |
|
d2114e913c | |
|
551e079da8 | |
|
15b0f07b37 | |
|
918436af7e | |
|
721cb84d2a | |
|
e3fb39e3fe | |
|
b277d96065 | |
|
ba80c1b6d6 | |
|
e28bcd400b | |
|
149cc270ff | |
|
27c9792108 | |
|
01a389cb68 | |
|
e065e5b315 | |
|
1b007dd7fc | |
|
fd4ddf588f | |
|
1a3d061954 | |
|
466f599d11 | |
|
dc584bb671 | |
|
cc823e7db1 | |
|
221b222f86 | |
|
1ee94a168b | |
|
44003d802f | |
|
2d71fd9e22 | |
|
cf5bc20b1b | |
|
c37e9551ad | |
|
c0ab4beb0c | |
|
65a3f0b6f4 | |
|
9635596b0b | |
|
06ff539b17 | |
|
5d4a0b4f00 | |
|
eb7aad96c0 | |
|
0b294c5d50 | |
|
65d7e3fad1 | |
|
d85d3e861c | |
|
160d1b4415 | |
|
75d8607643 | |
|
abb1755311 | |
|
457485dae7 | |
|
5f89facf9e | |
|
68f6eeb3ad | |
|
7b023ad59d | |
|
b3412e8930 | |
|
33e72abff9 | |
|
824e239915 | |
|
4353b05cf1 | |
|
413cc49d3b | |
|
454f192562 | |
|
484d564b5d | |
|
882050600e | |
|
39ab923224 | |
|
cefb0c6e9e | |
|
05796cb497 | |
|
94c6c8e5db | |
|
c21608b0a0 | |
|
d27c259928 | |
|
298bbddeb1 | |
|
2f8e96a6b6 | |
|
eef4e17727 | |
|
ecf9352a25 | |
|
e04a6e39f3 | |
|
b9469a4acc | |
|
34640fe559 | |
|
bb1dbc887b | |
|
75d82c2a93 | |
|
e6b546c358 | |
|
8d4f0be202 | |
|
4cb4308a11 | |
|
8cf877a1cd | |
|
a06e9cc3b2 | |
|
595cf81eb8 | |
|
d486e39255 | |
|
d2b79e7185 | |
|
894571c484 | |
|
a2978c8cb9 | |
|
bcaba7b7c6 | |
|
8af54ff2fa | |
|
723e0e2c1a | |
|
5d818ccc71 | |
|
a89474786e | |
|
1e81dbdf17 | |
|
0b1a080bb0 | |
|
7cda5f7e53 | |
|
97b07d9972 | |
|
c98b49aaf4 | |
|
24eff67e60 | |
|
56ca2c3cb0 | |
|
e14cd169e1 | |
|
61ae19d7e4 | |
|
799912b953 | |
|
dc78ea1ac8 | |
|
90fcf7cfd5 | |
|
175a42bd49 | |
|
c56dd706ce | |
|
f0013a8815 | |
|
87d7908063 | |
|
7d87d1ee8a | |
|
a2bb9f117b | |
|
7a7b69c73d | |
|
2ba1db0362 | |
|
142d02ce43 | |
|
1870c11c0b | |
|
899c388ca7 | |
|
4a48297387 | |
|
32410ebca7 | |
|
2b85b27c17 | |
|
723072726e | |
|
4a6bd57977 | |
|
cff2fde9f9 | |
|
ce7cad8bd3 | |
|
0e5a3e2f6a | |
|
e219aad7e5 | |
|
5c98ba78cb | |
|
f5d0b8bfb0 | |
|
2c014197c7 | |
|
2c378da929 |
|
@ -1,2 +1,3 @@
|
|||
*.factor text eol=lf
|
||||
*.html text eol=lf
|
||||
misc/vim/*/*/generated.vim linguist-generated
|
||||
|
|
|
@ -38,7 +38,7 @@ build script:
|
|||
* Windows: `build.cmd`
|
||||
|
||||
or download the correct boot image for your system from
|
||||
http://downloads.factorcode.org/images/master/, put it in the factor
|
||||
http://downloads.factorcode.org/images/master/, put it in the `factor`
|
||||
directory and run:
|
||||
|
||||
* Unix: `make` and then `./factor -i=boot.unix-x86.64.image`
|
||||
|
|
|
@ -41,8 +41,8 @@ HELP: memory>byte-array
|
|||
|
||||
HELP: cast-array
|
||||
{ $values { "byte-array" byte-array } { "c-type" "a C type" } { "array" "a specialized array" } }
|
||||
{ $description "Converts a byte array into a specialized array by interpreting the bytes in as machine-specific values. Code which uses this word is unportable." }
|
||||
{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
|
||||
{ $description "Converts a " { $link byte-array } " into a specialized array by interpreting the bytes in it as machine-specific values. Code using this word is unportable." }
|
||||
{ $notes "The appropriate specialized array vocabulary must be loaded, otherwise an error will be thrown. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
|
||||
{ $errors "Throws an error if the type does not exist, the necessary specialized array vocabulary is not loaded, or the requested size is negative." } ;
|
||||
|
||||
HELP: malloc-array
|
||||
|
@ -257,4 +257,4 @@ ARTICLE: "c-out-params" "Output parameters in C"
|
|||
{ $code
|
||||
"1234 { c-string } [ do_frob ] with-out-parameters"
|
||||
}
|
||||
"which would put the functions return value and error string on the stack." ;
|
||||
"which would put the function's return value and error string on the stack." ;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
USING: alien.libraries.finder sequences tools.test ;
|
||||
IN: alien.libraries.finder.linux.tests
|
||||
|
||||
{ t } [ "libm.so" "m" find-library subseq? ] unit-test
|
||||
{ t } [ "libc.so" "c" find-library subseq? ] unit-test
|
||||
|
|
|
@ -44,4 +44,4 @@ PRIVATE>
|
|||
|
||||
M: linux find-library*
|
||||
"lib" prepend load-ldconfig-cache
|
||||
[ ldconfig-matches? ] with find nip ?first ;
|
||||
[ ldconfig-matches? ] with find nip ?last ;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
|
||||
USING: alien.libraries.finder
|
||||
USING: alien.libraries.finder alien.libraries.finder.macosx
|
||||
alien.libraries.finder.macosx.private sequences tools.test ;
|
||||
|
||||
IN: alien.libraries.finder.macosx
|
||||
|
||||
{
|
||||
{
|
||||
f
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
USING: alien.libraries.finder sequences tools.test ;
|
||||
|
||||
{ t } [ "kernel32.dll" "kernel32" find-library subseq? ] unit-test
|
|
@ -166,10 +166,10 @@ ERROR: not-enough-bits n bit-reader ;
|
|||
bs bytes>> subseq endian> execute( seq -- x )
|
||||
n bs subseq-endian execute( bignum n bs -- bits ) ;
|
||||
|
||||
M: lsb0-bit-reader peek ( n bs -- bits )
|
||||
M: lsb0-bit-reader peek
|
||||
\ le> \ subseq>bits-le (peek) ;
|
||||
|
||||
M: msb0-bit-reader peek ( n bs -- bits )
|
||||
M: msb0-bit-reader peek
|
||||
\ be> \ subseq>bits-be (peek) ;
|
||||
|
||||
:: bit-writer-bytes ( writer -- bytes )
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
! Copyright (C) 2004, 2011 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays assocs byte-arrays classes classes.builtin
|
||||
classes.private classes.tuple classes.tuple.private combinators
|
||||
combinators.short-circuit combinators.smart
|
||||
compiler.codegen.relocation compiler.units fry generic
|
||||
generic.single.private grouping hashtables hashtables.private io
|
||||
io.binary io.encodings.binary io.files io.pathnames kernel
|
||||
kernel.private layouts locals make math math.order namespaces
|
||||
namespaces.private parser parser.notes prettyprint quotations
|
||||
sequences sequences.private source-files strings system vectors
|
||||
vocabs words ;
|
||||
USING: accessors arrays assocs byte-arrays classes
|
||||
classes.builtin classes.private classes.tuple
|
||||
classes.tuple.private combinators combinators.short-circuit
|
||||
combinators.smart command-line compiler.codegen.relocation
|
||||
compiler.units fry generic generic.single.private grouping
|
||||
hashtables hashtables.private io io.binary io.encodings.binary
|
||||
io.files io.pathnames kernel kernel.private layouts locals make
|
||||
math math.order namespaces namespaces.private parser
|
||||
parser.notes prettyprint quotations sequences sequences.private
|
||||
source-files strings system vectors vocabs words ;
|
||||
IN: bootstrap.image
|
||||
|
||||
: arch-name ( os cpu -- arch )
|
||||
|
@ -541,4 +541,7 @@ PRIVATE>
|
|||
: make-my-image ( -- )
|
||||
my-arch-name make-image ;
|
||||
|
||||
MAIN: make-my-image
|
||||
: make-image-main ( -- )
|
||||
command-line get [ make-my-image ] [ [ make-image ] each ] if-empty ;
|
||||
|
||||
MAIN: make-image-main
|
||||
|
|
|
@ -778,8 +778,8 @@ CONSTANT: all-primitives {
|
|||
{
|
||||
"tools.profiler.sampling.private"
|
||||
{
|
||||
{ "profiling" ( n -- ) "sampling_profiler" { object } { } f }
|
||||
{ "(get-samples)" ( -- samples/f ) "get_samples" { } { object } f }
|
||||
{ "set-profiling" ( n -- ) "set_profiling" { object } { } f }
|
||||
{ "get-samples" ( -- samples/f ) "get_samples" { } { object } f }
|
||||
}
|
||||
}
|
||||
{
|
||||
|
|
|
@ -47,14 +47,7 @@ SYMBOL: build-images-destination
|
|||
] each
|
||||
] with-file-writer ;
|
||||
|
||||
! Windows scp doesn't like pathnames with colons, it treats them as hostnames.
|
||||
! Workaround for uploading checksums.txt created with temp-file.
|
||||
! e.g. C:\Users\\Doug\\AppData\\Local\\Temp/factorcode.org\\Factor/checksums.txt
|
||||
! ssh: Could not resolve hostname c: no address associated with name
|
||||
|
||||
HOOK: scp-name os ( -- path )
|
||||
M: object scp-name "scp" ;
|
||||
M: windows scp-name "pscp" ;
|
||||
: scp-name ( -- path ) "scp" ;
|
||||
|
||||
: upload-images ( -- )
|
||||
[
|
||||
|
|
|
@ -31,11 +31,11 @@ GENERIC: from ( channel -- value )
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: channel to ( value channel -- )
|
||||
M: channel to
|
||||
dup receivers>>
|
||||
[ dup wait to ] [ nip (to) ] if-empty ;
|
||||
|
||||
M: channel from ( channel -- value )
|
||||
M: channel from
|
||||
[ self ] dip
|
||||
notify senders>>
|
||||
[ (from) ] unless-empty
|
||||
|
|
|
@ -60,10 +60,10 @@ C: <remote-channel> remote-channel
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: remote-channel to ( value remote-channel -- )
|
||||
M: remote-channel to
|
||||
[ id>> swap to-message boa ] keep send-message drop ;
|
||||
|
||||
M: remote-channel from ( remote-channel -- value )
|
||||
M: remote-channel from
|
||||
[ id>> from-message boa ] keep send-message ;
|
||||
|
||||
[
|
||||
|
|
|
@ -8,7 +8,7 @@ SINGLETON: adler-32
|
|||
|
||||
CONSTANT: adler-32-modulus 65521
|
||||
|
||||
M: adler-32 checksum-bytes ( bytes checksum -- value )
|
||||
M: adler-32 checksum-bytes
|
||||
drop
|
||||
[ sum 1 + ]
|
||||
[ [ dup length [1,b] <reversed> vdot ] [ length ] bi + ] bi
|
||||
|
|
|
@ -5,7 +5,7 @@ IN: checksums.bsd
|
|||
|
||||
SINGLETON: bsd
|
||||
|
||||
M: bsd checksum-bytes ( bytes checksum -- value )
|
||||
M: bsd checksum-bytes
|
||||
drop 0 [
|
||||
[ [ -1 shift ] [ 1 bitand 15 shift ] bi + ] dip
|
||||
+ 0xffff bitand
|
||||
|
|
|
@ -38,67 +38,67 @@ CONSTANT: fnv1-256-basis 0xdd268dbcaac550362d98c384c4e576ccc8b1536847b6bbb31023b
|
|||
CONSTANT: fnv1-512-basis 0xb86db0b1171f4416dca1e50f309990acac87d059c90000000000000000000d21e948f68a34c192f62ea79bc942dbe7ce182036415f56e34bac982aac4afe9fd9
|
||||
CONSTANT: fnv1-1024-basis 0x5f7a76758ecc4d32e56d5a591028b74b29fc4223fdada16c3bf34eda3674da9a21d9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c6d7eb6e73802734510a555f256cc005ae556bde8cc9c6a93b21aff4b16c71ee90b3
|
||||
|
||||
M: fnv1-32 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-32 checksum-bytes
|
||||
drop
|
||||
fnv1-32-basis swap
|
||||
[ swap fnv1-32-prime * bitxor fnv1-32-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-32 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-32 checksum-bytes
|
||||
drop
|
||||
fnv1-32-basis swap
|
||||
[ bitxor fnv1-32-prime * fnv1-32-mod bitand ] each ;
|
||||
|
||||
|
||||
M: fnv1-64 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-64 checksum-bytes
|
||||
drop
|
||||
fnv1-64-basis swap
|
||||
[ swap fnv1-64-prime * bitxor fnv1-64-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-64 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-64 checksum-bytes
|
||||
drop
|
||||
fnv1-64-basis swap
|
||||
[ bitxor fnv1-64-prime * fnv1-64-mod bitand ] each ;
|
||||
|
||||
|
||||
M: fnv1-128 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-128 checksum-bytes
|
||||
drop
|
||||
fnv1-128-basis swap
|
||||
[ swap fnv1-128-prime * bitxor fnv1-128-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-128 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-128 checksum-bytes
|
||||
drop
|
||||
fnv1-128-basis swap
|
||||
[ bitxor fnv1-128-prime * fnv1-128-mod bitand ] each ;
|
||||
|
||||
|
||||
M: fnv1-256 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-256 checksum-bytes
|
||||
drop
|
||||
fnv1-256-basis swap
|
||||
[ swap fnv1-256-prime * bitxor fnv1-256-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-256 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-256 checksum-bytes
|
||||
drop
|
||||
fnv1-256-basis swap
|
||||
[ bitxor fnv1-256-prime * fnv1-256-mod bitand ] each ;
|
||||
|
||||
|
||||
M: fnv1-512 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-512 checksum-bytes
|
||||
drop
|
||||
fnv1-512-basis swap
|
||||
[ swap fnv1-512-prime * bitxor fnv1-512-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-512 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-512 checksum-bytes
|
||||
drop
|
||||
fnv1-512-basis swap
|
||||
[ bitxor fnv1-512-prime * fnv1-512-mod bitand ] each ;
|
||||
|
||||
|
||||
M: fnv1-1024 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1-1024 checksum-bytes
|
||||
drop
|
||||
fnv1-1024-basis swap
|
||||
[ swap fnv1-1024-prime * bitxor fnv1-1024-mod bitand ] each ;
|
||||
|
||||
M: fnv1a-1024 checksum-bytes ( bytes checksum -- value )
|
||||
M: fnv1a-1024 checksum-bytes
|
||||
drop
|
||||
fnv1-1024-basis swap
|
||||
[ bitxor fnv1-1024-prime * fnv1-1024-mod bitand ] each ;
|
||||
|
|
|
@ -47,7 +47,7 @@ CONSTANT: n 0xe6546b64
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: murmur3-32 checksum-bytes ( bytes checksum -- value )
|
||||
M: murmur3-32 checksum-bytes
|
||||
seed>> 32 bits main-loop end-case avalanche ;
|
||||
|
||||
INSTANCE: murmur3-32 checksum
|
||||
|
|
|
@ -38,13 +38,13 @@ M: evp-md-context dispose*
|
|||
: set-digest ( name ctx -- )
|
||||
handle>> swap digest-named f EVP_DigestInit_ex ssl-error ;
|
||||
|
||||
M: openssl-checksum initialize-checksum-state ( checksum -- evp-md-context )
|
||||
M: openssl-checksum initialize-checksum-state
|
||||
maybe-init-ssl name>> <evp-md-context> [ set-digest ] keep ;
|
||||
|
||||
M: evp-md-context add-checksum-bytes ( ctx bytes -- ctx' )
|
||||
M: evp-md-context add-checksum-bytes
|
||||
[ dup handle>> ] dip dup length EVP_DigestUpdate ssl-error ;
|
||||
|
||||
M: evp-md-context get-checksum ( ctx -- value )
|
||||
M: evp-md-context get-checksum
|
||||
handle>>
|
||||
{ { int EVP_MAX_MD_SIZE } int }
|
||||
[ EVP_DigestFinal_ex ssl-error ] with-out-parameters
|
||||
|
|
|
@ -116,7 +116,7 @@ M: struct-mirror delete-at
|
|||
M: struct-mirror clear-assoc
|
||||
object>> reset-struct-slots ;
|
||||
|
||||
M: struct-mirror >alist ( mirror -- alist )
|
||||
M: struct-mirror >alist
|
||||
object>> [
|
||||
[ drop "underlying" ] [ >c-ptr ] bi 2array 1array
|
||||
] [
|
||||
|
|
|
@ -7,7 +7,7 @@ TUPLE: gray < color { gray read-only } { alpha read-only } ;
|
|||
|
||||
C: <gray> gray
|
||||
|
||||
M: gray >rgba ( gray -- rgba )
|
||||
M: gray >rgba
|
||||
[ gray>> dup dup ] [ alpha>> ] bi <rgba> ; inline
|
||||
|
||||
M: gray red>> gray>> ;
|
||||
|
|
|
@ -6,12 +6,15 @@ lexer math math.parser sequences ;
|
|||
|
||||
IN: colors.hex
|
||||
|
||||
ERROR: invalid-hex-color hex ;
|
||||
|
||||
: hex>rgba ( hex -- rgba )
|
||||
dup length {
|
||||
{ 6 [ 2 group [ hex> 255 /f ] map first3 1.0 ] }
|
||||
{ 8 [ 2 group [ hex> 255 /f ] map first4 ] }
|
||||
{ 3 [ [ digit> 15 /f ] { } map-as first3 1.0 ] }
|
||||
{ 4 [ [ digit> 15 /f ] { } map-as first4 ] }
|
||||
[ drop invalid-hex-color ]
|
||||
} case <rgba> ;
|
||||
|
||||
: rgba>hex ( rgba -- hex )
|
||||
|
|
|
@ -29,7 +29,7 @@ C: <hsva> hsva
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: hsva >rgba ( hsva -- rgba )
|
||||
M: hsva >rgba
|
||||
[
|
||||
dup Hi
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ C: <ryba> ryba
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: ryba >rgba ( ryba -- rgba )
|
||||
M: ryba >rgba
|
||||
[
|
||||
[ red>> ] [ yellow>> ] [ blue>> ] tri
|
||||
[ ryb>rgb ] normalized
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
USING: help.markup help.syntax strings system vocabs vocabs.loader ;
|
||||
USING: help.markup help.syntax io.pathnames strings system vocabs vocabs.loader ;
|
||||
IN: command-line
|
||||
|
||||
HELP: run-bootstrap-init
|
||||
{ $description "Runs the bootstrap initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-boot-rc" } "." } ;
|
||||
{ $description "Runs the bootstrap initialization file in the user's " { $link home } " directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-boot-rc" } "." } ;
|
||||
|
||||
HELP: run-user-init
|
||||
{ $description "Runs the startup initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } "." } ;
|
||||
{ $description "Runs the startup initialization file in the user's " { $link home } " directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } "." } ;
|
||||
|
||||
HELP: load-vocab-roots
|
||||
{ $description "Loads the newline-separated list of additional vocabulary roots from the file named " { $snippet ".factor-roots" } "." } ;
|
||||
|
@ -117,7 +117,7 @@ $nl
|
|||
{ $subsections load-vocab-roots } ;
|
||||
|
||||
ARTICLE: "rc-files" "Running code on startup"
|
||||
"Factor looks for three optional files in your home directory."
|
||||
"Factor looks for three optional files in the user's " { $link home } " directory."
|
||||
{ $subsections
|
||||
".factor-boot-rc"
|
||||
".factor-rc"
|
||||
|
@ -125,12 +125,6 @@ ARTICLE: "rc-files" "Running code on startup"
|
|||
}
|
||||
"The " { $snippet "-no-user-init" } " command line switch will inhibit loading running of these files."
|
||||
$nl
|
||||
"If you are unsure where the files should be located, evaluate the following code:"
|
||||
{ $code
|
||||
"USE: command-line"
|
||||
"\".factor-rc\" rc-path print"
|
||||
"\".factor-boot-rc\" rc-path print"
|
||||
}
|
||||
"Here is an example " { $snippet ".factor-boot-rc" } " which sets up your developer name:"
|
||||
{ $code
|
||||
"USING: tools.scaffold namespaces ;"
|
||||
|
@ -139,8 +133,8 @@ $nl
|
|||
|
||||
ARTICLE: "command-line" "Command line arguments"
|
||||
"Factor command line usage:"
|
||||
{ $code "factor [VM args...] [script] [args...]" }
|
||||
"Zero or more VM arguments can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
|
||||
{ $code "factor [options] [script] [arguments]" }
|
||||
"Zero or more options can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
|
||||
{ $subsections command-line }
|
||||
"Instead of running a script, it is also possible to run a vocabulary; this invokes the vocabulary's " { $link POSTPONE: MAIN: } " word:"
|
||||
{ $code "factor [system switches...] -run=<vocab name>" }
|
||||
|
|
|
@ -24,9 +24,6 @@ SYMBOL: command-line
|
|||
: (command-line) ( -- args )
|
||||
OBJ-ARGS special-object sift [ alien>native-string ] map ;
|
||||
|
||||
: rc-path ( name -- path )
|
||||
home prepend-path ;
|
||||
|
||||
: try-user-init ( file -- )
|
||||
"user-init" get swap '[
|
||||
_ [ ?run-file ] [
|
||||
|
@ -37,14 +34,14 @@ SYMBOL: command-line
|
|||
] when ;
|
||||
|
||||
: run-bootstrap-init ( -- )
|
||||
".factor-boot-rc" rc-path try-user-init ;
|
||||
"~/.factor-boot-rc" try-user-init ;
|
||||
|
||||
: run-user-init ( -- )
|
||||
".factor-rc" rc-path try-user-init ;
|
||||
"~/.factor-rc" try-user-init ;
|
||||
|
||||
: load-vocab-roots ( -- )
|
||||
"user-init" get [
|
||||
".factor-roots" rc-path dup exists? [
|
||||
"~/.factor-roots" dup exists? [
|
||||
utf8 file-lines harvest [ add-vocab-root ] each
|
||||
] [ drop ] if
|
||||
"roots" get [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2011 Joe Groff.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: combinators command-line eval io io.pathnames kernel
|
||||
namespaces system vocabs.loader ;
|
||||
layouts math math.parser namespaces system vocabs.loader ;
|
||||
IN: command-line.startup
|
||||
|
||||
: help? ( -- ? )
|
||||
|
@ -9,35 +9,33 @@ IN: command-line.startup
|
|||
os windows? [ script get "/?" = or ] when ;
|
||||
|
||||
: help. ( -- )
|
||||
"Usage: " write vm-path file-name write " [Factor arguments] [script] [script arguments]
|
||||
"Usage: " write vm-path file-name write " [options] [script] [arguments]
|
||||
|
||||
Factor arguments:
|
||||
Options:
|
||||
-help print this message and exit
|
||||
-version print the Factor version and exit
|
||||
-i=<image> load Factor image file <image> (default " write vm-path file-stem write ".image)
|
||||
-i=<image> load Factor image file <image> [" write vm-path file-stem write ".image]
|
||||
-run=<vocab> run the MAIN: entry point of <vocab>
|
||||
-run=listener run terminal listener
|
||||
-run=ui.tools run Factor development UI
|
||||
-e=<code> evaluate <code>
|
||||
-no-user-init suppress loading of .factor-rc
|
||||
-datastack=<int> datastack size in KiB
|
||||
-retainstack=<int> retainstack size in KiB
|
||||
-callstack=<int> callstack size in KiB
|
||||
-callbacks=<int> callback heap size in KiB
|
||||
-young=<int> young gc generation 0 size in MiB
|
||||
-aging=<int> aging gc generation 1 size in MiB
|
||||
-tenured=<int> tenured gc generation 2 size in MiB
|
||||
-codeheap=<int> codeheap size in MiB
|
||||
-pic=<int> max pic size
|
||||
-datastack=<int> datastack size in KiB [" write cell 32 * number>string write "]
|
||||
-retainstack=<int> retainstack size in KiB [" write cell 32 * number>string write "]
|
||||
-callstack=<int> callstack size in KiB [" write cell cpu ppc? 256 128 ? * number>string write "]
|
||||
-callbacks=<int> callback heap size in KiB [256]
|
||||
-young=<int> young gc generation 0 size in MiB [" write cell 4 / number>string write "]
|
||||
-aging=<int> aging gc generation 1 size in MiB [" write cell 2 / number>string write "]
|
||||
-tenured=<int> tenured gc generation 2 size in MiB [" write cell 24 * number>string write "]
|
||||
-codeheap=<int> codeheap size in MiB [64]
|
||||
-pic=<int> max pic size [3]
|
||||
-fep enter fep mode immediately
|
||||
-no-signals turn off OS signal handling
|
||||
-console open console if possible
|
||||
-roots=<paths> a list of \"" write os windows? ";" ":" ? write "\"-delimited extra vocab roots
|
||||
-roots=<paths> '" write os windows? ";" ":" ? write "'-separated list of extra vocab root directories
|
||||
|
||||
Enter
|
||||
\"command-line\" help
|
||||
from within Factor for more information.
|
||||
|
||||
" write ;
|
||||
|
||||
: version? ( -- ? ) "version" get ;
|
||||
|
|
|
@ -95,7 +95,7 @@ IN: compiler.cfg.builder.alien
|
|||
[ stack-params get [ caller-stack-cleanup ] keep ]
|
||||
} cleave ;
|
||||
|
||||
M: #alien-invoke emit-node ( block node -- block' )
|
||||
M: #alien-invoke emit-node
|
||||
params>>
|
||||
[
|
||||
[ params>alien-insn-params ]
|
||||
|
@ -104,7 +104,7 @@ M: #alien-invoke emit-node ( block node -- block' )
|
|||
]
|
||||
[ caller-return ] bi ;
|
||||
|
||||
M: #alien-indirect emit-node ( block node -- block' )
|
||||
M: #alien-indirect emit-node
|
||||
params>>
|
||||
[
|
||||
[ ds-pop ^^unbox-any-c-ptr ] dip
|
||||
|
@ -113,7 +113,7 @@ M: #alien-indirect emit-node ( block node -- block' )
|
|||
]
|
||||
[ caller-return ] bi ;
|
||||
|
||||
M: #alien-assembly emit-node ( block node -- block' )
|
||||
M: #alien-assembly emit-node
|
||||
params>>
|
||||
[
|
||||
[ params>alien-insn-params ]
|
||||
|
@ -167,7 +167,7 @@ M: #alien-assembly emit-node ( block node -- block' )
|
|||
: emit-callback-outputs ( block params -- )
|
||||
[ emit-callback-return ] keep callback-stack-cleanup ;
|
||||
|
||||
M: #alien-callback emit-node ( block node -- block' )
|
||||
M: #alien-callback emit-node
|
||||
dup params>> xt>> dup
|
||||
[
|
||||
t cfg get frame-pointer?<<
|
||||
|
|
|
@ -88,7 +88,7 @@ M: long-long-type unbox
|
|||
int-rep long-long-on-stack? long-long-odd-register? 3array
|
||||
int-rep long-long-on-stack? f 3array 2array record-reg-reps ;
|
||||
|
||||
M: struct-c-type unbox ( src c-type -- vregs reps )
|
||||
M: struct-c-type unbox
|
||||
[ ^^unbox-any-c-ptr ] dip explode-struct ;
|
||||
|
||||
: frob-struct ( c-type -- c-type )
|
||||
|
|
|
@ -8,11 +8,11 @@ SYMBOL: stack-params
|
|||
|
||||
GENERIC: alloc-stack-param ( rep -- n )
|
||||
|
||||
M: object alloc-stack-param ( rep -- n )
|
||||
M: object alloc-stack-param
|
||||
stack-params get
|
||||
[ rep-size cell align stack-params +@ ] dip ;
|
||||
|
||||
M: float-rep alloc-stack-param ( rep -- n )
|
||||
M: float-rep alloc-stack-param
|
||||
stack-params get swap rep-size
|
||||
[ cell align stack-params +@ ] keep
|
||||
float-right-align-on-stack? [ + ] [ drop ] if ;
|
||||
|
|
|
@ -71,7 +71,7 @@ GENERIC: emit-node ( block node -- block' )
|
|||
##branch, [ begin-basic-block ] dip
|
||||
[ label>> id>> loops get set-at ] [ child>> emit-nodes ] 2bi ;
|
||||
|
||||
M: #recursive emit-node ( block node -- block' )
|
||||
M: #recursive emit-node
|
||||
dup label>> loop?>> [ emit-loop ] [ emit-recursive ] if ;
|
||||
|
||||
! #if
|
||||
|
@ -109,28 +109,28 @@ M: #recursive emit-node ( block node -- block' )
|
|||
! loc>vreg sync
|
||||
ds-pop any-rep ^^copy f cc/= ##compare-imm-branch, emit-if ;
|
||||
|
||||
M: #if emit-node ( block node -- block' )
|
||||
M: #if emit-node
|
||||
{
|
||||
{ [ dup trivial-if? ] [ drop emit-trivial-if ] }
|
||||
{ [ dup trivial-not-if? ] [ drop emit-trivial-not-if ] }
|
||||
[ emit-actual-if ]
|
||||
} cond ;
|
||||
|
||||
M: #dispatch emit-node ( block node -- block' )
|
||||
M: #dispatch emit-node
|
||||
! Inputs to the final instruction need to be copied because of
|
||||
! loc>vreg sync. ^^offset>slot always returns a fresh vreg,
|
||||
! though.
|
||||
ds-pop ^^offset>slot next-vreg ##dispatch, emit-if ;
|
||||
|
||||
M: #call emit-node ( block node -- block' )
|
||||
M: #call emit-node
|
||||
dup word>> dup "intrinsic" word-prop [
|
||||
nip call( block #call -- block' )
|
||||
] [ swap call-height emit-call ] if* ;
|
||||
|
||||
M: #call-recursive emit-node ( block node -- block' )
|
||||
M: #call-recursive emit-node
|
||||
[ label>> id>> ] [ call-height ] bi emit-call ;
|
||||
|
||||
M: #push emit-node ( block node -- block )
|
||||
M: #push emit-node
|
||||
literal>> ^^load-literal ds-push ;
|
||||
|
||||
! #shuffle
|
||||
|
@ -157,7 +157,7 @@ M: #push emit-node ( block node -- block )
|
|||
[ make-input-map ] [ mapping>> ] [ extract-outputs ] tri
|
||||
[ [ of of peek-loc ] 2with map ] 2with map ;
|
||||
|
||||
M: #shuffle emit-node ( block node -- block )
|
||||
M: #shuffle emit-node
|
||||
[ out-vregs/stack ] keep store-height-changes
|
||||
first2 [ ds-loc store-vregs ] [ rs-loc store-vregs ] bi* ;
|
||||
|
||||
|
@ -167,14 +167,14 @@ M: #shuffle emit-node ( block node -- block )
|
|||
t >>kill-block?
|
||||
##safepoint, ##epilogue, ##return, ;
|
||||
|
||||
M: #return emit-node ( block node -- block' )
|
||||
M: #return emit-node
|
||||
drop end-word ;
|
||||
|
||||
M: #return-recursive emit-node ( block node -- block' )
|
||||
M: #return-recursive emit-node
|
||||
label>> id>> loops get key? [ ] [ end-word ] if ;
|
||||
|
||||
! #terminate
|
||||
M: #terminate emit-node ( block node -- block' )
|
||||
M: #terminate emit-node
|
||||
drop ##no-tco, end-basic-block f ;
|
||||
|
||||
! No-op nodes
|
||||
|
|
|
@ -35,7 +35,7 @@ GENERIC: visit-insn ( live-set insn -- )
|
|||
: gen-uses ( live-set insn -- )
|
||||
uses-vregs [ swap conjoin ] with each ; inline
|
||||
|
||||
M: vreg-insn visit-insn ( live-set insn -- )
|
||||
M: vreg-insn visit-insn
|
||||
[ kill-defs ] [ gen-uses ] 2bi ;
|
||||
|
||||
DEFER: lookup-base-pointer
|
||||
|
@ -98,7 +98,7 @@ M: vreg-insn lookup-base-pointer* 2drop f ;
|
|||
: fill-gc-map ( live-set gc-map -- )
|
||||
[ gc-roots ] dip [ gc-roots<< ] [ derived-roots<< ] bi ;
|
||||
|
||||
M: gc-map-insn visit-insn ( live-set insn -- )
|
||||
M: gc-map-insn visit-insn
|
||||
[ kill-defs ] [ gc-map>> fill-gc-map ] [ gen-uses ] 2tri ;
|
||||
|
||||
M: ##phi visit-insn kill-defs ;
|
||||
|
|
|
@ -33,7 +33,7 @@ T{ error-type-holder
|
|||
{ type +compiler-error+ }
|
||||
{ word ":errors" }
|
||||
{ plural "compiler errors" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/compiler-error.tiff" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/compiler-error.png" }
|
||||
{ quot [ compiler-errors get values ] }
|
||||
{ forget-quot [ compiler-errors get delete-at ] }
|
||||
} define-error-type
|
||||
|
@ -51,7 +51,7 @@ T{ error-type-holder
|
|||
{ type +linkage-error+ }
|
||||
{ word ":linkage" }
|
||||
{ plural "linkage errors" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/linkage-error.png" }
|
||||
{ quot [ linkage-errors get values ] }
|
||||
{ forget-quot [ linkage-errors get delete-at ] }
|
||||
{ fatal? f }
|
||||
|
@ -77,7 +77,7 @@ T{ error-type-holder
|
|||
{ type +user-init-error+ }
|
||||
{ word ":user-init-errors" }
|
||||
{ plural "rc file errors" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/user-init-error.tiff" }
|
||||
{ icon "vocab:ui/tools/error-list/icons/user-init-error.png" }
|
||||
{ quot [ user-init-errors get-global values ] }
|
||||
{ forget-quot [ user-init-errors get-global delete-at ] }
|
||||
} define-error-type
|
||||
|
|
|
@ -9,7 +9,7 @@ IN: compiler.tree.escape-analysis.branches
|
|||
|
||||
M: #branch escape-analysis*
|
||||
[ in-d>> add-escaping-values ]
|
||||
[ live-children sift [ (escape-analysis) ] each ]
|
||||
[ live-children [ [ (escape-analysis) ] when* ] each ]
|
||||
bi ;
|
||||
|
||||
: (merge-allocations) ( values -- allocation )
|
||||
|
|
|
@ -34,7 +34,7 @@ M: true-constraint satisfied?
|
|||
|
||||
TUPLE: false-constraint value ;
|
||||
|
||||
: =f ( value -- constriant ) resolve-copy false-constraint boa ;
|
||||
: =f ( value -- constraint ) resolve-copy false-constraint boa ;
|
||||
|
||||
M: false-constraint assume*
|
||||
[ \ f <class-info> swap value>> refine-value-info ]
|
||||
|
|
|
@ -358,7 +358,7 @@ generic-comparison-ops [
|
|||
|
||||
\ instance? [
|
||||
! We need to force the caller word to recompile when the class
|
||||
! is redefined, since now we're making assumptions but the
|
||||
! is redefined, since now we're making assumptions about the
|
||||
! class definition itself.
|
||||
dup literal>> classoid?
|
||||
[
|
||||
|
|
|
@ -47,9 +47,6 @@ IN: compiler.tree.propagation.slots
|
|||
[ swap slot <literal-info> ]
|
||||
} 2&& ;
|
||||
|
||||
: length-accessor? ( slot info -- ? )
|
||||
[ 1 = ] [ length>> ] bi* and ;
|
||||
|
||||
: value-info-slot ( slot info -- info' )
|
||||
{
|
||||
{ [ over 0 = ] [ 2drop fixnum <class-info> ] }
|
||||
|
|
|
@ -196,7 +196,8 @@ ERROR: bad-partial-eval quot word ;
|
|||
dup classoid?
|
||||
[
|
||||
predicate-def
|
||||
! union{ and intersection{ have useless expansions, and recurse infinitely
|
||||
! union{ and intersection{ and not{ have useless
|
||||
! expansions, and recurse infinitely
|
||||
dup { [ length 2 >= ] [ second \ instance? = ] } 1&& [
|
||||
drop f
|
||||
] when
|
||||
|
|
|
@ -68,11 +68,11 @@ C: <connection> connection
|
|||
: send-to-connection ( message connection -- )
|
||||
stream>> [ serialize flush ] with-stream* ;
|
||||
|
||||
M: remote-thread send ( message thread -- )
|
||||
M: remote-thread send
|
||||
[ id>> 2array ] [ node>> ] [ thread-connections at ] tri
|
||||
[ nip send-to-connection ] [ send-remote-message ] if* ;
|
||||
|
||||
M: thread (serialize) ( obj -- )
|
||||
M: thread (serialize)
|
||||
id>> [ local-node get insecure>> ] dip <remote-thread> (serialize) ;
|
||||
|
||||
: stop-node ( -- )
|
||||
|
|
|
@ -13,7 +13,7 @@ M: thread mailbox-of
|
|||
[ { mailbox } declare ]
|
||||
[ <mailbox> [ >>mailbox drop ] keep ] ?if ; inline
|
||||
|
||||
M: thread send ( message thread -- )
|
||||
M: thread send
|
||||
mailbox-of mailbox-put ;
|
||||
|
||||
: my-mailbox ( -- mailbox ) self mailbox-of ; inline
|
||||
|
|
|
@ -77,9 +77,7 @@ render-loc render-dim ;
|
|||
compute-height ;
|
||||
|
||||
: metrics>dim ( bounds -- dim )
|
||||
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi
|
||||
[ ceiling >integer ]
|
||||
bi@ 2array ;
|
||||
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi 2array ;
|
||||
|
||||
: fill-background ( context font dim -- )
|
||||
[ background>> >rgba-components CGContextSetRGBFillColor ]
|
||||
|
@ -88,7 +86,7 @@ render-loc render-dim ;
|
|||
|
||||
: selection-rect ( dim line selection -- rect )
|
||||
[let [ start>> ] [ end>> ] [ string>> ] tri :> ( start end string )
|
||||
start end [ 0 swap string subseq utf16n encode length 2 / >integer ] bi@
|
||||
start end [ 0 swap string subseq utf16n encode length 2 /i ] bi@
|
||||
]
|
||||
[ f CTLineGetOffsetForStringIndex round ] bi-curry@ bi
|
||||
[ drop nip 0 ] [ swap - swap second ] 3bi <CGRect> ;
|
||||
|
|
|
@ -18,7 +18,7 @@ SYMBOL: couch
|
|||
TUPLE: couchdb-error { data assoc } ;
|
||||
C: <couchdb-error> couchdb-error
|
||||
|
||||
M: couchdb-error error. ( error -- )
|
||||
M: couchdb-error error.
|
||||
"CouchDB Error: " write data>>
|
||||
"error" over at [ print ] when*
|
||||
"reason" of [ print ] when* ;
|
||||
|
|
|
@ -524,7 +524,7 @@ HOOK: immediate-bitwise? cpu ( n -- ? )
|
|||
HOOK: immediate-comparand? cpu ( n -- ? )
|
||||
HOOK: immediate-store? cpu ( n -- ? )
|
||||
|
||||
M: object immediate-comparand? ( n -- ? )
|
||||
M: object immediate-comparand?
|
||||
{
|
||||
{ [ dup fixnum? ] [ tag-fixnum immediate-arithmetic? ] }
|
||||
{ [ dup not ] [ drop t ] }
|
||||
|
|
|
@ -5,13 +5,13 @@ compiler.cfg.builder.alien.boxing sequences arrays
|
|||
alien.c-types cpu.architecture cpu.ppc alien.complex ;
|
||||
IN: cpu.ppc.32.linux
|
||||
|
||||
M: linux lr-save ( -- n ) 1 cells ;
|
||||
M: linux lr-save 1 cells ;
|
||||
|
||||
M: linux has-toc ( -- ? ) f ;
|
||||
M: linux has-toc f ;
|
||||
|
||||
M: linux reserved-area-size ( -- n ) 2 cells ;
|
||||
M: linux reserved-area-size 2 cells ;
|
||||
|
||||
M: linux allows-null-dereference ( -- ? ) f ;
|
||||
M: linux allows-null-dereference f ;
|
||||
|
||||
M: ppc param-regs
|
||||
drop {
|
||||
|
@ -35,7 +35,7 @@ M: ppc long-long-odd-register? t ;
|
|||
|
||||
M: ppc float-right-align-on-stack? f ;
|
||||
|
||||
M: ppc flatten-struct-type ( type -- seq )
|
||||
M: ppc flatten-struct-type
|
||||
{
|
||||
{ [ dup lookup-c-type complex-double lookup-c-type = ]
|
||||
[ drop { { int-rep f f } { int-rep f f }
|
||||
|
|
|
@ -7,11 +7,11 @@ IN: cpu.ppc.64.linux
|
|||
|
||||
M: linux lr-save 2 cells ;
|
||||
|
||||
M: linux has-toc ( -- ? ) t ;
|
||||
M: linux has-toc t ;
|
||||
|
||||
M: linux reserved-area-size ( -- n ) 6 cells ;
|
||||
M: linux reserved-area-size 6 cells ;
|
||||
|
||||
M: linux allows-null-dereference ( -- ? ) f ;
|
||||
M: linux allows-null-dereference f ;
|
||||
|
||||
M: ppc param-regs
|
||||
drop {
|
||||
|
@ -33,7 +33,7 @@ M: ppc long-long-odd-register? f ;
|
|||
|
||||
M: ppc float-right-align-on-stack? t ;
|
||||
|
||||
M: ppc flatten-struct-type ( type -- seq )
|
||||
M: ppc flatten-struct-type
|
||||
{
|
||||
{ [ dup lookup-c-type complex-double lookup-c-type = ]
|
||||
[ drop { { double-rep f f } { double-rep f f } } ] }
|
||||
|
@ -42,7 +42,7 @@ M: ppc flatten-struct-type ( type -- seq )
|
|||
[ heap-size cell align cell /i { int-rep f f } <repetition> ]
|
||||
} cond ;
|
||||
|
||||
M: ppc flatten-struct-type-return ( type -- seq )
|
||||
M: ppc flatten-struct-type-return
|
||||
{
|
||||
{ [ dup lookup-c-type complex-double lookup-c-type = ]
|
||||
[ drop { { double-rep f f } { double-rep f f } } ] }
|
||||
|
|
|
@ -115,16 +115,16 @@ IN: cpu.ppc.assembler
|
|||
|
||||
! 2.4 Branch Instructions
|
||||
GENERIC: B ( target_addr/label -- )
|
||||
M: integer B ( target_addr -- ) -2 shift 0 0 18 i-insn ;
|
||||
M: integer B -2 shift 0 0 18 i-insn ;
|
||||
|
||||
GENERIC: BL ( target_addr/label -- )
|
||||
M: integer BL ( target_addr -- ) -2 shift 0 1 18 i-insn ;
|
||||
M: integer BL -2 shift 0 1 18 i-insn ;
|
||||
|
||||
: BA ( target_addr -- ) -2 shift 1 0 18 i-insn ;
|
||||
: BLA ( target_addr -- ) -2 shift 1 1 18 i-insn ;
|
||||
|
||||
GENERIC: BC ( bo bi target_addr/label -- )
|
||||
M: integer BC ( bo bi target_addr -- ) -2 shift 0 0 16 b-insn ;
|
||||
M: integer BC -2 shift 0 0 16 b-insn ;
|
||||
|
||||
: BCA ( bo bi target_addr -- ) -2 shift 1 0 16 b-insn ;
|
||||
: BCL ( bo bi target_addr -- ) -2 shift 0 1 16 b-insn ;
|
||||
|
|
|
@ -34,9 +34,9 @@ HOOK: has-toc os ( -- ? )
|
|||
HOOK: reserved-area-size os ( -- n )
|
||||
HOOK: allows-null-dereference os ( -- ? )
|
||||
|
||||
M: label B ( label -- ) [ 0 B ] dip rc-relative-ppc-3-pc label-fixup ;
|
||||
M: label BL ( label -- ) [ 0 BL ] dip rc-relative-ppc-3-pc label-fixup ;
|
||||
M: label BC ( bo bi label -- ) [ 0 BC ] dip rc-relative-ppc-2-pc label-fixup ;
|
||||
M: label B [ 0 B ] dip rc-relative-ppc-3-pc label-fixup ;
|
||||
M: label BL [ 0 BL ] dip rc-relative-ppc-3-pc label-fixup ;
|
||||
M: label BC [ 0 BC ] dip rc-relative-ppc-2-pc label-fixup ;
|
||||
|
||||
CONSTANT: scratch-reg 30
|
||||
CONSTANT: fp-scratch-reg 30
|
||||
|
@ -44,16 +44,16 @@ CONSTANT: ds-reg 14
|
|||
CONSTANT: rs-reg 15
|
||||
CONSTANT: vm-reg 16
|
||||
|
||||
M: ppc machine-registers ( -- assoc )
|
||||
M: ppc machine-registers
|
||||
{
|
||||
{ int-regs $[ 3 12 [a,b] 17 29 [a,b] append ] }
|
||||
{ float-regs $[ 0 29 [a,b] ] }
|
||||
} ;
|
||||
|
||||
M: ppc frame-reg ( -- reg ) 31 ;
|
||||
M: ppc.32 vm-stack-space ( -- n ) 16 ;
|
||||
M: ppc.64 vm-stack-space ( -- n ) 32 ;
|
||||
M: ppc complex-addressing? ( -- ? ) f ;
|
||||
M: ppc frame-reg 31 ;
|
||||
M: ppc.32 vm-stack-space 16 ;
|
||||
M: ppc.64 vm-stack-space 32 ;
|
||||
M: ppc complex-addressing? f ;
|
||||
|
||||
! PW1-PW8 parameter save slots
|
||||
: param-save-size ( -- n ) 8 cells ; foldable
|
||||
|
@ -67,7 +67,7 @@ M: ppc complex-addressing? ( -- ? ) f ;
|
|||
: param@ ( n -- offset )
|
||||
reserved-area-size + ;
|
||||
|
||||
M: ppc gc-root-offset ( spill-slot -- n )
|
||||
M: ppc gc-root-offset
|
||||
n>> spill@ cell /i ;
|
||||
|
||||
: LOAD32 ( r n -- )
|
||||
|
@ -129,12 +129,12 @@ HOOK: %load-cell-imm-rc cpu ( -- rel-class )
|
|||
M: ppc.32 %load-cell-imm-rc rc-absolute-ppc-2/2 ;
|
||||
M: ppc.64 %load-cell-imm-rc rc-absolute-ppc-2/2/2/2 ;
|
||||
|
||||
M: ppc.32 %load-immediate ( reg val -- )
|
||||
M: ppc.32 %load-immediate
|
||||
dup -0x8000 0x7fff between? [ LI ] [ LOAD32 ] if ;
|
||||
M: ppc.64 %load-immediate ( reg val -- )
|
||||
M: ppc.64 %load-immediate
|
||||
dup -0x8000 0x7fff between? [ LI ] [ LOAD64 ] if ;
|
||||
|
||||
M: ppc %load-reference ( reg obj -- )
|
||||
M: ppc %load-reference
|
||||
[ [ 0 %load-cell-imm ] [ %load-cell-imm-rc rel-literal ] bi* ]
|
||||
[ \ f type-number LI ]
|
||||
if* ;
|
||||
|
@ -156,11 +156,11 @@ M: ds-loc loc-reg drop ds-reg ;
|
|||
M: rs-loc loc-reg drop rs-reg ;
|
||||
|
||||
! Load value at stack location loc into vreg.
|
||||
M: ppc %peek ( vreg loc -- )
|
||||
M: ppc %peek
|
||||
[ loc-reg ] [ n>> cells neg ] bi %load-cell ;
|
||||
|
||||
! Replace value at stack location loc with value in vreg.
|
||||
M: ppc %replace ( vreg loc -- )
|
||||
M: ppc %replace
|
||||
[ loc-reg ] [ n>> cells neg ] bi %store-cell ;
|
||||
|
||||
! Replace value at stack location with an immediate value.
|
||||
|
@ -176,45 +176,45 @@ M:: ppc %replace-imm ( src loc -- )
|
|||
} cond
|
||||
scratch-reg reg offset %store-cell ;
|
||||
|
||||
M: ppc %clear ( loc -- )
|
||||
M: ppc %clear
|
||||
297 swap %replace-imm ;
|
||||
|
||||
! Increment stack pointer by n cells.
|
||||
M: ppc %inc ( loc -- )
|
||||
M: ppc %inc
|
||||
[ ds-loc? [ ds-reg ds-reg ] [ rs-reg rs-reg ] if ] [ n>> ] bi cells ADDI ;
|
||||
|
||||
M: ppc stack-frame-size ( stack-frame -- i )
|
||||
M: ppc stack-frame-size
|
||||
(stack-frame-size)
|
||||
reserved-area-size +
|
||||
param-save-size +
|
||||
factor-area-size +
|
||||
16 align ;
|
||||
|
||||
M: ppc %call ( word -- )
|
||||
M: ppc %call
|
||||
0 BL rc-relative-ppc-3-pc rel-word-pic ;
|
||||
|
||||
: instrs ( n -- b ) 4 * ; inline
|
||||
|
||||
M: ppc %jump ( word -- )
|
||||
M: ppc %jump
|
||||
6 0 %load-cell-imm 1 instrs %load-cell-imm-rc rel-here
|
||||
0 B rc-relative-ppc-3-pc rel-word-pic-tail ;
|
||||
|
||||
M: ppc %dispatch ( src temp -- )
|
||||
M: ppc %dispatch
|
||||
[ nip 0 %load-cell-imm 3 instrs %load-cell-imm-rc rel-here ]
|
||||
[ swap dupd %load-cell-x ]
|
||||
[ nip MTCTR ] 2tri BCTR ;
|
||||
|
||||
M: ppc %slot ( dst obj slot scale tag -- )
|
||||
M: ppc %slot
|
||||
[ 0 assert= ] bi@ %load-cell-x ;
|
||||
|
||||
M: ppc %slot-imm ( dst obj slot tag -- )
|
||||
M: ppc %slot-imm
|
||||
slot-offset scratch-reg swap LI
|
||||
scratch-reg %load-cell-x ;
|
||||
|
||||
M: ppc %set-slot ( src obj slot scale tag -- )
|
||||
M: ppc %set-slot
|
||||
[ 0 assert= ] bi@ %store-cell-x ;
|
||||
|
||||
M: ppc %set-slot-imm ( src obj slot tag -- )
|
||||
M: ppc %set-slot-imm
|
||||
slot-offset [ scratch-reg ] dip LI scratch-reg %store-cell-x ;
|
||||
|
||||
M: ppc %jump-label B ;
|
||||
|
@ -255,7 +255,7 @@ M: ppc.64 %log2 [ CNTLZD ] [ drop dup NEG ] [ drop dup 63 ADDI ] 2tri ;
|
|||
M: ppc.32 %bit-count POPCNTW ;
|
||||
M: ppc.64 %bit-count POPCNTD ;
|
||||
|
||||
M: ppc %copy ( dst src rep -- )
|
||||
M: ppc %copy
|
||||
2over eq? [ 3drop ] [
|
||||
{
|
||||
{ tagged-rep [ MR ] }
|
||||
|
@ -276,15 +276,15 @@ M: ppc %copy ( dst src rep -- )
|
|||
{ cc/o [ 0 label BNS ] }
|
||||
} case ; inline
|
||||
|
||||
M: ppc %fixnum-add ( label dst src1 src2 cc -- )
|
||||
M: ppc %fixnum-add
|
||||
[ ADDO. ] overflow-template ;
|
||||
|
||||
M: ppc %fixnum-sub ( label dst src1 src2 cc -- )
|
||||
M: ppc %fixnum-sub
|
||||
[ SUBFO. ] overflow-template ;
|
||||
|
||||
M: ppc.32 %fixnum-mul ( label dst src1 src2 cc -- )
|
||||
M: ppc.32 %fixnum-mul
|
||||
[ MULLWO. ] overflow-template ;
|
||||
M: ppc.64 %fixnum-mul ( label dst src1 src2 cc -- )
|
||||
M: ppc.64 %fixnum-mul
|
||||
[ MULLDO. ] overflow-template ;
|
||||
|
||||
M: ppc %add-float FADD ;
|
||||
|
@ -292,11 +292,11 @@ M: ppc %sub-float FSUB ;
|
|||
M: ppc %mul-float FMUL ;
|
||||
M: ppc %div-float FDIV ;
|
||||
|
||||
M: ppc %min-float ( dst src1 src2 -- )
|
||||
M: ppc %min-float
|
||||
2dup [ scratch-reg ] 2dip FSUB
|
||||
[ scratch-reg ] 2dip FSEL ;
|
||||
|
||||
M: ppc %max-float ( dst src1 src2 -- )
|
||||
M: ppc %max-float
|
||||
2dup [ scratch-reg ] 2dip FSUB
|
||||
[ scratch-reg ] 2dip FSEL ;
|
||||
|
||||
|
@ -343,26 +343,26 @@ M:: ppc.64 %float>integer ( dst src -- )
|
|||
} ;
|
||||
|
||||
! Return values of this class go here
|
||||
M: ppc return-regs ( -- regs )
|
||||
M: ppc return-regs
|
||||
{
|
||||
{ int-regs { 3 4 5 6 } }
|
||||
{ float-regs { 1 2 3 4 } }
|
||||
} ;
|
||||
|
||||
! Is this structure small enough to be returned in registers?
|
||||
M: ppc return-struct-in-registers? ( c-type -- ? )
|
||||
M: ppc return-struct-in-registers?
|
||||
lookup-c-type return-in-registers?>> ;
|
||||
|
||||
! If t, the struct return pointer is never passed in a param reg
|
||||
M: ppc struct-return-on-stack? ( -- ? ) f ;
|
||||
M: ppc struct-return-on-stack? f ;
|
||||
|
||||
GENERIC: load-param ( reg src -- )
|
||||
M: integer load-param ( reg src -- ) int-rep %copy ;
|
||||
M: spill-slot load-param ( reg src -- ) [ 1 ] dip n>> spill@ %load-cell ;
|
||||
M: integer load-param int-rep %copy ;
|
||||
M: spill-slot load-param [ 1 ] dip n>> spill@ %load-cell ;
|
||||
|
||||
GENERIC: store-param ( reg dst -- )
|
||||
M: integer store-param ( reg dst -- ) swap int-rep %copy ;
|
||||
M: spill-slot store-param ( reg dst -- ) [ 1 ] dip n>> spill@ %store-cell ;
|
||||
M: integer store-param swap int-rep %copy ;
|
||||
M: spill-slot store-param [ 1 ] dip n>> spill@ %store-cell ;
|
||||
|
||||
M:: ppc %unbox ( dst src func rep -- )
|
||||
3 src load-param
|
||||
|
@ -459,10 +459,7 @@ M:: ppc %c-invoke ( name dll gc-map -- )
|
|||
dead-outputs [ first2 discard-reg-param ] each
|
||||
; inline
|
||||
|
||||
M: ppc %alien-invoke ( varargs? reg-inputs stack-inputs
|
||||
reg-outputs dead-outputs
|
||||
cleanup stack-size
|
||||
symbols dll gc-map -- )
|
||||
M: ppc %alien-invoke
|
||||
'[ _ _ _ %c-invoke ] emit-alien-insn ;
|
||||
|
||||
M:: ppc %alien-indirect ( src
|
||||
|
@ -483,36 +480,33 @@ M:: ppc %alien-indirect ( src
|
|||
gc-map gc-map-here
|
||||
] emit-alien-insn ;
|
||||
|
||||
M: ppc %alien-assembly ( varargs? reg-inputs stack-inputs
|
||||
reg-outputs dead-outputs
|
||||
cleanup stack-size
|
||||
quot -- )
|
||||
M: ppc %alien-assembly
|
||||
'[ _ call( -- ) ] emit-alien-insn ;
|
||||
|
||||
M: ppc %callback-inputs ( reg-outputs stack-outputs -- )
|
||||
M: ppc %callback-inputs
|
||||
[ [ first3 load-reg-param ] each ]
|
||||
[ [ first3 load-stack-param ] each ] bi*
|
||||
3 vm-reg MR
|
||||
4 0 LI
|
||||
"begin_callback" f f %c-invoke ;
|
||||
|
||||
M: ppc %callback-outputs ( reg-inputs -- )
|
||||
M: ppc %callback-outputs
|
||||
3 vm-reg MR
|
||||
"end_callback" f f %c-invoke
|
||||
[ first3 store-reg-param ] each ;
|
||||
|
||||
M: ppc stack-cleanup ( stack-size return abi -- n )
|
||||
M: ppc stack-cleanup
|
||||
3drop 0 ;
|
||||
|
||||
M: ppc fused-unboxing? f ;
|
||||
|
||||
M: ppc %alien-global ( register symbol dll -- )
|
||||
M: ppc %alien-global
|
||||
[ 0 %load-cell-imm ] 2dip %load-cell-imm-rc rel-dlsym ;
|
||||
|
||||
M: ppc %vm-field ( dst field -- ) [ vm-reg ] dip %load-cell ;
|
||||
M: ppc %set-vm-field ( src field -- ) [ vm-reg ] dip %store-cell ;
|
||||
M: ppc %vm-field [ vm-reg ] dip %load-cell ;
|
||||
M: ppc %set-vm-field [ vm-reg ] dip %store-cell ;
|
||||
|
||||
M: ppc %unbox-alien ( dst src -- )
|
||||
M: ppc %unbox-alien
|
||||
scratch-reg alien-offset LI scratch-reg %load-cell-x ;
|
||||
|
||||
! Convert a c-ptr object to a raw C pointer.
|
||||
|
@ -706,7 +700,7 @@ M:: ppc.64 %convert-integer ( dst src c-type -- )
|
|||
{ c:ulonglong [ ] }
|
||||
} case ;
|
||||
|
||||
M: ppc.32 %load-memory-imm ( dst base offset rep c-type -- )
|
||||
M: ppc.32 %load-memory-imm
|
||||
[
|
||||
pick %trap-null
|
||||
{
|
||||
|
@ -725,7 +719,7 @@ M: ppc.32 %load-memory-imm ( dst base offset rep c-type -- )
|
|||
} case
|
||||
] ?if ;
|
||||
|
||||
M: ppc.64 %load-memory-imm ( dst base offset rep c-type -- )
|
||||
M: ppc.64 %load-memory-imm
|
||||
[
|
||||
pick %trap-null
|
||||
{
|
||||
|
@ -747,7 +741,7 @@ M: ppc.64 %load-memory-imm ( dst base offset rep c-type -- )
|
|||
] ?if ;
|
||||
|
||||
|
||||
M: ppc.32 %load-memory ( dst base displacement scale offset rep c-type -- )
|
||||
M: ppc.32 %load-memory
|
||||
[ [ 0 assert= ] bi@ ] 2dip
|
||||
[
|
||||
pick %trap-null
|
||||
|
@ -767,7 +761,7 @@ M: ppc.32 %load-memory ( dst base displacement scale offset rep c-type -- )
|
|||
} case
|
||||
] ?if ;
|
||||
|
||||
M: ppc.64 %load-memory ( dst base displacement scale offset rep c-type -- )
|
||||
M: ppc.64 %load-memory
|
||||
[ [ 0 assert= ] bi@ ] 2dip
|
||||
[
|
||||
pick %trap-null
|
||||
|
@ -790,7 +784,7 @@ M: ppc.64 %load-memory ( dst base displacement scale offset rep c-type -- )
|
|||
] ?if ;
|
||||
|
||||
|
||||
M: ppc.32 %store-memory-imm ( src base offset rep c-type -- )
|
||||
M: ppc.32 %store-memory-imm
|
||||
[
|
||||
{
|
||||
{ c:char [ STB ] }
|
||||
|
@ -808,7 +802,7 @@ M: ppc.32 %store-memory-imm ( src base offset rep c-type -- )
|
|||
} case
|
||||
] ?if ;
|
||||
|
||||
M: ppc.64 %store-memory-imm ( src base offset rep c-type -- )
|
||||
M: ppc.64 %store-memory-imm
|
||||
[
|
||||
{
|
||||
{ c:char [ STB ] }
|
||||
|
@ -828,7 +822,7 @@ M: ppc.64 %store-memory-imm ( src base offset rep c-type -- )
|
|||
} case
|
||||
] ?if ;
|
||||
|
||||
M: ppc.32 %store-memory ( src base displacement scale offset rep c-type -- )
|
||||
M: ppc.32 %store-memory
|
||||
[ [ 0 assert= ] bi@ ] 2dip
|
||||
[
|
||||
{
|
||||
|
@ -847,7 +841,7 @@ M: ppc.32 %store-memory ( src base displacement scale offset rep c-type -- )
|
|||
} case
|
||||
] ?if ;
|
||||
|
||||
M: ppc.64 %store-memory ( src base displacement scale offset rep c-type -- )
|
||||
M: ppc.64 %store-memory
|
||||
[ [ 0 assert= ] bi@ ] 2dip
|
||||
[
|
||||
{
|
||||
|
@ -914,7 +908,7 @@ M:: ppc %check-nursery-branch ( label size cc temp1 temp2 -- )
|
|||
{ cc/<= [ 0 label BGT ] }
|
||||
} case ;
|
||||
|
||||
M: ppc %call-gc ( gc-map -- )
|
||||
M: ppc %call-gc
|
||||
\ minor-gc %call gc-map-here ;
|
||||
|
||||
M:: ppc %prologue ( stack-size -- )
|
||||
|
@ -1033,7 +1027,7 @@ M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
|
|||
src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> ( branch1 branch2 )
|
||||
label branch1 branch2 (%branch) ;
|
||||
|
||||
M: ppc %spill ( src rep dst -- )
|
||||
M: ppc %spill
|
||||
n>> spill@ swap {
|
||||
{ int-rep [ [ 1 ] dip %store-cell ] }
|
||||
{ tagged-rep [ [ 1 ] dip %store-cell ] }
|
||||
|
@ -1043,7 +1037,7 @@ M: ppc %spill ( src rep dst -- )
|
|||
{ scalar-rep [ scratch-reg swap LI 1 scratch-reg STVX ] }
|
||||
} case ;
|
||||
|
||||
M: ppc %reload ( dst rep src -- )
|
||||
M: ppc %reload
|
||||
n>> spill@ swap {
|
||||
{ int-rep [ [ 1 ] dip %load-cell ] }
|
||||
{ tagged-rep [ [ 1 ] dip %load-cell ] }
|
||||
|
@ -1053,11 +1047,11 @@ M: ppc %reload ( dst rep src -- )
|
|||
{ scalar-rep [ scratch-reg swap LI 1 scratch-reg LVX ] }
|
||||
} case ;
|
||||
|
||||
M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ;
|
||||
M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ;
|
||||
M: ppc immediate-store? ( n -- ? ) immediate-comparand? ;
|
||||
M: ppc immediate-arithmetic? -32768 32767 between? ;
|
||||
M: ppc immediate-bitwise? 0 65535 between? ;
|
||||
M: ppc immediate-store? immediate-comparand? ;
|
||||
|
||||
M: ppc enable-cpu-features ( -- )
|
||||
M: ppc enable-cpu-features
|
||||
enable-float-intrinsics ;
|
||||
|
||||
USE: vocabs
|
||||
|
|
|
@ -26,18 +26,18 @@ M: x86.32 rs-reg EDI ;
|
|||
M: x86.32 stack-reg ESP ;
|
||||
M: x86.32 frame-reg EBP ;
|
||||
|
||||
M: x86.32 immediate-comparand? ( obj -- ? ) drop t ;
|
||||
M: x86.32 immediate-comparand? drop t ;
|
||||
|
||||
M:: x86.32 %load-vector ( dst val rep -- )
|
||||
dst 0 [] rep copy-memory* val rc-absolute rel-binary-literal ;
|
||||
|
||||
M: x86.32 %vm-field ( dst field -- )
|
||||
M: x86.32 %vm-field
|
||||
[ 0 [] MOV ] dip rc-absolute-cell rel-vm ;
|
||||
|
||||
M: x86.32 %set-vm-field ( dst field -- )
|
||||
M: x86.32 %set-vm-field
|
||||
[ 0 [] swap MOV ] dip rc-absolute-cell rel-vm ;
|
||||
|
||||
M: x86.32 %vm-field-ptr ( dst field -- )
|
||||
M: x86.32 %vm-field-ptr
|
||||
[ 0 MOV ] dip rc-absolute-cell rel-vm ;
|
||||
|
||||
M: x86.32 %mark-card
|
||||
|
@ -61,7 +61,7 @@ M: x86.32 vm-stack-space 16 ;
|
|||
: save-vm-ptr ( n -- )
|
||||
stack@ 0 MOV 0 rc-absolute-cell rel-vm ;
|
||||
|
||||
M: x86.32 return-struct-in-registers? ( c-type -- ? )
|
||||
M: x86.32 return-struct-in-registers?
|
||||
lookup-c-type
|
||||
[ return-in-registers?>> ]
|
||||
[ heap-size { 1 2 4 8 } member? ] bi
|
||||
|
@ -87,7 +87,7 @@ M: x86.32 return-regs
|
|||
M: x86.32 %prepare-jump
|
||||
pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here ;
|
||||
|
||||
M: x86.32 %load-stack-param ( dst rep n -- )
|
||||
M: x86.32 %load-stack-param
|
||||
next-stack@ swap pick register? [ %copy ] [
|
||||
{
|
||||
{ int-rep [ [ EAX ] dip MOV ?spill-slot EAX MOV ] }
|
||||
|
@ -96,7 +96,7 @@ M: x86.32 %load-stack-param ( dst rep n -- )
|
|||
} case
|
||||
] if ;
|
||||
|
||||
M: x86.32 %store-stack-param ( src rep n -- )
|
||||
M: x86.32 %store-stack-param
|
||||
stack@ swap pick register? [ swapd %copy ] [
|
||||
{
|
||||
{ int-rep [ [ [ EAX ] dip ?spill-slot MOV ] [ EAX MOV ] bi* ] }
|
||||
|
@ -115,7 +115,7 @@ M: x86.32 %store-stack-param ( src rep n -- )
|
|||
dst ?spill-slot x87-insn execute
|
||||
] if ; inline
|
||||
|
||||
M: x86.32 %load-reg-param ( vreg rep reg -- )
|
||||
M: x86.32 %load-reg-param
|
||||
swap {
|
||||
{ int-rep [ int-rep %copy ] }
|
||||
{ float-rep [ drop \ FSTPS float-rep load-float-return ] }
|
||||
|
@ -132,14 +132,14 @@ M: x86.32 %load-reg-param ( vreg rep reg -- )
|
|||
src ?spill-slot x87-insn execute
|
||||
] if ; inline
|
||||
|
||||
M: x86.32 %store-reg-param ( vreg rep reg -- )
|
||||
M: x86.32 %store-reg-param
|
||||
swap {
|
||||
{ int-rep [ swap int-rep %copy ] }
|
||||
{ float-rep [ drop \ FLDS float-rep store-float-return ] }
|
||||
{ double-rep [ drop \ FLDL double-rep store-float-return ] }
|
||||
} case ;
|
||||
|
||||
M: x86.32 %discard-reg-param ( rep reg -- )
|
||||
M: x86.32 %discard-reg-param
|
||||
drop {
|
||||
{ int-rep [ ] }
|
||||
{ float-rep [ ST0 FSTP ] }
|
||||
|
@ -179,12 +179,12 @@ M:: x86.32 %box-long-long ( dst src1 src2 func gc-map -- )
|
|||
M: x86.32 %c-invoke
|
||||
[ 0 CALL rc-relative rel-dlsym ] dip gc-map-here ;
|
||||
|
||||
M: x86.32 %begin-callback ( -- )
|
||||
M: x86.32 %begin-callback
|
||||
0 save-vm-ptr
|
||||
4 stack@ 0 MOV
|
||||
"begin_callback" f f %c-invoke ;
|
||||
|
||||
M: x86.32 %end-callback ( -- )
|
||||
M: x86.32 %end-callback
|
||||
0 save-vm-ptr
|
||||
"end_callback" f f %c-invoke ;
|
||||
|
||||
|
@ -192,7 +192,7 @@ M: x86.32 %end-callback ( -- )
|
|||
! MINGW ABI incompatibility disaster
|
||||
[ large-struct? ] [ mingw eq? os windows? not or ] bi* and ;
|
||||
|
||||
M: x86.32 %prepare-var-args ( reg-inputs -- ) drop ;
|
||||
M: x86.32 %prepare-var-args drop ;
|
||||
|
||||
M:: x86.32 stack-cleanup ( stack-size return abi -- n )
|
||||
! a) Functions which are stdcall/fastcall/thiscall have to
|
||||
|
@ -205,7 +205,7 @@ M:: x86.32 stack-cleanup ( stack-size return abi -- n )
|
|||
[ 0 ]
|
||||
} cond ;
|
||||
|
||||
M: x86.32 %cleanup ( n -- )
|
||||
M: x86.32 %cleanup
|
||||
[ ESP swap SUB ] unless-zero ;
|
||||
|
||||
M: x86.32 %safepoint
|
||||
|
@ -224,7 +224,7 @@ M: x86.32 flatten-struct-type
|
|||
|
||||
M: x86.32 struct-return-on-stack? os linux? not ;
|
||||
|
||||
M: x86.32 (cpuid) ( eax ecx regs -- )
|
||||
M: x86.32 (cpuid)
|
||||
void { uint uint void* } cdecl [
|
||||
! Save ds-reg, rs-reg
|
||||
EDI PUSH
|
||||
|
|
|
@ -40,16 +40,16 @@ M: x86.64 machine-registers
|
|||
: vm-reg ( -- reg ) R13 ; inline
|
||||
: nv-reg ( -- reg ) RBX ; inline
|
||||
|
||||
M: x86.64 %vm-field ( dst offset -- )
|
||||
M: x86.64 %vm-field
|
||||
[ vm-reg ] dip [+] MOV ;
|
||||
|
||||
M:: x86.64 %load-vector ( dst val rep -- )
|
||||
dst 0 [RIP+] rep copy-memory* val rc-relative rel-binary-literal ;
|
||||
|
||||
M: x86.64 %set-vm-field ( src offset -- )
|
||||
M: x86.64 %set-vm-field
|
||||
[ vm-reg ] dip [+] swap MOV ;
|
||||
|
||||
M: x86.64 %vm-field-ptr ( dst offset -- )
|
||||
M: x86.64 %vm-field-ptr
|
||||
[ vm-reg ] dip [+] LEA ;
|
||||
|
||||
M: x86.64 %prepare-jump
|
||||
|
@ -83,7 +83,7 @@ M:: x86.64 %load-reg-param ( vreg rep reg -- )
|
|||
M:: x86.64 %store-reg-param ( vreg rep reg -- )
|
||||
reg vreg rep %copy ;
|
||||
|
||||
M: x86.64 %discard-reg-param ( rep reg -- )
|
||||
M: x86.64 %discard-reg-param
|
||||
2drop ;
|
||||
|
||||
M:: x86.64 %unbox ( dst src func rep -- )
|
||||
|
@ -102,12 +102,12 @@ M: x86.64 %c-invoke
|
|||
[ R11 0 MOV rc-absolute-cell rel-dlsym R11 CALL ] dip
|
||||
gc-map-here ;
|
||||
|
||||
M: x86.64 %begin-callback ( -- )
|
||||
M: x86.64 %begin-callback
|
||||
param-reg-0 vm-reg MOV
|
||||
param-reg-1 0 MOV
|
||||
"begin_callback" f f %c-invoke ;
|
||||
|
||||
M: x86.64 %end-callback ( -- )
|
||||
M: x86.64 %end-callback
|
||||
param-reg-0 vm-reg MOV
|
||||
"end_callback" f f %c-invoke ;
|
||||
|
||||
|
@ -122,7 +122,7 @@ M: x86.64 long-long-on-stack? f ;
|
|||
|
||||
M: x86.64 struct-return-on-stack? f ;
|
||||
|
||||
M: x86.64 (cpuid) ( rax rcx regs -- )
|
||||
M: x86.64 (cpuid)
|
||||
void { uint uint void* } cdecl [
|
||||
RAX param-reg-0 MOV
|
||||
RCX param-reg-1 MOV
|
||||
|
|
|
@ -38,14 +38,14 @@ M: x86.64 reserved-stack-space 0 ;
|
|||
] [ reps ] if
|
||||
] [ reps ] if ;
|
||||
|
||||
M: x86.64 flatten-struct-type ( c-type -- seq )
|
||||
M: x86.64 flatten-struct-type
|
||||
dup heap-size 16 <=
|
||||
[ flatten-small-struct record-reg-reps ] [
|
||||
call-next-method unrecord-reg-reps
|
||||
[ first t f 3array ] map
|
||||
] if ;
|
||||
|
||||
M: x86.64 return-struct-in-registers? ( c-type -- ? )
|
||||
M: x86.64 return-struct-in-registers?
|
||||
heap-size 2 cells <= ;
|
||||
|
||||
M: x86.64 dummy-stack-params? f ;
|
||||
|
@ -54,6 +54,6 @@ M: x86.64 dummy-int-params? f ;
|
|||
|
||||
M: x86.64 dummy-fp-params? f ;
|
||||
|
||||
M: x86.64 %prepare-var-args ( reg-inputs -- )
|
||||
M: x86.64 %prepare-var-args
|
||||
[ second reg-class-of float-regs? ] count 8 min
|
||||
[ EAX EAX XOR ] [ <byte> AL swap MOV ] if-zero ;
|
||||
|
|
|
@ -13,7 +13,7 @@ M: x86.64 param-regs
|
|||
|
||||
M: x86.64 reserved-stack-space 4 cells ;
|
||||
|
||||
M: x86.64 return-struct-in-registers? ( c-type -- ? )
|
||||
M: x86.64 return-struct-in-registers?
|
||||
heap-size { 1 2 4 8 } member? ;
|
||||
|
||||
M: x86.64 value-struct? heap-size { 1 2 4 8 } member? ;
|
||||
|
@ -24,5 +24,4 @@ M: x86.64 dummy-int-params? t ;
|
|||
|
||||
M: x86.64 dummy-fp-params? t ;
|
||||
|
||||
M: x86.64 %prepare-var-args ( reg-inputs -- )
|
||||
drop ;
|
||||
M: x86.64 %prepare-var-args drop ;
|
||||
|
|
|
@ -338,7 +338,7 @@ M: immediate SBB { 0b011 t 0x80 } immediate-1/4 ;
|
|||
M: operand SBB 0o030 2-operand ;
|
||||
|
||||
GENERIC: AND ( dst src -- )
|
||||
M: immediate AND ( dst src -- )
|
||||
M: immediate AND
|
||||
maybe-zero-extend { 0b100 t 0x80 } immediate-1/4 ;
|
||||
M: operand AND 0o040 2-operand ;
|
||||
|
||||
|
@ -357,13 +357,11 @@ M: immediate XOR { 0b110 t 0x80 } immediate-1/4 ;
|
|||
M: operand XOR 0o060 2-operand ;
|
||||
|
||||
GENERIC: CMP ( dst src -- )
|
||||
M: immediate CMP ( dst src -- )
|
||||
{ 0b111 t 0x80 } immediate-1/4 ;
|
||||
M: immediate CMP { 0b111 t 0x80 } immediate-1/4 ;
|
||||
M: operand CMP 0o070 2-operand ;
|
||||
|
||||
GENERIC: TEST ( dst src -- )
|
||||
M: immediate TEST ( dst src -- )
|
||||
maybe-zero-extend { 0b0 t 0xf7 } immediate-4 ;
|
||||
M: immediate TEST maybe-zero-extend { 0b0 t 0xf7 } immediate-4 ;
|
||||
M: operand TEST 0o204 2-operand ;
|
||||
|
||||
: XCHG ( dst src -- ) 0o207 2-operand ;
|
||||
|
@ -371,20 +369,20 @@ M: operand TEST 0o204 2-operand ;
|
|||
: BSR ( dst src -- ) { 0x0f 0xbd } (2-operand) ;
|
||||
|
||||
GENERIC: BT ( value n -- )
|
||||
M: immediate BT ( value n -- ) { 0b100 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BT ( value n -- ) swap { 0x0f 0xa3 } (2-operand) ;
|
||||
M: immediate BT { 0b100 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BT swap { 0x0f 0xa3 } (2-operand) ;
|
||||
|
||||
GENERIC: BTC ( value n -- )
|
||||
M: immediate BTC ( value n -- ) { 0b111 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTC ( value n -- ) swap { 0x0f 0xbb } (2-operand) ;
|
||||
M: immediate BTC { 0b111 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTC swap { 0x0f 0xbb } (2-operand) ;
|
||||
|
||||
GENERIC: BTR ( value n -- )
|
||||
M: immediate BTR ( value n -- ) { 0b110 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTR ( value n -- ) swap { 0x0f 0xb3 } (2-operand) ;
|
||||
M: immediate BTR { 0b110 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTR swap { 0x0f 0xb3 } (2-operand) ;
|
||||
|
||||
GENERIC: BTS ( value n -- )
|
||||
M: immediate BTS ( value n -- ) { 0b101 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTS ( value n -- ) swap { 0x0f 0xab } (2-operand) ;
|
||||
M: immediate BTS { 0b101 t { 0x0f 0xba } } immediate-1* ;
|
||||
M: operand BTS swap { 0x0f 0xab } (2-operand) ;
|
||||
|
||||
: NOT ( dst -- ) { 0b010 t 0xf7 } 1-operand ;
|
||||
: NEG ( dst -- ) { 0b011 t 0xf7 } 1-operand ;
|
||||
|
|
|
@ -35,16 +35,16 @@ M: x86 integer-float-needs-stack-frame? f ;
|
|||
M: x86 %integer>float [ drop dup XORPS ] [ CVTSI2SD ] 2bi ;
|
||||
M: x86 %float>integer CVTTSD2SI ;
|
||||
|
||||
M: x86 %compare-float-ordered ( dst src1 src2 cc temp -- )
|
||||
M: x86 %compare-float-ordered
|
||||
[ COMISD ] (%compare-float) ;
|
||||
|
||||
M: x86 %compare-float-unordered ( dst src1 src2 cc temp -- )
|
||||
M: x86 %compare-float-unordered
|
||||
[ UCOMISD ] (%compare-float) ;
|
||||
|
||||
M: x86 %compare-float-ordered-branch ( label src1 src2 cc -- )
|
||||
M: x86 %compare-float-ordered-branch
|
||||
[ COMISD ] (%compare-float-branch) ;
|
||||
|
||||
M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- )
|
||||
M: x86 %compare-float-unordered-branch
|
||||
[ UCOMISD ] (%compare-float-branch) ;
|
||||
|
||||
! SIMD
|
||||
|
@ -262,7 +262,7 @@ M: x86 %shuffle-vector-halves-imm-reps
|
|||
{ sse2? { double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %shuffle-vector ( dst src shuffle rep -- )
|
||||
M: x86 %shuffle-vector
|
||||
two-operand PSHUFB ;
|
||||
|
||||
M: x86 %shuffle-vector-reps
|
||||
|
@ -331,14 +331,14 @@ M: x86 %unsigned-pack-vector-reps
|
|||
{ sse4.1? { int-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %tail>head-vector ( dst src rep -- )
|
||||
M: x86 %tail>head-vector
|
||||
dup {
|
||||
{ float-4-rep [ drop UNPCKHPD ] }
|
||||
{ double-2-rep [ drop UNPCKHPD ] }
|
||||
[ drop [ %copy ] [ drop PUNPCKHQDQ ] 3bi ]
|
||||
} case ;
|
||||
|
||||
M: x86 %unpack-vector-head ( dst src rep -- )
|
||||
M: x86 %unpack-vector-head
|
||||
{
|
||||
{ char-16-rep [ PMOVSXBW ] }
|
||||
{ uchar-16-rep [ PMOVZXBW ] }
|
||||
|
@ -349,13 +349,13 @@ M: x86 %unpack-vector-head ( dst src rep -- )
|
|||
{ float-4-rep [ CVTPS2PD ] }
|
||||
} case ;
|
||||
|
||||
M: x86 %unpack-vector-head-reps ( -- reps )
|
||||
M: x86 %unpack-vector-head-reps
|
||||
{
|
||||
{ sse2? { float-4-rep } }
|
||||
{ sse4.1? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %integer>float-vector ( dst src rep -- )
|
||||
M: x86 %integer>float-vector
|
||||
{
|
||||
{ int-4-rep [ CVTDQ2PS ] }
|
||||
} case ;
|
||||
|
@ -365,7 +365,7 @@ M: x86 %integer>float-vector-reps
|
|||
{ sse2? { int-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %float>integer-vector ( dst src rep -- )
|
||||
M: x86 %float>integer-vector
|
||||
{
|
||||
{ float-4-rep [ CVTTPS2DQ ] }
|
||||
} case ;
|
||||
|
@ -405,7 +405,7 @@ M: x86 %float>integer-vector-reps
|
|||
{ cc> [ [ PCMPGTQ ] [ PCMPGTD ] [ PCMPGTW ] [ PCMPGTB ] (%compare-int-vector) ] }
|
||||
} case ;
|
||||
|
||||
M: x86 %compare-vector ( dst src1 src2 rep cc -- )
|
||||
M: x86 %compare-vector
|
||||
[ [ two-operand ] keep ] dip
|
||||
over float-vector-rep?
|
||||
[ %compare-float-vector ]
|
||||
|
@ -481,7 +481,7 @@ M: x86 %compare-vector-ccs
|
|||
[ drop PMOVMSKB 0xffff ]
|
||||
} case ;
|
||||
|
||||
M: x86 %move-vector-mask ( dst src rep -- )
|
||||
M: x86 %move-vector-mask
|
||||
(%move-vector-mask) drop ;
|
||||
|
||||
M: x86 %move-vector-mask-reps
|
||||
|
@ -512,7 +512,7 @@ M: x86 %test-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %add-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %add-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ ADDPS ] }
|
||||
|
@ -533,7 +533,7 @@ M: x86 %add-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %saturated-add-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %saturated-add-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ char-16-rep [ PADDSB ] }
|
||||
|
@ -547,7 +547,7 @@ M: x86 %saturated-add-vector-reps
|
|||
{ sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %add-sub-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %add-sub-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ ADDSUBPS ] }
|
||||
|
@ -559,7 +559,7 @@ M: x86 %add-sub-vector-reps
|
|||
{ sse3? { float-4-rep double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %sub-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %sub-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ SUBPS ] }
|
||||
|
@ -580,7 +580,7 @@ M: x86 %sub-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %saturated-sub-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %saturated-sub-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ char-16-rep [ PSUBSB ] }
|
||||
|
@ -594,7 +594,7 @@ M: x86 %saturated-sub-vector-reps
|
|||
{ sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %mul-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %mul-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ MULPS ] }
|
||||
|
@ -612,7 +612,7 @@ M: x86 %mul-vector-reps
|
|||
{ sse4.1? { int-4-rep uint-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %mul-high-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %mul-high-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ short-8-rep [ PMULHW ] }
|
||||
|
@ -624,7 +624,7 @@ M: x86 %mul-high-vector-reps
|
|||
{ sse2? { short-8-rep ushort-8-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %mul-horizontal-add-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %mul-horizontal-add-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ char-16-rep [ PMADDUBSW ] }
|
||||
|
@ -638,7 +638,7 @@ M: x86 %mul-horizontal-add-vector-reps
|
|||
{ ssse3? { char-16-rep uchar-16-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %div-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %div-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ DIVPS ] }
|
||||
|
@ -651,7 +651,7 @@ M: x86 %div-vector-reps
|
|||
{ sse2? { double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %min-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %min-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ char-16-rep [ PMINSB ] }
|
||||
|
@ -671,7 +671,7 @@ M: x86 %min-vector-reps
|
|||
{ sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %max-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %max-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ char-16-rep [ PMAXSB ] }
|
||||
|
@ -691,7 +691,7 @@ M: x86 %max-vector-reps
|
|||
{ sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %avg-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %avg-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ uchar-16-rep [ PAVGB ] }
|
||||
|
@ -726,7 +726,7 @@ M: x86 %sad-vector-reps
|
|||
{ sse2? { uchar-16-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %horizontal-add-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %horizontal-add-vector
|
||||
[ two-operand ] keep
|
||||
signed-rep {
|
||||
{ float-4-rep [ HADDPS ] }
|
||||
|
@ -741,7 +741,7 @@ M: x86 %horizontal-add-vector-reps
|
|||
{ ssse3? { int-4-rep uint-4-rep short-8-rep ushort-8-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %horizontal-shl-vector-imm ( dst src1 src2 rep -- )
|
||||
M: x86 %horizontal-shl-vector-imm
|
||||
two-operand PSLLDQ ;
|
||||
|
||||
M: x86 %horizontal-shl-vector-imm-reps
|
||||
|
@ -749,7 +749,7 @@ M: x86 %horizontal-shl-vector-imm-reps
|
|||
{ sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %horizontal-shr-vector-imm ( dst src1 src2 rep -- )
|
||||
M: x86 %horizontal-shr-vector-imm
|
||||
two-operand PSRLDQ ;
|
||||
|
||||
M: x86 %horizontal-shr-vector-imm-reps
|
||||
|
@ -757,7 +757,7 @@ M: x86 %horizontal-shr-vector-imm-reps
|
|||
{ sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %abs-vector ( dst src rep -- )
|
||||
M: x86 %abs-vector
|
||||
{
|
||||
{ char-16-rep [ PABSB ] }
|
||||
{ short-8-rep [ PABSW ] }
|
||||
|
@ -769,7 +769,7 @@ M: x86 %abs-vector-reps
|
|||
{ ssse3? { char-16-rep short-8-rep int-4-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %sqrt-vector ( dst src rep -- )
|
||||
M: x86 %sqrt-vector
|
||||
{
|
||||
{ float-4-rep [ SQRTPS ] }
|
||||
{ double-2-rep [ SQRTPD ] }
|
||||
|
@ -781,7 +781,7 @@ M: x86 %sqrt-vector-reps
|
|||
{ sse2? { double-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %and-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %and-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ ANDPS ] }
|
||||
|
@ -795,7 +795,7 @@ M: x86 %and-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %andn-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %andn-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ ANDNPS ] }
|
||||
|
@ -809,7 +809,7 @@ M: x86 %andn-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %or-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %or-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ ORPS ] }
|
||||
|
@ -823,7 +823,7 @@ M: x86 %or-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %xor-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %xor-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ float-4-rep [ XORPS ] }
|
||||
|
@ -837,7 +837,7 @@ M: x86 %xor-vector-reps
|
|||
{ sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %shl-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %shl-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ short-8-rep [ PSLLW ] }
|
||||
|
@ -853,7 +853,7 @@ M: x86 %shl-vector-reps
|
|||
{ sse2? { short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
|
||||
} available-reps ;
|
||||
|
||||
M: x86 %shr-vector ( dst src1 src2 rep -- )
|
||||
M: x86 %shr-vector
|
||||
[ two-operand ] keep
|
||||
{
|
||||
{ short-8-rep [ PSRAW ] }
|
||||
|
@ -911,9 +911,9 @@ M: x86 %integer>scalar drop MOVD ;
|
|||
] }
|
||||
} case ;
|
||||
|
||||
M: x86.32 %scalar>integer ( dst src rep -- ) %scalar>integer-32 ;
|
||||
M: x86.32 %scalar>integer %scalar>integer-32 ;
|
||||
|
||||
M: x86.64 %scalar>integer ( dst src rep -- )
|
||||
M: x86.64 %scalar>integer
|
||||
{
|
||||
{ longlong-scalar-rep [ MOVD ] }
|
||||
{ ulonglong-scalar-rep [ MOVD ] }
|
||||
|
|
|
@ -46,7 +46,7 @@ HOOK: pic-tail-reg cpu ( -- reg )
|
|||
|
||||
: align-stack ( n -- n' ) 16 align ;
|
||||
|
||||
M: x86 stack-frame-size ( stack-frame -- i )
|
||||
M: x86 stack-frame-size
|
||||
(stack-frame-size)
|
||||
reserved-stack-space +
|
||||
cell +
|
||||
|
@ -60,7 +60,7 @@ M: x86 test-instruction? t ;
|
|||
|
||||
M: x86 immediate-store? immediate-comparand? ;
|
||||
|
||||
M: x86 %load-immediate ( reg val -- )
|
||||
M: x86 %load-immediate
|
||||
{ fixnum } declare [ 32-bit-version-of dup XOR ] [ MOV ] if-zero ;
|
||||
|
||||
M: x86 %load-reference
|
||||
|
@ -90,13 +90,13 @@ M: x86 %replace-imm
|
|||
[ [ 0 MOV ] dip rc-absolute rel-literal ]
|
||||
} cond ;
|
||||
|
||||
M: x86 %clear ( loc -- )
|
||||
M: x86 %clear
|
||||
297 swap %replace-imm ;
|
||||
|
||||
M: x86 %inc ( loc -- )
|
||||
M: x86 %inc
|
||||
[ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ;
|
||||
|
||||
M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
|
||||
M: x86 %call 0 CALL rc-relative rel-word-pic ;
|
||||
|
||||
: xt-tail-pic-offset ( -- n )
|
||||
! See the comment in vm/cpu-x86.hpp
|
||||
|
@ -104,21 +104,21 @@ M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
|
|||
|
||||
HOOK: %prepare-jump cpu ( -- )
|
||||
|
||||
M: x86 %jump ( word -- )
|
||||
M: x86 %jump
|
||||
%prepare-jump
|
||||
0 JMP rc-relative rel-word-pic-tail ;
|
||||
|
||||
M: x86 %jump-label ( label -- ) 0 JMP rc-relative label-fixup ;
|
||||
M: x86 %jump-label 0 JMP rc-relative label-fixup ;
|
||||
|
||||
M: x86 %return ( -- ) 0 RET ;
|
||||
M: x86 %return 0 RET ;
|
||||
|
||||
: (%slot) ( obj slot scale tag -- op ) neg <indirect> ; inline
|
||||
: (%slot-imm) ( obj slot tag -- op ) slot-offset [+] ; inline
|
||||
|
||||
M: x86 %slot ( dst obj slot scale tag -- ) (%slot) MOV ;
|
||||
M: x86 %slot-imm ( dst obj slot tag -- ) (%slot-imm) MOV ;
|
||||
M: x86 %set-slot ( src obj slot scale tag -- ) (%slot) swap MOV ;
|
||||
M: x86 %set-slot-imm ( src obj slot tag -- ) (%slot-imm) swap MOV ;
|
||||
M: x86 %slot (%slot) MOV ;
|
||||
M: x86 %slot-imm (%slot-imm) MOV ;
|
||||
M: x86 %set-slot (%slot) swap MOV ;
|
||||
M: x86 %set-slot-imm (%slot-imm) swap MOV ;
|
||||
|
||||
:: two-operand ( dst src1 src2 rep -- dst src )
|
||||
dst src2 eq? dst src1 eq? not and [ "Cannot handle this case" throw ] when
|
||||
|
@ -130,13 +130,13 @@ M: x86 %set-slot-imm ( src obj slot tag -- ) (%slot-imm) swap MOV ;
|
|||
dst ; inline
|
||||
|
||||
M: x86 %add 2over eq? [ nip ADD ] [ [+] LEA ] if ;
|
||||
M: x86 %add-imm ( dst src1 src2 -- )
|
||||
M: x86 %add-imm
|
||||
2over eq? [
|
||||
nip { { 1 [ INC ] } { -1 [ DEC ] } [ ADD ] } case
|
||||
] [ [+] LEA ] if ;
|
||||
|
||||
M: x86 %sub int-rep two-operand SUB ;
|
||||
M: x86 %sub-imm ( dst src1 src2 -- )
|
||||
M: x86 %sub-imm
|
||||
2over eq? [
|
||||
nip { { 1 [ DEC ] } { -1 [ INC ] } [ SUB ] } case
|
||||
] [ neg [+] LEA ] if ;
|
||||
|
@ -173,7 +173,7 @@ M: object copy-memory* copy-register* ;
|
|||
|
||||
: ?spill-slot ( obj -- obj ) dup spill-slot? [ n>> spill@ ] when ;
|
||||
|
||||
M: x86 %copy ( dst src rep -- )
|
||||
M: x86 %copy
|
||||
2over eq? [ 3drop ] [
|
||||
[ [ ?spill-slot ] bi@ ] dip
|
||||
2over [ register? ] both? [ copy-register* ] [ copy-memory* ] if
|
||||
|
@ -186,16 +186,16 @@ M: x86 %copy ( dst src rep -- )
|
|||
{ cc/o [ JNO ] }
|
||||
} case ; inline
|
||||
|
||||
M: x86 %fixnum-add ( label dst src1 src2 cc -- )
|
||||
M: x86 %fixnum-add
|
||||
[ ADD ] fixnum-overflow ;
|
||||
|
||||
M: x86 %fixnum-sub ( label dst src1 src2 cc -- )
|
||||
M: x86 %fixnum-sub
|
||||
[ SUB ] fixnum-overflow ;
|
||||
|
||||
M: x86 %fixnum-mul ( label dst src1 src2 cc -- )
|
||||
M: x86 %fixnum-mul
|
||||
[ IMUL2 ] fixnum-overflow ;
|
||||
|
||||
M: x86 %unbox-alien ( dst src -- )
|
||||
M: x86 %unbox-alien
|
||||
alien-offset [+] MOV ;
|
||||
|
||||
M:: x86 %unbox-any-c-ptr ( dst src -- )
|
||||
|
@ -364,7 +364,7 @@ M: x86.64 has-small-reg? 2drop t ;
|
|||
: %sign-extend ( dst src bits -- )
|
||||
[ MOVSX ] (%convert-integer) ; inline
|
||||
|
||||
M: x86 %convert-integer ( dst src c-type -- )
|
||||
M: x86 %convert-integer
|
||||
{
|
||||
{ c:char [ 8 %sign-extend ] }
|
||||
{ c:uchar [ 8 %zero-extend ] }
|
||||
|
@ -411,10 +411,10 @@ M: x86 %convert-integer ( dst src c-type -- )
|
|||
} case
|
||||
] [ nipd %copy ] ?if ;
|
||||
|
||||
M: x86 %load-memory ( dst base displacement scale offset rep c-type -- )
|
||||
M: x86 %load-memory
|
||||
(%memory) (%load-memory) ;
|
||||
|
||||
M: x86 %load-memory-imm ( dst base offset rep c-type -- )
|
||||
M: x86 %load-memory-imm
|
||||
(%memory-imm) (%load-memory) ;
|
||||
|
||||
: (%store-memory) ( src exclude address rep c-type -- )
|
||||
|
@ -429,10 +429,10 @@ M: x86 %load-memory-imm ( dst base offset rep c-type -- )
|
|||
} case
|
||||
] [ [ nip swap ] dip %copy ] ?if ;
|
||||
|
||||
M: x86 %store-memory ( src base displacement scale offset rep c-type -- )
|
||||
M: x86 %store-memory
|
||||
(%memory) (%store-memory) ;
|
||||
|
||||
M: x86 %store-memory-imm ( src base offset rep c-type -- )
|
||||
M: x86 %store-memory-imm
|
||||
(%memory-imm) (%store-memory) ;
|
||||
|
||||
: shift-count? ( reg -- ? ) { ECX RCX } member-eq? ;
|
||||
|
@ -510,16 +510,16 @@ M:: x86 %check-nursery-branch ( label size cc temp1 temp2 -- )
|
|||
M: x86 gc-root-offset
|
||||
n>> spill-offset special-offset cell + cell /i ;
|
||||
|
||||
M: x86 %call-gc ( gc-map -- )
|
||||
M: x86 %call-gc
|
||||
\ minor-gc %call
|
||||
gc-map-here ;
|
||||
|
||||
M: x86 %alien-global ( dst symbol library -- )
|
||||
M: x86 %alien-global
|
||||
[ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
|
||||
|
||||
M: x86 %prologue ( n -- ) cell - decr-stack-reg ;
|
||||
M: x86 %prologue cell - decr-stack-reg ;
|
||||
|
||||
M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
|
||||
M: x86 %epilogue cell - incr-stack-reg ;
|
||||
|
||||
:: (%boolean) ( dst temp insn -- )
|
||||
dst \ f type-number MOV
|
||||
|
@ -610,10 +610,10 @@ M:: x86 %dispatch ( src temp -- )
|
|||
[ (align-code) ]
|
||||
bi ;
|
||||
|
||||
M: x86 %spill ( src rep dst -- )
|
||||
M: x86 %spill
|
||||
-rot %copy ;
|
||||
|
||||
M: x86 %reload ( dst rep src -- )
|
||||
M: x86 %reload
|
||||
swap %copy ;
|
||||
|
||||
M:: x86 %local-allot ( dst size align offset -- )
|
||||
|
@ -661,10 +661,7 @@ M:: x86 %alien-assembly ( varargs? reg-inputs stack-inputs
|
|||
reg-outputs [ first3 %load-reg-param ] each
|
||||
dead-outputs [ first2 %discard-reg-param ] each ;
|
||||
|
||||
M: x86 %alien-invoke ( varargs? reg-inputs stack-inputs
|
||||
reg-outputs dead-outputs
|
||||
cleanup stack-size
|
||||
symbols dll gc-map -- )
|
||||
M: x86 %alien-invoke
|
||||
'[ _ _ _ %c-invoke ] %alien-assembly ;
|
||||
|
||||
M:: x86 %alien-indirect ( src
|
||||
|
@ -681,14 +678,14 @@ M:: x86 %alien-indirect ( src
|
|||
|
||||
HOOK: %begin-callback cpu ( -- )
|
||||
|
||||
M: x86 %callback-inputs ( reg-outputs stack-outputs -- )
|
||||
M: x86 %callback-inputs
|
||||
[ [ first3 %load-reg-param ] each ]
|
||||
[ [ first3 %load-stack-param ] each ] bi*
|
||||
%begin-callback ;
|
||||
|
||||
HOOK: %end-callback cpu ( -- )
|
||||
|
||||
M: x86 %callback-outputs ( reg-inputs -- )
|
||||
M: x86 %callback-outputs
|
||||
%end-callback
|
||||
[ first3 %store-reg-param ] each ;
|
||||
|
||||
|
@ -708,10 +705,10 @@ M: x86 long-long-odd-register? f ;
|
|||
|
||||
M: x86 float-right-align-on-stack? f ;
|
||||
|
||||
M: x86 immediate-arithmetic? ( n -- ? )
|
||||
M: x86 immediate-arithmetic?
|
||||
-0x80000000 0x7fffffff between? ;
|
||||
|
||||
M: x86 immediate-bitwise? ( n -- ? )
|
||||
M: x86 immediate-bitwise?
|
||||
-0x80000000 0x7fffffff between? ;
|
||||
|
||||
:: %cmov-float= ( dst src -- )
|
||||
|
@ -778,7 +775,7 @@ M:: x86 %bit-test ( dst src1 src2 temp -- )
|
|||
src1 src2 BT
|
||||
dst temp \ CMOVB (%boolean) ;
|
||||
|
||||
M: x86 enable-cpu-features ( -- )
|
||||
M: x86 enable-cpu-features
|
||||
enable-min/max
|
||||
enable-log2
|
||||
enable-bit-test
|
||||
|
|
|
@ -86,14 +86,14 @@ M:: x86 %float>integer ( dst src -- )
|
|||
src2 shuffle-down quot call
|
||||
ST0 FSTP ; inline
|
||||
|
||||
M: x86 %compare-float-ordered ( dst src1 src2 cc temp -- )
|
||||
M: x86 %compare-float-ordered
|
||||
[ [ FCOMI ] compare-op ] (%compare-float) ;
|
||||
|
||||
M: x86 %compare-float-unordered ( dst src1 src2 cc temp -- )
|
||||
M: x86 %compare-float-unordered
|
||||
[ [ FUCOMI ] compare-op ] (%compare-float) ;
|
||||
|
||||
M: x86 %compare-float-ordered-branch ( label src1 src2 cc -- )
|
||||
M: x86 %compare-float-ordered-branch
|
||||
[ [ FCOMI ] compare-op ] (%compare-float-branch) ;
|
||||
|
||||
M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- )
|
||||
M: x86 %compare-float-unordered-branch
|
||||
[ [ FUCOMI ] compare-op ] (%compare-float-branch) ;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: classes kernel help.markup help.syntax sequences
|
||||
alien assocs strings math quotations db.private ;
|
||||
USING: alien assocs classes db.private help.markup help.syntax
|
||||
kernel math quotations sequences strings ;
|
||||
IN: db
|
||||
|
||||
HELP: db-connection
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays assocs classes continuations destructors kernel math
|
||||
namespaces sequences classes.tuple words strings
|
||||
tools.walker accessors combinators fry db.errors ;
|
||||
USING: accessors assocs continuations destructors fry kernel
|
||||
namespaces sequences strings ;
|
||||
IN: db
|
||||
|
||||
TUPLE: db-connection
|
||||
|
@ -27,7 +26,7 @@ HOOK: parse-db-error db-connection ( error -- error' )
|
|||
|
||||
: dispose-statements ( assoc -- ) values dispose-each ;
|
||||
|
||||
M: db-connection dispose ( db-connection -- )
|
||||
M: db-connection dispose
|
||||
dup db-connection [
|
||||
[ dispose-statements H{ } clone ] change-insert-statements
|
||||
[ dispose-statements H{ } clone ] change-update-statements
|
||||
|
@ -77,7 +76,7 @@ GENERIC: bind-tuple ( tuple statement -- )
|
|||
|
||||
GENERIC: execute-statement* ( statement type -- )
|
||||
|
||||
M: object execute-statement* ( statement type -- )
|
||||
M: object execute-statement*
|
||||
'[
|
||||
_ _ drop query-results dispose
|
||||
] [
|
||||
|
@ -139,9 +138,9 @@ HOOK: begin-transaction db-connection ( -- )
|
|||
HOOK: commit-transaction db-connection ( -- )
|
||||
HOOK: rollback-transaction db-connection ( -- )
|
||||
|
||||
M: db-connection begin-transaction ( -- ) "BEGIN" sql-command ;
|
||||
M: db-connection commit-transaction ( -- ) "COMMIT" sql-command ;
|
||||
M: db-connection rollback-transaction ( -- ) "ROLLBACK" sql-command ;
|
||||
M: db-connection begin-transaction "BEGIN" sql-command ;
|
||||
M: db-connection commit-transaction "COMMIT" sql-command ;
|
||||
M: db-connection rollback-transaction "ROLLBACK" sql-command ;
|
||||
|
||||
: in-transaction? ( -- ? ) in-transaction get ;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ TUPLE: db-pool < pool db ;
|
|||
: with-db-pool ( db quot -- )
|
||||
[ <db-pool> ] dip with-pool ; inline
|
||||
|
||||
M: db-pool make-connection ( pool -- conn )
|
||||
M: db-pool make-connection
|
||||
db>> db-open ;
|
||||
|
||||
: with-pooled-db ( pool quot -- )
|
||||
|
|
|
@ -31,7 +31,7 @@ IN: db.postgresql.lib
|
|||
|
||||
ERROR: postgresql-result-null ;
|
||||
|
||||
M: postgresql-result-null summary ( obj -- str )
|
||||
M: postgresql-result-null summary
|
||||
drop "PQexec returned f." ;
|
||||
|
||||
: postgresql-result-ok? ( res -- ? )
|
||||
|
@ -126,7 +126,7 @@ M: postgresql-result-null summary ( obj -- str )
|
|||
TUPLE: postgresql-malloc-destructor alien ;
|
||||
C: <postgresql-malloc-destructor> postgresql-malloc-destructor
|
||||
|
||||
M: postgresql-malloc-destructor dispose ( obj -- )
|
||||
M: postgresql-malloc-destructor dispose
|
||||
alien>> PQfreemem ;
|
||||
|
||||
: &postgresql-free ( alien -- alien )
|
||||
|
|
|
@ -25,7 +25,7 @@ TUPLE: postgresql-statement < statement ;
|
|||
|
||||
TUPLE: postgresql-result-set < result-set ;
|
||||
|
||||
M: postgresql-db db-open ( db -- db-connection )
|
||||
M: postgresql-db db-open
|
||||
{
|
||||
[ host>> ]
|
||||
[ port>> ]
|
||||
|
@ -36,46 +36,46 @@ M: postgresql-db db-open ( db -- db-connection )
|
|||
[ password>> ]
|
||||
} cleave connect-postgres <postgresql-db-connection> ;
|
||||
|
||||
M: postgresql-db-connection db-close ( handle -- ) PQfinish ;
|
||||
M: postgresql-db-connection db-close PQfinish ;
|
||||
|
||||
M: postgresql-statement bind-statement* ( statement -- ) drop ;
|
||||
M: postgresql-statement bind-statement* drop ;
|
||||
|
||||
GENERIC: postgresql-bind-conversion ( tuple object -- low-level-binding )
|
||||
|
||||
M: sql-spec postgresql-bind-conversion ( tuple spec -- object )
|
||||
M: sql-spec postgresql-bind-conversion
|
||||
slot-name>> swap get-slot-named <low-level-binding> ;
|
||||
|
||||
M: literal-bind postgresql-bind-conversion ( tuple literal-bind -- object )
|
||||
M: literal-bind postgresql-bind-conversion
|
||||
nip value>> <low-level-binding> ;
|
||||
|
||||
M: generator-bind postgresql-bind-conversion ( tuple generate-bind -- object )
|
||||
M: generator-bind postgresql-bind-conversion
|
||||
dup generator-singleton>> eval-generator
|
||||
[ swap slot-name>> rot set-slot-named ] [ <low-level-binding> ] bi ;
|
||||
|
||||
M: postgresql-statement bind-tuple ( tuple statement -- )
|
||||
M: postgresql-statement bind-tuple
|
||||
[ nip ] [
|
||||
in-params>>
|
||||
[ postgresql-bind-conversion ] with map
|
||||
] 2bi
|
||||
>>bind-params drop ;
|
||||
|
||||
M: postgresql-result-set #rows ( result-set -- n )
|
||||
M: postgresql-result-set #rows
|
||||
handle>> PQntuples ;
|
||||
|
||||
M: postgresql-result-set #columns ( result-set -- n )
|
||||
M: postgresql-result-set #columns
|
||||
handle>> PQnfields ;
|
||||
|
||||
: result-handle-n ( result-set -- handle n )
|
||||
[ handle>> ] [ n>> ] bi ;
|
||||
|
||||
M: postgresql-result-set row-column ( result-set column -- object )
|
||||
M: postgresql-result-set row-column
|
||||
[ result-handle-n ] dip pq-get-string ;
|
||||
|
||||
M: postgresql-result-set row-column-typed ( result-set column -- object )
|
||||
M: postgresql-result-set row-column-typed
|
||||
dup pick out-params>> nth type>>
|
||||
[ result-handle-n ] 2dip postgresql-column-typed ;
|
||||
|
||||
M: postgresql-statement query-results ( query -- result-set )
|
||||
M: postgresql-statement query-results
|
||||
dup bind-params>> [
|
||||
over [ bind-statement ] keep
|
||||
do-postgresql-bound-statement
|
||||
|
@ -85,17 +85,17 @@ M: postgresql-statement query-results ( query -- result-set )
|
|||
postgresql-result-set new-result-set
|
||||
dup init-result-set ;
|
||||
|
||||
M: postgresql-result-set advance-row ( result-set -- )
|
||||
M: postgresql-result-set advance-row
|
||||
[ 1 + ] change-n drop ;
|
||||
|
||||
M: postgresql-result-set more-rows? ( result-set -- ? )
|
||||
M: postgresql-result-set more-rows?
|
||||
[ n>> ] [ max>> ] bi < ;
|
||||
|
||||
M: postgresql-statement dispose ( query -- )
|
||||
M: postgresql-statement dispose
|
||||
dup handle>> PQclear
|
||||
f >>handle drop ;
|
||||
|
||||
M: postgresql-result-set dispose ( result-set -- )
|
||||
M: postgresql-result-set dispose
|
||||
[ handle>> PQclear ]
|
||||
[
|
||||
0 >>n
|
||||
|
@ -103,27 +103,27 @@ M: postgresql-result-set dispose ( result-set -- )
|
|||
f >>handle drop
|
||||
] bi ;
|
||||
|
||||
M: postgresql-statement prepare-statement ( statement -- )
|
||||
M: postgresql-statement prepare-statement
|
||||
dup
|
||||
[ db-connection get handle>> f ] dip
|
||||
[ sql>> ] [ in-params>> ] bi
|
||||
length f PQprepare postgresql-error
|
||||
>>handle drop ;
|
||||
|
||||
M: postgresql-db-connection <simple-statement> ( sql in out -- statement )
|
||||
M: postgresql-db-connection <simple-statement>
|
||||
postgresql-statement new-statement ;
|
||||
|
||||
M: postgresql-db-connection <prepared-statement> ( sql in out -- statement )
|
||||
M: postgresql-db-connection <prepared-statement>
|
||||
<simple-statement> dup prepare-statement ;
|
||||
|
||||
: bind-name% ( -- )
|
||||
CHAR: $ 0,
|
||||
sql-counter [ inc ] [ get 0# ] bi ;
|
||||
|
||||
M: postgresql-db-connection bind% ( spec -- )
|
||||
M: postgresql-db-connection bind%
|
||||
bind-name% 1, ;
|
||||
|
||||
M: postgresql-db-connection bind# ( spec object -- )
|
||||
M: postgresql-db-connection bind#
|
||||
[ bind-name% f swap type>> ] dip
|
||||
<literal-bind> 1, ;
|
||||
|
||||
|
@ -169,7 +169,7 @@ M: postgresql-db-connection bind# ( spec object -- )
|
|||
"_seq'');' language sql;" 0%
|
||||
] query-make ;
|
||||
|
||||
M: postgresql-db-connection create-sql-statement ( class -- seq )
|
||||
M: postgresql-db-connection create-sql-statement
|
||||
[
|
||||
[ create-table-sql , ] keep
|
||||
dup db-assigned? [ create-function-sql , ] [ drop ] if
|
||||
|
@ -189,13 +189,13 @@ M: postgresql-db-connection create-sql-statement ( class -- seq )
|
|||
"drop table " 0% 0% drop
|
||||
] query-make ;
|
||||
|
||||
M: postgresql-db-connection drop-sql-statement ( class -- seq )
|
||||
M: postgresql-db-connection drop-sql-statement
|
||||
[
|
||||
[ drop-table-sql , ] keep
|
||||
dup db-assigned? [ drop-function-sql , ] [ drop ] if
|
||||
] { } make ;
|
||||
|
||||
M: postgresql-db-connection <insert-db-assigned-statement> ( class -- statement )
|
||||
M: postgresql-db-connection <insert-db-assigned-statement>
|
||||
[
|
||||
"select add_" 0% 0%
|
||||
"(" 0%
|
||||
|
@ -205,7 +205,7 @@ M: postgresql-db-connection <insert-db-assigned-statement> ( class -- statement
|
|||
");" 0%
|
||||
] query-make ;
|
||||
|
||||
M: postgresql-db-connection <insert-user-assigned-statement> ( class -- statement )
|
||||
M: postgresql-db-connection <insert-user-assigned-statement>
|
||||
[
|
||||
"insert into " 0% 0%
|
||||
"(" 0%
|
||||
|
@ -228,10 +228,10 @@ M: postgresql-db-connection <insert-user-assigned-statement> ( class -- statemen
|
|||
");" 0%
|
||||
] query-make ;
|
||||
|
||||
M: postgresql-db-connection insert-tuple-set-key ( tuple statement -- )
|
||||
M: postgresql-db-connection insert-tuple-set-key
|
||||
query-modify-tuple ;
|
||||
|
||||
M: postgresql-db-connection persistent-table ( -- hashtable )
|
||||
M: postgresql-db-connection persistent-table
|
||||
H{
|
||||
{ +db-assigned-id+ { "integer" "serial" f } }
|
||||
{ +user-assigned-id+ { f f f } }
|
||||
|
@ -271,7 +271,7 @@ M: postgresql-db-connection persistent-table ( -- hashtable )
|
|||
} ;
|
||||
|
||||
ERROR: no-compound-found string object ;
|
||||
M: postgresql-db-connection compound ( string object -- string' )
|
||||
M: postgresql-db-connection compound
|
||||
over {
|
||||
{ "default" [ first number>string " " glue ] }
|
||||
{ "varchar" [ first number>string "(" ")" surround append ] }
|
||||
|
|
|
@ -33,7 +33,7 @@ SINGLETON: retryable
|
|||
] if
|
||||
] 2map >>bind-params ;
|
||||
|
||||
M: retryable execute-statement* ( statement type -- )
|
||||
M: retryable execute-statement*
|
||||
drop [ retries>> <iota> ] [
|
||||
[
|
||||
nip
|
||||
|
@ -62,7 +62,7 @@ M: retryable execute-statement* ( statement type -- )
|
|||
dup column-name>> 0% " = " 0% bind%
|
||||
] interleave ;
|
||||
|
||||
M: db-connection <update-tuple-statement> ( class -- statement )
|
||||
M: db-connection <update-tuple-statement>
|
||||
[
|
||||
"update " 0% 0%
|
||||
" set " 0%
|
||||
|
@ -71,7 +71,7 @@ M: db-connection <update-tuple-statement> ( class -- statement )
|
|||
where-primary-key%
|
||||
] query-make ;
|
||||
|
||||
M: random-id-generator eval-generator ( singleton -- obj )
|
||||
M: random-id-generator eval-generator
|
||||
drop
|
||||
system-random-generator get [
|
||||
63 [ random-bits ] keep 1 - set-bit
|
||||
|
@ -102,32 +102,32 @@ M: random-id-generator eval-generator ( singleton -- obj )
|
|||
: in-parens ( quot -- )
|
||||
"(" 0% call ")" 0% ; inline
|
||||
|
||||
M: interval where ( spec obj -- )
|
||||
M: interval where
|
||||
[
|
||||
[ from>> "from" where-interval ] [
|
||||
nip infinite-interval? [ " and " 0% ] unless
|
||||
] [ to>> "to" where-interval ] 2tri
|
||||
] in-parens ;
|
||||
|
||||
M: sequence where ( spec obj -- )
|
||||
M: sequence where
|
||||
[
|
||||
[ " or " 0% ] [ dupd where ] interleave drop
|
||||
] in-parens ;
|
||||
|
||||
M: byte-array where ( spec obj -- )
|
||||
M: byte-array where
|
||||
over column-name>> 0% " = " 0% bind# ;
|
||||
|
||||
M: NULL where ( spec obj -- )
|
||||
M: NULL where
|
||||
drop column-name>> 0% " is NULL" 0% ;
|
||||
|
||||
: object-where ( spec obj -- )
|
||||
over column-name>> 0% " = " 0% bind# ;
|
||||
|
||||
M: object where ( spec obj -- ) object-where ;
|
||||
M: object where object-where ;
|
||||
|
||||
M: integer where ( spec obj -- ) object-where ;
|
||||
M: integer where object-where ;
|
||||
|
||||
M: string where ( spec obj -- ) object-where ;
|
||||
M: string where object-where ;
|
||||
|
||||
: filter-slots ( tuple specs -- specs' )
|
||||
[
|
||||
|
@ -145,7 +145,7 @@ M: string where ( spec obj -- ) object-where ;
|
|||
: where-clause ( tuple specs -- )
|
||||
dupd filter-slots [ drop ] [ many-where ] if-empty ;
|
||||
|
||||
M: db-connection <delete-tuples-statement> ( tuple table -- sql )
|
||||
M: db-connection <delete-tuples-statement>
|
||||
[
|
||||
"delete from " 0% 0%
|
||||
where-clause
|
||||
|
@ -153,7 +153,7 @@ M: db-connection <delete-tuples-statement> ( tuple table -- sql )
|
|||
|
||||
ERROR: all-slots-ignored class ;
|
||||
|
||||
M: db-connection <select-by-slots-statement> ( tuple class -- statement )
|
||||
M: db-connection <select-by-slots-statement>
|
||||
[
|
||||
"select " 0%
|
||||
[ dupd filter-ignores ] dip
|
||||
|
@ -188,13 +188,13 @@ M: db-connection <select-by-slots-statement> ( tuple class -- statement )
|
|||
[ offset>> [ do-offset ] [ drop ] if* ]
|
||||
} 2cleave ;
|
||||
|
||||
M: db-connection query>statement ( query -- tuple )
|
||||
M: db-connection query>statement
|
||||
[ tuple>> dup class-of ] keep
|
||||
[ <select-by-slots-statement> ] dip make-query* ;
|
||||
|
||||
! select ID, NAME, SCORE from EXAM limit 1 offset 3
|
||||
|
||||
M: db-connection <count-statement> ( query -- statement )
|
||||
M: db-connection <count-statement>
|
||||
[ tuple>> dup class-of ] keep
|
||||
[ [ "select count(*) from " 0% 0% where-clause ] query-make ]
|
||||
dip make-query* ;
|
||||
|
|
|
@ -13,35 +13,37 @@ IN: db.sqlite.ffi
|
|||
} cond cdecl add-library >>
|
||||
|
||||
! Return values from sqlite functions
|
||||
CONSTANT: SQLITE_OK 0 ! Successful result
|
||||
CONSTANT: SQLITE_ERROR 1 ! SQL error or missing database
|
||||
CONSTANT: SQLITE_INTERNAL 2 ! An internal logic error in SQLite
|
||||
CONSTANT: SQLITE_PERM 3 ! Access permission denied
|
||||
CONSTANT: SQLITE_ABORT 4 ! Callback routine requested an abort
|
||||
CONSTANT: SQLITE_BUSY 5 ! The database file is locked
|
||||
CONSTANT: SQLITE_LOCKED 6 ! A table in the database is locked
|
||||
CONSTANT: SQLITE_NOMEM 7 ! A malloc() failed
|
||||
CONSTANT: SQLITE_READONLY 8 ! Attempt to write a readonly database
|
||||
CONSTANT: SQLITE_INTERRUPT 9 ! Operation terminated by sqlite_interrupt()
|
||||
CONSTANT: SQLITE_IOERR 10 ! Some kind of disk I/O error occurred
|
||||
CONSTANT: SQLITE_CORRUPT 11 ! The database disk image is malformed
|
||||
CONSTANT: SQLITE_NOTFOUND 12 ! (Internal Only) Table or record not found
|
||||
CONSTANT: SQLITE_FULL 13 ! Insertion failed because database is full
|
||||
CONSTANT: SQLITE_CANTOPEN 14 ! Unable to open the database file
|
||||
CONSTANT: SQLITE_PROTOCOL 15 ! Database lock protocol error
|
||||
CONSTANT: SQLITE_EMPTY 16 ! (Internal Only) Database table is empty
|
||||
CONSTANT: SQLITE_SCHEMA 17 ! The database schema changed
|
||||
CONSTANT: SQLITE_TOOBIG 18 ! Too much data for one row of a table
|
||||
CONSTANT: SQLITE_CONSTRAINT 19 ! Abort due to contraint violation
|
||||
CONSTANT: SQLITE_MISMATCH 20 ! Data type mismatch
|
||||
CONSTANT: SQLITE_MISUSE 21 ! Library used incorrectly
|
||||
CONSTANT: SQLITE_NOLFS 22 ! Uses OS features not supported on host
|
||||
CONSTANT: SQLITE_AUTH 23 ! Authorization denied
|
||||
CONSTANT: SQLITE_FORMAT 24 ! Auxiliary database format error
|
||||
CONSTANT: SQLITE_RANGE 25 ! 2nd parameter to sqlite3_bind out of range
|
||||
CONSTANT: SQLITE_NOTADB 26 ! File opened that is not a database file
|
||||
CONSTANT: SQLITE_OK 0 ! Successful result
|
||||
CONSTANT: SQLITE_ERROR 1 ! SQL error or missing database
|
||||
CONSTANT: SQLITE_INTERNAL 2 ! An internal logic error in SQLite
|
||||
CONSTANT: SQLITE_PERM 3 ! Access permission denied
|
||||
CONSTANT: SQLITE_ABORT 4 ! Callback routine requested an abort
|
||||
CONSTANT: SQLITE_BUSY 5 ! The database file is locked
|
||||
CONSTANT: SQLITE_LOCKED 6 ! A table in the database is locked
|
||||
CONSTANT: SQLITE_NOMEM 7 ! A malloc() failed
|
||||
CONSTANT: SQLITE_READONLY 8 ! Attempt to write a readonly database
|
||||
CONSTANT: SQLITE_INTERRUPT 9 ! Operation terminated by sqlite_interrupt()
|
||||
CONSTANT: SQLITE_IOERR 10 ! Some kind of disk I/O error occurred
|
||||
CONSTANT: SQLITE_CORRUPT 11 ! The database disk image is malformed
|
||||
CONSTANT: SQLITE_NOTFOUND 12 ! (Internal Only) Table or record not found
|
||||
CONSTANT: SQLITE_FULL 13 ! Insertion failed because database is full
|
||||
CONSTANT: SQLITE_CANTOPEN 14 ! Unable to open the database file
|
||||
CONSTANT: SQLITE_PROTOCOL 15 ! Database lock protocol error
|
||||
CONSTANT: SQLITE_EMPTY 16 ! (Internal Only) Database table is empty
|
||||
CONSTANT: SQLITE_SCHEMA 17 ! The database schema changed
|
||||
CONSTANT: SQLITE_TOOBIG 18 ! Too much data for one row of a table
|
||||
CONSTANT: SQLITE_CONSTRAINT 19 ! Abort due to contraint violation
|
||||
CONSTANT: SQLITE_MISMATCH 20 ! Data type mismatch
|
||||
CONSTANT: SQLITE_MISUSE 21 ! Library used incorrectly
|
||||
CONSTANT: SQLITE_NOLFS 22 ! Uses OS features not supported on host
|
||||
CONSTANT: SQLITE_AUTH 23 ! Authorization denied
|
||||
CONSTANT: SQLITE_FORMAT 24 ! Auxiliary database format error
|
||||
CONSTANT: SQLITE_RANGE 25 ! 2nd parameter to sqlite3_bind out of range
|
||||
CONSTANT: SQLITE_NOTADB 26 ! File opened that is not a database file
|
||||
CONSTANT: SQLITE_NOTICE 27 ! Notifications from sqlite3_log()
|
||||
CONSTANT: SQLITE_WARNING 28 ! Warnings from sqlite3_log()
|
||||
|
||||
: sqlite-error-messages ( -- seq ) {
|
||||
CONSTANT: sqlite-error-messages {
|
||||
"Successful result"
|
||||
"SQL error or missing database"
|
||||
"An internal logic error in SQLite"
|
||||
|
@ -69,7 +71,9 @@ CONSTANT: SQLITE_NOTADB 26 ! File opened that is not a database file
|
|||
"Auxiliary database format error"
|
||||
"2nd parameter to sqlite3_bind out of range"
|
||||
"File opened that is not a database file"
|
||||
} ;
|
||||
"Notifications from sqlite3_log()"
|
||||
"Warnings from sqlite3_log()"
|
||||
}
|
||||
|
||||
! Return values from sqlite3_step
|
||||
CONSTANT: SQLITE_ROW 100
|
||||
|
@ -101,19 +105,240 @@ CONSTANT: SQLITE_OPEN_MASTER_JOURNAL 0x00004000
|
|||
|
||||
C-TYPE: sqlite3
|
||||
C-TYPE: sqlite3_stmt
|
||||
C-TYPE: sqlite3_value
|
||||
C-TYPE: sqlite3_context
|
||||
C-TYPE: sqlite3_file
|
||||
TYPEDEF: longlong sqlite3_int64
|
||||
TYPEDEF: ulonglong sqlite3_uint64
|
||||
|
||||
LIBRARY: sqlite
|
||||
FUNCTION: int sqlite3_open ( c-string filename, void* ppDb )
|
||||
|
||||
! FUNCTION: char sqlite3_version[]
|
||||
FUNCTION: char* sqlite3_libversion ( )
|
||||
FUNCTION: char* sqlite3_sourceid ( )
|
||||
FUNCTION: int sqlite3_libversion_number ( )
|
||||
FUNCTION: int sqlite3_compileoption_used ( char* zOptName )
|
||||
FUNCTION: char* sqlite3_compileoption_get ( int N )
|
||||
FUNCTION: int sqlite3_threadsafe ( )
|
||||
|
||||
FUNCTION: int sqlite3_close ( sqlite3* pDb )
|
||||
FUNCTION: int sqlite3_close_v2 ( sqlite3* pDb )
|
||||
|
||||
FUNCTION: int sqlite3_exec (
|
||||
sqlite3* pDb,
|
||||
char* sql,
|
||||
void* callback,
|
||||
void* arg,
|
||||
char** errmsg
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_initialize ( )
|
||||
FUNCTION: int sqlite3_shutdown ( )
|
||||
FUNCTION: int sqlite3_os_init ( )
|
||||
FUNCTION: int sqlite3_os_end ( )
|
||||
|
||||
FUNCTION: int sqlite3_extended_result_codes ( sqlite3* pDb, int onoff )
|
||||
FUNCTION: sqlite3_uint64 sqlite3_last_insert_rowid ( sqlite3* pDb )
|
||||
FUNCTION: sqlite3_uint64 sqlite3_set_last_insert_rowid ( sqlite3* pDb, sqlite3_int64 n )
|
||||
FUNCTION: int sqlite3_changes ( sqlite3* pDb )
|
||||
FUNCTION: int sqlite3_total_changes ( sqlite3* pDb )
|
||||
FUNCTION: void sqlite3_interrupt ( sqlite3* pDb )
|
||||
|
||||
FUNCTION: int sqlite3_complete ( c-string sql )
|
||||
FUNCTION: int sqlite3_complete16 ( void *sql )
|
||||
|
||||
FUNCTION: void *sqlite3_malloc ( int i )
|
||||
FUNCTION: void *sqlite3_malloc64 ( sqlite3_uint64 u )
|
||||
FUNCTION: void *sqlite3_realloc ( void* ptr, int i )
|
||||
FUNCTION: void *sqlite3_realloc64 ( void* ptr, sqlite3_uint64 u )
|
||||
FUNCTION: void sqlite3_free ( void* ptr )
|
||||
FUNCTION: sqlite3_uint64 sqlite3_msize ( void* ptr )
|
||||
|
||||
FUNCTION: sqlite3_int64 sqlite3_memory_used ( )
|
||||
FUNCTION: sqlite3_int64 sqlite3_memory_highwater ( int resetFlag )
|
||||
|
||||
FUNCTION: void sqlite3_randomness ( int N, void *P )
|
||||
|
||||
FUNCTION: int sqlite3_set_authorizer (
|
||||
sqlite3* pDb,
|
||||
void* cb, ! int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
|
||||
void* pUserData
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_trace_v2 (
|
||||
sqlite3* pDb,
|
||||
uint uMask,
|
||||
void* cb, ! int(*xCallback)(unsigned,void*,void*,void*),
|
||||
void* pCtx
|
||||
)
|
||||
|
||||
FUNCTION: void sqlite3_progress_handler ( sqlite3* pDb, int arg1, void* cb, void* arg2 )
|
||||
|
||||
FUNCTION: int sqlite3_open (
|
||||
c-string filename, ! Database filename (UTF-8)
|
||||
sqlite3** ppDb ! OUT: SQLite db handle
|
||||
)
|
||||
FUNCTION: int sqlite3_open16 (
|
||||
c-string filename, ! Database filename (UTF-16)
|
||||
sqlite3** ppDb ! OUT: SQLite db handle
|
||||
)
|
||||
FUNCTION: int sqlite3_open_v2 (
|
||||
c-string filename, ! Database filename (UTF-8)
|
||||
sqlite3** ppDb, ! OUT: SQLite db handle
|
||||
int flags, ! Flags
|
||||
c-string zVfs ! Name of VFS module to use
|
||||
)
|
||||
|
||||
FUNCTION: c-string sqlite3_uri_parameter ( c-string zFilename, c-string zParam )
|
||||
FUNCTION: int sqlite3_uri_boolean ( c-string zFile, c-string zParam, int bDefault )
|
||||
FUNCTION: sqlite3_int64 sqlite3_uri_int64 ( c-string str1, c-string str2, sqlite3_int64 i )
|
||||
FUNCTION: c-string sqlite3_uri_key ( c-string zFilename, int N )
|
||||
|
||||
FUNCTION: c-string sqlite3_filename_database ( c-string str )
|
||||
FUNCTION: c-string sqlite3_filename_journal ( c-string str )
|
||||
FUNCTION: c-string sqlite3_filename_wal ( c-string str )
|
||||
|
||||
FUNCTION: sqlite3_file* sqlite3_database_file_object ( c-string str )
|
||||
|
||||
FUNCTION: char* sqlite3_create_filename (
|
||||
c-string zDatabase,
|
||||
c-string zJournal,
|
||||
c-string zWal,
|
||||
int nParam,
|
||||
c-string *azParam
|
||||
)
|
||||
FUNCTION: void sqlite3_free_filename ( c-string name )
|
||||
|
||||
FUNCTION: int sqlite3_errcode ( sqlite3 *db )
|
||||
FUNCTION: int sqlite3_extended_errcode ( sqlite3 *db )
|
||||
FUNCTION: c-string sqlite3_errmsg ( sqlite3* pDb )
|
||||
FUNCTION: int sqlite3_prepare ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail )
|
||||
FUNCTION: int sqlite3_prepare_v2 ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail )
|
||||
FUNCTION: void *sqlite3_errmsg16 ( sqlite3* pDb )
|
||||
FUNCTION: c-string sqlite3_errstr ( int N )
|
||||
|
||||
FUNCTION: int sqlite3_limit ( sqlite3* pDb, int id, int newVal )
|
||||
|
||||
! FUNCTION: int sqlite3_prepare ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail )
|
||||
! FUNCTION: int sqlite3_prepare_v2 ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail )
|
||||
|
||||
FUNCTION: int sqlite3_prepare (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-8 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
char** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_prepare_v2 (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-8 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
char** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_prepare_v3 (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-8 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
uint prepFlags, ! Zero or more SQLITE_PREPARE_ flags
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
char** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_prepare16 (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-16 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
void** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_prepare16_v2 (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-16 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
void** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_prepare16_v3 (
|
||||
sqlite3* db, ! Database handle
|
||||
c-string zSql, ! SQL statement, UTF-16 encoded
|
||||
int nByte, ! Maximum length of zSql in bytes.
|
||||
uint prepFlags, ! Zero or more SQLITE_PREPARE_ flags
|
||||
sqlite3_stmt** ppStmt, ! OUT: Statement handle
|
||||
void** pzTail ! OUT: Pointer to unused portion of zSql
|
||||
)
|
||||
|
||||
FUNCTION: char *sqlite3_sql ( sqlite3_stmt *pStmt )
|
||||
FUNCTION: char *sqlite3_expanded_sql ( sqlite3_stmt *pStmt )
|
||||
FUNCTION: char *sqlite3_normalized_sql ( sqlite3_stmt *pStmt )
|
||||
|
||||
FUNCTION: int sqlite3_stmt_readonly ( sqlite3_stmt *pStmt )
|
||||
FUNCTION: int sqlite3_stmt_isexplain ( sqlite3_stmt *pStmt )
|
||||
FUNCTION: int sqlite3_stmt_busy ( sqlite3_stmt *pStmt )
|
||||
|
||||
|
||||
FUNCTION: int sqlite3_bind_parameter_count ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: char* sqlite3_bind_parameter_name ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, c-string zName )
|
||||
FUNCTION: int sqlite3_clear_bindings ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: int sqlite3_column_count ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: char* sqlite3_column_name ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: void* sqlite3_column_name16 ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: char* sqlite3_column_database_name ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: void* sqlite3_column_database_name16 ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: char* sqlite3_column_table_name ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: void* sqlite3_column_table_name16 ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: char* sqlite3_column_origin_name ( sqlite3_stmt* pStmt, int N )
|
||||
FUNCTION: void* sqlite3_column_origin_name16 ( sqlite3_stmt* pStmt, int N )
|
||||
|
||||
FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: void* sqlite3_column_decltype16 ( sqlite3_stmt* pStmt, int col )
|
||||
|
||||
FUNCTION: int sqlite3_step ( sqlite3_stmt* pStmt )
|
||||
|
||||
FUNCTION: void* sqlite3_column_blob ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col )
|
||||
! Bind the same function as above, but for unsigned 64bit integers
|
||||
FUNCTION-ALIAS: sqlite3_column_uint64
|
||||
sqlite3_uint64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: c-string sqlite3_column_text ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: c-string sqlite3_column_text16 ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: sqlite3_value* sqlite3_column_value ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_bytes ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_bytes16 ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_type ( sqlite3_stmt* pStmt, int col )
|
||||
|
||||
FUNCTION: int sqlite3_finalize ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: int sqlite3_reset ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: int sqlite3_step ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: sqlite3_uint64 sqlite3_last_insert_rowid ( sqlite3* pStmt )
|
||||
|
||||
FUNCTION: void* sqlite3_value_blob ( sqlite3_value* value )
|
||||
FUNCTION: double sqlite3_value_double ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_int ( sqlite3_value* value )
|
||||
FUNCTION: sqlite3_int64 sqlite3_value_int64 ( sqlite3_value* value )
|
||||
FUNCTION: void* sqlite3_value_pointer ( sqlite3_value* value, char* value )
|
||||
FUNCTION: uchar* sqlite3_value_text ( sqlite3_value* value )
|
||||
FUNCTION: void* sqlite3_value_text16 ( sqlite3_value* value )
|
||||
FUNCTION: void* sqlite3_value_text16le ( sqlite3_value* value )
|
||||
FUNCTION: void* sqlite3_value_text16be ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_bytes ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_bytes16 ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_type ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_numeric_type ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_nochange ( sqlite3_value* value )
|
||||
FUNCTION: int sqlite3_value_frombind ( sqlite3_value* value )
|
||||
|
||||
FUNCTION: uint sqlite3_value_subtype ( sqlite3_value* value )
|
||||
FUNCTION: sqlite3_value *sqlite3_value_dup ( sqlite3_value* value )
|
||||
FUNCTION: void sqlite3_value_free ( sqlite3_value* value )
|
||||
|
||||
|
||||
|
||||
FUNCTION: int sqlite3_data_count ( sqlite3_stmt *pStmt )
|
||||
|
||||
FUNCTION: int sqlite3_bind_blob ( sqlite3_stmt* pStmt, int index, void* ptr, int len, int destructor )
|
||||
FUNCTION: int sqlite3_bind_double ( sqlite3_stmt* pStmt, int index, double x )
|
||||
FUNCTION: int sqlite3_bind_int ( sqlite3_stmt* pStmt, int index, int n )
|
||||
|
@ -123,18 +348,89 @@ FUNCTION-ALIAS: sqlite3-bind-uint64
|
|||
int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_uint64 in64 )
|
||||
FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n )
|
||||
FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, c-string text, int len, int destructor )
|
||||
FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, c-string name )
|
||||
FUNCTION: int sqlite3_clear_bindings ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: int sqlite3_column_count ( sqlite3_stmt* pStmt )
|
||||
FUNCTION: void* sqlite3_column_blob ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_bytes ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col )
|
||||
! Bind the same function as above, but for unsigned 64bit integers
|
||||
FUNCTION-ALIAS: sqlite3_column_uint64
|
||||
sqlite3_uint64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: c-string sqlite3_column_name ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: c-string sqlite3_column_text ( sqlite3_stmt* pStmt, int col )
|
||||
FUNCTION: int sqlite3_column_type ( sqlite3_stmt* pStmt, int col )
|
||||
|
||||
|
||||
FUNCTION: void* sqlite3_aggregate_context ( sqlite3_context* context, int nBytes )
|
||||
FUNCTION: void* sqlite3_user_data ( sqlite3_context* context )
|
||||
FUNCTION: sqlite3 *sqlite3_context_db_handle ( sqlite3_context* context )
|
||||
|
||||
FUNCTION: void *sqlite3_get_auxdata ( sqlite3_context* context, int N )
|
||||
FUNCTION: void sqlite3_set_auxdata ( sqlite3_context* context, int N, void* arg, void* arg2 )
|
||||
|
||||
FUNCTION: void sqlite3_result_blob ( sqlite3_context* context, void* arg, int arg2, void* cb )
|
||||
FUNCTION: void sqlite3_result_blob64 ( sqlite3_context* context, void* arg1, sqlite3_uint64 arg2, void* cb )
|
||||
FUNCTION: void sqlite3_result_double ( sqlite3_context* context, double d )
|
||||
FUNCTION: void sqlite3_result_error ( sqlite3_context* context, char* arg1, int arg2 )
|
||||
FUNCTION: void sqlite3_result_error16 ( sqlite3_context* context, void* arg1, int arg2 )
|
||||
FUNCTION: void sqlite3_result_error_toobig ( sqlite3_context* context )
|
||||
FUNCTION: void sqlite3_result_error_nomem ( sqlite3_context* context )
|
||||
FUNCTION: void sqlite3_result_error_code ( sqlite3_context* context, int i )
|
||||
FUNCTION: void sqlite3_result_int ( sqlite3_context* context, int i )
|
||||
FUNCTION: void sqlite3_result_int64 ( sqlite3_context* context, sqlite3_int64 i )
|
||||
FUNCTION: void sqlite3_result_null ( sqlite3_context* context )
|
||||
FUNCTION: void sqlite3_result_text ( sqlite3_context* context, char* c, int i, void* cb )
|
||||
FUNCTION: void sqlite3_result_text64 ( sqlite3_context* context, char* c, sqlite3_uint64 ui, void* v, uchar encoding )
|
||||
FUNCTION: void sqlite3_result_text16 ( sqlite3_context* context, void* arg, int arg2, void* arg3 )
|
||||
FUNCTION: void sqlite3_result_text16le ( sqlite3_context* context, void* arg1, int arg2, void* arg3 )
|
||||
FUNCTION: void sqlite3_result_text16be ( sqlite3_context* context, void* arg1, int arg2, void* arg3 )
|
||||
FUNCTION: void sqlite3_result_value ( sqlite3_context* context, sqlite3_value* value )
|
||||
FUNCTION: void sqlite3_result_pointer ( sqlite3_context* context, void* arg1, char* arg2, void* ptr )
|
||||
FUNCTION: void sqlite3_result_zeroblob ( sqlite3_context* context, int n )
|
||||
FUNCTION: int sqlite3_result_zeroblob64 ( sqlite3_context* context, sqlite3_uint64 n )
|
||||
|
||||
FUNCTION: void sqlite3_result_subtype ( sqlite3_context* context, uint u )
|
||||
|
||||
FUNCTION: int sqlite3_create_collation (
|
||||
sqlite3* pDb,
|
||||
c-string zName,
|
||||
int eTextRep,
|
||||
void* pArg,
|
||||
void* cb ! int(*xCompare)(void*,int,const void*,int,const void*)
|
||||
)
|
||||
FUNCTION: int sqlite3_create_collation_v2 (
|
||||
sqlite3* pDb,
|
||||
c-string zName,
|
||||
int eTextRep,
|
||||
void *pArg,
|
||||
void* cb1, ! int(*xCompare)(void*,int,const void*,int,const void*),
|
||||
void* cb2, ! void(*xDestroy)(void*)
|
||||
)
|
||||
FUNCTION: int sqlite3_create_collation16 (
|
||||
sqlite3* pDb,
|
||||
void *zName,
|
||||
int eTextRep,
|
||||
void* pArg,
|
||||
void* cb ! int(*xCompare)(void*,int,const void*,int,const void*)
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_collation_needed (
|
||||
sqlite3* pDb,
|
||||
void* ptr,
|
||||
void* cb ! void(*)(void*,sqlite3*,int eTextRep,const char*)
|
||||
)
|
||||
FUNCTION: int sqlite3_collation_needed16 (
|
||||
sqlite3* pDb,
|
||||
void* ptr,
|
||||
void* cb ! void(*)(void*,sqlite3*,int eTextRep,const void*)
|
||||
)
|
||||
|
||||
FUNCTION: int sqlite3_sleep ( int n )
|
||||
|
||||
C-GLOBAL: c-string sqlite3_temp_directory
|
||||
C-GLOBAL: c-string sqlite3_data_directory
|
||||
|
||||
FUNCTION: int sqlite3_win32_set_directory (
|
||||
ulong type, ! Identifier for directory being set or reset
|
||||
void* zValue ! New value for directory being set or reset
|
||||
)
|
||||
FUNCTION: int sqlite3_win32_set_directory8 ( ulong type, c-string zValue )
|
||||
FUNCTION: int sqlite3_win32_set_directory16 ( ulong type, c-string zValue )
|
||||
|
||||
CONSTANT: SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
|
||||
CONSTANT: SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
|
||||
|
||||
FUNCTION: int sqlite3_get_autocommit ( sqlite3* pDb )
|
||||
FUNCTION: sqlite3* sqlite3_db_handle ( sqlite3_stmt* pStmt )
|
||||
|
||||
FUNCTION: c-string sqlite3_db_filename ( sqlite3* db, c-string zDbName )
|
||||
FUNCTION: int sqlite3_db_readonly ( sqlite3* db, c-string zDbName )
|
|
@ -22,19 +22,19 @@ TUPLE: sqlite-db-connection < db-connection ;
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: sqlite-db db-open ( db -- db-connection )
|
||||
M: sqlite-db db-open
|
||||
path>> sqlite-open <sqlite-db-connection> ;
|
||||
|
||||
M: sqlite-db-connection db-close ( handle -- ) sqlite-close ;
|
||||
M: sqlite-db-connection db-close sqlite-close ;
|
||||
|
||||
TUPLE: sqlite-statement < statement ;
|
||||
|
||||
TUPLE: sqlite-result-set < result-set has-more? ;
|
||||
|
||||
M: sqlite-db-connection <simple-statement> ( str in out -- obj )
|
||||
M: sqlite-db-connection <simple-statement>
|
||||
<prepared-statement> ;
|
||||
|
||||
M: sqlite-db-connection <prepared-statement> ( str in out -- obj )
|
||||
M: sqlite-db-connection <prepared-statement>
|
||||
sqlite-statement new-statement ;
|
||||
|
||||
: sqlite-maybe-prepare ( statement -- statement )
|
||||
|
@ -43,22 +43,22 @@ M: sqlite-db-connection <prepared-statement> ( str in out -- obj )
|
|||
>>handle
|
||||
] unless ;
|
||||
|
||||
M: sqlite-statement dispose ( statement -- )
|
||||
M: sqlite-statement dispose
|
||||
handle>>
|
||||
[ [ sqlite3_reset drop ] keep sqlite-finalize ] when* ;
|
||||
|
||||
M: sqlite-result-set dispose ( result-set -- )
|
||||
M: sqlite-result-set dispose
|
||||
f >>handle drop ;
|
||||
|
||||
: reset-bindings ( statement -- )
|
||||
sqlite-maybe-prepare
|
||||
handle>> [ sqlite3_reset drop ] [ sqlite3_clear_bindings drop ] bi ;
|
||||
|
||||
M: sqlite-statement low-level-bind ( statement -- )
|
||||
M: sqlite-statement low-level-bind
|
||||
[ handle>> ] [ bind-params>> ] bi
|
||||
[ [ key>> ] [ value>> ] [ type>> ] tri sqlite-bind-type ] with each ;
|
||||
|
||||
M: sqlite-statement bind-statement* ( statement -- )
|
||||
M: sqlite-statement bind-statement*
|
||||
sqlite-maybe-prepare
|
||||
dup bound?>> [ dup reset-bindings ] when
|
||||
low-level-bind ;
|
||||
|
@ -72,12 +72,12 @@ TUPLE: sqlite-low-level-binding < low-level-binding key type ;
|
|||
swap >>value
|
||||
swap >>key ;
|
||||
|
||||
M: sql-spec sqlite-bind-conversion ( tuple spec -- array )
|
||||
M: sql-spec sqlite-bind-conversion
|
||||
[ column-name>> ":" prepend ]
|
||||
[ slot-name>> rot get-slot-named ]
|
||||
[ type>> ] tri <sqlite-low-level-binding> ;
|
||||
|
||||
M: literal-bind sqlite-bind-conversion ( tuple literal-bind -- array )
|
||||
M: literal-bind sqlite-bind-conversion
|
||||
nip [ key>> ] [ value>> ] [ type>> ] tri
|
||||
<sqlite-low-level-binding> ;
|
||||
|
||||
|
@ -87,7 +87,7 @@ M:: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
|
|||
obj name tuple set-slot-named
|
||||
generate-bind key>> obj generate-bind type>> <sqlite-low-level-binding> ;
|
||||
|
||||
M: sqlite-statement bind-tuple ( tuple statement -- )
|
||||
M: sqlite-statement bind-tuple
|
||||
[
|
||||
in-params>> [ sqlite-bind-conversion ] with map
|
||||
] keep bind-statement ;
|
||||
|
@ -98,31 +98,31 @@ ERROR: sqlite-last-id-fail ;
|
|||
db-connection get handle>> sqlite3_last_insert_rowid
|
||||
dup zero? [ sqlite-last-id-fail ] when ;
|
||||
|
||||
M: sqlite-db-connection insert-tuple-set-key ( tuple statement -- )
|
||||
M: sqlite-db-connection insert-tuple-set-key
|
||||
execute-statement last-insert-id swap set-primary-key ;
|
||||
|
||||
M: sqlite-result-set #columns ( result-set -- n )
|
||||
M: sqlite-result-set #columns
|
||||
handle>> sqlite-#columns ;
|
||||
|
||||
M: sqlite-result-set row-column ( result-set n -- obj )
|
||||
M: sqlite-result-set row-column
|
||||
[ handle>> ] [ sqlite-column ] bi* ;
|
||||
|
||||
M: sqlite-result-set row-column-typed ( result-set n -- obj )
|
||||
M: sqlite-result-set row-column-typed
|
||||
dup pick out-params>> nth type>>
|
||||
[ handle>> ] 2dip sqlite-column-typed ;
|
||||
|
||||
M: sqlite-result-set advance-row ( result-set -- )
|
||||
M: sqlite-result-set advance-row
|
||||
dup handle>> sqlite-next >>has-more? drop ;
|
||||
|
||||
M: sqlite-result-set more-rows? ( result-set -- ? )
|
||||
M: sqlite-result-set more-rows?
|
||||
has-more?>> ;
|
||||
|
||||
M: sqlite-statement query-results ( query -- result-set )
|
||||
M: sqlite-statement query-results
|
||||
sqlite-maybe-prepare
|
||||
dup handle>> sqlite-result-set new-result-set
|
||||
dup advance-row ;
|
||||
|
||||
M: sqlite-db-connection <insert-db-assigned-statement> ( class -- statement )
|
||||
M: sqlite-db-connection <insert-db-assigned-statement>
|
||||
[
|
||||
"insert into " 0% 0%
|
||||
"(" 0%
|
||||
|
@ -143,19 +143,19 @@ M: sqlite-db-connection <insert-db-assigned-statement> ( class -- statement )
|
|||
");" 0%
|
||||
] query-make ;
|
||||
|
||||
M: sqlite-db-connection <insert-user-assigned-statement> ( class -- statement )
|
||||
M: sqlite-db-connection <insert-user-assigned-statement>
|
||||
<insert-db-assigned-statement> ;
|
||||
|
||||
M: sqlite-db-connection bind# ( spec obj -- )
|
||||
M: sqlite-db-connection bind#
|
||||
[
|
||||
[ column-name>> ":" next-sql-counter surround dup 0% ]
|
||||
[ type>> ] bi
|
||||
] dip <literal-bind> 1, ;
|
||||
|
||||
M: sqlite-db-connection bind% ( spec -- )
|
||||
M: sqlite-db-connection bind%
|
||||
dup 1, column-name>> ":" prepend 0% ;
|
||||
|
||||
M: sqlite-db-connection persistent-table ( -- assoc )
|
||||
M: sqlite-db-connection persistent-table
|
||||
H{
|
||||
{ +db-assigned-id+ { "integer" "integer" f } }
|
||||
{ +user-assigned-id+ { f f f } }
|
||||
|
@ -314,16 +314,16 @@ M: sqlite-db-connection persistent-table ( -- assoc )
|
|||
");" 0%
|
||||
] 2bi ;
|
||||
|
||||
M: sqlite-db-connection create-sql-statement ( class -- statement )
|
||||
M: sqlite-db-connection create-sql-statement
|
||||
[
|
||||
[ sqlite-create-table ]
|
||||
[ drop create-db-triggers ] 2bi
|
||||
] query-make ;
|
||||
|
||||
M: sqlite-db-connection drop-sql-statement ( class -- statements )
|
||||
M: sqlite-db-connection drop-sql-statement
|
||||
[ nip "drop table " 0% 0% ";" 0% ] query-make ;
|
||||
|
||||
M: sqlite-db-connection compound ( string seq -- new-string )
|
||||
M: sqlite-db-connection compound
|
||||
over {
|
||||
{ "default" [ first number>string " " glue ] }
|
||||
{ "references" [ >reference-string ] }
|
||||
|
|
|
@ -4,6 +4,6 @@ USING: debugger io kernel prettyprint sequences system
|
|||
unix.signals ;
|
||||
IN: debugger.unix
|
||||
|
||||
M: unix signal-error. ( obj -- )
|
||||
M: unix signal-error.
|
||||
"Unix signal #" write
|
||||
third [ pprint ] [ signal-name. ] bi nl ;
|
||||
|
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 662 B After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 584 B After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 662 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 751 B After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 548 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 795 B After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 758 B After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -21,7 +21,7 @@ M: macosx find-atom
|
|||
f
|
||||
] if* ;
|
||||
|
||||
M: atom-editor editor-command ( file line -- command )
|
||||
M: atom-editor editor-command
|
||||
[
|
||||
atom-path get [ find-atom ] unless* ,
|
||||
number>string ":" glue ,
|
||||
|
|
|
@ -4,6 +4,6 @@ IN: editors.bbedit
|
|||
SINGLETON: bbedit
|
||||
bbedit editor-class set-global
|
||||
|
||||
M: bbedit editor-command ( file line -- command )
|
||||
M: bbedit editor-command
|
||||
drop
|
||||
[ "open" , "-a" , "BBEdit" , , ] { } make ;
|
||||
|
|
|
@ -16,7 +16,7 @@ M: macosx brackets-path
|
|||
f
|
||||
] if* ;
|
||||
|
||||
M: brackets-editor editor-command ( file line -- command )
|
||||
M: brackets-editor editor-command
|
||||
[ brackets-path "brackets" or , drop , ] { } make ;
|
||||
|
||||
os windows? [ "editors.brackets.windows" require ] when
|
||||
|
|
|
@ -12,5 +12,5 @@ coteditor editor-class set-global
|
|||
f
|
||||
] if* ;
|
||||
|
||||
M: coteditor editor-command ( file line -- command )
|
||||
M: coteditor editor-command
|
||||
[ find-cot-bundle-path , "-l" , number>string , , ] { } make ;
|
||||
|
|
|
@ -14,7 +14,7 @@ editpadpro editor-class set-global
|
|||
} 0||
|
||||
] unless* ;
|
||||
|
||||
M: editpadpro editor-command ( file line -- command )
|
||||
M: editpadpro editor-command
|
||||
[
|
||||
editpadpro-path , number>string "/l" prepend , ,
|
||||
] { } make ;
|
||||
|
|
|
@ -11,7 +11,7 @@ editplus editor-class set-global
|
|||
[ "editplus.exe" ] unless*
|
||||
] unless* ;
|
||||
|
||||
M: editplus editor-command ( file line -- command )
|
||||
M: editplus editor-command
|
||||
[
|
||||
editplus-path , "-cursor" , number>string , ,
|
||||
] { } make ;
|
||||
|
|
|
@ -10,7 +10,7 @@ SYMBOL: emacsclient-args
|
|||
|
||||
HOOK: find-emacsclient os ( -- path )
|
||||
|
||||
M: object find-emacsclient ( -- path )
|
||||
M: object find-emacsclient
|
||||
"emacsclient" ?find-in-path ;
|
||||
|
||||
M: windows find-emacsclient
|
||||
|
@ -20,7 +20,7 @@ M: windows find-emacsclient
|
|||
[ "emacsclient.exe" ]
|
||||
} 0|| ;
|
||||
|
||||
M: emacsclient editor-command ( file line -- command )
|
||||
M: emacsclient editor-command
|
||||
[
|
||||
emacsclient-path get [ find-emacsclient ] unless* ,
|
||||
emacsclient-args get [ { "-a=emacs" "--no-wait" } ] unless* %
|
||||
|
|
|
@ -11,7 +11,7 @@ emeditor editor-class set-global
|
|||
[ "EmEditor.exe" ] unless*
|
||||
] unless* ;
|
||||
|
||||
M: emeditor editor-command ( file line -- command )
|
||||
M: emeditor editor-command
|
||||
[
|
||||
emeditor-path , "/l" , number>string , ,
|
||||
] { } make ;
|
||||
|
|
|
@ -13,7 +13,7 @@ etexteditor editor-class set-global
|
|||
[ "e.exe" ] unless*
|
||||
] unless* ;
|
||||
|
||||
M: etexteditor editor-command ( file line -- command )
|
||||
M: etexteditor editor-command
|
||||
[
|
||||
etexteditor-path ,
|
||||
[ , ] [ "--line" , number>string , ] bi*
|
||||
|
|