Skip to content

Commit

Permalink
Try -> TryTable in AST
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Oct 16, 2023
1 parent c2f7fca commit 5b7a8e1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct
op 0x04; block_type bt; list instr es1;
if es2 <> [] then op 0x05;
list instr es2; end_ ()
| Try (bt, cs, es) ->
| TryTable (bt, cs, es) ->
op 0x1f; block_type bt; vec catch cs; list instr es; end_ ()
| Br x -> op 0x0c; var x
| BrIf x -> op 0x0d; var x
Expand Down
2 changes: 1 addition & 1 deletion interpreter/exec/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ let rec step (c : config) : config =
| ThrowRef, Ref (ExnRef (t, args)) :: vs ->
vs, [Throwing (t, args) @@ e.at]

| Try (bt, cs, es'), vs ->
| TryTable (bt, cs, es'), vs ->
let FuncType (ts1, ts2) = block_type frame.inst bt in
let n1 = Lib.List32.length ts1 in
let n2 = Lib.List32.length ts2 in
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ and instr' =
| Unary of unop (* unary numeric operator *)
| Binary of binop (* binary numeric operator *)
| Convert of cvtop (* conversion *)
| Try of block_type * catch list * instr list (* try *)
| TryTable of block_type * catch list * instr list (* handle exceptions *)
| Throw of var (* throw exception *)
| ThrowRef (* rethrow exception *)
| VecConst of vec (* constant *)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/free.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let rec instr (e : instr) =
tables (var x) ++ types (var y)
| Throw x -> tags (var x)
| ThrowRef -> empty
| Try (bt, cs, es) ->
| TryTable (bt, cs, es) ->
block_type bt ++ list catch cs ++ block es
| LocalGet x | LocalSet x | LocalTee x -> locals (var x)
| GlobalGet x | GlobalSet x -> globals (var x)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/operators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let select t = Select t
let block bt es = Block (bt, es)
let loop bt es = Loop (bt, es)
let if_ bt es1 es2 = If (bt, es1, es2)
let try_table bt cs es = Try (bt, cs, es)
let try_table bt cs es = TryTable (bt, cs, es)
let br x = Br x
let br_if x = BrIf x
let br_table xs x = BrTable (xs, x)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/text/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ let rec instr e =
"return_call_indirect " ^ var x, [Node ("type " ^ var y, [])]
| Throw x -> "throw " ^ var x, []
| ThrowRef -> "throw_ref", []
| Try (bt, cs, es) ->
| TryTable (bt, cs, es) ->
"try_table", block_type bt @ list catch cs @ list instr es
| LocalGet x -> "local.get " ^ var x, []
| LocalSet x -> "local.set " ^ var x, []
Expand Down
2 changes: 1 addition & 1 deletion interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type
| ThrowRef ->
[RefType ExnRefType] -->... []

| Try (bt, cs, es) ->
| TryTable (bt, cs, es) ->
let FuncType (ts1, ts2) as ft = check_block_type c bt in
let c' = {c with labels = ts2 :: c.labels} in
List.iter (fun ct -> check_catch c ct ts2 e.at) cs;
Expand Down

0 comments on commit 5b7a8e1

Please sign in to comment.