substrate-lang 0.9.4 → 0.10.1
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 +7 -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/std/web/canvas.sub +3 -3
- package/std/web/dom.sub +45 -11
- package/std/web/gpu-commands.sub +439 -0
- package/std/web/gpu.sub +17 -424
- package/std/web/patches.sub +45 -10
- 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/audio.mjs +17 -9
- package/substrate/host/web/audio.sub +9 -3
- package/substrate/host/web/clipboard.mjs +2 -2
- package/substrate/host/web/clipboard.sub +10 -3
- package/substrate/host/web/dom.mjs +165 -64
- package/substrate/host/web/dom.sub +9 -27
- 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/gpu.mjs +63 -25
- package/substrate/host/web/gpu.sub +18 -4
- package/substrate/host/web/location.mjs +18 -2
- package/substrate/host/web/location.sub +19 -7
- 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/std/test/page.sub
CHANGED
|
@@ -62,12 +62,14 @@
|
|
|
62
62
|
|
|
63
63
|
;; ---- opening and closing ----
|
|
64
64
|
|
|
65
|
-
(define (page-open [dir string] [url string] [address string] [server (fn ())] [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
(define (page-open [dir string] [url string] [address string] [server (fn ())] [b (ptr (ptr page))] [err (ptr error)])
|
|
66
|
+
-> bool
|
|
67
|
+
(let ([ok #t])
|
|
68
|
+
(set! (@ b) 0)
|
|
69
|
+
(try (set! (@ b) (opened! dir url address server))
|
|
70
|
+
[catch page-failed (why) (set! ok (error-fail! err error-other why))])
|
|
69
71
|
(arena-free (& work))
|
|
70
|
-
|
|
72
|
+
ok))
|
|
71
73
|
|
|
72
74
|
(define (page-close [b (ptr page)])
|
|
73
75
|
(closed! b)
|
|
@@ -75,8 +77,8 @@
|
|
|
75
77
|
|
|
76
78
|
(define (opened! [dir string] [url string] [address string] [server (fn ())]) -> (ptr page)
|
|
77
79
|
(unless connected
|
|
78
|
-
(let ([why
|
|
79
|
-
(unless (devtools-connect (& connection) address heard 0 (& why)) (throw page-failed why))
|
|
80
|
+
(let ([why error])
|
|
81
|
+
(unless (devtools-connect (& connection) address heard 0 (& why)) (throw page-failed (error-text (& why))))
|
|
80
82
|
(set! connected #t)))
|
|
81
83
|
(let ([b (new 0 page)])
|
|
82
84
|
(+= opened 1)
|
|
@@ -134,7 +136,7 @@
|
|
|
134
136
|
(loaded! b "Page.navigate" (params-text (& p)))))
|
|
135
137
|
|
|
136
138
|
(define (closed! [b (ptr page)])
|
|
137
|
-
(let ([all (opened-pages)] [r (ptr json-value) 0] [
|
|
139
|
+
(let ([all (opened-pages)] [r (ptr json-value) 0] [p (params-of)])
|
|
138
140
|
(for ([i u32 0]) (< i (-> all length)) (+= i 1)
|
|
139
141
|
(when (== (@ all i) (cast u32 b))
|
|
140
142
|
(memcpy (cast (ptr u8) (+ (-> all items) i)) (cast (ptr u8) (+ (-> all items) (+ i 1))) (* (- (-> all length) (+ i 1)) 4))
|
|
@@ -142,7 +144,7 @@
|
|
|
142
144
|
(break)))
|
|
143
145
|
(when (and connected (> (-> b context length) 0))
|
|
144
146
|
(param-string! (& p) "browserContextId" (-> b context))
|
|
145
|
-
(devtools-call (& connection) (& work) "Target.disposeBrowserContext" (params-text (& p)) "" (& r)
|
|
147
|
+
(devtools-call (& connection) (& work) "Target.disposeBrowserContext" (params-text (& p)) "" (& r) 0))
|
|
146
148
|
(when (> (-> b downloads-dir length) 0) (fs-remove (-> b downloads-dir) #t 0))
|
|
147
149
|
(unless (== (-> b server) 0) (worker-stop (-> b server)))
|
|
148
150
|
(when (and connected (== (-> pages length) 0))
|
|
@@ -158,12 +160,13 @@
|
|
|
158
160
|
;; Starts the server on a worker with the site's directory as its argument, and gives the first line it prints, its
|
|
159
161
|
;; address, with index.html after it.
|
|
160
162
|
(define (served-from! [b (ptr page)] [server (fn ())]) -> string
|
|
161
|
-
(let ([o worker-options] [why
|
|
163
|
+
(let ([o worker-options] [why error] [line (make-buffer)] [said (make-buffer)] [until (+ (clock-monotonic) 60000.0)])
|
|
162
164
|
(worker-options-init! (& o))
|
|
163
165
|
(set! (-> o output) #t)
|
|
164
166
|
(set! (-> server-head handle) unheard)
|
|
165
|
-
(
|
|
166
|
-
|
|
167
|
+
(unless (worker-start server (cast (slice u8) (-> b site)) (& o) (cast (ptr void) (& server-head)) (& (-> b server))
|
|
168
|
+
(& why))
|
|
169
|
+
(throw page-failed (error-text (& why))))
|
|
167
170
|
(while #t
|
|
168
171
|
(let ([left (- until (clock-monotonic))] [value i32 0] [bytes (slice u8)] [kind i32 0] [ended string ""])
|
|
169
172
|
(when (<= left 0.0) (throw page-failed "the server did not print its address within 60 s"))
|
|
@@ -365,9 +368,9 @@
|
|
|
365
368
|
|
|
366
369
|
(define (page-choose-files! [b (ptr page)] [paths (slice string)])
|
|
367
370
|
(guarded b
|
|
368
|
-
(let ([out (make-buffer)] [info fs-info] [why
|
|
371
|
+
(let ([out (make-buffer)] [info fs-info] [why error])
|
|
369
372
|
(for ([i u32 0]) (< i (-> paths length)) (+= i 1)
|
|
370
|
-
(
|
|
373
|
+
(unless (fs-stat (@ paths i) (& info) (& why)) (throw page-failed (error-text (& why))))
|
|
371
374
|
(pushed-text! (& out) (native-path (absolute (@ paths i)))))
|
|
372
375
|
(set! (-> b chosen) (strings-in (& out)))
|
|
373
376
|
(set! (-> b choosing) #t))))
|
|
@@ -563,8 +566,8 @@
|
|
|
563
566
|
(try (evaluated b "window.ready = false") [catch page-failed (why) (begin)])
|
|
564
567
|
(set! (-> b thrown) #f)
|
|
565
568
|
(set! (-> b errors length) 0)
|
|
566
|
-
(let ([
|
|
567
|
-
(when (> (->
|
|
569
|
+
(let ([refusal (text-at (page-call b method parameters) "errorText")])
|
|
570
|
+
(when (> (-> refusal length) 0) (throw page-failed (cat "the browser cannot open the page: " refusal))))
|
|
568
571
|
(started! b))
|
|
569
572
|
|
|
570
573
|
;; Asks the agent in the page to carry out the request, and gives its answer.
|
|
@@ -621,10 +624,10 @@
|
|
|
621
624
|
(while #t
|
|
622
625
|
(let ([all (cast (ptr download) (-> b downloads bytes))] [n (/ (-> b downloads length) (sizeof download))])
|
|
623
626
|
(for ([i u32 0]) (< i n) (+= i 1)
|
|
624
|
-
(let ([d (+ all i)] [bytes (slice u8)] [why
|
|
627
|
+
(let ([d (+ all i)] [bytes (slice u8)] [why error])
|
|
625
628
|
(when (and (== (-> d name) name) (== (-> d state) "completed"))
|
|
626
|
-
(
|
|
627
|
-
(throw page-failed why))
|
|
629
|
+
(unless (fs-read-file (joined-path (-> b downloads-dir) (-> d guid)) (& bytes) (& why))
|
|
630
|
+
(throw page-failed (error-text (& why))))
|
|
628
631
|
(return bytes)))))
|
|
629
632
|
(when (>= (clock-monotonic) until) (throw page-failed (cat (cat "no file named " (quoted name)) " was downloaded")))
|
|
630
633
|
(devtools-pump (& connection) 20.0))
|
|
@@ -689,7 +692,7 @@
|
|
|
689
692
|
[(== from origin)
|
|
690
693
|
(let* ([file (if (== path "/") "/index.html" path)] [bytes (slice u8)]
|
|
691
694
|
[full (resolved-path (-> b site) (slice file 1 (-> file length)))])
|
|
692
|
-
(if (and (within? full (-> b site)) (
|
|
695
|
+
(if (and (within? full (-> b site)) (fs-read-file full (& bytes) 0))
|
|
693
696
|
(fulfilled! session request 200 (type-of file) bytes #f)
|
|
694
697
|
(fulfilled! session request 404 "text/plain" (cast (slice u8) "not found") #f)))]
|
|
695
698
|
[(and (> (-> b server-host length) 0) (== (host-of from) (-> b server-host)))
|
|
@@ -722,7 +725,7 @@
|
|
|
722
725
|
|
|
723
726
|
;; A file picker that opened gives the files the test chose, or else is cancelled.
|
|
724
727
|
(define (chose! [b (ptr page)] [node f64])
|
|
725
|
-
(let ([q (params-of)] [a (make-arena)] [r (ptr json-value) 0] [why
|
|
728
|
+
(let ([q (params-of)] [a (make-arena)] [r (ptr json-value) 0] [why error])
|
|
726
729
|
(param-number! (& q) "backendNodeId" node)
|
|
727
730
|
(if (-> b choosing)
|
|
728
731
|
(let ([files (make-buffer)])
|
|
@@ -734,21 +737,23 @@
|
|
|
734
737
|
(buffer-add-byte! (& files) #\])
|
|
735
738
|
(param-raw! (& q) "files" (buffer-string (& files)))
|
|
736
739
|
(unless (devtools-call (& connection) (& a) "DOM.setFileInputFiles" (params-text (& q)) (-> b session) (& r) (& why))
|
|
737
|
-
(pushed-text! (& (-> b lines)) (cat "files: " why))))
|
|
740
|
+
(pushed-text! (& (-> b lines)) (cat "files: " (error-text (& why))))))
|
|
738
741
|
(if (devtools-call (& connection) (& a) "DOM.resolveNode" (params-text (& q)) (-> b session) (& r) (& why))
|
|
739
742
|
(let ([p (params-of)])
|
|
740
743
|
(param-string! (& p) "objectId" (text-at (json-get r "object") "objectId"))
|
|
741
744
|
(param-string! (& p) "functionDeclaration" "function () { this.dispatchEvent(new Event('cancel')); }")
|
|
742
745
|
(unless (devtools-call (& connection) (& a) "Runtime.callFunctionOn" (params-text (& p)) (-> b session) (& r) (& why))
|
|
743
|
-
(pushed-text! (& (-> b lines)) (cat "files: " why))))
|
|
744
|
-
(pushed-text! (& (-> b lines)) (cat "files: " why))))
|
|
746
|
+
(pushed-text! (& (-> b lines)) (cat "files: " (error-text (& why))))))
|
|
747
|
+
(pushed-text! (& (-> b lines)) (cat "files: " (error-text (& why))))))
|
|
748
|
+
(error-free! (& why))
|
|
745
749
|
(arena-free (& a))))
|
|
746
750
|
|
|
747
751
|
;; ---- helpers ----
|
|
748
752
|
|
|
749
753
|
(define (call [method string] [parameters string] [session string]) -> (ptr json-value)
|
|
750
|
-
(let ([r (ptr json-value) 0] [why
|
|
751
|
-
(unless (devtools-call (& connection) (& work) method parameters session (& r) (& why))
|
|
754
|
+
(let ([r (ptr json-value) 0] [why error])
|
|
755
|
+
(unless (devtools-call (& connection) (& work) method parameters session (& r) (& why))
|
|
756
|
+
(throw page-failed (error-text (& why))))
|
|
752
757
|
r))
|
|
753
758
|
|
|
754
759
|
(define (page-call [b (ptr page)] [method string] [parameters string]) -> (ptr json-value)
|
package/std/test/run.sub
CHANGED
|
@@ -21,20 +21,21 @@
|
|
|
21
21
|
;; ---- running ----
|
|
22
22
|
|
|
23
23
|
(define (program-in [dir string] [program string] [env (slice string)] [args (slice string)] [input (slice u8)]) -> ran
|
|
24
|
-
(let ([o process-options] [r ran] [bytes (slice u8)] [why
|
|
24
|
+
(let ([o process-options] [r ran] [bytes (slice u8)] [why error])
|
|
25
25
|
(process-options-init! (& o))
|
|
26
26
|
(set! (-> o dir) dir)
|
|
27
27
|
(set! (-> o env) env)
|
|
28
|
-
(
|
|
29
|
-
|
|
28
|
+
(unless (process-run program args (& o) input 60000 (& bytes) (& (-> r code)) (& why))
|
|
29
|
+
(throw test-failed (joined (joined program ": ") (error-text (& why)))))
|
|
30
30
|
(set! (-> r output) (cast string bytes))
|
|
31
31
|
r))
|
|
32
32
|
|
|
33
33
|
(define (granted [clauses (slice (slice string))]) -> grants
|
|
34
|
-
(let ([g (make-grants)] [why
|
|
34
|
+
(let ([g (make-grants)] [why error])
|
|
35
35
|
(for ([i u32 0]) (< i (-> clauses length)) (+= i 1)
|
|
36
36
|
(let ([c (@ clauses i)])
|
|
37
|
-
(unless (grants-add! (& g) (@ c 0) (slice c 1 (-> c length)) (& why))
|
|
37
|
+
(unless (grants-add! (& g) (@ c 0) (slice c 1 (-> c length)) (& why))
|
|
38
|
+
(throw test-failed (error-text (& why))))))
|
|
38
39
|
g))
|
|
39
40
|
|
|
40
41
|
(define (host-in [dir string] [env (slice string)] [g (ptr grants)] [args (slice string)] [input (slice u8)]) -> ran
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
[compare (compare-output! (-> r output) expected message)]))
|
|
73
74
|
|
|
74
75
|
(define (expected-text [path string]) -> string
|
|
75
|
-
(let ([bytes (slice u8)] [why
|
|
76
|
-
(
|
|
76
|
+
(let ([bytes (slice u8)] [why error])
|
|
77
|
+
(unless (fs-read-file path (& bytes) (& why)) (throw test-failed (joined (joined path ": ") (error-text (& why)))))
|
|
77
78
|
(cast string bytes)))
|
|
78
79
|
|
|
79
80
|
(define (sub-run-in [dir string] [name string] [grants (slice string)]) -> ran
|
package/std/test/test.sub
CHANGED
|
@@ -98,12 +98,12 @@
|
|
|
98
98
|
(when (and (digits-integer (option "-t") 10 #f (& n)) (> n 0)) (set! at-once (cast u32 n)))
|
|
99
99
|
(when (digits-integer (option "--timeout-ms") 10 #f (& n)) (set! time-limit n)))
|
|
100
100
|
(for ([i u32 0]) (< i (-> arguments length)) (+= i 1)
|
|
101
|
-
(let ([a (@ arguments i)]
|
|
101
|
+
(let ([a (@ arguments i)])
|
|
102
102
|
(cond [(== a "-v") (set! verbose #t)]
|
|
103
103
|
[(== a "--ignored") (set! ignored-only #t)]
|
|
104
104
|
[(== a "--nocapture") (set! capturing #f)]
|
|
105
105
|
[(and (== a "--grant") (< (+ i 2) (-> arguments length)))
|
|
106
|
-
(grants-add! (& needs) (@ arguments (+ i 1)) (slice (& (@ arguments (+ i 2))) 1)
|
|
106
|
+
(grants-add! (& needs) (@ arguments (+ i 1)) (slice (& (@ arguments (+ i 2))) 1) 0)
|
|
107
107
|
(+= i 2)]))))
|
|
108
108
|
|
|
109
109
|
(define (valued? [a string]) -> bool (or (== a "--name") (== a "-t") (== a "--timeout-ms")))
|
|
@@ -205,9 +205,9 @@
|
|
|
205
205
|
;; Returns #t if the test is now running in slot s, or #f if it could not start.
|
|
206
206
|
(define (started! [s (ptr slot)] [e (ptr entry)]) -> bool
|
|
207
207
|
(set! (-> s captured length) 0)
|
|
208
|
-
(let ([o worker-options] [why
|
|
209
|
-
(
|
|
210
|
-
(failed! e why "")
|
|
208
|
+
(let ([o worker-options] [why error] [scratch (scratch-of e)])
|
|
209
|
+
(unless (fs-make-dir scratch (& why))
|
|
210
|
+
(failed! e (error-text (& why)) "")
|
|
211
211
|
(return #f))
|
|
212
212
|
(env-set "SUBSTRATE_SCRATCH" scratch 0)
|
|
213
213
|
(worker-options-init! (& o))
|
|
@@ -226,14 +226,13 @@
|
|
|
226
226
|
(pushed! (& items) (toolchain-host)))
|
|
227
227
|
(for ([j u32 1]) (< j (-> c length)) (+= j 1) (pushed! (& items) (scratch-placed (@ c j) scratch))))
|
|
228
228
|
(unless (grants-add! (& (-> o grants)) kind (strings-in (& items)) (& why))
|
|
229
|
-
(failed! e why "")
|
|
229
|
+
(failed! e (error-text (& why)) "")
|
|
230
230
|
(return #f))))
|
|
231
231
|
(set! (-> s entry) e)
|
|
232
232
|
(set! (-> s head handle) heard)
|
|
233
|
-
(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
(failed! e (beyond why) "")
|
|
233
|
+
(unless (worker-start (-> e run) (slice (cast (ptr u8) 0) 0) (& o) (cast (ptr void) (& (-> s head)))
|
|
234
|
+
(& (-> s worker)) (& why))
|
|
235
|
+
(failed! e (beyond (error-text (& why))) "")
|
|
237
236
|
(return #f))
|
|
238
237
|
(when (> time-limit 0)
|
|
239
238
|
(set! (-> s clock handle) out-of-time)
|
|
@@ -426,12 +425,12 @@
|
|
|
426
425
|
(output-differs! got expected message)))
|
|
427
426
|
|
|
428
427
|
(define (compare-output-file! [got string] [module string] [file string] [message string])
|
|
429
|
-
(let ([why
|
|
430
|
-
(
|
|
428
|
+
(let ([why error] [bytes (slice u8)] [path (test-path module file)])
|
|
429
|
+
(unless (fs-read-file path (& bytes) (& why))
|
|
431
430
|
(let ([b (make-buffer)])
|
|
432
431
|
(buffer-add-string! (& b) message)
|
|
433
432
|
(buffer-add-byte! (& b) 10)
|
|
434
|
-
(buffer-add-string! (& b) why)
|
|
433
|
+
(buffer-add-string! (& b) (error-text (& why)))
|
|
435
434
|
(throw test-failed (buffer-string (& b)))))
|
|
436
435
|
(unless (== (trimmed got) (trimmed (cast string bytes))) (output-differs! got (cast string bytes) message))
|
|
437
436
|
(free (-> bytes items))))
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
;; Vectors: growable arrays of one type, on the heap. (define-vector name type) declares the type name, whose zero value
|
|
2
|
+
;; is an empty vector, and its functions name-count, name-items, name-at, name-at-unchecked, name-add!, name-push!,
|
|
3
|
+
;; name-pop!, name-clear!, name-reserve! and name-free!. vector-count, vector-at and the others call the function of
|
|
4
|
+
;; their first argument's type, and vector-each runs its body for each item. Growing may move the items, so a pointer
|
|
5
|
+
;; to an item lasts until the vector next grows.
|
|
6
|
+
(require-unqualified std/meta/method)
|
|
7
|
+
|
|
8
|
+
(provide define-vector vector-count vector-items vector-at vector-at-unchecked vector-add! vector-push! vector-pop!
|
|
9
|
+
vector-clear! vector-reserve! vector-free! vector-each)
|
|
10
|
+
|
|
11
|
+
(begin-for-syntax
|
|
12
|
+
(require-unqualified compiler/macros)
|
|
13
|
+
(require-unqualified std/meta/type-info)
|
|
14
|
+
|
|
15
|
+
(define (define-vector-form [s datum]) -> datum
|
|
16
|
+
(syntax-match s
|
|
17
|
+
[(_ (? identifier? name) t)
|
|
18
|
+
(let ([count (method-name name '-count)] [items (method-name name '-items)] [at (method-name name '-at)]
|
|
19
|
+
[at-unchecked (method-name name '-at-unchecked)] [add (method-name name '-add!)]
|
|
20
|
+
[push (method-name name '-push!)] [pop (method-name name '-pop!)] [clear (method-name name '-clear!)]
|
|
21
|
+
[reserve (method-name name '-reserve!)] [free! (method-name name '-free!)])
|
|
22
|
+
#`(begin
|
|
23
|
+
(struct #,name [items (ptr #,t)] [count u32] [room u32])
|
|
24
|
+
(define (#,count [v (ptr #,name)]) -> u32 (-> v count))
|
|
25
|
+
(define (#,items [v (ptr #,name)]) -> (slice #,t) (slice (-> v items) (-> v count)))
|
|
26
|
+
(define (#,at [v (ptr #,name)] [i u32]) -> (ptr #,t) (& (@ (slice (-> v items) (-> v count)) i)))
|
|
27
|
+
(define (#,at-unchecked [v (ptr #,name)] [i u32]) -> (ptr #,t) (+ (-> v items) i))
|
|
28
|
+
(define (#,reserve [v (ptr #,name)] [n u32])
|
|
29
|
+
(when (> n (-> v room))
|
|
30
|
+
(let ([room u64 (if (== (-> v room) 0) 4 (cast u64 (-> v room)))])
|
|
31
|
+
(while (< room (cast u64 n)) (set! room (* room 2)))
|
|
32
|
+
(let ([bytes (* room (cast u64 (sizeof #,t)))])
|
|
33
|
+
(set! (-> v items)
|
|
34
|
+
(cast (ptr #,t) (realloc (-> v items) (if (< bytes 2147483584) (cast u32 bytes) 2147483584))))
|
|
35
|
+
(set! (-> v room) (cast u32 room))))))
|
|
36
|
+
(define (#,push [v (ptr #,name)] [x #,t])
|
|
37
|
+
(when (== (-> v count) (-> v room)) (#,reserve v (+ (-> v count) 1)))
|
|
38
|
+
(set! (@ (+ (-> v items) (-> v count))) x)
|
|
39
|
+
(+= (-> v count) 1))
|
|
40
|
+
(define (#,add [v (ptr #,name)]) -> (ptr #,t)
|
|
41
|
+
(when (== (-> v count) (-> v room)) (#,reserve v (+ (-> v count) 1)))
|
|
42
|
+
(let ([p (+ (-> v items) (-> v count))])
|
|
43
|
+
(memset p 0 (sizeof #,t))
|
|
44
|
+
(+= (-> v count) 1)
|
|
45
|
+
p))
|
|
46
|
+
(define (#,pop [v (ptr #,name)]) -> #,t
|
|
47
|
+
(when (== (-> v count) 0) (host-trap "vector-pop!: the vector is empty"))
|
|
48
|
+
(-= (-> v count) 1)
|
|
49
|
+
(@ (+ (-> v items) (-> v count))))
|
|
50
|
+
(define (#,clear [v (ptr #,name)]) (set! (-> v count) 0))
|
|
51
|
+
(define (#,free! [v (ptr #,name)])
|
|
52
|
+
(free (-> v items))
|
|
53
|
+
(set! (-> v items) 0)
|
|
54
|
+
(set! (-> v count) 0)
|
|
55
|
+
(set! (-> v room) 0))))]
|
|
56
|
+
[_ (raise-syntax-error 'define-vector "expected (define-vector name type)" s)]))
|
|
57
|
+
|
|
58
|
+
(define (vector-each-form [s datum]) -> datum
|
|
59
|
+
(syntax-match s
|
|
60
|
+
[(_ (((? identifier? x) v)) body0 body ...)
|
|
61
|
+
#`(let ([the-vector #,v])
|
|
62
|
+
(for ([i u32 0]) (< i (vector-count the-vector)) (+= i 1)
|
|
63
|
+
(let ([#,x (vector-at-unchecked the-vector i)]) #,body0 #,@body)))]
|
|
64
|
+
[(_ (((? identifier? x) (? identifier? i) v)) body0 body ...)
|
|
65
|
+
#`(let ([the-vector #,v])
|
|
66
|
+
(for ([#,i u32 0]) (< #,i (vector-count the-vector)) (+= #,i 1)
|
|
67
|
+
(let ([#,x (vector-at-unchecked the-vector #,i)]) #,body0 #,@body)))]
|
|
68
|
+
[_ (raise-syntax-error
|
|
69
|
+
'vector-each "expected (vector-each ([item vector]) body ...) or (vector-each ([item index vector]) body ...)" s)])))
|
|
70
|
+
|
|
71
|
+
(define-syntax define-vector define-vector-form)
|
|
72
|
+
(define-syntax vector-each vector-each-form)
|
|
73
|
+
(define-methods [vector-count -count] [vector-items -items] [vector-at -at] [vector-at-unchecked -at-unchecked]
|
|
74
|
+
[vector-add! -add!] [vector-push! -push!] [vector-pop! -pop!] [vector-clear! -clear!]
|
|
75
|
+
[vector-reserve! -reserve!] [vector-free! -free!])
|
package/std/web/canvas.sub
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
(define begun u32 0)
|
|
16
16
|
|
|
17
17
|
(define (canvas-begin! [node u32])
|
|
18
|
-
(words! (slice (array-of u32
|
|
18
|
+
(words! (slice (array-of u32 11 node 0)))
|
|
19
19
|
(set! drawing (-> (dom-patches) length))
|
|
20
20
|
(set! begun (dom-flushes)))
|
|
21
21
|
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
|
|
91
91
|
(define next-image u32 1)
|
|
92
92
|
|
|
93
|
-
(define (canvas-load-image! [path string]) -> u32
|
|
93
|
+
(define (canvas-load-image! [path string] [tag (ptr void)]) -> u32
|
|
94
94
|
(if (canvas-drawing?)
|
|
95
95
|
0
|
|
96
96
|
(let ([id next-image])
|
|
97
97
|
(+= next-image 1)
|
|
98
|
-
(dom-image! id path)
|
|
98
|
+
(dom-image! id path tag)
|
|
99
99
|
id)))
|
|
100
100
|
|
|
101
101
|
(define (canvas-draw-sprite! [image u32] [cell-width f64] [cell-height f64] [frame u32] [x f64] [y f64] [flip bool])
|
package/std/web/dom.sub
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
;; The page: the host module "dom" and the patches that patches.sub writes. dom-flush! sends the patches
|
|
2
|
-
;;
|
|
1
|
+
;; The page: the host module "dom" and the patches that patches.sub writes. dom-flush! sends the patches. A read takes a
|
|
2
|
+
;; name that walks from a node, or from the current event, through the page's objects: a property's name, or names
|
|
3
|
+
;; joined by dots. It gives a number, with true as 1, or text. The text lasts until the patches are sent. dom-is and
|
|
4
|
+
;; dom-event-is also take a node, and say whether the name leads to it. (dom-is node dom-document "activeElement") says
|
|
5
|
+
;; whether the node has the focus. dom-event-call calls a method of the current event.
|
|
3
6
|
(require-unqualified host-dom host/web/dom)
|
|
4
7
|
(require-unqualified patches "patches.sub")
|
|
5
8
|
|
|
6
|
-
(provide (all-from-out host-dom) (all-from-out patches) dom-flush! dom-event-
|
|
9
|
+
(provide (all-from-out host-dom) (all-from-out patches) dom-flush! dom-element dom-event-number dom-event-text
|
|
10
|
+
dom-event-call dom-event-is dom-read-number dom-read-text dom-is)
|
|
11
|
+
|
|
12
|
+
(import event-number "dom" "event_number" (i32 i32 -> f64))
|
|
13
|
+
(import event-text "dom" "event_text" (i32 i32 i32 -> i32))
|
|
14
|
+
(import event-call "dom" "event_call" (i32 i32 ->))
|
|
15
|
+
(import event-is "dom" "event_is" (i32 i32 i32 -> i32))
|
|
16
|
+
(import read-number "dom" "read_number" (i32 i32 i32 -> f64))
|
|
17
|
+
(import read-text "dom" "read_text" (i32 i32 i32 i32 -> i32))
|
|
18
|
+
(import is "dom" "is" (i32 i32 i32 i32 -> i32))
|
|
19
|
+
|
|
20
|
+
(define (dom-element [id string]) -> u32
|
|
21
|
+
(let ([n (dom-new-node!)])
|
|
22
|
+
(if (== (dom-bind-element (cast i32 (-> id bytes)) (cast i32 (-> id length)) (cast i32 n)) 0) 0 n)))
|
|
7
23
|
|
|
8
24
|
(define (dom-flush!)
|
|
9
25
|
(let* ([b (dom-patches)] [n (-> b length)])
|
|
@@ -12,12 +28,30 @@
|
|
|
12
28
|
(dom-apply (cast i32 (-> b bytes)) n))
|
|
13
29
|
(dom-discard!)))
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
(define (kept-text [p (ptr u8)] [n u32]) -> string
|
|
32
|
+
(let ([copy (cast (ptr u8) (dom-frame-alloc n))])
|
|
33
|
+
(memcpy copy p n)
|
|
34
|
+
(free p)
|
|
35
|
+
(cast string (slice copy n))))
|
|
36
|
+
|
|
37
|
+
(define (dom-event-number [path string]) -> f64 (event-number (cast i32 (-> path bytes)) (cast i32 (-> path length))))
|
|
38
|
+
|
|
39
|
+
(define (dom-event-text [path string]) -> string
|
|
40
|
+
(let* ([n u32 0] [p (event-text (cast i32 (-> path bytes)) (cast i32 (-> path length)) (cast i32 (& n)))])
|
|
41
|
+
(kept-text (cast (ptr u8) p) n)))
|
|
42
|
+
|
|
43
|
+
(define (dom-event-call [method string]) (event-call (cast i32 (-> method bytes)) (cast i32 (-> method length))))
|
|
44
|
+
|
|
45
|
+
(define (dom-read-number [node u32] [path string]) -> f64
|
|
46
|
+
(read-number (cast i32 node) (cast i32 (-> path bytes)) (cast i32 (-> path length))))
|
|
47
|
+
|
|
48
|
+
(define (dom-read-text [node u32] [path string]) -> string
|
|
49
|
+
(let* ([n u32 0]
|
|
50
|
+
[p (read-text (cast i32 node) (cast i32 (-> path bytes)) (cast i32 (-> path length)) (cast i32 (& n)))])
|
|
51
|
+
(kept-text (cast (ptr u8) p) n)))
|
|
52
|
+
|
|
53
|
+
(define (dom-event-is [node u32] [path string]) -> bool
|
|
54
|
+
(!= (event-is (cast i32 node) (cast i32 (-> path bytes)) (cast i32 (-> path length))) 0))
|
|
22
55
|
|
|
23
|
-
(define (dom-
|
|
56
|
+
(define (dom-is [node u32] [from u32] [path string]) -> bool
|
|
57
|
+
(!= (is (cast i32 node) (cast i32 from) (cast i32 (-> path bytes)) (cast i32 (-> path length))) 0))
|