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

all: Rework evy-evaluation to be hoisted on main #65

Merged
merged 4 commits into from
Feb 5, 2023

Conversation

juliaogris
Copy link
Member

@juliaogris juliaogris commented Feb 4, 2023

Rework evy-evaluation to be hoisted on main rather than the separately
exported evaluate function. Some things, such as time.Sleep and
fmt.Sprintf only get properly initialised if the main*() function is
the entry point to the wasm code.

Additional, we had to solve to problem of having a JS function
returning a string in memory - we've done this in a hacky way by
returning Ptr and Length in separate function calls.

In preparation remove Lex and Parse button and wasm bindings.

Fix erroneously overridden env object, completely this time. While we
added the fix in 4d25139 we forgot to override the broken lines. oups.
Simplify go.env definition so that we don't repeat key:val where key and
val are the same.
Remove lex and parse from wasm and frontend as these were only used in
the early stages to debug code. The buttons for lex and parse had been
hidden for a while - let's simplify and remove all bindings
completely.
@github-actions
Copy link

github-actions bot commented Feb 4, 2023

firebase-deployment: https://evy-lang--65-092fjtga.web.app (43ca51c)

Copy link
Contributor

@camh- camh- left a comment

Choose a reason for hiding this comment

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

LGTM I think. Not a fan of the global source variables - wondering if they can be somehow hoisted into the wasm instance, but its fine to get going I think.

frontend/index.js Outdated Show resolved Hide resolved
frontend/index.js Outdated Show resolved Hide resolved
frontend/index.js Outdated Show resolved Hide resolved
frontend/index.js Outdated Show resolved Hide resolved
@juliaogris juliaogris force-pushed the wasm-main-entry branch 3 times, most recently from 954f24e to 31593d2 Compare February 5, 2023 04:57
Launch wasm from go `main()` rather than from go exported function
`evaluate()`. It turns out that some things, such as time.Sleep and
fmt.Sprintf only get properly intialised with the main function is the
entry point to the wasm code, so let's fix this up.

We cannot pass parameters to main() so we need JS to provide function to
extract the evy source as string. Unfortunately we can't pass strings
directly in wasm so we have write bytes to linear memory. This was fine
when passing strings as function arguments, but when we want return
values this falls apart as wasm can only provide a single return value.
I attempted to make this single return value a pointer in memory where
the first 4 bytes contain the length and the following bytes the
contents of a string, but got lost with endian specs and other details.
Instead JS provides the somewhat hacky functions `sourcePtr` and
`sourceLength`, which are called separate from Go code and reassembled
to a string.
Copy link
Contributor

@camh- camh- left a comment

Choose a reason for hiding this comment

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

📗 LGTM

@juliaogris juliaogris merged commit 5f22244 into master Feb 5, 2023
@juliaogris juliaogris deleted the wasm-main-entry branch February 5, 2023 05:45
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.

None yet

2 participants