wardite 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/break.wat +13 -0
- data/examples/call_indirect.wat +15 -0
- data/examples/loop.wat +20 -0
- data/examples/start.wat +12 -0
- data/lib/wardite/instruction.rb +11 -5
- data/lib/wardite/load.rb +130 -9
- data/lib/wardite/value.rb +45 -42
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite/wasi.rb +2 -2
- data/lib/wardite.rb +387 -15
- data/sig/generated/wardite/instruction.rbs +6 -3
- data/sig/generated/wardite/load.rbs +44 -6
- data/sig/generated/wardite/value.rbs +82 -80
- data/sig/generated/wardite/wasi.rbs +4 -4
- data/sig/generated/wardite.rbs +97 -17
- data/sig/wardite.rbs +1 -3
- metadata +6 -2
@@ -26,8 +26,17 @@ module Wardite
|
|
26
26
|
def initialize: () -> void
|
27
27
|
end
|
28
28
|
|
29
|
+
class TableSection < Section
|
30
|
+
attr_accessor table_types: Array[Symbol]
|
31
|
+
|
32
|
+
attr_accessor table_limits: Array[[ Integer, Integer? ]]
|
33
|
+
|
34
|
+
# @rbs return: void
|
35
|
+
def initialize: () -> void
|
36
|
+
end
|
37
|
+
|
29
38
|
class MemorySection < Section
|
30
|
-
attr_accessor limits: Array[[ Integer, Integer
|
39
|
+
attr_accessor limits: Array[[ Integer, Integer? ]]
|
31
40
|
|
32
41
|
# @rbs return: void
|
33
42
|
def initialize: () -> void
|
@@ -42,7 +51,7 @@ module Wardite
|
|
42
51
|
# TODO: unused in wasm 1.0 spec?
|
43
52
|
attr_accessor shared: bool
|
44
53
|
|
45
|
-
attr_accessor value:
|
54
|
+
attr_accessor value: wasmValue
|
46
55
|
|
47
56
|
# @rbs &blk: (Global) -> void
|
48
57
|
# @rbs return: void
|
@@ -55,6 +64,24 @@ module Wardite
|
|
55
64
|
def initialize: () -> void
|
56
65
|
end
|
57
66
|
|
67
|
+
class StartSection < Section
|
68
|
+
attr_accessor func_index: Integer
|
69
|
+
|
70
|
+
# @rbs return: void
|
71
|
+
def initialize: () -> void
|
72
|
+
end
|
73
|
+
|
74
|
+
class ElemSection < Section
|
75
|
+
attr_accessor table_indices: Array[Integer]
|
76
|
+
|
77
|
+
attr_accessor table_offsets: Array[Integer]
|
78
|
+
|
79
|
+
attr_accessor element_indices: Array[Array[Integer]]
|
80
|
+
|
81
|
+
# @rbs return: void
|
82
|
+
def initialize: () -> void
|
83
|
+
end
|
84
|
+
|
58
85
|
class CodeSection < Section
|
59
86
|
class CodeBody
|
60
87
|
attr_accessor locals_count: Array[Integer]
|
@@ -134,11 +161,13 @@ module Wardite
|
|
134
161
|
|
135
162
|
extend Wardite::ValueHelper
|
136
163
|
|
164
|
+
self.@buf: File | StringIO
|
165
|
+
|
137
166
|
# @rbs buf: File|StringIO
|
138
|
-
# @rbs import_object: Hash[Symbol, Hash[Symbol,
|
167
|
+
# @rbs import_object: Hash[Symbol, Hash[Symbol, wasmCallable]]
|
139
168
|
# @rbs enable_wasi: boolish
|
140
169
|
# @rbs return: Instance
|
141
|
-
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, Hash[Symbol,
|
170
|
+
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, Hash[Symbol, wasmCallable]], ?enable_wasi: boolish) -> Instance
|
142
171
|
|
143
172
|
# @rbs return: Integer
|
144
173
|
def self.preamble: () -> Integer
|
@@ -155,12 +184,21 @@ module Wardite
|
|
155
184
|
# @rbs return: MemorySection
|
156
185
|
def self.memory_section: () -> MemorySection
|
157
186
|
|
187
|
+
# @rbs return: StartSection
|
188
|
+
def self.start_section: () -> StartSection
|
189
|
+
|
190
|
+
# @rbs return: ElemSection
|
191
|
+
def self.elem_section: () -> ElemSection
|
192
|
+
|
158
193
|
# @rbs return: GlobalSection
|
159
194
|
def self.global_section: () -> GlobalSection
|
160
195
|
|
161
196
|
# @rbs return: FunctionSection
|
162
197
|
def self.function_section: () -> FunctionSection
|
163
198
|
|
199
|
+
# @rbs return: TableSection
|
200
|
+
def self.table_section: () -> TableSection
|
201
|
+
|
164
202
|
# @rbs return: CodeSection
|
165
203
|
def self.code_section: () -> CodeSection
|
166
204
|
|
@@ -180,8 +218,8 @@ module Wardite
|
|
180
218
|
def self.decode_expr: (Array[Op] ops) -> Integer
|
181
219
|
|
182
220
|
# @rbs ops: Array[Op]
|
183
|
-
# @rbs return:
|
184
|
-
def self.decode_global_expr: (Array[Op] ops) ->
|
221
|
+
# @rbs return: wasmValue
|
222
|
+
def self.decode_global_expr: (Array[Op] ops) -> wasmValue
|
185
223
|
|
186
224
|
# @rbs return: ExportSection
|
187
225
|
def self.export_section: () -> ExportSection
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Generated from lib/wardite/value.rb with RBS::Inline
|
2
2
|
|
3
3
|
module Wardite
|
4
|
+
type wasmValue = I32 | I64 | F32 | F64
|
5
|
+
|
4
6
|
module ValueHelper
|
5
7
|
# @rbs value: Integer
|
6
8
|
# @rbs return: I32
|
@@ -59,44 +61,44 @@ module Wardite
|
|
59
61
|
def packed: (?size: Integer | nil) -> String
|
60
62
|
|
61
63
|
# @rbs to: Symbol
|
62
|
-
# @rbs return:
|
63
|
-
def wrap: (to: Symbol) ->
|
64
|
+
# @rbs return: wasmValue
|
65
|
+
def wrap: (to: Symbol) -> wasmValue
|
64
66
|
|
65
67
|
# @rbs to: Symbol
|
66
|
-
# @rbs return:
|
67
|
-
def extend_s: (to: Symbol) ->
|
68
|
+
# @rbs return: wasmValue
|
69
|
+
def extend_s: (to: Symbol) -> wasmValue
|
68
70
|
|
69
71
|
# @rbs to: Symbol
|
70
|
-
# @rbs return:
|
71
|
-
def extend_u: (to: Symbol) ->
|
72
|
+
# @rbs return: wasmValue
|
73
|
+
def extend_u: (to: Symbol) -> wasmValue
|
72
74
|
|
73
75
|
# @rbs to: Symbol
|
74
|
-
# @rbs return:
|
75
|
-
def trunc_s: (to: Symbol) ->
|
76
|
+
# @rbs return: wasmValue
|
77
|
+
def trunc_s: (to: Symbol) -> wasmValue
|
76
78
|
|
77
79
|
# @rbs to: Symbol
|
78
|
-
# @rbs return:
|
79
|
-
def trunc_u: (to: Symbol) ->
|
80
|
+
# @rbs return: wasmValue
|
81
|
+
def trunc_u: (to: Symbol) -> wasmValue
|
80
82
|
|
81
83
|
# @rbs to: Symbol
|
82
|
-
# @rbs return:
|
83
|
-
def convert_s: (to: Symbol) ->
|
84
|
+
# @rbs return: wasmValue
|
85
|
+
def convert_s: (to: Symbol) -> wasmValue
|
84
86
|
|
85
87
|
# @rbs to: Symbol
|
86
|
-
# @rbs return:
|
87
|
-
def convert_u: (to: Symbol) ->
|
88
|
+
# @rbs return: wasmValue
|
89
|
+
def convert_u: (to: Symbol) -> wasmValue
|
88
90
|
|
89
91
|
# @rbs to: Symbol
|
90
|
-
# @rbs return:
|
91
|
-
def demote: (to: Symbol) ->
|
92
|
+
# @rbs return: wasmValue
|
93
|
+
def demote: (to: Symbol) -> wasmValue
|
92
94
|
|
93
95
|
# @rbs to: Symbol
|
94
|
-
# @rbs return:
|
95
|
-
def promote: (to: Symbol) ->
|
96
|
+
# @rbs return: wasmValue
|
97
|
+
def promote: (to: Symbol) -> wasmValue
|
96
98
|
|
97
99
|
# @rbs to: Symbol
|
98
|
-
# @rbs return:
|
99
|
-
def reinterpret: (to: Symbol) ->
|
100
|
+
# @rbs return: wasmValue
|
101
|
+
def reinterpret: (to: Symbol) -> wasmValue
|
100
102
|
|
101
103
|
# I32#inspect shows signed value for convinience
|
102
104
|
def inspect: () -> untyped
|
@@ -127,44 +129,44 @@ module Wardite
|
|
127
129
|
def packed: (?size: Integer | nil) -> String
|
128
130
|
|
129
131
|
# @rbs to: Symbol
|
130
|
-
# @rbs return:
|
131
|
-
def wrap: (to: Symbol) ->
|
132
|
+
# @rbs return: wasmValue
|
133
|
+
def wrap: (to: Symbol) -> wasmValue
|
132
134
|
|
133
135
|
# @rbs to: Symbol
|
134
|
-
# @rbs return:
|
135
|
-
def extend_s: (to: Symbol) ->
|
136
|
+
# @rbs return: wasmValue
|
137
|
+
def extend_s: (to: Symbol) -> wasmValue
|
136
138
|
|
137
139
|
# @rbs to: Symbol
|
138
|
-
# @rbs return:
|
139
|
-
def extend_u: (to: Symbol) ->
|
140
|
+
# @rbs return: wasmValue
|
141
|
+
def extend_u: (to: Symbol) -> wasmValue
|
140
142
|
|
141
143
|
# @rbs to: Symbol
|
142
|
-
# @rbs return:
|
143
|
-
def trunc_s: (to: Symbol) ->
|
144
|
+
# @rbs return: wasmValue
|
145
|
+
def trunc_s: (to: Symbol) -> wasmValue
|
144
146
|
|
145
147
|
# @rbs to: Symbol
|
146
|
-
# @rbs return:
|
147
|
-
def trunc_u: (to: Symbol) ->
|
148
|
+
# @rbs return: wasmValue
|
149
|
+
def trunc_u: (to: Symbol) -> wasmValue
|
148
150
|
|
149
151
|
# @rbs to: Symbol
|
150
|
-
# @rbs return:
|
151
|
-
def convert_s: (to: Symbol) ->
|
152
|
+
# @rbs return: wasmValue
|
153
|
+
def convert_s: (to: Symbol) -> wasmValue
|
152
154
|
|
153
155
|
# @rbs to: Symbol
|
154
|
-
# @rbs return:
|
155
|
-
def convert_u: (to: Symbol) ->
|
156
|
+
# @rbs return: wasmValue
|
157
|
+
def convert_u: (to: Symbol) -> wasmValue
|
156
158
|
|
157
159
|
# @rbs to: Symbol
|
158
|
-
# @rbs return:
|
159
|
-
def demote: (to: Symbol) ->
|
160
|
+
# @rbs return: wasmValue
|
161
|
+
def demote: (to: Symbol) -> wasmValue
|
160
162
|
|
161
163
|
# @rbs to: Symbol
|
162
|
-
# @rbs return:
|
163
|
-
def promote: (to: Symbol) ->
|
164
|
+
# @rbs return: wasmValue
|
165
|
+
def promote: (to: Symbol) -> wasmValue
|
164
166
|
|
165
167
|
# @rbs to: Symbol
|
166
|
-
# @rbs return:
|
167
|
-
def reinterpret: (to: Symbol) ->
|
168
|
+
# @rbs return: wasmValue
|
169
|
+
def reinterpret: (to: Symbol) -> wasmValue
|
168
170
|
|
169
171
|
# I64#inspect shows signed value
|
170
172
|
def inspect: () -> untyped
|
@@ -190,47 +192,47 @@ module Wardite
|
|
190
192
|
def packed: (?size: Integer | nil) -> String
|
191
193
|
|
192
194
|
# @rbs to: Symbol
|
193
|
-
# @rbs return:
|
194
|
-
def wrap: (to: Symbol) ->
|
195
|
+
# @rbs return: wasmValue
|
196
|
+
def wrap: (to: Symbol) -> wasmValue
|
195
197
|
|
196
198
|
# @rbs to: Symbol
|
197
|
-
# @rbs return:
|
198
|
-
def extend_s: (to: Symbol) ->
|
199
|
+
# @rbs return: wasmValue
|
200
|
+
def extend_s: (to: Symbol) -> wasmValue
|
199
201
|
|
200
202
|
# @rbs to: Symbol
|
201
|
-
# @rbs return:
|
202
|
-
def extend_u: (to: Symbol) ->
|
203
|
+
# @rbs return: wasmValue
|
204
|
+
def extend_u: (to: Symbol) -> wasmValue
|
203
205
|
|
204
206
|
# @todo need more testcase...
|
205
207
|
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-s-mathrm-trunc-mathsf-s-m-n-z
|
206
208
|
# @rbs to: Symbol
|
207
|
-
# @rbs return:
|
208
|
-
def trunc_s: (to: Symbol) ->
|
209
|
+
# @rbs return: wasmValue
|
210
|
+
def trunc_s: (to: Symbol) -> wasmValue
|
209
211
|
|
210
212
|
# @see https://webassembly.github.io/spec/core/exec/numerics.html#xref-exec-numerics-op-trunc-u-mathrm-trunc-mathsf-u-m-n-z
|
211
213
|
# @rbs to: Symbol
|
212
|
-
# @rbs return:
|
213
|
-
def trunc_u: (to: Symbol) ->
|
214
|
+
# @rbs return: wasmValue
|
215
|
+
def trunc_u: (to: Symbol) -> wasmValue
|
214
216
|
|
215
217
|
# @rbs to: Symbol
|
216
|
-
# @rbs return:
|
217
|
-
def convert_s: (to: Symbol) ->
|
218
|
+
# @rbs return: wasmValue
|
219
|
+
def convert_s: (to: Symbol) -> wasmValue
|
218
220
|
|
219
221
|
# @rbs to: Symbol
|
220
|
-
# @rbs return:
|
221
|
-
def convert_u: (to: Symbol) ->
|
222
|
+
# @rbs return: wasmValue
|
223
|
+
def convert_u: (to: Symbol) -> wasmValue
|
222
224
|
|
223
225
|
# @rbs to: Symbol
|
224
|
-
# @rbs return:
|
225
|
-
def demote: (to: Symbol) ->
|
226
|
+
# @rbs return: wasmValue
|
227
|
+
def demote: (to: Symbol) -> wasmValue
|
226
228
|
|
227
229
|
# @rbs to: Symbol
|
228
|
-
# @rbs return:
|
229
|
-
def promote: (to: Symbol) ->
|
230
|
+
# @rbs return: wasmValue
|
231
|
+
def promote: (to: Symbol) -> wasmValue
|
230
232
|
|
231
233
|
# @rbs to: Symbol
|
232
|
-
# @rbs return:
|
233
|
-
def reinterpret: (to: Symbol) ->
|
234
|
+
# @rbs return: wasmValue
|
235
|
+
def reinterpret: (to: Symbol) -> wasmValue
|
234
236
|
|
235
237
|
def inspect: () -> untyped
|
236
238
|
end
|
@@ -255,47 +257,47 @@ module Wardite
|
|
255
257
|
def packed: (?size: Integer | nil) -> String
|
256
258
|
|
257
259
|
# @rbs to: Symbol
|
258
|
-
# @rbs return:
|
259
|
-
def wrap: (to: Symbol) ->
|
260
|
+
# @rbs return: wasmValue
|
261
|
+
def wrap: (to: Symbol) -> wasmValue
|
260
262
|
|
261
263
|
# @rbs to: Symbol
|
262
|
-
# @rbs return:
|
263
|
-
def extend_s: (to: Symbol) ->
|
264
|
+
# @rbs return: wasmValue
|
265
|
+
def extend_s: (to: Symbol) -> wasmValue
|
264
266
|
|
265
267
|
# @rbs to: Symbol
|
266
|
-
# @rbs return:
|
267
|
-
def extend_u: (to: Symbol) ->
|
268
|
+
# @rbs return: wasmValue
|
269
|
+
def extend_u: (to: Symbol) -> wasmValue
|
268
270
|
|
269
271
|
# @see the same as F32
|
270
272
|
# @rbs to: Symbol
|
271
|
-
# @rbs return:
|
272
|
-
def trunc_s: (to: Symbol) ->
|
273
|
+
# @rbs return: wasmValue
|
274
|
+
def trunc_s: (to: Symbol) -> wasmValue
|
273
275
|
|
274
276
|
# @see the same as F32
|
275
277
|
# @rbs to: Symbol
|
276
|
-
# @rbs return:
|
277
|
-
def trunc_u: (to: Symbol) ->
|
278
|
+
# @rbs return: wasmValue
|
279
|
+
def trunc_u: (to: Symbol) -> wasmValue
|
278
280
|
|
279
281
|
# @rbs to: Symbol
|
280
|
-
# @rbs return:
|
281
|
-
def convert_s: (to: Symbol) ->
|
282
|
+
# @rbs return: wasmValue
|
283
|
+
def convert_s: (to: Symbol) -> wasmValue
|
282
284
|
|
283
285
|
# @rbs to: Symbol
|
284
|
-
# @rbs return:
|
285
|
-
def convert_u: (to: Symbol) ->
|
286
|
+
# @rbs return: wasmValue
|
287
|
+
def convert_u: (to: Symbol) -> wasmValue
|
286
288
|
|
287
289
|
# @todo no loss of digits...
|
288
290
|
# @rbs to: Symbol
|
289
|
-
# @rbs return:
|
290
|
-
def demote: (to: Symbol) ->
|
291
|
+
# @rbs return: wasmValue
|
292
|
+
def demote: (to: Symbol) -> wasmValue
|
291
293
|
|
292
294
|
# @rbs to: Symbol
|
293
|
-
# @rbs return:
|
294
|
-
def promote: (to: Symbol) ->
|
295
|
+
# @rbs return: wasmValue
|
296
|
+
def promote: (to: Symbol) -> wasmValue
|
295
297
|
|
296
298
|
# @rbs to: Symbol
|
297
|
-
# @rbs return:
|
298
|
-
def reinterpret: (to: Symbol) ->
|
299
|
+
# @rbs return: wasmValue
|
300
|
+
def reinterpret: (to: Symbol) -> wasmValue
|
299
301
|
|
300
302
|
def inspect: () -> untyped
|
301
303
|
end
|
@@ -10,12 +10,12 @@ module Wardite
|
|
10
10
|
def initialize: () -> untyped
|
11
11
|
|
12
12
|
# @rbs store: Store
|
13
|
-
# @rbs args: Array[
|
13
|
+
# @rbs args: Array[wasmValue]
|
14
14
|
# @rbs return: Object
|
15
|
-
def fd_write: (Store store, Array[
|
15
|
+
def fd_write: (Store store, Array[wasmValue] args) -> Object
|
16
16
|
|
17
|
-
# @rbs return: Hash[Symbol,
|
18
|
-
def to_module: () -> Hash[Symbol,
|
17
|
+
# @rbs return: Hash[Symbol, wasmCallable]
|
18
|
+
def to_module: () -> Hash[Symbol, wasmCallable]
|
19
19
|
|
20
20
|
private
|
21
21
|
|
data/sig/generated/wardite.rbs
CHANGED
@@ -14,15 +14,17 @@ module Wardite
|
|
14
14
|
|
15
15
|
attr_accessor runtime: Runtime
|
16
16
|
|
17
|
+
attr_accessor types: Array[Type]
|
18
|
+
|
17
19
|
attr_accessor store: Store
|
18
20
|
|
19
21
|
attr_accessor exports: Exports
|
20
22
|
|
21
|
-
attr_reader import_object: Hash[Symbol, Hash[Symbol,
|
23
|
+
attr_reader import_object: Hash[Symbol, Hash[Symbol, wasmCallable]]
|
22
24
|
|
23
|
-
# @rbs import_object: Hash[Symbol, Hash[Symbol,
|
25
|
+
# @rbs import_object: Hash[Symbol, Hash[Symbol, wasmCallable]]
|
24
26
|
# @rbs &blk: (Instance) -> void
|
25
|
-
def initialize: (Hash[Symbol, Hash[Symbol,
|
27
|
+
def initialize: (Hash[Symbol, Hash[Symbol, wasmCallable]] import_object) { (Instance) -> void } -> untyped
|
26
28
|
|
27
29
|
# @rbs return: ImportSection
|
28
30
|
def import_section: () -> ImportSection
|
@@ -33,6 +35,9 @@ module Wardite
|
|
33
35
|
# @rbs return: MemorySection|nil
|
34
36
|
def memory_section: () -> (MemorySection | nil)
|
35
37
|
|
38
|
+
# @rbs return: StartSection|nil
|
39
|
+
def start_section: () -> (StartSection | nil)
|
40
|
+
|
36
41
|
# @rbs return: GlobalSection|nil
|
37
42
|
def global_section: () -> (GlobalSection | nil)
|
38
43
|
|
@@ -42,6 +47,12 @@ module Wardite
|
|
42
47
|
# @rbs return: FunctionSection|nil
|
43
48
|
def function_section: () -> (FunctionSection | nil)
|
44
49
|
|
50
|
+
# @rbs return: TableSection?
|
51
|
+
def table_section: () -> TableSection?
|
52
|
+
|
53
|
+
# @rbs return: ElemSection?
|
54
|
+
def elem_section: () -> ElemSection?
|
55
|
+
|
45
56
|
# @rbs return: CodeSection|nil
|
46
57
|
def code_section: () -> (CodeSection | nil)
|
47
58
|
|
@@ -53,7 +64,7 @@ module Wardite
|
|
53
64
|
include ValueHelper
|
54
65
|
|
55
66
|
# TODO: add types of class that the stack accomodates
|
56
|
-
attr_accessor stack: Array[
|
67
|
+
attr_accessor stack: Array[wasmValue]
|
57
68
|
|
58
69
|
attr_accessor call_stack: Array[Frame]
|
59
70
|
|
@@ -62,6 +73,9 @@ module Wardite
|
|
62
73
|
# @rbs inst: Instance
|
63
74
|
def initialize: (Instance inst) -> untyped
|
64
75
|
|
76
|
+
# @rbs return: void
|
77
|
+
def invoke_start_section: () -> void
|
78
|
+
|
65
79
|
# @rbs name: String|Symbol
|
66
80
|
# @rbs return: bool
|
67
81
|
def callable?: (String | Symbol name) -> bool
|
@@ -71,6 +85,10 @@ module Wardite
|
|
71
85
|
# @rbs return: Object|nil
|
72
86
|
def call: (String | Symbol name, Array[Object] args) -> (Object | nil)
|
73
87
|
|
88
|
+
# @rbs idx: Integer
|
89
|
+
# @rbs return: void
|
90
|
+
def call_by_index: (Integer idx) -> void
|
91
|
+
|
74
92
|
# @rbs wasm_function: WasmFunction
|
75
93
|
# @rbs return: void
|
76
94
|
def push_frame: (WasmFunction wasm_function) -> void
|
@@ -80,8 +98,8 @@ module Wardite
|
|
80
98
|
def invoke_internal: (WasmFunction wasm_function) -> (Object | nil)
|
81
99
|
|
82
100
|
# @rbs external_function: ExternalFunction
|
83
|
-
# @rbs return:
|
84
|
-
def invoke_external: (ExternalFunction external_function) -> (
|
101
|
+
# @rbs return: wasmValue|nil
|
102
|
+
def invoke_external: (ExternalFunction external_function) -> (wasmValue | nil)
|
85
103
|
|
86
104
|
# @rbs return: void
|
87
105
|
def execute!: () -> void
|
@@ -91,6 +109,17 @@ module Wardite
|
|
91
109
|
# @rbs return: void
|
92
110
|
def eval_insn: (Frame frame, Op insn) -> void
|
93
111
|
|
112
|
+
# @rbs ops: Array[Op]
|
113
|
+
# @rbs pc_start: Integer
|
114
|
+
# @rbs return: Integer
|
115
|
+
def fetch_ops_while_else_or_end: (Array[Op] ops, Integer pc_start) -> Integer
|
116
|
+
|
117
|
+
# @rbs labels: Array[Label]
|
118
|
+
# @rbs stack: Array[wasmValue]
|
119
|
+
# @rbs level: Integer
|
120
|
+
# @rbs return: Integer
|
121
|
+
def do_branch: (Array[Label] labels, Array[wasmValue] stack, Integer level) -> Integer
|
122
|
+
|
94
123
|
# @rbs ops: Array[Op]
|
95
124
|
# @rbs pc_start: Integer
|
96
125
|
# @rbs return: Integer
|
@@ -103,8 +132,8 @@ module Wardite
|
|
103
132
|
def stack_unwind: (Integer sp, Integer arity) -> void
|
104
133
|
|
105
134
|
# @rbs finish: Integer
|
106
|
-
# @rbs return: Array[
|
107
|
-
def drained_stack: (Integer finish) -> Array[
|
135
|
+
# @rbs return: Array[wasmValue]
|
136
|
+
def drained_stack: (Integer finish) -> Array[wasmValue]
|
108
137
|
|
109
138
|
# @rbs name: Symbol
|
110
139
|
# @rbs args: Array[Object]
|
@@ -116,6 +145,17 @@ module Wardite
|
|
116
145
|
def respond_to?: (String | Symbol name) -> bool
|
117
146
|
end
|
118
147
|
|
148
|
+
class Type
|
149
|
+
attr_accessor callsig: Array[Symbol]
|
150
|
+
|
151
|
+
attr_accessor retsig: Array[Symbol]
|
152
|
+
|
153
|
+
# @rbs callsig: Array[Symbol]
|
154
|
+
# @rbs retsig: Array[Symbol]
|
155
|
+
# @rbs returb: void
|
156
|
+
def initialize: (Array[Symbol] callsig, Array[Symbol] retsig) -> untyped
|
157
|
+
end
|
158
|
+
|
119
159
|
class Frame
|
120
160
|
attr_accessor pc: Integer
|
121
161
|
|
@@ -127,15 +167,15 @@ module Wardite
|
|
127
167
|
|
128
168
|
attr_accessor labels: Array[Label]
|
129
169
|
|
130
|
-
attr_accessor locals: Array[
|
170
|
+
attr_accessor locals: Array[wasmValue]
|
131
171
|
|
132
172
|
# @rbs pc: Integer
|
133
173
|
# @rbs sp: Integer
|
134
174
|
# @rbs body: Array[Op]
|
135
175
|
# @rbs arity: Integer
|
136
|
-
# @rbs locals: Array[
|
176
|
+
# @rbs locals: Array[wasmValue]
|
137
177
|
# @rbs returb: void
|
138
|
-
def initialize: (Integer pc, Integer sp, Array[Op] body, Integer arity, Array[
|
178
|
+
def initialize: (Integer pc, Integer sp, Array[Op] body, Integer arity, Array[wasmValue] locals) -> untyped
|
139
179
|
end
|
140
180
|
|
141
181
|
class Label
|
@@ -147,12 +187,15 @@ module Wardite
|
|
147
187
|
|
148
188
|
attr_accessor arity: Integer
|
149
189
|
|
190
|
+
attr_accessor start: Integer | nil
|
191
|
+
|
150
192
|
# @rbs kind: (:if|:loop|:block)
|
151
193
|
# @rbs pc: Integer
|
152
194
|
# @rbs sp: Integer
|
153
195
|
# @rbs arity: Integer
|
154
|
-
# @rbs
|
155
|
-
|
196
|
+
# @rbs start: Integer|nil
|
197
|
+
# @rbs return: void
|
198
|
+
def initialize: (:if | :loop | :block kind, Integer pc, Integer sp, Integer arity, ?Integer | nil start) -> void
|
156
199
|
end
|
157
200
|
|
158
201
|
class Store
|
@@ -162,6 +205,10 @@ module Wardite
|
|
162
205
|
|
163
206
|
attr_accessor globals: Array[Global]
|
164
207
|
|
208
|
+
attr_accessor tables: Array[Table]
|
209
|
+
|
210
|
+
attr_accessor elements: Array[[ Symbol, Integer, Array[Integer] ]]
|
211
|
+
|
165
212
|
# @rbs inst: Instance
|
166
213
|
# @rbs return: void
|
167
214
|
def initialize: (Instance inst) -> void
|
@@ -189,6 +236,27 @@ module Wardite
|
|
189
236
|
def inspect: () -> untyped
|
190
237
|
end
|
191
238
|
|
239
|
+
class Table
|
240
|
+
attr_accessor type: Symbol
|
241
|
+
|
242
|
+
attr_accessor current: Integer
|
243
|
+
|
244
|
+
attr_accessor max: Integer | nil
|
245
|
+
|
246
|
+
attr_accessor refs: Array[WasmFunction | ExternalFunction | nil]
|
247
|
+
|
248
|
+
# @rbs type: Symbol
|
249
|
+
# @rbs init: Integer
|
250
|
+
# @rbs max: Integer|nil
|
251
|
+
# @rbs return: void
|
252
|
+
def initialize: (Symbol type, Integer init, Integer | nil max) -> void
|
253
|
+
|
254
|
+
# @rbs idx: Integer
|
255
|
+
# @rbs elem: WasmFunction|ExternalFunction|nil
|
256
|
+
# @rbs return: void
|
257
|
+
def set: (Integer idx, WasmFunction | ExternalFunction | nil elem) -> void
|
258
|
+
end
|
259
|
+
|
192
260
|
class Global
|
193
261
|
attr_accessor type: Symbol
|
194
262
|
|
@@ -197,7 +265,7 @@ module Wardite
|
|
197
265
|
# TODO: unused in wasm 1.0 spec?
|
198
266
|
attr_accessor shared: bool
|
199
267
|
|
200
|
-
attr_accessor value:
|
268
|
+
attr_accessor value: wasmValue
|
201
269
|
|
202
270
|
# @rbs &blk: (Global) -> void
|
203
271
|
# @rbs return: void
|
@@ -274,20 +342,32 @@ module Wardite
|
|
274
342
|
|
275
343
|
# @rbs return: Array[Integer]
|
276
344
|
def locals_count: () -> Array[Integer]
|
345
|
+
|
346
|
+
# @rbs override_type: Type?
|
347
|
+
# @rbs return: WasmFunction
|
348
|
+
def clone: (?override_type: Type?) -> WasmFunction
|
277
349
|
end
|
278
350
|
|
351
|
+
type wasmFuncReturn = Object | nil
|
352
|
+
|
353
|
+
type wasmCallable = ^(Store, Array[wasmValue]) -> wasmFuncReturn
|
354
|
+
|
279
355
|
class ExternalFunction
|
280
356
|
attr_accessor callsig: Array[Symbol]
|
281
357
|
|
282
358
|
attr_accessor retsig: Array[Symbol]
|
283
359
|
|
284
|
-
attr_accessor callable:
|
360
|
+
attr_accessor callable: wasmCallable
|
285
361
|
|
286
362
|
# @rbs callsig: Array[Symbol]
|
287
363
|
# @rbs retsig: Array[Symbol]
|
288
|
-
# @rbs callable:
|
364
|
+
# @rbs callable: wasmCallable
|
289
365
|
# @rbs return: void
|
290
|
-
def initialize: (Array[Symbol] callsig, Array[Symbol] retsig,
|
366
|
+
def initialize: (Array[Symbol] callsig, Array[Symbol] retsig, wasmCallable callable) -> void
|
367
|
+
|
368
|
+
# @rbs override_type: Type?
|
369
|
+
# @rbs return: ExternalFunction
|
370
|
+
def clone: (?override_type: Type?) -> ExternalFunction
|
291
371
|
end
|
292
372
|
|
293
373
|
class GenericError < StandardError
|
data/sig/wardite.rbs
CHANGED
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.3.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-
|
11
|
+
date: 2024-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A pure-ruby webassembly runtime
|
14
14
|
email:
|
@@ -24,7 +24,9 @@ files:
|
|
24
24
|
- examples/.gitignore
|
25
25
|
- examples/add.wasm
|
26
26
|
- examples/add.wat
|
27
|
+
- examples/break.wat
|
27
28
|
- examples/call.wat
|
29
|
+
- examples/call_indirect.wat
|
28
30
|
- examples/consts.wat
|
29
31
|
- examples/fib.wat
|
30
32
|
- examples/fib2.wat
|
@@ -33,7 +35,9 @@ files:
|
|
33
35
|
- examples/i32_const.wat
|
34
36
|
- examples/i32_store.wat
|
35
37
|
- examples/local_set.wat
|
38
|
+
- examples/loop.wat
|
36
39
|
- examples/memory.wat
|
40
|
+
- examples/start.wat
|
37
41
|
- exe/wardite
|
38
42
|
- lib/wardite.rb
|
39
43
|
- lib/wardite/alu_f32.generated.rb
|