Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine: add LoadAndRun method to reduce needed code to support most typical usage #23

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

deadprogram
Copy link
Member

This PR adds a LoadAndRun() method to the engine to reduce the boilerplate needed code to support the most typical usage.

… usage

Signed-off-by: deadprogram <ron@hybridgroup.com>
@deadprogram
Copy link
Member Author

With this change you can now do this:

	println("Loading and running WASM code...")
	ins, err := eng.LoadAndRun(bytes.NewReader(wasmCode))
	if err != nil {
		println(err.Error())
		return
	}

instead of always having to do this:

	println("Loading WASM module...")
	if err := eng.Interpreter.Load(bytes.NewReader(wasmModule)); err != nil {
		println(err.Error())
		return
	}

	println("Running module...")
	ins, err := eng.Interpreter.Run()
	if err != nil {
		println(err.Error())
		return
	}

@deadprogram
Copy link
Member Author

Based on side-channel conversation with @orsinium we will also do some additional work in future PR to better scope Interpreter and Module for the individual Load() and Run() methods respectively.

@deadprogram
Copy link
Member Author

Now merging.

@deadprogram deadprogram merged commit f85cd1d into main Mar 9, 2024
1 check passed
@deadprogram deadprogram deleted the load-and-run branch March 9, 2024 11:05
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.

1 participant