substrate-lang 0.9.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/compiler/{binary.cdd2ffb408dd@0+0.wasm → binary.2d43b43d1600@0+0.wasm} +0 -0
- package/build/compiler/checker.4dd4556dd421@0+0.wasm +0 -0
- package/build/compiler/{compile.da85f9bc4478@0+0.wasm → compile.5d8f6407af2a@0+0.wasm} +0 -0
- package/build/compiler/{core.0410ffbdc488@0+0.wasm → core.f2defb75e00b@0+0.wasm} +0 -0
- package/build/compiler/expander.967ce443d379@0+0.wasm +0 -0
- package/build/compiler/fs.01b8aab4a9a8@0+0.wasm +0 -0
- package/build/compiler/{leb128.ba77430f659f@0+0.wasm → leb128.15d814b7b4f2@0+0.wasm} +0 -0
- package/build/compiler/{link.be6e641afa93@0+0.wasm → link.b826ea7c8f17@0+0.wasm} +0 -0
- package/build/compiler/{macros.b695763c0ca3@0+0.wasm → macros.b269e0c42784@0+0.wasm} +0 -0
- package/build/compiler/{main.cbbdf42e34c2@0+0.wasm → main.4fc52f204d54@0+0.wasm} +0 -0
- package/build/compiler/{ops.324f0a665fab@0+0.wasm → ops.515b5e05f646@0+0.wasm} +0 -0
- package/build/compiler/{path.1b5fd988b6f3@0+0.wasm → path.5a6286472cd4@0+0.wasm} +0 -0
- package/build/compiler/program +21 -21
- package/build/compiler/{prune.29dde307bdee@0+0.wasm → prune.406215c3e4f8@0+0.wasm} +0 -0
- package/build/compiler/reader.694b03770bf0@0+0.wasm +0 -0
- package/build/compiler/roots.cefd10e93684@0+0.wasm +0 -0
- package/build/compiler/{running.b99787c2d180@0+0.wasm → running.0d25dbaec018@0+0.wasm} +0 -0
- package/build/compiler/serialize.b0d82f3d63d2@0+0.wasm +0 -0
- package/build/compiler/{sha256.f6c742932dde@0+0.wasm → sha256.a6c32b04d799@0+0.wasm} +0 -0
- package/build/compiler/substrate.5ee5d0b4d3e7@0+0.wasm +0 -0
- package/build/compiler/{syntax.fadc832db29f@0+0.wasm → syntax.32f3e40b61c7@0+0.wasm} +0 -0
- package/build/compiler/{writer.550227768eb9@0+0.wasm → writer.00b7802cbe39@0+0.wasm} +0 -0
- package/build/sub/{base64.454b045156d2@0+0.wasm → base64.a26bdcf60a2d@0+0.wasm} +0 -0
- package/build/sub/build.459c5b9412bd@0+0.wasm +0 -0
- package/build/sub/chromium.3d5818f2707d@0+0.wasm +0 -0
- package/build/sub/common.1edc613607a0@0+0.wasm +0 -0
- package/build/sub/deflate.23f7c4679260@0+0.wasm +0 -0
- package/build/sub/doc.0775df5de6fe@0+0.wasm +0 -0
- package/build/sub/{doc.f18ad14060e9@0+0.wasm → doc.ef9965d5d402@0+0.wasm} +0 -0
- package/build/sub/env.e5451da6e747@0+0.wasm +0 -0
- package/build/sub/events.bf5473ebf220@0+0.wasm +0 -0
- package/build/sub/fetch.7790d4943758@0+0.wasm +0 -0
- package/build/sub/fetch.96b2d10f025e@0+0.wasm +0 -0
- package/build/sub/files.ad0469fdf6fa@0+0.wasm +0 -0
- package/build/sub/fs.01b8aab4a9a8@0+0.wasm +0 -0
- package/build/sub/git.dc4c0e757ebe@0+0.wasm +0 -0
- package/build/sub/grants.c54776c0d7e3@0+0.wasm +0 -0
- package/build/sub/gzip.16e372eda1cf@0+0.wasm +0 -0
- package/build/sub/hash.660682e4f491@0+0.wasm +0 -0
- package/build/sub/{html.0b0362932a75@0+0.wasm → html.a23126eb949a@0+0.wasm} +0 -0
- package/build/sub/{html.3b3c8d7d9971@0+0.wasm → html.e9ed37f34977@0+0.wasm} +0 -0
- package/build/sub/{inflate.3cfa17586072@0+0.wasm → inflate.59bb61f14001@0+0.wasm} +0 -0
- package/build/sub/json.55590d2f518a@0+0.wasm +0 -0
- package/build/sub/manifest.ef317480deb0@0+0.wasm +0 -0
- package/build/sub/{map.e582eae03ec2@0+0.wasm → map.f455cca6a42a@0+0.wasm} +0 -0
- package/build/sub/pack.e02836264f6a@0+0.wasm +0 -0
- package/build/sub/{path.1b5fd988b6f3@0+0.wasm → path.5a6286472cd4@0+0.wasm} +0 -0
- package/build/sub/path.6891ffea73ca@0+0.wasm +0 -0
- package/build/sub/process.7106571fa723@0+0.wasm +0 -0
- package/build/sub/program +48 -48
- package/build/sub/read.0b93933d62a2@0+0.wasm +0 -0
- package/build/sub/{reader.d256e69e09e2@0+0.wasm → reader.694b03770bf0@0+0.wasm} +0 -0
- package/build/sub/{root.02141d04d568@0+0.wasm → root.f10a4906f460@0+0.wasm} +0 -0
- package/build/sub/{roots.e366210c01d6@0+0.wasm → roots.cefd10e93684@0+0.wasm} +0 -0
- package/build/sub/{sha256.f6c742932dde@0+0.wasm → sha256.a6c32b04d799@0+0.wasm} +0 -0
- package/build/sub/{sha512.9fee24e95460@0+0.wasm → sha512.c24a792d7891@0+0.wasm} +0 -0
- package/build/sub/site.1732b58ec0e8@0+0.wasm +0 -0
- package/build/sub/site.ae3913b0b0f4@0+0.wasm +0 -0
- package/build/sub/store.a24d7a25daa6@0+0.wasm +0 -0
- package/build/sub/stream.126e3bd5d626@0+0.wasm +0 -0
- package/build/sub/sub.2e3092140706@0+0.wasm +0 -0
- package/build/sub/substrate.5ee5d0b4d3e7@0+0.wasm +0 -0
- package/build/sub/{syntax.fadc832db29f@0+0.wasm → syntax.32f3e40b61c7@0+0.wasm} +0 -0
- package/build/sub/tar.2a633861e654@0+0.wasm +0 -0
- package/build/sub/test.9bd59c73f65e@0+0.wasm +0 -0
- package/build/sub/{text.8ff142d72fd7@0+0.wasm → text.1bc90482bd43@0+0.wasm} +0 -0
- package/build/sub/{timer.d3454726b3bf@0+0.wasm → timer.f35eb62ae446@0+0.wasm} +0 -0
- package/build/sub/upgrade.39ee449b00d5@0+0.wasm +0 -0
- package/build/sub/{utf8.e82afeb9e953@0+0.wasm → utf8.e7216bd054e1@0+0.wasm} +0 -0
- package/build/sub/worker.762a9d642af0@0+0.wasm +0 -0
- package/build/sub/writer.00b7802cbe39@0+0.wasm +0 -0
- package/package.json +1 -1
- package/std/archive/tar.sub +30 -23
- package/std/browser/chromium.sub +5 -4
- package/std/browser/devtools.sub +24 -19
- package/std/compress/gzip.sub +18 -16
- package/std/compress/inflate.sub +7 -4
- package/std/crypto/password.sub +3 -3
- package/std/doc/doc.sub +2 -2
- package/std/encoding/json.sub +20 -8
- package/std/encoding/wire.sub +9 -7
- package/std/http/form.sub +2 -2
- package/std/http/multipart.sub +8 -10
- package/std/http/route.sub +9 -4
- package/std/http/server.sub +14 -11
- package/std/http/session.sub +2 -2
- package/std/http/static.sub +5 -5
- package/std/meta/derive.sub +0 -2
- package/std/meta/method.sub +41 -0
- package/std/meta/type-info.sub +30 -37
- package/std/package/files.sub +24 -25
- package/std/package/git.sub +26 -33
- package/std/package/hash.sub +8 -8
- package/std/package/manifest.sub +67 -42
- package/std/package/map.sub +1 -1
- package/std/package/pack.sub +13 -13
- package/std/package/read.sub +7 -6
- package/std/package/site.sub +7 -7
- package/std/package/store.sub +16 -12
- package/std/package.sub +6 -6
- package/std/test/browser.sub +9 -8
- package/std/test/build.sub +2 -2
- package/std/test/page.sub +31 -26
- package/std/test/run.sub +8 -7
- package/std/test/test.sub +12 -13
- package/std/vector/vector.sub +75 -0
- package/substrate/VERSION +1 -1
- package/substrate/compiler/checker.sub +40 -212
- package/substrate/compiler/compile.sub +3 -3
- package/substrate/compiler/expander.sub +32 -50
- package/substrate/compiler/main.sub +9 -9
- package/substrate/compiler/reader.sub +4 -4
- package/substrate/compiler/roots.sub +8 -8
- package/substrate/compiler/running.sub +1 -1
- package/substrate/compiler/serialize.sub +56 -49
- package/substrate/compiler/substrate.sub +53 -11
- package/substrate/host/errors.mjs +3 -2
- package/substrate/host/events.sub +3 -16
- package/substrate/host/fs.mjs +5 -4
- package/substrate/host/fs.sub +135 -102
- package/substrate/host/grants.mjs +1 -1
- package/substrate/host/grants.sub +8 -7
- package/substrate/host/modules/fake.mjs +1 -1
- package/substrate/host/modules/websocket.mjs +4 -4
- package/substrate/host/modules/websocket.sub +8 -6
- package/substrate/host/node/env.mjs +12 -6
- package/substrate/host/node/env.sub +21 -16
- package/substrate/host/node/fs.mjs +1 -1
- package/substrate/host/node/net.mjs +2 -2
- package/substrate/host/node/net.sub +13 -6
- package/substrate/host/node/process.mjs +4 -4
- package/substrate/host/node/process.sub +25 -24
- package/substrate/host/node/signal.mjs +3 -2
- package/substrate/host/node/signal.sub +9 -6
- package/substrate/host/node/watch.mjs +1 -1
- package/substrate/host/node/watch.sub +11 -9
- package/substrate/host/stream.sub +2 -0
- package/substrate/host/subhost-core.mjs +9 -1
- package/substrate/host/web/clipboard.mjs +2 -2
- package/substrate/host/web/clipboard.sub +10 -3
- package/substrate/host/web/files.mjs +2 -2
- package/substrate/host/web/files.sub +6 -2
- package/substrate/host/web/fs.mjs +3 -3
- package/substrate/host/web/location.mjs +3 -1
- package/substrate/host/web/location.sub +8 -4
- package/substrate/host/worker-side.mjs +3 -1
- package/substrate/host/worker.mjs +6 -5
- package/substrate/host/worker.sub +10 -10
- package/build/compiler/checker.2b0ea87ed311@0+0.wasm +0 -0
- package/build/compiler/expander.80707e1666d6@0+0.wasm +0 -0
- package/build/compiler/fs.5017b627cbd2@0+0.wasm +0 -0
- package/build/compiler/reader.d256e69e09e2@0+0.wasm +0 -0
- package/build/compiler/roots.e366210c01d6@0+0.wasm +0 -0
- package/build/compiler/serialize.a12536bbbe9a@0+0.wasm +0 -0
- package/build/compiler/substrate.728c690187f2@0+0.wasm +0 -0
- package/build/sub/build.115aeefc15e8@0+0.wasm +0 -0
- package/build/sub/chromium.fc0bfea0fbe6@0+0.wasm +0 -0
- package/build/sub/common.997c21b0b8cf@0+0.wasm +0 -0
- package/build/sub/deflate.3138a38325a1@0+0.wasm +0 -0
- package/build/sub/doc.e3f9a998cd91@0+0.wasm +0 -0
- package/build/sub/env.861d55fff974@0+0.wasm +0 -0
- package/build/sub/events.2c981f6f1ec7@0+0.wasm +0 -0
- package/build/sub/fetch.b0ce8f8b3da8@0+0.wasm +0 -0
- package/build/sub/fetch.d62aa5fc9623@0+0.wasm +0 -0
- package/build/sub/files.1706cc0941c0@0+0.wasm +0 -0
- package/build/sub/fs.5017b627cbd2@0+0.wasm +0 -0
- package/build/sub/git.1c5791236e35@0+0.wasm +0 -0
- package/build/sub/grants.cd99dff2854e@0+0.wasm +0 -0
- package/build/sub/gzip.9ebea150f218@0+0.wasm +0 -0
- package/build/sub/hash.ba8330dad9ff@0+0.wasm +0 -0
- package/build/sub/json.af2e0ae20084@0+0.wasm +0 -0
- package/build/sub/manifest.6e014ac19e5d@0+0.wasm +0 -0
- package/build/sub/pack.4295e4f5bdbd@0+0.wasm +0 -0
- package/build/sub/path.de22f6659534@0+0.wasm +0 -0
- package/build/sub/process.ca10ac0b8a62@0+0.wasm +0 -0
- package/build/sub/read.279fafcda508@0+0.wasm +0 -0
- package/build/sub/site.76aa8286c257@0+0.wasm +0 -0
- package/build/sub/site.e6e415bc3170@0+0.wasm +0 -0
- package/build/sub/store.c48db3345968@0+0.wasm +0 -0
- package/build/sub/stream.27fd2fe858e1@0+0.wasm +0 -0
- package/build/sub/sub.c0fb7310de12@0+0.wasm +0 -0
- package/build/sub/substrate.728c690187f2@0+0.wasm +0 -0
- package/build/sub/tar.692c0e8827cd@0+0.wasm +0 -0
- package/build/sub/test.1fd2ff8123bf@0+0.wasm +0 -0
- package/build/sub/upgrade.2a9219e6a45d@0+0.wasm +0 -0
- package/build/sub/worker.ea1e11f8f5e2@0+0.wasm +0 -0
- package/build/sub/writer.550227768eb9@0+0.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# substrate-lang
|
|
2
2
|
|
|
3
3
|
Substrate is a Lisp for writing WebAssembly. It has C-like semantics
|
|
4
|
-
(modernized with
|
|
4
|
+
(modernized with variants and bounds-checked slices), combined with
|
|
5
5
|
Racket-style hygienic macros and module hooks for defining new languages and
|
|
6
6
|
DSLs. Its compiler is small (~11k LOC, <600 KiB of Wasm), very fast,
|
|
7
7
|
self-hosted, and runs in the browser.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/compiler/program
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
substrate.
|
|
2
|
-
writer.
|
|
3
|
-
syntax.
|
|
4
|
-
path.
|
|
5
|
-
fs.
|
|
6
|
-
reader.
|
|
7
|
-
roots.
|
|
8
|
-
running.
|
|
9
|
-
core.
|
|
10
|
-
ops.
|
|
11
|
-
checker.
|
|
12
|
-
leb128.
|
|
13
|
-
binary.
|
|
14
|
-
serialize.
|
|
15
|
-
compile.
|
|
16
|
-
sha256.
|
|
17
|
-
link.
|
|
18
|
-
macros.
|
|
19
|
-
expander.
|
|
20
|
-
prune.
|
|
21
|
-
main.
|
|
1
|
+
substrate.5ee5d0b4d3e7@0+0
|
|
2
|
+
writer.00b7802cbe39@0+0
|
|
3
|
+
syntax.32f3e40b61c7@0+0
|
|
4
|
+
path.5a6286472cd4@0+0
|
|
5
|
+
fs.01b8aab4a9a8@0+0
|
|
6
|
+
reader.694b03770bf0@0+0
|
|
7
|
+
roots.cefd10e93684@0+0
|
|
8
|
+
running.0d25dbaec018@0+0
|
|
9
|
+
core.f2defb75e00b@0+0
|
|
10
|
+
ops.515b5e05f646@0+0
|
|
11
|
+
checker.4dd4556dd421@0+0
|
|
12
|
+
leb128.15d814b7b4f2@0+0
|
|
13
|
+
binary.2d43b43d1600@0+0
|
|
14
|
+
serialize.b0d82f3d63d2@0+0
|
|
15
|
+
compile.5d8f6407af2a@0+0
|
|
16
|
+
sha256.a6c32b04d799@0+0
|
|
17
|
+
link.b826ea7c8f17@0+0
|
|
18
|
+
macros.b269e0c42784@0+0
|
|
19
|
+
expander.967ce443d379@0+0
|
|
20
|
+
prune.406215c3e4f8@0+0
|
|
21
|
+
main.4fc52f204d54@0+0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/sub/program
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
substrate.
|
|
2
|
-
process.
|
|
3
|
-
path.
|
|
4
|
-
path.
|
|
5
|
-
fs.
|
|
6
|
-
common.
|
|
7
|
-
grants.
|
|
8
|
-
writer.
|
|
9
|
-
syntax.
|
|
10
|
-
reader.
|
|
11
|
-
roots.
|
|
12
|
-
read.
|
|
13
|
-
manifest.
|
|
14
|
-
git.
|
|
15
|
-
files.
|
|
16
|
-
sha256.
|
|
17
|
-
hash.
|
|
18
|
-
store.
|
|
19
|
-
map.
|
|
20
|
-
env.
|
|
21
|
-
events.
|
|
22
|
-
build.
|
|
23
|
-
pack.
|
|
24
|
-
site.
|
|
25
|
-
site.
|
|
26
|
-
fetch.
|
|
27
|
-
stream.
|
|
28
|
-
worker.
|
|
29
|
-
deflate.
|
|
30
|
-
inflate.
|
|
31
|
-
gzip.
|
|
32
|
-
tar.
|
|
33
|
-
fetch.
|
|
34
|
-
doc.
|
|
35
|
-
html.
|
|
36
|
-
html.
|
|
37
|
-
text.
|
|
38
|
-
root.
|
|
39
|
-
doc.
|
|
40
|
-
timer.
|
|
41
|
-
chromium.
|
|
42
|
-
test.
|
|
43
|
-
utf8.
|
|
44
|
-
json.
|
|
45
|
-
sha512.
|
|
46
|
-
base64.
|
|
47
|
-
upgrade.
|
|
48
|
-
sub.
|
|
1
|
+
substrate.5ee5d0b4d3e7@0+0
|
|
2
|
+
process.7106571fa723@0+0
|
|
3
|
+
path.5a6286472cd4@0+0
|
|
4
|
+
path.6891ffea73ca@0+0
|
|
5
|
+
fs.01b8aab4a9a8@0+0
|
|
6
|
+
common.1edc613607a0@0+0
|
|
7
|
+
grants.c54776c0d7e3@0+0
|
|
8
|
+
writer.00b7802cbe39@0+0
|
|
9
|
+
syntax.32f3e40b61c7@0+0
|
|
10
|
+
reader.694b03770bf0@0+0
|
|
11
|
+
roots.cefd10e93684@0+0
|
|
12
|
+
read.0b93933d62a2@0+0
|
|
13
|
+
manifest.ef317480deb0@0+0
|
|
14
|
+
git.dc4c0e757ebe@0+0
|
|
15
|
+
files.ad0469fdf6fa@0+0
|
|
16
|
+
sha256.a6c32b04d799@0+0
|
|
17
|
+
hash.660682e4f491@0+0
|
|
18
|
+
store.a24d7a25daa6@0+0
|
|
19
|
+
map.f455cca6a42a@0+0
|
|
20
|
+
env.e5451da6e747@0+0
|
|
21
|
+
events.bf5473ebf220@0+0
|
|
22
|
+
build.459c5b9412bd@0+0
|
|
23
|
+
pack.e02836264f6a@0+0
|
|
24
|
+
site.ae3913b0b0f4@0+0
|
|
25
|
+
site.1732b58ec0e8@0+0
|
|
26
|
+
fetch.7790d4943758@0+0
|
|
27
|
+
stream.126e3bd5d626@0+0
|
|
28
|
+
worker.762a9d642af0@0+0
|
|
29
|
+
deflate.23f7c4679260@0+0
|
|
30
|
+
inflate.59bb61f14001@0+0
|
|
31
|
+
gzip.16e372eda1cf@0+0
|
|
32
|
+
tar.2a633861e654@0+0
|
|
33
|
+
fetch.96b2d10f025e@0+0
|
|
34
|
+
doc.ef9965d5d402@0+0
|
|
35
|
+
html.e9ed37f34977@0+0
|
|
36
|
+
html.a23126eb949a@0+0
|
|
37
|
+
text.1bc90482bd43@0+0
|
|
38
|
+
root.f10a4906f460@0+0
|
|
39
|
+
doc.0775df5de6fe@0+0
|
|
40
|
+
timer.f35eb62ae446@0+0
|
|
41
|
+
chromium.3d5818f2707d@0+0
|
|
42
|
+
test.9bd59c73f65e@0+0
|
|
43
|
+
utf8.e7216bd054e1@0+0
|
|
44
|
+
json.55590d2f518a@0+0
|
|
45
|
+
sha512.c24a792d7891@0+0
|
|
46
|
+
base64.a26bdcf60a2d@0+0
|
|
47
|
+
upgrade.39ee449b00d5@0+0
|
|
48
|
+
sub.2e3092140706@0+0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/std/archive/tar.sub
CHANGED
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
(set! (-> r at) 0))
|
|
15
15
|
|
|
16
16
|
;; An entry's path is in a or the data, and a file's bytes are in the data.
|
|
17
|
-
(define (tar-next! [a (ptr arena)] [r (ptr tar-reader)] [e (ptr tar-entry)] [err (ptr buffer)])
|
|
17
|
+
(define (tar-next! [a (ptr arena)] [r (ptr tar-reader)] [e (ptr tar-entry)] [found (ptr bool)] [err (ptr buffer)])
|
|
18
|
+
-> bool
|
|
18
19
|
(let ([long string] [sized #f] [given-size u64 0])
|
|
20
|
+
(set! (@ found) #f)
|
|
19
21
|
(while #t
|
|
20
22
|
(let* ([data (-> r data)] [at (-> r at)] [left (- (-> data length) at)] [h (slice u8)] [size u64 0] [type u8 0]
|
|
21
23
|
[body (slice u8)] [next u64 0])
|
|
22
|
-
(when (== left 0) (return
|
|
24
|
+
(when (== left 0) (return #t))
|
|
23
25
|
(when (< left 512) (return (bad! err "the archive is cut short")))
|
|
24
26
|
(set! h (slice data at (+ at 512)))
|
|
25
|
-
(when (zeros? h) (return
|
|
27
|
+
(when (zeros? h) (return #t))
|
|
26
28
|
(unless (summed? h) (return (bad! err "a header's checksum is wrong")))
|
|
27
29
|
(unless (octal h 124 12 (& size)) (return (bad! err "a header's size is not a number")))
|
|
28
30
|
(when sized (set! size given-size))
|
|
@@ -41,38 +43,43 @@
|
|
|
41
43
|
[else tar-other]))
|
|
42
44
|
(set! (-> e path) (if (> (-> long length) 0) long (header-path a h)))
|
|
43
45
|
(set! (-> e bytes) (if (== (-> e kind) tar-file) body (slice body 0 0)))
|
|
44
|
-
(
|
|
46
|
+
(set! (@ found) #t)
|
|
47
|
+
(return #t)])))))
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
(let ([r tar-reader] [e tar-entry] [got i32 1] [top ""] [one #t] [why string])
|
|
49
|
+
(define (tar-unpack! [a (ptr arena)] [data (slice u8)] [dir string] [err (ptr buffer)]) -> bool
|
|
50
|
+
(let ([r tar-reader] [e tar-entry] [found #t] [top ""] [one #t] [why error] [reason (make-buffer)])
|
|
49
51
|
(tar-reader-init! (& r) data)
|
|
50
|
-
(while
|
|
51
|
-
(
|
|
52
|
-
|
|
52
|
+
(while found
|
|
53
|
+
(unless (tar-next! a (& r) (& e) (& found) (& reason))
|
|
54
|
+
(buffer-add-string! err "not a tar archive: ")
|
|
55
|
+
(buffer-add! err (buffer-bytes (& reason)))
|
|
56
|
+
(buffer-free! (& reason))
|
|
57
|
+
(return #f))
|
|
58
|
+
(when (and found (!= (-> e kind) tar-other))
|
|
53
59
|
(let ([p (cleaned (-> e path))])
|
|
54
60
|
(when (> (-> p length) 0)
|
|
55
61
|
(when (== (-> top length) 0) (set! top (first-part p)))
|
|
56
62
|
(unless (or (and (== p top) (== (-> e kind) tar-directory)) (inside-top? p top)) (set! one #f))))))
|
|
57
|
-
(
|
|
63
|
+
(buffer-free! (& reason))
|
|
58
64
|
(tar-reader-init! (& r) data)
|
|
59
|
-
(set!
|
|
60
|
-
(while
|
|
61
|
-
(
|
|
62
|
-
(when (and
|
|
65
|
+
(set! found #t)
|
|
66
|
+
(while found
|
|
67
|
+
(tar-next! a (& r) (& e) (& found) err)
|
|
68
|
+
(when (and found (!= (-> e kind) tar-other))
|
|
63
69
|
(let ([p (cleaned (-> e path))])
|
|
64
70
|
(when (and one (> (-> top length) 0)) (set! p (if (== p top) "" (slice p (+ (-> top length) 1)))))
|
|
65
71
|
(when (> (-> p length) 0)
|
|
66
72
|
(let ([full (under a dir p)])
|
|
67
|
-
(when (or (and (== (-> e kind) tar-directory) (
|
|
73
|
+
(when (or (and (== (-> e kind) tar-directory) (not (fs-make-dir full (& why))))
|
|
68
74
|
(and (== (-> e kind) tar-file)
|
|
69
|
-
(
|
|
70
|
-
|
|
75
|
+
(not (and (fs-make-dir (up-to-last-slash full) (& why))
|
|
76
|
+
(fs-write-file full (-> e bytes) (& why))))))
|
|
71
77
|
(buffer-add-string! err p)
|
|
72
78
|
(buffer-add-string! err ": ")
|
|
73
|
-
(buffer-add-string! err why)
|
|
74
|
-
(
|
|
75
|
-
|
|
79
|
+
(buffer-add-string! err (error-text (& why)))
|
|
80
|
+
(error-free! (& why))
|
|
81
|
+
(return #f)))))))
|
|
82
|
+
#t))
|
|
76
83
|
|
|
77
84
|
(define (cleaned [p string]) -> string
|
|
78
85
|
(let ([s p])
|
|
@@ -100,9 +107,9 @@
|
|
|
100
107
|
(while (and (> i 0) (!= (@ p (- i 1)) #\/)) (-= i 1))
|
|
101
108
|
(if (<= i 1) "/" (slice p 0 (- i 1)))))
|
|
102
109
|
|
|
103
|
-
(define (bad! [err (ptr buffer)] [why string]) ->
|
|
110
|
+
(define (bad! [err (ptr buffer)] [why string]) -> bool
|
|
104
111
|
(buffer-add-string! err why)
|
|
105
|
-
|
|
112
|
+
#f)
|
|
106
113
|
|
|
107
114
|
(define (zeros? [h (slice u8)]) -> bool
|
|
108
115
|
(for ([i u32 0]) (< i (-> h length)) (+= i 1) (when (!= (@ h i) 0) (return #f)))
|
package/std/browser/chromium.sub
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
[stopped (fn ((ptr chromium)))])
|
|
17
17
|
|
|
18
18
|
(define (chromium-start [c (ptr chromium)] [file string] [profile string] [args (slice string)] [ms f64]
|
|
19
|
-
[started (fn ((ptr chromium)))] [err (ptr
|
|
19
|
+
[started (fn ((ptr chromium)))] [err (ptr error)]) -> bool
|
|
20
20
|
(let ([argv (make-buffer)] [o process-options] [profile-flag (make-buffer)]
|
|
21
21
|
[fixed (slice (array-of string "--headless=new" "--remote-debugging-port=0" "--no-first-run"
|
|
22
22
|
"--no-default-browser-check" "--no-sandbox" "--mute-audio"
|
|
@@ -41,9 +41,10 @@
|
|
|
41
41
|
(process-options-init! (& o))
|
|
42
42
|
(set! (-> o stdin) process-ignore)
|
|
43
43
|
(set! (-> o stdout) process-ignore)
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
(let ([spawned (process-spawn file (strings-in (& argv)) (& o) (cast (ptr void) (& (-> c head))) (& (-> c id))
|
|
45
|
+
err)])
|
|
46
|
+
(buffer-free! (& argv))
|
|
47
|
+
(unless spawned (return #f)))
|
|
47
48
|
(set! (-> c running) #t)
|
|
48
49
|
(stream-tag! (process-stderr (-> c id)) (cast (ptr void) (& (-> c head))))
|
|
49
50
|
(stream-read! (process-stderr (-> c id)) (slice (-> c chunk)))
|
package/std/browser/devtools.sub
CHANGED
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
(define socket-head event-head)
|
|
28
28
|
|
|
29
29
|
(define (relay)
|
|
30
|
-
(let ([why
|
|
30
|
+
(let ([why error] [id u32 0])
|
|
31
31
|
(event-handler! worker-source from-parent)
|
|
32
32
|
(set! (-> socket-head handle) from-socket)
|
|
33
|
-
(
|
|
34
|
-
|
|
33
|
+
(unless (websocket-connect (@ (host-args) 0) 0 (cast (ptr void) (& socket-head)) (& id) (& why))
|
|
34
|
+
(host-exit 1 (error-text (& why))))
|
|
35
|
+
(set! socket id)))
|
|
35
36
|
|
|
36
37
|
(define (from-parent [source u32] [kind u32] [id u32] [tag (ptr void)] [value i32])
|
|
37
38
|
(when (and (== kind worker-message) (== id 0))
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
;; ---- the connection ----
|
|
56
57
|
|
|
57
58
|
(define (devtools-connect [d (ptr devtools)] [address string] [handler (fn ((ptr devtools) string (ptr json-value) string))]
|
|
58
|
-
[state (ptr void)] [err (ptr
|
|
59
|
+
[state (ptr void)] [err (ptr error)]) -> bool
|
|
59
60
|
(let ([text string] [deadline (+ (clock-monotonic) patience)])
|
|
60
61
|
(set! (-> d head handle) relay-heard)
|
|
61
62
|
(set! (-> d next) 0)
|
|
@@ -65,11 +66,13 @@
|
|
|
65
66
|
(set! (-> d awaited) (make-buffer))
|
|
66
67
|
(set! (-> d kept) (make-buffer))
|
|
67
68
|
(set! (-> d why) "")
|
|
68
|
-
(
|
|
69
|
-
|
|
69
|
+
(unless (worker-start relay (cast (slice u8) address) 0 (cast (ptr void) (& (-> d head))) (& (-> d relay)) err)
|
|
70
|
+
(return #f))
|
|
70
71
|
(while #t
|
|
71
72
|
(unless (next! d deadline (& text))
|
|
72
|
-
(
|
|
73
|
+
(if (> (-> d why length) 0)
|
|
74
|
+
(error-fail! err error-other (-> d why))
|
|
75
|
+
(error-fail! err error-timeout "Chromium did not take a DevTools connection within 30 s"))
|
|
73
76
|
(devtools-close d)
|
|
74
77
|
(return #f))
|
|
75
78
|
(let ([open (== text "open")])
|
|
@@ -137,49 +140,51 @@
|
|
|
137
140
|
(-> d next)))
|
|
138
141
|
|
|
139
142
|
(define (devtools-call [d (ptr devtools)] [a (ptr arena)] [method string] [parameters string] [session string]
|
|
140
|
-
[result (ptr (ptr json-value))] [err (ptr
|
|
143
|
+
[result (ptr (ptr json-value))] [err (ptr error)]) -> bool
|
|
141
144
|
(let ([id (devtools-send d method parameters session)] [deadline (+ (clock-monotonic) patience)] [text string]
|
|
142
145
|
[ok #f] [done #f])
|
|
143
146
|
(buffer-add-u32! (& (-> d awaited)) id)
|
|
144
147
|
(while (not done)
|
|
145
148
|
(cond [(or (taken! d id (& text)) (next! d deadline (& text)))
|
|
146
|
-
(let ([e (make-arena)] [
|
|
147
|
-
(
|
|
149
|
+
(let ([e (make-arena)] [m (ptr json-value) 0] [rid i64 0])
|
|
150
|
+
(json-parse (& e) text (& m) 0)
|
|
148
151
|
(free (-> text bytes))
|
|
149
152
|
(cond [(== m 0) (begin)]
|
|
150
153
|
[(json-as-i64 (json-get m "id") (& rid))
|
|
151
154
|
(cond [(== (cast u32 rid) id)
|
|
152
155
|
(set! done #t)
|
|
153
|
-
(let ([
|
|
154
|
-
(if (==
|
|
156
|
+
(let ([refusal (json-get m "error")] [r (json-get m "result")] [why string])
|
|
157
|
+
(if (== refusal 0)
|
|
155
158
|
(begin
|
|
156
159
|
(set! (@ result) (if (== r 0) 0 (json-copy a r)))
|
|
157
160
|
(set! ok #t))
|
|
158
|
-
(let ([b (make-buffer)] [message (json-get
|
|
161
|
+
(let ([b (make-buffer)] [message (json-get refusal "message")])
|
|
159
162
|
(json-as-string message (& why))
|
|
160
163
|
(buffer-add-string! (& b) method)
|
|
161
164
|
(buffer-add-string! (& b) ": ")
|
|
162
165
|
(buffer-add-string! (& b) why)
|
|
163
|
-
(
|
|
166
|
+
(error-fail! err error-other (buffer-string (& b)))
|
|
167
|
+
(buffer-free! (& b)))))]
|
|
164
168
|
[(awaited? d (cast u32 rid)) (kept! d (cast u32 rid) m)]
|
|
165
169
|
[else (begin)])]
|
|
166
170
|
[else (heard! d m)])
|
|
167
171
|
(arena-free (& e)))]
|
|
168
172
|
[else
|
|
169
173
|
(set! done #t)
|
|
170
|
-
(let ([b (make-buffer)])
|
|
174
|
+
(let ([b (make-buffer)] [late (== (-> d why length) 0)])
|
|
171
175
|
(buffer-add-string! (& b) method)
|
|
172
176
|
(buffer-add-string! (& b) ": ")
|
|
173
|
-
(buffer-add-string! (& b) (if
|
|
174
|
-
(
|
|
177
|
+
(buffer-add-string! (& b) (if late "Chromium did not answer within 30 s" (-> d why)))
|
|
178
|
+
(error-fail! err (if late error-timeout error-other) (buffer-string (& b)))
|
|
179
|
+
(buffer-free! (& b)))]))
|
|
175
180
|
(-= (-> d awaited length) 4)
|
|
176
181
|
ok))
|
|
177
182
|
|
|
178
183
|
(define (devtools-pump [d (ptr devtools)] [ms f64])
|
|
179
184
|
(let ([deadline (+ (clock-monotonic) ms)] [text string])
|
|
180
185
|
(while (next! d deadline (& text))
|
|
181
|
-
(let ([e (make-arena)] [
|
|
182
|
-
(
|
|
186
|
+
(let ([e (make-arena)] [m (ptr json-value) 0] [rid i64 0])
|
|
187
|
+
(json-parse (& e) text (& m) 0)
|
|
183
188
|
(free (-> text bytes))
|
|
184
189
|
(cond [(== m 0) (begin)]
|
|
185
190
|
[(json-as-i64 (json-get m "id") (& rid)) (when (awaited? d (cast u32 rid)) (kept! d (cast u32 rid) m))]
|
package/std/compress/gzip.sub
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
;; The gzip format (RFC 1952) around DEFLATE data, and its CRC-32. gunzip! decodes whole gzip data, each member in
|
|
2
|
-
;; turn, adding at most most bytes to out
|
|
2
|
+
;; turn, adding at most most bytes to out.
|
|
3
3
|
(require-unqualified "inflate.sub")
|
|
4
4
|
(require-unqualified "deflate.sub")
|
|
5
5
|
|
|
6
|
-
(provide crc32 gunzip! gzip-
|
|
6
|
+
(provide crc32 gunzip! gzip-start! gzip-end! gzip!)
|
|
7
7
|
|
|
8
8
|
;; CRC-32 with eight tables, slicing eight bytes at a time.
|
|
9
9
|
(define tables (array u32 2048))
|
|
@@ -82,7 +82,9 @@
|
|
|
82
82
|
[(-105) "incorrect data check"]
|
|
83
83
|
[(-106) "incorrect length check"]
|
|
84
84
|
[(-107) "unexpected end of data"]
|
|
85
|
-
[else
|
|
85
|
+
[else "no error"]))
|
|
86
|
+
|
|
87
|
+
(define (refused [err (ptr error)] [code i32]) -> bool (error-fail! err error-invalid (gzip-message code)))
|
|
86
88
|
|
|
87
89
|
(define (le32 [p (ptr u8)]) -> u32
|
|
88
90
|
(bit-or (cast u32 (@ p 0)) (<< (cast u32 (@ p 1)) 8) (<< (cast u32 (@ p 2)) 16) (<< (cast u32 (@ p 3)) 24)))
|
|
@@ -114,19 +116,19 @@
|
|
|
114
116
|
(+= i 2))
|
|
115
117
|
(cast i32 i)))
|
|
116
118
|
|
|
117
|
-
(define (gunzip! [out (ptr buffer)] [in (slice u8)] [most u32]) ->
|
|
119
|
+
(define (gunzip! [out (ptr buffer)] [in (slice u8)] [most u32] [err (ptr error)]) -> bool
|
|
118
120
|
(let ([at u32 0] [start (-> out length)])
|
|
119
121
|
(while #t
|
|
120
122
|
(let* ([rest (slice in at)] [h (header-length rest)] [used u32 0] [begun (-> out length)])
|
|
121
|
-
(when (< h 0) (return h))
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
(when (< h 0) (return (refused err h)))
|
|
124
|
+
(unless (inflate! out (slice rest (cast u32 h)) (- most (- begun start)) (& used) err) (return #f))
|
|
125
|
+
(let ([trailer (+ (cast u32 h) used)])
|
|
126
|
+
(when (< (- (-> rest length) trailer) 4) (return (refused err short-header)))
|
|
127
|
+
(unless (== (le32 (+ (-> rest items) trailer)) (crc32 0 (slice (buffer-bytes out) begun)))
|
|
128
|
+
(return (refused err bad-data-check)))
|
|
129
|
+
(when (< (- (-> rest length) trailer) 8) (return (refused err short-header)))
|
|
130
|
+
(unless (== (le32 (+ (-> rest items) trailer 4)) (- (-> out length) begun))
|
|
131
|
+
(return (refused err bad-length-check)))
|
|
132
|
+
(+= at (+ trailer 8))
|
|
133
|
+
(when (== at (-> in length)) (return #t)))))
|
|
134
|
+
#t))
|