Compare commits

...

24 commits

Author SHA1 Message Date
d18b752c8c chore(deps): update dependency ruby to v3.3.4
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-07-17 16:29:54 +12:00
47b5b42f84 chore(deps): update dependency faker to v3.4.2
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-07-17 15:30:21 +12:00
865dc83cd9 chore(deps): update dependency ruby to v3.3.3 (#204)
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ruby](https://www.ruby-lang.org) ([source](https://github.com/ruby/ruby)) | patch | `3.3.1` -> `3.3.3` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIwLjAuMC1zZW1hbnRpYy1yZWxlYXNlIiwidXBkYXRlZEluVmVyIjoiMC4wLjAtc2VtYW50aWMtcmVsZWFzZSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: #204
Co-authored-by: Renovate Bot <bot@harton.nz>
Co-committed-by: Renovate Bot <bot@harton.nz>
2024-06-23 20:49:07 +12:00
0b27fad3a1 chore(deps): update dependency ruby to v3.3.1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-05-29 12:53:09 +12:00
e283b61db4 chore(deps): update dependency faker to v3.4.1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-05-29 12:41:25 +12:00
ced57137ea chore(deps): update dependency rake to v13.2.1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-04-05 19:33:43 +13:00
839903ed18 chore(deps): update dependency faker to v3.3.1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-04-03 03:25:06 +13:00
80ab33901f chore(deps): update dependency rake to v13.2.0
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-04-02 15:26:53 +13:00
8f42232c5f chore(deps): update dependency faker to v3.3.0
All checks were successful
continuous-integration/drone Build is passing
continuous-integration/drone/push Build is passing
2024-03-27 11:30:21 +13:00
7043302f05 chore: Update forgejo hostname.
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-05 14:56:29 +13:00
1b05daa9d0 chore: Update required_ruby_version in gemspec.
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-02-05 09:27:58 +13:00
88e102734e chore(deps): update dependency rspec to v3.13.0
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2024-02-05 02:20:30 +13:00
c5fd045c5c chore(deps): update dependency ruby to v3.3.0 (#195)
Some checks failed
continuous-integration/drone/push Build is failing
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ruby](https://www.ruby-lang.org) ([source](https://github.com/ruby/ruby)) | minor | `3.2.2` -> `3.3.0` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEwNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Reviewed-on: https://code.harton.nz/james/wag/pulls/195
Co-authored-by: Renovate Bot <bot@harton.nz>
Co-committed-by: Renovate Bot <bot@harton.nz>
2024-01-15 10:39:11 +13:00
29f3f5f0d8 chore(deps): update dependency faker to v3.2.3
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-01-13 14:13:59 +13:00
5a19f80ec8 chore(deps): update dependency faker to v3.2.2
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2023-11-04 10:25:24 +13:00
2b82edebb2 chore(deps): update dependency rake to v13.1.0
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2023-10-28 15:25:36 +13:00
863fc7ed27 chore(deps): update dependency faker to v3.2.1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2023-10-13 11:25:33 +13:00
5b1e172432
chore(CI): Simplify CI configuration.
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-13 10:29:38 +13:00
ef1c44a170
chore: fix version related rubocop failure.
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2023-07-28 11:40:32 +12:00
0977967055 chore(deps): update dependency ruby to v3.2.2
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2023-07-28 11:24:30 +12:00
16447e3507 chore: Configure Renovate (#190)
All checks were successful
continuous-integration/drone/push Build is passing
Welcome to [Renovate](https://github.com/renovatebot/renovate)! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.

---
### Detected Package Files

 * `.tool-versions` (asdf)
 * `Gemfile` (bundler)
 * `.drone.yml` (droneci)

### Configuration Summary

Based on the default config's presets, Renovate will:

  - Start dependency updates only once this onboarding PR is merged
  - Enable Renovate Dependency Dashboard creation.
  - Use semantic commit type `fix` for dependencies and `chore` for all others if semantic commits are in use.
  - Ignore `node_modules`, `bower_components`, `vendor` and various test/tests directories.
  - Group known monorepo packages together.
  - Use curated list of recommended non-monorepo package groupings.
  - Apply crowd-sourced package replacement rules.
  - Apply crowd-sourced workarounds for known problems with packages.
  - Use semantic prefixes for commit messages and PR titles.
  - Use `chore` as semantic commit type for commit messages and PR titles.
  - Removes rate limit for PR creation per hour.
  - Remove limit for open PRs at any time.
  - Automerge all upgrades (including `major`) if they pass tests.
  - Assign PRs to `james`.
  - Rebase existing PRs any time the base branch has been updated.
  - Raise PR when vulnerability alerts are detected.
  - Disable Renovate Dependency Dashboard creation.

🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the `renovate.json` in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.

---

### What to Expect

With your current configuration, Renovate will create 3 Pull Requests:

<details>
<summary>chore(deps): update dependency rubocop to '~> 1.55.0'</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/rubocop-1.x`
  - Merge into: `main`
  - Upgrade [rubocop](https://github.com/rubocop/rubocop) to `'~> 1.55.0'`

</details>

<details>
<summary>chore(deps): update dependency ruby to v3.2.2</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/ruby-3.x`
  - Merge into: `main`
  - Upgrade [ruby](https://github.com/ruby/ruby) to `3.2.2`

</details>

<details>
<summary>chore(deps): lock file maintenance</summary>

  - Branch name: `renovate/lock-file-maintenance`
  - Merge into: `main`
  - Regenerate lock files to use latest dependency versions

</details>

---

 Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: Renovate Bot <bot@harton.nz>
Reviewed-on: https://code.harton.nz/james/wag/pulls/190
Co-authored-by: Renovate Bot <renovate@noreply.localhost>
Co-committed-by: Renovate Bot <renovate@noreply.localhost>
2023-07-28 10:26:51 +12:00
cd016156b5
chore: Release version 0.2.1.
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-28 08:52:25 +12:00
f7370ac264
chore: Rubocop fixes.
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2023-07-28 08:44:34 +12:00
1076413d03
chore: migrate to local.
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-28 08:32:26 +12:00
37 changed files with 407 additions and 250 deletions

166
.drone.yml Normal file
View file

@ -0,0 +1,166 @@
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

View file

@ -1,32 +0,0 @@
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

View file

@ -30,3 +30,7 @@ Style/Documentation:
Style/OptionalArguments:
Enabled: false
AllCops:
NewCops: enable
SuggestExtensions: false

1
.tool-versions Normal file
View file

@ -0,0 +1 @@
ruby 3.3.4

View file

@ -1,7 +1,7 @@
PATH
remote: .
specs:
wag (0.2.0)
wag (0.2.1)
dry-inflector (~> 0.2.0)
GEM
@ -9,12 +9,12 @@ GEM
specs:
ast (2.4.2)
coderay (1.1.3)
concurrent-ruby (1.2.2)
diff-lcs (1.5.0)
concurrent-ruby (1.2.3)
diff-lcs (1.5.1)
dry-inflector (0.2.1)
faker (3.2.0)
faker (3.4.2)
i18n (>= 1.8.11, < 2)
i18n (1.14.1)
i18n (1.14.5)
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.0.6)
rake (13.2.1)
regexp_parser (2.8.1)
rexml (3.2.5)
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)
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)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
rubocop (1.52.1)
json (~> 2.3)
parallel (~> 1.10)
@ -59,6 +59,7 @@ GEM
unicode-display_width (2.4.2)
PLATFORMS
arm64-darwin-22
x86_64-linux
DEPENDENCIES

View file

@ -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,6 +68,7 @@ end
```
### Example of folded generation
```ruby
folded = WAG::Module.new.build do
func(:gcd) do
@ -154,7 +155,6 @@ 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 on GitLab at https://gitlab.com/jimsy/wag.
Bug reports and pull requests are welcome at https://harton.dev/james/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.

View file

@ -12,7 +12,7 @@ module WAG
end
def to_sexpr
[:data, [:"i32.const", offset], value]
[:data, [:'i32.const', offset], value]
end
end
end

View file

@ -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

View file

@ -26,7 +26,7 @@ module WAG
@desc
end
def table(number, type = :anyfunc, &block)
def table(number, type = :funcref, &block)
@desc = Table.new(number, type)
@desc.instance_exec(&block) if block
@desc

View file

@ -29,7 +29,7 @@ module WAG
@desc
end
def table(number, type = :anyfunc, &block)
def table(number, type = :funcref, &block)
@desc = Table.new(number, type)
@desc.instance_exec(&block) if block
@desc

View file

@ -8,6 +8,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -8,6 +8,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -8,6 +8,7 @@ module WAG
def initialize(*labels)
@labels = labels.map { |label| WAG::Label.from(label) }
super()
end
def to_sexpr

View file

@ -8,6 +8,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(literal)
@literal = literal.to_f
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(literal)
@literal = literal.to_f
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(literal)
@literal = literal.to_i
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(literal)
@literal = literal.to_i
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -9,6 +9,7 @@ module WAG
def initialize(label)
@label = WAG::Label.from(label)
super()
end
def to_sexpr

View file

@ -16,8 +16,8 @@ module WAG
@types = []
end
def build(&block)
instance_exec(&block)
def build(&)
instance_exec(&)
self
end
@ -76,14 +76,14 @@ module WAG
func
end
def table(elements, type = :anyfunc, &block)
def table(elements, type = :funcref, &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
def to_sexpr # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
mod = [:module]
mod.concat(@imports.map(&:to_sexpr))
mod.concat(@exports.map(&:to_sexpr))

View file

@ -5,7 +5,7 @@ module WAG
include WAG::Encodable
attr_reader :elements, :type
def initialize(elements, type = :anyfunc)
def initialize(elements, type = :funcref)
@elements = elements
@type = type
end

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true
module WAG
VERSION = '0.2.0'
VERSION = '0.2.1'
end

View file

@ -1,3 +1,6 @@
{
"extends": ["gitlab>jimsy/renovate"]
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>renovate/renovate"
]
}

View file

@ -45,7 +45,7 @@ RSpec.describe 'WAT code generation' do
memory(:mem, 1)
table(16, :anyfunc)
table(16, :funcref)
elem(0, :dead, :dead, :dead, :alive, :dead, :dead, :dead, :dead,
:dead, :dead, :dead, :alive, :alive, :dead, :dead, :dead,

View file

@ -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

View file

@ -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

View file

@ -19,12 +19,12 @@ RSpec.describe WAG::Export do
describe 'When exporting a table' do
before do
export.table(1, :anyfunc)
export.table(1, :funcref)
end
describe '#to_sexpr' do
subject { super().to_sexpr }
it { is_expected.to eq [:export, 'marty', [:table, 1, :anyfunc]] }
it { is_expected.to eq [:export, 'marty', [:table, 1, :funcref]] }
end
end

View file

@ -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

View file

@ -19,12 +19,12 @@ RSpec.describe WAG::Import do
describe 'When importing a table' do
before do
import.table(1, :anyfunc)
import.table(1, :funcref)
end
describe '#to_sexpr' do
subject { super().to_sexpr }
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :anyfunc]] }
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :funcref]] }
end
end

View file

@ -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)|

View file

@ -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, :anyfunc]] }
it { is_expected.to eq [:module, [:table, 16, :funcref]] }
end
end
end

View file

@ -8,6 +8,6 @@ RSpec.describe WAG::Table do
describe '#to_sexpr' do
subject { super().to_sexpr }
it { is_expected.to eq [:table, elements, :anyfunc] }
it { is_expected.to eq [:table, elements, :funcref] }
end
end

View file

@ -6,19 +6,19 @@ Gem::Specification.new do |spec|
spec.name = 'wag'
spec.version = WAG::VERSION
spec.authors = ['James Harton']
spec.email = ['james@automat.nz']
spec.email = ['james@harton.nz']
spec.summary = 'WebAssembly Generator'
spec.description = 'Generate and compile WebAssembly code from Ruby'
spec.homepage = 'https://gitlab.com/jimsy/wag'
spec.homepage = 'https://harton.dev/james/wag'
spec.license = 'Hippocratic'
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
spec.required_ruby_version = Gem::Requirement.new('~> 3.3')
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://gitlab.com/jimsy/wag'
spec.metadata['changelog_uri'] = 'https://gitlab.com/jimsy/wag'
spec.metadata['source_code_uri'] = 'https://harton.dev/james/wag'
spec.metadata['changelog_uri'] = 'https://harton.dev/james/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,4 +32,5 @@ 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