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