فهرست منبع

Revert "clear macro interpreter instead of creating a new one"

This reverts commit 9ad781c71f37fae61a50b594c48397ab345e876c.
Simon Krajewski 9 سال پیش
والد
کامیت
224021694a
2فایلهای تغییر یافته به همراه7 افزوده شده و 19 حذف شده
  1. 2 18
      src/macro/interp.ml
  2. 5 1
      src/typing/typer.ml

+ 2 - 18
src/macro/interp.ml

@@ -142,7 +142,7 @@ type callstack = {
 }
 
 type context = {
-	mutable gen : Genneko.context;
+	gen : Genneko.context;
 	types : (Type.path,int) Hashtbl.t;
 	prototypes : (string list, vobject) Hashtbl.t;
 	fields_cache : (int,string) Hashtbl.t;
@@ -3723,23 +3723,7 @@ let create com api =
 	List.iter (fun e -> ignore((eval ctx e)())) (Genneko.header());
 	ctx
 
-let clear ctx com =
-	Hashtbl.clear ctx.types;
-	Hashtbl.clear ctx.prototypes;
-	ctx.gen <- Genneko.new_context com 2 true;
-	ctx.locals_map <- PMap.empty;
-	ctx.locals_count <- 0;
-	ctx.locals_barrier <- 0;
-	ctx.locals_env <- DynArray.create();
-	ctx.globals <- PMap.empty;
-	ctx.callstack <- [];
-	ctx.callsize <- 0;
-	ctx.stack <- DynArray.create();
-	ctx.exc <- [];
-	ctx.vthis <- VNull;
-	ctx.venv <- [||];
-	select ctx;
-	List.iter (fun e -> ignore((eval ctx e)())) (Genneko.header())
+
 
 let do_reuse ctx api =
 	ctx.is_reused <- false;

+ 5 - 1
src/typing/typer.ml

@@ -4854,7 +4854,11 @@ and flush_macro_context mint ctx =
 	mctx.com.Common.modules <- modules;
 	(* if one of the type we are using has been modified, we need to create a new macro context from scratch *)
 	let mint = if not (Interp.can_reuse mint types) then begin
-		Interp.clear mint mctx.com;
+		let com2 = mctx.com in
+		let mint = Interp.create com2 (make_macro_api ctx Ast.null_pos) in
+		let macro = ((fun() -> Interp.select mint), mctx) in
+		ctx.g.macros <- Some macro;
+		mctx.g.macros <- Some macro;
 		init_macro_interp ctx mctx mint;
 		mint
 	end else mint in