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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d2b7f37620b7290c9a4c1fc558024d87cb7ad73bf217c7f7abbda3e6dfda266
4
- data.tar.gz: c239d24ee56a9dd80084abc11dcffad7a40edbc2c4644146c3cf91fa5b393ddd
3
+ metadata.gz: '02079b17ada50d21f00ea34c1830452eea21ff12a2fb6e9c5903d07cdca53d3a'
4
+ data.tar.gz: 9ab24caf2cc630593ce32ab652c8044a621f67ddce1cb70f75a1cd9e767b13e2
5
5
  SHA512:
6
- metadata.gz: 8a9369b5cb946190e8dd0f0fc5c17d383e9f5f168098332b78a4ed821398f0a6d7b631558ba6a8a32a14d9ebcce88dd23e8f05d32b73eb7d9e7aafa14a46b0f4
7
- data.tar.gz: 62f7f961e035a39203616793aa257d238a62760c70f6c9184070d3b79cc0615b829fbe5c4b89608838efe3db6b1a9e26332a125530992fcb41dcd64df8df3304
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:
@@ -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 > 6
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 > 6
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.read(1)&.ord
854
+ size = fetch_uleb128(@buf)
849
855
  @buf.read(size)
850
856
  nil
851
857
  end
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Wardite
5
- VERSION = "0.4.0" #: String
5
+ VERSION = "0.4.1" #: String
6
6
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wardite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio Kondo