diff --git a/std/StringTools.hx b/std/StringTools.hx index b9a44311f78..1acc76e0b6a 100644 --- a/std/StringTools.hx +++ b/std/StringTools.hx @@ -45,7 +45,7 @@ class StringTools { #elseif neko return untyped new String(_urlEncode(s.__s)); #elseif js - return untyped encodeURIComponent(s); + return js.Lib.global.encodeURIComponent(s); #elseif cpp return untyped s.__URLEncode(); #elseif java @@ -111,7 +111,7 @@ class StringTools { #elseif neko return untyped new String(_urlDecode(s.__s)); #elseif js - return untyped decodeURIComponent(s.split("+").join(" ")); + return js.Lib.global.decodeURIComponent(s.split("+").join(" ")); #elseif cpp return untyped s.__URLDecode(); #elseif java diff --git a/std/cpp/_std/Std.hx b/std/cpp/_std/Std.hx index 4e09a314806..378fdffc740 100644 --- a/std/cpp/_std/Std.hx +++ b/std/cpp/_std/Std.hx @@ -40,7 +40,7 @@ } @:keep public static function string(s:Dynamic):String { - return untyped s == null ? "null" : s.toString(); + return s == null ? "null" : s.toString(); } @:keep public static function int(x:Float):Int { diff --git a/std/cpp/_std/sys/io/File.hx b/std/cpp/_std/sys/io/File.hx index 78fdebd596f..97459fca0cb 100644 --- a/std/cpp/_std/sys/io/File.hx +++ b/std/cpp/_std/sys/io/File.hx @@ -48,22 +48,22 @@ class File { } public static function read(path:String, binary:Bool = true):FileInput { - return untyped new FileInput(NativeFile.file_open(path, (if (binary) "rb" else "r"))); + return @:privateAccess new FileInput(NativeFile.file_open(path, (if (binary) "rb" else "r"))); } public static function write(path:String, binary:Bool = true):FileOutput { - return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "wb" else "w"))); + return @:privateAccess new FileOutput(NativeFile.file_open(path, (if (binary) "wb" else "w"))); } public static function append(path:String, binary:Bool = true):FileOutput { - return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "ab" else "a"))); + return @:privateAccess new FileOutput(NativeFile.file_open(path, (if (binary) "ab" else "a"))); } public static function update(path:String, binary:Bool = true):FileOutput { if (!FileSystem.exists(path)) { write(path).close(); } - return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "rb+" else "r+"))); + return @:privateAccess new FileOutput(NativeFile.file_open(path, (if (binary) "rb+" else "r+"))); } public static function copy(srcPath:String, dstPath:String):Void { diff --git a/std/haxe/DynamicAccess.hx b/std/haxe/DynamicAccess.hx index 91f552bbf35..8feaf8b6fd3 100644 --- a/std/haxe/DynamicAccess.hx +++ b/std/haxe/DynamicAccess.hx @@ -50,7 +50,7 @@ abstract DynamicAccess(Dynamic) from Dynamic to Dynamic { @:arrayAccess public inline function get(key:String):Null { #if js - return untyped this[key]; // we know it's an object, so we don't need a check + return js.Syntax.code("{0}[{1}]", this, key); // we know it's an object, so we don't need a check #else return Reflect.field(this, key); #end @@ -68,7 +68,7 @@ abstract DynamicAccess(Dynamic) from Dynamic to Dynamic { @:arrayAccess public inline function set(key:String, value:T):T { #if js - return untyped this[key] = value; + return js.Syntax.code("{0}[{1}] = {2}", this, key, value); #else Reflect.setField(this, key, value); return value; diff --git a/std/haxe/EntryPoint.hx b/std/haxe/EntryPoint.hx index 27eb45da728..c12e5f3fce1 100644 --- a/std/haxe/EntryPoint.hx +++ b/std/haxe/EntryPoint.hx @@ -12,7 +12,7 @@ class EntryPoint { var nextTick = haxe.EventLoop.main.getNextTick(); inline function setTimeoutNextTick() { if (nextTick >= 0) { - (untyped setTimeout)(run, nextTick * 1000); + js.Lib.global.setTimeout(run, nextTick * 1000); } } #if nodejs diff --git a/std/haxe/Int32.hx b/std/haxe/Int32.hx index 615bea1860a..91b90147fc5 100644 --- a/std/haxe/Int32.hx +++ b/std/haxe/Int32.hx @@ -78,10 +78,13 @@ abstract Int32(Int) from Int to Int { @:op(A * B) inline static function mul(a:Int32, b:Int32):Int32 return _mul(a, b); - static var _mul:Int32->Int32->Int32 = untyped if (Math.imul != null) - Math.imul + static var _mul:Int32->Int32->Int32 = { + final imul:Dynamic = (cast Math : Dynamic).imul; + if (imul != null) + cast imul else function(a:Int32, b:Int32):Int32 return clamp((a : Int) * ((b : Int) & 0xFFFF) + clamp((a : Int) * ((b : Int) >>> 16) << 16)); + } #else @:op(A * B) private static function mul(a:Int32, b:Int32):Int32 return clamp((a : Int) * ((b : Int) & 0xFFFF) + clamp((a : Int) * ((b : Int) >>> 16) << 16)); diff --git a/std/haxe/Log.hx b/std/haxe/Log.hx index 08d8b7fcead..131eecda6c0 100644 --- a/std/haxe/Log.hx +++ b/std/haxe/Log.hx @@ -62,8 +62,9 @@ class Log { public static dynamic function trace(v:Dynamic, ?infos:PosInfos):Void { var str = formatOutput(v, infos); #if js - if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null) - (untyped console).log(str); + var console = js.Lib.global.console; + if (js.Syntax.typeof(console) != "undefined" && console.log != null) + console.log(str); #elseif lua untyped __define_feature__("use._hx_print", _hx_print(str)); #elseif sys diff --git a/std/haxe/Timer.hx b/std/haxe/Timer.hx index ccf04173aa7..ba178d76850 100644 --- a/std/haxe/Timer.hx +++ b/std/haxe/Timer.hx @@ -69,7 +69,7 @@ class Timer { }, time_ms); #elseif js var me = this; - id = untyped setInterval(function() me.run(), time_ms); + id = js.Lib.global.setInterval(function() me.run(), time_ms); #else event = EventLoop.current.addTimer(() -> this.run(), time_ms/1000.); #end @@ -90,7 +90,7 @@ class Timer { #if flash untyped __global__["flash.utils.clearInterval"](id); #elseif js - untyped clearInterval(id); + js.Lib.global.clearInterval(id); #end id = null; #else diff --git a/std/haxe/rtti/Meta.hx b/std/haxe/rtti/Meta.hx index 4505e66a481..9da7e51c572 100644 --- a/std/haxe/rtti/Meta.hx +++ b/std/haxe/rtti/Meta.hx @@ -60,7 +60,7 @@ class Meta { var t:hl.BaseType = t; return t.__meta__; #else - return untyped t.__meta__; + return t.__meta__; #end } diff --git a/std/js/Boot.hx b/std/js/Boot.hx index 6b299bcbadd..0677ffadd1e 100644 --- a/std/js/Boot.hx +++ b/std/js/Boot.hx @@ -107,7 +107,7 @@ class Boot { } var tostr; try { - tostr = untyped o.toString; + tostr = o.toString; } catch (e:Dynamic) { // strange error on IE return "???"; diff --git a/std/js/Cookie.hx b/std/js/Cookie.hx index 8994cc68321..45ec9d41c3a 100644 --- a/std/js/Cookie.hx +++ b/std/js/Cookie.hx @@ -33,7 +33,7 @@ class Cookie { var s = name + "=" + StringTools.urlEncode(value); if (expireDelay != null) { var d = DateTools.delta(Date.now(), expireDelay * 1000); - s += ";expires=" + untyped d.toGMTString(); + s += ";expires=" + (d : Dynamic).toGMTString(); } if (path != null) { s += ";path=" + path; diff --git a/std/js/Selection.hx b/std/js/Selection.hx index 6731e3d1fa1..afcfcb96a6f 100644 --- a/std/js/Selection.hx +++ b/std/js/Selection.hx @@ -36,7 +36,7 @@ class Selection { if (doc.selectionStart != null) return doc.value.substring(doc.selectionStart, doc.selectionEnd); // IE - var range = untyped js.Lib.document.selection.createRange(); + var range = (js.Lib.document : Dynamic).selection.createRange(); if (range.parentElement() != doc) return ""; return range.text; @@ -92,7 +92,7 @@ class Selection { return; } // IE - var range = untyped js.Lib.document.selection.createRange(); + var range = (js.Lib.document : Dynamic).selection.createRange(); range.text = left + text + right; range.moveStart('character', -text.length - right.length); range.moveEnd('character', -right.length); diff --git a/std/js/_std/Reflect.hx b/std/js/_std/Reflect.hx index db99e909748..906f482cd2c 100644 --- a/std/js/_std/Reflect.hx +++ b/std/js/_std/Reflect.hx @@ -111,7 +111,7 @@ public static function makeVarArgs(f:Array->T):Dynamic { return function() { - var a = untyped Array.prototype.slice.call(js.Syntax.code("arguments")); + var a:Array = js.Syntax.code("Array.prototype.slice.call(arguments)"); return f(a); }; } diff --git a/std/js/_std/haxe/ds/ObjectMap.hx b/std/js/_std/haxe/ds/ObjectMap.hx index 970665b5a9e..cac9f3af8cb 100644 --- a/std/js/_std/haxe/ds/ObjectMap.hx +++ b/std/js/_std/haxe/ds/ObjectMap.hx @@ -99,7 +99,7 @@ class ObjectMap implements haxe.Constraints.IMap { } static inline function getId(obj:{}):Int { - return untyped obj.__id__; + return Syntax.code("{0}.__id__", obj); } var h:{__keys__:{}}; @@ -118,16 +118,16 @@ class ObjectMap implements haxe.Constraints.IMap { } public inline function get(key:K):Null { - return untyped h[getId(key)]; + return Syntax.code("{0}[{1}]", h, getId(key)); } public inline function exists(key:K):Bool { - return untyped h.__keys__[getId(key)] != null; + return Syntax.code("{0}[{1}] != null", h.__keys__, getId(key)); } public function remove(key:K):Bool { var id = getId(key); - if (untyped h.__keys__[id] == null) + if (Syntax.code("{0}[{1}] == null", h.__keys__, id)) return false; js.Syntax.delete(h, id); js.Syntax.delete(h.__keys__, id); diff --git a/std/js/lib/ArrayBuffer.hx b/std/js/lib/ArrayBuffer.hx index 49a5302157e..30534499d00 100644 --- a/std/js/lib/ArrayBuffer.hx +++ b/std/js/lib/ArrayBuffer.hx @@ -44,8 +44,7 @@ private class ArrayBufferCompat { return resultArray.buffer; } - static function __init__():Void - untyped { + static function __init__():Void { // IE10 ArrayBuffer.slice polyfill if (js.Syntax.code("ArrayBuffer").prototype.slice == null) js.Syntax.code("ArrayBuffer").prototype.slice = sliceImpl; diff --git a/std/jvm/_std/EReg.hx b/std/jvm/_std/EReg.hx index bc4624342a1..0b91c22b64c 100644 --- a/std/jvm/_std/EReg.hx +++ b/std/jvm/_std/EReg.hx @@ -59,11 +59,11 @@ using StringTools; } public function matchedLeft():String { - return untyped cur.substring(0, matcher.start()); + return cur.substring(0, matcher.start()); } public function matchedRight():String { - return untyped cur.substring(matcher.end(), cur.length); + return cur.substring(matcher.end(), cur.length); } public function matchedPos():{pos:Int, len:Int} { @@ -117,7 +117,7 @@ using StringTools; var m = matcher; m.reset(s); if (m.find()) { - return untyped [s.substring(0, m.start()), s.substring(m.end(), s.length)]; + return [s.substring(0, m.start()), s.substring(m.end(), s.length)]; } else { return [s]; } diff --git a/std/jvm/_std/haxe/ds/WeakMap.hx b/std/jvm/_std/haxe/ds/WeakMap.hx index 69183d4d0a7..d9139de2370 100644 --- a/std/jvm/_std/haxe/ds/WeakMap.hx +++ b/std/jvm/_std/haxe/ds/WeakMap.hx @@ -465,7 +465,7 @@ import java.lang.ref.ReferenceQueue; // guarantee: Whatever this function is, it will never return 0 nor 1 extern private static inline function hash(s:Dynamic):HashType { - var k:Int = untyped s.hashCode(); + var k:Int = (cast s : java.lang.Object).hashCode(); // k *= 357913941; // k ^= k << 24; // k += ~357913941; @@ -512,7 +512,7 @@ private class Entry extends WeakReference { } final inline public function keyEquals(k:K):Bool { - return k != null && untyped k.equals(get()); + return k != null && (cast k : java.lang.Object).equals(get()); } } diff --git a/std/lua/_std/Std.hx b/std/lua/_std/Std.hx index 57c54a05b19..e8198512aa2 100644 --- a/std/lua/_std/Std.hx +++ b/std/lua/_std/Std.hx @@ -30,12 +30,14 @@ import lua.NativeStringTools; return isOfType(v, t); } + @:access(lua.Boot) public static inline function isOfType(v:Dynamic, t:Dynamic):Bool { - return untyped lua.Boot.__instanceof(v, t); + return lua.Boot.__instanceof(v, t); } + @:access(lua.Boot) public static inline function downcast(value:T, c:Class):Null { - return untyped lua.Boot.__instanceof(value, c) ? cast value : null; + return lua.Boot.__instanceof(value, c) ? cast value : null; } @:deprecated('Std.instance() is deprecated. Use Std.downcast() instead.') @@ -94,6 +96,6 @@ import lua.NativeStringTools; } public static function random(x:Int):Int { - return untyped x <= 0 ? 0 : Math.floor(Math.random() * x); + return x <= 0 ? 0 : Math.floor(Math.random() * x); } } diff --git a/std/neko/_std/Std.hx b/std/neko/_std/Std.hx index 6d7567f83dd..f104a65709d 100644 --- a/std/neko/_std/Std.hx +++ b/std/neko/_std/Std.hx @@ -26,8 +26,9 @@ return isOfType(v, t); } + @:access(neko.Boot) public static function isOfType(v:Dynamic, t:Dynamic):Bool { - return untyped neko.Boot.__instanceof(v, t); + return neko.Boot.__instanceof(v, t); } public static function downcast(value:T, c:Class):Null { diff --git a/std/neko/_std/Sys.hx b/std/neko/_std/Sys.hx index 735878db8a4..26ddabf6e07 100644 --- a/std/neko/_std/Sys.hx +++ b/std/neko/_std/Sys.hx @@ -36,15 +36,15 @@ import haxe.SysTools; } public static function stdin() : haxe.io.Input { - return untyped new sys.io.FileInput(file_stdin()); + return @:privateAccess new sys.io.FileInput(file_stdin()); } public static function stdout() : haxe.io.Output { - return untyped new sys.io.FileOutput(file_stdout()); + return @:privateAccess new sys.io.FileOutput(file_stdout()); } public static function stderr() : haxe.io.Output { - return untyped new sys.io.FileOutput(file_stderr()); + return @:privateAccess new sys.io.FileOutput(file_stderr()); } public static function args() : Array untyped { diff --git a/std/php/_std/sys/io/File.hx b/std/php/_std/sys/io/File.hx index b1a7794ebc9..6c42aa7bcd3 100644 --- a/std/php/_std/sys/io/File.hx +++ b/std/php/_std/sys/io/File.hx @@ -49,18 +49,18 @@ import php.Global; } public static function write(path:String, binary:Bool = true):FileOutput { - return untyped new FileOutput(fopen(path, binary ? "wb" : "w")); + return @:privateAccess new FileOutput(fopen(path, binary ? "wb" : "w")); } public static function append(path:String, binary:Bool = true):FileOutput { - return untyped new FileOutput(fopen(path, binary ? "ab" : "a")); + return @:privateAccess new FileOutput(fopen(path, binary ? "ab" : "a")); } public static function update(path:String, binary:Bool = true):FileOutput { if (!FileSystem.exists(path)) { write(path).close(); } - return untyped new FileOutput(fopen(path, binary ? "rb+" : "r+")); + return @:privateAccess new FileOutput(fopen(path, binary ? "rb+" : "r+")); } public static function copy(srcPath:String, dstPath:String):Void {