wardite 0.5.1 → 0.6.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.
- checksums.yaml +4 -4
- data/Steepfile +1 -0
- data/exe/wardite +11 -5
- data/lib/wardite/instruction.rb +7 -9
- data/lib/wardite/load.rb +14 -9
- data/lib/wardite/revisitor.rb +1 -1
- data/lib/wardite/value.rb +6 -22
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi/consts.rb +129 -0
- data/lib/wardite/wasi.rb +268 -7
- data/lib/wardite/wasm_module.rb +53 -0
- data/lib/wardite.rb +68 -40
- data/misc/proposals/rubykaigi2025.md +46 -0
- data/misc/slides/fib.c +4 -0
- data/misc/slides/fib.html +13 -0
- data/misc/slides/image-1.png +0 -0
- data/misc/slides/image-2.png +0 -0
- data/misc/slides/image.png +0 -0
- data/misc/slides/tokyo12.html +614 -0
- data/misc/slides/tokyo12.md +624 -0
- data/sig/fcntl.rbs +7 -0
- data/sig/generated/wardite/load.rbs +2 -2
- data/sig/generated/wardite/value.rbs +3 -10
- data/sig/generated/wardite/wasi/consts.rbs +137 -0
- data/sig/generated/wardite/wasi.rbs +62 -5
- data/sig/generated/wardite/wasm_module.rbs +42 -0
- data/sig/generated/wardite.rbs +24 -9
- metadata +15 -3
- data/examples/add.wasm +0 -0
@@ -0,0 +1,137 @@
|
|
1
|
+
# Generated from lib/wardite/wasi/consts.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
module Wasi
|
5
|
+
EACCES: ::Integer
|
6
|
+
|
7
|
+
EAGAIN: ::Integer
|
8
|
+
|
9
|
+
EBADF: ::Integer
|
10
|
+
|
11
|
+
EEXIST: ::Integer
|
12
|
+
|
13
|
+
EFAULT: ::Integer
|
14
|
+
|
15
|
+
EINTR: ::Integer
|
16
|
+
|
17
|
+
EINVAL: ::Integer
|
18
|
+
|
19
|
+
EIO: ::Integer
|
20
|
+
|
21
|
+
EISDIR: ::Integer
|
22
|
+
|
23
|
+
ELOOP: ::Integer
|
24
|
+
|
25
|
+
ENAMETOOLONG: ::Integer
|
26
|
+
|
27
|
+
ENOENT: ::Integer
|
28
|
+
|
29
|
+
ENOSYS: ::Integer
|
30
|
+
|
31
|
+
ENOTDIR: ::Integer
|
32
|
+
|
33
|
+
ERANGE: ::Integer
|
34
|
+
|
35
|
+
ENOTEMPTY: ::Integer
|
36
|
+
|
37
|
+
ENOTSOCK: ::Integer
|
38
|
+
|
39
|
+
ENOTSUP: ::Integer
|
40
|
+
|
41
|
+
EPERM: ::Integer
|
42
|
+
|
43
|
+
EROFS: ::Integer
|
44
|
+
|
45
|
+
FILETYPE_UNKNOWN: ::Integer
|
46
|
+
|
47
|
+
FILETYPE_BLOCK_DEVICE: Integer
|
48
|
+
|
49
|
+
FILETYPE_CHARACTER_DEVICE: Integer
|
50
|
+
|
51
|
+
FILETYPE_DIRECTORY: Integer
|
52
|
+
|
53
|
+
FILETYPE_REGULAR_FILE: Integer
|
54
|
+
|
55
|
+
FILETYPE_SOCKET_DGRAM: Integer
|
56
|
+
|
57
|
+
FILETYPE_SOCKET_STREAM: Integer
|
58
|
+
|
59
|
+
FILETYPE_SYMBOLIC_LINK: Integer
|
60
|
+
|
61
|
+
FD_APPEND: Integer
|
62
|
+
|
63
|
+
FD_DSYNC: Integer
|
64
|
+
|
65
|
+
FD_NONBLOCK: Integer
|
66
|
+
|
67
|
+
FD_RSYNC: Integer
|
68
|
+
|
69
|
+
FD_SYNC: Integer
|
70
|
+
|
71
|
+
RIGHT_FD_DATASYNC: untyped
|
72
|
+
|
73
|
+
RIGHT_FD_READ: untyped
|
74
|
+
|
75
|
+
RIGHT_FD_SEEK: untyped
|
76
|
+
|
77
|
+
RIGHT_FDSTAT_SET_FLAGS: untyped
|
78
|
+
|
79
|
+
RIGHT_FD_SYNC: untyped
|
80
|
+
|
81
|
+
RIGHT_FD_TELL: untyped
|
82
|
+
|
83
|
+
RIGHT_FD_WRITE: untyped
|
84
|
+
|
85
|
+
RIGHT_FD_ADVISE: untyped
|
86
|
+
|
87
|
+
RIGHT_FD_ALLOCATE: untyped
|
88
|
+
|
89
|
+
RIGHT_PATH_CREATE_DIRECTORY: untyped
|
90
|
+
|
91
|
+
RIGHT_PATH_CREATE_FILE: untyped
|
92
|
+
|
93
|
+
RIGHT_PATH_LINK_SOURCE: untyped
|
94
|
+
|
95
|
+
RIGHT_PATH_LINK_TARGET: untyped
|
96
|
+
|
97
|
+
RIGHT_PATH_OPEN: untyped
|
98
|
+
|
99
|
+
RIGHT_FD_READDIR: untyped
|
100
|
+
|
101
|
+
RIGHT_PATH_READLINK: untyped
|
102
|
+
|
103
|
+
RIGHT_PATH_RENAME_SOURCE: untyped
|
104
|
+
|
105
|
+
RIGHT_PATH_RENAME_TARGET: untyped
|
106
|
+
|
107
|
+
RIGHT_PATH_FILESTAT_GET: untyped
|
108
|
+
|
109
|
+
RIGHT_PATH_FILESTAT_SET_SIZE: untyped
|
110
|
+
|
111
|
+
RIGHT_PATH_FILESTAT_SET_TIMES: untyped
|
112
|
+
|
113
|
+
RIGHT_FD_FILESTAT_GET: untyped
|
114
|
+
|
115
|
+
RIGHT_FD_FILESTAT_SET_SIZE: untyped
|
116
|
+
|
117
|
+
RIGHT_FD_FILESTAT_SET_TIMES: untyped
|
118
|
+
|
119
|
+
RIGHT_PATH_SYMLINK: untyped
|
120
|
+
|
121
|
+
RIGHT_PATH_REMOVE_DIRECTORY: untyped
|
122
|
+
|
123
|
+
RIGHT_PATH_UNLINK_FILE: untyped
|
124
|
+
|
125
|
+
RIGHT_POLL_FD_READWRITE: untyped
|
126
|
+
|
127
|
+
RIGHT_SOCK_SHUTDOWN: untyped
|
128
|
+
|
129
|
+
RIGHT_FILE_RIGHT_BASE: untyped
|
130
|
+
|
131
|
+
RIGHT_DIR_RIGHT_BASE: untyped
|
132
|
+
|
133
|
+
# @rbs mode_str: String
|
134
|
+
# @rbs return: Integer
|
135
|
+
def self.to_ftype: (String mode_str) -> Integer
|
136
|
+
end
|
137
|
+
end
|
@@ -1,21 +1,78 @@
|
|
1
1
|
# Generated from lib/wardite/wasi.rb with RBS::Inline
|
2
2
|
|
3
|
-
# rbs_inline: enabled
|
4
3
|
module Wardite
|
5
4
|
class WasiSnapshotPreview1
|
6
5
|
include ValueHelper
|
7
6
|
|
8
|
-
|
7
|
+
include WasmModule
|
9
8
|
|
10
|
-
|
9
|
+
attr_accessor fd_table: Array[IO | File]
|
10
|
+
|
11
|
+
attr_accessor argv: Array[String]
|
12
|
+
|
13
|
+
# @rbs argv: Array[String]
|
14
|
+
# @rbs return: void
|
15
|
+
def initialize: (?argv: Array[String]) -> void
|
16
|
+
|
17
|
+
# @rbs store: Store
|
18
|
+
# @rbs args: Array[wasmValue]
|
19
|
+
# @rbs return: Object
|
20
|
+
def args_get: (Store store, Array[wasmValue] args) -> Object
|
21
|
+
|
22
|
+
# @rbs store: Store
|
23
|
+
# @rbs args: Array[wasmValue]
|
24
|
+
# @rbs return: Object
|
25
|
+
def args_sizes_get: (Store store, Array[wasmValue] args) -> Object
|
26
|
+
|
27
|
+
# @rbs store: Store
|
28
|
+
# @rbs args: Array[wasmValue]
|
29
|
+
# @rbs return: Object
|
30
|
+
def environ_sizes_get: (Store store, Array[wasmValue] args) -> Object
|
31
|
+
|
32
|
+
# @rbs store: Store
|
33
|
+
# @rbs args: Array[wasmValue]
|
34
|
+
# @rbs return: Object
|
35
|
+
def environ_get: (Store store, Array[wasmValue] args) -> Object
|
36
|
+
|
37
|
+
# @rbs store: Store
|
38
|
+
# @rbs args: Array[wasmValue]
|
39
|
+
# @rbs return: Object
|
40
|
+
def clock_time_get: (Store store, Array[wasmValue] args) -> Object
|
41
|
+
|
42
|
+
# @rbs store: Store
|
43
|
+
# @rbs args: Array[wasmValue]
|
44
|
+
# @rbs return: Object
|
45
|
+
def fd_prestat_get: (Store store, Array[wasmValue] args) -> Object
|
11
46
|
|
12
47
|
# @rbs store: Store
|
13
48
|
# @rbs args: Array[wasmValue]
|
14
49
|
# @rbs return: Object
|
15
50
|
def fd_write: (Store store, Array[wasmValue] args) -> Object
|
16
51
|
|
17
|
-
# @rbs
|
18
|
-
|
52
|
+
# @rbs store: Store
|
53
|
+
# @rbs args: Array[wasmValue]
|
54
|
+
# @rbs return: Object
|
55
|
+
def fd_read: (Store store, Array[wasmValue] args) -> Object
|
56
|
+
|
57
|
+
# @rbs store: Store
|
58
|
+
# @rbs args: Array[wasmValue]
|
59
|
+
# @rbs return: Object
|
60
|
+
def fd_fdstat_get: (Store store, Array[wasmValue] args) -> Object
|
61
|
+
|
62
|
+
# @rbs store: Store
|
63
|
+
# @rbs args: Array[wasmValue]
|
64
|
+
# @rbs return: Object
|
65
|
+
def fd_filestat_get: (Store store, Array[wasmValue] args) -> Object
|
66
|
+
|
67
|
+
# @rbs store: Store
|
68
|
+
# @rbs args: Array[wasmValue]
|
69
|
+
# @rbs return: Object
|
70
|
+
def proc_exit: (Store store, Array[wasmValue] args) -> Object
|
71
|
+
|
72
|
+
# @rbs store: Store
|
73
|
+
# @rbs args: Array[wasmValue]
|
74
|
+
# @rbs return: Object
|
75
|
+
def random_get: (Store store, Array[wasmValue] args) -> Object
|
19
76
|
|
20
77
|
private
|
21
78
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Generated from lib/wardite/wasm_module.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Wardite
|
4
|
+
interface _WasmCallable
|
5
|
+
def call: (Store, Array[wasmValue]) -> wasmFuncReturn
|
6
|
+
|
7
|
+
def []: (Store, Array[wasmValue]) -> wasmFuncReturn
|
8
|
+
end
|
9
|
+
|
10
|
+
type wasmModuleSrc = Hash[Symbol, _WasmCallable] | WasmModule | HashModule
|
11
|
+
|
12
|
+
type wasmModule = WasmModule | HashModule
|
13
|
+
|
14
|
+
module WasmModule
|
15
|
+
# @rbs fnname: Symbol
|
16
|
+
# @rbs store: Store
|
17
|
+
# @rbs args: Array[wasmValue]
|
18
|
+
# @rbs return: wasmFuncReturn
|
19
|
+
def invoke: (Symbol fnname, Store store, *untyped args) -> wasmFuncReturn
|
20
|
+
|
21
|
+
# @rbs fnname: Symbol
|
22
|
+
# @rbs return: _WasmCallable
|
23
|
+
def callable: (Symbol fnname) -> _WasmCallable
|
24
|
+
end
|
25
|
+
|
26
|
+
class HashModule
|
27
|
+
attr_accessor hash: Hash[Symbol, _WasmCallable]
|
28
|
+
|
29
|
+
# @rbs ha: Hash[Symbol, _WasmCallable]
|
30
|
+
def initialize: (untyped hash) -> untyped
|
31
|
+
|
32
|
+
# @rbs fnname: Symbol
|
33
|
+
# @rbs store: Store
|
34
|
+
# @rbs args: Array[wasmValue]
|
35
|
+
# @rbs return: wasmFuncReturn
|
36
|
+
def invoke: (Symbol fnname, Store store, *untyped args) -> wasmFuncReturn
|
37
|
+
|
38
|
+
# @rbs fnname: Symbol
|
39
|
+
# @rbs return: _WasmCallable
|
40
|
+
def callable: (Symbol fnname) -> _WasmCallable
|
41
|
+
end
|
42
|
+
end
|
data/sig/generated/wardite.rbs
CHANGED
@@ -20,11 +20,13 @@ module Wardite
|
|
20
20
|
|
21
21
|
attr_accessor exports: Exports
|
22
22
|
|
23
|
-
attr_reader import_object: Hash[Symbol,
|
23
|
+
attr_reader import_object: Hash[Symbol, wasmModule]
|
24
24
|
|
25
|
-
|
25
|
+
attr_accessor wasi: WasiSnapshotPreview1?
|
26
|
+
|
27
|
+
# @rbs import_object: Hash[Symbol, wasmModuleSrc]
|
26
28
|
# @rbs &blk: (Instance) -> void
|
27
|
-
def initialize: (Hash[Symbol,
|
29
|
+
def initialize: (Hash[Symbol, wasmModuleSrc] import_object) { (Instance) -> void } -> untyped
|
28
30
|
|
29
31
|
# @rbs return: void
|
30
32
|
def check_data_count: () -> void
|
@@ -199,6 +201,8 @@ module Wardite
|
|
199
201
|
class Store
|
200
202
|
attr_accessor funcs: Array[WasmFunction | ExternalFunction]
|
201
203
|
|
204
|
+
attr_accessor modules: Hash[Symbol, wasmModule]
|
205
|
+
|
202
206
|
attr_accessor memories: Array[Memory]
|
203
207
|
|
204
208
|
attr_accessor globals: Array[Global]
|
@@ -325,7 +329,10 @@ module Wardite
|
|
325
329
|
end
|
326
330
|
|
327
331
|
# TODO: common interface btw. WasmFunction and ExternalFunction?
|
332
|
+
# may be _WasmCallable?
|
328
333
|
class WasmFunction
|
334
|
+
include ValueHelper
|
335
|
+
|
329
336
|
attr_accessor callsig: Array[Symbol]
|
330
337
|
|
331
338
|
attr_accessor retsig: Array[Symbol]
|
@@ -334,6 +341,8 @@ module Wardite
|
|
334
341
|
|
335
342
|
attr_accessor findex: Integer
|
336
343
|
|
344
|
+
attr_accessor default_locals: Array[wasmValue]
|
345
|
+
|
337
346
|
# @rbs callsig: Array[Symbol]
|
338
347
|
# @rbs retsig: Array[Symbol]
|
339
348
|
# @rbs code_body: CodeSection::CodeBody
|
@@ -349,6 +358,9 @@ module Wardite
|
|
349
358
|
# @rbs return: Array[Integer]
|
350
359
|
def locals_count: () -> Array[Integer]
|
351
360
|
|
361
|
+
# @rbs return: Array[wasmValue]
|
362
|
+
def construct_default_locals: () -> Array[wasmValue]
|
363
|
+
|
352
364
|
# @rbs override_type: Type?
|
353
365
|
# @rbs return: WasmFunction
|
354
366
|
def clone: (?override_type: Type?) -> WasmFunction
|
@@ -356,20 +368,23 @@ module Wardite
|
|
356
368
|
|
357
369
|
type wasmFuncReturn = Object | nil
|
358
370
|
|
359
|
-
type wasmCallable = ^(Store, Array[wasmValue]) -> wasmFuncReturn
|
360
|
-
|
361
371
|
class ExternalFunction
|
372
|
+
attr_accessor target_module: wasmModule
|
373
|
+
|
374
|
+
attr_accessor name: Symbol
|
375
|
+
|
362
376
|
attr_accessor callsig: Array[Symbol]
|
363
377
|
|
364
378
|
attr_accessor retsig: Array[Symbol]
|
365
379
|
|
366
|
-
attr_accessor callable: wasmCallable
|
367
|
-
|
368
380
|
# @rbs callsig: Array[Symbol]
|
369
381
|
# @rbs retsig: Array[Symbol]
|
370
|
-
# @rbs callable:
|
382
|
+
# @rbs callable: _WasmCallable
|
371
383
|
# @rbs return: void
|
372
|
-
def initialize: (Array[Symbol] callsig, Array[Symbol] retsig
|
384
|
+
def initialize: (untyped target_module, untyped name, Array[Symbol] callsig, Array[Symbol] retsig) -> void
|
385
|
+
|
386
|
+
# @rbs return: _WasmCallable
|
387
|
+
def callable: () -> _WasmCallable
|
373
388
|
|
374
389
|
# @rbs override_type: Type?
|
375
390
|
# @rbs return: ExternalFunction
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wardite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio Kondo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A pure-ruby webassembly runtime
|
14
14
|
email:
|
@@ -22,7 +22,6 @@ files:
|
|
22
22
|
- Rakefile
|
23
23
|
- Steepfile
|
24
24
|
- examples/.gitignore
|
25
|
-
- examples/add.wasm
|
26
25
|
- examples/add.wat
|
27
26
|
- examples/break.wat
|
28
27
|
- examples/call.wat
|
@@ -58,10 +57,21 @@ files:
|
|
58
57
|
- lib/wardite/value.rb
|
59
58
|
- lib/wardite/version.rb
|
60
59
|
- lib/wardite/wasi.rb
|
60
|
+
- lib/wardite/wasi/consts.rb
|
61
|
+
- lib/wardite/wasm_module.rb
|
62
|
+
- misc/proposals/rubykaigi2025.md
|
63
|
+
- misc/slides/fib.c
|
64
|
+
- misc/slides/fib.html
|
65
|
+
- misc/slides/image-1.png
|
66
|
+
- misc/slides/image-2.png
|
67
|
+
- misc/slides/image.png
|
68
|
+
- misc/slides/tokyo12.html
|
69
|
+
- misc/slides/tokyo12.md
|
61
70
|
- scripts/gen_alu.rb
|
62
71
|
- scripts/gen_conv.rb
|
63
72
|
- scripts/templates/alu_module.rb.tmpl
|
64
73
|
- scripts/templates/conv_module.rb.tmpl
|
74
|
+
- sig/fcntl.rbs
|
65
75
|
- sig/generated/wardite.rbs
|
66
76
|
- sig/generated/wardite/alu_f32.generated.rbs
|
67
77
|
- sig/generated/wardite/alu_f64.generated.rbs
|
@@ -77,6 +87,8 @@ files:
|
|
77
87
|
- sig/generated/wardite/value.rbs
|
78
88
|
- sig/generated/wardite/version.rbs
|
79
89
|
- sig/generated/wardite/wasi.rbs
|
90
|
+
- sig/generated/wardite/wasi/consts.rbs
|
91
|
+
- sig/generated/wardite/wasm_module.rbs
|
80
92
|
- sig/wardite.rbs
|
81
93
|
homepage: https://github.com/udzura/wardite
|
82
94
|
licenses: []
|
data/examples/add.wasm
DELETED
Binary file
|