From d54b36be3d365b1a9a4ec8b12313b84c508ecd98 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 8 Feb 2022 19:18:57 +0100 Subject: Implement pre-passes to update the AST before executing the interpreter --- src/InterpreterUtils.ml | 2 -- src/Logging.ml | 3 +++ src/Print.ml | 2 +- src/main.ml | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/InterpreterUtils.ml b/src/InterpreterUtils.ml index bbdd038f..0445c6b6 100644 --- a/src/InterpreterUtils.ml +++ b/src/InterpreterUtils.ml @@ -1,5 +1,3 @@ -(* TODO: most of the definitions in this file need to be moved elsewhere *) - module T = Types module V = Values module E = Expressions diff --git a/src/Logging.ml b/src/Logging.ml index 5605772d..f4fa9309 100644 --- a/src/Logging.ml +++ b/src/Logging.ml @@ -9,6 +9,9 @@ let main_log = L.get_logger "MainLogger" (** Below, we create subgloggers for various submodules, so that we can precisely toggle logging on/off, depending on which information we need *) +(** Logger for PrePasses *) +let pre_passes_log = L.get_logger "MainLogger.PrePasses" + (** Logger for Translate *) let translate_log = L.get_logger "MainLogger.Translate" diff --git a/src/Print.ml b/src/Print.ml index 2db92d41..7c1ef79a 100644 --- a/src/Print.ml +++ b/src/Print.ml @@ -733,7 +733,7 @@ module CfimAst = struct | E.Field (E.ProjOption variant_id, fid) -> assert (variant_id == T.option_some_id); assert (fid == T.FieldId.zero); - "(" ^ s ^ "as Option::Some)." ^ T.FieldId.to_string fid + "(" ^ s ^ " as Option::Some)." ^ T.FieldId.to_string fid | E.Field (E.ProjTuple _, fid) -> "(" ^ s ^ ")." ^ T.FieldId.to_string fid | E.Field (E.ProjAdt (adt_id, opt_variant_id), fid) -> ( diff --git a/src/main.ml b/src/main.ml index 2502ac4d..79a04c4e 100644 --- a/src/main.ml +++ b/src/main.ml @@ -113,6 +113,9 @@ let () = (* Print the module *) main_log#ldebug (lazy ("\n" ^ Print.Module.module_to_string m ^ "\n")); + (* Apply the pre-passes *) + let m = PrePasses.apply_passes m in + (* Some options for the execution *) let config = { -- cgit v1.2.3