Bladeren bron

Merge branch 'development' into haxe.Unit

Simon Krajewski 5 maanden geleden
bovenliggende
commit
9cfa97626b
1 gewijzigde bestanden met toevoegingen van 91 en 66 verwijderingen
  1. 91 66
      src/typing/typerEntry.ml

+ 91 - 66
src/typing/typerEntry.ml

@@ -6,58 +6,7 @@ open Typer
 open Resolution
 open Error
 
-let create com macros =
-	let rec ctx = {
-		com = com;
-		t = com.basic;
-		g = {
-			core_api = None;
-			macros = macros;
-			module_check_policies = [];
-			delayed = Array.init TyperPass.all_typer_passes_length (fun _ -> { tasks = []});
-			delayed_min_index = 0;
-			debug_delayed = [];
-			retain_meta = Common.defined com Define.RetainUntypedMeta;
-			std_types = null_module;
-			global_using = [];
-			complete = false;
-			type_hints = [];
-			load_only_cached_modules = false;
-			return_partial_type = false;
-			build_count = 0;
-			t_dynamic_def = t_dynamic;
-			do_macro = MacroContext.type_macro;
-			do_load_macro = MacroContext.load_macro';
-			do_load_module = TypeloadModule.load_module;
-			do_load_type_def = Typeload.load_type_def;
-			get_build_info = InstanceBuilder.get_build_info;
-			do_format_string = format_string;
-			do_load_core_class = Typeload.load_core_class;
-			delayed_display = None;
-			root_typer = ctx;
-		};
-		m = {
-			curmod = null_module;
-			import_resolution = new resolution_list ["import";"typer"];
-			own_resolution = None;
-			enum_with_type = None;
-			module_using = [];
-			import_statements = [];
-			is_display_file = false;
-		};
-		c = {
-			curclass = null_class;
-			tthis = t_dynamic;
-			get_build_infos = (fun() -> None);
-		};
-		f = TyperManager.create_ctx_f null_field;
-		e = TyperManager.create_ctx_e FunStatic false;
-		pass = PBuildModule;
-		allow_inline = true;
-		allow_transform = true;
-		type_params = [];
-		memory_marker = Typecore.memory_marker;
-	} in
+let load_std_types ctx =
 	ctx.g.std_types <- (try
 		TypeloadModule.load_module ctx ([],"StdTypes") null_pos
 	with
@@ -115,7 +64,9 @@ let create com macros =
 			end
 		| TEnumDecl _ | TClassDecl _ ->
 			()
-	) ctx.g.std_types.m_types;
+	) ctx.g.std_types.m_types
+
+let load_string ctx =
 	let m = TypeloadModule.load_module ctx ([],"String") null_pos in
 	List.iter (fun mt -> match mt with
 		| TClassDecl ({cl_path = ([],"String")} as c) ->
@@ -123,12 +74,16 @@ let create com macros =
 			Type.unify t ctx.t.tstring;
 			ctx.t.tstring <- t
 		| _ -> ()
-	) m.m_types;
+	) m.m_types
+
+let load_std ctx =
 	let m = TypeloadModule.load_module ctx ([],"Std") null_pos in
 	List.iter (fun mt -> match mt with
 		| TClassDecl ({cl_path = ([],"Std")} as c) -> ctx.com.std <- c;
 		| _ -> ()
-	) m.m_types;
+	) m.m_types
+
+let load_any ctx =
 	let m = TypeloadModule.load_module ctx ([],"Any") null_pos in
 	List.iter (fun mt -> match mt with
 		| TAbstractDecl a ->
@@ -139,27 +94,97 @@ let create com macros =
 				ctx.t.tany <- t;
 			| _ -> ())
 		| _ -> ()
-	) m.m_types;
+	) m.m_types
+
+let load_array ctx =
 	let m = TypeloadModule.load_module ctx ([],"Array") null_pos in
-	(try
+	try
 		List.iter (fun t -> (
 			match t with
 			| TClassDecl ({cl_path = ([],"Array")} as c) ->
 				ctx.t.tarray <- (fun t -> TInst (c,[t]));
 				raise Exit
-			| _ -> ()
+			| _ ->
+				()
 		)) m.m_types;
 		die "" __LOC__
-	with Exit -> ());
+	with Exit ->
+		()
+
+let load_enum_tools ctx =
 	let m = TypeloadModule.load_module ctx (["haxe"],"EnumTools") null_pos in
-	(match m.m_types with
-	| [TClassDecl c1;TClassDecl c2] -> ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
+	match m.m_types with
+	| [TClassDecl c1;TClassDecl c2] ->
+		ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
 	| [TClassDecl c1] ->
-		let m = TypeloadModule.load_module ctx (["haxe"],"EnumWithType.valueTools") null_pos in
-		(match m.m_types with
-		| [TClassDecl c2 ] -> ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
-		| _ -> die "" __LOC__);
-	| _ -> die "" __LOC__);
+		let m = TypeloadModule.load_module ctx (["haxe"],"EnumValueTools") null_pos in
+		begin match m.m_types with
+		| [TClassDecl c2 ] ->
+			ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
+		| _ ->
+			die "" __LOC__
+		end;
+	| _ ->
+		die "" __LOC__
+
+let create com macros =
+	let rec ctx = {
+		com = com;
+		t = com.basic;
+		g = {
+			core_api = None;
+			macros = macros;
+			module_check_policies = [];
+			delayed = Array.init TyperPass.all_typer_passes_length (fun _ -> { tasks = []});
+			delayed_min_index = 0;
+			debug_delayed = [];
+			retain_meta = Common.defined com Define.RetainUntypedMeta;
+			std_types = null_module;
+			global_using = [];
+			complete = false;
+			type_hints = [];
+			load_only_cached_modules = false;
+			return_partial_type = false;
+			build_count = 0;
+			t_dynamic_def = t_dynamic;
+			do_macro = MacroContext.type_macro;
+			do_load_macro = MacroContext.load_macro';
+			do_load_module = TypeloadModule.load_module;
+			do_load_type_def = Typeload.load_type_def;
+			get_build_info = InstanceBuilder.get_build_info;
+			do_format_string = format_string;
+			do_load_core_class = Typeload.load_core_class;
+			delayed_display = None;
+			root_typer = ctx;
+		};
+		m = {
+			curmod = null_module;
+			import_resolution = new resolution_list ["import";"typer"];
+			own_resolution = None;
+			enum_with_type = None;
+			module_using = [];
+			import_statements = [];
+			is_display_file = false;
+		};
+		c = {
+			curclass = null_class;
+			tthis = t_dynamic;
+			get_build_infos = (fun() -> None);
+		};
+		f = TyperManager.create_ctx_f null_field;
+		e = TyperManager.create_ctx_e FunStatic false;
+		pass = PBuildModule;
+		allow_inline = true;
+		allow_transform = true;
+		type_params = [];
+		memory_marker = Typecore.memory_marker;
+	} in
+	load_std_types ctx;
+	load_string ctx;
+	load_std ctx;
+	load_any ctx;
+	load_array ctx;
+	load_enum_tools ctx;
 	ignore(TypeloadModule.load_module ctx (["haxe"],"Exception") null_pos);
 	ctx.g.complete <- true;
 	ctx