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

Fix parsecmm.mly in ocaml subdirectory #357

Merged
merged 3 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix parsecmm.mly in ocaml back to the version of Cmm from ocaml
Partially revert changes from CMM traps (#72)
  • Loading branch information
gretay-js committed Oct 27, 2021
commit 045920d2a33f83c66d68b143353cc1b9183e9c9a
2 changes: 1 addition & 1 deletion ocaml/testsuite/tests/asmgen/catch-try-float.cmm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ arguments = "-DFLOAT_CATCH -DFUN=catch_try_float main.c"
(function "catch_try_float" (b:float)
(+f 10.0
(catch
(try (exit(1) lbl 100.0)
(try (exit lbl 100.0)
with var 456.0)
with (lbl x:float) (+f x 1000.0))))
2 changes: 1 addition & 1 deletion ocaml/testsuite/tests/asmgen/catch-try.cmm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ arguments = "-DINT_INT -DFUN=catch_exit main.c"
(function "catch_exit" (b:int)
(+ 33
(catch
(try (exit(1) lbl 12)
(try (exit lbl 12)
with var 456)
with (lbl x:val) (+ x 789))))
19 changes: 8 additions & 11 deletions ocaml/testsuite/tools/parsecmm.mly
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let make_switch n selector caselist =
let index = Array.make n 0 in
let casev = Array.of_list caselist in
let dbg = Debuginfo.none in
let actv = Array.make (Array.length casev) (Cexit(Cmm.Lbl 0,[],[]), dbg) in
let actv = Array.make (Array.length casev) (Cexit(0,[]), dbg) in
for i = 0 to Array.length casev - 1 do
let (posl, e) = casev.(i) in
List.iter (fun pos -> index.(pos) <- i) posl;
Expand Down Expand Up @@ -206,9 +206,6 @@ componentlist:
component { [$1] }
| componentlist STAR component { $3 :: $1 }
;
traps:
LPAREN INTCONST RPAREN { List.init $2 (fun _ -> Pop) }
| /**/ { [] }
expr:
INTCONST { Cconst_int ($1, debuginfo ()) }
| FLOATCONST { Cconst_float (float_of_string $1, debuginfo ()) }
Expand Down Expand Up @@ -239,22 +236,22 @@ expr:
match $3 with
Cconst_int (x, _) when x <> 0 -> $4
| _ -> Cifthenelse($3, debuginfo (), $4, debuginfo (),
(Cexit(Cmm.Lbl lbl0,[],[])),
(Cexit(lbl0,[])),
debuginfo ()) in
Ccatch(Nonrecursive, [lbl0, [], Ctuple [], debuginfo ()],
Ccatch(Recursive,
[lbl1, [], Csequence(body, Cexit(Cmm.Lbl lbl1, [], [])), debuginfo ()],
Cexit(Cmm.Lbl lbl1, [], []))) }
| LPAREN EXIT traps IDENT exprlist RPAREN
{ Cexit(Cmm.Lbl (find_label $4), List.rev $5, $3) }
[lbl1, [], Csequence(body, Cexit(lbl1, [])), debuginfo ()],
Cexit(lbl1, []))) }
| LPAREN EXIT IDENT exprlist RPAREN
{ Cexit(find_label $3, List.rev $4) }
| LPAREN CATCH sequence WITH catch_handlers RPAREN
{ let handlers = $5 in
List.iter (fun (_, l, _, _) ->
List.iter (fun (x, _) -> unbind_ident x) l) handlers;
Ccatch(Recursive, handlers, $3) }
| EXIT { Cexit(Cmm.Lbl 0,[],[]) }
| EXIT { Cexit(0,[]) }
| LPAREN TRY sequence WITH bind_ident sequence RPAREN
{ unbind_ident $5; Ctrywith($3, Regular, $5, $6, debuginfo ()) }
{ unbind_ident $5; Ctrywith($3, $5, $6, debuginfo ()) }
| LPAREN VAL expr expr RPAREN
{ let open Asttypes in
Cop(Cload (Word_val, Mutable), [access_array $3 $4 Arch.size_addr],
Expand Down