Compare commits
1 commit
main
...
renovate/l
Author | SHA1 | Date | |
---|---|---|---|
74a604070e |
37 changed files with 250 additions and 407 deletions
166
.drone.yml
166
.drone.yml
|
@ -1,166 +0,0 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
environment:
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
ASDF_DIR: /root/.asdf
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
|
||||
steps:
|
||||
- name: restore ASDF cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .asdf
|
||||
|
||||
- name: restore bundle cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .bundle
|
||||
|
||||
- name: install dependencies
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
pull: "always"
|
||||
depends_on:
|
||||
- restore ASDF cache
|
||||
- restore bundle cache
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y wabt
|
||||
- rm -rf /var/cache/apt
|
||||
- mkdir -p bin
|
||||
- cp -v /usr/bin/wat2wasm bin/
|
||||
- cp -v /usr/bin/wasm-validate bin/
|
||||
- asdf_install
|
||||
- rm -rf .asdf/downloads
|
||||
- . $ASDF_DIR/asdf.sh
|
||||
- bundle install
|
||||
|
||||
- name: store ASDF cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .asdf
|
||||
|
||||
- name: store bundle cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .bundle
|
||||
|
||||
- name: store WABT cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: "wabt"
|
||||
mount:
|
||||
- bin
|
||||
|
||||
- name: rubocop
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
depends_on:
|
||||
- install dependencies
|
||||
commands:
|
||||
- . $ASDF_DIR/asdf.sh
|
||||
- bundle exec rubocop
|
||||
|
||||
- name: rspec
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
depends_on:
|
||||
- install dependencies
|
||||
commands:
|
||||
- export PATH=/drone/src/bin:$PATH
|
||||
- . $ASDF_DIR/asdf.sh
|
||||
- bundle exec rspec
|
32
.gitlab-ci.yml
Normal file
32
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
image: ruby:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
|
||||
before_script:
|
||||
- apt-get update && apt-get install wabt && rm -rf /var/cache/apt
|
||||
- bundle install
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- bundle exec rspec
|
||||
|
||||
rubocop:
|
||||
stage: test
|
||||
script:
|
||||
- bundle exec rspec
|
||||
|
||||
release:
|
||||
stage: release
|
||||
only:
|
||||
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
except:
|
||||
- branches
|
||||
script:
|
||||
- gem build
|
||||
artifacts:
|
||||
name: "wag-$CI_COMMIT_TAG.gem"
|
||||
paths:
|
||||
- wag-*.gem
|
|
@ -30,7 +30,3 @@ Style/Documentation:
|
|||
|
||||
Style/OptionalArguments:
|
||||
Enabled: false
|
||||
|
||||
AllCops:
|
||||
NewCops: enable
|
||||
SuggestExtensions: false
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
ruby 3.3.4
|
35
Gemfile.lock
35
Gemfile.lock
|
@ -1,7 +1,7 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
wag (0.2.1)
|
||||
wag (0.2.0)
|
||||
dry-inflector (~> 0.2.0)
|
||||
|
||||
GEM
|
||||
|
@ -9,12 +9,12 @@ GEM
|
|||
specs:
|
||||
ast (2.4.2)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.2.3)
|
||||
diff-lcs (1.5.1)
|
||||
concurrent-ruby (1.2.2)
|
||||
diff-lcs (1.5.0)
|
||||
dry-inflector (0.2.1)
|
||||
faker (3.4.2)
|
||||
faker (3.2.0)
|
||||
i18n (>= 1.8.11, < 2)
|
||||
i18n (1.14.5)
|
||||
i18n (1.14.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.6.3)
|
||||
method_source (1.0.0)
|
||||
|
@ -27,22 +27,22 @@ GEM
|
|||
method_source (~> 1.0)
|
||||
racc (1.7.1)
|
||||
rainbow (3.1.1)
|
||||
rake (13.2.1)
|
||||
rake (13.0.6)
|
||||
regexp_parser (2.8.1)
|
||||
rexml (3.2.5)
|
||||
rspec (3.13.0)
|
||||
rspec-core (~> 3.13.0)
|
||||
rspec-expectations (~> 3.13.0)
|
||||
rspec-mocks (~> 3.13.0)
|
||||
rspec-core (3.13.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-expectations (3.13.0)
|
||||
rspec (3.12.0)
|
||||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
rspec-mocks (~> 3.12.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-mocks (3.13.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-support (3.13.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.1)
|
||||
rubocop (1.52.1)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
|
@ -59,7 +59,6 @@ GEM
|
|||
unicode-display_width (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-22
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
|
|
12
README.md
12
README.md
|
@ -7,8 +7,8 @@ It is closely modeled after WAT, the WebAssembly text format, and at this stage
|
|||
generates WAT and compiles and validates it using [the WebAssembly Binary Toolkit][1].
|
||||
|
||||
Due to the flexibility of WAT this library is very flexible in what structures
|
||||
it allows you to create. Be aware that you can build modules which are not
|
||||
valid WASM. Always validate your modules by using `#to_wasm.valid?`.
|
||||
it allows you to create. Be aware that you can build modules which are not
|
||||
valid WASM. Always validate your modules by using `#to_wasm.valid?`.
|
||||
|
||||
## Keyword conflict
|
||||
|
||||
|
@ -20,7 +20,7 @@ of `public_send`, etc.
|
|||
## Folding
|
||||
|
||||
WAG supports generating both the "folded" and "unfolded" variants of the WAT
|
||||
language. As an example here are two implementations of Euclid's Greatest
|
||||
language. As an example here are two implementations of Euclid's Greatest
|
||||
Common Divisor algorithm:
|
||||
|
||||
### Example of unfolded generation
|
||||
|
@ -68,7 +68,6 @@ end
|
|||
```
|
||||
|
||||
### Example of folded generation
|
||||
|
||||
```ruby
|
||||
folded = WAG::Module.new.build do
|
||||
func(:gcd) do
|
||||
|
@ -155,6 +154,7 @@ Or install it yourself as:
|
|||
|
||||
$ gem install wag
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
||||
|
@ -163,7 +163,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|||
|
||||
## Contributing
|
||||
|
||||
Bug reports and pull requests are welcome at https://harton.dev/james/wag.
|
||||
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/jimsy/wag.
|
||||
|
||||
## License
|
||||
|
||||
|
@ -172,7 +172,7 @@ This software is licensed under the terms of the
|
|||
this package for the terms.
|
||||
|
||||
This license actively proscribes this software being used by and for some
|
||||
industries, countries and activities. If your usage of this software doesn't
|
||||
industries, countries and activities. If your usage of this software doesn't
|
||||
comply with the terms of this license, then [contact me](mailto:james@harton.nz)
|
||||
with the details of your use-case to organise the purchase of a license - the
|
||||
cost of which may include a donation to a suitable charity or NGO.
|
||||
|
|
|
@ -12,7 +12,7 @@ module WAG
|
|||
end
|
||||
|
||||
def to_sexpr
|
||||
[:data, [:'i32.const', offset], value]
|
||||
[:data, [:"i32.const", offset], value]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ module WAG
|
|||
end
|
||||
|
||||
def to_sexpr
|
||||
[:elem, [:'i32.const', table_id]].concat(labels.map(&:to_sexpr))
|
||||
[:elem, [:"i32.const", table_id]].concat(labels.map(&:to_sexpr))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ module WAG
|
|||
@desc
|
||||
end
|
||||
|
||||
def table(number, type = :funcref, &block)
|
||||
def table(number, type = :anyfunc, &block)
|
||||
@desc = Table.new(number, type)
|
||||
@desc.instance_exec(&block) if block
|
||||
@desc
|
||||
|
|
|
@ -29,7 +29,7 @@ module WAG
|
|||
@desc
|
||||
end
|
||||
|
||||
def table(number, type = :funcref, &block)
|
||||
def table(number, type = :anyfunc, &block)
|
||||
@desc = Table.new(number, type)
|
||||
@desc.instance_exec(&block) if block
|
||||
@desc
|
||||
|
|
|
@ -8,7 +8,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -8,7 +8,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -8,7 +8,6 @@ module WAG
|
|||
|
||||
def initialize(*labels)
|
||||
@labels = labels.map { |label| WAG::Label.from(label) }
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -8,7 +8,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(literal)
|
||||
@literal = literal.to_f
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(literal)
|
||||
@literal = literal.to_f
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(literal)
|
||||
@literal = literal.to_i
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(literal)
|
||||
@literal = literal.to_i
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -9,7 +9,6 @@ module WAG
|
|||
|
||||
def initialize(label)
|
||||
@label = WAG::Label.from(label)
|
||||
super()
|
||||
end
|
||||
|
||||
def to_sexpr
|
||||
|
|
|
@ -16,8 +16,8 @@ module WAG
|
|||
@types = []
|
||||
end
|
||||
|
||||
def build(&)
|
||||
instance_exec(&)
|
||||
def build(&block)
|
||||
instance_exec(&block)
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -76,14 +76,14 @@ module WAG
|
|||
func
|
||||
end
|
||||
|
||||
def table(elements, type = :funcref, &block)
|
||||
def table(elements, type = :anyfunc, &block)
|
||||
table = Table.new(elements, type)
|
||||
@tables << table
|
||||
table.instance_exec(&block) if block
|
||||
table
|
||||
end
|
||||
|
||||
def to_sexpr # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
||||
def to_sexpr # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
||||
mod = [:module]
|
||||
mod.concat(@imports.map(&:to_sexpr))
|
||||
mod.concat(@exports.map(&:to_sexpr))
|
||||
|
|
|
@ -5,7 +5,7 @@ module WAG
|
|||
include WAG::Encodable
|
||||
attr_reader :elements, :type
|
||||
|
||||
def initialize(elements, type = :funcref)
|
||||
def initialize(elements, type = :anyfunc)
|
||||
@elements = elements
|
||||
@type = type
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module WAG
|
||||
VERSION = '0.2.1'
|
||||
VERSION = '0.2.0'
|
||||
end
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"local>renovate/renovate"
|
||||
]
|
||||
"extends": ["gitlab>jimsy/renovate"]
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ RSpec.describe 'WAT code generation' do
|
|||
|
||||
memory(:mem, 1)
|
||||
|
||||
table(16, :funcref)
|
||||
table(16, :anyfunc)
|
||||
|
||||
elem(0, :dead, :dead, :dead, :alive, :dead, :dead, :dead, :dead,
|
||||
:dead, :dead, :dead, :alive, :alive, :dead, :dead, :dead,
|
||||
|
|
|
@ -10,6 +10,6 @@ RSpec.describe WAG::Data do
|
|||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
|
||||
it { is_expected.to eq [:data, [:'i32.const', offset], value] }
|
||||
it { is_expected.to eq [:data, [:"i32.const", offset], value] }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,12 +11,12 @@ RSpec.describe WAG::Element do
|
|||
|
||||
context 'When the element has no labels' do
|
||||
let(:labels) { [] }
|
||||
it { is_expected.to eq [:elem, [:'i32.const', table_id]] }
|
||||
it { is_expected.to eq [:elem, [:"i32.const", table_id]] }
|
||||
end
|
||||
|
||||
context 'When the element has no labels' do
|
||||
let(:labels) { %i[l0 l1 l2] }
|
||||
it { is_expected.to eq [:elem, [:'i32.const', table_id], :$l0, :$l1, :$l2] }
|
||||
it { is_expected.to eq [:elem, [:"i32.const", table_id], :$l0, :$l1, :$l2] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,12 +19,12 @@ RSpec.describe WAG::Export do
|
|||
|
||||
describe 'When exporting a table' do
|
||||
before do
|
||||
export.table(1, :funcref)
|
||||
export.table(1, :anyfunc)
|
||||
end
|
||||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:export, 'marty', [:table, 1, :funcref]] }
|
||||
it { is_expected.to eq [:export, 'marty', [:table, 1, :anyfunc]] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ RSpec.describe WAG::Function do
|
|||
|
||||
context 'When the function has a body' do
|
||||
before { function.i64.const(13) }
|
||||
it { is_expected.to eq [:func, "$#{label}".to_sym, [:'i64.const', 13]] }
|
||||
it { is_expected.to eq [:func, "$#{label}".to_sym, [:"i64.const", 13]] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,12 +19,12 @@ RSpec.describe WAG::Import do
|
|||
|
||||
describe 'When importing a table' do
|
||||
before do
|
||||
import.table(1, :funcref)
|
||||
import.table(1, :anyfunc)
|
||||
end
|
||||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :funcref]] }
|
||||
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :anyfunc]] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,177 +17,177 @@ INSTRUCTIONS = { unreachable: 0x00,
|
|||
call_indirect: 0x11,
|
||||
drop: 0x1a,
|
||||
select: 0x1b,
|
||||
'local.get': 0x20,
|
||||
'local.set': 0x21,
|
||||
'local.tee': 0x22,
|
||||
'global.get': 0x23,
|
||||
'global.set': 0x24,
|
||||
'i32.load': 0x28,
|
||||
'i64.load': 0x29,
|
||||
'f32.load': 0x2a,
|
||||
'f64.load': 0x2b,
|
||||
'i32.load8_s': 0x2c,
|
||||
'i32.load8_u': 0x2d,
|
||||
'i32.load16_s': 0x2e,
|
||||
'i32.load16_u': 0x2f,
|
||||
'i64.load8_s': 0x30,
|
||||
'i64.load8_u': 0x31,
|
||||
'i64.load16_s': 0x32,
|
||||
'i64.load16_u': 0x33,
|
||||
'i64.load32_s': 0x34,
|
||||
'i64.load32_u': 0x35,
|
||||
'i32.store': 0x36,
|
||||
'i64.store': 0x37,
|
||||
'f32.store': 0x38,
|
||||
'f64.store': 0x39,
|
||||
'i32.store8': 0x3a,
|
||||
'i32.store16': 0x3b,
|
||||
'i64.store8': 0x3c,
|
||||
'i64.store16': 0x3d,
|
||||
'i64.store32': 0x3e,
|
||||
'memory.size': 0x3f,
|
||||
'memory.grow': 0x40,
|
||||
'i32.const': 0x41,
|
||||
'i64.const': 0x42,
|
||||
'f32.const': 0x43,
|
||||
'f64.const': 0x44,
|
||||
'i32.eqz': 0x45,
|
||||
'i32.eq': 0x46,
|
||||
'i32.ne': 0x47,
|
||||
'i32.lt_s': 0x48,
|
||||
'i32.lt_u': 0x49,
|
||||
'i32.gt_s': 0x4a,
|
||||
'i32.gt_u': 0x4b,
|
||||
'i32.le_s': 0x4c,
|
||||
'i32.le_u': 0x4d,
|
||||
'i32.ge_s': 0x4e,
|
||||
'i32.ge_u': 0x4f,
|
||||
'i64.eqz': 0x50,
|
||||
'i64.eq': 0x51,
|
||||
'i64.ne': 0x52,
|
||||
'i64.lt_s': 0x53,
|
||||
'i64.lt_u': 0x54,
|
||||
'i64.gt_s': 0x55,
|
||||
'i64.gt_u': 0x56,
|
||||
'i64.le_s': 0x57,
|
||||
'i64.le_u': 0x58,
|
||||
'i64.ge_s': 0x59,
|
||||
'i64.ge_u': 0x5a,
|
||||
'f32.eq': 0x5b,
|
||||
'f32.ne': 0x5c,
|
||||
'f32.lt': 0x5d,
|
||||
'f32.gt': 0x5e,
|
||||
'f32.le': 0x5f,
|
||||
'f32.ge': 0x60,
|
||||
'f64.eq': 0x61,
|
||||
'f64.ne': 0x62,
|
||||
'f64.lt': 0x63,
|
||||
'f64.gt': 0x64,
|
||||
'f64.le': 0x65,
|
||||
'f64.ge': 0x66,
|
||||
'i32.clz': 0x67,
|
||||
'i32.ctz': 0x68,
|
||||
'i32.popcnt': 0x69,
|
||||
'i32.add': 0x6a,
|
||||
'i32.sub': 0x6b,
|
||||
'i32.mul': 0x6c,
|
||||
'i32.div_s': 0x6d,
|
||||
'i32.div_u': 0x6e,
|
||||
'i32.rem_s': 0x6f,
|
||||
'i32.rem_u': 0x70,
|
||||
'i32.and': 0x71,
|
||||
'i32.or': 0x72,
|
||||
'i32.xor': 0x73,
|
||||
'i32.shl': 0x74,
|
||||
'i32.shr_s': 0x75,
|
||||
'i32.shr_u': 0x76,
|
||||
'i32.rotl': 0x77,
|
||||
'i32.rotr': 0x78,
|
||||
'i64.clz': 0x79,
|
||||
'i64.ctz': 0x7a,
|
||||
'i64.popcnt': 0x7b,
|
||||
'i64.add': 0x7c,
|
||||
'i64.sub': 0x7d,
|
||||
'i64.mul': 0x7e,
|
||||
'i64.div_s': 0x7f,
|
||||
'i64.div_u': 0x80,
|
||||
'i64.rem_s': 0x81,
|
||||
'i64.rem_u': 0x82,
|
||||
'i64.and': 0x83,
|
||||
'i64.or': 0x84,
|
||||
'i64.xor': 0x85,
|
||||
'i64.shl': 0x86,
|
||||
'i64.shr_s': 0x87,
|
||||
'i64.shr_u': 0x88,
|
||||
'i64.rotl': 0x89,
|
||||
'i64.rotr': 0x8a,
|
||||
'f32.abs': 0x8b,
|
||||
'f32.neg': 0x8c,
|
||||
'f32.ceil': 0x8d,
|
||||
'f32.floor': 0x8e,
|
||||
'f32.trunc': 0x8f,
|
||||
'f32.nearest': 0x90,
|
||||
'f32.sqrt': 0x91,
|
||||
'f32.add': 0x92,
|
||||
'f32.sub': 0x93,
|
||||
'f32.mul': 0x94,
|
||||
'f32.div': 0x95,
|
||||
'f32.min': 0x96,
|
||||
'f32.max': 0x97,
|
||||
'f32.copysign': 0x98,
|
||||
'f64.abs': 0x99,
|
||||
'f64.neg': 0x9a,
|
||||
'f64.ceil': 0x9b,
|
||||
'f64.floor': 0x9c,
|
||||
'f64.trunc': 0x9d,
|
||||
'f64.nearest': 0x9e,
|
||||
'f64.sqrt': 0x9f,
|
||||
'f64.add': 0xa0,
|
||||
'f64.sub': 0xa1,
|
||||
'f64.mul': 0xa2,
|
||||
'f64.div': 0xa3,
|
||||
'f64.min': 0xa4,
|
||||
'f64.max': 0xa5,
|
||||
'f64.copysign': 0xa6,
|
||||
'i32.wrap_i64': 0xa7,
|
||||
'i32.trunc_f32_s': 0xa8,
|
||||
'i32.trunc_f32_u': 0xa9,
|
||||
'i32.trunc_f64_s': 0xaa,
|
||||
'i32.trunc_f64_u': 0xab,
|
||||
'i64.extend_i32_s': 0xac,
|
||||
'i64.extend_i32_u': 0xad,
|
||||
'i64.trunc_f32_s': 0xae,
|
||||
'i64.trunc_f32_u': 0xaf,
|
||||
'i64.trunc_f64_s': 0xb0,
|
||||
'i64.trunc_f64_u': 0xb1,
|
||||
'f32.convert_i32_s': 0xb2,
|
||||
'f32.convert_i32_u': 0xb3,
|
||||
'f32.convert_i64_s': 0xb4,
|
||||
'f32.convert_i64_u': 0xb5,
|
||||
'f32.demote_f64': 0xb6,
|
||||
'f64.convert_i32_s': 0xb7,
|
||||
'f64.convert_i32_u': 0xb8,
|
||||
'f64.convert_i64_s': 0xb9,
|
||||
'f64.convert_i64_u': 0xba,
|
||||
'f64.promote_f32': 0xbb,
|
||||
'i32.reinterpret_f32': 0xbc,
|
||||
'i64.reinterpret_f64': 0xbd,
|
||||
'f32.reinterpret_i32': 0xbe,
|
||||
'f64.reinterpret_i64': 0xbf }.freeze
|
||||
"local.get": 0x20,
|
||||
"local.set": 0x21,
|
||||
"local.tee": 0x22,
|
||||
"global.get": 0x23,
|
||||
"global.set": 0x24,
|
||||
"i32.load": 0x28,
|
||||
"i64.load": 0x29,
|
||||
"f32.load": 0x2a,
|
||||
"f64.load": 0x2b,
|
||||
"i32.load8_s": 0x2c,
|
||||
"i32.load8_u": 0x2d,
|
||||
"i32.load16_s": 0x2e,
|
||||
"i32.load16_u": 0x2f,
|
||||
"i64.load8_s": 0x30,
|
||||
"i64.load8_u": 0x31,
|
||||
"i64.load16_s": 0x32,
|
||||
"i64.load16_u": 0x33,
|
||||
"i64.load32_s": 0x34,
|
||||
"i64.load32_u": 0x35,
|
||||
"i32.store": 0x36,
|
||||
"i64.store": 0x37,
|
||||
"f32.store": 0x38,
|
||||
"f64.store": 0x39,
|
||||
"i32.store8": 0x3a,
|
||||
"i32.store16": 0x3b,
|
||||
"i64.store8": 0x3c,
|
||||
"i64.store16": 0x3d,
|
||||
"i64.store32": 0x3e,
|
||||
"memory.size": 0x3f,
|
||||
"memory.grow": 0x40,
|
||||
"i32.const": 0x41,
|
||||
"i64.const": 0x42,
|
||||
"f32.const": 0x43,
|
||||
"f64.const": 0x44,
|
||||
"i32.eqz": 0x45,
|
||||
"i32.eq": 0x46,
|
||||
"i32.ne": 0x47,
|
||||
"i32.lt_s": 0x48,
|
||||
"i32.lt_u": 0x49,
|
||||
"i32.gt_s": 0x4a,
|
||||
"i32.gt_u": 0x4b,
|
||||
"i32.le_s": 0x4c,
|
||||
"i32.le_u": 0x4d,
|
||||
"i32.ge_s": 0x4e,
|
||||
"i32.ge_u": 0x4f,
|
||||
"i64.eqz": 0x50,
|
||||
"i64.eq": 0x51,
|
||||
"i64.ne": 0x52,
|
||||
"i64.lt_s": 0x53,
|
||||
"i64.lt_u": 0x54,
|
||||
"i64.gt_s": 0x55,
|
||||
"i64.gt_u": 0x56,
|
||||
"i64.le_s": 0x57,
|
||||
"i64.le_u": 0x58,
|
||||
"i64.ge_s": 0x59,
|
||||
"i64.ge_u": 0x5a,
|
||||
"f32.eq": 0x5b,
|
||||
"f32.ne": 0x5c,
|
||||
"f32.lt": 0x5d,
|
||||
"f32.gt": 0x5e,
|
||||
"f32.le": 0x5f,
|
||||
"f32.ge": 0x60,
|
||||
"f64.eq": 0x61,
|
||||
"f64.ne": 0x62,
|
||||
"f64.lt": 0x63,
|
||||
"f64.gt": 0x64,
|
||||
"f64.le": 0x65,
|
||||
"f64.ge": 0x66,
|
||||
"i32.clz": 0x67,
|
||||
"i32.ctz": 0x68,
|
||||
"i32.popcnt": 0x69,
|
||||
"i32.add": 0x6a,
|
||||
"i32.sub": 0x6b,
|
||||
"i32.mul": 0x6c,
|
||||
"i32.div_s": 0x6d,
|
||||
"i32.div_u": 0x6e,
|
||||
"i32.rem_s": 0x6f,
|
||||
"i32.rem_u": 0x70,
|
||||
"i32.and": 0x71,
|
||||
"i32.or": 0x72,
|
||||
"i32.xor": 0x73,
|
||||
"i32.shl": 0x74,
|
||||
"i32.shr_s": 0x75,
|
||||
"i32.shr_u": 0x76,
|
||||
"i32.rotl": 0x77,
|
||||
"i32.rotr": 0x78,
|
||||
"i64.clz": 0x79,
|
||||
"i64.ctz": 0x7a,
|
||||
"i64.popcnt": 0x7b,
|
||||
"i64.add": 0x7c,
|
||||
"i64.sub": 0x7d,
|
||||
"i64.mul": 0x7e,
|
||||
"i64.div_s": 0x7f,
|
||||
"i64.div_u": 0x80,
|
||||
"i64.rem_s": 0x81,
|
||||
"i64.rem_u": 0x82,
|
||||
"i64.and": 0x83,
|
||||
"i64.or": 0x84,
|
||||
"i64.xor": 0x85,
|
||||
"i64.shl": 0x86,
|
||||
"i64.shr_s": 0x87,
|
||||
"i64.shr_u": 0x88,
|
||||
"i64.rotl": 0x89,
|
||||
"i64.rotr": 0x8a,
|
||||
"f32.abs": 0x8b,
|
||||
"f32.neg": 0x8c,
|
||||
"f32.ceil": 0x8d,
|
||||
"f32.floor": 0x8e,
|
||||
"f32.trunc": 0x8f,
|
||||
"f32.nearest": 0x90,
|
||||
"f32.sqrt": 0x91,
|
||||
"f32.add": 0x92,
|
||||
"f32.sub": 0x93,
|
||||
"f32.mul": 0x94,
|
||||
"f32.div": 0x95,
|
||||
"f32.min": 0x96,
|
||||
"f32.max": 0x97,
|
||||
"f32.copysign": 0x98,
|
||||
"f64.abs": 0x99,
|
||||
"f64.neg": 0x9a,
|
||||
"f64.ceil": 0x9b,
|
||||
"f64.floor": 0x9c,
|
||||
"f64.trunc": 0x9d,
|
||||
"f64.nearest": 0x9e,
|
||||
"f64.sqrt": 0x9f,
|
||||
"f64.add": 0xa0,
|
||||
"f64.sub": 0xa1,
|
||||
"f64.mul": 0xa2,
|
||||
"f64.div": 0xa3,
|
||||
"f64.min": 0xa4,
|
||||
"f64.max": 0xa5,
|
||||
"f64.copysign": 0xa6,
|
||||
"i32.wrap_i64": 0xa7,
|
||||
"i32.trunc_f32_s": 0xa8,
|
||||
"i32.trunc_f32_u": 0xa9,
|
||||
"i32.trunc_f64_s": 0xaa,
|
||||
"i32.trunc_f64_u": 0xab,
|
||||
"i64.extend_i32_s": 0xac,
|
||||
"i64.extend_i32_u": 0xad,
|
||||
"i64.trunc_f32_s": 0xae,
|
||||
"i64.trunc_f32_u": 0xaf,
|
||||
"i64.trunc_f64_s": 0xb0,
|
||||
"i64.trunc_f64_u": 0xb1,
|
||||
"f32.convert_i32_s": 0xb2,
|
||||
"f32.convert_i32_u": 0xb3,
|
||||
"f32.convert_i64_s": 0xb4,
|
||||
"f32.convert_i64_u": 0xb5,
|
||||
"f32.demote_f64": 0xb6,
|
||||
"f64.convert_i32_s": 0xb7,
|
||||
"f64.convert_i32_u": 0xb8,
|
||||
"f64.convert_i64_s": 0xb9,
|
||||
"f64.convert_i64_u": 0xba,
|
||||
"f64.promote_f32": 0xbb,
|
||||
"i32.reinterpret_f32": 0xbc,
|
||||
"i64.reinterpret_f64": 0xbd,
|
||||
"f32.reinterpret_i32": 0xbe,
|
||||
"f64.reinterpret_i64": 0xbf }.freeze
|
||||
|
||||
REQUIRED_ARGS = {
|
||||
br: [:label],
|
||||
br_if: [:label],
|
||||
call: [:label],
|
||||
'local.get': [:label],
|
||||
'local.set': [:label],
|
||||
'local.tee': [:label],
|
||||
'global.get': [:label],
|
||||
'global.set': [:label],
|
||||
'i32.const': [13],
|
||||
'i64.const': [13],
|
||||
'f32.const': [13.0],
|
||||
'f64.const': [13.0]
|
||||
"local.get": [:label],
|
||||
"local.set": [:label],
|
||||
"local.tee": [:label],
|
||||
"global.get": [:label],
|
||||
"global.set": [:label],
|
||||
"i32.const": [13],
|
||||
"i64.const": [13],
|
||||
"f32.const": [13.0],
|
||||
"f64.const": [13.0]
|
||||
}.freeze
|
||||
|
||||
INSTRUCTIONS.each do |(instruction_name, op_code)|
|
||||
|
|
|
@ -78,7 +78,7 @@ RSpec.describe WAG::Module do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:module, [:elem, [:'i32.const', 1], :$foo1, :$foo2]] }
|
||||
it { is_expected.to eq [:module, [:elem, [:"i32.const", 1], :$foo1, :$foo2]] }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe WAG::Module do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:module, [:data, [:'i32.const', 16], 'Hello World']] }
|
||||
it { is_expected.to eq [:module, [:data, [:"i32.const", 16], 'Hello World']] }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -115,7 +115,7 @@ RSpec.describe WAG::Module do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:module, [:table, 16, :funcref]] }
|
||||
it { is_expected.to eq [:module, [:table, 16, :anyfunc]] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ RSpec.describe WAG::Table do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:table, elements, :funcref] }
|
||||
it { is_expected.to eq [:table, elements, :anyfunc] }
|
||||
end
|
||||
end
|
||||
|
|
11
wag.gemspec
11
wag.gemspec
|
@ -6,19 +6,19 @@ Gem::Specification.new do |spec|
|
|||
spec.name = 'wag'
|
||||
spec.version = WAG::VERSION
|
||||
spec.authors = ['James Harton']
|
||||
spec.email = ['james@harton.nz']
|
||||
spec.email = ['james@automat.nz']
|
||||
|
||||
spec.summary = 'WebAssembly Generator'
|
||||
spec.description = 'Generate and compile WebAssembly code from Ruby'
|
||||
spec.homepage = 'https://harton.dev/james/wag'
|
||||
spec.homepage = 'https://gitlab.com/jimsy/wag'
|
||||
spec.license = 'Hippocratic'
|
||||
spec.required_ruby_version = Gem::Requirement.new('~> 3.3')
|
||||
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
||||
|
||||
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
||||
|
||||
spec.metadata['homepage_uri'] = spec.homepage
|
||||
spec.metadata['source_code_uri'] = 'https://harton.dev/james/wag'
|
||||
spec.metadata['changelog_uri'] = 'https://harton.dev/james/wag'
|
||||
spec.metadata['source_code_uri'] = 'https://gitlab.com/jimsy/wag'
|
||||
spec.metadata['changelog_uri'] = 'https://gitlab.com/jimsy/wag'
|
||||
|
||||
# Specify which files should be added to the gem when it is released. The `git
|
||||
# ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||
|
@ -32,5 +32,4 @@ Gem::Specification.new do |spec|
|
|||
spec.require_paths = ['lib']
|
||||
|
||||
spec.add_runtime_dependency('dry-inflector', '~> 0.2.0')
|
||||
spec.metadata['rubygems_mfa_required'] = 'true'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue