-
Notifications
You must be signed in to change notification settings - Fork 529
[spec] specify host functions in spectec #2210
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,17 +170,32 @@ rule Step_read/call: | |
| z; (CALL x) ~> (REF.FUNC_ADDR a) (CALL_REF $funcinst(z)[a].TYPE) | ||
| -- if $moduleinst(z).FUNCS[x] = a | ||
|
|
||
| rule Step_read/call_ref-null: | ||
| z; (REF.NULL_ADDR) (CALL_REF yy) ~> TRAP | ||
| rule Step/call_ref-null: | ||
| z; (REF.NULL_ADDR) (CALL_REF yy) ~> z; TRAP | ||
|
|
||
| rule Step_read/call_ref-func: | ||
| z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) | ||
| rule Step/call_ref-func: | ||
| z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> z; (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) | ||
| ---- | ||
| -- if $funcinst(z)[a] = fi | ||
| -- Expand: fi.TYPE ~~ FUNC t_1^n -> t_2^m | ||
| -- if fi.CODE = FUNC x (LOCAL t)* (instr*) | ||
| -- if f = {LOCALS val^n ($default_(t))*, MODULE fi.MODULE} | ||
|
|
||
| rule Step/call_ref-hostfunc-res: | ||
| s; f; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> s'; f; $lift_result(result) | ||
| ---- | ||
| -- if $funcinst((s; f))[a] = fi | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it not work to use pattern matching here, like in the hand-written version?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the reason was that there's a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right. In that case leave it as is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering why I needed the parens around
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly. Or more precisely, the show hint for $funcinst removes the call parens.. |
||
| -- Expand: fi.TYPE ~~ FUNC t_1^n -> t_2^m | ||
| -- if fi.CODE = _HOSTFUNC hf | ||
| -- if RES s' result <- $hostcall(_HOSTFUNC hf, s, val^n) | ||
|
|
||
| rule Step/call_ref-hostfunc-div: | ||
| s; f; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> s; f; (REF.FUNC_ADDR a) (CALL_REF yy) | ||
| ---- | ||
| -- if $funcinst((s; f))[a] = fi | ||
| -- Expand: fi.TYPE ~~ FUNC t_1^n -> t_2^m | ||
| -- if fi.CODE = _HOSTFUNC hf | ||
| -- if BOT <- $hostcall(_HOSTFUNC hf, s, val^n) | ||
|
|
||
| rule Step_read/return_call: | ||
| z; (RETURN_CALL x) ~> (REF.FUNC_ADDR a) (RETURN_CALL_REF $funcinst(z)[a].TYPE) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the representation of exception results changes in #2189.