Quellcode durchsuchen

run analyzer transformation even if untyped is present

But don't optimize.
Simon Krajewski vor 9 Jahren
Ursprung
Commit
c1cb0a9b71

+ 3 - 3
analyzer.ml

@@ -93,7 +93,7 @@ let can_throw e =
 	let rec loop e = match e.eexpr with
 		| TConst _ | TLocal _ | TTypeExpr _ | TFunction _ | TBlock _ -> ()
 		| TCall _ | TNew _ | TThrow _ | TCast(_,Some _) -> raise Exit
-		| TField _ -> raise Exit (* sigh *)
+		| TField _ | TArray _ -> raise Exit (* sigh *)
 		| _ -> Type.iter loop e
 	in
 	try
@@ -216,8 +216,6 @@ module Config = struct
 						true
 					else
 						loop ml
-				| (Meta.HasUntyped,_,_) :: _ ->
-					true
 				| _ :: ml ->
 					loop ml
 				| [] ->
@@ -261,6 +259,8 @@ module Config = struct
 					| EConst (Ident s) when s = flag_dot_debug -> {config with dot_debug = true}
 					| _ -> config
 				) config el
+			| (Meta.HasUntyped,_,_) ->
+				{config with optimize = false}
 			| _ ->
 				config
 		) config meta

+ 3 - 1
std/cpp/_std/Reflect.hx

@@ -19,7 +19,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-@:coreApi class Reflect {
+@:coreApi
+@:analyzer(ignore)
+class Reflect {
 
 	public  static function hasField( o : Dynamic, field : String ) : Bool untyped {
 		return o!=null && o.__HasField(field);

+ 0 - 1
std/js/_std/Type.hx

@@ -99,7 +99,6 @@ enum ValueType {
 		default:
 			throw "Too many arguments";
 		}
-		return null;
 	}
 
 	public static function createEmptyInstance<T>( cl : Class<T> ) : T untyped {

+ 0 - 1
std/neko/_std/String.hx

@@ -77,7 +77,6 @@
 					return last;
 				last = p;
 			}
-			return null;
 		}
 	}
 

+ 2 - 2
std/neko/_std/Type.hx

@@ -68,7 +68,7 @@ enum ValueType {
 
 	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
 		var path = name.split(".");
-		cl = Reflect.field(untyped neko.Boot.__classes,path[0]);
+		var cl = Reflect.field(untyped neko.Boot.__classes,path[0]);
 		var i = 1;
 		while( cl != null && i < path.length ) {
 			cl = Reflect.field(cl,path[i]);
@@ -83,7 +83,7 @@ enum ValueType {
 
 	public static function resolveEnum( name : String ) : Enum<Dynamic> untyped {
 		var path = name.split(".");
-		e = Reflect.field(neko.Boot.__classes,path[0]);
+		var e = Reflect.field(neko.Boot.__classes,path[0]);
 		var i = 1;
 		while( e != null && i < path.length ) {
 			e = Reflect.field(e,path[i]);

+ 1 - 1
tests/optimization/src/TestJs.hx

@@ -61,7 +61,7 @@ class TestJs {
 		return v + v2;
 	}
 
-	@:js("var a = [];a;")
+	@:js("var a = [];var tmp;try {tmp = a[0];} catch( e ) {tmp = null;}tmp;")
 	@:analyzer(no_local_dce)
 	static function testInlineWithComplexExpr() {
 		var a = [];