wardite 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/global.wat +13 -0
- data/lib/wardite/instruction.rb +1 -1
- data/lib/wardite/load.rb +679 -0
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite.rb +79 -591
- data/sig/generated/wardite/instruction.rbs +2 -2
- data/sig/generated/wardite/load.rbs +198 -0
- data/sig/generated/wardite.rbs +24 -165
- metadata +5 -2
@@ -0,0 +1,198 @@
|
|
1
|
+
# Generated from lib/wardite/load.rb with RBS::Inline
|
2
|
+
|
3
|
+
# rbs_inline: enabled
|
4
|
+
module Wardite
|
5
|
+
class Section
|
6
|
+
attr_accessor name: String
|
7
|
+
|
8
|
+
attr_accessor code: Integer
|
9
|
+
|
10
|
+
attr_accessor size: Integer
|
11
|
+
end
|
12
|
+
|
13
|
+
class TypeSection < Section
|
14
|
+
attr_accessor defined_types: Array[Array[Symbol]]
|
15
|
+
|
16
|
+
attr_accessor defined_results: Array[Array[Symbol]]
|
17
|
+
|
18
|
+
# @rbs return: void
|
19
|
+
def initialize: () -> void
|
20
|
+
end
|
21
|
+
|
22
|
+
class FunctionSection < Section
|
23
|
+
attr_accessor func_indices: Array[Integer]
|
24
|
+
|
25
|
+
# @rbs return: void
|
26
|
+
def initialize: () -> void
|
27
|
+
end
|
28
|
+
|
29
|
+
class MemorySection < Section
|
30
|
+
attr_accessor limits: Array[[ Integer, Integer | nil ]]
|
31
|
+
|
32
|
+
# @rbs return: void
|
33
|
+
def initialize: () -> void
|
34
|
+
end
|
35
|
+
|
36
|
+
class GlobalSection < Section
|
37
|
+
class Global
|
38
|
+
attr_accessor type: Symbol
|
39
|
+
|
40
|
+
attr_accessor mutable: bool
|
41
|
+
|
42
|
+
# TODO: unused in wasm 1.0 spec?
|
43
|
+
attr_accessor shared: bool
|
44
|
+
|
45
|
+
attr_accessor value: I32 | I64 | F32 | F64
|
46
|
+
|
47
|
+
# @rbs &blk: (Global) -> void
|
48
|
+
# @rbs return: void
|
49
|
+
def initialize: () { (Global) -> void } -> void
|
50
|
+
end
|
51
|
+
|
52
|
+
attr_accessor globals: Array[Global]
|
53
|
+
|
54
|
+
# @rbs return: void
|
55
|
+
def initialize: () -> void
|
56
|
+
end
|
57
|
+
|
58
|
+
class CodeSection < Section
|
59
|
+
class CodeBody
|
60
|
+
attr_accessor locals_count: Array[Integer]
|
61
|
+
|
62
|
+
attr_accessor locals_type: Array[Symbol]
|
63
|
+
|
64
|
+
attr_accessor body: Array[Op]
|
65
|
+
|
66
|
+
# @rbs &blk: (CodeBody) -> void
|
67
|
+
# @rbs return: void
|
68
|
+
def initialize: () { (CodeBody) -> void } -> void
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_accessor func_codes: Array[CodeBody]
|
72
|
+
|
73
|
+
# @rbs return: void
|
74
|
+
def initialize: () -> void
|
75
|
+
end
|
76
|
+
|
77
|
+
class DataSection < Section
|
78
|
+
class Segment
|
79
|
+
attr_accessor flags: Integer
|
80
|
+
|
81
|
+
attr_accessor offset: Integer
|
82
|
+
|
83
|
+
attr_accessor data: String
|
84
|
+
|
85
|
+
# @rbs &blk: (Segment) -> void
|
86
|
+
# @rbs return: void
|
87
|
+
def initialize: () { (Segment) -> void } -> void
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_accessor segments: Array[Segment]
|
91
|
+
|
92
|
+
# @rbs return: void
|
93
|
+
def initialize: () -> void
|
94
|
+
end
|
95
|
+
|
96
|
+
class ExportSection < Section
|
97
|
+
class ExportDesc
|
98
|
+
attr_accessor name: String
|
99
|
+
|
100
|
+
attr_accessor kind: Integer
|
101
|
+
|
102
|
+
attr_accessor func_index: Integer
|
103
|
+
end
|
104
|
+
|
105
|
+
attr_accessor exports: Hash[String, ExportDesc]
|
106
|
+
|
107
|
+
def initialize: () -> void
|
108
|
+
|
109
|
+
# @rbs &blk: (ExportDesc) -> void
|
110
|
+
def add_desc: () { (ExportDesc) -> void } -> untyped
|
111
|
+
end
|
112
|
+
|
113
|
+
class ImportSection < Section
|
114
|
+
class ImportDesc
|
115
|
+
attr_accessor module_name: String
|
116
|
+
|
117
|
+
attr_accessor name: String
|
118
|
+
|
119
|
+
attr_accessor kind: Integer
|
120
|
+
|
121
|
+
attr_accessor sig_index: Integer
|
122
|
+
end
|
123
|
+
|
124
|
+
attr_accessor imports: Array[ImportDesc]
|
125
|
+
|
126
|
+
def initialize: () -> void
|
127
|
+
|
128
|
+
# @rbs &blk: (ImportDesc) -> void
|
129
|
+
def add_desc: () { (ImportDesc) -> void } -> untyped
|
130
|
+
end
|
131
|
+
|
132
|
+
module BinaryLoader
|
133
|
+
extend Wardite::Leb128Helper
|
134
|
+
|
135
|
+
extend Wardite::ValueHelper
|
136
|
+
|
137
|
+
# @rbs buf: File|StringIO
|
138
|
+
# @rbs import_object: Hash[Symbol, Hash[Symbol, Proc]]
|
139
|
+
# @rbs enable_wasi: boolish
|
140
|
+
# @rbs return: Instance
|
141
|
+
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, Hash[Symbol, Proc]], ?enable_wasi: boolish) -> Instance
|
142
|
+
|
143
|
+
# @rbs return: Integer
|
144
|
+
def self.preamble: () -> Integer
|
145
|
+
|
146
|
+
# @rbs return: Array[Section]
|
147
|
+
def self.sections: () -> Array[Section]
|
148
|
+
|
149
|
+
# @rbs return: TypeSection
|
150
|
+
def self.type_section: () -> TypeSection
|
151
|
+
|
152
|
+
# @rbs return: ImportSection
|
153
|
+
def self.import_section: () -> ImportSection
|
154
|
+
|
155
|
+
# @rbs return: MemorySection
|
156
|
+
def self.memory_section: () -> MemorySection
|
157
|
+
|
158
|
+
# @rbs return: GlobalSection
|
159
|
+
def self.global_section: () -> GlobalSection
|
160
|
+
|
161
|
+
# @rbs return: FunctionSection
|
162
|
+
def self.function_section: () -> FunctionSection
|
163
|
+
|
164
|
+
# @rbs return: CodeSection
|
165
|
+
def self.code_section: () -> CodeSection
|
166
|
+
|
167
|
+
# @rbs buf: StringIO
|
168
|
+
# @rbs return: Array[::Wardite::Op]
|
169
|
+
def self.code_body: (StringIO buf) -> Array[::Wardite::Op]
|
170
|
+
|
171
|
+
# @rbs return: DataSection
|
172
|
+
def self.data_section: () -> DataSection
|
173
|
+
|
174
|
+
# @rbs sbuf: StringIO
|
175
|
+
# @rbs return: String
|
176
|
+
def self.fetch_insn_while_end: (StringIO sbuf) -> String
|
177
|
+
|
178
|
+
# @rbs ops: Array[Op]
|
179
|
+
# @rbs return: Integer
|
180
|
+
def self.decode_expr: (Array[Op] ops) -> Integer
|
181
|
+
|
182
|
+
# @rbs ops: Array[Op]
|
183
|
+
# @rbs return: I32|I64|F32|F64
|
184
|
+
def self.decode_global_expr: (Array[Op] ops) -> (I32 | I64 | F32 | F64)
|
185
|
+
|
186
|
+
# @rbs return: ExportSection
|
187
|
+
def self.export_section: () -> ExportSection
|
188
|
+
|
189
|
+
# @rbs code: Integer
|
190
|
+
# @rbs return: nil
|
191
|
+
def self.unimplemented_skip_section: (Integer code) -> nil
|
192
|
+
|
193
|
+
# @rbs sbuf: StringIO
|
194
|
+
# @rbs n: Integer
|
195
|
+
# @rbs return: String
|
196
|
+
def self.assert_read: (StringIO sbuf, Integer n) -> String
|
197
|
+
end
|
198
|
+
end
|
data/sig/generated/wardite.rbs
CHANGED
@@ -7,171 +7,6 @@ module Wardite
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Wardite
|
10
|
-
class Section
|
11
|
-
attr_accessor name: String
|
12
|
-
|
13
|
-
attr_accessor code: Integer
|
14
|
-
|
15
|
-
attr_accessor size: Integer
|
16
|
-
end
|
17
|
-
|
18
|
-
class TypeSection < Section
|
19
|
-
attr_accessor defined_types: Array[Array[Symbol]]
|
20
|
-
|
21
|
-
attr_accessor defined_results: Array[Array[Symbol]]
|
22
|
-
|
23
|
-
# @rbs return: void
|
24
|
-
def initialize: () -> void
|
25
|
-
end
|
26
|
-
|
27
|
-
class FunctionSection < Section
|
28
|
-
attr_accessor func_indices: Array[Integer]
|
29
|
-
|
30
|
-
# @rbs return: void
|
31
|
-
def initialize: () -> void
|
32
|
-
end
|
33
|
-
|
34
|
-
class MemorySection < Section
|
35
|
-
attr_accessor limits: Array[[ Integer, Integer | nil ]]
|
36
|
-
|
37
|
-
# @rbs return: void
|
38
|
-
def initialize: () -> void
|
39
|
-
end
|
40
|
-
|
41
|
-
class CodeSection < Section
|
42
|
-
class CodeBody
|
43
|
-
attr_accessor locals_count: Array[Integer]
|
44
|
-
|
45
|
-
attr_accessor locals_type: Array[Symbol]
|
46
|
-
|
47
|
-
attr_accessor body: Array[Op]
|
48
|
-
|
49
|
-
# @rbs &blk: (CodeBody) -> void
|
50
|
-
# @rbs return: void
|
51
|
-
def initialize: () { (CodeBody) -> void } -> void
|
52
|
-
end
|
53
|
-
|
54
|
-
attr_accessor func_codes: Array[CodeBody]
|
55
|
-
|
56
|
-
# @rbs return: void
|
57
|
-
def initialize: () -> void
|
58
|
-
end
|
59
|
-
|
60
|
-
class DataSection < Section
|
61
|
-
class Segment
|
62
|
-
attr_accessor flags: Integer
|
63
|
-
|
64
|
-
attr_accessor offset: Integer
|
65
|
-
|
66
|
-
attr_accessor data: String
|
67
|
-
|
68
|
-
# @rbs &blk: (Segment) -> void
|
69
|
-
# @rbs return: void
|
70
|
-
def initialize: () { (Segment) -> void } -> void
|
71
|
-
end
|
72
|
-
|
73
|
-
attr_accessor segments: Array[Segment]
|
74
|
-
|
75
|
-
# @rbs return: void
|
76
|
-
def initialize: () -> void
|
77
|
-
end
|
78
|
-
|
79
|
-
class ExportSection < Section
|
80
|
-
class ExportDesc
|
81
|
-
attr_accessor name: String
|
82
|
-
|
83
|
-
attr_accessor kind: Integer
|
84
|
-
|
85
|
-
attr_accessor func_index: Integer
|
86
|
-
end
|
87
|
-
|
88
|
-
attr_accessor exports: Hash[String, ExportDesc]
|
89
|
-
|
90
|
-
def initialize: () -> void
|
91
|
-
|
92
|
-
# @rbs &blk: (ExportDesc) -> void
|
93
|
-
def add_desc: () { (ExportDesc) -> void } -> untyped
|
94
|
-
end
|
95
|
-
|
96
|
-
class ImportSection < Section
|
97
|
-
class ImportDesc
|
98
|
-
attr_accessor module_name: String
|
99
|
-
|
100
|
-
attr_accessor name: String
|
101
|
-
|
102
|
-
attr_accessor kind: Integer
|
103
|
-
|
104
|
-
attr_accessor sig_index: Integer
|
105
|
-
end
|
106
|
-
|
107
|
-
attr_accessor imports: Array[ImportDesc]
|
108
|
-
|
109
|
-
def initialize: () -> void
|
110
|
-
|
111
|
-
# @rbs &blk: (ImportDesc) -> void
|
112
|
-
def add_desc: () { (ImportDesc) -> void } -> untyped
|
113
|
-
end
|
114
|
-
|
115
|
-
module BinaryLoader
|
116
|
-
extend Wardite::Leb128Helper
|
117
|
-
|
118
|
-
extend Wardite::ValueHelper
|
119
|
-
|
120
|
-
# @rbs buf: File|StringIO
|
121
|
-
# @rbs import_object: Hash[Symbol, Hash[Symbol, Proc]]
|
122
|
-
# @rbs enable_wasi: boolish
|
123
|
-
# @rbs return: Instance
|
124
|
-
def self.load_from_buffer: (File | StringIO buf, ?import_object: Hash[Symbol, Hash[Symbol, Proc]], ?enable_wasi: boolish) -> Instance
|
125
|
-
|
126
|
-
# @rbs return: Integer
|
127
|
-
def self.preamble: () -> Integer
|
128
|
-
|
129
|
-
# @rbs return: Array[Section]
|
130
|
-
def self.sections: () -> Array[Section]
|
131
|
-
|
132
|
-
# @rbs return: TypeSection
|
133
|
-
def self.type_section: () -> TypeSection
|
134
|
-
|
135
|
-
# @rbs return: ImportSection
|
136
|
-
def self.import_section: () -> ImportSection
|
137
|
-
|
138
|
-
# @rbs return: MemorySection
|
139
|
-
def self.memory_section: () -> MemorySection
|
140
|
-
|
141
|
-
# @rbs return: FunctionSection
|
142
|
-
def self.function_section: () -> FunctionSection
|
143
|
-
|
144
|
-
# @rbs return: CodeSection
|
145
|
-
def self.code_section: () -> CodeSection
|
146
|
-
|
147
|
-
# @rbs buf: StringIO
|
148
|
-
# @rbs return: Array[::Wardite::Op]
|
149
|
-
def self.code_body: (StringIO buf) -> Array[::Wardite::Op]
|
150
|
-
|
151
|
-
# @rbs return: DataSection
|
152
|
-
def self.data_section: () -> DataSection
|
153
|
-
|
154
|
-
# @rbs sbuf: StringIO
|
155
|
-
# @rbs return: String
|
156
|
-
def self.fetch_insn_while_end: (StringIO sbuf) -> String
|
157
|
-
|
158
|
-
# @rbs ops: Array[Op]
|
159
|
-
# @rbs return: Integer
|
160
|
-
def self.decode_expr: (Array[Op] ops) -> Integer
|
161
|
-
|
162
|
-
# @rbs return: ExportSection
|
163
|
-
def self.export_section: () -> ExportSection
|
164
|
-
|
165
|
-
# @rbs code: Integer
|
166
|
-
# @rbs return: nil
|
167
|
-
def self.unimplemented_skip_section: (Integer code) -> nil
|
168
|
-
|
169
|
-
# @rbs sbuf: StringIO
|
170
|
-
# @rbs n: Integer
|
171
|
-
# @rbs return: String
|
172
|
-
def self.assert_read: (StringIO sbuf, Integer n) -> String
|
173
|
-
end
|
174
|
-
|
175
10
|
class Instance
|
176
11
|
attr_accessor version: Integer
|
177
12
|
|
@@ -198,6 +33,9 @@ module Wardite
|
|
198
33
|
# @rbs return: MemorySection|nil
|
199
34
|
def memory_section: () -> (MemorySection | nil)
|
200
35
|
|
36
|
+
# @rbs return: GlobalSection|nil
|
37
|
+
def global_section: () -> (GlobalSection | nil)
|
38
|
+
|
201
39
|
# @rbs return: DataSection|nil
|
202
40
|
def data_section: () -> (DataSection | nil)
|
203
41
|
|
@@ -322,6 +160,8 @@ module Wardite
|
|
322
160
|
|
323
161
|
attr_accessor memories: Array[Memory]
|
324
162
|
|
163
|
+
attr_accessor globals: Array[Global]
|
164
|
+
|
325
165
|
# @rbs inst: Instance
|
326
166
|
# @rbs return: void
|
327
167
|
def initialize: (Instance inst) -> void
|
@@ -349,6 +189,25 @@ module Wardite
|
|
349
189
|
def inspect: () -> untyped
|
350
190
|
end
|
351
191
|
|
192
|
+
class Global
|
193
|
+
attr_accessor type: Symbol
|
194
|
+
|
195
|
+
attr_accessor mutable: bool
|
196
|
+
|
197
|
+
# TODO: unused in wasm 1.0 spec?
|
198
|
+
attr_accessor shared: bool
|
199
|
+
|
200
|
+
attr_accessor value: I32 | I64 | F32 | F64
|
201
|
+
|
202
|
+
# @rbs &blk: (Global) -> void
|
203
|
+
# @rbs return: void
|
204
|
+
def initialize: () { (Global) -> void } -> void
|
205
|
+
|
206
|
+
alias mutable? mutable
|
207
|
+
|
208
|
+
alias shared? shared
|
209
|
+
end
|
210
|
+
|
352
211
|
class WasmData
|
353
212
|
attr_accessor memory_index: Integer
|
354
213
|
|
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.2.
|
4
|
+
version: 0.2.2
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A pure-ruby webassembly runtime
|
14
14
|
email:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- examples/consts.wat
|
29
29
|
- examples/fib.wat
|
30
30
|
- examples/fib2.wat
|
31
|
+
- examples/global.wat
|
31
32
|
- examples/helloworld.wat
|
32
33
|
- examples/i32_const.wat
|
33
34
|
- examples/i32_store.wat
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- lib/wardite/convert.generated.rb
|
44
45
|
- lib/wardite/instruction.rb
|
45
46
|
- lib/wardite/leb128.rb
|
47
|
+
- lib/wardite/load.rb
|
46
48
|
- lib/wardite/value.rb
|
47
49
|
- lib/wardite/version.rb
|
48
50
|
- lib/wardite/wasi.rb
|
@@ -59,6 +61,7 @@ files:
|
|
59
61
|
- sig/generated/wardite/convert.generated.rbs
|
60
62
|
- sig/generated/wardite/instruction.rbs
|
61
63
|
- sig/generated/wardite/leb128.rbs
|
64
|
+
- sig/generated/wardite/load.rbs
|
62
65
|
- sig/generated/wardite/value.rbs
|
63
66
|
- sig/generated/wardite/version.rbs
|
64
67
|
- sig/generated/wardite/wasi.rbs
|