Browse Source

lose dms_display

Simon Krajewski 3 years ago
parent
commit
b76ebd8c22

+ 1 - 1
src/codegen/swfLoader.ml

@@ -569,7 +569,7 @@ let parse_swf com file =
 	IO.close_in ch;
 	List.iter (fun t ->
 		match t.tdata with
-		| TActionScript3 (id,as3) when not com.debug && not com.display.DisplayTypes.DisplayMode.dms_display ->
+		| TActionScript3 (id,as3) ->
 			t.tdata <- TActionScript3 (id,remove_debug_infos as3)
 		| _ -> ()
 	) tags;

+ 2 - 2
src/compiler/args.ml

@@ -48,7 +48,7 @@ let add_libs com libs =
 			| Some cs ->
 				(try
 					(* if we are compiling, really call haxelib since library path might have changed *)
-					if not com.display.dms_display then raise Not_found;
+					if com.display.dms_full_typing then raise Not_found;
 					cs#find_haxelib libs
 				with Not_found ->
 					let lines = call_haxelib() in
@@ -368,7 +368,7 @@ let parse_args com =
 				actx.force_typing <- true;
 				actx.config_macros <- (Printf.sprintf "include('%s', true, null, null, true)" cl) :: actx.config_macros;
 			end
-		with Failure _ when com.display.dms_display ->
+		with Failure _ when com.display.dms_error_policy = EPIgnore ->
 			()
 		end
 	in

+ 1 - 6
src/compiler/compiler.ml

@@ -245,7 +245,7 @@ let do_type ctx tctx actx =
 
 let handle_display ctx tctx display_file_dot_path =
 	let com = ctx.com in
-	if not ctx.com.display.dms_display && ctx.has_error then raise Abort;
+	if ctx.com.display.dms_kind = DMNone & ctx.has_error then raise Abort;
 	begin match ctx.com.display.dms_kind,!Parser.delayed_syntax_completion with
 		| DMDefault,Some(kind,subj) -> DisplayOutput.handle_syntax_completion com kind subj
 		| _ -> ()
@@ -507,11 +507,6 @@ let compile ctx actx =
 	let display_file_dot_path = DisplayOutput.process_display_file com actx in
 	(* Initialize target: This allows access to the appropriate std packages and sets the -D defines. *)
 	let ext = initialize_target ctx com actx in
-	(* if we are at the last compilation step, allow all packages accesses - in case of macros or opening another project file *)
-	if com.display.dms_display then begin match com.display.dms_kind with
-		| DMDefault | DMUsage _ -> ()
-		| _ -> if not ctx.has_next then com.package_rules <- PMap.foldi (fun p r acc -> match r with Forbidden -> acc | _ -> PMap.add p r acc) com.package_rules PMap.empty;
-	end;
 	com.config <- get_config com; (* make sure to adapt all flags changes defined after platform *)
 	let t = Timer.timer ["init"] in
 	List.iter (fun f -> f()) (List.rev (actx.pre_compilation));

+ 1 - 1
src/compiler/server.ml

@@ -80,7 +80,7 @@ let parse_file cs com file p =
 						end else begin try
 							(* We assume that when not in display mode it's okay to cache stuff that has #if display
 							checks. The reasoning is that non-display mode has more information than display mode. *)
-							if not com.display.dms_display then raise Not_found;
+							if com.display.dms_full_typing then raise Not_found;
 							let ident = Hashtbl.find Parser.special_identifier_files fkey in
 							Printf.sprintf "not cached, using \"%s\" define" ident,true
 						with Not_found ->

+ 4 - 6
src/context/display/displayTexpr.ml

@@ -164,12 +164,10 @@ let check_display_file ctx cs =
 			| Some m -> check_display_module ctx cc cfile m
 			end
 		with Not_found ->
-			if ctx.com.display.dms_display then begin
-				let fkey = DisplayPosition.display_position#get_file_key in
-				(* force parsing again : if the completion point have been changed *)
-				cs#remove_files fkey;
-				cs#taint_modules fkey;
-			end;
+			let fkey = DisplayPosition.display_position#get_file_key in
+			(* force parsing again : if the completion point have been changed *)
+			cs#remove_files fkey;
+			cs#taint_modules fkey;
 		end
 	| None ->
 		()

+ 0 - 3
src/core/displayTypes.ml

@@ -227,7 +227,6 @@ module DisplayMode = struct
 
 	type settings = {
 		dms_kind : t;
-		dms_display : bool;
 		dms_full_typing : bool;
 		dms_force_macro_typing : bool;
 		dms_error_policy : error_policy;
@@ -240,7 +239,6 @@ module DisplayMode = struct
 
 	let default_display_settings = {
 		dms_kind = DMDefault;
-		dms_display = true;
 		dms_full_typing = false;
 		dms_force_macro_typing = false;
 		dms_error_policy = EPIgnore;
@@ -253,7 +251,6 @@ module DisplayMode = struct
 
 	let default_compilation_settings = {
 		dms_kind = DMNone;
-		dms_display = false;
 		dms_full_typing = true;
 		dms_force_macro_typing = true;
 		dms_error_policy = EPShow;

+ 0 - 2
src/typing/calls.ml

@@ -185,8 +185,6 @@ let rec acc_get ctx g p =
 			let tf = apply_params cf.cf_type in
 			if not (type_iseq tf e.etype) then mk (TCast(e,None)) tf e.epos
 			else e
-		| Var _,None when ctx.com.display.dms_display ->
-			 FieldAccess.get_field_expr fa FRead
 		| Var _,None ->
 			typing_error "Recursive inline is not supported" p
 		end

+ 1 - 1
src/typing/macroContext.ml

@@ -521,7 +521,7 @@ let get_macro_context ctx p =
 		com2.package_rules <- PMap.empty;
 		com2.main_class <- None;
 		(* Inherit most display settings, but require normal typing. *)
-		com2.display <- {ctx.com.display with dms_kind = DMNone; dms_display = false; dms_full_typing = true; dms_force_macro_typing = true; dms_inline = true; };
+		com2.display <- {ctx.com.display with dms_kind = DMNone; dms_full_typing = true; dms_force_macro_typing = true; dms_inline = true; };
 		com2.class_path <- List.filter (fun s -> not (ExtString.String.exists s "/_std/")) com2.class_path;
 		let name = platform_name !Globals.macro_platform in
 		com2.class_path <- List.map (fun p -> p ^ name ^ "/_std/") com2.std_path @ com2.class_path;

+ 1 - 1
src/typing/typeload.ml

@@ -630,7 +630,7 @@ and load_complex_type ctx allow_display (t,pn) =
 		if Diagnostics.is_diagnostics_run ctx.com p then begin
 			delay ctx PForce (fun () -> DisplayToplevel.handle_unresolved_identifier ctx name p true);
 			t_dynamic
-		end else if ctx.com.display.dms_display && not (DisplayPosition.display_position#enclosed_in pn) then
+		end else if ctx.com.display.dms_error_policy = EPIgnore && not (DisplayPosition.display_position#enclosed_in pn) then
 			t_dynamic
 		else
 			raise exc

+ 6 - 3
src/typing/typer.ml

@@ -948,10 +948,13 @@ and type_new ctx path el with_type force_inline p =
 		with Error (e,p) ->
 			typing_error (error_msg e) p;
 	in
+	let display_position_in_el () =
+		List.exists (fun e -> DisplayPosition.display_position#enclosed_in (pos e)) el
+	in
 	let t = if (fst path).tparams <> [] then begin
 		try
 			Typeload.load_instance ctx path false
-		with Error _ as exc when ctx.com.display.dms_display ->
+		with Error _ as exc when display_position_in_el() ->
 			(* If we fail for some reason, process the arguments in case we want to display them (#7650). *)
 			List.iter (fun e -> ignore(type_expr ctx e WithType.value)) el;
 			raise exc
@@ -991,7 +994,7 @@ and type_new ctx path el with_type force_inline p =
 		| mt ->
 			typing_error ((s_type_path (t_infos mt).mt_path) ^ " cannot be constructed") p
 		end
-	| Error _ as exc when ctx.com.display.dms_display ->
+	| Error _ as exc when display_position_in_el() ->
 		List.iter (fun e -> ignore(type_expr ctx e WithType.value)) el;
 		raise exc
 	in
@@ -1315,7 +1318,7 @@ and type_local_function ctx kind f with_type p =
 				(mk (TVar (v,Some (mk (TConst TNull) ft p))) ctx.t.tvoid p) ::
 				(mk (TBinop (OpAssign,mk (TLocal v) ft p,e)) ft p) ::
 				exprs
-			end else if inline && not ctx.com.display.dms_display then
+			end else if inline && not ctx.is_display_file then
 				(mk (TBlock []) ctx.t.tvoid p) :: exprs (* do not add variable since it will be inlined *)
 			else
 				(mk (TVar (v,Some e)) ctx.t.tvoid p) :: exprs