Browse Source

fixed bugs in flash -debug

Nicolas Cannasse 19 years ago
parent
commit
9b7b3d9926
4 changed files with 20 additions and 9 deletions
  1. 3 0
      doc/CHANGES.txt
  2. 4 4
      genswf8.ml
  3. 2 1
      std/flash/Boot.hx
  4. 11 4
      transform.ml

+ 3 - 0
doc/CHANGES.txt

@@ -1,3 +1,6 @@
+2006-??-??: 1.08
+	fixed bug in flash -debug
+
 2006-09-11: 1.07
 	fixed resources in Neko
 	typedef, override, package and f9dynamic are now keywords

+ 4 - 4
genswf8.ml

@@ -412,7 +412,7 @@ let free_reg ctx r p =
 (* Generation Helpers *)
 
 let define_var ctx v ef exprs =
-	if ctx.version = 6 || List.exists (Transform.local_find false v) exprs || v = Transform.stack_var_pos then begin
+	if ctx.version = 6 || List.exists (Transform.local_find false v) exprs then begin
 		push ctx [VStr (v,false)];
 		ctx.regs <- PMap.add v NoReg ctx.regs;
 		match ef with
@@ -911,11 +911,11 @@ and gen_expr_2 ctx retval e =
 		ctx.fun_pargs <- (ctx.code_pos, List.rev !pargs) :: ctx.fun_pargs;
 		if ctx.debug then begin
 			let start_try = gen_try ctx in
-			gen_expr ctx false (Transform.stack_block (ctx.curclass,fst ctx.curmethod) f.tf_expr);
+			gen_expr ctx false (Transform.stack_block ~useadd:true (ctx.curclass,fst ctx.curmethod) f.tf_expr);
 			let end_try = start_try() in
 			(* if $spos == 1 , then no upper call, so report as uncaught *)
-			push ctx [VInt 1; VStr (Transform.stack_var_pos,false)];
-			write ctx AEval;
+			getvar ctx (access_local ctx Transform.stack_var_pos);
+			push ctx [VInt 1];
 			write ctx AEqual;
 			write ctx ANot;
 			let j = cjmp ctx in

+ 2 - 1
std/flash/Boot.hx

@@ -1,3 +1,4 @@
+/*
 /*
  * Copyright (c) 2005, The haXe Project Contributors
  * All rights reserved.
@@ -178,7 +179,7 @@ class Boot {
 		var a : Array<String> = untyped __eval__("$s");
 		for( i in 0...a.length-1 )
 			s += "\nCalled from "+a[i];
-		var old = a.copy();
+		var old = a.slice(0,a.length-1);
 		a.splice(0,a.length);
 		#end
 		if( untyped Lib.onerror != null )

+ 11 - 4
transform.ml

@@ -208,9 +208,16 @@ let stack_var_pos = "$spos"
 let stack_e = emk (TLocal stack_var)
 let stack_pop = emk (TCall (emk (TField (stack_e,"pop")),[]))
 
-let stack_push (c,m) =
+let stack_push useadd (c,m) =
 	emk (TCall (emk (TField (stack_e,"push")),[
-		emk (TConst (TString (Ast.s_type_path c.cl_path ^ "::" ^ m)))
+		if useadd then
+			emk (TBinop (
+				Ast.OpAdd,
+				emk (TConst (TString (Ast.s_type_path c.cl_path ^ "::"))),
+				emk (TConst (TString m))
+			))
+		else
+			emk (TConst (TString (Ast.s_type_path c.cl_path ^ "::" ^ m)))
 	]))
 
 let stack_save_pos =
@@ -237,7 +244,7 @@ let stack_restore_pos =
 	emk (TCall (emk (TField (stack_e,"push")),[ emk (TArray (ev,emk (TConst (TInt 0l)))) ]))
 	]
 
-let stack_block ctx e =
+let stack_block ?(useadd=false) ctx e =
 	let rec loop e =
 		match e.eexpr with
 		| TFunction _ ->
@@ -263,5 +270,5 @@ let stack_block ctx e =
 			map loop e
 	in
 	match (block e).eexpr with
-	| TBlock l -> mk (TBlock (stack_push ctx :: stack_save_pos :: List.map loop l @ [stack_pop])) e.etype e.epos
+	| TBlock l -> mk (TBlock (stack_push useadd ctx :: stack_save_pos :: List.map loop l @ [stack_pop])) e.etype e.epos
 	| _ -> assert false