-
Notifications
You must be signed in to change notification settings - Fork 0
[interpreter] Syntax and validation for new instructions #68
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: expand-deftype-to-desctype
Are you sure you want to change the base?
Conversation
Specifically ref.get_desc, ref.cast_desc, br_on_cast_desc, and br_on_cast_desc_fail. Also update the existing br_on_cast and br_on_cast_fail tests to account for the change to no longer require the cast output type to be a subtype of the input 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.
LGTM, just a couple of nits.
(match_reftype c.types rt2 rt1) e.at | ||
("type mismatch on cast: type " ^ string_of_reftype rt2 ^ | ||
" does not match " ^ string_of_reftype rt1); | ||
((top_of_heaptype c.types ht1) = (top_of_heaptype c.types ht2)) e.at |
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.
((top_of_heaptype c.types ht1) = (top_of_heaptype c.types ht2)) e.at | |
(top_of_heaptype c.types ht1 = top_of_heaptype c.types ht2) e.at |
Similarly below.
let ut = match ut with | ||
| Some ut -> ut | ||
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it) | ||
in | ||
let dt = deftype_of_typeuse ut in |
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.
let ut = match ut with | |
| Some ut -> ut | |
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it) | |
in | |
let dt = deftype_of_typeuse ut in | |
let dt = match ut with | |
| Some ut -> deftype_of_typeuse ut | |
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it) | |
in |
in | ||
let DescT (_, ut', _) = expand_deftype_to_desctype (type_ c (x @@ at)) in | ||
match ut' with | ||
| Some ut' -> (Null, if exact then ExactHT ut' else UseHT ut') |
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.
Seeing this kind of pattern repeat, I wonder if it wouldn't be a more convenient factorisation if exactness was folded into UseHT as a parameter flag, similar to nullability or mutability.
(func (result anyref) | ||
(br_on_cast 0 eqref anyref (unreachable)) | ||
(func (param (ref null any)) (result (ref null func)) | ||
(block (result (ref null func)) (br_on_cast 1 (ref null any) (ref null func) (local.get 0) (unreachable))) |
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.
Isn't the block redundant?
Specifically ref.get_desc, ref.cast_desc, br_on_cast_desc, and
br_on_cast_desc_fail. Also update the existing br_on_cast and
br_on_cast_fail tests to account for the change to no longer require
the cast output type to be a subtype of the input type.