Skip to content

Commit

Permalink
show context of local functions for times (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
frabbit authored and Simn committed May 1, 2017
1 parent 6e9e578 commit 3e95b7c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/macro/eval/evalContext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,18 @@ let select ctx = get_ctx_ref := (fun() -> ctx)

(* Misc *)

let rec kind_name ctx = function
| EKLocalFunction i -> Printf.sprintf "localFunction%i" i
| EKMethod(i1,i2) -> Printf.sprintf "%s.%s" (rev_hash_s i1) (rev_hash_s i2)
| EKDelayed -> "delayed"
let rec kind_name ctx kind =
let rec loop kind env_id = match kind, env_id with
| EKLocalFunction i, 0 ->
Printf.sprintf "localFunction%i" i
| EKLocalFunction i, env_id ->
let parent_id = env_id - 1 in
let env = DynArray.get ctx.environments parent_id in
Printf.sprintf "%s.localFunction%i" (loop env.kind parent_id) i
| EKMethod(i1,i2),_ -> Printf.sprintf "%s.%s" (rev_hash_s i1) (rev_hash_s i2)
| EKDelayed,_ -> "delayed"
in
loop kind ctx.environment_offset

let vstring s =
let proto = (get_ctx()).string_prototype in
Expand Down Expand Up @@ -229,4 +237,4 @@ let get_instance_field_index_raise proto name =

let get_instance_field_index proto name =
try get_instance_field_index_raise proto name
with Not_found -> Error.error (Printf.sprintf "Field index for %s not found on prototype %s" (rev_hash_s name) (rev_hash_s proto.ppath)) null_pos
with Not_found -> Error.error (Printf.sprintf "Field index for %s not found on prototype %s" (rev_hash_s name) (rev_hash_s proto.ppath)) null_pos

0 comments on commit 3e95b7c

Please sign in to comment.