@@ -341,11 +341,14 @@ let bool e = J.ECond (e, one, zero)
341341
342342(* ***)
343343
344- let source_location ctx ?force (pc : Code.loc ) =
345- match Parse_bytecode.Debug. find_loc ctx. Ctx. debug ?force pc with
344+ let source_location debug ?force (pc : Code.loc ) =
345+ match Parse_bytecode.Debug. find_loc debug ?force pc with
346346 | Some pi -> J. Pi pi
347347 | None -> J. N
348348
349+ let source_location_ctx ctx ?force (pc : Code.loc ) =
350+ source_location ctx.Ctx. debug ?force pc
351+
349352(* ***)
350353
351354let float_const f = J. ENum (J.Num. of_float f)
@@ -1240,13 +1243,13 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
12401243 let (px, cx), queue = access_queue queue x in
12411244 (Mlvalue.Block. field cx n, or_p px mutable_p, queue), []
12421245 | Closure (args , ((pc , _ ) as cont )) ->
1243- let loc = source_location ctx ~force: After (After pc) in
1246+ let loc = source_location_ctx ctx ~force: After (After pc) in
12441247 let clo = compile_closure ctx cont in
12451248 let clo =
12461249 match clo with
12471250 | (st , x ) :: rem ->
12481251 let loc =
1249- match x, source_location ctx (Before pc) with
1252+ match x, source_location_ctx ctx (Before pc) with
12501253 | (J. U | J. N ), (J. U | J. N ) -> J. U
12511254 | x , (J. U | J. N ) -> x
12521255 | (J. U | J. N ), x -> x
@@ -1495,14 +1498,14 @@ and translate_instr ctx expr_queue instr =
14951498 let instr, pc = instr in
14961499 match instr with
14971500 | Assign (x , y ) ->
1498- let loc = source_location ctx pc in
1501+ let loc = source_location_ctx ctx pc in
14991502 let (_py, cy), expr_queue = access_queue expr_queue y in
15001503 flush_queue
15011504 expr_queue
15021505 mutator_p
15031506 [ J. Expression_statement (J. EBin (J. Eq , J. EVar (J. V x), cy)), loc ]
15041507 | Let (x , e ) -> (
1505- let loc = source_location ctx pc in
1508+ let loc = source_location_ctx ctx pc in
15061509 let (ce, prop, expr_queue), instrs = translate_expr ctx expr_queue loc x e 0 in
15071510 let keep_name x =
15081511 match Code.Var. get_name x with
@@ -1533,23 +1536,23 @@ and translate_instr ctx expr_queue instr =
15331536 prop
15341537 (instrs @ [ J. variable_declaration [ J. V x, (ce, loc) ], loc ]))
15351538 | Set_field (x , n , y ) ->
1536- let loc = source_location ctx pc in
1539+ let loc = source_location_ctx ctx pc in
15371540 let (_px, cx), expr_queue = access_queue expr_queue x in
15381541 let (_py, cy), expr_queue = access_queue expr_queue y in
15391542 flush_queue
15401543 expr_queue
15411544 mutator_p
15421545 [ J. Expression_statement (J. EBin (J. Eq , Mlvalue.Block. field cx n, cy)), loc ]
15431546 | Offset_ref (x , 1 ) ->
1544- let loc = source_location ctx pc in
1547+ let loc = source_location_ctx ctx pc in
15451548 (* FIX: may overflow.. *)
15461549 let (_px, cx), expr_queue = access_queue expr_queue x in
15471550 flush_queue
15481551 expr_queue
15491552 mutator_p
15501553 [ J. Expression_statement (J. EUn (J. IncrA , Mlvalue.Block. field cx 0 )), loc ]
15511554 | Offset_ref (x , n ) ->
1552- let loc = source_location ctx pc in
1555+ let loc = source_location_ctx ctx pc in
15531556 (* FIX: may overflow.. *)
15541557 let (_px, cx), expr_queue = access_queue expr_queue x in
15551558 flush_queue
@@ -1558,7 +1561,7 @@ and translate_instr ctx expr_queue instr =
15581561 [ J. Expression_statement (J. EBin (J. PlusEq , Mlvalue.Block. field cx 0 , int n)), loc
15591562 ]
15601563 | Array_set (x , y , z ) ->
1561- let loc = source_location ctx pc in
1564+ let loc = source_location_ctx ctx pc in
15621565 let (_px, cx), expr_queue = access_queue expr_queue x in
15631566 let (_py, cy), expr_queue = access_queue expr_queue y in
15641567 let (_pz, cz), expr_queue = access_queue expr_queue z in
@@ -1619,7 +1622,7 @@ and compile_block st queue (pc : Addr.t) loop_stack frontier interm =
16191622 else (
16201623 if debug () then Format. eprintf " break;@;}@]@," ;
16211624 body @ [ J. Break_statement None , J. N ])) )
1622- , source_location st.ctx (Code. location_of_pc pc) )
1625+ , source_location_ctx st.ctx (Code. location_of_pc pc) )
16231626 in
16241627 let label = if ! lab_used then Some lab else None in
16251628 let for_loop =
@@ -1854,7 +1857,7 @@ and compile_conditional st queue last loop_stack backs frontier interm =
18541857 | Stop -> Format. eprintf " stop;@;"
18551858 | Cond (x , _ , _ ) -> Format. eprintf " @[<hv 2>cond(%a){@;" Code.Var. print x
18561859 | Switch (x , _ , _ ) -> Format. eprintf " @[<hv 2>switch(%a){@;" Code.Var. print x);
1857- let loc = source_location st.ctx pc in
1860+ let loc = source_location_ctx st.ctx pc in
18581861 let res =
18591862 match last with
18601863 | Return x ->
0 commit comments