aboutsummaryrefslogtreecommitdiff
path: root/third_party/lzma.js/lzma-decoder.js
blob: 31edd4725974396c3e0ea21181889148b0ec66ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This is lzma.js, powered by lzip (which is GPL, source code at https://github.com/kripken/lzma.js)
var LZMA = {
  run: function(data, decompress) {
    var inputIndex = 0;
    var returnValue = [];
    var Module = {
      arguments: ['-q'].concat(decompress ? ['-d'] : []),
      stdin: function() { return inputIndex < data.length ? data[inputIndex++] : null },
      stdout: function(x) { if (x !== null) returnValue.push(x) }
    };


function a(b){throw b}var ca=void 0,j=!0,l=null,m=!1,ka=[],la="object"===typeof process,sa="object"===typeof window,Ca="function"===typeof importScripts,Ka=!sa&&!la&&!Ca;if(la){print=(function(b){process.stdout.write(b+"\n")});printErr=(function(b){process.stderr.write(b+"\n")});var bb=require("fs");read=(function(b){var d=bb.readFileSync(b).toString();!d&&"/"!=b[0]&&(b=__dirname.split("/").slice(0,-1).join("/")+"/src/"+b,d=bb.readFileSync(b).toString());return d});load=(function(b){cb(read(b))});ka=process.argv.slice(2)}else{Ka?(this.read||(this.read=(function(b){snarf(b)})),"undefined"!=typeof scriptArgs?ka=scriptArgs:"undefined"!=typeof arguments&&(ka=arguments)):sa?(this.print=printErr=(function(b){console.log(b)}),this.read=(function(b){var d=new XMLHttpRequest;d.open("GET",b,m);d.send(l);return d.responseText}),this.arguments&&(ka=arguments)):Ca?this.load=importScripts:a("Unknown runtime environment. Where are we?")}function cb(b){eval.call(l,b)}"undefined"==typeof load&&"undefined"!=typeof read&&(this.load=(function(b){cb(read(b))}));"undefined"===typeof printErr&&(this.printErr=(function(){}));"undefined"===typeof print&&(this.print=printErr);try{this.Module=Module}catch(db){this.Module=Module={}}Module.arguments||(Module.arguments=ka);Module.print&&(print=Module.print);function vb(b){if(1==wb){return 1}var d={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+b];d||("*"==b[b.length-1]?d=wb:"i"==b[0]&&(b=parseInt(b.substr(1)),xb(0==b%8),d=b/8));return d}function Hb(b){var d=n;n+=b;n=n+3>>2<<2;return d}function Ib(b){var d=Qb;Qb+=b;Qb=Qb+3>>2<<2;if(Qb>=Rb){for(;Rb<=Qb;){Rb=2*Rb+4095>>12<<12}var b=p,c=new ArrayBuffer(Rb);p=new Int8Array(c);Sb=new Int16Array(c);r=new Int32Array(c);s=new Uint8Array(c);Tb=new Uint16Array(c);z=new Uint32Array(c);Ub=new Float32Array(c);Vb=new Float64Array(c);p.set(b)}return d}var wb=4,Yb={},Zb,B,$b;function bc(b){print(b+":\n"+Error().stack);a("Assertion: "+b)}function xb(b,d){b||bc("Assertion failed: "+d)}var cc=this;Module.ccall=(function(b,d,c,e){try{var f=eval("_"+b)}catch(i){try{f=cc.Module["_"+b]}catch(h){}}xb(f,"Cannot call unknown function "+b+" (perhaps LLVM optimizations or closure removed it?)");var g=0,b=e?e.map((function(b){if("string"==c[g++]){var d=n;Hb(b.length+1);dc(b,d);b=d}return b})):[];return(function(b,c){return"string"==c?ec(b):b})(f.apply(l,b),d)});function fc(b,d,c){c=c||"i8";"*"===c[c.length-1]&&(c="i32");switch(c){case"i1":p[b]=d;break;case"i8":p[b]=d;break;case"i16":Sb[b>>1]=d;break;case"i32":r[b>>2]=d;break;case"i64":r[b>>2]=d;break;case"float":Ub[b>>2]=d;break;case"double":gc[0]=d;r[b>>2]=hc[0];r[b+4>>2]=hc[1];break;default:bc("invalid type for setValue: "+c)}}Module.setValue=fc;Module.getValue=(function(b,d){d=d||"i8";"*"===d[d.length-1]&&(d="i32");switch(d){case"i1":return p[b];case"i8":return p[b];case"i16":return Sb[b>>1];case"i32":return r[b>>2];case"i64":return r[b>>2];case"float":return Ub[b>>2];case"double":return hc[0]=r[b>>2],hc[1]=r[b+4>>2],gc[0];default:bc("invalid type for setValue: "+d)}return l});var ic=1,D=2;Module.ALLOC_NORMAL=0;Module.ALLOC_STACK=ic;Module.ALLOC_STATIC=D;function F(b,d,c){var e,f;"number"===typeof b?(e=j,f=b):(e=m,f=b.length);var i="string"===typeof d?d:l,c=[jc,Hb,Ib][c===ca?D:c](Math.max(f,i?1:d.length));if(e){return kc(c,f),c}e=0;for(var h;e<f;){var g=b[e];"function"===typeof g&&(g=Yb.Ua(g));h=i||d[e];0===h?e++:("i64"==h&&(h="i32"),fc(c+e,g,h),e+=vb(h))}return c}Module.allocate=F;function ec(b,d){for(var c="undefined"==typeof d,e="",f=0,i,h=String.fromCharCode(0);;){i=String.fromCharCode(s[b+f]);if(c&&i==h){break}e+=i;f+=1;if(!c&&f==d){break}}return e}Module.Pointer_stringify=ec;Module.Array_stringify=(function(b){for(var d="",c=0;c<b.length;c++){d+=String.fromCharCode(b[c])}return d});var mc,nc=4096,p,s,Sb,Tb,r,z,Ub,Vb,n,oc,Qb,pc=Module.TOTAL_STACK||5242880,Rb=Module.TOTAL_MEMORY||10485760;xb(!!Int32Array&&!!Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"Cannot fallback to non-typed array case: Code is too specialized");var qc=new ArrayBuffer(Rb);p=new Int8Array(qc);Sb=new Int16Array(qc);r=new Int32Array(qc);s=new Uint8Array(qc);Tb=new Uint16Array(qc);z=new Uint32Array(qc);Ub=new Float32Array(qc);Vb=new Float64Array(qc);r[0]=255;xb(255===s[0]&&0===s[3],"Typed arrays 2 must be run on a little-endian system");var sc=rc("(null)");Qb=sc.length;for(var tc=0;tc<sc.length;tc++){p[tc]=sc[tc]}Module.HEAP=ca;Module.HEAP8=p;Module.HEAP16=Sb;Module.HEAP32=r;Module.HEAPU8=s;Module.HEAPU16=Tb;Module.HEAPU32=z;Module.HEAPF32=Ub;Module.HEAPF64=Vb;oc=(n=4*Math.ceil(Qb/4))+pc;var uc=8*Math.ceil(oc/8);p.subarray(uc);var hc=r.subarray(uc>>2);Ub.subarray(uc>>2);var gc=Vb.subarray(uc>>3);oc=uc+8;Qb=oc+4095>>12<<12;function vc(b){for(;0<b.length;){var d=b.shift(),c=d.l;"number"===typeof c&&(c=mc[c]);c(d.Pa===ca?l:d.Pa