wardite 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/wardite/alu_i32.generated.rb +27 -13
- data/lib/wardite/alu_i64.generated.rb +27 -13
- data/lib/wardite/errors.rb +9 -0
- data/lib/wardite/load.rb +2 -2
- data/lib/wardite/value.rb +16 -0
- data/lib/wardite/version.rb +1 -1
- data/lib/wardite.rb +41 -10
- data/scripts/gen_alu.rb +27 -13
- data/sig/generated/wardite/errors.rbs +12 -0
- data/sig/generated/wardite/load.rbs +1 -1
- data/sig/generated/wardite/value.rbs +8 -0
- data/sig/generated/wardite.rbs +9 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ca81e45a3da7f90566d465d5248bcac03981953e97c81681de900851348407
|
4
|
+
data.tar.gz: 2b0952f92a92bce4d54283868fd2565b9dbaa178cc1187b2a7f6feca6225fe57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4db779ed117465fb2c981c0b9da39dcdd001e60abf00262d04353449b5b72ad433949d6c640458fe2b61b503e84180dbf3c7709d791b48f7ed2a5ad9dbe372
|
7
|
+
data.tar.gz: 7d00f04205f6ef10b21dee7067adf1f480a529cea4bf0caa404fd888547f101f3908f54863262333e2b363d2d17b28b4899ff12ddc5e226958eda975354fd954
|
data/README.md
CHANGED
@@ -311,7 +311,7 @@ module Wardite
|
|
311
311
|
digits = target.memsize
|
312
312
|
count = 0
|
313
313
|
digits.times do |i|
|
314
|
-
if (target.value & (1 << i)).
|
314
|
+
if (target.value & (1 << i)).nonzero?
|
315
315
|
count += 1
|
316
316
|
end
|
317
317
|
end
|
@@ -347,7 +347,13 @@ module Wardite
|
|
347
347
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
348
348
|
raise EvalError, "maybe empty or invalid stack"
|
349
349
|
end
|
350
|
-
|
350
|
+
result = left.value_s / right.value_s.to_f
|
351
|
+
iresult = (result >= 0 ? result.floor : result.ceil).to_i
|
352
|
+
if iresult >= (1 << (left.memsize - 1))
|
353
|
+
raise IntegerOverflow, "integer overflow"
|
354
|
+
end
|
355
|
+
|
356
|
+
runtime.stack.push(I32(iresult))
|
351
357
|
|
352
358
|
|
353
359
|
when :i32_div_u
|
@@ -363,7 +369,13 @@ module Wardite
|
|
363
369
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
364
370
|
raise EvalError, "maybe empty or invalid stack"
|
365
371
|
end
|
366
|
-
|
372
|
+
result = left.value_s % right.value_s
|
373
|
+
if result > 0 && left.value_s < 0
|
374
|
+
result = result - right.value_s
|
375
|
+
elsif result < 0 && left.value_s > 0
|
376
|
+
result = result - right.value_s
|
377
|
+
end
|
378
|
+
runtime.stack.push(I32(result))
|
367
379
|
|
368
380
|
|
369
381
|
when :i32_rem_u
|
@@ -403,8 +415,8 @@ module Wardite
|
|
403
415
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
404
416
|
raise EvalError, "maybe empty or invalid stack"
|
405
417
|
end
|
406
|
-
value = left.value << right.value
|
407
|
-
value %=
|
418
|
+
value = left.value << (right.value % right.memsize)
|
419
|
+
value %= 1 << right.memsize
|
408
420
|
|
409
421
|
runtime.stack.push(I32(value))
|
410
422
|
|
@@ -414,7 +426,7 @@ module Wardite
|
|
414
426
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
415
427
|
raise EvalError, "maybe empty or invalid stack"
|
416
428
|
end
|
417
|
-
value = left.value_s >> right.value
|
429
|
+
value = left.value_s >> (right.value % right.memsize)
|
418
430
|
runtime.stack.push(I32(value))
|
419
431
|
|
420
432
|
|
@@ -423,7 +435,7 @@ module Wardite
|
|
423
435
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
424
436
|
raise EvalError, "maybe empty or invalid stack"
|
425
437
|
end
|
426
|
-
value = left.value >> right.value
|
438
|
+
value = left.value >> (right.value % right.memsize)
|
427
439
|
runtime.stack.push(I32(value))
|
428
440
|
|
429
441
|
|
@@ -432,9 +444,10 @@ module Wardite
|
|
432
444
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
433
445
|
raise EvalError, "maybe empty or invalid stack"
|
434
446
|
end
|
435
|
-
|
436
|
-
|
437
|
-
|
447
|
+
k = (right.value % right.memsize)
|
448
|
+
rotated = left.value << k
|
449
|
+
rest = left.value & (I32::I32_MAX << (right.memsize - k))
|
450
|
+
value = rotated | (rest >> (right.memsize - k))
|
438
451
|
runtime.stack.push(I32(value))
|
439
452
|
|
440
453
|
|
@@ -443,9 +456,10 @@ module Wardite
|
|
443
456
|
if !right.is_a?(I32) || !left.is_a?(I32)
|
444
457
|
raise EvalError, "maybe empty or invalid stack"
|
445
458
|
end
|
446
|
-
|
447
|
-
|
448
|
-
|
459
|
+
k = (right.value % right.memsize)
|
460
|
+
rotated = left.value >> k
|
461
|
+
rest = left.value & (I32::I32_MAX >> (right.memsize - k))
|
462
|
+
value = rotated | (rest << (right.memsize - k))
|
449
463
|
runtime.stack.push(I32(value))
|
450
464
|
|
451
465
|
|
@@ -368,7 +368,7 @@ module Wardite
|
|
368
368
|
digits = target.memsize
|
369
369
|
count = 0
|
370
370
|
digits.times do |i|
|
371
|
-
if (target.value & (1 << i)).
|
371
|
+
if (target.value & (1 << i)).nonzero?
|
372
372
|
count += 1
|
373
373
|
end
|
374
374
|
end
|
@@ -404,7 +404,13 @@ module Wardite
|
|
404
404
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
405
405
|
raise EvalError, "maybe empty or invalid stack"
|
406
406
|
end
|
407
|
-
|
407
|
+
result = left.value_s / right.value_s.to_f
|
408
|
+
iresult = (result >= 0 ? result.floor : result.ceil).to_i
|
409
|
+
if iresult >= (1 << (left.memsize - 1))
|
410
|
+
raise IntegerOverflow, "integer overflow"
|
411
|
+
end
|
412
|
+
|
413
|
+
runtime.stack.push(I64(iresult))
|
408
414
|
|
409
415
|
|
410
416
|
when :i64_div_u
|
@@ -420,7 +426,13 @@ module Wardite
|
|
420
426
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
421
427
|
raise EvalError, "maybe empty or invalid stack"
|
422
428
|
end
|
423
|
-
|
429
|
+
result = left.value_s % right.value_s
|
430
|
+
if result > 0 && left.value_s < 0
|
431
|
+
result = result - right.value_s
|
432
|
+
elsif result < 0 && left.value_s > 0
|
433
|
+
result = result - right.value_s
|
434
|
+
end
|
435
|
+
runtime.stack.push(I64(result))
|
424
436
|
|
425
437
|
|
426
438
|
when :i64_rem_u
|
@@ -460,8 +472,8 @@ module Wardite
|
|
460
472
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
461
473
|
raise EvalError, "maybe empty or invalid stack"
|
462
474
|
end
|
463
|
-
value = left.value << right.value
|
464
|
-
value %=
|
475
|
+
value = left.value << (right.value % right.memsize)
|
476
|
+
value %= 1 << right.memsize
|
465
477
|
|
466
478
|
runtime.stack.push(I64(value))
|
467
479
|
|
@@ -471,7 +483,7 @@ module Wardite
|
|
471
483
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
472
484
|
raise EvalError, "maybe empty or invalid stack"
|
473
485
|
end
|
474
|
-
value = left.value_s >> right.value
|
486
|
+
value = left.value_s >> (right.value % right.memsize)
|
475
487
|
runtime.stack.push(I64(value))
|
476
488
|
|
477
489
|
|
@@ -480,7 +492,7 @@ module Wardite
|
|
480
492
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
481
493
|
raise EvalError, "maybe empty or invalid stack"
|
482
494
|
end
|
483
|
-
value = left.value >> right.value
|
495
|
+
value = left.value >> (right.value % right.memsize)
|
484
496
|
runtime.stack.push(I64(value))
|
485
497
|
|
486
498
|
|
@@ -489,9 +501,10 @@ module Wardite
|
|
489
501
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
490
502
|
raise EvalError, "maybe empty or invalid stack"
|
491
503
|
end
|
492
|
-
|
493
|
-
|
494
|
-
|
504
|
+
k = (right.value % right.memsize)
|
505
|
+
rotated = left.value << k
|
506
|
+
rest = left.value & (I64::I64_MAX << (right.memsize - k))
|
507
|
+
value = rotated | (rest >> (right.memsize - k))
|
495
508
|
runtime.stack.push(I64(value))
|
496
509
|
|
497
510
|
|
@@ -500,9 +513,10 @@ module Wardite
|
|
500
513
|
if !right.is_a?(I64) || !left.is_a?(I64)
|
501
514
|
raise EvalError, "maybe empty or invalid stack"
|
502
515
|
end
|
503
|
-
|
504
|
-
|
505
|
-
|
516
|
+
k = (right.value % right.memsize)
|
517
|
+
rotated = left.value >> k
|
518
|
+
rest = left.value & (I64::I64_MAX >> (right.memsize - k))
|
519
|
+
value = rotated | (rest << (right.memsize - k))
|
506
520
|
runtime.stack.push(I64(value))
|
507
521
|
|
508
522
|
|
data/lib/wardite/load.rb
CHANGED
@@ -193,7 +193,7 @@ module Wardite
|
|
193
193
|
|
194
194
|
attr_accessor :kind #: Integer
|
195
195
|
|
196
|
-
attr_accessor :
|
196
|
+
attr_accessor :index #: Integer
|
197
197
|
end
|
198
198
|
|
199
199
|
attr_accessor :exports #: Hash[String, ExportDesc]
|
@@ -840,7 +840,7 @@ module Wardite
|
|
840
840
|
dest.add_desc do |desc|
|
841
841
|
desc.name = name
|
842
842
|
desc.kind = kind
|
843
|
-
desc.
|
843
|
+
desc.index = index
|
844
844
|
end
|
845
845
|
end
|
846
846
|
|
data/lib/wardite/value.rb
CHANGED
@@ -237,6 +237,10 @@ module Wardite
|
|
237
237
|
def inspect
|
238
238
|
"I32(#{value_s})"
|
239
239
|
end
|
240
|
+
|
241
|
+
def ==(other)
|
242
|
+
return self.class == other.class && self.value == other.value
|
243
|
+
end
|
240
244
|
end
|
241
245
|
|
242
246
|
class I64
|
@@ -400,6 +404,10 @@ module Wardite
|
|
400
404
|
def inspect
|
401
405
|
"I64(#{@value})"
|
402
406
|
end
|
407
|
+
|
408
|
+
def ==(other)
|
409
|
+
return self.class == other.class && self.value == other.value
|
410
|
+
end
|
403
411
|
end
|
404
412
|
|
405
413
|
class F32
|
@@ -601,6 +609,10 @@ module Wardite
|
|
601
609
|
def inspect
|
602
610
|
"F32(#{@value})"
|
603
611
|
end
|
612
|
+
|
613
|
+
def ==(other)
|
614
|
+
return self.class == other.class && self.value == other.value
|
615
|
+
end
|
604
616
|
end
|
605
617
|
|
606
618
|
class F64
|
@@ -800,5 +812,9 @@ module Wardite
|
|
800
812
|
def inspect
|
801
813
|
"F64(#{@value})"
|
802
814
|
end
|
815
|
+
|
816
|
+
def ==(other)
|
817
|
+
return self.class == other.class && self.value == other.value
|
818
|
+
end
|
803
819
|
end
|
804
820
|
end
|
data/lib/wardite/version.rb
CHANGED
data/lib/wardite.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "wardite/const"
|
|
7
7
|
require_relative "wardite/instruction"
|
8
8
|
require_relative "wardite/value"
|
9
9
|
require_relative "wardite/load"
|
10
|
+
require_relative "wardite/errors"
|
10
11
|
|
11
12
|
module Wardite
|
12
13
|
module Evaluator
|
@@ -258,10 +259,13 @@ module Wardite
|
|
258
259
|
if !callable?(name)
|
259
260
|
raise ::NoMethodError, "function #{name} not found"
|
260
261
|
end
|
261
|
-
kind, fn = @instance.exports[name.to_s]
|
262
|
+
kind, fn = @instance.exports.mappings[name.to_s]
|
262
263
|
if kind != 0
|
263
264
|
raise ::NoMethodError, "#{name} is not a function"
|
264
265
|
end
|
266
|
+
if !fn.is_a?(WasmFunction) && !fn.is_a?(ExternalFunction)
|
267
|
+
raise ::NoMethodError, "#{name} is not a function"
|
268
|
+
end
|
265
269
|
if fn.callsig.size != args.size
|
266
270
|
raise ArgumentError, "unmatch arg size"
|
267
271
|
end
|
@@ -727,10 +731,12 @@ module Wardite
|
|
727
731
|
end
|
728
732
|
|
729
733
|
rescue => e
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
+
if ENV["DEBUG"]
|
735
|
+
require "pp"
|
736
|
+
$stderr.puts "instance:::\n#{self.instance.pretty_inspect}"
|
737
|
+
$stderr.puts "frame:::\n#{frame.pretty_inspect}"
|
738
|
+
$stderr.puts "stack:::\n#{stack.pretty_inspect}"
|
739
|
+
end
|
734
740
|
raise e
|
735
741
|
end
|
736
742
|
|
@@ -1114,6 +1120,7 @@ module Wardite
|
|
1114
1120
|
end
|
1115
1121
|
|
1116
1122
|
@data += String.new("\0" * (delta * 64 * 1024))
|
1123
|
+
self.current = newsize
|
1117
1124
|
prev
|
1118
1125
|
end
|
1119
1126
|
|
@@ -1219,8 +1226,11 @@ module Wardite
|
|
1219
1226
|
end
|
1220
1227
|
end
|
1221
1228
|
|
1229
|
+
# @rbs!
|
1230
|
+
# type exportHandle = WasmFunction | ExternalFunction | Table | Global | Memory
|
1231
|
+
|
1222
1232
|
class Exports
|
1223
|
-
attr_accessor :mappings #: Hash[String, [Integer,
|
1233
|
+
attr_accessor :mappings #: Hash[String, [Integer, exportHandle]]
|
1224
1234
|
|
1225
1235
|
# @rbs export_section: ExportSection
|
1226
1236
|
# @rbs store: Store
|
@@ -1228,15 +1238,36 @@ module Wardite
|
|
1228
1238
|
def initialize(export_section, store)
|
1229
1239
|
@mappings = {}
|
1230
1240
|
export_section.exports.each_pair do |name, desc|
|
1231
|
-
|
1232
|
-
|
1241
|
+
case desc.kind
|
1242
|
+
when 0x0
|
1243
|
+
@mappings[name] = [desc.kind, store.funcs[desc.index]]
|
1244
|
+
when 0x1
|
1245
|
+
@mappings[name] = [desc.kind, store.tables[desc.index]]
|
1246
|
+
when 0x2
|
1247
|
+
@mappings[name] = [desc.kind, store.memories[desc.index]]
|
1248
|
+
when 0x3
|
1249
|
+
@mappings[name] = [desc.kind, store.globals[desc.index]]
|
1250
|
+
else
|
1251
|
+
end
|
1233
1252
|
end
|
1234
1253
|
end
|
1235
1254
|
|
1236
1255
|
# @rbs name: String
|
1237
|
-
# @rbs return:
|
1256
|
+
# @rbs return: exportHandle|nil
|
1238
1257
|
def [](name)
|
1239
|
-
@mappings[name]
|
1258
|
+
@mappings[name]&.[](1)
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
def respond_to?(name)
|
1262
|
+
!!self[name.to_s] || super
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
def method_missing(name, *_args)
|
1266
|
+
if self[name.to_s]
|
1267
|
+
self[name.to_s]
|
1268
|
+
else
|
1269
|
+
super
|
1270
|
+
end
|
1240
1271
|
end
|
1241
1272
|
end
|
1242
1273
|
|
data/scripts/gen_alu.rb
CHANGED
@@ -480,7 +480,7 @@ module GenAlu
|
|
480
480
|
digits = target.memsize
|
481
481
|
count = 0
|
482
482
|
digits.times do |i|
|
483
|
-
if (target.value & (1 << i)).
|
483
|
+
if (target.value & (1 << i)).nonzero?
|
484
484
|
count += 1
|
485
485
|
end
|
486
486
|
end
|
@@ -520,7 +520,13 @@ module GenAlu
|
|
520
520
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
521
521
|
raise EvalError, "maybe empty or invalid stack"
|
522
522
|
end
|
523
|
-
|
523
|
+
result = left.value_s / right.value_s.to_f
|
524
|
+
iresult = (result >= 0 ? result.floor : result.ceil).to_i
|
525
|
+
if iresult >= (1 << (left.memsize - 1))
|
526
|
+
raise IntegerOverflow, "integer overflow"
|
527
|
+
end
|
528
|
+
|
529
|
+
runtime.stack.push(${CLASS}(iresult))
|
524
530
|
RUBY
|
525
531
|
|
526
532
|
div_u: <<~RUBY,
|
@@ -547,7 +553,13 @@ module GenAlu
|
|
547
553
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
548
554
|
raise EvalError, "maybe empty or invalid stack"
|
549
555
|
end
|
550
|
-
|
556
|
+
result = left.value_s % right.value_s
|
557
|
+
if result > 0 && left.value_s < 0
|
558
|
+
result = result - right.value_s
|
559
|
+
elsif result < 0 && left.value_s > 0
|
560
|
+
result = result - right.value_s
|
561
|
+
end
|
562
|
+
runtime.stack.push(${CLASS}(result))
|
551
563
|
RUBY
|
552
564
|
|
553
565
|
rem_u: <<~RUBY,
|
@@ -592,8 +604,8 @@ module GenAlu
|
|
592
604
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
593
605
|
raise EvalError, "maybe empty or invalid stack"
|
594
606
|
end
|
595
|
-
value = left.value << right.value
|
596
|
-
value %=
|
607
|
+
value = left.value << (right.value % right.memsize)
|
608
|
+
value %= 1 << right.memsize
|
597
609
|
|
598
610
|
runtime.stack.push(${CLASS}(value))
|
599
611
|
RUBY
|
@@ -604,7 +616,7 @@ module GenAlu
|
|
604
616
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
605
617
|
raise EvalError, "maybe empty or invalid stack"
|
606
618
|
end
|
607
|
-
value = left.value_s >> right.value
|
619
|
+
value = left.value_s >> (right.value % right.memsize)
|
608
620
|
runtime.stack.push(${CLASS}(value))
|
609
621
|
RUBY
|
610
622
|
|
@@ -614,7 +626,7 @@ module GenAlu
|
|
614
626
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
615
627
|
raise EvalError, "maybe empty or invalid stack"
|
616
628
|
end
|
617
|
-
value = left.value >> right.value
|
629
|
+
value = left.value >> (right.value % right.memsize)
|
618
630
|
runtime.stack.push(${CLASS}(value))
|
619
631
|
RUBY
|
620
632
|
|
@@ -624,9 +636,10 @@ module GenAlu
|
|
624
636
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
625
637
|
raise EvalError, "maybe empty or invalid stack"
|
626
638
|
end
|
627
|
-
|
628
|
-
|
629
|
-
|
639
|
+
k = (right.value % right.memsize)
|
640
|
+
rotated = left.value << k
|
641
|
+
rest = left.value & (${CLASS}::${CLASS}_MAX << (right.memsize - k))
|
642
|
+
value = rotated | (rest >> (right.memsize - k))
|
630
643
|
runtime.stack.push(${CLASS}(value))
|
631
644
|
RUBY
|
632
645
|
|
@@ -636,9 +649,10 @@ module GenAlu
|
|
636
649
|
if !right.is_a?(${CLASS}) || !left.is_a?(${CLASS})
|
637
650
|
raise EvalError, "maybe empty or invalid stack"
|
638
651
|
end
|
639
|
-
|
640
|
-
|
641
|
-
|
652
|
+
k = (right.value % right.memsize)
|
653
|
+
rotated = left.value >> k
|
654
|
+
rest = left.value & (${CLASS}::${CLASS}_MAX >> (right.memsize - k))
|
655
|
+
value = rotated | (rest << (right.memsize - k))
|
642
656
|
runtime.stack.push(${CLASS}(value))
|
643
657
|
RUBY
|
644
658
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Generated from lib/wardite/errors.rb with RBS::Inline
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# rbs_inline: enabled
|
5
|
+
module Wardite
|
6
|
+
# basic error class.
|
7
|
+
class WebAssemblyError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class IntegerOverflow < WebAssemblyError
|
11
|
+
end
|
12
|
+
end
|
@@ -115,6 +115,8 @@ module Wardite
|
|
115
115
|
|
116
116
|
# I32#inspect shows signed value for convinience
|
117
117
|
def inspect: () -> untyped
|
118
|
+
|
119
|
+
def ==: (untyped other) -> untyped
|
118
120
|
end
|
119
121
|
|
120
122
|
class I64
|
@@ -196,6 +198,8 @@ module Wardite
|
|
196
198
|
|
197
199
|
# I64#inspect shows signed value
|
198
200
|
def inspect: () -> untyped
|
201
|
+
|
202
|
+
def ==: (untyped other) -> untyped
|
199
203
|
end
|
200
204
|
|
201
205
|
class F32
|
@@ -278,6 +282,8 @@ module Wardite
|
|
278
282
|
def trunc_sat_s: (to: Symbol) -> wasmValue
|
279
283
|
|
280
284
|
def inspect: () -> untyped
|
285
|
+
|
286
|
+
def ==: (untyped other) -> untyped
|
281
287
|
end
|
282
288
|
|
283
289
|
class F64
|
@@ -358,5 +364,7 @@ module Wardite
|
|
358
364
|
def trunc_sat_s: (to: Symbol) -> wasmValue
|
359
365
|
|
360
366
|
def inspect: () -> untyped
|
367
|
+
|
368
|
+
def ==: (untyped other) -> untyped
|
361
369
|
end
|
362
370
|
end
|
data/sig/generated/wardite.rbs
CHANGED
@@ -315,8 +315,10 @@ module Wardite
|
|
315
315
|
def result_size: () -> Integer
|
316
316
|
end
|
317
317
|
|
318
|
+
type exportHandle = WasmFunction | ExternalFunction | Table | Global | Memory
|
319
|
+
|
318
320
|
class Exports
|
319
|
-
attr_accessor mappings: Hash[String, [ Integer,
|
321
|
+
attr_accessor mappings: Hash[String, [ Integer, exportHandle ]]
|
320
322
|
|
321
323
|
# @rbs export_section: ExportSection
|
322
324
|
# @rbs store: Store
|
@@ -324,8 +326,12 @@ module Wardite
|
|
324
326
|
def initialize: (ExportSection export_section, Store store) -> void
|
325
327
|
|
326
328
|
# @rbs name: String
|
327
|
-
# @rbs return:
|
328
|
-
def []: (String name) ->
|
329
|
+
# @rbs return: exportHandle|nil
|
330
|
+
def []: (String name) -> (exportHandle | nil)
|
331
|
+
|
332
|
+
def respond_to?: (untyped name) -> untyped
|
333
|
+
|
334
|
+
def method_missing: (untyped name, *untyped _args) -> untyped
|
329
335
|
end
|
330
336
|
|
331
337
|
# TODO: common interface btw. WasmFunction and 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.
|
4
|
+
version: 0.5.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-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A pure-ruby webassembly runtime
|
14
14
|
email:
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/wardite/alu_i64.generated.rb
|
50
50
|
- lib/wardite/const.rb
|
51
51
|
- lib/wardite/convert.generated.rb
|
52
|
+
- lib/wardite/errors.rb
|
52
53
|
- lib/wardite/instruction.rb
|
53
54
|
- lib/wardite/leb128.rb
|
54
55
|
- lib/wardite/load.rb
|
@@ -66,6 +67,7 @@ files:
|
|
66
67
|
- sig/generated/wardite/alu_i64.generated.rbs
|
67
68
|
- sig/generated/wardite/const.rbs
|
68
69
|
- sig/generated/wardite/convert.generated.rbs
|
70
|
+
- sig/generated/wardite/errors.rbs
|
69
71
|
- sig/generated/wardite/instruction.rbs
|
70
72
|
- sig/generated/wardite/leb128.rbs
|
71
73
|
- sig/generated/wardite/load.rbs
|