Browse Source

Revert "[php] implemented direct method comparison"

This reverts commit f4b4a37578927308b5b0349e7a3413f0dbf7593a.
Alexander Kuzmenko 7 years ago
parent
commit
fc9d19c16e
4 changed files with 4 additions and 66 deletions
  1. 0 2
      extra/CHANGES.txt
  2. 4 37
      src/generators/genphp7.ml
  3. 0 5
      std/php/Boot.hx
  4. 0 22
      tests/unit/src/unit/TestPhp.hx

+ 0 - 2
extra/CHANGES.txt

@@ -6,8 +6,6 @@
 
 	General improvements and optimizations:
 
-	php : implemented direct method comparison. No need to use `Reflect.compareMethods()`
-
 	Removals:
 
 	Deprecations:

+ 4 - 37
src/generators/genphp7.ml

@@ -286,15 +286,6 @@ let is_int expr = match follow expr.etype with TAbstract ({ a_path = ([], "Int")
 *)
 let is_float expr = match follow expr.etype with TAbstract ({ a_path = ([], "Float") }, _) -> true | _ -> false
 
-(**
-	Check if specified expression is of `Int` or `Float` type
-*)
-let is_number expr =
-	match follow expr.etype with
-		| TAbstract ({ a_path = ([], "Float") }, _)
-		| TAbstract ({ a_path = ([], "Int") }, _) -> true
-		| _ -> false
-
 (**
 	Check if specified type is String
 *)
@@ -721,18 +712,6 @@ let is_magic expr =
 		)
 	| _ -> false
 
-(**
-	Check if `expr` is a closure created of a static or an instance method (except `dynamic` methods)
-*)
-let is_method_closure expr =
-	match (reveal_expr expr).eexpr with
-		| TField (_, access) ->
-			(match access with
-				| FClosure (_, field) -> not (is_dynamic_method field)
-				| _ -> false
-			)
-		| _ -> false
-
 (**
 	Check if `expr1` and `expr2` can be reliably checked for equality only with `Boot.equal()`
 *)
@@ -740,22 +719,10 @@ let need_boot_equal expr1 expr2 =
 	if is_constant_null expr1 || is_constant_null expr2 then
 		false
 	else
-		if is_method_closure expr1 || is_method_closure expr2 then
-			true
-		else
-			let unknown1 = is_unknown_type expr1.etype
-			and unknown2 = is_unknown_type expr2.etype in
-			if unknown1 && unknown2 then
-				true
-			else
-				let int1 = is_int expr1
-				and int2 = is_int expr2
-				and float1 = is_float expr1
-				and float2 = is_float expr2 in
-				(int1 && float2)
-				|| (float1 && (float2 || int2))
-				|| (unknown1 && (int2 || float2))
-				|| ((int1 || float1) && unknown2)
+		(is_int expr1 && (is_float expr2 || is_unknown_type expr2.etype))
+		|| (is_float expr1 && (is_float expr2 || is_int expr2 || is_unknown_type expr2.etype))
+		|| (is_unknown_type expr1.etype && (is_int expr2 || is_float expr2))
+		|| (is_unknown_type expr1.etype && is_unknown_type expr2.etype)
 
 (**
 	Adds `return` expression to block if it does not have one already

+ 0 - 5
std/php/Boot.hx

@@ -399,9 +399,6 @@ class Boot {
 		if (isNumber(left) && isNumber(right)) {
 			return Syntax.equal(left, right);
 		}
-		if (Std.is(left, HxClosure) && Std.is(right, HxClosure)) {
-			return (left:HxClosure).equals(right);
-		}
 		return Syntax.strictEqual(left, right);
 	}
 
@@ -575,8 +572,6 @@ private class HxClass {
 			return Global.constant('$phpClassName::$property');
 		} else if (Boot.hasGetter(phpClassName, property)) {
 			return Syntax.staticCall(phpClassName, 'get_$property');
-		} else if(phpClassName.method_exists(property)) {
-			return new HxClosure(phpClassName, property);
 		} else {
 			return Syntax.getStaticField(phpClassName, property);
 		}

+ 0 - 22
tests/unit/src/unit/TestPhp.hx

@@ -161,28 +161,6 @@ class TestPhp extends Test
 		eq(str.toUpperCase(), anon.toUpperCase());
 		eq(str.toString(), anon.toString());
 	}
-
-	function testClosureComparison() {
-		eq(ClosureDummy.testStatic, ClosureDummy.testStatic);
-		//Waiting for a fix: https://github.com/HaxeFoundation/haxe/issues/6719
-		// t(ClosureDummy.testStatic == ClosureDummy.testStatic);
-		t((ClosureDummy:Dynamic).testStatic == (ClosureDummy:Dynamic).testStatic);
-
-		var inst = new ClosureDummy();
-		eq(inst.test, inst.test);
-		//Waiting for a fix: https://github.com/HaxeFoundation/haxe/issues/6719
-		// t(inst.test == inst.test);
-		t((inst:Dynamic).test == (inst:Dynamic).test);
-		var inst2 = new ClosureDummy();
-		//Waiting for a fix: https://github.com/HaxeFoundation/haxe/issues/6719
-		// f(inst.test == inst2.test);
-	}
-}
-
-private class ClosureDummy {
-	static public function testStatic() {}
-	public function new() {}
-	public function test() {}
 }
 
 private class DummyForRef {