ソースを参照

fixed issues with unset of values in for loops and executing blocks that return functions (haXe/PHP)

Franco Ponticelli 16 年 前
コミット
46c9ccec46
2 ファイル変更16 行追加7 行削除
  1. 1 0
      doc/CHANGES.txt
  2. 15 7
      genphp.ml

+ 1 - 0
doc/CHANGES.txt

@@ -17,6 +17,7 @@ TODO :
 	fixed __vector__ generation for AS3 target
 	fix with inline functions : position is now the inserted position and not the original one (better error reporting)
 	added SWC output support
+	fixed issues with unset of values in for loops and executing blocks that return functions (haXe/PHP)
 
 2008-11-23: 2.02
 	Std.is(MyInterface, Class) now returns true (haXe/PHP)

+ 15 - 7
genphp.ml

@@ -552,6 +552,14 @@ and gen_call ctx e el =
 		spr ctx ", array(";
 		concat ctx ", " (gen_value ctx) el;
 		spr ctx "))"
+	| TBlock _, el ->
+		ctx.is_call <- true;
+		spr ctx "call_user_func_array(";
+		gen_value ctx e;
+		ctx.is_call <- false;
+		spr ctx ", array(";
+		concat ctx ", " (gen_value ctx) el;
+		spr ctx "))"
 	| _ ->
 		ctx.is_call <- true;
 		gen_value ctx e;
@@ -822,7 +830,7 @@ and gen_inline_function ctx f params p =
 
 and gen_while_expr ctx e =
 	match e.eexpr with
-	| TBlock (el) ->
+	| TBlock (el) ->	
 		let old_l = ctx.inv_locals in
 		let b = save_locals ctx in
 		print ctx "{";
@@ -1277,7 +1285,7 @@ and gen_expr ctx e =
 		newline ctx;
 		print ctx "%s$%s = %s$%s->next()" p v p tmp;
 		newline ctx;
-		gen_expr ctx e;
+		gen_while_expr ctx e;
 		newline ctx;
 		spr ctx "}";
 		b();
@@ -1504,11 +1512,11 @@ and gen_value ctx e =
 		)) e.etype e.epos);
 		v()
 	| TTry (b,catchs) ->
-	let v = value true in
-	gen_expr ctx (mk (TTry (assign b,
-		List.map (fun (v,t,e) -> v, t , assign e) catchs
-	)) e.etype e.epos);
-	v()
+		let v = value true in
+		gen_expr ctx (mk (TTry (assign b,
+			List.map (fun (v,t,e) -> v, t , assign e) catchs
+		)) e.etype e.epos);
+		v()
 
 let is_method_defined ctx m static =
 	if static then