wardite 0.5.1 → 0.6.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.
@@ -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
@@ -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: wasmCallable
382
+ # @rbs callable: _WasmCallable
371
383
  # @rbs return: void
372
- 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
373
388
 
374
389
  # @rbs override_type: Type?
375
390
  # @rbs return: ExternalFunction
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wardite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio Kondo
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-24 00:00:00.000000000 Z
10
+ date: 2025-01-13 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: A pure-ruby webassembly runtime
14
13
  email:
@@ -22,7 +21,6 @@ files:
22
21
  - Rakefile
23
22
  - Steepfile
24
23
  - examples/.gitignore
25
- - examples/add.wasm
26
24
  - examples/add.wat
27
25
  - examples/break.wat
28
26
  - examples/call.wat
@@ -58,10 +56,21 @@ files:
58
56
  - lib/wardite/value.rb
59
57
  - lib/wardite/version.rb
60
58
  - lib/wardite/wasi.rb
59
+ - lib/wardite/wasi/consts.rb
60
+ - lib/wardite/wasm_module.rb
61
+ - misc/bench-value.rb
62
+ - misc/slides/fib.c
63
+ - misc/slides/fib.html
64
+ - misc/slides/image-1.png
65
+ - misc/slides/image-2.png
66
+ - misc/slides/image.png
67
+ - misc/slides/tokyo12.html
68
+ - misc/slides/tokyo12.md
61
69
  - scripts/gen_alu.rb
62
70
  - scripts/gen_conv.rb
63
71
  - scripts/templates/alu_module.rb.tmpl
64
72
  - scripts/templates/conv_module.rb.tmpl
73
+ - sig/fcntl.rbs
65
74
  - sig/generated/wardite.rbs
66
75
  - sig/generated/wardite/alu_f32.generated.rbs
67
76
  - sig/generated/wardite/alu_f64.generated.rbs
@@ -77,13 +86,14 @@ files:
77
86
  - sig/generated/wardite/value.rbs
78
87
  - sig/generated/wardite/version.rbs
79
88
  - sig/generated/wardite/wasi.rbs
89
+ - sig/generated/wardite/wasi/consts.rbs
90
+ - sig/generated/wardite/wasm_module.rbs
80
91
  - sig/wardite.rbs
81
92
  homepage: https://github.com/udzura/wardite
82
93
  licenses: []
83
94
  metadata:
84
95
  homepage_uri: https://github.com/udzura/wardite
85
96
  source_code_uri: https://github.com/udzura/wardite
86
- post_install_message:
87
97
  rdoc_options: []
88
98
  require_paths:
89
99
  - lib
@@ -98,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
108
  - !ruby/object:Gem::Version
99
109
  version: '0'
100
110
  requirements: []
101
- rubygems_version: 3.5.11
102
- signing_key:
111
+ rubygems_version: 3.6.2
103
112
  specification_version: 4
104
113
  summary: A pure-ruby webassembly runtime
105
114
  test_files: []
data/examples/add.wasm DELETED
Binary file