diff options
author | Son Ho | 2021-11-29 22:06:43 +0100 |
---|---|---|
committer | Son Ho | 2021-11-29 22:06:43 +0100 |
commit | 2d6690a392d777b7bd035d383c1ee8fa4a53668f (patch) | |
tree | 43d2a008844340b0f93a77eaf6da953f77c10317 | |
parent | 43ae2d3dabe5a44e997b1fedcf89ec612ab8aa85 (diff) |
Fix some issues, introduce debugging log in the interpreter
Diffstat (limited to '')
-rw-r--r-- | src/Interpreter.ml | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Interpreter.ml b/src/Interpreter.ml index 99ef8357..75be6074 100644 --- a/src/Interpreter.ml +++ b/src/Interpreter.ml @@ -17,6 +17,14 @@ module L = Logging ... *) +(** Some utilities *) + +let eval_ctx_to_string = Print.Contexts.eval_ctx_to_string + +let statement_to_string = Print.EvalCtxCfimAst.statement_to_string + +let expression_to_string = Print.EvalCtxCfimAst.expression_to_string + (* TODO: move *) let mk_unit_ty : T.ety = T.Tuple [] @@ -2133,6 +2141,12 @@ let eval_non_local_function_call (config : C.config) (ctx : C.eval_ctx) (** Evaluate a statement *) let rec eval_statement (config : C.config) (ctx : C.eval_ctx) (st : A.statement) : (C.eval_ctx * statement_eval_res) eval_result = + (* Debugging *) + L.log#ldebug + (lazy + ("\n" ^ eval_ctx_to_string ctx ^ "\nAbout to evaluate statement: " + ^ statement_to_string ctx st)); + (* Evaluate *) match st with | A.Assign (p, rvalue) -> ( (* Evaluate the rvalue *) @@ -2256,6 +2270,12 @@ and eval_function_body (config : C.config) (ctx : C.eval_ctx) (** Evaluate an expression *) and eval_expression (config : C.config) (ctx : C.eval_ctx) (e : A.expression) : (C.eval_ctx * statement_eval_res) eval_result = + (* Debugging *) + L.log#ldebug + (lazy + ("\n" ^ eval_ctx_to_string ctx ^ "\nAbout to evaluate expression: \n" + ^ expression_to_string ctx e)); + (* Evaluate *) match e with | A.Statement st -> eval_statement config ctx st | A.Sequence (e1, e2) -> ( @@ -2357,7 +2377,6 @@ let test_unit_function (type_defs : T.type_def T.TypeDefId.vector) no arguments) - TODO: move *) let fun_def_is_unit (def : A.fun_def) : bool = def.A.arg_count = 0 - && V.VarId.length def.A.locals = 0 && T.RegionVarId.length def.A.signature.region_params = 0 && T.TypeVarId.length def.A.signature.type_params = 0 && V.VarId.length def.A.signature.inputs = 0 |