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: Add read function #79

Merged
merged 3 commits into from
Feb 16, 2023
Merged

all: Add read function #79

merged 3 commits into from
Feb 16, 2023

Conversation

juliaogris
Copy link
Member

@juliaogris juliaogris commented Feb 15, 2023

Add blocking read function for line-by-line reading from text input.

Rework access to "returned" strings for function imported from JS to
go/wasm, used in getting evy source and readline. To achieve blocking
reads while allowing interactivity in JS code sleep for 50ms between
every unsuccessful read attempt in go/wasm.

Try it with
https://evy-lang--79-se5aqk1b.web.app#echo

@github-actions
Copy link

github-actions bot commented Feb 15, 2023

firebase-deployment: https://evy-lang--79-se5aqk1b.web.app (3595abe)

Upgrade tinygo to v0.27.0 with

    hermit install tinygo-0.27.0

Tinygo's dependencies go and gofmt get upgraded to 1.20. As a result
linters failed (not linting, but linters(!)) so upgrade golangci-lint
and its settings.
Rework access to evy source code. What we wanted was a JS function that
returns a string (the evy source code). However, go/wasm only allows JS
functions that return float64, int, int32 or uint32 it seems. As a
result we queried the global sourcePointer and sourceLength as written
to linear memory separately and rebuilt the string in go wasm.

Now that we will need another string returning functions (read()) it is
time to rework this approach: Write the string to memory in JS all the
same, but combine pointer (high 32 bits) and length (low 32 bits) into
a single 64 bit JS Number which is return to in go/wasm as float64.
Reconstruct pointer and length from it in go/wasm with the inverse bit
manipulations and reconstruct string.

It could be that passing float64 is going to bite as at some point - we
will deal with it.
Add blocking read function for line-by-line reading from text input.

Add jsRead function to index.js which returns a memory address of read
string iff a string has been entered into the input area followed by a
newline, otherwise return 0.

go/wasm provides read() which wraps jsRead() in a loop with intermittent
sleeps to yield to JS for processing user events. If the return value
of jsRead() is not 0 extract the string for the given memory address
and return. read() is provided to the evaluator via the runtime struct
and used inside the evy builtin read.

Move `hidden` class towards the end of index.css because for it so that
the same property `display` can be overriden from `flex` to `none`.
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 50e6a7d into master Feb 16, 2023
@juliaogris juliaogris deleted the read branch February 16, 2023 01:06
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