Commits

Anonymous committed df146ce

Renamed bc_abstraction to lambda.

Comments (0)

Files changed (3)

   | Sint x -> const_int lltype x
   | Sfloat x -> const_float lltype x
   | Ssymbol s -> const_array i8_type (convert_string s)
-  | Sclosure (_, { abs_body = Some Jitcode (typ, fn_name) } ) -> begin
+  | Sclosure (_, { lam_body = Some Jitcode (typ, fn_name) } ) -> begin
       match lookup_function fn_name m with
 	  Some fn -> fn
 	| None -> assert false
 (* NOTE env probably needs to be passed through gen_llvm *)
 let jit_compile name globals env abstraction typeinfo =
   let current_module = m in
-  let type_ = get_type typeinfo abstraction.abs_code in
+  let type_ = get_type typeinfo abstraction.lam_ast in
   let current_function = define_function name (function_sig type_) 
     current_module 
   in
 	    (label "phi") join_builder in
 	  (return, join_builder)
   in
-  gen_llvm builder abstraction.abs_code
+  gen_llvm builder abstraction.lam_ast
 ;;
 
 (*
   | B_ref of reference * bytecode
   | B_set of reference * bytecode
   | B_test of bytecode * bytecode
-  | B_abs of bc_abstraction * bytecode
+  | B_abs of lambda * bytecode
   | B_ret
   | B_apply
   | B_arg of int * bytecode
   | B_nuate of stack_frame list * reference
   | B_halt
       
-and bc_abstraction = { abs_params : variable array;
-		       abs_varargs : bool;
-		       abs_code : ast;
-		       mutable abs_body : code option }
+and lambda = { lam_params : variable array;
+	       lam_varargs : bool;
+	       lam_ast : ast;  (* AST of the lambda body *)
+	       mutable lam_body : code option }
 
 and code = 
     Bytecode of bytecode
   | Schar of char
   | Svector of sval array
 
-and sclosure = environment * bc_abstraction
+and sclosure = environment * lambda
 
 and ast =
     A_lit of sval
 	fprintf f "lset %s:%d.%d" var.var_uname frame idx
     | B_test _ -> fprintf f "test"
     | B_abs (abs, _) ->
-	fprintf f "lambda/%d" (Array.length abs.abs_params)
+	fprintf f "lambda/%d" (Array.length abs.lam_params)
     | B_ret -> fprintf f "ret"
     | B_apply -> fprintf f "apply"
     | B_arg (idx, _) -> fprintf f "arg %d" idx
 	       allow us to compile it in terms of the *live* environment rather
 	       than with everything unbound.  However, there are many cases
 	       where we would not gain any benefit from deferred compilation *)
-	    B_abs ( { abs_params = params;
-		      abs_varargs = varargs;
-		      abs_code = body;
-		      abs_body = None }, next)
+	    B_abs ( { lam_params = params;
+		      lam_varargs = varargs;
+		      lam_ast = body;
+		      lam_body = None }, next)
 	| A_app (fn, args) -> begin
 	    let c = bc_compile env fn B_apply in
 	    let _, n = Array.fold_left
 	  let next = if acc == Sfalse then falseb else trueb in
 	  eval acc globals env rib stack next
       | B_abs (abs, next) -> begin
-	  let () = match abs.abs_body with
+	  let () = match abs.lam_body with
 	      Some _ -> ()
 	    | None -> ()
 		(* This compiles the lambda abstraction in order to create the
 		   compilation even longer, under the application of the
 		   function, if that was beneficial. 
 		let frame = 
-		  { vars = abs.abs_params;
-		    vals = Array.map (fun _ -> Sunbound) abs.abs_params } in
+		  { vars = abs.lam_params;
+		    vals = Array.map (fun _ -> Sunbound) abs.lam_params } in
 		let env = frame :: env in
-		let body = bc_compile env abs.abs_code B_ret in
-		abs.abs_body <- Some body*)
+		let body = bc_compile env abs.lam_ast B_ret in
+		abs.lam_body <- Some body*)
 	  in
 	  let closure = Sclosure (env, abs) in
 	  eval closure globals env rib stack next
       | B_conti x ->
 	  let var = mklocal "conti" in
 	  let body = B_nuate (stack, (var, Lbinding (0, 0))) in
-	  let abs = { abs_params = [| var |];
-		      abs_varargs = false;
-		      abs_code = A_lit (Sunbound);
-		      abs_body = Some (Bytecode body) } in
+	  let abs = { lam_params = [| var |];
+		      lam_varargs = false;
+		      lam_ast = A_lit (Sunbound);
+		      lam_body = Some (Bytecode body) } in
 	  let acc = Sclosure ([], abs) in
 	  eval acc globals env rib stack x
 	    
   and apply acc globals env rib stack =
     match acc with
 	Sclosure (env, abs) ->
-	  let { abs_params = params;
-		abs_varargs = varargs;
-		abs_body = body } = abs in
+	  let { lam_params = params;
+		lam_varargs = varargs;
+		lam_body = body } = abs in
 	  let frame = if varargs then
 	    (* one param (the last) is the varargs, the rest are the
 	       regular args *)
 		   function until it is applied.  However, we can't memoize
 		   it since it is compiled with values of the params
 		   bound in the environment *)
-		let body = compile globals env abs.abs_code B_ret in
-		(* abs.abs_body <- Some body; *)
+		let body = compile globals env abs.lam_ast B_ret in
+		(* abs.lam_body <- Some body; *)
 		body
 	    | Some Bytecode body -> body
 	  in