//==============================================================================// Optimizer tool. This is meant to be run after the emscripten compiler has// finished generating code. These optimizations are done on the generated// code to further improve it. Some of the modifications also work in// conjunction with closure compiler.//==============================================================================// *** Environment setup code ***vararguments_=[];varENVIRONMENT_IS_NODE=typeofprocess==='object';varENVIRONMENT_IS_WEB=typeofwindow==='object';varENVIRONMENT_IS_WORKER=typeofimportScripts==='function';varENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){// Expose functionality in the same simple way that the shells work// Note that we pollute the global namespace here, otherwise we break in nodeprint=function(x){process['stdout'].write(x+'\n');};printErr=function(x){process['stderr'].write(x+'\n');};varnodeFS=require('fs');read=function(filename){varret=nodeFS['readFileSync'](filename).toString();if(!ret&&filename[0]!='/'){filename=__dirname.split('/').slice(0,-1).join('/')+'/src/'+filename;ret=nodeFS['readFileSync'](filename).toString();}returnret;};load=function(f){globalEval(read(f));};arguments_=process['argv'].slice(2);}elseif(ENVIRONMENT_IS_SHELL){// Polyfill over SpiderMonkey/V8 differencesif(!this['read']){this['read']=function(f){snarf(f)};}if(typeofscriptArgs!='undefined'){arguments_=scriptArgs;}elseif(typeofarguments!='undefined'){arguments_=arguments;}}elseif(ENVIRONMENT_IS_WEB){this['print']=printErr=function(x){console.log(x);};this['read']=function(url){varxhr=newXMLHttpRequest();xhr.open('GET',url,false);xhr.send(null);returnxhr.responseText;};if(this['arguments']){arguments_=arguments;}}elseif(ENVIRONMENT_IS_WORKER){// We can do very little here...this['load']=importScripts;}else{throw'Unknown runtime environment. Where are we?';}functionglobalEval(x){eval.call(null,x);}if(typeofload=='undefined'&&typeofread!='undefined'){this['load']=function(f){globalEval(read(f));};}if(typeofprintErr==='undefined'){this['printErr']=function(){};}if