Commits

Paweł Wieczorek  committed d9e78b9

added stub for frames

  • Participants
  • Parent commits 5edaa96
  • Branches very_simple_while_compiler

Comments (0)

Files changed (2)

File source/Compiler/WhileX86Compiler.ml

         { local_variable_map       : (AST.variable, location32) FrozenHashtbl.t
         }
 
-    type frame_description =
+    type frame =
         { scope_blocks              : scope_block list ref
         ; leave_symbol              : symbol
         }
         ; global_variable_table     : (AST.variable,   symbol) FrozenHashtbl.t
         ; exception_symbol_table    : (AST.identifier, symbol) FrozenHashtbl.t
         ; frame_leave               : symbol option ref
+        ; current_frame             : frame option ref
         }
 
     let get_all_symbols_from_table context =
         ; global_variable_table     = FrozenHashtbl.freeze (Helpers.compute_global_variable_table declarations)
         ; exception_symbol_table    = FrozenHashtbl.freeze (Helpers.compute_exception_symbol_table declarations)
         ; frame_leave               = ref None
+        ; current_frame             = ref None
         } 
 
     let create_fresh_local_symbol ?(suffix="") context = 
         context.frame_leave := Some frame_leave_symbol;
         frame_leave_symbol
 
+    let inside_frame context cont =
+        assert (Option.is_none !(context.current_frame));
+        let leave_symbol = create_fresh_local_symbol ~suffix:"_frame_leave"  context in
+        let frame = 
+            { scope_blocks = ref []
+            ; leave_symbol = leave_symbol
+            } in
+        context.current_frame := Some frame;
+        let r = cont leave_symbol in
+        context.current_frame := None;
+        r
+
+
 end
 
 (*********************************************************************************************************************

File source/Util/FrozenHashtbl.ml

 
 type ('k, 'v) t = ('k, 'v) Hashtbl.t
 
-let freeze t = t
+let freeze t = (Hashtbl.copy t)
 
 let find h k = Hashtbl.find h k