wardite 0.2.0 → 0.2.2

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.
@@ -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
 
@@ -215,7 +53,7 @@ module Wardite
215
53
  include ValueHelper
216
54
 
217
55
  # TODO: add types of class that the stack accomodates
218
- attr_accessor stack: Array[I32 | I64 | F32 | F64 | Block]
56
+ attr_accessor stack: Array[I32 | I64 | F32 | F64]
219
57
 
220
58
  attr_accessor call_stack: Array[Frame]
221
59
 
@@ -265,8 +103,8 @@ module Wardite
265
103
  def stack_unwind: (Integer sp, Integer arity) -> void
266
104
 
267
105
  # @rbs finish: Integer
268
- # @rbs return: Array[I32|I64|F32|F64|Block]
269
- def drained_stack: (Integer finish) -> Array[I32 | I64 | F32 | F64 | Block]
106
+ # @rbs return: Array[I32|I64|F32|F64]
107
+ def drained_stack: (Integer finish) -> Array[I32 | I64 | F32 | F64]
270
108
 
271
109
  # @rbs name: Symbol
272
110
  # @rbs args: Array[Object]
@@ -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
@@ -333,6 +173,8 @@ module Wardite
333
173
  class Memory
334
174
  attr_accessor data: String
335
175
 
176
+ attr_accessor current: Integer
177
+
336
178
  attr_accessor max: Integer | nil
337
179
 
338
180
  # @rbs min: Integer
@@ -340,9 +182,32 @@ module Wardite
340
182
  # @rbs return: void
341
183
  def initialize: (Integer min, Integer | nil max) -> void
342
184
 
185
+ # @rbs delta: Integer
186
+ # @rbs return: Integer
187
+ def grow: (Integer delta) -> Integer
188
+
343
189
  def inspect: () -> untyped
344
190
  end
345
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
+
346
211
  class WasmData
347
212
  attr_accessor memory_index: Integer
348
213
 
@@ -437,6 +302,9 @@ module Wardite
437
302
  class EvalError < StandardError
438
303
  end
439
304
 
305
+ class Unreachable < StandardError
306
+ end
307
+
440
308
  # @rbs path: String|nil
441
309
  # @rbs buffer: File|StringIO|nil
442
310
  # @rbs **options: Hash[Symbol, Object]
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.0
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-02 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A pure-ruby webassembly runtime
14
14
  email:
@@ -25,8 +25,10 @@ files:
25
25
  - examples/add.wasm
26
26
  - examples/add.wat
27
27
  - examples/call.wat
28
+ - examples/consts.wat
28
29
  - examples/fib.wat
29
30
  - examples/fib2.wat
31
+ - examples/global.wat
30
32
  - examples/helloworld.wat
31
33
  - examples/i32_const.wat
32
34
  - examples/i32_store.wat
@@ -34,20 +36,32 @@ files:
34
36
  - examples/memory.wat
35
37
  - exe/wardite
36
38
  - lib/wardite.rb
39
+ - lib/wardite/alu_f32.generated.rb
40
+ - lib/wardite/alu_f64.generated.rb
37
41
  - lib/wardite/alu_i32.generated.rb
42
+ - lib/wardite/alu_i64.generated.rb
38
43
  - lib/wardite/const.rb
44
+ - lib/wardite/convert.generated.rb
39
45
  - lib/wardite/instruction.rb
40
46
  - lib/wardite/leb128.rb
47
+ - lib/wardite/load.rb
41
48
  - lib/wardite/value.rb
42
49
  - lib/wardite/version.rb
43
50
  - lib/wardite/wasi.rb
44
51
  - scripts/gen_alu.rb
52
+ - scripts/gen_conv.rb
45
53
  - scripts/templates/alu_module.rb.tmpl
54
+ - scripts/templates/conv_module.rb.tmpl
46
55
  - sig/generated/wardite.rbs
56
+ - sig/generated/wardite/alu_f32.generated.rbs
57
+ - sig/generated/wardite/alu_f64.generated.rbs
47
58
  - sig/generated/wardite/alu_i32.generated.rbs
59
+ - sig/generated/wardite/alu_i64.generated.rbs
48
60
  - sig/generated/wardite/const.rbs
61
+ - sig/generated/wardite/convert.generated.rbs
49
62
  - sig/generated/wardite/instruction.rbs
50
63
  - sig/generated/wardite/leb128.rbs
64
+ - sig/generated/wardite/load.rbs
51
65
  - sig/generated/wardite/value.rbs
52
66
  - sig/generated/wardite/version.rbs
53
67
  - sig/generated/wardite/wasi.rbs