Selaa lähdekoodia

force inlining in js for static externs

Nicolas Cannasse 14 vuotta sitten
vanhempi
commit
ec21c2b275
2 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 3 3
      optimizer.ml
  2. 1 1
      typer.ml

+ 3 - 3
optimizer.ml

@@ -31,7 +31,7 @@ type in_local = {
 	mutable i_read : int;
 }
 
-let rec type_inline ctx cf f ethis params tret p =
+let rec type_inline ctx cf f ethis params tret p force =
 	(* type substitution on both class and function type parameters *)
 	let has_params, map_type =
 		let rec get_params c pl =
@@ -236,7 +236,7 @@ let rec type_inline ctx cf f ethis params tret p =
 
 		This could be fixed with better post process code cleanup (planed)
 	*)
-	if Common.platform ctx.com Js && (init <> None || !has_vars) then begin
+	if Common.platform ctx.com Js && not force && (init <> None || !has_vars) then begin
 		None
 	end else
 		let wrap e =
@@ -687,7 +687,7 @@ let rec reduce_loop ctx e =
 		let cf = mk_field "" ef.etype e.epos in
 		let ethis = mk (TConst TThis) t_dynamic e.epos in
 		let rt = (match follow ef.etype with TFun (_,rt) -> rt | _ -> assert false) in
-		let inl = (try type_inline ctx cf func ethis el rt e.epos with Error (Custom _,_) -> None) in
+		let inl = (try type_inline ctx cf func ethis el rt e.epos false with Error (Custom _,_) -> None) in
 		(match inl with
 		| None -> reduce_expr ctx e
 		| Some e -> reduce_loop ctx e)

+ 1 - 1
typer.ml

@@ -287,7 +287,7 @@ let make_call ctx e params t p =
 		let params = List.map (ctx.g.do_optimize ctx) params in
 		(match f.cf_expr with
 		| Some { eexpr = TFunction fd } ->
-			(match Optimizer.type_inline ctx f fd ethis params t p with
+			(match Optimizer.type_inline ctx f fd ethis params t p (match cl with Some { cl_extern = true } -> true | _ -> false) with
 			| None ->
 				(match cl with
 				| Some { cl_extern = true } -> error "Inline could not be done" p