Skip to content

Add fuel#50

Merged
jbourassa merged 2 commits intomainfrom
fuel
Nov 30, 2022
Merged

Add fuel#50
jbourassa merged 2 commits intomainfrom
fuel

Conversation

@jbourassa
Copy link
Copy Markdown
Collaborator

Add fuel:

  • Allow configuring an Engine to use fuel
  • Add fuel methods to Store and Caller
  • Add trap code for out of fuel

Fixes #25

- Allow configuring an Engine to use fuel
- Add fuel methods to Store and Caller
- Add trap code for out of fuel
@jbourassa jbourassa marked this pull request as ready for review November 29, 2022 22:20
Comment on lines +62 to +63
class.define_method("consume_fuel=", method!(Config::set_consume_fuel, 1))?;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of these setters, I think a builder-like API would be nice here too, and coherent with WasiCtxBuilder. But I decided to not shave this yak just yet.

Comment on lines +5 to +20
def self.test_on_store_and_caller(desc, store = :store, &block)
context "on Store" do
it desc do
instance_exec(send(store), &block)
end
end

context "on Caller" do
it desc do
func = Func.new(send(store), FuncType.new([], [])) do |caller|
instance_exec(caller, &block)
end
func.call
end
end
end
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little strange but allows writing the test once for both Store and Caller. I think it's worth it.

@jbourassa jbourassa merged commit a615747 into main Nov 30, 2022
@jbourassa jbourassa deleted the fuel branch November 30, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support fuel

2 participants