wardite 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/wardite/leb128.rb +5 -4
- data/lib/wardite/load.rb +8 -2
- data/lib/wardite/version.rb +1 -1
- data/sig/generated/wardite/leb128.rbs +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02079b17ada50d21f00ea34c1830452eea21ff12a2fb6e9c5903d07cdca53d3a'
|
4
|
+
data.tar.gz: 9ab24caf2cc630593ce32ab652c8044a621f67ddce1cb70f75a1cd9e767b13e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88054ffba3884002ea3ff7c63b21a38ff41a93f2e641ec7b82cf39f47e7df7672c5c6412f4efd1ca9feb6e222aaaadf98e67a40810c8ed213046df348aac8f79
|
7
|
+
data.tar.gz: 1c5b8765bff6ae42eb00c696efd8af2c6b892911d52fc68a1124fb3804419f121f886ba416b6b39b3183afa22e1f6aadf730681c004f254796c5e6934ab39da1
|
data/README.md
CHANGED
@@ -7,6 +7,21 @@ A pure-ruby webassembly runtime.
|
|
7
7
|
- [x] Fully typed by RBS (with the aid of [rbs-inline](https://github.com/soutaro/rbs-inline))
|
8
8
|
- [ ] WASI (p1) support
|
9
9
|
|
10
|
+
## Supported Instructions
|
11
|
+
|
12
|
+
ref: https://webassembly.github.io/spec/core/binary/instructions.html
|
13
|
+
|
14
|
+
- [x] Control Instructions
|
15
|
+
- [x] Parametric Instructions
|
16
|
+
- [x] Variable Instructions
|
17
|
+
- [ ] Table Instructions
|
18
|
+
- [x] Memory Instructions (except `data.drop`)
|
19
|
+
- [x] Numeric Instructions (`0x41 ... 0xC4`)
|
20
|
+
- [x] Numeric Instructions (`0xFC` Operations)
|
21
|
+
- [ ] Reference Instructions
|
22
|
+
- [ ] Vector Instructions
|
23
|
+
- [x] end `0x0B`
|
24
|
+
|
10
25
|
## Installation
|
11
26
|
|
12
27
|
Install the gem and add to the application's Gemfile by executing:
|
data/lib/wardite/leb128.rb
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
module Wardite
|
3
3
|
module Leb128Helper
|
4
4
|
# @rbs buf: File|StringIO
|
5
|
+
# @rbs max_level: Integer
|
5
6
|
# @rbs return: Integer
|
6
|
-
def fetch_uleb128(buf)
|
7
|
+
def fetch_uleb128(buf, max_level: 8)
|
7
8
|
dest = 0
|
8
9
|
level = 0
|
9
10
|
while b = buf.read(1)
|
@@ -18,7 +19,7 @@ module Wardite
|
|
18
19
|
return dest
|
19
20
|
end
|
20
21
|
|
21
|
-
if level >
|
22
|
+
if level > max_level
|
22
23
|
break
|
23
24
|
end
|
24
25
|
level += 1
|
@@ -29,7 +30,7 @@ module Wardite
|
|
29
30
|
|
30
31
|
# @rbs buf: File|StringIO
|
31
32
|
# @rbs return: Integer
|
32
|
-
def fetch_sleb128(buf)
|
33
|
+
def fetch_sleb128(buf, max_level: 8)
|
33
34
|
dest = 0
|
34
35
|
level = 0
|
35
36
|
while b = buf.read(1)
|
@@ -44,7 +45,7 @@ module Wardite
|
|
44
45
|
break
|
45
46
|
end
|
46
47
|
|
47
|
-
if level >
|
48
|
+
if level > max_level
|
48
49
|
raise "unreachable! debug: dest = #{dest} level = #{level}"
|
49
50
|
end
|
50
51
|
level += 1
|
data/lib/wardite/load.rb
CHANGED
@@ -630,7 +630,7 @@ module Wardite
|
|
630
630
|
when :i32
|
631
631
|
operand << fetch_sleb128(buf)
|
632
632
|
when :i64
|
633
|
-
operand << fetch_sleb128(buf)
|
633
|
+
operand << fetch_sleb128(buf, max_level: 16)
|
634
634
|
when :f32
|
635
635
|
data = buf.read 4
|
636
636
|
if !data || data.size != 4
|
@@ -667,6 +667,12 @@ module Wardite
|
|
667
667
|
end
|
668
668
|
|
669
669
|
dest
|
670
|
+
rescue => e
|
671
|
+
require "pp"
|
672
|
+
$stderr.puts "parsed:::"
|
673
|
+
$stderr.puts "#{dest.pretty_inspect}"
|
674
|
+
$stderr.puts "code = #{code}"
|
675
|
+
raise e
|
670
676
|
end
|
671
677
|
|
672
678
|
# @rbs c: String
|
@@ -845,7 +851,7 @@ module Wardite
|
|
845
851
|
# @rbs return: nil
|
846
852
|
def self.unimplemented_skip_section(code)
|
847
853
|
$stderr.puts "warning: unimplemented section: 0x0#{code}"
|
848
|
-
size = @buf
|
854
|
+
size = fetch_uleb128(@buf)
|
849
855
|
@buf.read(size)
|
850
856
|
nil
|
851
857
|
end
|
data/lib/wardite/version.rb
CHANGED
@@ -4,11 +4,12 @@
|
|
4
4
|
module Wardite
|
5
5
|
module Leb128Helper
|
6
6
|
# @rbs buf: File|StringIO
|
7
|
+
# @rbs max_level: Integer
|
7
8
|
# @rbs return: Integer
|
8
|
-
def fetch_uleb128: (File | StringIO buf) -> Integer
|
9
|
+
def fetch_uleb128: (File | StringIO buf, ?max_level: Integer) -> Integer
|
9
10
|
|
10
11
|
# @rbs buf: File|StringIO
|
11
12
|
# @rbs return: Integer
|
12
|
-
def fetch_sleb128: (File | StringIO buf) -> Integer
|
13
|
+
def fetch_sleb128: (File | StringIO buf, ?max_level: untyped) -> Integer
|
13
14
|
end
|
14
15
|
end
|