diff options
Diffstat (limited to 'cparser/Unblock.ml')
-rw-r--r-- | cparser/Unblock.ml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cparser/Unblock.ml b/cparser/Unblock.ml index bad5002b..ad4b5497 100644 --- a/cparser/Unblock.ml +++ b/cparser/Unblock.ml @@ -214,12 +214,18 @@ let debug_lineno (filename, lineno) = let empty_string = string_const "" +let curr_fun_id = ref 0 + +let debug_var_decl ctx id = + Debug.add_lvar_scope !curr_fun_id id (List.hd ctx) + let debug_scope ctx = debug_annot 6L (empty_string :: List.rev_map integer_const ctx) (* Add line number debug annotation if the line number changes. Add scope debug annotation regardless. *) + let add_lineno ctx prev_loc this_loc s = if !Clflags.option_g then sseq no_loc (debug_scope ctx) @@ -307,7 +313,12 @@ let rec unblock_stmt env ctx ploc s = | Sblock sl -> let ctx' = if block_contains_decl sl - then new_scope_id () :: ctx + then + let id = new_scope_id () in + (match ctx with + | [] -> Debug.enter_function_scope !curr_fun_id id + | a::_ -> Debug.enter_scope !curr_fun_id a id); + id:: ctx else ctx in unblock_block env ctx' ploc sl | Sdecl d -> @@ -336,6 +347,7 @@ and unblock_block env ctx ploc = function let unblock_fundef env f = local_variables := []; next_scope_id := 0; + curr_fun_id:= f.fd_name.stamp; (* TODO: register the parameters as being declared in function scope *) let body = unblock_stmt env [] no_loc f.fd_body in let decls = !local_variables in |