Simon Krajewski 1 год назад
Родитель
Сommit
fe25b83bc9

+ 0 - 10
src/generators/genjs.ml

@@ -1648,9 +1648,6 @@ let generate_type ctx = function
 	| TEnumDecl e -> generate_enum ctx e
 	| TTypeDecl _ | TAbstractDecl _ -> ()
 
-let set_current_class ctx c =
-	ctx.current <- c
-
 let alloc_ctx com es_version =
 	let smap =
 		if com.debug || Common.defined com Define.JsSourceMap || Common.defined com Define.SourceMap then
@@ -1707,13 +1704,6 @@ let alloc_ctx com es_version =
 	);
 	ctx
 
-let gen_single_expr ctx e expr =
-	if expr then gen_expr ctx e else gen_value ctx e;
-	let str = Rbuffer.unsafe_contents ctx.buf in
-	Rbuffer.reset ctx.buf;
-	ctx.id_counter <- 0;
-	str
-
 let generate com =
 	(match com.js_gen with
 	| Some g -> g()

+ 0 - 54
src/macro/macroApi.ml

@@ -40,7 +40,6 @@ type 'value compiler_api = {
 	allow_package : string -> unit;
 	type_patch : string -> string -> bool -> string option -> unit;
 	meta_patch : string -> string -> string option -> bool -> pos -> unit;
-	set_js_generator : (Genjs.ctx -> unit) -> unit;
 	get_local_type : unit -> t option;
 	get_expected_type : unit -> t option;
 	get_call_arguments : unit -> Ast.expr list option;
@@ -2015,59 +2014,6 @@ let macro_api ccom get_api =
 			};
 			vnull
 		);
-		"set_custom_js_generator", vfun1 (fun f ->
-			let f = prepare_callback f 1 in
-			(get_api()).set_js_generator (fun js_ctx ->
-				let com = ccom() in
-				Genjs.setup_kwds com;
-				let api = encode_obj [
-					"outputFile", encode_string com.file;
-					"types", encode_array (List.map (fun t -> encode_type (type_of_module_type t)) com.types);
-					"main", (match com.main with None -> vnull | Some e -> encode_texpr e);
-					"generateValue", vfun1 (fun v ->
-						let e = decode_texpr v in
-						let str = Genjs.gen_single_expr js_ctx e false in
-						encode_string str
-					);
-					"isKeyword", vfun1 (fun v ->
-						vbool (Hashtbl.mem Genjs.kwds (decode_string v))
-					);
-					"hasFeature", vfun1 (fun v ->
-						vbool (Common.has_feature com (decode_string v))
-					);
-					"addFeature", vfun1 (fun v ->
-						Common.add_feature com (decode_string v);
-						vnull
-					);
-					"quoteString", vfun1 (fun v ->
-						encode_string ("\"" ^ StringHelper.s_escape (decode_string v) ^ "\"")
-					);
-					"buildMetaData", vfun1 (fun t ->
-						match Texpr.build_metadata com.basic (decode_type_decl t) with
-						| None -> vnull
-						| Some e -> encode_texpr e
-					);
-					"generateStatement", vfun1 (fun v ->
-						let e = decode_texpr v in
-						let str = Genjs.gen_single_expr js_ctx e true in
-						encode_string str
-					);
-					"setTypeAccessor", vfun1 (fun callb ->
-						let callb = prepare_callback callb 1 in
-						js_ctx.Genjs.type_accessor <- (fun t ->
-							decode_string (callb [encode_type (type_of_module_type t)])
-						);
-						vnull
-					);
-					"setCurrentClass", vfun1 (fun c ->
-						Genjs.set_current_class js_ctx (match decode_type_decl c with TClassDecl c -> c | _ -> Globals.die "" __LOC__);
-						vnull
-					);
-				] in
-				ignore(f [api]);
-			);
-			vnull
-		);
 		"flush_disk_cache", vfun0 (fun () ->
 			let com = (get_api()).get_com() in
 			com.file_lookup_cache#clear;

+ 0 - 9
src/typing/macroContext.ml

@@ -225,15 +225,6 @@ let make_macro_com_api com mcom p =
 		meta_patch = (fun m t f s p ->
 			Interp.exc_string "unsupported"
 		);
-		set_js_generator = (fun gen ->
-			com.js_gen <- Some (fun() ->
-				Path.mkdir_from_path com.file;
-				let js_ctx = Genjs.alloc_ctx com (get_es_version com) in
-				let t = macro_timer com ["jsGenerator"] in
-				gen js_ctx;
-				t()
-			);
-		);
 		get_local_type = (fun() ->
 			Interp.exc_string "unsupported"
 		);

+ 0 - 9
std/haxe/macro/Compiler.hx

@@ -526,15 +526,6 @@ class Compiler {
 		#end
 	}
 
-	/**
-		Change the default JS output by using a custom generator callback
-	**/
-	public static function setCustomJSGenerator(callb:JSGenApi->Void) {
-		#if (neko || eval)
-		load("set_custom_js_generator", 1)(callb);
-		#end
-	}
-
 	#if (neko || eval)
 	static inline function load(f, nargs):Dynamic {
 		return @:privateAccess Context.load(f, nargs);

+ 0 - 15
tests/misc/projects/Issue8231/Main.hx

@@ -1,15 +0,0 @@
-class Main {
-	static var tmp:Int;
-
-	@:analyzer(ignore)
-	static function main() {
-		var finally = 999;
-		tmp = finally;
-	}
-
-	#if macro
-	static function setupGenerator() {
-		haxe.macro.Compiler.setCustomJSGenerator(api -> new haxe.macro.ExampleJSGenerator(api).generate());
-	}
-	#end
-}

+ 0 - 5
tests/misc/projects/Issue8231/compile.hxml

@@ -1,5 +0,0 @@
--main Main
---macro Main.setupGenerator()
--js bin/test.js
-
---cmd node bin/test.js