andrei-markeev / ts2c

Convert Javascript/TypeScript to C
ISC License
1.26k stars 95 forks source link

Transpilation failed. TypeError: Cannot read property 'length' of undefined #53

Closed zaoqi closed 4 years ago

zaoqi commented 5 years ago

https://andrei-markeev.github.io/ts2c/

function h(){throw"TheLanguage PANIC";}function aa(a){return function(){return[!1,a]}}function ca(a){return function(){return[!0,a()]}}function da(a){for(a=a();a[0];)a=a[1]();return a[1]}function ea(a,b){return[10,a,b]}function q(a){return 10===a[0]}function fa(a){for(;q(a);)a=a[2];return a}function r(a){return 0===a[0]}function u(a,b){return a===b?!0:a[1]===b[1]?(v(a,b),!0):!1}function ha(a,b){return[1,a,b]}function w(a){return 1===a[0]}function ia(a){return a[1]}function ja(a){return a[2]}
function x(a){return 2===a[0]}function ka(a,b){return[3,a,b]}function z(a){return 3===a[0]}function la(a){return a[1]}function ma(a){return a[2]}function na(a){return 4===a[0]}function oa(a){return a[2]}function A(a,b){return[6,a,b]}function pa(a,b){return[8,a,b]}function qa(a){a=B(a);if(z(a)||w(a)||q(a))a[1]=qa(a[1]),a[2]=qa(a[2]);return a}
function ra(a){var b=ua(a);if(z(b)||w(b))if(b[1]=qa(b[1]),b[2]=qa(b[2]),q(b[1])||q(b[2])){a=[9];va(a,b);var c=b[2];b=ra(b[1]);c=ra(c);a[1]=b;a[2]=c}else a=b;else a=b;return a}function v(a,b){a!==b&&(a===C&&(a=b,b=C),a[0]=4,a[1]=b,a[2]=!1,a[3]=!1)}function va(a,b){9===a[0]||h();9!==b[0]||h();a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3]}function wa(a){return[3,xa,[1,D,[1,a,C]]]}function F(a){for(var b=C,c=a.length-1;0<=c;c--)b=[1,a[c],b];return b}
function ya(a,b,c){for(var d=[];w(a);)d.push(a[1]),a=a[2];return x(a)?b(d):c(d,a)}function G(a){return ya(a,function(b){return b},function(){return!1})}function H(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return F(a)}function I(a){if(!na(a))return a;for(var b=[];na(a);)b.push(a),a=a[1];for(var c=0;c<b.length;c++)v(b[c],a);return a}function za(a){return 5===a[0]||7===a[0]||6===a[0]||8===a[0]}function J(a){return na(a)||za(a)}function Aa(a){return J(a)||q(a)}
function Ba(a){if(5===a[0])return a;if(7===a[0])throw"WIP";if(6===a[0])throw"WIP";if(8===a[0])throw"WIP";return h()}
function B(a,b,c,d){function f(M){v(n,M);for(var E=0;E<d.length;E++)v(d[E],M);return M}function l(){c[1]=!0;return g(Ca)}function g(M){f(M);return J(M)?(d.push(n),B(M,b,[!1,!1],d)):M}function k(){var M={},E;for(E in m)M[E]=!0;for(E in b)M[E]=!0;return M}void 0===b&&(b={});void 0===c&&(c=[!1,!1]);void 0===d&&(d=[]);var m={},n=a;for(a=0;J(n)&&32>a;a++)d.push(n),n=N(n);for(;J(n);){a=O(n);if(!0===b[a])return l();if(!0===m[a]){c[0]=!0;if(5===n[0])return l();if(6===n[0]){a=n[1];for(var y=n[2],K=!1,S=0,
ba=[Da,Ea,Fa,Ga,Ha,Ia,Ja,Ka];S<ba.length;S++)if(P(ba[S],a)){K=!0;break}if(K)return 1===y.length||h(),!1===c[1]||h(),y=B(y[0],k(),c),c[1]?g(A(a,[y])):h();if(P(a,La)||P(a,Ma)||P(a,Na))return l();if(P(a,Oa)&&(3===y.length||h(),!1===c[1]||h(),a=B(y[0],k(),c),c[1]))return g(A(Oa,[a,y[1],y[2]]))}else if(7===n[0]||8===n[0])return l();return h()}m[a]=!0;d.push(n);n=N(n)}return f(n)}
function N(a){var b=I(a);!na(b)||h();a=5===b[0]?Pa(b[1],b[2],a):7===b[0]?Qa(b[1],b[2],b[3]):6===b[0]?Ra(b[1],b[2],a):8===b[0]?Sa(b[1],b[2],a):b;a=I(a);v(b,a);return a}function ua(a){for(;J(a)||q(a);)a=B(fa(a));return a}function Ta(a){for(;q(a);)a=a[2];for(a=N(a);q(a);)a=a[2];return a}function Ua(a,b,c,d){var f=[],l=[];a=I(a);for(var g=!0;;){if(x(a))return d(l,f);if(q(a))l.push(a[1]),a=a[2];else if(w(a))f.push(a[1]),a=a[2];else if(J(a))if(g)g=!1,a=N(a);else return c();else return b()}}
function Va(a){Aa(a)&&(a=Ta(a));if(Aa(a))return null;if(r(a))return!0;if(!z(a))return!1;a=a[1];Aa(a)&&(a=Ta(a));return Aa(a)?null:r(a)?u(a,Q):!1}function Wa(a,b,c){for(var d=[],f=0;f<a.length;f+=2){if(P(a[f],b)){d[f]=b;d[f+1]=c;for(f+=2;f<a.length;f+=2)d[f]=a[f],d[f+1]=a[f+1];return d}d[f]=a[f];d[f+1]=a[f+1]}d[a.length]=b;d[a.length+1]=c;return d}function Xa(a,b,c){for(var d=0;d<a.length;d+=2)if(P(a[d],b))return a[d+1];return c}
function Ya(a,b){for(var c=0;c<a.length;c+=2)if(P(a[c],b))return a[c+1];return h()}function R(a){for(var b=C,c=0;c<a.length;c+=2)b=[1,H(a[c],a[c+1]),b];return[3,Za,H(b)]}function fb(a,b){for(var c=0;c<a.length;c+=2)b(a[c],a[c+1])}
function gb(a){a=B(a);if(!z(a))return!1;var b=B(a[1]);if(!r(b)||!u(b,Za))return!1;b=B(a[2]);if(!w(b)||!x(B(b[2])))return!1;a=[];for(b=B(b[1]);!x(b);){if(!w(b))return!1;var c=B(b[1]);b=B(b[2]);if(!w(c))return!1;var d=c[1];c=B(c[2]);if(!w(c))return!1;var f=c[1];if(!x(B(c[2])))return!1;c=!0;for(var l=0;l<a.length;l+=2)if(P(a[l],d)){a[l+1]=f;c=!1;break}c&&a.push(d,f)}return a}
function Pa(a,b,c){function d(){return wa(H(hb,H(Na,H(R(a),f))))}var f=N(b);if(J(f))return c;if(w(f))return Ua(f,d,function(){return c},function(l,g){if(0!==l.length)throw"WIP";if(P(g[0],ib)){if(1===g.length)return d();for(var k=g[1],m=[],n=2;n<g.length;n++)m.push(g[n]);return[7,a,k,m]}if(P(g[0],jb)){if(1===g.length)return d();k=B([5,a,g[1]]);if(!z(k))return d();m=N(k[1]);if(J(m))return c;if(!r(m)||!u(m,T))return d();m=N(k[2]);if(J(m))return c;if(!w(m))return d();k=m[1];m=N(m[2]);if(J(m))return c;
if(!x(m))return d();m=[R(a)];for(n=2;n<g.length;n++)m.push(g[n]);return[8,k,m]}if(P(g[0],hb)){if(1===g.length)return d();k=g[1];m=[];for(n=2;n<g.length;n++)m.push([5,a,g[n]]);return[6,k,m]}k=[5,a,g[0]];m=[];for(n=1;n<g.length;n++)m.push([5,a,g[n]]);return[8,k,m]});if(x(f))return f;b=Va(f);return null===b?c:!0===b?Xa(a,f,d()):d()}
function Sa(a,b,c){function d(){return wa(H(hb,H(Ma,H(a,F(b)))))}a=N(a);if(J(a))return c;if(!z(a))return d();var f=B(a[1]);if(!r(f)||!u(f,U))return d();var l=B(a[2]);if(!w(l))return d();f=qa(l[1]);l=B(l[2]);if(!w(l)||!x(B(l[2])))return d();l=l[1];for(var g=kb,k=0;!x(f);){var m=Va(f);if(null===m)return c;if(!0===m){m=C;for(var n=b.length-1;n>=k;n--)m=[1,b[n],m];g=Wa(g,f,m);k=b.length;f=C}else if(w(f))if(k<b.length)m=b[k],k++,g=Wa(g,f[1],m),f=f[2];else return d();else return d()}return b.length!==k?
d():[5,g,l]}function Ra(a,b,c){function d(){return wa(H(hb,H(a,F(b))))}for(var f=0;f<lb.length;f++){var l=lb[f];if(P(a,l[0])){if(b.length!==l[1])break;return 1===l[1]?l[2](b[0],d,c):2===l[1]?l[2](b[0],b[1],d,c):3===l[1]?l[2](b[0],b[1],b[2],d,c):h()}}return d()}function Qa(a,b,c){function d(){return wa(H(ib,H(R(a),b,F(c))))}return P(b,mb)?1!==c.length?d():c[0]:P(b,nb)?2!==c.length?d():ob(a,c[0],c[1],d):P(b,pb)?2!==c.length?d():[10,c[0],[5,a,c[1]]]:d()}
function ob(a,b,c,d){b=ra(b);for(var f=[],l=!1,g=b;!x(g);){var k=Va(g);null!==k||h();if(k)f.push(g),l=!0,g=C;else if(w(g))f.push(g[1]),g=g[2];else return d()}g=l?F(f):b;var m=[];fb(a,function(n){for(var y=0;y<f.length;y++)if(P(f[y],n))return;m.push(n)});d=g;for(l=m.length-1;0<=l;l--)d=[1,m[l],d];for(l=m.length-1;0<=l;l--)g=ha(H(ib,mb,Ya(a,m[l])),g);return[3,U,H(b,[1,H(ib,mb,[3,U,H(d,c)]),g])]}
function qb(a,b){function c(f,l,g,k){g=qb(g(f),g(l));k=qb(k(f),k(l));return!0===g&&!0===k?(v(f,l),!0):!1!==g&&!1!==k?null:!1}if(a===b)return!0;a=B(a);b=B(b);if(a===b)return!0;if(q(a)){var d=qb(fa(a),b);!0===d&&(d=null);return d}if(q(b))return d=qb(a,fa(b)),!0===d&&(d=null),d;if(x(a)){if(!x(b))return!1;v(a,b);return!0}return r(a)?r(b)?u(a,b):!1:w(a)?w(b)?c(a,b,ia,ja):!1:z(a)?z(b)?c(a,b,la,ma):!1:h()}function P(a,b){return!1!==qb(a,b)}
function V(a,b){function c(d,f,l,g){return V(l(d),l(f))&&V(g(d),g(f))?(v(d,f),!0):!1}if(a===b)return!0;a=I(a);b=I(b);if(a===b)return!0;if(x(a)){if(!x(b))return!1;v(a,C);v(b,C);return!0}return r(a)?r(b)?u(a,b):!1:w(a)?w(b)?c(a,b,ia,ja):!1:z(a)?z(b)?c(a,b,la,ma):!1:za(a)?!1:h()}
function O(a){a=I(a);var b;if(x(a))return"()";if(w(a)){var c="(";for(b="";w(a);)c+=b+O(a[1]),b=" ",a=I(a[2]);return x(a)?c+")":c+(" . "+O(a)+")")}return z(a)?"#"+O([1,a[1],a[2]]):r(a)?a[1]:q(a)?";("+O(a[1])+" "+O(a[2])+")":5===a[0]?"$("+O(R(a[1]))+" "+O(a[2])+")":6===a[0]?"%("+O(a[1])+" "+O(F(a[2]))+")":7===a[0]?"@("+O(R(a[1]))+" "+O(a[2])+" "+O(F(a[3]))+")":8===a[0]?"^("+O(a[1])+" "+O(F(a[2]))+")":h()}
function tb(a){function b(){return $a.length===sa}function c(){!b()||h();var e=$a[sa];sa++;return e}function d(e){$a[sa-1]===e||h();sa--}function f(e){void 0===e&&(e="");throw"TheLanguage parse ERROR!"+e;}function l(e){return" "===e||"\n"===e||"\t"===e||"\r"===e}function g(){if(b())return!1;var e=c();if(!l(e))return d(e),!1;for(;l(e)&&!b();)e=c();l(e)||d(e);return!0}function k(){if(b())return!1;var e=c(),p="";if(!K(e))return d(e),!1;for(;K(e)&&!b();)p+=e,e=c();K(e)?p+=e:d(e);return[0,p]}function m(){if(b())return!1;
var e=c();if("("!==e)return d(e),!1;for(var p=[9],t=p;;){g();if(b())return f();e=c();if(")"===e)return va(p,C),t;if("."===e){g();e=S();va(p,e);g();if(b())return f();e=c();return")"!==e?f():t}d(e);e=S();var L=[9];va(p,[1,e,L]);p=L}}function n(){if(b())return!1;var e=c();if("#"!==e)return d(e),!1;e=m();return!1!==e&&w(e)?[3,e[1],e[2]]:f()}function y(e,p){return function(){if(b())return!1;var t=c();if(t!==e)return d(t),!1;t=m();if(!1===t||!w(t))return f();var L=t[2];return w(L)&&x(L[2])?p(t[1],L[1]):
f()}}function K(e){if(l(e))return!1;for(var p=0,t="()!#.$%^@~/->_:?[]&;".split("");p<t.length;p++)if(t[p]===e)return!1;return!0}function S(){g();for(var e=0,p=[m,Mb,n,ab,bb,cb,db,eb];e<p.length;e++){var t=(0,p[e])();if(!1!==t)return t}return f()}function ba(e){return!1===e?f():e}function M(e){ba(!b());ba(c()===e)}function E(e){function p(){M("[");var ta=E();M("]");return ta}void 0===e&&(e=!1);var t=0;for(e=e?[m,k,p,n,ab,bb,cb,db,eb]:[m,rb,n,ab,bb,cb,db,eb];t<e.length;t++){var L=(0,e[t])();if(!1!==
L)return L}return f()}function sb(e){if(b())return e;var p=c();if("."===p)return p=E(),H(W,H(U,H(e),X),p);if(":"===p)return p=E(),H(W,p,e);if("~"===p)return H(Y,e);if("@"===p)return p=E(),H(W,H(U,[1,e,X],X),p);if("?"===p)return H(W,U,H(Y,e));if("/"===p){for(e=[e];;){p=E(!0);e.push(p);if(b())break;p=c();if("/"!==p){d(p);break}}return H(ub,F(e))}d(p);return e}function rb(){if(b())return!1;var e=c();if("&"===e){ba(!b());e=c();if("+"===e)return e=E(),H(T,H(D,e));d(e);e=E();return H(T,e)}if(":"===e){ba(!b());
e=c();if("&"===e)return M(">"),e=E(),H(W,H(T,H(U,X,e)),vb);if(">"===e)return e=E(),H(W,H(U,X,e),vb);d(e);e=E();return H(W,e,vb)}if("+"===e)return e=E(),H(D,e);if("["===e)return e=E(),M("]"),sb(e);if("_"===e)return M(":"),e=E(),H(W,e,X);d(e);e=k();return!1===e?!1:sb(e)}function Mb(){var e=rb();return!1===e?!1:r(e)?e:[3,Q,[1,D,[1,e,C]]]}var $a=a,sa=0,ab=y("$",function(e,p){var t=gb(e);return!1===t?f():[5,t,p]}),bb=y("%",function(e,p){var t=ya(p,function(L){return L},function(){return f()});return[6,
e,t]}),cb=function(e,p){return function(){if(b())return!1;var t=c();if(t!==e)return d(t),!1;t=m();if(!1===t||!w(t))return f();var L=t[2];if(!w(L))return f();var ta=L[2];return w(ta)&&x(ta[2])?p(t[1],L[1],ta[1]):f()}}("@",function(e,p,t){t=ya(t,function(L){return L},function(){return f()});e=gb(e);return!1===e?f():[7,e,p,t]}),db=y("^",function(e,p){var t=ya(p,function(L){return L},function(){return f()});return[8,e,t]}),eb=y(";",function(e,p){return[10,e,p]});return S()}
function Z(a){function b(f,l){function g(K){return l?"["+K+"]":K}if(r(f))return f[1];var k=G(f);if(!1!==k&&3===k.length&&V(k[0],W)){var m=G(k[1]);if(!1!==m&&3===m.length&&V(m[0],U)){var n=m[1],y=G(n);if(!1!==y&&1===y.length&&V(m[2],X))return g(b(y[0],!0)+"."+b(k[2],!0));if(w(n)&&V(n[2],X)&&V(m[2],X))return g(b(n[1],!0)+"@"+b(k[2],!0));if(V(n,X)&&V(k[2],vb))return g(":>"+b(m[2],!0))}n=G(k[2]);if(V(k[1],U)&&!1!==n&&2===n.length&&V(n[0],Y))return g(b(n[1],!0)+"?");if(!1!==m&&2===m.length&&V(k[2],vb)&&
V(m[0],T)&&(m=G(m[1]),!1!==m&&3===m.length&&V(m[0],U)&&V(m[1],X)))return g(":&>"+b(m[2],!0));m=void 0;m=V(k[2],X)?"_":V(k[2],vb)?"":b(k[2],!0);return g(m+":"+b(k[1],!0))}if(!1!==k&&2===k.length){if(V(k[0],T))return m=G(k[1]),!1!==m&&2===m.length&&V(m[0],D)?g("&+"+b(m[1],!0)):g("&"+b(k[1],!0));if(V(k[0],Y))return g(b(k[1],!0)+"~");if(V(k[0],D))return g("+"+b(k[1],!0));if(V(k[0],ub)&&(k=G(k[1]),!1!==k&&1<k.length)){m=b(k[0],!0);for(n=1;n<k.length;n++)m+="/"+b(k[n],!0);return g(m)}}return l?O(f):O([3,
Q,[1,D,[1,f,C]]])}a=tb(O(a));var c="",d="";if(x(a))return"()";if(w(a)){c="(";for(d="";w(a);)c+=d+Z(a[1]),d=" ",a=a[2];return c=x(a)?c+")":c+(" . "+Z(a)+")")}return z(a)?(c=a[1],a=a[2],d=G(a),!1!==d&&2===d.length&&V(c,Q)&&V(d[0],D)?b(d[1],!1):"#"+Z([1,c,a])):r(a)?a[1]:q(a)?";("+Z(a[1])+" "+Z(a[2])+")":5===a[0]?"$("+Z(R(a[1]))+" "+Z(a[2])+")":6===a[0]?"%("+Z(a[1])+" "+Z(F(a[2]))+")":7===a[0]?"@("+Z(R(a[1]))+" "+Z(a[2])+" "+Z(F(a[3]))+")":8===a[0]?"^("+Z(a[1])+" "+Z(F(a[2]))+")":h()}
function wb(a,b,c,d,f){void 0===f&&(f=!1);c=B(c);if(z(c)){var l=c[1],g=c[2];if(P(l,xb)){if(g=B(g),w(g)&&(l=g[1],g=B(g[2]),x(g))){if(!1===f){var k=l;l=function(){return a(k,d)}}else{var m=l;l=function(){return wb(a,b,[8,f,m],d)}}return ca(l)}}else if(P(l,yb)&&(g=B(g),w(g)&&(l=g[1],g=B(g[2]),w(g)))){var n=g[1];g=B(g[2]);if(x(g)){if(!1===f){var y=l;l=function(){return wb(a,b,y,d,n)}}else l=function(){throw"WIP";};return ca(l)}}}return!1===f?ca(function(){return b(c,d,a)}):ca(function(){return b(c,d,
function(K,S){return ca(function(){return wb(a,b,pa(f,[K]),S)})})})}function zb(a,b,c){c=N(c);return J(c)?A(a,[c]):b(c)?Ab:Bb}function Cb(a,b,c,d,f){d=N(d);return J(d)?A(a,[d]):b(d)?c(d):f()}
var C=[2],xa=[0,"\u8b2c\u8aa4"],D=[0,"\u592a\u59cb\u521d\u6838"],X=[0,"\u7701\u7565\u4e00\u7269"],Ca=[3,xa,[1,D,[1,[1,[0,"\u5b87\u5b99\u4ea1\u77e3"],[1,X,C]],C]]],Q=[0,"\u7b26\u540d"],T=[0,"\u5f0f\u5f62"],U=[0,"\u5316\u6ec5"],hb=[3,Q,[1,D,[1,[1,T,[1,[1,D,[1,U,C]],C]],C]]],W=[0,"\u4e00\u985e\u4f55\u7269"],Na=[3,Q,[1,D,[1,[1,W,[1,U,[1,[0,"\u89e3\u7b97"],C]]],C]]],Za=[0,"\u6620\u8868"],ib=[3,Q,[1,D,[1,[1,T,[1,[1,D,[1,T,C]],C]],C]]],jb=[3,Q,[1,D,[1,[1,T,[1,T,C]],C]]],mb=[3,Q,[1,D,[1,[1,W,[1,T,[1,[0,"\u5f15\u7528"],
C]]],C]]],vb=[0,"\u7279\u5b9a\u5176\u7269"],nb=[3,Q,[1,D,[1,[1,W,[1,[1,T,[1,[1,U,[1,X,[1,U,C]]],C]],[1,vb,C]]],C]]],Db=[0,"\u8a3b\u758f"],pb=[3,Q,[1,D,[1,[1,W,[1,T,[1,Db,C]]],C]]],Y=[0,"\u662f\u975e"],Eb=[0,"\u69cb\u7269"],Fa=[3,Q,[1,D,[1,[1,W,[1,U,[1,[1,Y,[1,[1,W,[1,Eb,[1,X,C]]],C]],C]]],C]]],Fb=[0,"\u723b\u967d"],Ab=[3,Fb,C],Gb=[0,"\u723b\u9670"],Bb=[3,Gb,C],Da=[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,[1,Eb,C],[1,X,C]]],[1,Q,C]]],C]]],Hb=[0,"\u5217\u5e8f"],Ea=[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,[1,Eb,C],[1,X,C]]],
[1,Hb,C]]],C]]],Ka=[3,Q,[1,D,[1,[1,W,[1,U,[1,[1,Y,[1,[1,W,[1,[0,"\u9593\u7a7a"],[1,X,C]]],C]],C]]],C]]],Ib=[0,"\u9023\u9838"],Ga=[3,Q,[1,D,[1,[1,W,[1,U,[1,[1,Y,[1,[1,W,[1,Ib,[1,X,C]]],C]],C]]],C]]],Ha=[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,[1,Ib,C],[1,X,C]]],[1,[0,"\u9996\u59cb"],C]]],C]]],Ia=[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,[1,Ib,C],[1,X,C]]],[1,[0,"\u5c3e\u672b"],C]]],C]]],La=[3,Q,[1,D,[1,[1,W,[1,U,[1,[1,Y,[1,[0,"\u7b49\u540c"],C]],C]]],C]]],Oa=[3,Q,[1,D,[1,[1,W,[1,U,[1,[0,"\u5982\u82e5"],C]]],C]]],Ma=[3,Q,[1,
D,[1,[1,W,[1,[1,U,[1,[1,U,X],[1,X,C]]],[1,[0,"\u61c9\u7528"],C]]],C]]],Ja=[3,Q,[1,D,[1,[1,W,[1,U,[1,[1,Y,[1,[1,W,[1,[0,"\u8a5e\u7d20"],[1,X,C]]],C]],C]]],C]]],Jb=[0,"\u4e4b\u7269"],Kb=[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,[1,Hb,C],[1,X,C]]],[1,[1,W,[1,Jb,[1,X,C]]],C]]],C]]],lb=[[Fa,1,function(a){return zb.call(this,Fa,z,a)}],[[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,X,[1,Eb,C]]],[1,vb,C]]],C]]],2,ka],[Da,1,function(a,b){return Cb.call(this,Da,z,la,a,b)}],[Ea,1,function(a,b){return Cb.call(this,Ea,z,ma,a,b)}],[Ka,1,function(a){return zb.call(this,
Ka,x,a)}],[[3,Q,[1,D,[1,[1,W,[1,[1,U,[1,X,[1,Ib,C]]],[1,vb,C]]],C]]],2,ha],[Ga,1,function(a){return zb.call(this,Ga,w,a)}],[Ha,1,function(a,b){return Cb.call(this,Ha,w,ia,a,b)}],[Ia,1,function(a,b){return Cb.call(this,Ia,w,ja,a,b)}],[La,2,function(a,b){function c(d,f,l,g){l=A(La,[l(d),l(f)]);d=A(La,[g(d),g(f)]);return A(Oa,[l,d,Bb])}if(a===b)return Ab;a=N(a);b=N(b);if(J(a)||J(b))return A(La,[a,b]);if(a===b)return Ab;!J(a)||h();return x(a)?x(a)?Ab:Bb:r(a)?r(b)?u(a,b)?Ab:Bb:Bb:z(a)?z(b)?c(a,b,la,ma):
Bb:w(a)?w(b)?c(a,b,ia,ja):Bb:h()}],[Ma,2,function(a,b,c){var d=[];for(b=B(b);w(b);)d.push(b[1]),b=B(b[2]);return x(b)?[8,a,d]:c()}],[Na,2,function(a,b,c){a=gb(a);return!1===a?c():[5,a,b]}],[Ja,1,function(a){return zb.call(this,Ja,r,a)}],[Kb,1,function(a,b){a=N(a);return J(a)?A(Kb,[a]):w(a)?a[1]:b()}],[Oa,3,function(a,b,c,d){a=N(a);if(J(a))return A(Oa,[a,b,c]);if(!z(a))return d();a=B(a[1]);return r(a)?u(a,Fb)?b:u(a,Gb)?c:d():d()}],[[3,Q,[1,D,[1,[1,W,[1,U,[1,Db,C]]],C]]],2,ea]],kb=[],ub=[0,"\u5176\u5b50"],
Lb=[0,"\u6548\u61c9"],xb=[3,Q,[1,D,[1,[1,ub,[1,[1,Lb,[1,[1,W,[1,Jb,[1,X,C]]],C]],C]],C]]],yb=[3,Q,[1,D,[1,[1,ub,[1,[1,Lb,[1,Ib,C]],C]],C]]];
module.exports={trampoline_return:aa,trampoline_delay:ca,run_trampoline:da,new_comment:ea,comment_p:q,comment_comment:function(a){return a[1]},comment_x:function(a){return a[2]},un_comment_all:fa,atom_p:r,new_atom:function(a){return[0,a]},un_atom:function(a){return a[1]},atom_equal_p:u,new_construction:ha,construction_p:w,construction_head:ia,construction_tail:ja,null_v:C,null_p:x,new_data:ka,data_p:z,data_name:la,data_list:ma,just_p:na,evaluate:function(a,b){return[5,a,b]},apply:pa,force_all_rec:qa,
force_uncomment_all_rec:ra,unlazy_all_rec:ra,jsArray_to_list:F,maybe_list_to_jsArray:G,new_list:H,un_just_all:I,un_just_comment_all:function(a){for(;na(a)||q(a);)a=I(fa(a));return a},delay_p:za,delay_just_p:J,lazy_p:Aa,delay_env:function(a){return Ba(a)[1]},delay_x:function(a){return Ba(a)[2]},force1:N,force_all:function(a){return B(a)},force_uncomment_all:ua,force_uncomment1:function(a){return q(a)?a[2]:N(a)},unlazy1:Ta,env_null_v:kb,env_set:Wa,env_get:Xa,env2val:R,env_foreach:fb,val2env:gb,equal_p:P,
simple_print:O,complex_parse:tb,complex_print:Z,machinetext_parse:function(a){function b(n){void 0===n&&(n="");throw"MT parse ERROR "+n;}function c(n){if(!n)return b()}function d(){c(0!==l);l--;return a[l]}function f(n){var y=g.pop(),K=g.pop();return void 0===K||void 0===y?b():g.unshift(n(K,y))}for(var l=a.length,g=[];0!==l;){var k=d();if("^"===k){for(k="";;){var m=d();if("^"===m)break;k=m+k}g.unshift([0,k])}else if("."===k)f(ha);else if("#"===k)f(ka);else if("$"===k)f(function(n,y){var K=gb(n);return!1===
K?b():[5,K,y]});else if("_"===k)g.unshift(C);else return b()}c(0===l);c(1===g.length);return g[0]},machinetext_print:function(a){function b(){for(var f=[],l=0,g=c;l<g.length;l++){var k=g[l];k=I(k);var m=function(n,y,K,S){d+=y;return f.push(K(n),S(n))};if(r(k))d+="^"+k[1]+"^";else if(w(k))m(k,".",ia,ja);else if(x(k))d+="_";else if(z(k))m(k,"#",la,ma);else if(za(k))k=Ba(k),m(k,"$",function(n){return R(n[1])},oa);else return{value:h()}}c=f}for(var c=[a],d="";0!==c.length;)if(a=b(),"object"===typeof a)return a.value;
return d},return_effect_systemName:xb,bind_effect_systemName:yb,new_effect_bind:function(a,b){return[3,yb,H(a,b)]},new_effect_return:function(a){return[3,xb,a]},run_monad_trampoline:function(a,b,c,d){return wb(a,b,c,d)},run_monad_stackoverflow:function(a,b,c,d){return da(wb(function(f,l){return aa(a(f,l))},function(f,l,g){return aa(b(f,l,function(k,m){return da(g(k,m))}))},c,d))}};
145 WARNING: unexpected binary expression! ts2c.bundle.js:6142
Uncaught TypeError: Cannot read property 'length' of undefined
    at ts2c.bundle.js:6459
    at Array.forEach (<anonymous>)
    at Object.getType (ts2c.bundle.js:6451)
    at TypeHelper.resolveTypes (ts2c.bundle.js:6536)
    at TypeHelper.inferTypes (ts2c.bundle.js:6515)
    at newConstructor.CProgram (ts2c.bundle.js:2713)
    at new newConstructor (ts2c.bundle.js:5608)
    at Object.transpile (ts2c.bundle.js:6805)
    at transpile ((index):54)
    at HTMLButtonElement.onclick ((index):28)
andrei-markeev commented 4 years ago

Let's not try to compile big real-world files for now. It is almost impossible to debug them. Also, minified files are often not a valid TypeScript, and TS2C uses TypeScript AST as a base.