-
Notifications
You must be signed in to change notification settings - Fork 119
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
Check mapping completeness #647
base: sail2
Are you sure you want to change the base?
Conversation
78a0c43
to
5fb2a22
Compare
let ast, env = Type_error.check env ast in | ||
let ast = Scattered.descatter ast in | ||
let ast, env = Type_error.check Type_check.initial_env (Type_check.strip_ast ast) in | ||
let side_effects = Effects.infer_side_effects asserts_termination ast in | ||
Effects.check_side_effects side_effects ast; | ||
let () = if !opt_ddump_tc_ast then Pretty_print_sail.output_ast stdout (Type_check.strip_ast ast) else () 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.
type_check again to add_attrs after scattered mapdefs get together
(* TODO: handle unsupported syntax *) | ||
try | ||
(* prepare left *) | ||
let lpats = List.map (fun mapcl -> lpat_of_mapcl mapcl true) mapcls in | ||
let _, lpats = opt_cases_to_pats 0 have_guard lpats in | ||
let lmatrix = | ||
Rows (List.mapi (fun i (l, pat) -> ({ loc = l; num = i }, Columns [generalize ctx (Some typl) pat])) lpats) | ||
in | ||
(* prepare right *) | ||
let rpats = List.map (fun mapcl -> lpat_of_mapcl mapcl false) mapcls in | ||
let _, rpats = opt_cases_to_pats 0 have_guard rpats in | ||
let rmatrix = | ||
Rows (List.mapi (fun i (l, pat) -> ({ loc = l; num = i }, Columns [generalize ctx (Some typr) pat])) rpats) | ||
in | ||
is_complete_matrixs ~keyword:"mapping" l ctx have_guard [(typl, lmatrix); (typr, rmatrix)] | ||
with _ -> false |
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.
Some syntaxes are not supported in match, but are allowed by mapping
example: test/c/poly_mapping2.sail
mapping test2m : bits(3) <-> bits(5) = { v <-> zero_int_bits(2) : bits(2) @ v }
When encountering this kind of syntax, an exception will be thrown, so here fallback to false.
2f18442
to
bd229e9
Compare
fix #424
Add basic mapdef completeness check