-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add scala-js support for fibonacci & loops #289
Merged
+78
−35
Conversation
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
@PEZ This one is tested on my local note book |
He-Pin
changed the title
chore: add scala-js support for fibonacci
chore: add scala-js support for fibonacci & loops
Dec 22, 2024
(function(){
'use strict';Object.freeze({esVersion:6,assumingES6:!0,isWebAssembly:!1,productionMode:!0,linkerVersion:"1.17.0",fileLevelThis:this});var aa;function ba(){var a=ca(da.g,0);switch(typeof a){case "string":return f(ea);case "number":return fa(a)?a<<24>>24===a?f(ha):a<<16>>16===a?f(ia):f(ja):ka(a)?f(la):f(ma);case "boolean":return f(na);case "undefined":return f(oa);default:return null===a?a.U():a instanceof g?f(pa):a&&a.$classData?f(a.$classData):null}}
function m(a){switch(typeof a){case "string":return"java.lang.String";case "number":return fa(a)?a<<24>>24===a?"java.lang.Byte":a<<16>>16===a?"java.lang.Short":"java.lang.Integer":ka(a)?"java.lang.Float":"java.lang.Double";case "boolean":return"java.lang.Boolean";case "undefined":return"java.lang.Void";default:return null===a?a.U():a instanceof g?"java.lang.Long":a&&a.$classData?a.$classData.name:null.ga()}}function qa(a,b){if(0===b)throw new ra("/ by zero");return a%b|0}var sa=0,ta=new WeakMap;
function ua(a){switch(typeof a){case "string":return va(a);case "number":wa||(wa=new n);var b=wa;var c=a|0;c===a&&-Infinity!==1/a?a=c:(b.K[0]=a,a=(b.v[0]|0)^(b.v[1]|0));return a;case "bigint":b=0;for(a<BigInt(0)&&(a=~a);a!==BigInt(0);)b^=Number(BigInt.asIntN(32,a)),a>>=BigInt(32);return b;case "boolean":return a?1231:1237;case "undefined":return 0;case "symbol":return a=a.description,void 0===a?0:va(a);default:if(null===a)return 0;b=ta.get(a);void 0===b&&(sa=b=sa+1|0,ta.set(a,b));return b}}
function fa(a){return"number"===typeof a&&(a|0)===a&&1/a!==1/-0}function ka(a){return"number"===typeof a&&(a!==a||Math.fround(a)===a)}function p(){}p.prototype.constructor=p;function q(){}q.prototype=p.prototype;p.prototype.r=function(){return ua(this)};p.prototype.i=function(){var a=this.r();return m(this)+"@"+(+(a>>>0)).toString(16)};p.prototype.toString=function(){return this.i()};function t(a){if("number"===typeof a){this.a=Array(a);for(var b=0;b<a;b++)this.a[b]=null}else this.a=a}
t.prototype=new q;t.prototype.constructor=t;function xa(){}xa.prototype=t.prototype;function u(a){if("number"===typeof a){this.a=Array(a);for(var b=0;b<a;b++)this.a[b]=!1}else this.a=a}u.prototype=new q;u.prototype.constructor=u;function v(a){this.a="number"===typeof a?new Uint16Array(a):a}v.prototype=new q;v.prototype.constructor=v;function w(a){this.a="number"===typeof a?new Int8Array(a):a}w.prototype=new q;w.prototype.constructor=w;function x(a){this.a="number"===typeof a?new Int16Array(a):a}
x.prototype=new q;x.prototype.constructor=x;function y(a){this.a="number"===typeof a?new Int32Array(a):a}y.prototype=new q;y.prototype.constructor=y;function z(a){if("number"===typeof a){this.a=Array(a);for(var b=0;b<a;b++)this.a[b]=aa}else this.a=a}z.prototype=new q;z.prototype.constructor=z;function A(a){this.a="number"===typeof a?new Float32Array(a):a}A.prototype=new q;A.prototype.constructor=A;function B(a){this.a="number"===typeof a?new Float64Array(a):a}B.prototype=new q;
B.prototype.constructor=B;function C(){this.m=void 0;this.k=this.q=this.e=null;this.l=0;this.Q=null;this.f="";this.h=this.j=this.D=void 0;this.name="";this.I=this.s=!1;this.n=void 0}function D(a,b,c,d){var e=new C;e.e={};e.Q=a;e.f=b;e.h=h=>h===e;e.name=c;e.s=!0;e.n=()=>!1;void 0!==d&&(e.j=ya(e,d));return e}
function E(a,b,c,d){var e=new C,h=Object.getOwnPropertyNames(c)[0];e.e=c;e.f="L"+b+";";e.h=l=>!!l.e[h];e.name=b;e.I=1===a;e.n=d||(l=>!!(l&&l.$classData&&l.$classData.e[h]));"number"!==typeof a&&(a.prototype.$classData=e);return e}function ya(a,b,c){var d=new C;b.prototype.$classData=d;var e="["+a.f;d.m=b;d.e={W:1,b:1};d.q=a;d.k=a;d.l=1;d.f=e;d.name=e;d.h=c||(h=>d===h);d.n=h=>h instanceof b;return d}
function za(a){function b(k){if("number"===typeof k){this.a=Array(k);for(var r=0;r<k;r++)this.a[r]=null}else this.a=k}var c=new C;b.prototype=new xa;b.prototype.constructor=b;b.prototype.$classData=c;var d=a.k||a,e=a.l+1,h="["+a.f;c.m=b;c.e={W:1,b:1};c.q=a;c.k=d;c.l=e;c.f=h;c.name=h;var l=k=>{var r=k.l;return r===e?d.h(k.k):r>e&&d===F};c.h=l;c.n=k=>{k=k&&k.$classData;return!!k&&(k===c||l(k))};return c}function Aa(a){a.j||(a.j=za(a));return a.j}function f(a){a.D||(a.D=new G(a));return a.D}
function ca(a,b){if(a===Ba)throw Ca();return new (Aa(a).m)(b)}var F=new C;F.e={};F.f="Ljava.lang.Object;";F.h=a=>!a.s;F.name="java.lang.Object";F.n=a=>null!==a;F.j=ya(F,t,a=>{var b=a.l;return 1===b?!a.k.s:1<b});p.prototype.$classData=F;var Ba=D(void 0,"V","void",void 0);D(!1,"Z","boolean",u);D(0,"C","char",v);D(0,"B","byte",w);D(0,"S","short",x);var Da=D(0,"I","int",y),Ea=D(null,"J","long",z);D(0,"F","float",A);D(0,"D","double",B);function H(){}H.prototype=new q;H.prototype.constructor=H;
E(H,"Loop$",{Z:1});var Fa;function I(){}I.prototype=new q;I.prototype.constructor=I;E(I,"MainJS$",{$:1});var Ga;function n(){this.K=this.v=this.o=null;wa=this;this.o=new ArrayBuffer(8);this.v=new Int32Array(this.o,0,2);new Float32Array(this.o,0,2);this.K=new Float64Array(this.o,0,1);this.v[0]=16909060;new Int8Array(this.o,0,8)}n.prototype=new q;n.prototype.constructor=n;E(n,"java.lang.FloatingPointBits$",{ra:1});var wa;function J(){this.L=null;Ha=this;this.L=new K(!1)}J.prototype=new q;
J.prototype.constructor=J;E(J,"java.lang.System$Streams$",{Aa:1});var Ha,oa=E(0,"java.lang.Void",{Ba:1},a=>void 0===a);function L(){}L.prototype=new q;L.prototype.constructor=L;E(L,"java.lang.reflect.Array$",{Ca:1});var Ia;function Ja(){Ia||(Ia=new L);return Ia}function M(){}M.prototype=new q;M.prototype.constructor=M;E(M,"java.util.Arrays$",{Da:1});var Ka;function g(a,b){this.C=a;this.B=b}g.prototype=new q;g.prototype.constructor=g;g.prototype.r=function(){return this.C^this.B};
g.prototype.i=function(){La||(La=new Ma);var a=this.C,b=this.B;return b===a>>31?""+a:0>b?"-"+Na(-a|0,0!==a?~b:-b|0):Na(a,b)};E(g,"org.scalajs.linker.runtime.RuntimeLong",{ca:1});
function Na(a,b){if(0===(-2097152&b))b=""+(4294967296*b+ +(a>>>0));else{var c=(32+(Math.clz32(1E9)|0)|0)-(0!==b?Math.clz32(b)|0:32+(Math.clz32(a)|0)|0)|0,d=c,e=0===(32&d)?1E9<<d:0;d=0===(32&d)?5E8>>>(31-d|0)|0|0<<d:1E9<<d;var h=a,l=b;for(a=b=0;0<=c&&0!==(-2097152&l);){var k=h,r=l,qc=e,qb=d;if(r===qb?(-2147483648^k)>=(-2147483648^qc):(-2147483648^r)>=(-2147483648^qb))k=l,r=d,l=h-e|0,k=(-2147483648^l)>(-2147483648^h)?-1+(k-r|0)|0:k-r|0,h=l,l=k,32>c?b|=1<<c:a|=1<<c;c=-1+c|0;k=d>>>1|0;e=e>>>1|0|d<<31;
d=k}c=l;if(0===c?-1147483648<=(-2147483648^h):-2147483648<=(-2147483648^c))c=4294967296*l+ +(h>>>0),h=c/1E9,e=h/4294967296|0,d=b,b=h=d+(h|0)|0,a=(-2147483648^h)<(-2147483648^d)?1+(a+e|0)|0:a+e|0,h=c%1E9|0;c=""+h;b=""+(4294967296*a+ +(b>>>0))+"000000000".substring(c.length)+c}return b}function Ma(){}Ma.prototype=new q;Ma.prototype.constructor=Ma;E(Ma,"org.scalajs.linker.runtime.RuntimeLong$",{da:1});var La;function Oa(){}Oa.prototype=new q;Oa.prototype.constructor=Oa;
E(Oa,"scala.runtime.ScalaRunTime$",{La:1});var Pa;function Qa(){}Qa.prototype=new q;Qa.prototype.constructor=Qa;E(Qa,"scala.scalajs.js.ArrayOps$",{Ka:1});var Ra;function N(a){this.P=a}N.prototype=new q;N.prototype.constructor=N;N.prototype.i=function(){return"DynamicVariable("+this.P+")"};E(N,"scala.util.DynamicVariable",{Ja:1});
function Sa(){var a=Ta;0===(32&a.t)<<24>>24&&0===(32&a.t)<<24>>24&&(a.J=new y(new Int32Array([1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72784,73040,73120,73552,92768,92864,93008,120782,120792,120802,120812,120822,123200,123632,124144,125264,130032])),a.t=(32|a.t)<<24>>24);
return a.J}function Ua(){this.J=null;this.t=0}Ua.prototype=new q;Ua.prototype.constructor=Ua;E(Ua,"java.lang.Character$",{na:1,b:1});var Va;function Wa(){throw new Xa('For input string: "'+O+'"');}function Ya(){}Ya.prototype=new q;Ya.prototype.constructor=Ya;E(Ya,"java.lang.Integer$",{ta:1,b:1});var Za;function P(a,b){a.M=b;"[object Error]"!==Object.prototype.toString.call(a)&&(void 0===Error.captureStackTrace||Object.isSealed(a)?Error():Error.captureStackTrace(a))}
class $a extends Error{constructor(){super();this.M=null}E(){return this.M}i(){var a=m(this),b=this.E();return null===b?a:a+": "+b}r(){return p.prototype.r.call(this)}get message(){var a=this.E();return null===a?"":a}get name(){return m(this)}toString(){return this.i()}}function ab(){this.G=this.F=0}ab.prototype=new q;ab.prototype.constructor=ab;E(ab,"java.util.Random",{Ea:1,b:1});
function bb(){var a=4294967296*+Math.random();a=+Math.floor(a)-2147483648;return 2147483647<a?2147483647:-2147483648>a?-2147483648:a|0}function cb(){}cb.prototype=new q;cb.prototype.constructor=cb;E(cb,"java.util.Random$",{Fa:1,b:1});var db;function eb(){this.N=null;fb=this;Ha||(Ha=new J);this.N=new N(Ha.L)}eb.prototype=new q;eb.prototype.constructor=eb;E(eb,"scala.Console$",{Ga:1,Ia:1});var fb;function G(a){this.g=a}G.prototype=new q;G.prototype.constructor=G;
G.prototype.i=function(){return(this.g.I?"interface ":this.g.s?"":"class ")+this.g.name};E(G,"java.lang.Class",{oa:1,b:1,c:1});class gb extends $a{}function hb(){}hb.prototype=new q;hb.prototype.constructor=hb;function ib(){}ib.prototype=hb.prototype;var na=E(0,"java.lang.Boolean",{ja:1,b:1,d:1,c:1},a=>"boolean"===typeof a);E(0,"java.lang.Character",{ma:1,b:1,d:1,c:1},()=>!1);class jb extends gb{}function kb(){}kb.prototype=new ib;kb.prototype.constructor=kb;function lb(){}lb.prototype=kb.prototype;
class ra extends jb{constructor(a){super();P(this,a)}}E(ra,"java.lang.ArithmeticException",{ia:1,x:1,u:1,y:1,b:1});var ha=E(0,"java.lang.Byte",{ka:1,p:1,b:1,d:1,c:1},a=>"number"===typeof a&&a<<24>>24===a&&1/a!==1/-0);function Ca(){var a=new mb;P(a,null);return a}class mb extends jb{}E(mb,"java.lang.IllegalArgumentException",{X:1,x:1,u:1,y:1,b:1});function nb(){}nb.prototype=new ib;nb.prototype.constructor=nb;E(nb,"java.lang.JSConsoleBasedPrintStream$DummyOutputStream",{va:1,T:1,R:1,V:1,S:1});
class ob extends jb{constructor(){super();P(this,null)}}E(ob,"java.lang.NullPointerException",{xa:1,x:1,u:1,y:1,b:1});var ia=E(0,"java.lang.Short",{za:1,p:1,b:1,d:1,c:1},a=>"number"===typeof a&&a<<16>>16===a&&1/a!==1/-0);class pb extends jb{constructor(a){super();this.O=null;this.H=!1;this.A=a;P(this,null)}E(){if(!this.H&&!this.H){if(null===this.A)var a="null";else try{a=this.A+" (of class "+m(this.A)+")"}catch(b){a="an instance of class "+m(this.A)}this.O=a;this.H=!0}return this.O}}
E(pb,"scala.MatchError",{Ha:1,x:1,u:1,y:1,b:1});var ma=E(0,"java.lang.Double",{pa:1,p:1,b:1,d:1,c:1,z:1},a=>"number"===typeof a),la=E(0,"java.lang.Float",{qa:1,p:1,b:1,d:1,c:1,z:1},a=>ka(a)),ja=E(0,"java.lang.Integer",{sa:1,p:1,b:1,d:1,c:1,z:1},a=>fa(a)),pa=E(0,"java.lang.Long",{wa:1,p:1,b:1,d:1,c:1,z:1},a=>a instanceof g);class Xa extends mb{constructor(a){super();P(this,a)}}E(Xa,"java.lang.NumberFormatException",{ya:1,X:1,x:1,u:1,y:1,b:1});
function va(a){for(var b=0,c=1,d=-1+a.length|0;0<=d;)b=b+Math.imul(a.charCodeAt(d),c)|0,c=Math.imul(31,c),d=-1+d|0;return b}var ea=E(0,"java.lang.String",{ea:1,b:1,d:1,la:1,c:1,z:1},a=>"string"===typeof a);function rb(){}rb.prototype=new lb;rb.prototype.constructor=rb;function sb(){}sb.prototype=rb.prototype;function K(a){this.Y=a;this.w=""}K.prototype=new sb;K.prototype.constructor=K;E(K,"java.lang.JSConsoleBasedPrintStream",{ua:1,ba:1,aa:1,T:1,R:1,V:1,S:1,ha:1});aa=new g(0,0);Ea.Q=aa;new (Aa(ea).m)([]);
Ga||(Ga=new I);var tb=process.argv.slice(2),Q=new (Aa(ea).m)(tb.length|0);Ra||(Ra=new Qa);var ub=tb.length|0;Ja();var vb;
if(Q instanceof t)vb=Q.a.length;else{var wb;if(Q instanceof u)wb=Q.a.length;else{var xb;if(Q instanceof v)xb=Q.a.length;else{var yb;if(Q instanceof w)yb=Q.a.length;else{var zb;if(Q instanceof x)zb=Q.a.length;else{var Ab;if(Q instanceof y)Ab=Q.a.length;else{var Bb;if(Q instanceof z)Bb=Q.a.length;else{var Cb;if(Q instanceof A)Cb=Q.a.length;else{var Db;if(Q instanceof B)Db=Q.a.length;else{var Eb=new mb;P(Eb,"argument type mismatch");throw Eb;}Cb=Db}Bb=Cb}Ab=Bb}zb=Ab}yb=zb}xb=yb}wb=xb}vb=wb}
for(var Fb=2147483647<ub?2147483647:ub,Gb=vb-0|0,Hb=Fb<Gb?Fb:Gb,Ib=0<Hb?Hb:0,Jb=0;Jb<Ib;){Pa||(Pa=new Oa);var R=Q,S=Jb+0|0,T=tb[Jb];if(R instanceof t)R.a[S]=T;else if(R instanceof y)R.a[S]=T|0;else if(R instanceof B)R.a[S]=+T;else if(R instanceof z){var Kb=T;R.a[S]=null===Kb?aa:Kb}else if(R instanceof A)R.a[S]=Math.fround(T);else if(R instanceof v){var Lb=T;R.a[S]=null===Lb?0:Lb.fa}else if(R instanceof w)R.a[S]=T|0;else if(R instanceof x)R.a[S]=T|0;else if(R instanceof u)R.a[S]=!!T;else{if(null===
R)throw new ob;throw new pb(R);}Jb=1+Jb|0}Fa||(Fa=new H);var O=Q.a[0];Za||(Za=new Ya);var Mb,Nb=null===O?0:O.length;0===Nb&&Wa();var Ob=O.charCodeAt(0),Pb=45===Ob,Qb=Pb?2147483648:2147483647,Rb=Pb||43===Ob?1:0;Rb>=O.length&&Wa();
for(var Sb=0;Rb!==Nb;){Va||(Va=new Ua);var Tb,Ta=Va,U=O.charCodeAt(Rb);if(256>U)var V=48<=U&&57>=U?-48+U|0:65<=U&&90>=U?-55+U|0:97<=U&&122>=U?-87+U|0:-1;else if(65313<=U&&65338>=U)V=-65303+U|0;else if(65345<=U&&65370>=U)V=-65335+U|0;else{Ka||(Ka=new M);var Ub;a:for(var Vb=Sa(),Wb=0,Xb=Vb.a.length;;){if(Wb===Xb){Ub=-1-Wb|0;break a}var Yb=(Wb+Xb|0)>>>1|0,Zb=Vb.a[Yb],$b=U===Zb?0:U<Zb?-1:1;if(0>$b)Xb=Yb;else{if(0===$b){Ub=Yb;break a}Wb=1+Yb|0}}var ac=0>Ub?-2-Ub|0:Ub;if(0>ac)V=-1;else{var bc=U-Sa().a[ac]|
0;V=9<bc?-1:bc}}Tb=10>V?V:-1;Sb=10*Sb+Tb;(-1===Tb||Sb>Qb)&&Wa();Rb=1+Rb|0}Mb=Pb?-Sb|0:Sb|0;var cc,dc=new ab,ec;db||(db=new cb);var fc=bb();ec=new g(bb(),fc);var gc=-554899859^ec.C;dc.F=gc>>>24|0|(65535&(5^ec.B))<<8;dc.G=16777215&gc;var hc;a:for(;;){var ic,jc=dc,kc=jc.G,lc=15525485*kc+11,mc=16777215&((lc/16777216|0)+(16777215&(1502*kc+15525485*jc.F|0))|0),nc=16777215&(lc|0);jc.F=mc;jc.G=nc;ic=(mc<<8|nc>>16)>>>1|0;var oc=qa(ic,1E4);if(!(0>((ic-oc|0)+9999|0))){hc=oc;break a}}cc=hc;
var W,pc=Ja(),rc=f(Da),sc=new y(new Int32Array([1E4])),tc=sc.a.length;if(0===tc)throw Ca();for(var da=rc,uc=1;uc!==tc;)da=ba(),uc=1+uc|0;W=function vc(a,b,c,d){var h=d.a[c],l=ca(b.g,h);c=1+c|0;if(c<d.a.length){b=b.g;b=b.q?f(b.q):null;for(var k=0;k!==h;)l.a[k]=vc(a,b,c,d),k=1+k|0}return l}(pc,da,0,sc);for(var X=0,wc=0;1E4>X;){for(;1E5>wc;)W.a[X]=W.a[X]+qa(wc,Mb)|0,wc=1+wc|0;var xc=X;W.a[xc]=W.a[xc]+cc|0;X=1+X|0}var yc=W.a[cc]+"\n",Y;fb||(fb=new eb);Y=fb.N.P;
for(var Z=yc;""!==Z;){var zc=Z.indexOf("\n")|0;if(0>zc)Y.w=""+Y.w+Z,Z="";else{var Ac=""+Y.w+Z.substring(0,zc);"undefined"!==typeof console&&(Y.Y&&console.error?console.error(Ac):console.log(Ac));Y.w="";Z=Z.substring(1+zc|0)}};
}).call(this); Loops generated more code than I expected |
🙏 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
I need to update all the remaining bench codes for better support of Scala-js
Modification:
Result:
All tests now support scala-js
A following up of #286