Created
October 31, 2011 12:43
-
-
Save skial/1327413 to your computer and use it in GitHub Desktop.
Haxe -> javascript output -> [hand crafted] minified javascript output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import js.Lib; | |
class Main { | |
static function main() { | |
var div = Lib.document.getElementById('haxe:trace'); | |
div.innerHTML = 'Message from mini me'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(context) { | |
var $_, $hxClasses = {}, $estr = function() { return js.Boot.__string_rec(this,''); } | |
function $extend(from, fields) { | |
function inherit() {}; inherit.prototype = from; var proto = new inherit(); | |
for (var name in fields) proto[name] = fields[name]; | |
return proto; | |
} | |
var Std = $hxClasses["Std"] = function() { } | |
Std.__name__ = ["Std"]; | |
Std["is"] = function(v,t) { | |
return js.Boot.__instanceof(v,t); | |
} | |
Std.string = function(s) { | |
return js.Boot.__string_rec(s,""); | |
} | |
Std["int"] = function(x) { | |
if(x < 0) return Math.ceil(x); | |
return Math.floor(x); | |
} | |
Std.parseInt = function(x) { | |
var v = parseInt(x,10); | |
if(v == 0 && x.charCodeAt(1) == 120) v = parseInt(x); | |
if(isNaN(v)) return null; | |
return v; | |
} | |
Std.parseFloat = function(x) { | |
return parseFloat(x); | |
} | |
Std.random = function(x) { | |
return Math.floor(Math.random() * x); | |
} | |
Std.prototype = { | |
__class__: Std | |
} | |
var IntIter = $hxClasses["IntIter"] = function(min,max) { | |
this.min = min; | |
this.max = max; | |
} | |
IntIter.__name__ = ["IntIter"]; | |
IntIter.prototype = { | |
min: null | |
,max: null | |
,hasNext: function() { | |
return this.min < this.max; | |
} | |
,next: function() { | |
return this.min++; | |
} | |
,__class__: IntIter | |
} | |
var Main = $hxClasses["Main"] = function() { } | |
Main.__name__ = ["Main"]; | |
Main.main = function() { | |
var div = js.Lib.document.getElementById("haxe:trace"); | |
div.innerHTML = "Message from mini me"; | |
} | |
Main.prototype = { | |
__class__: Main | |
} | |
var js = {} | |
js.Lib = $hxClasses["js.Lib"] = function() { } | |
js.Lib.__name__ = ["js","Lib"]; | |
js.Lib.isIE = null; | |
js.Lib.isOpera = null; | |
js.Lib.document = null; | |
js.Lib.window = null; | |
js.Lib.alert = function(v) { | |
alert(js.Boot.__string_rec(v,"")); | |
} | |
js.Lib.eval = function(code) { | |
return eval(code); | |
} | |
js.Lib.setErrorHandler = function(f) { | |
js.Lib.onerror = f; | |
} | |
js.Lib.prototype = { | |
__class__: js.Lib | |
} | |
js.Boot = $hxClasses["js.Boot"] = function() { } | |
js.Boot.__name__ = ["js","Boot"]; | |
js.Boot.__unhtml = function(s) { | |
return s.split("&").join("&").split("<").join("<").split(">").join(">"); | |
} | |
js.Boot.__trace = function(v,i) { | |
var msg = i != null?i.fileName + ":" + i.lineNumber + ": ":""; | |
msg += js.Boot.__string_rec(v,""); | |
var d = document.getElementById("haxe:trace"); | |
if(d != null) d.innerHTML += js.Boot.__unhtml(msg) + "<br/>"; else if(typeof(console) != "undefined" && console.log != null) console.log(msg); | |
} | |
js.Boot.__clear_trace = function() { | |
var d = document.getElementById("haxe:trace"); | |
if(d != null) d.innerHTML = ""; | |
} | |
js.Boot.__string_rec = function(o,s) { | |
if(o == null) return "null"; | |
if(s.length >= 5) return "<...>"; | |
var t = typeof(o); | |
if(t == "function" && (o.__name__ != null || o.__ename__ != null)) t = "object"; | |
switch(t) { | |
case "object": | |
if(o instanceof Array) { | |
if(o.__enum__ != null) { | |
if(o.length == 2) return o[0]; | |
var str = o[0] + "("; | |
s += "\t"; | |
var _g1 = 2, _g = o.length; | |
while(_g1 < _g) { | |
var i = _g1++; | |
if(i != 2) str += "," + js.Boot.__string_rec(o[i],s); else str += js.Boot.__string_rec(o[i],s); | |
} | |
return str + ")"; | |
} | |
var l = o.length; | |
var i; | |
var str = "["; | |
s += "\t"; | |
var _g = 0; | |
while(_g < l) { | |
var i1 = _g++; | |
str += (i1 > 0?",":"") + js.Boot.__string_rec(o[i1],s); | |
} | |
str += "]"; | |
return str; | |
} | |
var tostr; | |
try { | |
tostr = o.toString; | |
} catch( e ) { | |
return "???"; | |
} | |
if(tostr != null && tostr != Object.toString) { | |
var s2 = o.toString(); | |
if(s2 != "[object Object]") return s2; | |
} | |
var k = null; | |
var str = "{\n"; | |
s += "\t"; | |
var hasp = o.hasOwnProperty != null; | |
for( var k in o ) { ; | |
if(hasp && !o.hasOwnProperty(k)) { | |
continue; | |
} | |
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__") { | |
continue; | |
} | |
if(str.length != 2) str += ", \n"; | |
str += s + k + " : " + js.Boot.__string_rec(o[k],s); | |
} | |
s = s.substring(1); | |
str += "\n" + s + "}"; | |
return str; | |
case "function": | |
return "<function>"; | |
case "string": | |
return o; | |
default: | |
return String(o); | |
} | |
} | |
js.Boot.__interfLoop = function(cc,cl) { | |
if(cc == null) return false; | |
if(cc == cl) return true; | |
var intf = cc.__interfaces__; | |
if(intf != null) { | |
var _g1 = 0, _g = intf.length; | |
while(_g1 < _g) { | |
var i = _g1++; | |
var i1 = intf[i]; | |
if(i1 == cl || js.Boot.__interfLoop(i1,cl)) return true; | |
} | |
} | |
return js.Boot.__interfLoop(cc.__super__,cl); | |
} | |
js.Boot.__instanceof = function(o,cl) { | |
try { | |
if(o instanceof cl) { | |
if(cl == Array) return o.__enum__ == null; | |
return true; | |
} | |
if(js.Boot.__interfLoop(o.__class__,cl)) return true; | |
} catch( e ) { | |
if(cl == null) return false; | |
} | |
switch(cl) { | |
case Int: | |
return Math.ceil(o%2147483648.0) === o; | |
case Float: | |
return typeof(o) == "number"; | |
case Bool: | |
return o === true || o === false; | |
case String: | |
return typeof(o) == "string"; | |
case Dynamic: | |
return true; | |
default: | |
if(o == null) return false; | |
return o.__enum__ == cl || cl == Class && o.__name__ != null || cl == Enum && o.__ename__ != null; | |
} | |
} | |
js.Boot.__init = function() { | |
js.Lib.isIE = typeof document!='undefined' && document.all != null && typeof window!='undefined' && window.opera == null; | |
js.Lib.isOpera = typeof window!='undefined' && window.opera != null; | |
Array.prototype.copy = Array.prototype.slice; | |
Array.prototype.insert = function(i,x) { | |
this.splice(i,0,x); | |
}; | |
Array.prototype.remove = Array.prototype.indexOf?function(obj) { | |
var idx = this.indexOf(obj); | |
if(idx == -1) return false; | |
this.splice(idx,1); | |
return true; | |
}:function(obj) { | |
var i = 0; | |
var l = this.length; | |
while(i < l) { | |
if(this[i] == obj) { | |
this.splice(i,1); | |
return true; | |
} | |
i++; | |
} | |
return false; | |
}; | |
Array.prototype.iterator = function() { | |
return { cur : 0, arr : this, hasNext : function() { | |
return this.cur < this.arr.length; | |
}, next : function() { | |
return this.arr[this.cur++]; | |
}}; | |
}; | |
if(String.prototype.cca == null) String.prototype.cca = String.prototype.charCodeAt; | |
String.prototype.charCodeAt = function(i) { | |
var x = this.cca(i); | |
if(x != x) return null; | |
return x; | |
}; | |
var oldsub = String.prototype.substr; | |
String.prototype.substr = function(pos,len) { | |
if(pos != null && pos != 0 && len != null && len < 0) return ""; | |
if(len == null) len = this.length; | |
if(pos < 0) { | |
pos = this.length + pos; | |
if(pos < 0) pos = 0; | |
} else if(len < 0) len = this.length + len - pos; | |
return oldsub.apply(this,[pos,len]); | |
}; | |
Function.prototype["$bind"] = function(o) { | |
var f = function() { | |
return f.method.apply(f.scope,arguments); | |
}; | |
f.scope = o; | |
f.method = this; | |
return f; | |
}; | |
} | |
js.Boot.prototype = { | |
__class__: js.Boot | |
} | |
js.Boot.__res = {} | |
js.Boot.__init(); | |
{ | |
String.prototype.__class__ = $hxClasses["String"] = String; | |
String.__name__ = ["String"]; | |
Array.prototype.__class__ = $hxClasses["Array"] = Array; | |
Array.__name__ = ["Array"]; | |
Int = $hxClasses["Int"] = { __name__ : ["Int"]}; | |
Dynamic = $hxClasses["Dynamic"] = { __name__ : ["Dynamic"]}; | |
Float = $hxClasses["Float"] = Number; | |
Float.__name__ = ["Float"]; | |
Bool = $hxClasses["Bool"] = { __ename__ : ["Bool"]}; | |
Class = $hxClasses["Class"] = { __name__ : ["Class"]}; | |
Enum = { }; | |
Void = $hxClasses["Void"] = { __ename__ : ["Void"]}; | |
} | |
{ | |
Math.__name__ = ["Math"]; | |
Math.NaN = Number["NaN"]; | |
Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"]; | |
Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"]; | |
$hxClasses["Math"] = Math; | |
Math.isFinite = function(i) { | |
return isFinite(i); | |
}; | |
Math.isNaN = function(i) { | |
return isNaN(i); | |
}; | |
} | |
{ | |
js.Lib.document = document; | |
js.Lib.window = window; | |
onerror = function(msg,url,line) { | |
var f = js.Lib.onerror; | |
if( f == null ) | |
return false; | |
return f(msg,[url+":"+line]); | |
} | |
} | |
js.Lib.onerror = null; | |
Main.main(); | |
context["haxe"] = context.haxe || haxe | |
})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(B){function Z(a,b){function c(){}c.prototype=a;var d=new c;for(var e in b)d[e]=b[e];return d}var $_,A={},C=function(){return H.e(this,"")},D=A.Std=function(){};D.a=["Std"],D.is=function(a,b){return H.g(a,b)},D.string=function(a){return H.e(a,"")},D.int=function(a){return a<0?Math.ceil(a):Math.floor(a)},D.parseInt=function(a){var b=parseInt(a,10);return b==0&&a.charCodeAt(1)==120&&(b=parseInt(a)),isNaN(b)?null:b},D.parseFloat=function(a){return parseFloat(a)},D.random=function(a){return Math.floor(Math.random()*a)},D.prototype={b:D};var E=A.IntIter=function(a,b){this.a=a,this.b=b};E.a=["IntIter"],E.prototype={a:null,b:null,c:function(){return this.a<this.b},d:function(){return this.a++},b:E};var F=A.Main=function(){};F.a=["Main"],F.F=function(){var a=G.d.getElementById("haxe:trace");a.innerHTML="Message from mini me"},F.prototype={b:F};var G={};G=A["js.Lib"]=function(){},G=["js","Lib"],G.b=G.c=G.d=G.e=null,G.f=function(a){alert(H.e(a,""))},G.g=function(a){return eval(a)},G.h=function(a){G.i=a},G.prototype={b:G},H=A["js.Boot"]=function(){},H.a=["js","Boot"],H.b=function(a){return a.split("&").join("&").split("<").join("<").split(">").join(">")},H.c=function(a,b){var c=b!=null?b.fileName+":"+b.lineNumber+": ":"";c+=H.e(a,"");var d=d.getElementById("haxe:trace");d!=null?d.innerHTML+=H.b(c)+"<br/>":typeof console!="undefined"&&console.log!=null&&console.log(c)},H.d=function(){var a=a.getElementById("haxe:trace");a!=null&&(a.innerHTML="")},H.e=function(a,b){if(a==null)return"null";if(b.length>=5)return"<...>";var c=typeof a;c=="function"&&(a.a!=null||a.P!=null)&&(c="object");switch(c){case"object":if(a instanceof Array){if(a.__enum__!=null){if(a.length==2)return a[0];var d=a[0]+"(";b+="\t";var e=2,f=a.length;while(e<f){var g=e++;g!=2?d+=","+H.e(a[g],b):d+=H.e(a[g],b)}return d+")"}var h=a.length,g,d="[";b+="\t";var f=0;while(f<h){var i=f++;d+=(i>0?",":"")+H.e(a[i],b)}return d+="]",d}var j;try{j=a.toString}catch(k){return"???"}if(j!=null&&j!=Object.toString){var l=a.toString();if(l!="[object Object]")return l}var m=null,d="{\n";b+="\t";var n=a.hasOwnProperty!=null;for(var m in a){if(n&&!a.hasOwnProperty(m))continue;if(m=="prototype"||m=="b"||m=="__super__"||m=="__interfaces__")continue;d.length!=2&&(d+=", \n"),d+=b+m+" : "+H.e(a[m],b)}return b=b.substring(1),d+="\n"+b+"}",d;case"function":return"<function>";case"string":return a;default:return String(a)}},H.f=function(a,b){if(a==null)return!1;if(a==b)return!0;var c=a.__interfaces__;if(c!=null){var d=0,e=c.length;while(d<e){var f=d++,g=c[f];if(g==b||H.f(g,b))return!0}}return H.f(a.__super__,b)},H.g=function(a,b){try{if(a instanceof b)return b==Array?a.__enum__==null:!0;if(H.f(a.b,b))return!0}catch(c){if(b==null)return!1}switch(b){case Int:return Math.ceil(a%2147483648)===a;case Float:return typeof a=="number";case Bool:return a===!0||a===!1;case String:return typeof a=="string";case Dynamic:return!0;default:if(a==null)return!1;return a.__enum__==b||b==Class&&a.a!=null||b==Enum&&a.P!=null}},H.h=function(){G.b=typeof d!="undefined"&&d.all!=null&&typeof e!="undefined"&&e.opera==null,G.c=typeof e!="undefined"&&e.opera!=null,Array.prototype.copy=Array.prototype.slice,Array.prototype.insert=function(a,b){this.splice(a,0,b)},Array.prototype.remove=Array.prototype.indexOf?function(a){var b=this.indexOf(a);return b==-1?!1:(this.splice(b,1),!0)}:function(a){var b=0,c=this.length;while(b<c){if(this[b]==a)return this.splice(b,1),!0;b++}return!1},Array.prototype.iterator=function(){return{cur:0,arr:this,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}},String.prototype.cca==null&&(String.prototype.cca=String.prototype.charCodeAt),String.prototype.charCodeAt=function(a){var b=this.cca(a);return b!=b?null:b};var a=String.prototype.substr;String.prototype.substr=function(b,c){return b!=null&&b!=0&&c!=null&&c<0?"":(c==null&&(c=this.length),b<0?(b=this.length+b,b<0&&(b=0)):c<0&&(c=this.length+c-b),a.apply(this,[b,c]))},Function.prototype.$bind=function(a){var b=function(){return b.method.apply(b.scope,arguments)};return b.scope=a,b.method=this,b}},H.prototype={b:H},H.i={},H.h(),String.prototype.b=A.String=String,String.a=["String"],Array.prototype.b=A.Array=Array,Array.a=["Array"],Int=A.Int={a:["Int"]},Dynamic=A.Dynamic={a:["Dynamic"]},Float=A.Float=Number,Float.a=["Float"],Bool=A.Bool={P:["Bool"]},Class=A.Class={a:["Class"]},Enum={},Void=A.Void={P:["Void"]},Math.a=["Math"],Math.NaN=Number.NaN,Math.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,Math.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,A.Math=Math,Math.isFinite=function(a){return isFinite(a)},Math.isNaN=function(a){return isNaN(a)},G.d=document,G.e=window,onerror=function(a,b,c){var d=G.onerror;return d==null?!1:d(a,[b+":"+c])},G.i=null,F.F(),B.haxe=B.haxe||haxe})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment