Ver código fonte

fix some display file handling related to macros

Simon Krajewski 9 anos atrás
pai
commit
63b1a60e0e
3 arquivos alterados com 10 adições e 5 exclusões
  1. 1 1
      src/typing/typecore.ml
  2. 8 4
      src/typing/typeload.ml
  3. 1 0
      src/typing/typer.ml

+ 1 - 1
src/typing/typecore.ml

@@ -99,7 +99,7 @@ and typer = {
 	mutable pass : typer_pass;
 	(* per-module *)
 	mutable m : typer_module;
-	is_display_file : bool;
+	mutable is_display_file : bool;
 	(* per-class *)
 	mutable curclass : tclass;
 	mutable tthis : t;

+ 8 - 4
src/typing/typeload.ml

@@ -2908,7 +2908,8 @@ let init_module_type ctx context_init do_init (decl,p) =
 	match decl with
 	| EImport (path,mode) ->
 		ctx.m.module_imports <- (path,mode) :: ctx.m.module_imports;
-		if ctx.is_display_file then begin
+		(* We cannot use ctx.is_display_file because the import could come from an import.hx file. *)
+		if Display.is_display_file p.pfile then begin
 			Display.add_import_position ctx.com p;
 			handle_path_display ctx path p;
 		end;
@@ -3024,7 +3025,7 @@ let init_module_type ctx context_init do_init (decl,p) =
 				) :: !context_init
 			))
 	| EUsing path ->
-		if ctx.is_display_file then begin
+		if Display.is_display_file p.pfile then begin
 			Display.add_import_position ctx.com p;
 			handle_path_display ctx path p;
 		end;
@@ -3475,8 +3476,11 @@ let type_module ctx mpath file ?(is_extern=false) tdecls p =
 			List.iter (fun mt -> match mt with
 				| TClassDecl c | TAbstractDecl({a_impl = Some c}) ->
 					ignore(c.cl_build());
-					let field cf =
-						ignore(follow cf.cf_type);
+					let field cf = match cf.cf_kind with
+						| Method MethMacro ->
+							(try ignore (ctx.g.do_macro ctx MDisplay c.cl_path cf.cf_name [] p) with Exit -> ())
+						| _ ->
+							ignore(follow cf.cf_type);
 					in
 					List.iter field c.cl_ordered_fields;
 					List.iter field c.cl_ordered_statics;

+ 1 - 0
src/typing/typer.ml

@@ -4931,6 +4931,7 @@ let get_macro_context ctx p =
 		Common.define com2 Define.Macro;
 		Common.init_platform com2 Neko;
 		let mctx = ctx.g.do_create com2 in
+		mctx.is_display_file <- ctx.is_display_file;
 		create_macro_interp ctx mctx;
 		api, mctx