wardite 0.5.0 → 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.
@@ -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
- attr_accessor fd_table: Array[IO]
7
+ include WasmModule
9
8
 
10
- def initialize: () -> untyped
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 return: Hash[Symbol, wasmCallable]
18
- def to_module: () -> Hash[Symbol, wasmCallable]
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
@@ -20,11 +20,13 @@ module Wardite
20
20
 
21
21
  attr_accessor exports: Exports
22
22
 
23
- attr_reader import_object: Hash[Symbol, Hash[Symbol, wasmCallable]]
23
+ attr_reader import_object: Hash[Symbol, wasmModule]
24
24
 
25
- # @rbs import_object: Hash[Symbol, Hash[Symbol, wasmCallable]]
25
+ attr_accessor wasi: WasiSnapshotPreview1?
26
+
27
+ # @rbs import_object: Hash[Symbol, wasmModuleSrc]
26
28
  # @rbs &blk: (Instance) -> void
27
- def initialize: (Hash[Symbol, Hash[Symbol, wasmCallable]] import_object) { (Instance) -> void } -> untyped
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
@@ -115,22 +117,12 @@ module Wardite
115
117
  # @rbs return: void
116
118
  def eval_insn: (Frame frame, Op insn) -> void
117
119
 
118
- # @rbs ops: Array[Op]
119
- # @rbs pc_start: Integer
120
- # @rbs return: Integer
121
- def fetch_ops_while_else_or_end: (Array[Op] ops, Integer pc_start) -> Integer
122
-
123
120
  # @rbs labels: Array[Label]
124
121
  # @rbs stack: Array[wasmValue]
125
122
  # @rbs level: Integer
126
123
  # @rbs return: Integer
127
124
  def do_branch: (Array[Label] labels, Array[wasmValue] stack, Integer level) -> Integer
128
125
 
129
- # @rbs ops: Array[Op]
130
- # @rbs pc_start: Integer
131
- # @rbs return: Integer
132
- def fetch_ops_while_end: (Array[Op] ops, Integer pc_start) -> Integer
133
-
134
126
  # unwind the stack and put return value if exists
135
127
  # @rbs sp: Integer
136
128
  # @rbs arity: Integer
@@ -209,6 +201,8 @@ module Wardite
209
201
  class Store
210
202
  attr_accessor funcs: Array[WasmFunction | ExternalFunction]
211
203
 
204
+ attr_accessor modules: Hash[Symbol, wasmModule]
205
+
212
206
  attr_accessor memories: Array[Memory]
213
207
 
214
208
  attr_accessor globals: Array[Global]
@@ -335,7 +329,10 @@ module Wardite
335
329
  end
336
330
 
337
331
  # TODO: common interface btw. WasmFunction and ExternalFunction?
332
+ # may be _WasmCallable?
338
333
  class WasmFunction
334
+ include ValueHelper
335
+
339
336
  attr_accessor callsig: Array[Symbol]
340
337
 
341
338
  attr_accessor retsig: Array[Symbol]
@@ -344,6 +341,8 @@ module Wardite
344
341
 
345
342
  attr_accessor findex: Integer
346
343
 
344
+ attr_accessor default_locals: Array[wasmValue]
345
+
347
346
  # @rbs callsig: Array[Symbol]
348
347
  # @rbs retsig: Array[Symbol]
349
348
  # @rbs code_body: CodeSection::CodeBody
@@ -359,6 +358,9 @@ module Wardite
359
358
  # @rbs return: Array[Integer]
360
359
  def locals_count: () -> Array[Integer]
361
360
 
361
+ # @rbs return: Array[wasmValue]
362
+ def construct_default_locals: () -> Array[wasmValue]
363
+
362
364
  # @rbs override_type: Type?
363
365
  # @rbs return: WasmFunction
364
366
  def clone: (?override_type: Type?) -> WasmFunction
@@ -366,20 +368,23 @@ module Wardite
366
368
 
367
369
  type wasmFuncReturn = Object | nil
368
370
 
369
- type wasmCallable = ^(Store, Array[wasmValue]) -> wasmFuncReturn
370
-
371
371
  class ExternalFunction
372
+ attr_accessor target_module: wasmModule
373
+
374
+ attr_accessor name: Symbol
375
+
372
376
  attr_accessor callsig: Array[Symbol]
373
377
 
374
378
  attr_accessor retsig: Array[Symbol]
375
379
 
376
- attr_accessor callable: wasmCallable
377
-
378
380
  # @rbs callsig: Array[Symbol]
379
381
  # @rbs retsig: Array[Symbol]
380
- # @rbs callable: wasmCallable
382
+ # @rbs callable: _WasmCallable
381
383
  # @rbs return: void
382
- def initialize: (Array[Symbol] callsig, Array[Symbol] retsig, wasmCallable callable) -> void
384
+ def initialize: (untyped target_module, untyped name, Array[Symbol] callsig, Array[Symbol] retsig) -> void
385
+
386
+ # @rbs return: _WasmCallable
387
+ def callable: () -> _WasmCallable
383
388
 
384
389
  # @rbs override_type: Type?
385
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.5.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: 2024-11-24 00:00:00.000000000 Z
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
@@ -31,6 +30,7 @@ files:
31
30
  - examples/fib.wat
32
31
  - examples/fib2.wat
33
32
  - examples/global.wat
33
+ - examples/grayscale.rb
34
34
  - examples/helloworld.wat
35
35
  - examples/i32_const.wat
36
36
  - examples/i32_store.wat
@@ -53,13 +53,25 @@ files:
53
53
  - lib/wardite/instruction.rb
54
54
  - lib/wardite/leb128.rb
55
55
  - lib/wardite/load.rb
56
+ - lib/wardite/revisitor.rb
56
57
  - lib/wardite/value.rb
57
58
  - lib/wardite/version.rb
58
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
59
70
  - scripts/gen_alu.rb
60
71
  - scripts/gen_conv.rb
61
72
  - scripts/templates/alu_module.rb.tmpl
62
73
  - scripts/templates/conv_module.rb.tmpl
74
+ - sig/fcntl.rbs
63
75
  - sig/generated/wardite.rbs
64
76
  - sig/generated/wardite/alu_f32.generated.rbs
65
77
  - sig/generated/wardite/alu_f64.generated.rbs
@@ -71,9 +83,12 @@ files:
71
83
  - sig/generated/wardite/instruction.rbs
72
84
  - sig/generated/wardite/leb128.rbs
73
85
  - sig/generated/wardite/load.rbs
86
+ - sig/generated/wardite/revisitor.rbs
74
87
  - sig/generated/wardite/value.rbs
75
88
  - sig/generated/wardite/version.rbs
76
89
  - sig/generated/wardite/wasi.rbs
90
+ - sig/generated/wardite/wasi/consts.rbs
91
+ - sig/generated/wardite/wasm_module.rbs
77
92
  - sig/wardite.rbs
78
93
  homepage: https://github.com/udzura/wardite
79
94
  licenses: []
data/examples/add.wasm DELETED
Binary file