libSystemTransform.js 287 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630
  1. /**
  2. * @license
  3. * Copyright 2010 The Emscripten Authors
  4. * SPDX-License-Identifier: MIT
  5. */
  6. // The Module object: Our interface to the outside world. We import
  7. // and export values on it. There are various ways Module can be used:
  8. // 1. Not defined. We create it here
  9. // 2. A function parameter, function(Module) { ..generated code.. }
  10. // 3. pre-run appended it, var Module = {}; ..generated code..
  11. // 4. External script tag defines var Module.
  12. // We need to check if Module already exists (e.g. case 3 above).
  13. // Substitution will be replaced with actual code on later stage of the build,
  14. // this way Closure Compiler will not mangle it (e.g. case 4. above).
  15. // Note that if you want to run closure, and also to use Module
  16. // after the generated code, you will need to define var Module = {};
  17. // before the code. Then that object will be used in the code, and you
  18. // can continue to use Module afterwards as well.
  19. var Module = typeof Module !== 'undefined' ? Module : {};
  20. // --pre-jses are emitted after the Module integration code, so that they can
  21. // refer to Module (if they choose; they can also define Module)
  22. // {{PRE_JSES}}
  23. // Sometimes an existing Module object exists with properties
  24. // meant to overwrite the default module functionality. Here
  25. // we collect those properties and reapply _after_ we configure
  26. // the current environment's defaults to avoid having to be so
  27. // defensive during initialization.
  28. var moduleOverrides = {};
  29. var key;
  30. for (key in Module) {
  31. if (Module.hasOwnProperty(key)) {
  32. moduleOverrides[key] = Module[key];
  33. }
  34. }
  35. var arguments_ = [];
  36. var thisProgram = './this.program';
  37. var quit_ = function(status, toThrow) {
  38. throw toThrow;
  39. };
  40. // Determine the runtime environment we are in. You can customize this by
  41. // setting the ENVIRONMENT setting at compile time (see settings.js).
  42. var ENVIRONMENT_IS_WEB = false;
  43. var ENVIRONMENT_IS_WORKER = false;
  44. var ENVIRONMENT_IS_NODE = false;
  45. var ENVIRONMENT_IS_SHELL = false;
  46. ENVIRONMENT_IS_WEB = typeof window === 'object';
  47. ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
  48. // N.b. Electron.js environment is simultaneously a NODE-environment, but
  49. // also a web environment.
  50. ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string';
  51. ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
  52. if (Module['ENVIRONMENT']) {
  53. throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)');
  54. }
  55. // `/` should be present at the end if `scriptDirectory` is not empty
  56. var scriptDirectory = '';
  57. function locateFile(path) {
  58. if (Module['locateFile']) {
  59. return Module['locateFile'](path, scriptDirectory);
  60. }
  61. return scriptDirectory + path;
  62. }
  63. // Hooks that are implemented differently in different runtime environments.
  64. var read_,
  65. readAsync,
  66. readBinary,
  67. setWindowTitle;
  68. var nodeFS;
  69. var nodePath;
  70. if (ENVIRONMENT_IS_NODE) {
  71. if (ENVIRONMENT_IS_WORKER) {
  72. scriptDirectory = require('path').dirname(scriptDirectory) + '/';
  73. } else {
  74. scriptDirectory = __dirname + '/';
  75. }
  76. /**
  77. * @license
  78. * Copyright 2019 The Emscripten Authors
  79. * SPDX-License-Identifier: MIT
  80. */
  81. read_ = function shell_read(filename, binary) {
  82. if (!nodeFS) nodeFS = require('fs');
  83. if (!nodePath) nodePath = require('path');
  84. filename = nodePath['normalize'](filename);
  85. return nodeFS['readFileSync'](filename, binary ? null : 'utf8');
  86. };
  87. readBinary = function readBinary(filename) {
  88. var ret = read_(filename, true);
  89. if (!ret.buffer) {
  90. ret = new Uint8Array(ret);
  91. }
  92. assert(ret.buffer);
  93. return ret;
  94. };
  95. if (process['argv'].length > 1) {
  96. thisProgram = process['argv'][1].replace(/\\/g, '/');
  97. }
  98. arguments_ = process['argv'].slice(2);
  99. if (typeof module !== 'undefined') {
  100. module['exports'] = Module;
  101. }
  102. process['on']('uncaughtException', function(ex) {
  103. // suppress ExitStatus exceptions from showing an error
  104. if (!(ex instanceof ExitStatus)) {
  105. throw ex;
  106. }
  107. });
  108. process['on']('unhandledRejection', abort);
  109. quit_ = function(status) {
  110. process['exit'](status);
  111. };
  112. Module['inspect'] = function () { return '[Emscripten Module object]'; };
  113. } else
  114. if (ENVIRONMENT_IS_SHELL) {
  115. if (typeof read != 'undefined') {
  116. read_ = function shell_read(f) {
  117. return read(f);
  118. };
  119. }
  120. readBinary = function readBinary(f) {
  121. var data;
  122. if (typeof readbuffer === 'function') {
  123. return new Uint8Array(readbuffer(f));
  124. }
  125. data = read(f, 'binary');
  126. assert(typeof data === 'object');
  127. return data;
  128. };
  129. if (typeof scriptArgs != 'undefined') {
  130. arguments_ = scriptArgs;
  131. } else if (typeof arguments != 'undefined') {
  132. arguments_ = arguments;
  133. }
  134. if (typeof quit === 'function') {
  135. quit_ = function(status) {
  136. quit(status);
  137. };
  138. }
  139. if (typeof print !== 'undefined') {
  140. // Prefer to use print/printErr where they exist, as they usually work better.
  141. if (typeof console === 'undefined') console = /** @type{!Console} */({});
  142. console.log = /** @type{!function(this:Console, ...*): undefined} */ (print);
  143. console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr !== 'undefined' ? printErr : print);
  144. }
  145. } else
  146. // Note that this includes Node.js workers when relevant (pthreads is enabled).
  147. // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
  148. // ENVIRONMENT_IS_NODE.
  149. if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
  150. if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
  151. scriptDirectory = self.location.href;
  152. } else if (document.currentScript) { // web
  153. scriptDirectory = document.currentScript.src;
  154. }
  155. // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
  156. // otherwise, slice off the final part of the url to find the script directory.
  157. // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
  158. // and scriptDirectory will correctly be replaced with an empty string.
  159. if (scriptDirectory.indexOf('blob:') !== 0) {
  160. scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf('/')+1);
  161. } else {
  162. scriptDirectory = '';
  163. }
  164. // Differentiate the Web Worker from the Node Worker case, as reading must
  165. // be done differently.
  166. {
  167. /**
  168. * @license
  169. * Copyright 2019 The Emscripten Authors
  170. * SPDX-License-Identifier: MIT
  171. */
  172. read_ = function shell_read(url) {
  173. var xhr = new XMLHttpRequest();
  174. xhr.open('GET', url, false);
  175. xhr.send(null);
  176. return xhr.responseText;
  177. };
  178. if (ENVIRONMENT_IS_WORKER) {
  179. readBinary = function readBinary(url) {
  180. var xhr = new XMLHttpRequest();
  181. xhr.open('GET', url, false);
  182. xhr.responseType = 'arraybuffer';
  183. xhr.send(null);
  184. return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
  185. };
  186. }
  187. readAsync = function readAsync(url, onload, onerror) {
  188. var xhr = new XMLHttpRequest();
  189. xhr.open('GET', url, true);
  190. xhr.responseType = 'arraybuffer';
  191. xhr.onload = function xhr_onload() {
  192. if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
  193. onload(xhr.response);
  194. return;
  195. }
  196. onerror();
  197. };
  198. xhr.onerror = onerror;
  199. xhr.send(null);
  200. };
  201. }
  202. setWindowTitle = function(title) { document.title = title };
  203. } else
  204. {
  205. throw new Error('environment detection error');
  206. }
  207. // Set up the out() and err() hooks, which are how we can print to stdout or
  208. // stderr, respectively.
  209. var out = Module['print'] || console.log.bind(console);
  210. var err = Module['printErr'] || console.warn.bind(console);
  211. // Merge back in the overrides
  212. for (key in moduleOverrides) {
  213. if (moduleOverrides.hasOwnProperty(key)) {
  214. Module[key] = moduleOverrides[key];
  215. }
  216. }
  217. // Free the object hierarchy contained in the overrides, this lets the GC
  218. // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
  219. moduleOverrides = null;
  220. // Emit code to handle expected values on the Module object. This applies Module.x
  221. // to the proper local x. This has two benefits: first, we only emit it if it is
  222. // expected to arrive, and second, by using a local everywhere else that can be
  223. // minified.
  224. if (Module['arguments']) arguments_ = Module['arguments'];if (!Object.getOwnPropertyDescriptor(Module, 'arguments')) Object.defineProperty(Module, 'arguments', { configurable: true, get: function() { abort('Module.arguments has been replaced with plain arguments_') } });
  225. if (Module['thisProgram']) thisProgram = Module['thisProgram'];if (!Object.getOwnPropertyDescriptor(Module, 'thisProgram')) Object.defineProperty(Module, 'thisProgram', { configurable: true, get: function() { abort('Module.thisProgram has been replaced with plain thisProgram') } });
  226. if (Module['quit']) quit_ = Module['quit'];if (!Object.getOwnPropertyDescriptor(Module, 'quit')) Object.defineProperty(Module, 'quit', { configurable: true, get: function() { abort('Module.quit has been replaced with plain quit_') } });
  227. // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
  228. // Assertions on removed incoming Module JS APIs.
  229. assert(typeof Module['memoryInitializerPrefixURL'] === 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
  230. assert(typeof Module['pthreadMainPrefixURL'] === 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
  231. assert(typeof Module['cdInitializerPrefixURL'] === 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
  232. assert(typeof Module['filePackagePrefixURL'] === 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
  233. assert(typeof Module['read'] === 'undefined', 'Module.read option was removed (modify read_ in JS)');
  234. assert(typeof Module['readAsync'] === 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
  235. assert(typeof Module['readBinary'] === 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
  236. assert(typeof Module['setWindowTitle'] === 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)');
  237. assert(typeof Module['TOTAL_MEMORY'] === 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
  238. if (!Object.getOwnPropertyDescriptor(Module, 'read')) Object.defineProperty(Module, 'read', { configurable: true, get: function() { abort('Module.read has been replaced with plain read_') } });
  239. if (!Object.getOwnPropertyDescriptor(Module, 'readAsync')) Object.defineProperty(Module, 'readAsync', { configurable: true, get: function() { abort('Module.readAsync has been replaced with plain readAsync') } });
  240. if (!Object.getOwnPropertyDescriptor(Module, 'readBinary')) Object.defineProperty(Module, 'readBinary', { configurable: true, get: function() { abort('Module.readBinary has been replaced with plain readBinary') } });
  241. if (!Object.getOwnPropertyDescriptor(Module, 'setWindowTitle')) Object.defineProperty(Module, 'setWindowTitle', { configurable: true, get: function() { abort('Module.setWindowTitle has been replaced with plain setWindowTitle') } });
  242. var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
  243. var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
  244. var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
  245. var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
  246. /**
  247. * @license
  248. * Copyright 2017 The Emscripten Authors
  249. * SPDX-License-Identifier: MIT
  250. */
  251. // {{PREAMBLE_ADDITIONS}}
  252. var STACK_ALIGN = 16;
  253. // stack management, and other functionality that is provided by the compiled code,
  254. // should not be used before it is ready
  255. /** @suppress{duplicate} */
  256. var stackSave;
  257. /** @suppress{duplicate} */
  258. var stackRestore;
  259. /** @suppress{duplicate} */
  260. var stackAlloc;
  261. stackSave = stackRestore = stackAlloc = function() {
  262. abort('cannot use the stack before compiled code is ready to run, and has provided stack access');
  263. };
  264. function staticAlloc(size) {
  265. abort('staticAlloc is no longer available at runtime; instead, perform static allocations at compile time (using makeStaticAlloc)');
  266. }
  267. function dynamicAlloc(size) {
  268. assert(DYNAMICTOP_PTR);
  269. var ret = HEAP32[DYNAMICTOP_PTR>>2];
  270. var end = (ret + size + 15) & -16;
  271. assert(end <= HEAP8.length, 'failure to dynamicAlloc - memory growth etc. is not supported there, call malloc/sbrk directly');
  272. HEAP32[DYNAMICTOP_PTR>>2] = end;
  273. return ret;
  274. }
  275. function alignMemory(size, factor) {
  276. if (!factor) factor = STACK_ALIGN; // stack alignment (16-byte) by default
  277. return Math.ceil(size / factor) * factor;
  278. }
  279. function getNativeTypeSize(type) {
  280. switch (type) {
  281. case 'i1': case 'i8': return 1;
  282. case 'i16': return 2;
  283. case 'i32': return 4;
  284. case 'i64': return 8;
  285. case 'float': return 4;
  286. case 'double': return 8;
  287. default: {
  288. if (type[type.length-1] === '*') {
  289. return 4; // A pointer
  290. } else if (type[0] === 'i') {
  291. var bits = Number(type.substr(1));
  292. assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
  293. return bits / 8;
  294. } else {
  295. return 0;
  296. }
  297. }
  298. }
  299. }
  300. function warnOnce(text) {
  301. if (!warnOnce.shown) warnOnce.shown = {};
  302. if (!warnOnce.shown[text]) {
  303. warnOnce.shown[text] = 1;
  304. err(text);
  305. }
  306. }
  307. /**
  308. * @license
  309. * Copyright 2020 The Emscripten Authors
  310. * SPDX-License-Identifier: MIT
  311. */
  312. // Wraps a JS function as a wasm function with a given signature.
  313. function convertJsFunctionToWasm(func, sig) {
  314. // If the type reflection proposal is available, use the new
  315. // "WebAssembly.Function" constructor.
  316. // Otherwise, construct a minimal wasm module importing the JS function and
  317. // re-exporting it.
  318. if (typeof WebAssembly.Function === "function") {
  319. var typeNames = {
  320. 'i': 'i32',
  321. 'j': 'i64',
  322. 'f': 'f32',
  323. 'd': 'f64'
  324. };
  325. var type = {
  326. parameters: [],
  327. results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
  328. };
  329. for (var i = 1; i < sig.length; ++i) {
  330. type.parameters.push(typeNames[sig[i]]);
  331. }
  332. return new WebAssembly.Function(type, func);
  333. }
  334. // The module is static, with the exception of the type section, which is
  335. // generated based on the signature passed in.
  336. var typeSection = [
  337. 0x01, // id: section,
  338. 0x00, // length: 0 (placeholder)
  339. 0x01, // count: 1
  340. 0x60, // form: func
  341. ];
  342. var sigRet = sig.slice(0, 1);
  343. var sigParam = sig.slice(1);
  344. var typeCodes = {
  345. 'i': 0x7f, // i32
  346. 'j': 0x7e, // i64
  347. 'f': 0x7d, // f32
  348. 'd': 0x7c, // f64
  349. };
  350. // Parameters, length + signatures
  351. typeSection.push(sigParam.length);
  352. for (var i = 0; i < sigParam.length; ++i) {
  353. typeSection.push(typeCodes[sigParam[i]]);
  354. }
  355. // Return values, length + signatures
  356. // With no multi-return in MVP, either 0 (void) or 1 (anything else)
  357. if (sigRet == 'v') {
  358. typeSection.push(0x00);
  359. } else {
  360. typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
  361. }
  362. // Write the overall length of the type section back into the section header
  363. // (excepting the 2 bytes for the section id and length)
  364. typeSection[1] = typeSection.length - 2;
  365. // Rest of the module is static
  366. var bytes = new Uint8Array([
  367. 0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
  368. 0x01, 0x00, 0x00, 0x00, // version: 1
  369. ].concat(typeSection, [
  370. 0x02, 0x07, // import section
  371. // (import "e" "f" (func 0 (type 0)))
  372. 0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
  373. 0x07, 0x05, // export section
  374. // (export "f" (func 0 (type 0)))
  375. 0x01, 0x01, 0x66, 0x00, 0x00,
  376. ]));
  377. // We can compile this wasm module synchronously because it is very small.
  378. // This accepts an import (at "e.f"), that it reroutes to an export (at "f")
  379. var module = new WebAssembly.Module(bytes);
  380. var instance = new WebAssembly.Instance(module, {
  381. 'e': {
  382. 'f': func
  383. }
  384. });
  385. var wrappedFunc = instance.exports['f'];
  386. return wrappedFunc;
  387. }
  388. var freeTableIndexes = [];
  389. // Weak map of functions in the table to their indexes, created on first use.
  390. var functionsInTableMap;
  391. // Add a wasm function to the table.
  392. function addFunctionWasm(func, sig) {
  393. var table = wasmTable;
  394. // Check if the function is already in the table, to ensure each function
  395. // gets a unique index. First, create the map if this is the first use.
  396. if (!functionsInTableMap) {
  397. functionsInTableMap = new WeakMap();
  398. for (var i = 0; i < table.length; i++) {
  399. var item = table.get(i);
  400. // Ignore null values.
  401. if (item) {
  402. functionsInTableMap.set(item, i);
  403. }
  404. }
  405. }
  406. if (functionsInTableMap.has(func)) {
  407. return functionsInTableMap.get(func);
  408. }
  409. // It's not in the table, add it now.
  410. var ret;
  411. // Reuse a free index if there is one, otherwise grow.
  412. if (freeTableIndexes.length) {
  413. ret = freeTableIndexes.pop();
  414. } else {
  415. ret = table.length;
  416. // Grow the table
  417. try {
  418. table.grow(1);
  419. } catch (err) {
  420. if (!(err instanceof RangeError)) {
  421. throw err;
  422. }
  423. throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
  424. }
  425. }
  426. // Set the new value.
  427. try {
  428. // Attempting to call this with JS function will cause of table.set() to fail
  429. table.set(ret, func);
  430. } catch (err) {
  431. if (!(err instanceof TypeError)) {
  432. throw err;
  433. }
  434. assert(typeof sig !== 'undefined', 'Missing signature argument to addFunction');
  435. var wrapped = convertJsFunctionToWasm(func, sig);
  436. table.set(ret, wrapped);
  437. }
  438. functionsInTableMap.set(func, ret);
  439. return ret;
  440. }
  441. function removeFunctionWasm(index) {
  442. functionsInTableMap.delete(wasmTable.get(index));
  443. freeTableIndexes.push(index);
  444. }
  445. // 'sig' parameter is required for the llvm backend but only when func is not
  446. // already a WebAssembly function.
  447. function addFunction(func, sig) {
  448. assert(typeof func !== 'undefined');
  449. return addFunctionWasm(func, sig);
  450. }
  451. function removeFunction(index) {
  452. removeFunctionWasm(index);
  453. }
  454. var funcWrappers = {};
  455. function getFuncWrapper(func, sig) {
  456. if (!func) return; // on null pointer, return undefined
  457. assert(sig);
  458. if (!funcWrappers[sig]) {
  459. funcWrappers[sig] = {};
  460. }
  461. var sigCache = funcWrappers[sig];
  462. if (!sigCache[func]) {
  463. // optimize away arguments usage in common cases
  464. if (sig.length === 1) {
  465. sigCache[func] = function dynCall_wrapper() {
  466. return dynCall(sig, func);
  467. };
  468. } else if (sig.length === 2) {
  469. sigCache[func] = function dynCall_wrapper(arg) {
  470. return dynCall(sig, func, [arg]);
  471. };
  472. } else {
  473. // general case
  474. sigCache[func] = function dynCall_wrapper() {
  475. return dynCall(sig, func, Array.prototype.slice.call(arguments));
  476. };
  477. }
  478. }
  479. return sigCache[func];
  480. }
  481. /**
  482. * @license
  483. * Copyright 2020 The Emscripten Authors
  484. * SPDX-License-Identifier: MIT
  485. */
  486. function makeBigInt(low, high, unsigned) {
  487. return unsigned ? ((+((low>>>0)))+((+((high>>>0)))*4294967296.0)) : ((+((low>>>0)))+((+((high|0)))*4294967296.0));
  488. }
  489. /** @param {Array=} args */
  490. function dynCall(sig, ptr, args) {
  491. if (args && args.length) {
  492. // j (64-bit integer) must be passed in as two numbers [low 32, high 32].
  493. assert(args.length === sig.substring(1).replace(/j/g, '--').length);
  494. assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
  495. return Module['dynCall_' + sig].apply(null, [ptr].concat(args));
  496. } else {
  497. assert(sig.length == 1);
  498. assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
  499. return Module['dynCall_' + sig].call(null, ptr);
  500. }
  501. }
  502. var tempRet0 = 0;
  503. var setTempRet0 = function(value) {
  504. tempRet0 = value;
  505. };
  506. var getTempRet0 = function() {
  507. return tempRet0;
  508. };
  509. function getCompilerSetting(name) {
  510. throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for getCompilerSetting or emscripten_get_compiler_setting to work';
  511. }
  512. // The address globals begin at. Very low in memory, for code size and optimization opportunities.
  513. // Above 0 is static memory, starting with globals.
  514. // Then the stack.
  515. // Then 'dynamic' memory for sbrk.
  516. var GLOBAL_BASE = 1024;
  517. /**
  518. * @license
  519. * Copyright 2010 The Emscripten Authors
  520. * SPDX-License-Identifier: MIT
  521. */
  522. // === Preamble library stuff ===
  523. // Documentation for the public APIs defined in this file must be updated in:
  524. // site/source/docs/api_reference/preamble.js.rst
  525. // A prebuilt local version of the documentation is available at:
  526. // site/build/text/docs/api_reference/preamble.js.txt
  527. // You can also build docs locally as HTML or other formats in site/
  528. // An online HTML version (which may be of a different version of Emscripten)
  529. // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
  530. var wasmBinary;if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];if (!Object.getOwnPropertyDescriptor(Module, 'wasmBinary')) Object.defineProperty(Module, 'wasmBinary', { configurable: true, get: function() { abort('Module.wasmBinary has been replaced with plain wasmBinary') } });
  531. var noExitRuntime;if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];if (!Object.getOwnPropertyDescriptor(Module, 'noExitRuntime')) Object.defineProperty(Module, 'noExitRuntime', { configurable: true, get: function() { abort('Module.noExitRuntime has been replaced with plain noExitRuntime') } });
  532. if (typeof WebAssembly !== 'object') {
  533. abort('No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead.');
  534. }
  535. /**
  536. * @license
  537. * Copyright 2019 The Emscripten Authors
  538. * SPDX-License-Identifier: MIT
  539. */
  540. // In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
  541. // In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)
  542. /** @param {number} ptr
  543. @param {number} value
  544. @param {string} type
  545. @param {number|boolean=} noSafe */
  546. function setValue(ptr, value, type, noSafe) {
  547. type = type || 'i8';
  548. if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
  549. switch(type) {
  550. case 'i1': HEAP8[((ptr)>>0)]=value; break;
  551. case 'i8': HEAP8[((ptr)>>0)]=value; break;
  552. case 'i16': HEAP16[((ptr)>>1)]=value; break;
  553. case 'i32': HEAP32[((ptr)>>2)]=value; break;
  554. case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
  555. case 'float': HEAPF32[((ptr)>>2)]=value; break;
  556. case 'double': HEAPF64[((ptr)>>3)]=value; break;
  557. default: abort('invalid type for setValue: ' + type);
  558. }
  559. }
  560. /** @param {number} ptr
  561. @param {string} type
  562. @param {number|boolean=} noSafe */
  563. function getValue(ptr, type, noSafe) {
  564. type = type || 'i8';
  565. if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
  566. switch(type) {
  567. case 'i1': return HEAP8[((ptr)>>0)];
  568. case 'i8': return HEAP8[((ptr)>>0)];
  569. case 'i16': return HEAP16[((ptr)>>1)];
  570. case 'i32': return HEAP32[((ptr)>>2)];
  571. case 'i64': return HEAP32[((ptr)>>2)];
  572. case 'float': return HEAPF32[((ptr)>>2)];
  573. case 'double': return HEAPF64[((ptr)>>3)];
  574. default: abort('invalid type for getValue: ' + type);
  575. }
  576. return null;
  577. }
  578. // Wasm globals
  579. var wasmMemory;
  580. // In fastcomp asm.js, we don't need a wasm Table at all.
  581. // In the wasm backend, we polyfill the WebAssembly object,
  582. // so this creates a (non-native-wasm) table for us.
  583. var wasmTable = new WebAssembly.Table({
  584. 'initial': 283,
  585. 'maximum': 283 + 0,
  586. 'element': 'anyfunc'
  587. });
  588. //========================================
  589. // Runtime essentials
  590. //========================================
  591. // whether we are quitting the application. no code should run after this.
  592. // set in exit() and abort()
  593. var ABORT = false;
  594. // set by exit() and abort(). Passed to 'onExit' handler.
  595. // NOTE: This is also used as the process return code code in shell environments
  596. // but only when noExitRuntime is false.
  597. var EXITSTATUS = 0;
  598. /** @type {function(*, string=)} */
  599. function assert(condition, text) {
  600. if (!condition) {
  601. abort('Assertion failed: ' + text);
  602. }
  603. }
  604. // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
  605. function getCFunc(ident) {
  606. var func = Module['_' + ident]; // closure exported function
  607. assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
  608. return func;
  609. }
  610. // C calling interface.
  611. /** @param {string|null=} returnType
  612. @param {Array=} argTypes
  613. @param {Arguments|Array=} args
  614. @param {Object=} opts */
  615. function ccall(ident, returnType, argTypes, args, opts) {
  616. // For fast lookup of conversion functions
  617. var toC = {
  618. 'string': function(str) {
  619. var ret = 0;
  620. if (str !== null && str !== undefined && str !== 0) { // null string
  621. // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
  622. var len = (str.length << 2) + 1;
  623. ret = stackAlloc(len);
  624. stringToUTF8(str, ret, len);
  625. }
  626. return ret;
  627. },
  628. 'array': function(arr) {
  629. var ret = stackAlloc(arr.length);
  630. writeArrayToMemory(arr, ret);
  631. return ret;
  632. }
  633. };
  634. function convertReturnValue(ret) {
  635. if (returnType === 'string') return UTF8ToString(ret);
  636. if (returnType === 'boolean') return Boolean(ret);
  637. return ret;
  638. }
  639. var func = getCFunc(ident);
  640. var cArgs = [];
  641. var stack = 0;
  642. assert(returnType !== 'array', 'Return type should not be "array".');
  643. if (args) {
  644. for (var i = 0; i < args.length; i++) {
  645. var converter = toC[argTypes[i]];
  646. if (converter) {
  647. if (stack === 0) stack = stackSave();
  648. cArgs[i] = converter(args[i]);
  649. } else {
  650. cArgs[i] = args[i];
  651. }
  652. }
  653. }
  654. var ret = func.apply(null, cArgs);
  655. ret = convertReturnValue(ret);
  656. if (stack !== 0) stackRestore(stack);
  657. return ret;
  658. }
  659. /** @param {string=} returnType
  660. @param {Array=} argTypes
  661. @param {Object=} opts */
  662. function cwrap(ident, returnType, argTypes, opts) {
  663. return function() {
  664. return ccall(ident, returnType, argTypes, arguments, opts);
  665. }
  666. }
  667. var ALLOC_NORMAL = 0; // Tries to use _malloc()
  668. var ALLOC_STACK = 1; // Lives for the duration of the current function call
  669. var ALLOC_DYNAMIC = 2; // Cannot be freed except through sbrk
  670. var ALLOC_NONE = 3; // Do not allocate
  671. // allocate(): This is for internal use. You can use it yourself as well, but the interface
  672. // is a little tricky (see docs right below). The reason is that it is optimized
  673. // for multiple syntaxes to save space in generated code. So you should
  674. // normally not use allocate(), and instead allocate memory using _malloc(),
  675. // initialize it with setValue(), and so forth.
  676. // @slab: An array of data, or a number. If a number, then the size of the block to allocate,
  677. // in *bytes* (note that this is sometimes confusing: the next parameter does not
  678. // affect this!)
  679. // @types: Either an array of types, one for each byte (or 0 if no type at that position),
  680. // or a single type which is used for the entire block. This only matters if there
  681. // is initial data - if @slab is a number, then this does not matter at all and is
  682. // ignored.
  683. // @allocator: How to allocate memory, see ALLOC_*
  684. /** @type {function((TypedArray|Array<number>|number), string, number, number=)} */
  685. function allocate(slab, types, allocator, ptr) {
  686. var zeroinit, size;
  687. if (typeof slab === 'number') {
  688. zeroinit = true;
  689. size = slab;
  690. } else {
  691. zeroinit = false;
  692. size = slab.length;
  693. }
  694. var singleType = typeof types === 'string' ? types : null;
  695. var ret;
  696. if (allocator == ALLOC_NONE) {
  697. ret = ptr;
  698. } else {
  699. ret = [_malloc,
  700. stackAlloc,
  701. dynamicAlloc][allocator](Math.max(size, singleType ? 1 : types.length));
  702. }
  703. if (zeroinit) {
  704. var stop;
  705. ptr = ret;
  706. assert((ret & 3) == 0);
  707. stop = ret + (size & ~3);
  708. for (; ptr < stop; ptr += 4) {
  709. HEAP32[((ptr)>>2)]=0;
  710. }
  711. stop = ret + size;
  712. while (ptr < stop) {
  713. HEAP8[((ptr++)>>0)]=0;
  714. }
  715. return ret;
  716. }
  717. if (singleType === 'i8') {
  718. if (slab.subarray || slab.slice) {
  719. HEAPU8.set(/** @type {!Uint8Array} */ (slab), ret);
  720. } else {
  721. HEAPU8.set(new Uint8Array(slab), ret);
  722. }
  723. return ret;
  724. }
  725. var i = 0, type, typeSize, previousType;
  726. while (i < size) {
  727. var curr = slab[i];
  728. type = singleType || types[i];
  729. if (type === 0) {
  730. i++;
  731. continue;
  732. }
  733. assert(type, 'Must know what type to store in allocate!');
  734. if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
  735. setValue(ret+i, curr, type);
  736. // no need to look up size unless type changes, so cache it
  737. if (previousType !== type) {
  738. typeSize = getNativeTypeSize(type);
  739. previousType = type;
  740. }
  741. i += typeSize;
  742. }
  743. return ret;
  744. }
  745. // Allocate memory during any stage of startup - static memory early on, dynamic memory later, malloc when ready
  746. function getMemory(size) {
  747. if (!runtimeInitialized) return dynamicAlloc(size);
  748. return _malloc(size);
  749. }
  750. /**
  751. * @license
  752. * Copyright 2019 The Emscripten Authors
  753. * SPDX-License-Identifier: MIT
  754. */
  755. // runtime_strings.js: Strings related runtime functions that are part of both MINIMAL_RUNTIME and regular runtime.
  756. // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns
  757. // a copy of that string as a Javascript String object.
  758. var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
  759. /**
  760. * @param {number} idx
  761. * @param {number=} maxBytesToRead
  762. * @return {string}
  763. */
  764. function UTF8ArrayToString(heap, idx, maxBytesToRead) {
  765. var endIdx = idx + maxBytesToRead;
  766. var endPtr = idx;
  767. // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
  768. // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
  769. // (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity)
  770. while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  771. if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
  772. return UTF8Decoder.decode(heap.subarray(idx, endPtr));
  773. } else {
  774. var str = '';
  775. // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
  776. while (idx < endPtr) {
  777. // For UTF8 byte structure, see:
  778. // http://en.wikipedia.org/wiki/UTF-8#Description
  779. // https://www.ietf.org/rfc/rfc2279.txt
  780. // https://tools.ietf.org/html/rfc3629
  781. var u0 = heap[idx++];
  782. if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
  783. var u1 = heap[idx++] & 63;
  784. if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
  785. var u2 = heap[idx++] & 63;
  786. if ((u0 & 0xF0) == 0xE0) {
  787. u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
  788. } else {
  789. if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte 0x' + u0.toString(16) + ' encountered when deserializing a UTF-8 string on the asm.js/wasm heap to a JS string!');
  790. u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63);
  791. }
  792. if (u0 < 0x10000) {
  793. str += String.fromCharCode(u0);
  794. } else {
  795. var ch = u0 - 0x10000;
  796. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  797. }
  798. }
  799. }
  800. return str;
  801. }
  802. // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns a
  803. // copy of that string as a Javascript String object.
  804. // maxBytesToRead: an optional length that specifies the maximum number of bytes to read. You can omit
  805. // this parameter to scan the string until the first \0 byte. If maxBytesToRead is
  806. // passed, and the string at [ptr, ptr+maxBytesToReadr[ contains a null byte in the
  807. // middle, then the string will cut short at that byte index (i.e. maxBytesToRead will
  808. // not produce a string of exact length [ptr, ptr+maxBytesToRead[)
  809. // N.B. mixing frequent uses of UTF8ToString() with and without maxBytesToRead may
  810. // throw JS JIT optimizations off, so it is worth to consider consistently using one
  811. // style or the other.
  812. /**
  813. * @param {number} ptr
  814. * @param {number=} maxBytesToRead
  815. * @return {string}
  816. */
  817. function UTF8ToString(ptr, maxBytesToRead) {
  818. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
  819. }
  820. // Copies the given Javascript String object 'str' to the given byte array at address 'outIdx',
  821. // encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP.
  822. // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
  823. // Parameters:
  824. // str: the Javascript string to copy.
  825. // heap: the array to copy to. Each index in this array is assumed to be one 8-byte element.
  826. // outIdx: The starting offset in the array to begin the copying.
  827. // maxBytesToWrite: The maximum number of bytes this function can write to the array.
  828. // This count should include the null terminator,
  829. // i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else.
  830. // maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator.
  831. // Returns the number of bytes written, EXCLUDING the null terminator.
  832. function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
  833. if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
  834. return 0;
  835. var startIdx = outIdx;
  836. var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
  837. for (var i = 0; i < str.length; ++i) {
  838. // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
  839. // See http://unicode.org/faq/utf_bom.html#utf16-3
  840. // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
  841. var u = str.charCodeAt(i); // possibly a lead surrogate
  842. if (u >= 0xD800 && u <= 0xDFFF) {
  843. var u1 = str.charCodeAt(++i);
  844. u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
  845. }
  846. if (u <= 0x7F) {
  847. if (outIdx >= endIdx) break;
  848. heap[outIdx++] = u;
  849. } else if (u <= 0x7FF) {
  850. if (outIdx + 1 >= endIdx) break;
  851. heap[outIdx++] = 0xC0 | (u >> 6);
  852. heap[outIdx++] = 0x80 | (u & 63);
  853. } else if (u <= 0xFFFF) {
  854. if (outIdx + 2 >= endIdx) break;
  855. heap[outIdx++] = 0xE0 | (u >> 12);
  856. heap[outIdx++] = 0x80 | ((u >> 6) & 63);
  857. heap[outIdx++] = 0x80 | (u & 63);
  858. } else {
  859. if (outIdx + 3 >= endIdx) break;
  860. if (u >= 0x200000) warnOnce('Invalid Unicode code point 0x' + u.toString(16) + ' encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF).');
  861. heap[outIdx++] = 0xF0 | (u >> 18);
  862. heap[outIdx++] = 0x80 | ((u >> 12) & 63);
  863. heap[outIdx++] = 0x80 | ((u >> 6) & 63);
  864. heap[outIdx++] = 0x80 | (u & 63);
  865. }
  866. }
  867. // Null-terminate the pointer to the buffer.
  868. heap[outIdx] = 0;
  869. return outIdx - startIdx;
  870. }
  871. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  872. // null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP.
  873. // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
  874. // Returns the number of bytes written, EXCLUDING the null terminator.
  875. function stringToUTF8(str, outPtr, maxBytesToWrite) {
  876. assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
  877. return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
  878. }
  879. // Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
  880. function lengthBytesUTF8(str) {
  881. var len = 0;
  882. for (var i = 0; i < str.length; ++i) {
  883. // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
  884. // See http://unicode.org/faq/utf_bom.html#utf16-3
  885. var u = str.charCodeAt(i); // possibly a lead surrogate
  886. if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
  887. if (u <= 0x7F) ++len;
  888. else if (u <= 0x7FF) len += 2;
  889. else if (u <= 0xFFFF) len += 3;
  890. else len += 4;
  891. }
  892. return len;
  893. }
  894. /**
  895. * @license
  896. * Copyright 2020 The Emscripten Authors
  897. * SPDX-License-Identifier: MIT
  898. */
  899. // runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime.
  900. // Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
  901. // a copy of that string as a Javascript String object.
  902. function AsciiToString(ptr) {
  903. var str = '';
  904. while (1) {
  905. var ch = HEAPU8[((ptr++)>>0)];
  906. if (!ch) return str;
  907. str += String.fromCharCode(ch);
  908. }
  909. }
  910. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  911. // null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
  912. function stringToAscii(str, outPtr) {
  913. return writeAsciiToMemory(str, outPtr, false);
  914. }
  915. // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
  916. // a copy of that string as a Javascript String object.
  917. var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined;
  918. function UTF16ToString(ptr, maxBytesToRead) {
  919. assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
  920. var endPtr = ptr;
  921. // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
  922. // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
  923. var idx = endPtr >> 1;
  924. var maxIdx = idx + maxBytesToRead / 2;
  925. // If maxBytesToRead is not passed explicitly, it will be undefined, and this
  926. // will always evaluate to true. This saves on code size.
  927. while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
  928. endPtr = idx << 1;
  929. if (endPtr - ptr > 32 && UTF16Decoder) {
  930. return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
  931. } else {
  932. var i = 0;
  933. var str = '';
  934. while (1) {
  935. var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
  936. if (codeUnit == 0 || i == maxBytesToRead / 2) return str;
  937. ++i;
  938. // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
  939. str += String.fromCharCode(codeUnit);
  940. }
  941. }
  942. }
  943. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  944. // null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
  945. // Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
  946. // Parameters:
  947. // str: the Javascript string to copy.
  948. // outPtr: Byte address in Emscripten HEAP where to write the string to.
  949. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
  950. // terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
  951. // maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
  952. // Returns the number of bytes written, EXCLUDING the null terminator.
  953. function stringToUTF16(str, outPtr, maxBytesToWrite) {
  954. assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
  955. assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
  956. // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
  957. if (maxBytesToWrite === undefined) {
  958. maxBytesToWrite = 0x7FFFFFFF;
  959. }
  960. if (maxBytesToWrite < 2) return 0;
  961. maxBytesToWrite -= 2; // Null terminator.
  962. var startPtr = outPtr;
  963. var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
  964. for (var i = 0; i < numCharsToWrite; ++i) {
  965. // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
  966. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
  967. HEAP16[((outPtr)>>1)]=codeUnit;
  968. outPtr += 2;
  969. }
  970. // Null-terminate the pointer to the HEAP.
  971. HEAP16[((outPtr)>>1)]=0;
  972. return outPtr - startPtr;
  973. }
  974. // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
  975. function lengthBytesUTF16(str) {
  976. return str.length*2;
  977. }
  978. function UTF32ToString(ptr, maxBytesToRead) {
  979. assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
  980. var i = 0;
  981. var str = '';
  982. // If maxBytesToRead is not passed explicitly, it will be undefined, and this
  983. // will always evaluate to true. This saves on code size.
  984. while (!(i >= maxBytesToRead / 4)) {
  985. var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
  986. if (utf32 == 0) break;
  987. ++i;
  988. // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
  989. // See http://unicode.org/faq/utf_bom.html#utf16-3
  990. if (utf32 >= 0x10000) {
  991. var ch = utf32 - 0x10000;
  992. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  993. } else {
  994. str += String.fromCharCode(utf32);
  995. }
  996. }
  997. return str;
  998. }
  999. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  1000. // null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
  1001. // Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
  1002. // Parameters:
  1003. // str: the Javascript string to copy.
  1004. // outPtr: Byte address in Emscripten HEAP where to write the string to.
  1005. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
  1006. // terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
  1007. // maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
  1008. // Returns the number of bytes written, EXCLUDING the null terminator.
  1009. function stringToUTF32(str, outPtr, maxBytesToWrite) {
  1010. assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
  1011. assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
  1012. // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
  1013. if (maxBytesToWrite === undefined) {
  1014. maxBytesToWrite = 0x7FFFFFFF;
  1015. }
  1016. if (maxBytesToWrite < 4) return 0;
  1017. var startPtr = outPtr;
  1018. var endPtr = startPtr + maxBytesToWrite - 4;
  1019. for (var i = 0; i < str.length; ++i) {
  1020. // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
  1021. // See http://unicode.org/faq/utf_bom.html#utf16-3
  1022. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
  1023. if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
  1024. var trailSurrogate = str.charCodeAt(++i);
  1025. codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
  1026. }
  1027. HEAP32[((outPtr)>>2)]=codeUnit;
  1028. outPtr += 4;
  1029. if (outPtr + 4 > endPtr) break;
  1030. }
  1031. // Null-terminate the pointer to the HEAP.
  1032. HEAP32[((outPtr)>>2)]=0;
  1033. return outPtr - startPtr;
  1034. }
  1035. // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
  1036. function lengthBytesUTF32(str) {
  1037. var len = 0;
  1038. for (var i = 0; i < str.length; ++i) {
  1039. // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
  1040. // See http://unicode.org/faq/utf_bom.html#utf16-3
  1041. var codeUnit = str.charCodeAt(i);
  1042. if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
  1043. len += 4;
  1044. }
  1045. return len;
  1046. }
  1047. // Allocate heap space for a JS string, and write it there.
  1048. // It is the responsibility of the caller to free() that memory.
  1049. function allocateUTF8(str) {
  1050. var size = lengthBytesUTF8(str) + 1;
  1051. var ret = _malloc(size);
  1052. if (ret) stringToUTF8Array(str, HEAP8, ret, size);
  1053. return ret;
  1054. }
  1055. // Allocate stack space for a JS string, and write it there.
  1056. function allocateUTF8OnStack(str) {
  1057. var size = lengthBytesUTF8(str) + 1;
  1058. var ret = stackAlloc(size);
  1059. stringToUTF8Array(str, HEAP8, ret, size);
  1060. return ret;
  1061. }
  1062. // Deprecated: This function should not be called because it is unsafe and does not provide
  1063. // a maximum length limit of how many bytes it is allowed to write. Prefer calling the
  1064. // function stringToUTF8Array() instead, which takes in a maximum length that can be used
  1065. // to be secure from out of bounds writes.
  1066. /** @deprecated
  1067. @param {boolean=} dontAddNull */
  1068. function writeStringToMemory(string, buffer, dontAddNull) {
  1069. warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
  1070. var /** @type {number} */ lastChar, /** @type {number} */ end;
  1071. if (dontAddNull) {
  1072. // stringToUTF8Array always appends null. If we don't want to do that, remember the
  1073. // character that existed at the location where the null will be placed, and restore
  1074. // that after the write (below).
  1075. end = buffer + lengthBytesUTF8(string);
  1076. lastChar = HEAP8[end];
  1077. }
  1078. stringToUTF8(string, buffer, Infinity);
  1079. if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
  1080. }
  1081. function writeArrayToMemory(array, buffer) {
  1082. assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
  1083. HEAP8.set(array, buffer);
  1084. }
  1085. /** @param {boolean=} dontAddNull */
  1086. function writeAsciiToMemory(str, buffer, dontAddNull) {
  1087. for (var i = 0; i < str.length; ++i) {
  1088. assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff);
  1089. HEAP8[((buffer++)>>0)]=str.charCodeAt(i);
  1090. }
  1091. // Null-terminate the pointer to the HEAP.
  1092. if (!dontAddNull) HEAP8[((buffer)>>0)]=0;
  1093. }
  1094. // Memory management
  1095. var PAGE_SIZE = 16384;
  1096. var WASM_PAGE_SIZE = 65536;
  1097. var ASMJS_PAGE_SIZE = 16777216;
  1098. function alignUp(x, multiple) {
  1099. if (x % multiple > 0) {
  1100. x += multiple - (x % multiple);
  1101. }
  1102. return x;
  1103. }
  1104. var HEAP,
  1105. /** @type {ArrayBuffer} */
  1106. buffer,
  1107. /** @type {Int8Array} */
  1108. HEAP8,
  1109. /** @type {Uint8Array} */
  1110. HEAPU8,
  1111. /** @type {Int16Array} */
  1112. HEAP16,
  1113. /** @type {Uint16Array} */
  1114. HEAPU16,
  1115. /** @type {Int32Array} */
  1116. HEAP32,
  1117. /** @type {Uint32Array} */
  1118. HEAPU32,
  1119. /** @type {Float32Array} */
  1120. HEAPF32,
  1121. /** @type {Float64Array} */
  1122. HEAPF64;
  1123. function updateGlobalBufferAndViews(buf) {
  1124. buffer = buf;
  1125. Module['HEAP8'] = HEAP8 = new Int8Array(buf);
  1126. Module['HEAP16'] = HEAP16 = new Int16Array(buf);
  1127. Module['HEAP32'] = HEAP32 = new Int32Array(buf);
  1128. Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf);
  1129. Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf);
  1130. Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf);
  1131. Module['HEAPF32'] = HEAPF32 = new Float32Array(buf);
  1132. Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
  1133. }
  1134. var STATIC_BASE = 1024,
  1135. STACK_BASE = 5538272,
  1136. STACKTOP = STACK_BASE,
  1137. STACK_MAX = 295392,
  1138. DYNAMIC_BASE = 5538272,
  1139. DYNAMICTOP_PTR = 295216;
  1140. assert(STACK_BASE % 16 === 0, 'stack must start aligned');
  1141. assert(DYNAMIC_BASE % 16 === 0, 'heap must start aligned');
  1142. var TOTAL_STACK = 5242880;
  1143. if (Module['TOTAL_STACK']) assert(TOTAL_STACK === Module['TOTAL_STACK'], 'the stack size can no longer be determined at runtime')
  1144. var INITIAL_INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 67108864;if (!Object.getOwnPropertyDescriptor(Module, 'INITIAL_MEMORY')) Object.defineProperty(Module, 'INITIAL_MEMORY', { configurable: true, get: function() { abort('Module.INITIAL_MEMORY has been replaced with plain INITIAL_INITIAL_MEMORY') } });
  1145. assert(INITIAL_INITIAL_MEMORY >= TOTAL_STACK, 'INITIAL_MEMORY should be larger than TOTAL_STACK, was ' + INITIAL_INITIAL_MEMORY + '! (TOTAL_STACK=' + TOTAL_STACK + ')');
  1146. // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
  1147. assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray !== undefined && Int32Array.prototype.set !== undefined,
  1148. 'JS engine does not provide full typed array support');
  1149. /**
  1150. * @license
  1151. * Copyright 2019 The Emscripten Authors
  1152. * SPDX-License-Identifier: MIT
  1153. */
  1154. // In standalone mode, the wasm creates the memory, and the user can't provide it.
  1155. // In non-standalone/normal mode, we create the memory here.
  1156. /**
  1157. * @license
  1158. * Copyright 2019 The Emscripten Authors
  1159. * SPDX-License-Identifier: MIT
  1160. */
  1161. // Create the main memory. (Note: this isn't used in STANDALONE_WASM mode since the wasm
  1162. // memory is created in the wasm, not in JS.)
  1163. if (Module['wasmMemory']) {
  1164. wasmMemory = Module['wasmMemory'];
  1165. } else
  1166. {
  1167. wasmMemory = new WebAssembly.Memory({
  1168. 'initial': INITIAL_INITIAL_MEMORY / WASM_PAGE_SIZE
  1169. ,
  1170. 'maximum': INITIAL_INITIAL_MEMORY / WASM_PAGE_SIZE
  1171. });
  1172. }
  1173. if (wasmMemory) {
  1174. buffer = wasmMemory.buffer;
  1175. }
  1176. // If the user provides an incorrect length, just use that length instead rather than providing the user to
  1177. // specifically provide the memory length with Module['INITIAL_MEMORY'].
  1178. INITIAL_INITIAL_MEMORY = buffer.byteLength;
  1179. assert(INITIAL_INITIAL_MEMORY % WASM_PAGE_SIZE === 0);
  1180. updateGlobalBufferAndViews(buffer);
  1181. HEAP32[DYNAMICTOP_PTR>>2] = DYNAMIC_BASE;
  1182. /**
  1183. * @license
  1184. * Copyright 2019 The Emscripten Authors
  1185. * SPDX-License-Identifier: MIT
  1186. */
  1187. // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
  1188. function writeStackCookie() {
  1189. assert((STACK_MAX & 3) == 0);
  1190. // The stack grows downwards
  1191. HEAPU32[(STACK_MAX >> 2)+1] = 0x2135467;
  1192. HEAPU32[(STACK_MAX >> 2)+2] = 0x89BACDFE;
  1193. // Also test the global address 0 for integrity.
  1194. // We don't do this with ASan because ASan does its own checks for this.
  1195. HEAP32[0] = 0x63736d65; /* 'emsc' */
  1196. }
  1197. function checkStackCookie() {
  1198. var cookie1 = HEAPU32[(STACK_MAX >> 2)+1];
  1199. var cookie2 = HEAPU32[(STACK_MAX >> 2)+2];
  1200. if (cookie1 != 0x2135467 || cookie2 != 0x89BACDFE) {
  1201. abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' ' + cookie1.toString(16));
  1202. }
  1203. // Also test the global address 0 for integrity.
  1204. // We don't do this with ASan because ASan does its own checks for this.
  1205. if (HEAP32[0] !== 0x63736d65 /* 'emsc' */) abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
  1206. }
  1207. function abortStackOverflow(allocSize) {
  1208. abort('Stack overflow! Attempted to allocate ' + allocSize + ' bytes on the stack, but stack has only ' + (STACK_MAX - stackSave() + allocSize) + ' bytes available!');
  1209. }
  1210. /**
  1211. * @license
  1212. * Copyright 2019 The Emscripten Authors
  1213. * SPDX-License-Identifier: MIT
  1214. */
  1215. // Endianness check (note: assumes compiler arch was little-endian)
  1216. (function() {
  1217. var h16 = new Int16Array(1);
  1218. var h8 = new Int8Array(h16.buffer);
  1219. h16[0] = 0x6373;
  1220. if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian!';
  1221. })();
  1222. function abortFnPtrError(ptr, sig) {
  1223. abort("Invalid function pointer " + ptr + " called with signature '" + sig + "'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this). Build with ASSERTIONS=2 for more info.");
  1224. }
  1225. function callRuntimeCallbacks(callbacks) {
  1226. while(callbacks.length > 0) {
  1227. var callback = callbacks.shift();
  1228. if (typeof callback == 'function') {
  1229. callback(Module); // Pass the module as the first argument.
  1230. continue;
  1231. }
  1232. var func = callback.func;
  1233. if (typeof func === 'number') {
  1234. if (callback.arg === undefined) {
  1235. Module['dynCall_v'](func);
  1236. } else {
  1237. Module['dynCall_vi'](func, callback.arg);
  1238. }
  1239. } else {
  1240. func(callback.arg === undefined ? null : callback.arg);
  1241. }
  1242. }
  1243. }
  1244. var __ATPRERUN__ = []; // functions called before the runtime is initialized
  1245. var __ATINIT__ = []; // functions called during startup
  1246. var __ATMAIN__ = []; // functions called when main() is to be run
  1247. var __ATEXIT__ = []; // functions called during shutdown
  1248. var __ATPOSTRUN__ = []; // functions called after the main() is called
  1249. var runtimeInitialized = false;
  1250. var runtimeExited = false;
  1251. function preRun() {
  1252. if (Module['preRun']) {
  1253. if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  1254. while (Module['preRun'].length) {
  1255. addOnPreRun(Module['preRun'].shift());
  1256. }
  1257. }
  1258. callRuntimeCallbacks(__ATPRERUN__);
  1259. }
  1260. function initRuntime() {
  1261. checkStackCookie();
  1262. assert(!runtimeInitialized);
  1263. runtimeInitialized = true;
  1264. if (!Module["noFSInit"] && !FS.init.initialized) FS.init();
  1265. TTY.init();
  1266. callRuntimeCallbacks(__ATINIT__);
  1267. }
  1268. function preMain() {
  1269. checkStackCookie();
  1270. FS.ignorePermissions = false;
  1271. callRuntimeCallbacks(__ATMAIN__);
  1272. }
  1273. function exitRuntime() {
  1274. checkStackCookie();
  1275. runtimeExited = true;
  1276. }
  1277. function postRun() {
  1278. checkStackCookie();
  1279. if (Module['postRun']) {
  1280. if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
  1281. while (Module['postRun'].length) {
  1282. addOnPostRun(Module['postRun'].shift());
  1283. }
  1284. }
  1285. callRuntimeCallbacks(__ATPOSTRUN__);
  1286. }
  1287. function addOnPreRun(cb) {
  1288. __ATPRERUN__.unshift(cb);
  1289. }
  1290. function addOnInit(cb) {
  1291. __ATINIT__.unshift(cb);
  1292. }
  1293. function addOnPreMain(cb) {
  1294. __ATMAIN__.unshift(cb);
  1295. }
  1296. function addOnExit(cb) {
  1297. }
  1298. function addOnPostRun(cb) {
  1299. __ATPOSTRUN__.unshift(cb);
  1300. }
  1301. /** @param {number|boolean=} ignore */
  1302. function unSign(value, bits, ignore) {
  1303. if (value >= 0) {
  1304. return value;
  1305. }
  1306. return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
  1307. : Math.pow(2, bits) + value;
  1308. }
  1309. /** @param {number|boolean=} ignore */
  1310. function reSign(value, bits, ignore) {
  1311. if (value <= 0) {
  1312. return value;
  1313. }
  1314. var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
  1315. : Math.pow(2, bits-1);
  1316. if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
  1317. // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
  1318. // TODO: In i64 mode 1, resign the two parts separately and safely
  1319. value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
  1320. }
  1321. return value;
  1322. }
  1323. /**
  1324. * @license
  1325. * Copyright 2019 The Emscripten Authors
  1326. * SPDX-License-Identifier: MIT
  1327. */
  1328. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
  1329. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
  1330. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  1331. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
  1332. assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
  1333. assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
  1334. assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
  1335. assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
  1336. var Math_abs = Math.abs;
  1337. var Math_cos = Math.cos;
  1338. var Math_sin = Math.sin;
  1339. var Math_tan = Math.tan;
  1340. var Math_acos = Math.acos;
  1341. var Math_asin = Math.asin;
  1342. var Math_atan = Math.atan;
  1343. var Math_atan2 = Math.atan2;
  1344. var Math_exp = Math.exp;
  1345. var Math_log = Math.log;
  1346. var Math_sqrt = Math.sqrt;
  1347. var Math_ceil = Math.ceil;
  1348. var Math_floor = Math.floor;
  1349. var Math_pow = Math.pow;
  1350. var Math_imul = Math.imul;
  1351. var Math_fround = Math.fround;
  1352. var Math_round = Math.round;
  1353. var Math_min = Math.min;
  1354. var Math_max = Math.max;
  1355. var Math_clz32 = Math.clz32;
  1356. var Math_trunc = Math.trunc;
  1357. // A counter of dependencies for calling run(). If we need to
  1358. // do asynchronous work before running, increment this and
  1359. // decrement it. Incrementing must happen in a place like
  1360. // Module.preRun (used by emcc to add file preloading).
  1361. // Note that you can add dependencies in preRun, even though
  1362. // it happens right before run - run will be postponed until
  1363. // the dependencies are met.
  1364. var runDependencies = 0;
  1365. var runDependencyWatcher = null;
  1366. var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
  1367. var runDependencyTracking = {};
  1368. function getUniqueRunDependency(id) {
  1369. var orig = id;
  1370. while (1) {
  1371. if (!runDependencyTracking[id]) return id;
  1372. id = orig + Math.random();
  1373. }
  1374. }
  1375. function addRunDependency(id) {
  1376. runDependencies++;
  1377. if (Module['monitorRunDependencies']) {
  1378. Module['monitorRunDependencies'](runDependencies);
  1379. }
  1380. if (id) {
  1381. assert(!runDependencyTracking[id]);
  1382. runDependencyTracking[id] = 1;
  1383. if (runDependencyWatcher === null && typeof setInterval !== 'undefined') {
  1384. // Check for missing dependencies every few seconds
  1385. runDependencyWatcher = setInterval(function() {
  1386. if (ABORT) {
  1387. clearInterval(runDependencyWatcher);
  1388. runDependencyWatcher = null;
  1389. return;
  1390. }
  1391. var shown = false;
  1392. for (var dep in runDependencyTracking) {
  1393. if (!shown) {
  1394. shown = true;
  1395. err('still waiting on run dependencies:');
  1396. }
  1397. err('dependency: ' + dep);
  1398. }
  1399. if (shown) {
  1400. err('(end of list)');
  1401. }
  1402. }, 10000);
  1403. }
  1404. } else {
  1405. err('warning: run dependency added without ID');
  1406. }
  1407. }
  1408. function removeRunDependency(id) {
  1409. runDependencies--;
  1410. if (Module['monitorRunDependencies']) {
  1411. Module['monitorRunDependencies'](runDependencies);
  1412. }
  1413. if (id) {
  1414. assert(runDependencyTracking[id]);
  1415. delete runDependencyTracking[id];
  1416. } else {
  1417. err('warning: run dependency removed without ID');
  1418. }
  1419. if (runDependencies == 0) {
  1420. if (runDependencyWatcher !== null) {
  1421. clearInterval(runDependencyWatcher);
  1422. runDependencyWatcher = null;
  1423. }
  1424. if (dependenciesFulfilled) {
  1425. var callback = dependenciesFulfilled;
  1426. dependenciesFulfilled = null;
  1427. callback(); // can add another dependenciesFulfilled
  1428. }
  1429. }
  1430. }
  1431. Module["preloadedImages"] = {}; // maps url to image data
  1432. Module["preloadedAudios"] = {}; // maps url to audio data
  1433. /** @param {string|number=} what */
  1434. function abort(what) {
  1435. if (Module['onAbort']) {
  1436. Module['onAbort'](what);
  1437. }
  1438. what += '';
  1439. out(what);
  1440. err(what);
  1441. ABORT = true;
  1442. EXITSTATUS = 1;
  1443. var output = 'abort(' + what + ') at ' + stackTrace();
  1444. what = output;
  1445. // Throw a wasm runtime error, because a JS error might be seen as a foreign
  1446. // exception, which means we'd run destructors on it. We need the error to
  1447. // simply make the program stop.
  1448. throw new WebAssembly.RuntimeError(what);
  1449. }
  1450. var memoryInitializer = null;
  1451. /**
  1452. * @license
  1453. * Copyright 2015 The Emscripten Authors
  1454. * SPDX-License-Identifier: MIT
  1455. */
  1456. /**
  1457. * @license
  1458. * Copyright 2017 The Emscripten Authors
  1459. * SPDX-License-Identifier: MIT
  1460. */
  1461. function hasPrefix(str, prefix) {
  1462. return String.prototype.startsWith ?
  1463. str.startsWith(prefix) :
  1464. str.indexOf(prefix) === 0;
  1465. }
  1466. // Prefix of data URIs emitted by SINGLE_FILE and related options.
  1467. var dataURIPrefix = 'data:application/octet-stream;base64,';
  1468. // Indicates whether filename is a base64 data URI.
  1469. function isDataURI(filename) {
  1470. return hasPrefix(filename, dataURIPrefix);
  1471. }
  1472. var fileURIPrefix = "file://";
  1473. // Indicates whether filename is delivered via file protocol (as opposed to http/https)
  1474. function isFileURI(filename) {
  1475. return hasPrefix(filename, fileURIPrefix);
  1476. }
  1477. var wasmBinaryFile = 'libSystemTransform.wasm';
  1478. if (!isDataURI(wasmBinaryFile)) {
  1479. wasmBinaryFile = locateFile(wasmBinaryFile);
  1480. }
  1481. function getBinary() {
  1482. try {
  1483. if (wasmBinary) {
  1484. return new Uint8Array(wasmBinary);
  1485. }
  1486. if (readBinary) {
  1487. return readBinary(wasmBinaryFile);
  1488. } else {
  1489. throw "both async and sync fetching of the wasm failed";
  1490. }
  1491. }
  1492. catch (err) {
  1493. abort(err);
  1494. }
  1495. }
  1496. function getBinaryPromise() {
  1497. // If we don't have the binary yet, and have the Fetch api, use that;
  1498. // in some environments, like Electron's render process, Fetch api may be present, but have a different context than expected, let's only use it on the Web
  1499. if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === 'function'
  1500. // Let's not use fetch to get objects over file:// as it's most likely Cordova which doesn't support fetch for file://
  1501. && !isFileURI(wasmBinaryFile)
  1502. ) {
  1503. return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
  1504. if (!response['ok']) {
  1505. throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
  1506. }
  1507. return response['arrayBuffer']();
  1508. }).catch(function () {
  1509. return getBinary();
  1510. });
  1511. }
  1512. // Otherwise, getBinary should be able to get it synchronously
  1513. return new Promise(function(resolve, reject) {
  1514. resolve(getBinary());
  1515. });
  1516. }
  1517. // Create the wasm instance.
  1518. // Receives the wasm imports, returns the exports.
  1519. function createWasm() {
  1520. // prepare imports
  1521. var info = {
  1522. 'env': asmLibraryArg,
  1523. 'wasi_snapshot_preview1': asmLibraryArg
  1524. };
  1525. // Load the wasm module and create an instance of using native support in the JS engine.
  1526. // handle a generated wasm instance, receiving its exports and
  1527. // performing other necessary setup
  1528. /** @param {WebAssembly.Module=} module*/
  1529. function receiveInstance(instance, module) {
  1530. var exports = instance.exports;
  1531. Module['asm'] = exports;
  1532. removeRunDependency('wasm-instantiate');
  1533. }
  1534. // we can't run yet (except in a pthread, where we have a custom sync instantiator)
  1535. addRunDependency('wasm-instantiate');
  1536. // Async compilation can be confusing when an error on the page overwrites Module
  1537. // (for example, if the order of elements is wrong, and the one defining Module is
  1538. // later), so we save Module and check it later.
  1539. var trueModule = Module;
  1540. function receiveInstantiatedSource(output) {
  1541. // 'output' is a WebAssemblyInstantiatedSource object which has both the module and instance.
  1542. // receiveInstance() will swap in the exports (to Module.asm) so they can be called
  1543. assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
  1544. trueModule = null;
  1545. // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
  1546. // When the regression is fixed, can restore the above USE_PTHREADS-enabled path.
  1547. receiveInstance(output['instance']);
  1548. }
  1549. function instantiateArrayBuffer(receiver) {
  1550. return getBinaryPromise().then(function(binary) {
  1551. return WebAssembly.instantiate(binary, info);
  1552. }).then(receiver, function(reason) {
  1553. err('failed to asynchronously prepare wasm: ' + reason);
  1554. abort(reason);
  1555. });
  1556. }
  1557. // Prefer streaming instantiation if available.
  1558. function instantiateAsync() {
  1559. if (!wasmBinary &&
  1560. typeof WebAssembly.instantiateStreaming === 'function' &&
  1561. !isDataURI(wasmBinaryFile) &&
  1562. // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
  1563. !isFileURI(wasmBinaryFile) &&
  1564. typeof fetch === 'function') {
  1565. fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function (response) {
  1566. var result = WebAssembly.instantiateStreaming(response, info);
  1567. return result.then(receiveInstantiatedSource, function(reason) {
  1568. // We expect the most common failure cause to be a bad MIME type for the binary,
  1569. // in which case falling back to ArrayBuffer instantiation should work.
  1570. err('wasm streaming compile failed: ' + reason);
  1571. err('falling back to ArrayBuffer instantiation');
  1572. instantiateArrayBuffer(receiveInstantiatedSource);
  1573. });
  1574. });
  1575. } else {
  1576. return instantiateArrayBuffer(receiveInstantiatedSource);
  1577. }
  1578. }
  1579. // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
  1580. // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
  1581. // to any other async startup actions they are performing.
  1582. if (Module['instantiateWasm']) {
  1583. try {
  1584. var exports = Module['instantiateWasm'](info, receiveInstance);
  1585. return exports;
  1586. } catch(e) {
  1587. err('Module.instantiateWasm callback failed with error: ' + e);
  1588. return false;
  1589. }
  1590. }
  1591. instantiateAsync();
  1592. return {}; // no exports yet; we'll fill them in later
  1593. }
  1594. // Globals used by JS i64 conversions
  1595. var tempDouble;
  1596. var tempI64;
  1597. // === Body ===
  1598. var ASM_CONSTS = {
  1599. 1034: function($0, $1, $2, $3) {STCallBack($0, $1, $2, $3);}
  1600. };
  1601. function _emscripten_asm_const_iii(code, sigPtr, argbuf) {
  1602. var args = readAsmConstArgs(sigPtr, argbuf);
  1603. return ASM_CONSTS[code].apply(null, args);
  1604. }
  1605. // STATICTOP = STATIC_BASE + 294368;
  1606. /* global initializers */ __ATINIT__.push({ func: function() { ___wasm_call_ctors() } });
  1607. /* no memory initializer */
  1608. // {{PRE_LIBRARY}}
  1609. function demangle(func) {
  1610. warnOnce('warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling');
  1611. return func;
  1612. }
  1613. function demangleAll(text) {
  1614. var regex =
  1615. /\b_Z[\w\d_]+/g;
  1616. return text.replace(regex,
  1617. function(x) {
  1618. var y = demangle(x);
  1619. return x === y ? x : (y + ' [' + x + ']');
  1620. });
  1621. }
  1622. function jsStackTrace() {
  1623. var err = new Error();
  1624. if (!err.stack) {
  1625. // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
  1626. // so try that as a special-case.
  1627. try {
  1628. throw new Error();
  1629. } catch(e) {
  1630. err = e;
  1631. }
  1632. if (!err.stack) {
  1633. return '(no stack trace available)';
  1634. }
  1635. }
  1636. return err.stack.toString();
  1637. }
  1638. function stackTrace() {
  1639. var js = jsStackTrace();
  1640. if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
  1641. return demangleAll(js);
  1642. }
  1643. function ___assert_fail(condition, filename, line, func) {
  1644. abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
  1645. }
  1646. function ___cxa_allocate_exception(size) {
  1647. return _malloc(size);
  1648. }
  1649. function _atexit(func, arg) {
  1650. warnOnce('atexit() called, but EXIT_RUNTIME is not set, so atexits() will not be called. set EXIT_RUNTIME to 1 (see the FAQ)');
  1651. __ATEXIT__.unshift({ func: func, arg: arg });
  1652. }function ___cxa_atexit(a0,a1
  1653. ) {
  1654. return _atexit(a0,a1);
  1655. }
  1656. function ___cxa_find_matching_catch_2() {
  1657. var thrown = ___exception_last;
  1658. if (!thrown) {
  1659. // just pass through the null ptr
  1660. return ((setTempRet0(0),0)|0);
  1661. }
  1662. var info = ___exception_infos[thrown];
  1663. var throwntype = info.type;
  1664. if (!throwntype) {
  1665. // just pass through the thrown ptr
  1666. return ((setTempRet0(0),thrown)|0);
  1667. }
  1668. var typeArray = Array.prototype.slice.call(arguments);
  1669. var pointer = ___cxa_is_pointer_type(throwntype);
  1670. // can_catch receives a **, add indirection
  1671. var buffer = 295376;
  1672. HEAP32[((buffer)>>2)]=thrown;
  1673. thrown = buffer;
  1674. // The different catch blocks are denoted by different types.
  1675. // Due to inheritance, those types may not precisely match the
  1676. // type of the thrown object. Find one which matches, and
  1677. // return the type of the catch block which should be called.
  1678. for (var i = 0; i < typeArray.length; i++) {
  1679. if (typeArray[i] && ___cxa_can_catch(typeArray[i], throwntype, thrown)) {
  1680. thrown = HEAP32[((thrown)>>2)]; // undo indirection
  1681. info.adjusted.push(thrown);
  1682. return ((setTempRet0(typeArray[i]),thrown)|0);
  1683. }
  1684. }
  1685. // Shouldn't happen unless we have bogus data in typeArray
  1686. // or encounter a type for which emscripten doesn't have suitable
  1687. // typeinfo defined. Best-efforts match just in case.
  1688. thrown = HEAP32[((thrown)>>2)]; // undo indirection
  1689. return ((setTempRet0(throwntype),thrown)|0);
  1690. }
  1691. var ___exception_infos={};
  1692. var ___exception_last=0;
  1693. function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
  1694. return __ZSt18uncaught_exceptionv.uncaught_exceptions > 0;
  1695. }function ___cxa_throw(ptr, type, destructor) {
  1696. ___exception_infos[ptr] = {
  1697. ptr: ptr,
  1698. adjusted: [ptr],
  1699. type: type,
  1700. destructor: destructor,
  1701. refcount: 0,
  1702. caught: false,
  1703. rethrown: false
  1704. };
  1705. ___exception_last = ptr;
  1706. if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
  1707. __ZSt18uncaught_exceptionv.uncaught_exceptions = 1;
  1708. } else {
  1709. __ZSt18uncaught_exceptionv.uncaught_exceptions++;
  1710. }
  1711. throw ptr;
  1712. }
  1713. function ___handle_stack_overflow() {
  1714. abort('stack overflow')
  1715. }
  1716. function ___resumeException(ptr) {
  1717. if (!___exception_last) { ___exception_last = ptr; }
  1718. throw ptr;
  1719. }
  1720. function setErrNo(value) {
  1721. HEAP32[((___errno_location())>>2)]=value;
  1722. return value;
  1723. }
  1724. var PATH={splitPath:function(filename) {
  1725. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  1726. return splitPathRe.exec(filename).slice(1);
  1727. },normalizeArray:function(parts, allowAboveRoot) {
  1728. // if the path tries to go above the root, `up` ends up > 0
  1729. var up = 0;
  1730. for (var i = parts.length - 1; i >= 0; i--) {
  1731. var last = parts[i];
  1732. if (last === '.') {
  1733. parts.splice(i, 1);
  1734. } else if (last === '..') {
  1735. parts.splice(i, 1);
  1736. up++;
  1737. } else if (up) {
  1738. parts.splice(i, 1);
  1739. up--;
  1740. }
  1741. }
  1742. // if the path is allowed to go above the root, restore leading ..s
  1743. if (allowAboveRoot) {
  1744. for (; up; up--) {
  1745. parts.unshift('..');
  1746. }
  1747. }
  1748. return parts;
  1749. },normalize:function(path) {
  1750. var isAbsolute = path.charAt(0) === '/',
  1751. trailingSlash = path.substr(-1) === '/';
  1752. // Normalize the path
  1753. path = PATH.normalizeArray(path.split('/').filter(function(p) {
  1754. return !!p;
  1755. }), !isAbsolute).join('/');
  1756. if (!path && !isAbsolute) {
  1757. path = '.';
  1758. }
  1759. if (path && trailingSlash) {
  1760. path += '/';
  1761. }
  1762. return (isAbsolute ? '/' : '') + path;
  1763. },dirname:function(path) {
  1764. var result = PATH.splitPath(path),
  1765. root = result[0],
  1766. dir = result[1];
  1767. if (!root && !dir) {
  1768. // No dirname whatsoever
  1769. return '.';
  1770. }
  1771. if (dir) {
  1772. // It has a dirname, strip trailing slash
  1773. dir = dir.substr(0, dir.length - 1);
  1774. }
  1775. return root + dir;
  1776. },basename:function(path) {
  1777. // EMSCRIPTEN return '/'' for '/', not an empty string
  1778. if (path === '/') return '/';
  1779. var lastSlash = path.lastIndexOf('/');
  1780. if (lastSlash === -1) return path;
  1781. return path.substr(lastSlash+1);
  1782. },extname:function(path) {
  1783. return PATH.splitPath(path)[3];
  1784. },join:function() {
  1785. var paths = Array.prototype.slice.call(arguments, 0);
  1786. return PATH.normalize(paths.join('/'));
  1787. },join2:function(l, r) {
  1788. return PATH.normalize(l + '/' + r);
  1789. }};
  1790. var PATH_FS={resolve:function() {
  1791. var resolvedPath = '',
  1792. resolvedAbsolute = false;
  1793. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  1794. var path = (i >= 0) ? arguments[i] : FS.cwd();
  1795. // Skip empty and invalid entries
  1796. if (typeof path !== 'string') {
  1797. throw new TypeError('Arguments to path.resolve must be strings');
  1798. } else if (!path) {
  1799. return ''; // an invalid portion invalidates the whole thing
  1800. }
  1801. resolvedPath = path + '/' + resolvedPath;
  1802. resolvedAbsolute = path.charAt(0) === '/';
  1803. }
  1804. // At this point the path should be resolved to a full absolute path, but
  1805. // handle relative paths to be safe (might happen when process.cwd() fails)
  1806. resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
  1807. return !!p;
  1808. }), !resolvedAbsolute).join('/');
  1809. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  1810. },relative:function(from, to) {
  1811. from = PATH_FS.resolve(from).substr(1);
  1812. to = PATH_FS.resolve(to).substr(1);
  1813. function trim(arr) {
  1814. var start = 0;
  1815. for (; start < arr.length; start++) {
  1816. if (arr[start] !== '') break;
  1817. }
  1818. var end = arr.length - 1;
  1819. for (; end >= 0; end--) {
  1820. if (arr[end] !== '') break;
  1821. }
  1822. if (start > end) return [];
  1823. return arr.slice(start, end - start + 1);
  1824. }
  1825. var fromParts = trim(from.split('/'));
  1826. var toParts = trim(to.split('/'));
  1827. var length = Math.min(fromParts.length, toParts.length);
  1828. var samePartsLength = length;
  1829. for (var i = 0; i < length; i++) {
  1830. if (fromParts[i] !== toParts[i]) {
  1831. samePartsLength = i;
  1832. break;
  1833. }
  1834. }
  1835. var outputParts = [];
  1836. for (var i = samePartsLength; i < fromParts.length; i++) {
  1837. outputParts.push('..');
  1838. }
  1839. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  1840. return outputParts.join('/');
  1841. }};
  1842. var TTY={ttys:[],init:function () {
  1843. // https://github.com/emscripten-core/emscripten/pull/1555
  1844. // if (ENVIRONMENT_IS_NODE) {
  1845. // // currently, FS.init does not distinguish if process.stdin is a file or TTY
  1846. // // device, it always assumes it's a TTY device. because of this, we're forcing
  1847. // // process.stdin to UTF8 encoding to at least make stdin reading compatible
  1848. // // with text files until FS.init can be refactored.
  1849. // process['stdin']['setEncoding']('utf8');
  1850. // }
  1851. },shutdown:function() {
  1852. // https://github.com/emscripten-core/emscripten/pull/1555
  1853. // if (ENVIRONMENT_IS_NODE) {
  1854. // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
  1855. // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
  1856. // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
  1857. // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
  1858. // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
  1859. // process['stdin']['pause']();
  1860. // }
  1861. },register:function(dev, ops) {
  1862. TTY.ttys[dev] = { input: [], output: [], ops: ops };
  1863. FS.registerDevice(dev, TTY.stream_ops);
  1864. },stream_ops:{open:function(stream) {
  1865. var tty = TTY.ttys[stream.node.rdev];
  1866. if (!tty) {
  1867. throw new FS.ErrnoError(43);
  1868. }
  1869. stream.tty = tty;
  1870. stream.seekable = false;
  1871. },close:function(stream) {
  1872. // flush any pending line data
  1873. stream.tty.ops.flush(stream.tty);
  1874. },flush:function(stream) {
  1875. stream.tty.ops.flush(stream.tty);
  1876. },read:function(stream, buffer, offset, length, pos /* ignored */) {
  1877. if (!stream.tty || !stream.tty.ops.get_char) {
  1878. throw new FS.ErrnoError(60);
  1879. }
  1880. var bytesRead = 0;
  1881. for (var i = 0; i < length; i++) {
  1882. var result;
  1883. try {
  1884. result = stream.tty.ops.get_char(stream.tty);
  1885. } catch (e) {
  1886. throw new FS.ErrnoError(29);
  1887. }
  1888. if (result === undefined && bytesRead === 0) {
  1889. throw new FS.ErrnoError(6);
  1890. }
  1891. if (result === null || result === undefined) break;
  1892. bytesRead++;
  1893. buffer[offset+i] = result;
  1894. }
  1895. if (bytesRead) {
  1896. stream.node.timestamp = Date.now();
  1897. }
  1898. return bytesRead;
  1899. },write:function(stream, buffer, offset, length, pos) {
  1900. if (!stream.tty || !stream.tty.ops.put_char) {
  1901. throw new FS.ErrnoError(60);
  1902. }
  1903. try {
  1904. for (var i = 0; i < length; i++) {
  1905. stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
  1906. }
  1907. } catch (e) {
  1908. throw new FS.ErrnoError(29);
  1909. }
  1910. if (length) {
  1911. stream.node.timestamp = Date.now();
  1912. }
  1913. return i;
  1914. }},default_tty_ops:{get_char:function(tty) {
  1915. if (!tty.input.length) {
  1916. var result = null;
  1917. if (ENVIRONMENT_IS_NODE) {
  1918. // we will read data by chunks of BUFSIZE
  1919. var BUFSIZE = 256;
  1920. var buf = Buffer.alloc ? Buffer.alloc(BUFSIZE) : new Buffer(BUFSIZE);
  1921. var bytesRead = 0;
  1922. try {
  1923. bytesRead = nodeFS.readSync(process.stdin.fd, buf, 0, BUFSIZE, null);
  1924. } catch(e) {
  1925. // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes,
  1926. // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0.
  1927. if (e.toString().indexOf('EOF') != -1) bytesRead = 0;
  1928. else throw e;
  1929. }
  1930. if (bytesRead > 0) {
  1931. result = buf.slice(0, bytesRead).toString('utf-8');
  1932. } else {
  1933. result = null;
  1934. }
  1935. } else
  1936. if (typeof window != 'undefined' &&
  1937. typeof window.prompt == 'function') {
  1938. // Browser.
  1939. result = window.prompt('Input: '); // returns null on cancel
  1940. if (result !== null) {
  1941. result += '\n';
  1942. }
  1943. } else if (typeof readline == 'function') {
  1944. // Command line.
  1945. result = readline();
  1946. if (result !== null) {
  1947. result += '\n';
  1948. }
  1949. }
  1950. if (!result) {
  1951. return null;
  1952. }
  1953. tty.input = intArrayFromString(result, true);
  1954. }
  1955. return tty.input.shift();
  1956. },put_char:function(tty, val) {
  1957. if (val === null || val === 10) {
  1958. out(UTF8ArrayToString(tty.output, 0));
  1959. tty.output = [];
  1960. } else {
  1961. if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
  1962. }
  1963. },flush:function(tty) {
  1964. if (tty.output && tty.output.length > 0) {
  1965. out(UTF8ArrayToString(tty.output, 0));
  1966. tty.output = [];
  1967. }
  1968. }},default_tty1_ops:{put_char:function(tty, val) {
  1969. if (val === null || val === 10) {
  1970. err(UTF8ArrayToString(tty.output, 0));
  1971. tty.output = [];
  1972. } else {
  1973. if (val != 0) tty.output.push(val);
  1974. }
  1975. },flush:function(tty) {
  1976. if (tty.output && tty.output.length > 0) {
  1977. err(UTF8ArrayToString(tty.output, 0));
  1978. tty.output = [];
  1979. }
  1980. }}};
  1981. var MEMFS={ops_table:null,mount:function(mount) {
  1982. return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
  1983. },createNode:function(parent, name, mode, dev) {
  1984. if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
  1985. // no supported
  1986. throw new FS.ErrnoError(63);
  1987. }
  1988. if (!MEMFS.ops_table) {
  1989. MEMFS.ops_table = {
  1990. dir: {
  1991. node: {
  1992. getattr: MEMFS.node_ops.getattr,
  1993. setattr: MEMFS.node_ops.setattr,
  1994. lookup: MEMFS.node_ops.lookup,
  1995. mknod: MEMFS.node_ops.mknod,
  1996. rename: MEMFS.node_ops.rename,
  1997. unlink: MEMFS.node_ops.unlink,
  1998. rmdir: MEMFS.node_ops.rmdir,
  1999. readdir: MEMFS.node_ops.readdir,
  2000. symlink: MEMFS.node_ops.symlink
  2001. },
  2002. stream: {
  2003. llseek: MEMFS.stream_ops.llseek
  2004. }
  2005. },
  2006. file: {
  2007. node: {
  2008. getattr: MEMFS.node_ops.getattr,
  2009. setattr: MEMFS.node_ops.setattr
  2010. },
  2011. stream: {
  2012. llseek: MEMFS.stream_ops.llseek,
  2013. read: MEMFS.stream_ops.read,
  2014. write: MEMFS.stream_ops.write,
  2015. allocate: MEMFS.stream_ops.allocate,
  2016. mmap: MEMFS.stream_ops.mmap,
  2017. msync: MEMFS.stream_ops.msync
  2018. }
  2019. },
  2020. link: {
  2021. node: {
  2022. getattr: MEMFS.node_ops.getattr,
  2023. setattr: MEMFS.node_ops.setattr,
  2024. readlink: MEMFS.node_ops.readlink
  2025. },
  2026. stream: {}
  2027. },
  2028. chrdev: {
  2029. node: {
  2030. getattr: MEMFS.node_ops.getattr,
  2031. setattr: MEMFS.node_ops.setattr
  2032. },
  2033. stream: FS.chrdev_stream_ops
  2034. }
  2035. };
  2036. }
  2037. var node = FS.createNode(parent, name, mode, dev);
  2038. if (FS.isDir(node.mode)) {
  2039. node.node_ops = MEMFS.ops_table.dir.node;
  2040. node.stream_ops = MEMFS.ops_table.dir.stream;
  2041. node.contents = {};
  2042. } else if (FS.isFile(node.mode)) {
  2043. node.node_ops = MEMFS.ops_table.file.node;
  2044. node.stream_ops = MEMFS.ops_table.file.stream;
  2045. node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity.
  2046. // When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred
  2047. // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size
  2048. // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme.
  2049. node.contents = null;
  2050. } else if (FS.isLink(node.mode)) {
  2051. node.node_ops = MEMFS.ops_table.link.node;
  2052. node.stream_ops = MEMFS.ops_table.link.stream;
  2053. } else if (FS.isChrdev(node.mode)) {
  2054. node.node_ops = MEMFS.ops_table.chrdev.node;
  2055. node.stream_ops = MEMFS.ops_table.chrdev.stream;
  2056. }
  2057. node.timestamp = Date.now();
  2058. // add the new node to the parent
  2059. if (parent) {
  2060. parent.contents[name] = node;
  2061. }
  2062. return node;
  2063. },getFileDataAsRegularArray:function(node) {
  2064. if (node.contents && node.contents.subarray) {
  2065. var arr = [];
  2066. for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]);
  2067. return arr; // Returns a copy of the original data.
  2068. }
  2069. return node.contents; // No-op, the file contents are already in a JS array. Return as-is.
  2070. },getFileDataAsTypedArray:function(node) {
  2071. if (!node.contents) return new Uint8Array(0);
  2072. if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes.
  2073. return new Uint8Array(node.contents);
  2074. },expandFileStorage:function(node, newCapacity) {
  2075. var prevCapacity = node.contents ? node.contents.length : 0;
  2076. if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough.
  2077. // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity.
  2078. // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to
  2079. // avoid overshooting the allocation cap by a very large margin.
  2080. var CAPACITY_DOUBLING_MAX = 1024 * 1024;
  2081. newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0);
  2082. if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding.
  2083. var oldContents = node.contents;
  2084. node.contents = new Uint8Array(newCapacity); // Allocate new storage.
  2085. if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage.
  2086. return;
  2087. },resizeFileStorage:function(node, newSize) {
  2088. if (node.usedBytes == newSize) return;
  2089. if (newSize == 0) {
  2090. node.contents = null; // Fully decommit when requesting a resize to zero.
  2091. node.usedBytes = 0;
  2092. return;
  2093. }
  2094. if (!node.contents || node.contents.subarray) { // Resize a typed array if that is being used as the backing store.
  2095. var oldContents = node.contents;
  2096. node.contents = new Uint8Array(newSize); // Allocate new storage.
  2097. if (oldContents) {
  2098. node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
  2099. }
  2100. node.usedBytes = newSize;
  2101. return;
  2102. }
  2103. // Backing with a JS array.
  2104. if (!node.contents) node.contents = [];
  2105. if (node.contents.length > newSize) node.contents.length = newSize;
  2106. else while (node.contents.length < newSize) node.contents.push(0);
  2107. node.usedBytes = newSize;
  2108. },node_ops:{getattr:function(node) {
  2109. var attr = {};
  2110. // device numbers reuse inode numbers.
  2111. attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
  2112. attr.ino = node.id;
  2113. attr.mode = node.mode;
  2114. attr.nlink = 1;
  2115. attr.uid = 0;
  2116. attr.gid = 0;
  2117. attr.rdev = node.rdev;
  2118. if (FS.isDir(node.mode)) {
  2119. attr.size = 4096;
  2120. } else if (FS.isFile(node.mode)) {
  2121. attr.size = node.usedBytes;
  2122. } else if (FS.isLink(node.mode)) {
  2123. attr.size = node.link.length;
  2124. } else {
  2125. attr.size = 0;
  2126. }
  2127. attr.atime = new Date(node.timestamp);
  2128. attr.mtime = new Date(node.timestamp);
  2129. attr.ctime = new Date(node.timestamp);
  2130. // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
  2131. // but this is not required by the standard.
  2132. attr.blksize = 4096;
  2133. attr.blocks = Math.ceil(attr.size / attr.blksize);
  2134. return attr;
  2135. },setattr:function(node, attr) {
  2136. if (attr.mode !== undefined) {
  2137. node.mode = attr.mode;
  2138. }
  2139. if (attr.timestamp !== undefined) {
  2140. node.timestamp = attr.timestamp;
  2141. }
  2142. if (attr.size !== undefined) {
  2143. MEMFS.resizeFileStorage(node, attr.size);
  2144. }
  2145. },lookup:function(parent, name) {
  2146. throw FS.genericErrors[44];
  2147. },mknod:function(parent, name, mode, dev) {
  2148. return MEMFS.createNode(parent, name, mode, dev);
  2149. },rename:function(old_node, new_dir, new_name) {
  2150. // if we're overwriting a directory at new_name, make sure it's empty.
  2151. if (FS.isDir(old_node.mode)) {
  2152. var new_node;
  2153. try {
  2154. new_node = FS.lookupNode(new_dir, new_name);
  2155. } catch (e) {
  2156. }
  2157. if (new_node) {
  2158. for (var i in new_node.contents) {
  2159. throw new FS.ErrnoError(55);
  2160. }
  2161. }
  2162. }
  2163. // do the internal rewiring
  2164. delete old_node.parent.contents[old_node.name];
  2165. old_node.name = new_name;
  2166. new_dir.contents[new_name] = old_node;
  2167. old_node.parent = new_dir;
  2168. },unlink:function(parent, name) {
  2169. delete parent.contents[name];
  2170. },rmdir:function(parent, name) {
  2171. var node = FS.lookupNode(parent, name);
  2172. for (var i in node.contents) {
  2173. throw new FS.ErrnoError(55);
  2174. }
  2175. delete parent.contents[name];
  2176. },readdir:function(node) {
  2177. var entries = ['.', '..'];
  2178. for (var key in node.contents) {
  2179. if (!node.contents.hasOwnProperty(key)) {
  2180. continue;
  2181. }
  2182. entries.push(key);
  2183. }
  2184. return entries;
  2185. },symlink:function(parent, newname, oldpath) {
  2186. var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
  2187. node.link = oldpath;
  2188. return node;
  2189. },readlink:function(node) {
  2190. if (!FS.isLink(node.mode)) {
  2191. throw new FS.ErrnoError(28);
  2192. }
  2193. return node.link;
  2194. }},stream_ops:{read:function(stream, buffer, offset, length, position) {
  2195. var contents = stream.node.contents;
  2196. if (position >= stream.node.usedBytes) return 0;
  2197. var size = Math.min(stream.node.usedBytes - position, length);
  2198. assert(size >= 0);
  2199. if (size > 8 && contents.subarray) { // non-trivial, and typed array
  2200. buffer.set(contents.subarray(position, position + size), offset);
  2201. } else {
  2202. for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
  2203. }
  2204. return size;
  2205. },write:function(stream, buffer, offset, length, position, canOwn) {
  2206. // The data buffer should be a typed array view
  2207. assert(!(buffer instanceof ArrayBuffer));
  2208. if (!length) return 0;
  2209. var node = stream.node;
  2210. node.timestamp = Date.now();
  2211. if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array?
  2212. if (canOwn) {
  2213. assert(position === 0, 'canOwn must imply no weird position inside the file');
  2214. node.contents = buffer.subarray(offset, offset + length);
  2215. node.usedBytes = length;
  2216. return length;
  2217. } else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
  2218. node.contents = buffer.slice(offset, offset + length);
  2219. node.usedBytes = length;
  2220. return length;
  2221. } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file?
  2222. node.contents.set(buffer.subarray(offset, offset + length), position);
  2223. return length;
  2224. }
  2225. }
  2226. // Appending to an existing file and we need to reallocate, or source data did not come as a typed array.
  2227. MEMFS.expandFileStorage(node, position+length);
  2228. if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position); // Use typed array write if available.
  2229. else {
  2230. for (var i = 0; i < length; i++) {
  2231. node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not.
  2232. }
  2233. }
  2234. node.usedBytes = Math.max(node.usedBytes, position + length);
  2235. return length;
  2236. },llseek:function(stream, offset, whence) {
  2237. var position = offset;
  2238. if (whence === 1) {
  2239. position += stream.position;
  2240. } else if (whence === 2) {
  2241. if (FS.isFile(stream.node.mode)) {
  2242. position += stream.node.usedBytes;
  2243. }
  2244. }
  2245. if (position < 0) {
  2246. throw new FS.ErrnoError(28);
  2247. }
  2248. return position;
  2249. },allocate:function(stream, offset, length) {
  2250. MEMFS.expandFileStorage(stream.node, offset + length);
  2251. stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
  2252. },mmap:function(stream, buffer, offset, length, position, prot, flags) {
  2253. // The data buffer should be a typed array view
  2254. assert(!(buffer instanceof ArrayBuffer));
  2255. if (!FS.isFile(stream.node.mode)) {
  2256. throw new FS.ErrnoError(43);
  2257. }
  2258. var ptr;
  2259. var allocated;
  2260. var contents = stream.node.contents;
  2261. // Only make a new copy when MAP_PRIVATE is specified.
  2262. if ( !(flags & 2) &&
  2263. contents.buffer === buffer.buffer ) {
  2264. // We can't emulate MAP_SHARED when the file is not backed by the buffer
  2265. // we're mapping to (e.g. the HEAP buffer).
  2266. allocated = false;
  2267. ptr = contents.byteOffset;
  2268. } else {
  2269. // Try to avoid unnecessary slices.
  2270. if (position > 0 || position + length < contents.length) {
  2271. if (contents.subarray) {
  2272. contents = contents.subarray(position, position + length);
  2273. } else {
  2274. contents = Array.prototype.slice.call(contents, position, position + length);
  2275. }
  2276. }
  2277. allocated = true;
  2278. // malloc() can lead to growing the heap. If targeting the heap, we need to
  2279. // re-acquire the heap buffer object in case growth had occurred.
  2280. var fromHeap = (buffer.buffer == HEAP8.buffer);
  2281. ptr = _malloc(length);
  2282. if (!ptr) {
  2283. throw new FS.ErrnoError(48);
  2284. }
  2285. (fromHeap ? HEAP8 : buffer).set(contents, ptr);
  2286. }
  2287. return { ptr: ptr, allocated: allocated };
  2288. },msync:function(stream, buffer, offset, length, mmapFlags) {
  2289. if (!FS.isFile(stream.node.mode)) {
  2290. throw new FS.ErrnoError(43);
  2291. }
  2292. if (mmapFlags & 2) {
  2293. // MAP_PRIVATE calls need not to be synced back to underlying fs
  2294. return 0;
  2295. }
  2296. var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
  2297. // should we check if bytesWritten and length are the same?
  2298. return 0;
  2299. }}};
  2300. var ERRNO_MESSAGES={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"};
  2301. var ERRNO_CODES={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e) {
  2302. if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
  2303. return setErrNo(e.errno);
  2304. },lookupPath:function(path, opts) {
  2305. path = PATH_FS.resolve(FS.cwd(), path);
  2306. opts = opts || {};
  2307. if (!path) return { path: '', node: null };
  2308. var defaults = {
  2309. follow_mount: true,
  2310. recurse_count: 0
  2311. };
  2312. for (var key in defaults) {
  2313. if (opts[key] === undefined) {
  2314. opts[key] = defaults[key];
  2315. }
  2316. }
  2317. if (opts.recurse_count > 8) { // max recursive lookup of 8
  2318. throw new FS.ErrnoError(32);
  2319. }
  2320. // split the path
  2321. var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
  2322. return !!p;
  2323. }), false);
  2324. // start at the root
  2325. var current = FS.root;
  2326. var current_path = '/';
  2327. for (var i = 0; i < parts.length; i++) {
  2328. var islast = (i === parts.length-1);
  2329. if (islast && opts.parent) {
  2330. // stop resolving
  2331. break;
  2332. }
  2333. current = FS.lookupNode(current, parts[i]);
  2334. current_path = PATH.join2(current_path, parts[i]);
  2335. // jump to the mount's root node if this is a mountpoint
  2336. if (FS.isMountpoint(current)) {
  2337. if (!islast || (islast && opts.follow_mount)) {
  2338. current = current.mounted.root;
  2339. }
  2340. }
  2341. // by default, lookupPath will not follow a symlink if it is the final path component.
  2342. // setting opts.follow = true will override this behavior.
  2343. if (!islast || opts.follow) {
  2344. var count = 0;
  2345. while (FS.isLink(current.mode)) {
  2346. var link = FS.readlink(current_path);
  2347. current_path = PATH_FS.resolve(PATH.dirname(current_path), link);
  2348. var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
  2349. current = lookup.node;
  2350. if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
  2351. throw new FS.ErrnoError(32);
  2352. }
  2353. }
  2354. }
  2355. }
  2356. return { path: current_path, node: current };
  2357. },getPath:function(node) {
  2358. var path;
  2359. while (true) {
  2360. if (FS.isRoot(node)) {
  2361. var mount = node.mount.mountpoint;
  2362. if (!path) return mount;
  2363. return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
  2364. }
  2365. path = path ? node.name + '/' + path : node.name;
  2366. node = node.parent;
  2367. }
  2368. },hashName:function(parentid, name) {
  2369. var hash = 0;
  2370. for (var i = 0; i < name.length; i++) {
  2371. hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
  2372. }
  2373. return ((parentid + hash) >>> 0) % FS.nameTable.length;
  2374. },hashAddNode:function(node) {
  2375. var hash = FS.hashName(node.parent.id, node.name);
  2376. node.name_next = FS.nameTable[hash];
  2377. FS.nameTable[hash] = node;
  2378. },hashRemoveNode:function(node) {
  2379. var hash = FS.hashName(node.parent.id, node.name);
  2380. if (FS.nameTable[hash] === node) {
  2381. FS.nameTable[hash] = node.name_next;
  2382. } else {
  2383. var current = FS.nameTable[hash];
  2384. while (current) {
  2385. if (current.name_next === node) {
  2386. current.name_next = node.name_next;
  2387. break;
  2388. }
  2389. current = current.name_next;
  2390. }
  2391. }
  2392. },lookupNode:function(parent, name) {
  2393. var errCode = FS.mayLookup(parent);
  2394. if (errCode) {
  2395. throw new FS.ErrnoError(errCode, parent);
  2396. }
  2397. var hash = FS.hashName(parent.id, name);
  2398. for (var node = FS.nameTable[hash]; node; node = node.name_next) {
  2399. var nodeName = node.name;
  2400. if (node.parent.id === parent.id && nodeName === name) {
  2401. return node;
  2402. }
  2403. }
  2404. // if we failed to find it in the cache, call into the VFS
  2405. return FS.lookup(parent, name);
  2406. },createNode:function(parent, name, mode, rdev) {
  2407. var node = new FS.FSNode(parent, name, mode, rdev);
  2408. FS.hashAddNode(node);
  2409. return node;
  2410. },destroyNode:function(node) {
  2411. FS.hashRemoveNode(node);
  2412. },isRoot:function(node) {
  2413. return node === node.parent;
  2414. },isMountpoint:function(node) {
  2415. return !!node.mounted;
  2416. },isFile:function(mode) {
  2417. return (mode & 61440) === 32768;
  2418. },isDir:function(mode) {
  2419. return (mode & 61440) === 16384;
  2420. },isLink:function(mode) {
  2421. return (mode & 61440) === 40960;
  2422. },isChrdev:function(mode) {
  2423. return (mode & 61440) === 8192;
  2424. },isBlkdev:function(mode) {
  2425. return (mode & 61440) === 24576;
  2426. },isFIFO:function(mode) {
  2427. return (mode & 61440) === 4096;
  2428. },isSocket:function(mode) {
  2429. return (mode & 49152) === 49152;
  2430. },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(str) {
  2431. var flags = FS.flagModes[str];
  2432. if (typeof flags === 'undefined') {
  2433. throw new Error('Unknown file open mode: ' + str);
  2434. }
  2435. return flags;
  2436. },flagsToPermissionString:function(flag) {
  2437. var perms = ['r', 'w', 'rw'][flag & 3];
  2438. if ((flag & 512)) {
  2439. perms += 'w';
  2440. }
  2441. return perms;
  2442. },nodePermissions:function(node, perms) {
  2443. if (FS.ignorePermissions) {
  2444. return 0;
  2445. }
  2446. // return 0 if any user, group or owner bits are set.
  2447. if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
  2448. return 2;
  2449. } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
  2450. return 2;
  2451. } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
  2452. return 2;
  2453. }
  2454. return 0;
  2455. },mayLookup:function(dir) {
  2456. var errCode = FS.nodePermissions(dir, 'x');
  2457. if (errCode) return errCode;
  2458. if (!dir.node_ops.lookup) return 2;
  2459. return 0;
  2460. },mayCreate:function(dir, name) {
  2461. try {
  2462. var node = FS.lookupNode(dir, name);
  2463. return 20;
  2464. } catch (e) {
  2465. }
  2466. return FS.nodePermissions(dir, 'wx');
  2467. },mayDelete:function(dir, name, isdir) {
  2468. var node;
  2469. try {
  2470. node = FS.lookupNode(dir, name);
  2471. } catch (e) {
  2472. return e.errno;
  2473. }
  2474. var errCode = FS.nodePermissions(dir, 'wx');
  2475. if (errCode) {
  2476. return errCode;
  2477. }
  2478. if (isdir) {
  2479. if (!FS.isDir(node.mode)) {
  2480. return 54;
  2481. }
  2482. if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
  2483. return 10;
  2484. }
  2485. } else {
  2486. if (FS.isDir(node.mode)) {
  2487. return 31;
  2488. }
  2489. }
  2490. return 0;
  2491. },mayOpen:function(node, flags) {
  2492. if (!node) {
  2493. return 44;
  2494. }
  2495. if (FS.isLink(node.mode)) {
  2496. return 32;
  2497. } else if (FS.isDir(node.mode)) {
  2498. if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write
  2499. (flags & 512)) { // TODO: check for O_SEARCH? (== search for dir only)
  2500. return 31;
  2501. }
  2502. }
  2503. return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
  2504. },MAX_OPEN_FDS:4096,nextfd:function(fd_start, fd_end) {
  2505. fd_start = fd_start || 0;
  2506. fd_end = fd_end || FS.MAX_OPEN_FDS;
  2507. for (var fd = fd_start; fd <= fd_end; fd++) {
  2508. if (!FS.streams[fd]) {
  2509. return fd;
  2510. }
  2511. }
  2512. throw new FS.ErrnoError(33);
  2513. },getStream:function(fd) {
  2514. return FS.streams[fd];
  2515. },createStream:function(stream, fd_start, fd_end) {
  2516. if (!FS.FSStream) {
  2517. FS.FSStream = /** @constructor */ function(){};
  2518. FS.FSStream.prototype = {
  2519. object: {
  2520. get: function() { return this.node; },
  2521. set: function(val) { this.node = val; }
  2522. },
  2523. isRead: {
  2524. get: function() { return (this.flags & 2097155) !== 1; }
  2525. },
  2526. isWrite: {
  2527. get: function() { return (this.flags & 2097155) !== 0; }
  2528. },
  2529. isAppend: {
  2530. get: function() { return (this.flags & 1024); }
  2531. }
  2532. };
  2533. }
  2534. // clone it, so we can return an instance of FSStream
  2535. var newStream = new FS.FSStream();
  2536. for (var p in stream) {
  2537. newStream[p] = stream[p];
  2538. }
  2539. stream = newStream;
  2540. var fd = FS.nextfd(fd_start, fd_end);
  2541. stream.fd = fd;
  2542. FS.streams[fd] = stream;
  2543. return stream;
  2544. },closeStream:function(fd) {
  2545. FS.streams[fd] = null;
  2546. },chrdev_stream_ops:{open:function(stream) {
  2547. var device = FS.getDevice(stream.node.rdev);
  2548. // override node's stream ops with the device's
  2549. stream.stream_ops = device.stream_ops;
  2550. // forward the open call
  2551. if (stream.stream_ops.open) {
  2552. stream.stream_ops.open(stream);
  2553. }
  2554. },llseek:function() {
  2555. throw new FS.ErrnoError(70);
  2556. }},major:function(dev) {
  2557. return ((dev) >> 8);
  2558. },minor:function(dev) {
  2559. return ((dev) & 0xff);
  2560. },makedev:function(ma, mi) {
  2561. return ((ma) << 8 | (mi));
  2562. },registerDevice:function(dev, ops) {
  2563. FS.devices[dev] = { stream_ops: ops };
  2564. },getDevice:function(dev) {
  2565. return FS.devices[dev];
  2566. },getMounts:function(mount) {
  2567. var mounts = [];
  2568. var check = [mount];
  2569. while (check.length) {
  2570. var m = check.pop();
  2571. mounts.push(m);
  2572. check.push.apply(check, m.mounts);
  2573. }
  2574. return mounts;
  2575. },syncfs:function(populate, callback) {
  2576. if (typeof(populate) === 'function') {
  2577. callback = populate;
  2578. populate = false;
  2579. }
  2580. FS.syncFSRequests++;
  2581. if (FS.syncFSRequests > 1) {
  2582. err('warning: ' + FS.syncFSRequests + ' FS.syncfs operations in flight at once, probably just doing extra work');
  2583. }
  2584. var mounts = FS.getMounts(FS.root.mount);
  2585. var completed = 0;
  2586. function doCallback(errCode) {
  2587. assert(FS.syncFSRequests > 0);
  2588. FS.syncFSRequests--;
  2589. return callback(errCode);
  2590. }
  2591. function done(errCode) {
  2592. if (errCode) {
  2593. if (!done.errored) {
  2594. done.errored = true;
  2595. return doCallback(errCode);
  2596. }
  2597. return;
  2598. }
  2599. if (++completed >= mounts.length) {
  2600. doCallback(null);
  2601. }
  2602. };
  2603. // sync all mounts
  2604. mounts.forEach(function (mount) {
  2605. if (!mount.type.syncfs) {
  2606. return done(null);
  2607. }
  2608. mount.type.syncfs(mount, populate, done);
  2609. });
  2610. },mount:function(type, opts, mountpoint) {
  2611. if (typeof type === 'string') {
  2612. // The filesystem was not included, and instead we have an error
  2613. // message stored in the variable.
  2614. throw type;
  2615. }
  2616. var root = mountpoint === '/';
  2617. var pseudo = !mountpoint;
  2618. var node;
  2619. if (root && FS.root) {
  2620. throw new FS.ErrnoError(10);
  2621. } else if (!root && !pseudo) {
  2622. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2623. mountpoint = lookup.path; // use the absolute path
  2624. node = lookup.node;
  2625. if (FS.isMountpoint(node)) {
  2626. throw new FS.ErrnoError(10);
  2627. }
  2628. if (!FS.isDir(node.mode)) {
  2629. throw new FS.ErrnoError(54);
  2630. }
  2631. }
  2632. var mount = {
  2633. type: type,
  2634. opts: opts,
  2635. mountpoint: mountpoint,
  2636. mounts: []
  2637. };
  2638. // create a root node for the fs
  2639. var mountRoot = type.mount(mount);
  2640. mountRoot.mount = mount;
  2641. mount.root = mountRoot;
  2642. if (root) {
  2643. FS.root = mountRoot;
  2644. } else if (node) {
  2645. // set as a mountpoint
  2646. node.mounted = mount;
  2647. // add the new mount to the current mount's children
  2648. if (node.mount) {
  2649. node.mount.mounts.push(mount);
  2650. }
  2651. }
  2652. return mountRoot;
  2653. },unmount:function (mountpoint) {
  2654. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2655. if (!FS.isMountpoint(lookup.node)) {
  2656. throw new FS.ErrnoError(28);
  2657. }
  2658. // destroy the nodes for this mount, and all its child mounts
  2659. var node = lookup.node;
  2660. var mount = node.mounted;
  2661. var mounts = FS.getMounts(mount);
  2662. Object.keys(FS.nameTable).forEach(function (hash) {
  2663. var current = FS.nameTable[hash];
  2664. while (current) {
  2665. var next = current.name_next;
  2666. if (mounts.indexOf(current.mount) !== -1) {
  2667. FS.destroyNode(current);
  2668. }
  2669. current = next;
  2670. }
  2671. });
  2672. // no longer a mountpoint
  2673. node.mounted = null;
  2674. // remove this mount from the child mounts
  2675. var idx = node.mount.mounts.indexOf(mount);
  2676. assert(idx !== -1);
  2677. node.mount.mounts.splice(idx, 1);
  2678. },lookup:function(parent, name) {
  2679. return parent.node_ops.lookup(parent, name);
  2680. },mknod:function(path, mode, dev) {
  2681. var lookup = FS.lookupPath(path, { parent: true });
  2682. var parent = lookup.node;
  2683. var name = PATH.basename(path);
  2684. if (!name || name === '.' || name === '..') {
  2685. throw new FS.ErrnoError(28);
  2686. }
  2687. var errCode = FS.mayCreate(parent, name);
  2688. if (errCode) {
  2689. throw new FS.ErrnoError(errCode);
  2690. }
  2691. if (!parent.node_ops.mknod) {
  2692. throw new FS.ErrnoError(63);
  2693. }
  2694. return parent.node_ops.mknod(parent, name, mode, dev);
  2695. },create:function(path, mode) {
  2696. mode = mode !== undefined ? mode : 438 /* 0666 */;
  2697. mode &= 4095;
  2698. mode |= 32768;
  2699. return FS.mknod(path, mode, 0);
  2700. },mkdir:function(path, mode) {
  2701. mode = mode !== undefined ? mode : 511 /* 0777 */;
  2702. mode &= 511 | 512;
  2703. mode |= 16384;
  2704. return FS.mknod(path, mode, 0);
  2705. },mkdirTree:function(path, mode) {
  2706. var dirs = path.split('/');
  2707. var d = '';
  2708. for (var i = 0; i < dirs.length; ++i) {
  2709. if (!dirs[i]) continue;
  2710. d += '/' + dirs[i];
  2711. try {
  2712. FS.mkdir(d, mode);
  2713. } catch(e) {
  2714. if (e.errno != 20) throw e;
  2715. }
  2716. }
  2717. },mkdev:function(path, mode, dev) {
  2718. if (typeof(dev) === 'undefined') {
  2719. dev = mode;
  2720. mode = 438 /* 0666 */;
  2721. }
  2722. mode |= 8192;
  2723. return FS.mknod(path, mode, dev);
  2724. },symlink:function(oldpath, newpath) {
  2725. if (!PATH_FS.resolve(oldpath)) {
  2726. throw new FS.ErrnoError(44);
  2727. }
  2728. var lookup = FS.lookupPath(newpath, { parent: true });
  2729. var parent = lookup.node;
  2730. if (!parent) {
  2731. throw new FS.ErrnoError(44);
  2732. }
  2733. var newname = PATH.basename(newpath);
  2734. var errCode = FS.mayCreate(parent, newname);
  2735. if (errCode) {
  2736. throw new FS.ErrnoError(errCode);
  2737. }
  2738. if (!parent.node_ops.symlink) {
  2739. throw new FS.ErrnoError(63);
  2740. }
  2741. return parent.node_ops.symlink(parent, newname, oldpath);
  2742. },rename:function(old_path, new_path) {
  2743. var old_dirname = PATH.dirname(old_path);
  2744. var new_dirname = PATH.dirname(new_path);
  2745. var old_name = PATH.basename(old_path);
  2746. var new_name = PATH.basename(new_path);
  2747. // parents must exist
  2748. var lookup, old_dir, new_dir;
  2749. try {
  2750. lookup = FS.lookupPath(old_path, { parent: true });
  2751. old_dir = lookup.node;
  2752. lookup = FS.lookupPath(new_path, { parent: true });
  2753. new_dir = lookup.node;
  2754. } catch (e) {
  2755. throw new FS.ErrnoError(10);
  2756. }
  2757. if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
  2758. // need to be part of the same mount
  2759. if (old_dir.mount !== new_dir.mount) {
  2760. throw new FS.ErrnoError(75);
  2761. }
  2762. // source must exist
  2763. var old_node = FS.lookupNode(old_dir, old_name);
  2764. // old path should not be an ancestor of the new path
  2765. var relative = PATH_FS.relative(old_path, new_dirname);
  2766. if (relative.charAt(0) !== '.') {
  2767. throw new FS.ErrnoError(28);
  2768. }
  2769. // new path should not be an ancestor of the old path
  2770. relative = PATH_FS.relative(new_path, old_dirname);
  2771. if (relative.charAt(0) !== '.') {
  2772. throw new FS.ErrnoError(55);
  2773. }
  2774. // see if the new path already exists
  2775. var new_node;
  2776. try {
  2777. new_node = FS.lookupNode(new_dir, new_name);
  2778. } catch (e) {
  2779. // not fatal
  2780. }
  2781. // early out if nothing needs to change
  2782. if (old_node === new_node) {
  2783. return;
  2784. }
  2785. // we'll need to delete the old entry
  2786. var isdir = FS.isDir(old_node.mode);
  2787. var errCode = FS.mayDelete(old_dir, old_name, isdir);
  2788. if (errCode) {
  2789. throw new FS.ErrnoError(errCode);
  2790. }
  2791. // need delete permissions if we'll be overwriting.
  2792. // need create permissions if new doesn't already exist.
  2793. errCode = new_node ?
  2794. FS.mayDelete(new_dir, new_name, isdir) :
  2795. FS.mayCreate(new_dir, new_name);
  2796. if (errCode) {
  2797. throw new FS.ErrnoError(errCode);
  2798. }
  2799. if (!old_dir.node_ops.rename) {
  2800. throw new FS.ErrnoError(63);
  2801. }
  2802. if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
  2803. throw new FS.ErrnoError(10);
  2804. }
  2805. // if we are going to change the parent, check write permissions
  2806. if (new_dir !== old_dir) {
  2807. errCode = FS.nodePermissions(old_dir, 'w');
  2808. if (errCode) {
  2809. throw new FS.ErrnoError(errCode);
  2810. }
  2811. }
  2812. try {
  2813. if (FS.trackingDelegate['willMovePath']) {
  2814. FS.trackingDelegate['willMovePath'](old_path, new_path);
  2815. }
  2816. } catch(e) {
  2817. err("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
  2818. }
  2819. // remove the node from the lookup hash
  2820. FS.hashRemoveNode(old_node);
  2821. // do the underlying fs rename
  2822. try {
  2823. old_dir.node_ops.rename(old_node, new_dir, new_name);
  2824. } catch (e) {
  2825. throw e;
  2826. } finally {
  2827. // add the node back to the hash (in case node_ops.rename
  2828. // changed its name)
  2829. FS.hashAddNode(old_node);
  2830. }
  2831. try {
  2832. if (FS.trackingDelegate['onMovePath']) FS.trackingDelegate['onMovePath'](old_path, new_path);
  2833. } catch(e) {
  2834. err("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
  2835. }
  2836. },rmdir:function(path) {
  2837. var lookup = FS.lookupPath(path, { parent: true });
  2838. var parent = lookup.node;
  2839. var name = PATH.basename(path);
  2840. var node = FS.lookupNode(parent, name);
  2841. var errCode = FS.mayDelete(parent, name, true);
  2842. if (errCode) {
  2843. throw new FS.ErrnoError(errCode);
  2844. }
  2845. if (!parent.node_ops.rmdir) {
  2846. throw new FS.ErrnoError(63);
  2847. }
  2848. if (FS.isMountpoint(node)) {
  2849. throw new FS.ErrnoError(10);
  2850. }
  2851. try {
  2852. if (FS.trackingDelegate['willDeletePath']) {
  2853. FS.trackingDelegate['willDeletePath'](path);
  2854. }
  2855. } catch(e) {
  2856. err("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
  2857. }
  2858. parent.node_ops.rmdir(parent, name);
  2859. FS.destroyNode(node);
  2860. try {
  2861. if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
  2862. } catch(e) {
  2863. err("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
  2864. }
  2865. },readdir:function(path) {
  2866. var lookup = FS.lookupPath(path, { follow: true });
  2867. var node = lookup.node;
  2868. if (!node.node_ops.readdir) {
  2869. throw new FS.ErrnoError(54);
  2870. }
  2871. return node.node_ops.readdir(node);
  2872. },unlink:function(path) {
  2873. var lookup = FS.lookupPath(path, { parent: true });
  2874. var parent = lookup.node;
  2875. var name = PATH.basename(path);
  2876. var node = FS.lookupNode(parent, name);
  2877. var errCode = FS.mayDelete(parent, name, false);
  2878. if (errCode) {
  2879. // According to POSIX, we should map EISDIR to EPERM, but
  2880. // we instead do what Linux does (and we must, as we use
  2881. // the musl linux libc).
  2882. throw new FS.ErrnoError(errCode);
  2883. }
  2884. if (!parent.node_ops.unlink) {
  2885. throw new FS.ErrnoError(63);
  2886. }
  2887. if (FS.isMountpoint(node)) {
  2888. throw new FS.ErrnoError(10);
  2889. }
  2890. try {
  2891. if (FS.trackingDelegate['willDeletePath']) {
  2892. FS.trackingDelegate['willDeletePath'](path);
  2893. }
  2894. } catch(e) {
  2895. err("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
  2896. }
  2897. parent.node_ops.unlink(parent, name);
  2898. FS.destroyNode(node);
  2899. try {
  2900. if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
  2901. } catch(e) {
  2902. err("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
  2903. }
  2904. },readlink:function(path) {
  2905. var lookup = FS.lookupPath(path);
  2906. var link = lookup.node;
  2907. if (!link) {
  2908. throw new FS.ErrnoError(44);
  2909. }
  2910. if (!link.node_ops.readlink) {
  2911. throw new FS.ErrnoError(28);
  2912. }
  2913. return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
  2914. },stat:function(path, dontFollow) {
  2915. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2916. var node = lookup.node;
  2917. if (!node) {
  2918. throw new FS.ErrnoError(44);
  2919. }
  2920. if (!node.node_ops.getattr) {
  2921. throw new FS.ErrnoError(63);
  2922. }
  2923. return node.node_ops.getattr(node);
  2924. },lstat:function(path) {
  2925. return FS.stat(path, true);
  2926. },chmod:function(path, mode, dontFollow) {
  2927. var node;
  2928. if (typeof path === 'string') {
  2929. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2930. node = lookup.node;
  2931. } else {
  2932. node = path;
  2933. }
  2934. if (!node.node_ops.setattr) {
  2935. throw new FS.ErrnoError(63);
  2936. }
  2937. node.node_ops.setattr(node, {
  2938. mode: (mode & 4095) | (node.mode & ~4095),
  2939. timestamp: Date.now()
  2940. });
  2941. },lchmod:function(path, mode) {
  2942. FS.chmod(path, mode, true);
  2943. },fchmod:function(fd, mode) {
  2944. var stream = FS.getStream(fd);
  2945. if (!stream) {
  2946. throw new FS.ErrnoError(8);
  2947. }
  2948. FS.chmod(stream.node, mode);
  2949. },chown:function(path, uid, gid, dontFollow) {
  2950. var node;
  2951. if (typeof path === 'string') {
  2952. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2953. node = lookup.node;
  2954. } else {
  2955. node = path;
  2956. }
  2957. if (!node.node_ops.setattr) {
  2958. throw new FS.ErrnoError(63);
  2959. }
  2960. node.node_ops.setattr(node, {
  2961. timestamp: Date.now()
  2962. // we ignore the uid / gid for now
  2963. });
  2964. },lchown:function(path, uid, gid) {
  2965. FS.chown(path, uid, gid, true);
  2966. },fchown:function(fd, uid, gid) {
  2967. var stream = FS.getStream(fd);
  2968. if (!stream) {
  2969. throw new FS.ErrnoError(8);
  2970. }
  2971. FS.chown(stream.node, uid, gid);
  2972. },truncate:function(path, len) {
  2973. if (len < 0) {
  2974. throw new FS.ErrnoError(28);
  2975. }
  2976. var node;
  2977. if (typeof path === 'string') {
  2978. var lookup = FS.lookupPath(path, { follow: true });
  2979. node = lookup.node;
  2980. } else {
  2981. node = path;
  2982. }
  2983. if (!node.node_ops.setattr) {
  2984. throw new FS.ErrnoError(63);
  2985. }
  2986. if (FS.isDir(node.mode)) {
  2987. throw new FS.ErrnoError(31);
  2988. }
  2989. if (!FS.isFile(node.mode)) {
  2990. throw new FS.ErrnoError(28);
  2991. }
  2992. var errCode = FS.nodePermissions(node, 'w');
  2993. if (errCode) {
  2994. throw new FS.ErrnoError(errCode);
  2995. }
  2996. node.node_ops.setattr(node, {
  2997. size: len,
  2998. timestamp: Date.now()
  2999. });
  3000. },ftruncate:function(fd, len) {
  3001. var stream = FS.getStream(fd);
  3002. if (!stream) {
  3003. throw new FS.ErrnoError(8);
  3004. }
  3005. if ((stream.flags & 2097155) === 0) {
  3006. throw new FS.ErrnoError(28);
  3007. }
  3008. FS.truncate(stream.node, len);
  3009. },utime:function(path, atime, mtime) {
  3010. var lookup = FS.lookupPath(path, { follow: true });
  3011. var node = lookup.node;
  3012. node.node_ops.setattr(node, {
  3013. timestamp: Math.max(atime, mtime)
  3014. });
  3015. },open:function(path, flags, mode, fd_start, fd_end) {
  3016. if (path === "") {
  3017. throw new FS.ErrnoError(44);
  3018. }
  3019. flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
  3020. mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
  3021. if ((flags & 64)) {
  3022. mode = (mode & 4095) | 32768;
  3023. } else {
  3024. mode = 0;
  3025. }
  3026. var node;
  3027. if (typeof path === 'object') {
  3028. node = path;
  3029. } else {
  3030. path = PATH.normalize(path);
  3031. try {
  3032. var lookup = FS.lookupPath(path, {
  3033. follow: !(flags & 131072)
  3034. });
  3035. node = lookup.node;
  3036. } catch (e) {
  3037. // ignore
  3038. }
  3039. }
  3040. // perhaps we need to create the node
  3041. var created = false;
  3042. if ((flags & 64)) {
  3043. if (node) {
  3044. // if O_CREAT and O_EXCL are set, error out if the node already exists
  3045. if ((flags & 128)) {
  3046. throw new FS.ErrnoError(20);
  3047. }
  3048. } else {
  3049. // node doesn't exist, try to create it
  3050. node = FS.mknod(path, mode, 0);
  3051. created = true;
  3052. }
  3053. }
  3054. if (!node) {
  3055. throw new FS.ErrnoError(44);
  3056. }
  3057. // can't truncate a device
  3058. if (FS.isChrdev(node.mode)) {
  3059. flags &= ~512;
  3060. }
  3061. // if asked only for a directory, then this must be one
  3062. if ((flags & 65536) && !FS.isDir(node.mode)) {
  3063. throw new FS.ErrnoError(54);
  3064. }
  3065. // check permissions, if this is not a file we just created now (it is ok to
  3066. // create and write to a file with read-only permissions; it is read-only
  3067. // for later use)
  3068. if (!created) {
  3069. var errCode = FS.mayOpen(node, flags);
  3070. if (errCode) {
  3071. throw new FS.ErrnoError(errCode);
  3072. }
  3073. }
  3074. // do truncation if necessary
  3075. if ((flags & 512)) {
  3076. FS.truncate(node, 0);
  3077. }
  3078. // we've already handled these, don't pass down to the underlying vfs
  3079. flags &= ~(128 | 512 | 131072);
  3080. // register the stream with the filesystem
  3081. var stream = FS.createStream({
  3082. node: node,
  3083. path: FS.getPath(node), // we want the absolute path to the node
  3084. flags: flags,
  3085. seekable: true,
  3086. position: 0,
  3087. stream_ops: node.stream_ops,
  3088. // used by the file family libc calls (fopen, fwrite, ferror, etc.)
  3089. ungotten: [],
  3090. error: false
  3091. }, fd_start, fd_end);
  3092. // call the new stream's open function
  3093. if (stream.stream_ops.open) {
  3094. stream.stream_ops.open(stream);
  3095. }
  3096. if (Module['logReadFiles'] && !(flags & 1)) {
  3097. if (!FS.readFiles) FS.readFiles = {};
  3098. if (!(path in FS.readFiles)) {
  3099. FS.readFiles[path] = 1;
  3100. err("FS.trackingDelegate error on read file: " + path);
  3101. }
  3102. }
  3103. try {
  3104. if (FS.trackingDelegate['onOpenFile']) {
  3105. var trackingFlags = 0;
  3106. if ((flags & 2097155) !== 1) {
  3107. trackingFlags |= FS.tracking.openFlags.READ;
  3108. }
  3109. if ((flags & 2097155) !== 0) {
  3110. trackingFlags |= FS.tracking.openFlags.WRITE;
  3111. }
  3112. FS.trackingDelegate['onOpenFile'](path, trackingFlags);
  3113. }
  3114. } catch(e) {
  3115. err("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: " + e.message);
  3116. }
  3117. return stream;
  3118. },close:function(stream) {
  3119. if (FS.isClosed(stream)) {
  3120. throw new FS.ErrnoError(8);
  3121. }
  3122. if (stream.getdents) stream.getdents = null; // free readdir state
  3123. try {
  3124. if (stream.stream_ops.close) {
  3125. stream.stream_ops.close(stream);
  3126. }
  3127. } catch (e) {
  3128. throw e;
  3129. } finally {
  3130. FS.closeStream(stream.fd);
  3131. }
  3132. stream.fd = null;
  3133. },isClosed:function(stream) {
  3134. return stream.fd === null;
  3135. },llseek:function(stream, offset, whence) {
  3136. if (FS.isClosed(stream)) {
  3137. throw new FS.ErrnoError(8);
  3138. }
  3139. if (!stream.seekable || !stream.stream_ops.llseek) {
  3140. throw new FS.ErrnoError(70);
  3141. }
  3142. if (whence != 0 && whence != 1 && whence != 2) {
  3143. throw new FS.ErrnoError(28);
  3144. }
  3145. stream.position = stream.stream_ops.llseek(stream, offset, whence);
  3146. stream.ungotten = [];
  3147. return stream.position;
  3148. },read:function(stream, buffer, offset, length, position) {
  3149. if (length < 0 || position < 0) {
  3150. throw new FS.ErrnoError(28);
  3151. }
  3152. if (FS.isClosed(stream)) {
  3153. throw new FS.ErrnoError(8);
  3154. }
  3155. if ((stream.flags & 2097155) === 1) {
  3156. throw new FS.ErrnoError(8);
  3157. }
  3158. if (FS.isDir(stream.node.mode)) {
  3159. throw new FS.ErrnoError(31);
  3160. }
  3161. if (!stream.stream_ops.read) {
  3162. throw new FS.ErrnoError(28);
  3163. }
  3164. var seeking = typeof position !== 'undefined';
  3165. if (!seeking) {
  3166. position = stream.position;
  3167. } else if (!stream.seekable) {
  3168. throw new FS.ErrnoError(70);
  3169. }
  3170. var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
  3171. if (!seeking) stream.position += bytesRead;
  3172. return bytesRead;
  3173. },write:function(stream, buffer, offset, length, position, canOwn) {
  3174. if (length < 0 || position < 0) {
  3175. throw new FS.ErrnoError(28);
  3176. }
  3177. if (FS.isClosed(stream)) {
  3178. throw new FS.ErrnoError(8);
  3179. }
  3180. if ((stream.flags & 2097155) === 0) {
  3181. throw new FS.ErrnoError(8);
  3182. }
  3183. if (FS.isDir(stream.node.mode)) {
  3184. throw new FS.ErrnoError(31);
  3185. }
  3186. if (!stream.stream_ops.write) {
  3187. throw new FS.ErrnoError(28);
  3188. }
  3189. if (stream.seekable && stream.flags & 1024) {
  3190. // seek to the end before writing in append mode
  3191. FS.llseek(stream, 0, 2);
  3192. }
  3193. var seeking = typeof position !== 'undefined';
  3194. if (!seeking) {
  3195. position = stream.position;
  3196. } else if (!stream.seekable) {
  3197. throw new FS.ErrnoError(70);
  3198. }
  3199. var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
  3200. if (!seeking) stream.position += bytesWritten;
  3201. try {
  3202. if (stream.path && FS.trackingDelegate['onWriteToFile']) FS.trackingDelegate['onWriteToFile'](stream.path);
  3203. } catch(e) {
  3204. err("FS.trackingDelegate['onWriteToFile']('"+stream.path+"') threw an exception: " + e.message);
  3205. }
  3206. return bytesWritten;
  3207. },allocate:function(stream, offset, length) {
  3208. if (FS.isClosed(stream)) {
  3209. throw new FS.ErrnoError(8);
  3210. }
  3211. if (offset < 0 || length <= 0) {
  3212. throw new FS.ErrnoError(28);
  3213. }
  3214. if ((stream.flags & 2097155) === 0) {
  3215. throw new FS.ErrnoError(8);
  3216. }
  3217. if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
  3218. throw new FS.ErrnoError(43);
  3219. }
  3220. if (!stream.stream_ops.allocate) {
  3221. throw new FS.ErrnoError(138);
  3222. }
  3223. stream.stream_ops.allocate(stream, offset, length);
  3224. },mmap:function(stream, buffer, offset, length, position, prot, flags) {
  3225. // User requests writing to file (prot & PROT_WRITE != 0).
  3226. // Checking if we have permissions to write to the file unless
  3227. // MAP_PRIVATE flag is set. According to POSIX spec it is possible
  3228. // to write to file opened in read-only mode with MAP_PRIVATE flag,
  3229. // as all modifications will be visible only in the memory of
  3230. // the current process.
  3231. if ((prot & 2) !== 0
  3232. && (flags & 2) === 0
  3233. && (stream.flags & 2097155) !== 2) {
  3234. throw new FS.ErrnoError(2);
  3235. }
  3236. if ((stream.flags & 2097155) === 1) {
  3237. throw new FS.ErrnoError(2);
  3238. }
  3239. if (!stream.stream_ops.mmap) {
  3240. throw new FS.ErrnoError(43);
  3241. }
  3242. return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
  3243. },msync:function(stream, buffer, offset, length, mmapFlags) {
  3244. if (!stream || !stream.stream_ops.msync) {
  3245. return 0;
  3246. }
  3247. return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
  3248. },munmap:function(stream) {
  3249. return 0;
  3250. },ioctl:function(stream, cmd, arg) {
  3251. if (!stream.stream_ops.ioctl) {
  3252. throw new FS.ErrnoError(59);
  3253. }
  3254. return stream.stream_ops.ioctl(stream, cmd, arg);
  3255. },readFile:function(path, opts) {
  3256. opts = opts || {};
  3257. opts.flags = opts.flags || 'r';
  3258. opts.encoding = opts.encoding || 'binary';
  3259. if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
  3260. throw new Error('Invalid encoding type "' + opts.encoding + '"');
  3261. }
  3262. var ret;
  3263. var stream = FS.open(path, opts.flags);
  3264. var stat = FS.stat(path);
  3265. var length = stat.size;
  3266. var buf = new Uint8Array(length);
  3267. FS.read(stream, buf, 0, length, 0);
  3268. if (opts.encoding === 'utf8') {
  3269. ret = UTF8ArrayToString(buf, 0);
  3270. } else if (opts.encoding === 'binary') {
  3271. ret = buf;
  3272. }
  3273. FS.close(stream);
  3274. return ret;
  3275. },writeFile:function(path, data, opts) {
  3276. opts = opts || {};
  3277. opts.flags = opts.flags || 'w';
  3278. var stream = FS.open(path, opts.flags, opts.mode);
  3279. if (typeof data === 'string') {
  3280. var buf = new Uint8Array(lengthBytesUTF8(data)+1);
  3281. var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
  3282. FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn);
  3283. } else if (ArrayBuffer.isView(data)) {
  3284. FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
  3285. } else {
  3286. throw new Error('Unsupported data type');
  3287. }
  3288. FS.close(stream);
  3289. },cwd:function() {
  3290. return FS.currentPath;
  3291. },chdir:function(path) {
  3292. var lookup = FS.lookupPath(path, { follow: true });
  3293. if (lookup.node === null) {
  3294. throw new FS.ErrnoError(44);
  3295. }
  3296. if (!FS.isDir(lookup.node.mode)) {
  3297. throw new FS.ErrnoError(54);
  3298. }
  3299. var errCode = FS.nodePermissions(lookup.node, 'x');
  3300. if (errCode) {
  3301. throw new FS.ErrnoError(errCode);
  3302. }
  3303. FS.currentPath = lookup.path;
  3304. },createDefaultDirectories:function() {
  3305. FS.mkdir('/tmp');
  3306. FS.mkdir('/home');
  3307. FS.mkdir('/home/web_user');
  3308. },createDefaultDevices:function() {
  3309. // create /dev
  3310. FS.mkdir('/dev');
  3311. // setup /dev/null
  3312. FS.registerDevice(FS.makedev(1, 3), {
  3313. read: function() { return 0; },
  3314. write: function(stream, buffer, offset, length, pos) { return length; }
  3315. });
  3316. FS.mkdev('/dev/null', FS.makedev(1, 3));
  3317. // setup /dev/tty and /dev/tty1
  3318. // stderr needs to print output using Module['printErr']
  3319. // so we register a second tty just for it.
  3320. TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
  3321. TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
  3322. FS.mkdev('/dev/tty', FS.makedev(5, 0));
  3323. FS.mkdev('/dev/tty1', FS.makedev(6, 0));
  3324. // setup /dev/[u]random
  3325. var random_device;
  3326. if (typeof crypto === 'object' && typeof crypto['getRandomValues'] === 'function') {
  3327. // for modern web browsers
  3328. var randomBuffer = new Uint8Array(1);
  3329. random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; };
  3330. } else
  3331. if (ENVIRONMENT_IS_NODE) {
  3332. // for nodejs with or without crypto support included
  3333. try {
  3334. var crypto_module = require('crypto');
  3335. // nodejs has crypto support
  3336. random_device = function() { return crypto_module['randomBytes'](1)[0]; };
  3337. } catch (e) {
  3338. // nodejs doesn't have crypto support
  3339. }
  3340. } else
  3341. {}
  3342. if (!random_device) {
  3343. // we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
  3344. random_device = function() { abort("no cryptographic support found for random_device. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: function(array) { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };"); };
  3345. }
  3346. FS.createDevice('/dev', 'random', random_device);
  3347. FS.createDevice('/dev', 'urandom', random_device);
  3348. // we're not going to emulate the actual shm device,
  3349. // just create the tmp dirs that reside in it commonly
  3350. FS.mkdir('/dev/shm');
  3351. FS.mkdir('/dev/shm/tmp');
  3352. },createSpecialDirectories:function() {
  3353. // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the name of the stream for fd 6 (see test_unistd_ttyname)
  3354. FS.mkdir('/proc');
  3355. FS.mkdir('/proc/self');
  3356. FS.mkdir('/proc/self/fd');
  3357. FS.mount({
  3358. mount: function() {
  3359. var node = FS.createNode('/proc/self', 'fd', 16384 | 511 /* 0777 */, 73);
  3360. node.node_ops = {
  3361. lookup: function(parent, name) {
  3362. var fd = +name;
  3363. var stream = FS.getStream(fd);
  3364. if (!stream) throw new FS.ErrnoError(8);
  3365. var ret = {
  3366. parent: null,
  3367. mount: { mountpoint: 'fake' },
  3368. node_ops: { readlink: function() { return stream.path } }
  3369. };
  3370. ret.parent = ret; // make it look like a simple root node
  3371. return ret;
  3372. }
  3373. };
  3374. return node;
  3375. }
  3376. }, {}, '/proc/self/fd');
  3377. },createStandardStreams:function() {
  3378. // TODO deprecate the old functionality of a single
  3379. // input / output callback and that utilizes FS.createDevice
  3380. // and instead require a unique set of stream ops
  3381. // by default, we symlink the standard streams to the
  3382. // default tty devices. however, if the standard streams
  3383. // have been overwritten we create a unique device for
  3384. // them instead.
  3385. if (Module['stdin']) {
  3386. FS.createDevice('/dev', 'stdin', Module['stdin']);
  3387. } else {
  3388. FS.symlink('/dev/tty', '/dev/stdin');
  3389. }
  3390. if (Module['stdout']) {
  3391. FS.createDevice('/dev', 'stdout', null, Module['stdout']);
  3392. } else {
  3393. FS.symlink('/dev/tty', '/dev/stdout');
  3394. }
  3395. if (Module['stderr']) {
  3396. FS.createDevice('/dev', 'stderr', null, Module['stderr']);
  3397. } else {
  3398. FS.symlink('/dev/tty1', '/dev/stderr');
  3399. }
  3400. // open default streams for the stdin, stdout and stderr devices
  3401. var stdin = FS.open('/dev/stdin', 'r');
  3402. var stdout = FS.open('/dev/stdout', 'w');
  3403. var stderr = FS.open('/dev/stderr', 'w');
  3404. assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
  3405. assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
  3406. assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
  3407. },ensureErrnoError:function() {
  3408. if (FS.ErrnoError) return;
  3409. FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) {
  3410. this.node = node;
  3411. this.setErrno = /** @this{Object} */ function(errno) {
  3412. this.errno = errno;
  3413. for (var key in ERRNO_CODES) {
  3414. if (ERRNO_CODES[key] === errno) {
  3415. this.code = key;
  3416. break;
  3417. }
  3418. }
  3419. };
  3420. this.setErrno(errno);
  3421. this.message = ERRNO_MESSAGES[errno];
  3422. // Try to get a maximally helpful stack trace. On Node.js, getting Error.stack
  3423. // now ensures it shows what we want.
  3424. if (this.stack) {
  3425. // Define the stack property for Node.js 4, which otherwise errors on the next line.
  3426. Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true });
  3427. this.stack = demangleAll(this.stack);
  3428. }
  3429. };
  3430. FS.ErrnoError.prototype = new Error();
  3431. FS.ErrnoError.prototype.constructor = FS.ErrnoError;
  3432. // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
  3433. [44].forEach(function(code) {
  3434. FS.genericErrors[code] = new FS.ErrnoError(code);
  3435. FS.genericErrors[code].stack = '<generic error, no stack>';
  3436. });
  3437. },staticInit:function() {
  3438. FS.ensureErrnoError();
  3439. FS.nameTable = new Array(4096);
  3440. FS.mount(MEMFS, {}, '/');
  3441. FS.createDefaultDirectories();
  3442. FS.createDefaultDevices();
  3443. FS.createSpecialDirectories();
  3444. FS.filesystems = {
  3445. 'MEMFS': MEMFS,
  3446. };
  3447. },init:function(input, output, error) {
  3448. assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
  3449. FS.init.initialized = true;
  3450. FS.ensureErrnoError();
  3451. // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
  3452. Module['stdin'] = input || Module['stdin'];
  3453. Module['stdout'] = output || Module['stdout'];
  3454. Module['stderr'] = error || Module['stderr'];
  3455. FS.createStandardStreams();
  3456. },quit:function() {
  3457. FS.init.initialized = false;
  3458. // force-flush all streams, so we get musl std streams printed out
  3459. var fflush = Module['_fflush'];
  3460. if (fflush) fflush(0);
  3461. // close all of our streams
  3462. for (var i = 0; i < FS.streams.length; i++) {
  3463. var stream = FS.streams[i];
  3464. if (!stream) {
  3465. continue;
  3466. }
  3467. FS.close(stream);
  3468. }
  3469. },getMode:function(canRead, canWrite) {
  3470. var mode = 0;
  3471. if (canRead) mode |= 292 | 73;
  3472. if (canWrite) mode |= 146;
  3473. return mode;
  3474. },joinPath:function(parts, forceRelative) {
  3475. var path = PATH.join.apply(null, parts);
  3476. if (forceRelative && path[0] == '/') path = path.substr(1);
  3477. return path;
  3478. },absolutePath:function(relative, base) {
  3479. return PATH_FS.resolve(base, relative);
  3480. },standardizePath:function(path) {
  3481. return PATH.normalize(path);
  3482. },findObject:function(path, dontResolveLastLink) {
  3483. var ret = FS.analyzePath(path, dontResolveLastLink);
  3484. if (ret.exists) {
  3485. return ret.object;
  3486. } else {
  3487. setErrNo(ret.error);
  3488. return null;
  3489. }
  3490. },analyzePath:function(path, dontResolveLastLink) {
  3491. // operate from within the context of the symlink's target
  3492. try {
  3493. var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3494. path = lookup.path;
  3495. } catch (e) {
  3496. }
  3497. var ret = {
  3498. isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
  3499. parentExists: false, parentPath: null, parentObject: null
  3500. };
  3501. try {
  3502. var lookup = FS.lookupPath(path, { parent: true });
  3503. ret.parentExists = true;
  3504. ret.parentPath = lookup.path;
  3505. ret.parentObject = lookup.node;
  3506. ret.name = PATH.basename(path);
  3507. lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3508. ret.exists = true;
  3509. ret.path = lookup.path;
  3510. ret.object = lookup.node;
  3511. ret.name = lookup.node.name;
  3512. ret.isRoot = lookup.path === '/';
  3513. } catch (e) {
  3514. ret.error = e.errno;
  3515. };
  3516. return ret;
  3517. },createFolder:function(parent, name, canRead, canWrite) {
  3518. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3519. var mode = FS.getMode(canRead, canWrite);
  3520. return FS.mkdir(path, mode);
  3521. },createPath:function(parent, path, canRead, canWrite) {
  3522. parent = typeof parent === 'string' ? parent : FS.getPath(parent);
  3523. var parts = path.split('/').reverse();
  3524. while (parts.length) {
  3525. var part = parts.pop();
  3526. if (!part) continue;
  3527. var current = PATH.join2(parent, part);
  3528. try {
  3529. FS.mkdir(current);
  3530. } catch (e) {
  3531. // ignore EEXIST
  3532. }
  3533. parent = current;
  3534. }
  3535. return current;
  3536. },createFile:function(parent, name, properties, canRead, canWrite) {
  3537. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3538. var mode = FS.getMode(canRead, canWrite);
  3539. return FS.create(path, mode);
  3540. },createDataFile:function(parent, name, data, canRead, canWrite, canOwn) {
  3541. var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
  3542. var mode = FS.getMode(canRead, canWrite);
  3543. var node = FS.create(path, mode);
  3544. if (data) {
  3545. if (typeof data === 'string') {
  3546. var arr = new Array(data.length);
  3547. for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
  3548. data = arr;
  3549. }
  3550. // make sure we can write to the file
  3551. FS.chmod(node, mode | 146);
  3552. var stream = FS.open(node, 'w');
  3553. FS.write(stream, data, 0, data.length, 0, canOwn);
  3554. FS.close(stream);
  3555. FS.chmod(node, mode);
  3556. }
  3557. return node;
  3558. },createDevice:function(parent, name, input, output) {
  3559. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3560. var mode = FS.getMode(!!input, !!output);
  3561. if (!FS.createDevice.major) FS.createDevice.major = 64;
  3562. var dev = FS.makedev(FS.createDevice.major++, 0);
  3563. // Create a fake device that a set of stream ops to emulate
  3564. // the old behavior.
  3565. FS.registerDevice(dev, {
  3566. open: function(stream) {
  3567. stream.seekable = false;
  3568. },
  3569. close: function(stream) {
  3570. // flush any pending line data
  3571. if (output && output.buffer && output.buffer.length) {
  3572. output(10);
  3573. }
  3574. },
  3575. read: function(stream, buffer, offset, length, pos /* ignored */) {
  3576. var bytesRead = 0;
  3577. for (var i = 0; i < length; i++) {
  3578. var result;
  3579. try {
  3580. result = input();
  3581. } catch (e) {
  3582. throw new FS.ErrnoError(29);
  3583. }
  3584. if (result === undefined && bytesRead === 0) {
  3585. throw new FS.ErrnoError(6);
  3586. }
  3587. if (result === null || result === undefined) break;
  3588. bytesRead++;
  3589. buffer[offset+i] = result;
  3590. }
  3591. if (bytesRead) {
  3592. stream.node.timestamp = Date.now();
  3593. }
  3594. return bytesRead;
  3595. },
  3596. write: function(stream, buffer, offset, length, pos) {
  3597. for (var i = 0; i < length; i++) {
  3598. try {
  3599. output(buffer[offset+i]);
  3600. } catch (e) {
  3601. throw new FS.ErrnoError(29);
  3602. }
  3603. }
  3604. if (length) {
  3605. stream.node.timestamp = Date.now();
  3606. }
  3607. return i;
  3608. }
  3609. });
  3610. return FS.mkdev(path, mode, dev);
  3611. },createLink:function(parent, name, target, canRead, canWrite) {
  3612. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3613. return FS.symlink(target, path);
  3614. },forceLoadFile:function(obj) {
  3615. if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
  3616. var success = true;
  3617. if (typeof XMLHttpRequest !== 'undefined') {
  3618. throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
  3619. } else if (read_) {
  3620. // Command-line.
  3621. try {
  3622. // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
  3623. // read() will try to parse UTF8.
  3624. obj.contents = intArrayFromString(read_(obj.url), true);
  3625. obj.usedBytes = obj.contents.length;
  3626. } catch (e) {
  3627. success = false;
  3628. }
  3629. } else {
  3630. throw new Error('Cannot load without read() or XMLHttpRequest.');
  3631. }
  3632. if (!success) setErrNo(29);
  3633. return success;
  3634. },createLazyFile:function(parent, name, url, canRead, canWrite) {
  3635. // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
  3636. /** @constructor */
  3637. function LazyUint8Array() {
  3638. this.lengthKnown = false;
  3639. this.chunks = []; // Loaded chunks. Index is the chunk number
  3640. }
  3641. LazyUint8Array.prototype.get = /** @this{Object} */ function LazyUint8Array_get(idx) {
  3642. if (idx > this.length-1 || idx < 0) {
  3643. return undefined;
  3644. }
  3645. var chunkOffset = idx % this.chunkSize;
  3646. var chunkNum = (idx / this.chunkSize)|0;
  3647. return this.getter(chunkNum)[chunkOffset];
  3648. };
  3649. LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
  3650. this.getter = getter;
  3651. };
  3652. LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
  3653. // Find length
  3654. var xhr = new XMLHttpRequest();
  3655. xhr.open('HEAD', url, false);
  3656. xhr.send(null);
  3657. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3658. var datalength = Number(xhr.getResponseHeader("Content-length"));
  3659. var header;
  3660. var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
  3661. var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
  3662. var chunkSize = 1024*1024; // Chunk size in bytes
  3663. if (!hasByteServing) chunkSize = datalength;
  3664. // Function to get a range from the remote URL.
  3665. var doXHR = (function(from, to) {
  3666. if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
  3667. if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
  3668. // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
  3669. var xhr = new XMLHttpRequest();
  3670. xhr.open('GET', url, false);
  3671. if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
  3672. // Some hints to the browser that we want binary data.
  3673. if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
  3674. if (xhr.overrideMimeType) {
  3675. xhr.overrideMimeType('text/plain; charset=x-user-defined');
  3676. }
  3677. xhr.send(null);
  3678. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3679. if (xhr.response !== undefined) {
  3680. return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
  3681. } else {
  3682. return intArrayFromString(xhr.responseText || '', true);
  3683. }
  3684. });
  3685. var lazyArray = this;
  3686. lazyArray.setDataGetter(function(chunkNum) {
  3687. var start = chunkNum * chunkSize;
  3688. var end = (chunkNum+1) * chunkSize - 1; // including this byte
  3689. end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
  3690. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
  3691. lazyArray.chunks[chunkNum] = doXHR(start, end);
  3692. }
  3693. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
  3694. return lazyArray.chunks[chunkNum];
  3695. });
  3696. if (usesGzip || !datalength) {
  3697. // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
  3698. chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
  3699. datalength = this.getter(0).length;
  3700. chunkSize = datalength;
  3701. out("LazyFiles on gzip forces download of the whole file when length is accessed");
  3702. }
  3703. this._length = datalength;
  3704. this._chunkSize = chunkSize;
  3705. this.lengthKnown = true;
  3706. };
  3707. if (typeof XMLHttpRequest !== 'undefined') {
  3708. if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
  3709. var lazyArray = new LazyUint8Array();
  3710. Object.defineProperties(lazyArray, {
  3711. length: {
  3712. get: /** @this{Object} */ function() {
  3713. if(!this.lengthKnown) {
  3714. this.cacheLength();
  3715. }
  3716. return this._length;
  3717. }
  3718. },
  3719. chunkSize: {
  3720. get: /** @this{Object} */ function() {
  3721. if(!this.lengthKnown) {
  3722. this.cacheLength();
  3723. }
  3724. return this._chunkSize;
  3725. }
  3726. }
  3727. });
  3728. var properties = { isDevice: false, contents: lazyArray };
  3729. } else {
  3730. var properties = { isDevice: false, url: url };
  3731. }
  3732. var node = FS.createFile(parent, name, properties, canRead, canWrite);
  3733. // This is a total hack, but I want to get this lazy file code out of the
  3734. // core of MEMFS. If we want to keep this lazy file concept I feel it should
  3735. // be its own thin LAZYFS proxying calls to MEMFS.
  3736. if (properties.contents) {
  3737. node.contents = properties.contents;
  3738. } else if (properties.url) {
  3739. node.contents = null;
  3740. node.url = properties.url;
  3741. }
  3742. // Add a function that defers querying the file size until it is asked the first time.
  3743. Object.defineProperties(node, {
  3744. usedBytes: {
  3745. get: /** @this {FSNode} */ function() { return this.contents.length; }
  3746. }
  3747. });
  3748. // override each stream op with one that tries to force load the lazy file first
  3749. var stream_ops = {};
  3750. var keys = Object.keys(node.stream_ops);
  3751. keys.forEach(function(key) {
  3752. var fn = node.stream_ops[key];
  3753. stream_ops[key] = function forceLoadLazyFile() {
  3754. if (!FS.forceLoadFile(node)) {
  3755. throw new FS.ErrnoError(29);
  3756. }
  3757. return fn.apply(null, arguments);
  3758. };
  3759. });
  3760. // use a custom read function
  3761. stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
  3762. if (!FS.forceLoadFile(node)) {
  3763. throw new FS.ErrnoError(29);
  3764. }
  3765. var contents = stream.node.contents;
  3766. if (position >= contents.length)
  3767. return 0;
  3768. var size = Math.min(contents.length - position, length);
  3769. assert(size >= 0);
  3770. if (contents.slice) { // normal array
  3771. for (var i = 0; i < size; i++) {
  3772. buffer[offset + i] = contents[position + i];
  3773. }
  3774. } else {
  3775. for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
  3776. buffer[offset + i] = contents.get(position + i);
  3777. }
  3778. }
  3779. return size;
  3780. };
  3781. node.stream_ops = stream_ops;
  3782. return node;
  3783. },createPreloadedFile:function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
  3784. Browser.init(); // XXX perhaps this method should move onto Browser?
  3785. // TODO we should allow people to just pass in a complete filename instead
  3786. // of parent and name being that we just join them anyways
  3787. var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
  3788. var dep = getUniqueRunDependency('cp ' + fullname); // might have several active requests for the same fullname
  3789. function processData(byteArray) {
  3790. function finish(byteArray) {
  3791. if (preFinish) preFinish();
  3792. if (!dontCreateFile) {
  3793. FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
  3794. }
  3795. if (onload) onload();
  3796. removeRunDependency(dep);
  3797. }
  3798. var handled = false;
  3799. Module['preloadPlugins'].forEach(function(plugin) {
  3800. if (handled) return;
  3801. if (plugin['canHandle'](fullname)) {
  3802. plugin['handle'](byteArray, fullname, finish, function() {
  3803. if (onerror) onerror();
  3804. removeRunDependency(dep);
  3805. });
  3806. handled = true;
  3807. }
  3808. });
  3809. if (!handled) finish(byteArray);
  3810. }
  3811. addRunDependency(dep);
  3812. if (typeof url == 'string') {
  3813. Browser.asyncLoad(url, function(byteArray) {
  3814. processData(byteArray);
  3815. }, onerror);
  3816. } else {
  3817. processData(url);
  3818. }
  3819. },indexedDB:function() {
  3820. return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
  3821. },DB_NAME:function() {
  3822. return 'EM_FS_' + window.location.pathname;
  3823. },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(paths, onload, onerror) {
  3824. onload = onload || function(){};
  3825. onerror = onerror || function(){};
  3826. var indexedDB = FS.indexedDB();
  3827. try {
  3828. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3829. } catch (e) {
  3830. return onerror(e);
  3831. }
  3832. openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
  3833. out('creating db');
  3834. var db = openRequest.result;
  3835. db.createObjectStore(FS.DB_STORE_NAME);
  3836. };
  3837. openRequest.onsuccess = function openRequest_onsuccess() {
  3838. var db = openRequest.result;
  3839. var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
  3840. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3841. var ok = 0, fail = 0, total = paths.length;
  3842. function finish() {
  3843. if (fail == 0) onload(); else onerror();
  3844. }
  3845. paths.forEach(function(path) {
  3846. var putRequest = files.put(FS.analyzePath(path).object.contents, path);
  3847. putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
  3848. putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3849. });
  3850. transaction.onerror = onerror;
  3851. };
  3852. openRequest.onerror = onerror;
  3853. },loadFilesFromDB:function(paths, onload, onerror) {
  3854. onload = onload || function(){};
  3855. onerror = onerror || function(){};
  3856. var indexedDB = FS.indexedDB();
  3857. try {
  3858. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3859. } catch (e) {
  3860. return onerror(e);
  3861. }
  3862. openRequest.onupgradeneeded = onerror; // no database to load from
  3863. openRequest.onsuccess = function openRequest_onsuccess() {
  3864. var db = openRequest.result;
  3865. try {
  3866. var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
  3867. } catch(e) {
  3868. onerror(e);
  3869. return;
  3870. }
  3871. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3872. var ok = 0, fail = 0, total = paths.length;
  3873. function finish() {
  3874. if (fail == 0) onload(); else onerror();
  3875. }
  3876. paths.forEach(function(path) {
  3877. var getRequest = files.get(path);
  3878. getRequest.onsuccess = function getRequest_onsuccess() {
  3879. if (FS.analyzePath(path).exists) {
  3880. FS.unlink(path);
  3881. }
  3882. FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
  3883. ok++;
  3884. if (ok + fail == total) finish();
  3885. };
  3886. getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3887. });
  3888. transaction.onerror = onerror;
  3889. };
  3890. openRequest.onerror = onerror;
  3891. }};var SYSCALLS={mappings:{},DEFAULT_POLLMASK:5,umask:511,calculateAt:function(dirfd, path) {
  3892. if (path[0] !== '/') {
  3893. // relative path
  3894. var dir;
  3895. if (dirfd === -100) {
  3896. dir = FS.cwd();
  3897. } else {
  3898. var dirstream = FS.getStream(dirfd);
  3899. if (!dirstream) throw new FS.ErrnoError(8);
  3900. dir = dirstream.path;
  3901. }
  3902. path = PATH.join2(dir, path);
  3903. }
  3904. return path;
  3905. },doStat:function(func, path, buf) {
  3906. try {
  3907. var stat = func(path);
  3908. } catch (e) {
  3909. if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
  3910. // an error occurred while trying to look up the path; we should just report ENOTDIR
  3911. return -54;
  3912. }
  3913. throw e;
  3914. }
  3915. HEAP32[((buf)>>2)]=stat.dev;
  3916. HEAP32[(((buf)+(4))>>2)]=0;
  3917. HEAP32[(((buf)+(8))>>2)]=stat.ino;
  3918. HEAP32[(((buf)+(12))>>2)]=stat.mode;
  3919. HEAP32[(((buf)+(16))>>2)]=stat.nlink;
  3920. HEAP32[(((buf)+(20))>>2)]=stat.uid;
  3921. HEAP32[(((buf)+(24))>>2)]=stat.gid;
  3922. HEAP32[(((buf)+(28))>>2)]=stat.rdev;
  3923. HEAP32[(((buf)+(32))>>2)]=0;
  3924. (tempI64 = [stat.size>>>0,(tempDouble=stat.size,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[(((buf)+(40))>>2)]=tempI64[0],HEAP32[(((buf)+(44))>>2)]=tempI64[1]);
  3925. HEAP32[(((buf)+(48))>>2)]=4096;
  3926. HEAP32[(((buf)+(52))>>2)]=stat.blocks;
  3927. HEAP32[(((buf)+(56))>>2)]=(stat.atime.getTime() / 1000)|0;
  3928. HEAP32[(((buf)+(60))>>2)]=0;
  3929. HEAP32[(((buf)+(64))>>2)]=(stat.mtime.getTime() / 1000)|0;
  3930. HEAP32[(((buf)+(68))>>2)]=0;
  3931. HEAP32[(((buf)+(72))>>2)]=(stat.ctime.getTime() / 1000)|0;
  3932. HEAP32[(((buf)+(76))>>2)]=0;
  3933. (tempI64 = [stat.ino>>>0,(tempDouble=stat.ino,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[(((buf)+(80))>>2)]=tempI64[0],HEAP32[(((buf)+(84))>>2)]=tempI64[1]);
  3934. return 0;
  3935. },doMsync:function(addr, stream, len, flags, offset) {
  3936. var buffer = HEAPU8.slice(addr, addr + len);
  3937. FS.msync(stream, buffer, offset, len, flags);
  3938. },doMkdir:function(path, mode) {
  3939. // remove a trailing slash, if one - /a/b/ has basename of '', but
  3940. // we want to create b in the context of this function
  3941. path = PATH.normalize(path);
  3942. if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
  3943. FS.mkdir(path, mode, 0);
  3944. return 0;
  3945. },doMknod:function(path, mode, dev) {
  3946. // we don't want this in the JS API as it uses mknod to create all nodes.
  3947. switch (mode & 61440) {
  3948. case 32768:
  3949. case 8192:
  3950. case 24576:
  3951. case 4096:
  3952. case 49152:
  3953. break;
  3954. default: return -28;
  3955. }
  3956. FS.mknod(path, mode, dev);
  3957. return 0;
  3958. },doReadlink:function(path, buf, bufsize) {
  3959. if (bufsize <= 0) return -28;
  3960. var ret = FS.readlink(path);
  3961. var len = Math.min(bufsize, lengthBytesUTF8(ret));
  3962. var endChar = HEAP8[buf+len];
  3963. stringToUTF8(ret, buf, bufsize+1);
  3964. // readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!)
  3965. // stringToUTF8() always appends a null byte, so restore the character under the null byte after the write.
  3966. HEAP8[buf+len] = endChar;
  3967. return len;
  3968. },doAccess:function(path, amode) {
  3969. if (amode & ~7) {
  3970. // need a valid mode
  3971. return -28;
  3972. }
  3973. var node;
  3974. var lookup = FS.lookupPath(path, { follow: true });
  3975. node = lookup.node;
  3976. if (!node) {
  3977. return -44;
  3978. }
  3979. var perms = '';
  3980. if (amode & 4) perms += 'r';
  3981. if (amode & 2) perms += 'w';
  3982. if (amode & 1) perms += 'x';
  3983. if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) {
  3984. return -2;
  3985. }
  3986. return 0;
  3987. },doDup:function(path, flags, suggestFD) {
  3988. var suggest = FS.getStream(suggestFD);
  3989. if (suggest) FS.close(suggest);
  3990. return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
  3991. },doReadv:function(stream, iov, iovcnt, offset) {
  3992. var ret = 0;
  3993. for (var i = 0; i < iovcnt; i++) {
  3994. var ptr = HEAP32[(((iov)+(i*8))>>2)];
  3995. var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
  3996. var curr = FS.read(stream, HEAP8,ptr, len, offset);
  3997. if (curr < 0) return -1;
  3998. ret += curr;
  3999. if (curr < len) break; // nothing more to read
  4000. }
  4001. return ret;
  4002. },doWritev:function(stream, iov, iovcnt, offset) {
  4003. var ret = 0;
  4004. for (var i = 0; i < iovcnt; i++) {
  4005. var ptr = HEAP32[(((iov)+(i*8))>>2)];
  4006. var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
  4007. var curr = FS.write(stream, HEAP8,ptr, len, offset);
  4008. if (curr < 0) return -1;
  4009. ret += curr;
  4010. }
  4011. return ret;
  4012. },varargs:undefined,get:function() {
  4013. assert(SYSCALLS.varargs != undefined);
  4014. SYSCALLS.varargs += 4;
  4015. var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
  4016. return ret;
  4017. },getStr:function(ptr) {
  4018. var ret = UTF8ToString(ptr);
  4019. return ret;
  4020. },getStreamFromFD:function(fd) {
  4021. var stream = FS.getStream(fd);
  4022. if (!stream) throw new FS.ErrnoError(8);
  4023. return stream;
  4024. },get64:function(low, high) {
  4025. if (low >= 0) assert(high === 0);
  4026. else assert(high === -1);
  4027. return low;
  4028. }};function ___sys_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs;
  4029. try {
  4030. var stream = SYSCALLS.getStreamFromFD(fd);
  4031. switch (cmd) {
  4032. case 0: {
  4033. var arg = SYSCALLS.get();
  4034. if (arg < 0) {
  4035. return -28;
  4036. }
  4037. var newStream;
  4038. newStream = FS.open(stream.path, stream.flags, 0, arg);
  4039. return newStream.fd;
  4040. }
  4041. case 1:
  4042. case 2:
  4043. return 0; // FD_CLOEXEC makes no sense for a single process.
  4044. case 3:
  4045. return stream.flags;
  4046. case 4: {
  4047. var arg = SYSCALLS.get();
  4048. stream.flags |= arg;
  4049. return 0;
  4050. }
  4051. case 12:
  4052. /* case 12: Currently in musl F_GETLK64 has same value as F_GETLK, so omitted to avoid duplicate case blocks. If that changes, uncomment this */ {
  4053. var arg = SYSCALLS.get();
  4054. var offset = 0;
  4055. // We're always unlocked.
  4056. HEAP16[(((arg)+(offset))>>1)]=2;
  4057. return 0;
  4058. }
  4059. case 13:
  4060. case 14:
  4061. /* case 13: Currently in musl F_SETLK64 has same value as F_SETLK, so omitted to avoid duplicate case blocks. If that changes, uncomment this */
  4062. /* case 14: Currently in musl F_SETLKW64 has same value as F_SETLKW, so omitted to avoid duplicate case blocks. If that changes, uncomment this */
  4063. return 0; // Pretend that the locking is successful.
  4064. case 16:
  4065. case 8:
  4066. return -28; // These are for sockets. We don't have them fully implemented yet.
  4067. case 9:
  4068. // musl trusts getown return values, due to a bug where they must be, as they overlap with errors. just return -1 here, so fnctl() returns that, and we set errno ourselves.
  4069. setErrNo(28);
  4070. return -1;
  4071. default: {
  4072. return -28;
  4073. }
  4074. }
  4075. } catch (e) {
  4076. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4077. return -e.errno;
  4078. }
  4079. }
  4080. function ___sys_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs;
  4081. try {
  4082. var stream = SYSCALLS.getStreamFromFD(fd);
  4083. switch (op) {
  4084. case 21509:
  4085. case 21505: {
  4086. if (!stream.tty) return -59;
  4087. return 0;
  4088. }
  4089. case 21510:
  4090. case 21511:
  4091. case 21512:
  4092. case 21506:
  4093. case 21507:
  4094. case 21508: {
  4095. if (!stream.tty) return -59;
  4096. return 0; // no-op, not actually adjusting terminal settings
  4097. }
  4098. case 21519: {
  4099. if (!stream.tty) return -59;
  4100. var argp = SYSCALLS.get();
  4101. HEAP32[((argp)>>2)]=0;
  4102. return 0;
  4103. }
  4104. case 21520: {
  4105. if (!stream.tty) return -59;
  4106. return -28; // not supported
  4107. }
  4108. case 21531: {
  4109. var argp = SYSCALLS.get();
  4110. return FS.ioctl(stream, op, argp);
  4111. }
  4112. case 21523: {
  4113. // TODO: in theory we should write to the winsize struct that gets
  4114. // passed in, but for now musl doesn't read anything on it
  4115. if (!stream.tty) return -59;
  4116. return 0;
  4117. }
  4118. case 21524: {
  4119. // TODO: technically, this ioctl call should change the window size.
  4120. // but, since emscripten doesn't have any concept of a terminal window
  4121. // yet, we'll just silently throw it away as we do TIOCGWINSZ
  4122. if (!stream.tty) return -59;
  4123. return 0;
  4124. }
  4125. default: abort('bad ioctl syscall ' + op);
  4126. }
  4127. } catch (e) {
  4128. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4129. return -e.errno;
  4130. }
  4131. }
  4132. function ___sys_open(path, flags, varargs) {SYSCALLS.varargs = varargs;
  4133. try {
  4134. var pathname = SYSCALLS.getStr(path);
  4135. var mode = SYSCALLS.get();
  4136. var stream = FS.open(pathname, flags, mode);
  4137. return stream.fd;
  4138. } catch (e) {
  4139. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4140. return -e.errno;
  4141. }
  4142. }
  4143. function ___sys_rename(old_path, new_path) {try {
  4144. old_path = SYSCALLS.getStr(old_path);
  4145. new_path = SYSCALLS.getStr(new_path);
  4146. FS.rename(old_path, new_path);
  4147. return 0;
  4148. } catch (e) {
  4149. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4150. return -e.errno;
  4151. }
  4152. }
  4153. function ___sys_rmdir(path) {try {
  4154. path = SYSCALLS.getStr(path);
  4155. FS.rmdir(path);
  4156. return 0;
  4157. } catch (e) {
  4158. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4159. return -e.errno;
  4160. }
  4161. }
  4162. function ___sys_unlink(path) {try {
  4163. path = SYSCALLS.getStr(path);
  4164. FS.unlink(path);
  4165. return 0;
  4166. } catch (e) {
  4167. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4168. return -e.errno;
  4169. }
  4170. }
  4171. var structRegistrations={};
  4172. function runDestructors(destructors) {
  4173. while (destructors.length) {
  4174. var ptr = destructors.pop();
  4175. var del = destructors.pop();
  4176. del(ptr);
  4177. }
  4178. }
  4179. function simpleReadValueFromPointer(pointer) {
  4180. return this['fromWireType'](HEAPU32[pointer >> 2]);
  4181. }
  4182. var awaitingDependencies={};
  4183. var registeredTypes={};
  4184. var typeDependencies={};
  4185. var char_0=48;
  4186. var char_9=57;function makeLegalFunctionName(name) {
  4187. if (undefined === name) {
  4188. return '_unknown';
  4189. }
  4190. name = name.replace(/[^a-zA-Z0-9_]/g, '$');
  4191. var f = name.charCodeAt(0);
  4192. if (f >= char_0 && f <= char_9) {
  4193. return '_' + name;
  4194. } else {
  4195. return name;
  4196. }
  4197. }function createNamedFunction(name, body) {
  4198. name = makeLegalFunctionName(name);
  4199. /*jshint evil:true*/
  4200. return new Function(
  4201. "body",
  4202. "return function " + name + "() {\n" +
  4203. " \"use strict\";" +
  4204. " return body.apply(this, arguments);\n" +
  4205. "};\n"
  4206. )(body);
  4207. }function extendError(baseErrorType, errorName) {
  4208. var errorClass = createNamedFunction(errorName, function(message) {
  4209. this.name = errorName;
  4210. this.message = message;
  4211. var stack = (new Error(message)).stack;
  4212. if (stack !== undefined) {
  4213. this.stack = this.toString() + '\n' +
  4214. stack.replace(/^Error(:[^\n]*)?\n/, '');
  4215. }
  4216. });
  4217. errorClass.prototype = Object.create(baseErrorType.prototype);
  4218. errorClass.prototype.constructor = errorClass;
  4219. errorClass.prototype.toString = function() {
  4220. if (this.message === undefined) {
  4221. return this.name;
  4222. } else {
  4223. return this.name + ': ' + this.message;
  4224. }
  4225. };
  4226. return errorClass;
  4227. }var InternalError=undefined;function throwInternalError(message) {
  4228. throw new InternalError(message);
  4229. }function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
  4230. myTypes.forEach(function(type) {
  4231. typeDependencies[type] = dependentTypes;
  4232. });
  4233. function onComplete(typeConverters) {
  4234. var myTypeConverters = getTypeConverters(typeConverters);
  4235. if (myTypeConverters.length !== myTypes.length) {
  4236. throwInternalError('Mismatched type converter count');
  4237. }
  4238. for (var i = 0; i < myTypes.length; ++i) {
  4239. registerType(myTypes[i], myTypeConverters[i]);
  4240. }
  4241. }
  4242. var typeConverters = new Array(dependentTypes.length);
  4243. var unregisteredTypes = [];
  4244. var registered = 0;
  4245. dependentTypes.forEach(function(dt, i) {
  4246. if (registeredTypes.hasOwnProperty(dt)) {
  4247. typeConverters[i] = registeredTypes[dt];
  4248. } else {
  4249. unregisteredTypes.push(dt);
  4250. if (!awaitingDependencies.hasOwnProperty(dt)) {
  4251. awaitingDependencies[dt] = [];
  4252. }
  4253. awaitingDependencies[dt].push(function() {
  4254. typeConverters[i] = registeredTypes[dt];
  4255. ++registered;
  4256. if (registered === unregisteredTypes.length) {
  4257. onComplete(typeConverters);
  4258. }
  4259. });
  4260. }
  4261. });
  4262. if (0 === unregisteredTypes.length) {
  4263. onComplete(typeConverters);
  4264. }
  4265. }function __embind_finalize_value_object(structType) {
  4266. var reg = structRegistrations[structType];
  4267. delete structRegistrations[structType];
  4268. var rawConstructor = reg.rawConstructor;
  4269. var rawDestructor = reg.rawDestructor;
  4270. var fieldRecords = reg.fields;
  4271. var fieldTypes = fieldRecords.map(function(field) { return field.getterReturnType; }).
  4272. concat(fieldRecords.map(function(field) { return field.setterArgumentType; }));
  4273. whenDependentTypesAreResolved([structType], fieldTypes, function(fieldTypes) {
  4274. var fields = {};
  4275. fieldRecords.forEach(function(field, i) {
  4276. var fieldName = field.fieldName;
  4277. var getterReturnType = fieldTypes[i];
  4278. var getter = field.getter;
  4279. var getterContext = field.getterContext;
  4280. var setterArgumentType = fieldTypes[i + fieldRecords.length];
  4281. var setter = field.setter;
  4282. var setterContext = field.setterContext;
  4283. fields[fieldName] = {
  4284. read: function(ptr) {
  4285. return getterReturnType['fromWireType'](
  4286. getter(getterContext, ptr));
  4287. },
  4288. write: function(ptr, o) {
  4289. var destructors = [];
  4290. setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
  4291. runDestructors(destructors);
  4292. }
  4293. };
  4294. });
  4295. return [{
  4296. name: reg.name,
  4297. 'fromWireType': function(ptr) {
  4298. var rv = {};
  4299. for (var i in fields) {
  4300. rv[i] = fields[i].read(ptr);
  4301. }
  4302. rawDestructor(ptr);
  4303. return rv;
  4304. },
  4305. 'toWireType': function(destructors, o) {
  4306. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
  4307. // assume all fields are present without checking.
  4308. for (var fieldName in fields) {
  4309. if (!(fieldName in o)) {
  4310. throw new TypeError('Missing field');
  4311. }
  4312. }
  4313. var ptr = rawConstructor();
  4314. for (fieldName in fields) {
  4315. fields[fieldName].write(ptr, o[fieldName]);
  4316. }
  4317. if (destructors !== null) {
  4318. destructors.push(rawDestructor, ptr);
  4319. }
  4320. return ptr;
  4321. },
  4322. 'argPackAdvance': 8,
  4323. 'readValueFromPointer': simpleReadValueFromPointer,
  4324. destructorFunction: rawDestructor,
  4325. }];
  4326. });
  4327. }
  4328. function getShiftFromSize(size) {
  4329. switch (size) {
  4330. case 1: return 0;
  4331. case 2: return 1;
  4332. case 4: return 2;
  4333. case 8: return 3;
  4334. default:
  4335. throw new TypeError('Unknown type size: ' + size);
  4336. }
  4337. }
  4338. function embind_init_charCodes() {
  4339. var codes = new Array(256);
  4340. for (var i = 0; i < 256; ++i) {
  4341. codes[i] = String.fromCharCode(i);
  4342. }
  4343. embind_charCodes = codes;
  4344. }var embind_charCodes=undefined;function readLatin1String(ptr) {
  4345. var ret = "";
  4346. var c = ptr;
  4347. while (HEAPU8[c]) {
  4348. ret += embind_charCodes[HEAPU8[c++]];
  4349. }
  4350. return ret;
  4351. }
  4352. var BindingError=undefined;function throwBindingError(message) {
  4353. throw new BindingError(message);
  4354. }/** @param {Object=} options */
  4355. function registerType(rawType, registeredInstance, options) {
  4356. options = options || {};
  4357. if (!('argPackAdvance' in registeredInstance)) {
  4358. throw new TypeError('registerType registeredInstance requires argPackAdvance');
  4359. }
  4360. var name = registeredInstance.name;
  4361. if (!rawType) {
  4362. throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
  4363. }
  4364. if (registeredTypes.hasOwnProperty(rawType)) {
  4365. if (options.ignoreDuplicateRegistrations) {
  4366. return;
  4367. } else {
  4368. throwBindingError("Cannot register type '" + name + "' twice");
  4369. }
  4370. }
  4371. registeredTypes[rawType] = registeredInstance;
  4372. delete typeDependencies[rawType];
  4373. if (awaitingDependencies.hasOwnProperty(rawType)) {
  4374. var callbacks = awaitingDependencies[rawType];
  4375. delete awaitingDependencies[rawType];
  4376. callbacks.forEach(function(cb) {
  4377. cb();
  4378. });
  4379. }
  4380. }function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
  4381. var shift = getShiftFromSize(size);
  4382. name = readLatin1String(name);
  4383. registerType(rawType, {
  4384. name: name,
  4385. 'fromWireType': function(wt) {
  4386. // ambiguous emscripten ABI: sometimes return values are
  4387. // true or false, and sometimes integers (0 or 1)
  4388. return !!wt;
  4389. },
  4390. 'toWireType': function(destructors, o) {
  4391. return o ? trueValue : falseValue;
  4392. },
  4393. 'argPackAdvance': 8,
  4394. 'readValueFromPointer': function(pointer) {
  4395. // TODO: if heap is fixed (like in asm.js) this could be executed outside
  4396. var heap;
  4397. if (size === 1) {
  4398. heap = HEAP8;
  4399. } else if (size === 2) {
  4400. heap = HEAP16;
  4401. } else if (size === 4) {
  4402. heap = HEAP32;
  4403. } else {
  4404. throw new TypeError("Unknown boolean type size: " + name);
  4405. }
  4406. return this['fromWireType'](heap[pointer >> shift]);
  4407. },
  4408. destructorFunction: null, // This type does not need a destructor
  4409. });
  4410. }
  4411. var emval_free_list=[];
  4412. var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle) {
  4413. if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
  4414. emval_handle_array[handle] = undefined;
  4415. emval_free_list.push(handle);
  4416. }
  4417. }
  4418. function count_emval_handles() {
  4419. var count = 0;
  4420. for (var i = 5; i < emval_handle_array.length; ++i) {
  4421. if (emval_handle_array[i] !== undefined) {
  4422. ++count;
  4423. }
  4424. }
  4425. return count;
  4426. }
  4427. function get_first_emval() {
  4428. for (var i = 5; i < emval_handle_array.length; ++i) {
  4429. if (emval_handle_array[i] !== undefined) {
  4430. return emval_handle_array[i];
  4431. }
  4432. }
  4433. return null;
  4434. }function init_emval() {
  4435. Module['count_emval_handles'] = count_emval_handles;
  4436. Module['get_first_emval'] = get_first_emval;
  4437. }function __emval_register(value) {
  4438. switch(value){
  4439. case undefined :{ return 1; }
  4440. case null :{ return 2; }
  4441. case true :{ return 3; }
  4442. case false :{ return 4; }
  4443. default:{
  4444. var handle = emval_free_list.length ?
  4445. emval_free_list.pop() :
  4446. emval_handle_array.length;
  4447. emval_handle_array[handle] = {refcount: 1, value: value};
  4448. return handle;
  4449. }
  4450. }
  4451. }function __embind_register_emval(rawType, name) {
  4452. name = readLatin1String(name);
  4453. registerType(rawType, {
  4454. name: name,
  4455. 'fromWireType': function(handle) {
  4456. var rv = emval_handle_array[handle].value;
  4457. __emval_decref(handle);
  4458. return rv;
  4459. },
  4460. 'toWireType': function(destructors, value) {
  4461. return __emval_register(value);
  4462. },
  4463. 'argPackAdvance': 8,
  4464. 'readValueFromPointer': simpleReadValueFromPointer,
  4465. destructorFunction: null, // This type does not need a destructor
  4466. // TODO: do we need a deleteObject here? write a test where
  4467. // emval is passed into JS via an interface
  4468. });
  4469. }
  4470. function _embind_repr(v) {
  4471. if (v === null) {
  4472. return 'null';
  4473. }
  4474. var t = typeof v;
  4475. if (t === 'object' || t === 'array' || t === 'function') {
  4476. return v.toString();
  4477. } else {
  4478. return '' + v;
  4479. }
  4480. }
  4481. function floatReadValueFromPointer(name, shift) {
  4482. switch (shift) {
  4483. case 2: return function(pointer) {
  4484. return this['fromWireType'](HEAPF32[pointer >> 2]);
  4485. };
  4486. case 3: return function(pointer) {
  4487. return this['fromWireType'](HEAPF64[pointer >> 3]);
  4488. };
  4489. default:
  4490. throw new TypeError("Unknown float type: " + name);
  4491. }
  4492. }function __embind_register_float(rawType, name, size) {
  4493. var shift = getShiftFromSize(size);
  4494. name = readLatin1String(name);
  4495. registerType(rawType, {
  4496. name: name,
  4497. 'fromWireType': function(value) {
  4498. return value;
  4499. },
  4500. 'toWireType': function(destructors, value) {
  4501. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
  4502. // avoid the following if() and assume value is of proper type.
  4503. if (typeof value !== "number" && typeof value !== "boolean") {
  4504. throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
  4505. }
  4506. return value;
  4507. },
  4508. 'argPackAdvance': 8,
  4509. 'readValueFromPointer': floatReadValueFromPointer(name, shift),
  4510. destructorFunction: null, // This type does not need a destructor
  4511. });
  4512. }
  4513. function new_(constructor, argumentList) {
  4514. if (!(constructor instanceof Function)) {
  4515. throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
  4516. }
  4517. /*
  4518. * Previously, the following line was just:
  4519. function dummy() {};
  4520. * Unfortunately, Chrome was preserving 'dummy' as the object's name, even though at creation, the 'dummy' has the
  4521. * correct constructor name. Thus, objects created with IMVU.new would show up in the debugger as 'dummy', which
  4522. * isn't very helpful. Using IMVU.createNamedFunction addresses the issue. Doublely-unfortunately, there's no way
  4523. * to write a test for this behavior. -NRD 2013.02.22
  4524. */
  4525. var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
  4526. dummy.prototype = constructor.prototype;
  4527. var obj = new dummy;
  4528. var r = constructor.apply(obj, argumentList);
  4529. return (r instanceof Object) ? r : obj;
  4530. }function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {
  4531. // humanName: a human-readable string name for the function to be generated.
  4532. // argTypes: An array that contains the embind type objects for all types in the function signature.
  4533. // argTypes[0] is the type object for the function return value.
  4534. // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
  4535. // argTypes[2...] are the actual function parameters.
  4536. // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
  4537. // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
  4538. // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
  4539. var argCount = argTypes.length;
  4540. if (argCount < 2) {
  4541. throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
  4542. }
  4543. var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
  4544. // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
  4545. // TODO: This omits argument count check - enable only at -O3 or similar.
  4546. // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
  4547. // return FUNCTION_TABLE[fn];
  4548. // }
  4549. // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
  4550. // TODO: Remove this completely once all function invokers are being dynamically generated.
  4551. var needsDestructorStack = false;
  4552. for(var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
  4553. if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
  4554. needsDestructorStack = true;
  4555. break;
  4556. }
  4557. }
  4558. var returns = (argTypes[0].name !== "void");
  4559. var argsList = "";
  4560. var argsListWired = "";
  4561. for(var i = 0; i < argCount - 2; ++i) {
  4562. argsList += (i!==0?", ":"")+"arg"+i;
  4563. argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
  4564. }
  4565. var invokerFnBody =
  4566. "return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" +
  4567. "if (arguments.length !== "+(argCount - 2)+") {\n" +
  4568. "throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" +
  4569. "}\n";
  4570. if (needsDestructorStack) {
  4571. invokerFnBody +=
  4572. "var destructors = [];\n";
  4573. }
  4574. var dtorStack = needsDestructorStack ? "destructors" : "null";
  4575. var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
  4576. var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
  4577. if (isClassMethodFunc) {
  4578. invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
  4579. }
  4580. for(var i = 0; i < argCount - 2; ++i) {
  4581. invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
  4582. args1.push("argType"+i);
  4583. args2.push(argTypes[i+2]);
  4584. }
  4585. if (isClassMethodFunc) {
  4586. argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
  4587. }
  4588. invokerFnBody +=
  4589. (returns?"var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
  4590. if (needsDestructorStack) {
  4591. invokerFnBody += "runDestructors(destructors);\n";
  4592. } else {
  4593. for(var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
  4594. var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
  4595. if (argTypes[i].destructorFunction !== null) {
  4596. invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
  4597. args1.push(paramName+"_dtor");
  4598. args2.push(argTypes[i].destructorFunction);
  4599. }
  4600. }
  4601. }
  4602. if (returns) {
  4603. invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
  4604. "return ret;\n";
  4605. } else {
  4606. }
  4607. invokerFnBody += "}\n";
  4608. args1.push(invokerFnBody);
  4609. var invokerFunction = new_(Function, args1).apply(null, args2);
  4610. return invokerFunction;
  4611. }
  4612. function ensureOverloadTable(proto, methodName, humanName) {
  4613. if (undefined === proto[methodName].overloadTable) {
  4614. var prevFunc = proto[methodName];
  4615. // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
  4616. proto[methodName] = function() {
  4617. // TODO This check can be removed in -O3 level "unsafe" optimizations.
  4618. if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
  4619. throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
  4620. }
  4621. return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
  4622. };
  4623. // Move the previous function into the overload table.
  4624. proto[methodName].overloadTable = [];
  4625. proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
  4626. }
  4627. }/** @param {number=} numArguments */
  4628. function exposePublicSymbol(name, value, numArguments) {
  4629. if (Module.hasOwnProperty(name)) {
  4630. if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
  4631. throwBindingError("Cannot register public name '" + name + "' twice");
  4632. }
  4633. // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
  4634. // that routes between the two.
  4635. ensureOverloadTable(Module, name, name);
  4636. if (Module.hasOwnProperty(numArguments)) {
  4637. throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
  4638. }
  4639. // Add the new function into the overload table.
  4640. Module[name].overloadTable[numArguments] = value;
  4641. }
  4642. else {
  4643. Module[name] = value;
  4644. if (undefined !== numArguments) {
  4645. Module[name].numArguments = numArguments;
  4646. }
  4647. }
  4648. }
  4649. function heap32VectorToArray(count, firstElement) {
  4650. var array = [];
  4651. for (var i = 0; i < count; i++) {
  4652. array.push(HEAP32[(firstElement >> 2) + i]);
  4653. }
  4654. return array;
  4655. }
  4656. /** @param {number=} numArguments */
  4657. function replacePublicSymbol(name, value, numArguments) {
  4658. if (!Module.hasOwnProperty(name)) {
  4659. throwInternalError('Replacing nonexistant public symbol');
  4660. }
  4661. // If there's an overload table for this symbol, replace the symbol in the overload table instead.
  4662. if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
  4663. Module[name].overloadTable[numArguments] = value;
  4664. }
  4665. else {
  4666. Module[name] = value;
  4667. Module[name].argCount = numArguments;
  4668. }
  4669. }
  4670. function embind__requireFunction(signature, rawFunction) {
  4671. signature = readLatin1String(signature);
  4672. function makeDynCaller(dynCall) {
  4673. var args = [];
  4674. for (var i = 1; i < signature.length; ++i) {
  4675. args.push('a' + i);
  4676. }
  4677. var name = 'dynCall_' + signature + '_' + rawFunction;
  4678. var body = 'return function ' + name + '(' + args.join(', ') + ') {\n';
  4679. body += ' return dynCall(rawFunction' + (args.length ? ', ' : '') + args.join(', ') + ');\n';
  4680. body += '};\n';
  4681. return (new Function('dynCall', 'rawFunction', body))(dynCall, rawFunction);
  4682. }
  4683. var dc = Module['dynCall_' + signature];
  4684. var fp = makeDynCaller(dc);
  4685. if (typeof fp !== "function") {
  4686. throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
  4687. }
  4688. return fp;
  4689. }
  4690. var UnboundTypeError=undefined;
  4691. function getTypeName(type) {
  4692. var ptr = ___getTypeName(type);
  4693. var rv = readLatin1String(ptr);
  4694. _free(ptr);
  4695. return rv;
  4696. }function throwUnboundTypeError(message, types) {
  4697. var unboundTypes = [];
  4698. var seen = {};
  4699. function visit(type) {
  4700. if (seen[type]) {
  4701. return;
  4702. }
  4703. if (registeredTypes[type]) {
  4704. return;
  4705. }
  4706. if (typeDependencies[type]) {
  4707. typeDependencies[type].forEach(visit);
  4708. return;
  4709. }
  4710. unboundTypes.push(type);
  4711. seen[type] = true;
  4712. }
  4713. types.forEach(visit);
  4714. throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
  4715. }function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn) {
  4716. var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
  4717. name = readLatin1String(name);
  4718. rawInvoker = embind__requireFunction(signature, rawInvoker);
  4719. exposePublicSymbol(name, function() {
  4720. throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes);
  4721. }, argCount - 1);
  4722. whenDependentTypesAreResolved([], argTypes, function(argTypes) {
  4723. var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
  4724. replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn), argCount - 1);
  4725. return [];
  4726. });
  4727. }
  4728. function integerReadValueFromPointer(name, shift, signed) {
  4729. // integers are quite common, so generate very specialized functions
  4730. switch (shift) {
  4731. case 0: return signed ?
  4732. function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
  4733. function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
  4734. case 1: return signed ?
  4735. function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
  4736. function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
  4737. case 2: return signed ?
  4738. function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
  4739. function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
  4740. default:
  4741. throw new TypeError("Unknown integer type: " + name);
  4742. }
  4743. }function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
  4744. name = readLatin1String(name);
  4745. if (maxRange === -1) { // LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come out as 'i32 -1'. Always treat those as max u32.
  4746. maxRange = 4294967295;
  4747. }
  4748. var shift = getShiftFromSize(size);
  4749. var fromWireType = function(value) {
  4750. return value;
  4751. };
  4752. if (minRange === 0) {
  4753. var bitshift = 32 - 8*size;
  4754. fromWireType = function(value) {
  4755. return (value << bitshift) >>> bitshift;
  4756. };
  4757. }
  4758. var isUnsignedType = (name.indexOf('unsigned') != -1);
  4759. registerType(primitiveType, {
  4760. name: name,
  4761. 'fromWireType': fromWireType,
  4762. 'toWireType': function(destructors, value) {
  4763. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
  4764. // avoid the following two if()s and assume value is of proper type.
  4765. if (typeof value !== "number" && typeof value !== "boolean") {
  4766. throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
  4767. }
  4768. if (value < minRange || value > maxRange) {
  4769. throw new TypeError('Passing a number "' + _embind_repr(value) + '" from JS side to C/C++ side to an argument of type "' + name + '", which is outside the valid range [' + minRange + ', ' + maxRange + ']!');
  4770. }
  4771. return isUnsignedType ? (value >>> 0) : (value | 0);
  4772. },
  4773. 'argPackAdvance': 8,
  4774. 'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
  4775. destructorFunction: null, // This type does not need a destructor
  4776. });
  4777. }
  4778. function __embind_register_memory_view(rawType, dataTypeIndex, name) {
  4779. var typeMapping = [
  4780. Int8Array,
  4781. Uint8Array,
  4782. Int16Array,
  4783. Uint16Array,
  4784. Int32Array,
  4785. Uint32Array,
  4786. Float32Array,
  4787. Float64Array,
  4788. ];
  4789. var TA = typeMapping[dataTypeIndex];
  4790. function decodeMemoryView(handle) {
  4791. handle = handle >> 2;
  4792. var heap = HEAPU32;
  4793. var size = heap[handle]; // in elements
  4794. var data = heap[handle + 1]; // byte offset into emscripten heap
  4795. return new TA(buffer, data, size);
  4796. }
  4797. name = readLatin1String(name);
  4798. registerType(rawType, {
  4799. name: name,
  4800. 'fromWireType': decodeMemoryView,
  4801. 'argPackAdvance': 8,
  4802. 'readValueFromPointer': decodeMemoryView,
  4803. }, {
  4804. ignoreDuplicateRegistrations: true,
  4805. });
  4806. }
  4807. function __embind_register_std_string(rawType, name) {
  4808. name = readLatin1String(name);
  4809. var stdStringIsUTF8
  4810. //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
  4811. = (name === "std::string");
  4812. registerType(rawType, {
  4813. name: name,
  4814. 'fromWireType': function(value) {
  4815. var length = HEAPU32[value >> 2];
  4816. var str;
  4817. if (stdStringIsUTF8) {
  4818. var decodeStartPtr = value + 4;
  4819. // Looping here to support possible embedded '0' bytes
  4820. for (var i = 0; i <= length; ++i) {
  4821. var currentBytePtr = value + 4 + i;
  4822. if (HEAPU8[currentBytePtr] == 0 || i == length) {
  4823. var maxRead = currentBytePtr - decodeStartPtr;
  4824. var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
  4825. if (str === undefined) {
  4826. str = stringSegment;
  4827. } else {
  4828. str += String.fromCharCode(0);
  4829. str += stringSegment;
  4830. }
  4831. decodeStartPtr = currentBytePtr + 1;
  4832. }
  4833. }
  4834. } else {
  4835. var a = new Array(length);
  4836. for (var i = 0; i < length; ++i) {
  4837. a[i] = String.fromCharCode(HEAPU8[value + 4 + i]);
  4838. }
  4839. str = a.join('');
  4840. }
  4841. _free(value);
  4842. return str;
  4843. },
  4844. 'toWireType': function(destructors, value) {
  4845. if (value instanceof ArrayBuffer) {
  4846. value = new Uint8Array(value);
  4847. }
  4848. var getLength;
  4849. var valueIsOfTypeString = (typeof value === 'string');
  4850. if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
  4851. throwBindingError('Cannot pass non-string to std::string');
  4852. }
  4853. if (stdStringIsUTF8 && valueIsOfTypeString) {
  4854. getLength = function() {return lengthBytesUTF8(value);};
  4855. } else {
  4856. getLength = function() {return value.length;};
  4857. }
  4858. // assumes 4-byte alignment
  4859. var length = getLength();
  4860. var ptr = _malloc(4 + length + 1);
  4861. HEAPU32[ptr >> 2] = length;
  4862. if (stdStringIsUTF8 && valueIsOfTypeString) {
  4863. stringToUTF8(value, ptr + 4, length + 1);
  4864. } else {
  4865. if (valueIsOfTypeString) {
  4866. for (var i = 0; i < length; ++i) {
  4867. var charCode = value.charCodeAt(i);
  4868. if (charCode > 255) {
  4869. _free(ptr);
  4870. throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
  4871. }
  4872. HEAPU8[ptr + 4 + i] = charCode;
  4873. }
  4874. } else {
  4875. for (var i = 0; i < length; ++i) {
  4876. HEAPU8[ptr + 4 + i] = value[i];
  4877. }
  4878. }
  4879. }
  4880. if (destructors !== null) {
  4881. destructors.push(_free, ptr);
  4882. }
  4883. return ptr;
  4884. },
  4885. 'argPackAdvance': 8,
  4886. 'readValueFromPointer': simpleReadValueFromPointer,
  4887. destructorFunction: function(ptr) { _free(ptr); },
  4888. });
  4889. }
  4890. function __embind_register_std_wstring(rawType, charSize, name) {
  4891. name = readLatin1String(name);
  4892. var decodeString, encodeString, getHeap, lengthBytesUTF, shift;
  4893. if (charSize === 2) {
  4894. decodeString = UTF16ToString;
  4895. encodeString = stringToUTF16;
  4896. lengthBytesUTF = lengthBytesUTF16;
  4897. getHeap = function() { return HEAPU16; };
  4898. shift = 1;
  4899. } else if (charSize === 4) {
  4900. decodeString = UTF32ToString;
  4901. encodeString = stringToUTF32;
  4902. lengthBytesUTF = lengthBytesUTF32;
  4903. getHeap = function() { return HEAPU32; };
  4904. shift = 2;
  4905. }
  4906. registerType(rawType, {
  4907. name: name,
  4908. 'fromWireType': function(value) {
  4909. // Code mostly taken from _embind_register_std_string fromWireType
  4910. var length = HEAPU32[value >> 2];
  4911. var HEAP = getHeap();
  4912. var str;
  4913. var decodeStartPtr = value + 4;
  4914. // Looping here to support possible embedded '0' bytes
  4915. for (var i = 0; i <= length; ++i) {
  4916. var currentBytePtr = value + 4 + i * charSize;
  4917. if (HEAP[currentBytePtr >> shift] == 0 || i == length) {
  4918. var maxReadBytes = currentBytePtr - decodeStartPtr;
  4919. var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
  4920. if (str === undefined) {
  4921. str = stringSegment;
  4922. } else {
  4923. str += String.fromCharCode(0);
  4924. str += stringSegment;
  4925. }
  4926. decodeStartPtr = currentBytePtr + charSize;
  4927. }
  4928. }
  4929. _free(value);
  4930. return str;
  4931. },
  4932. 'toWireType': function(destructors, value) {
  4933. if (!(typeof value === 'string')) {
  4934. throwBindingError('Cannot pass non-string to C++ string type ' + name);
  4935. }
  4936. // assumes 4-byte alignment
  4937. var length = lengthBytesUTF(value);
  4938. var ptr = _malloc(4 + length + charSize);
  4939. HEAPU32[ptr >> 2] = length >> shift;
  4940. encodeString(value, ptr + 4, length + charSize);
  4941. if (destructors !== null) {
  4942. destructors.push(_free, ptr);
  4943. }
  4944. return ptr;
  4945. },
  4946. 'argPackAdvance': 8,
  4947. 'readValueFromPointer': simpleReadValueFromPointer,
  4948. destructorFunction: function(ptr) { _free(ptr); },
  4949. });
  4950. }
  4951. function __embind_register_value_object(
  4952. rawType,
  4953. name,
  4954. constructorSignature,
  4955. rawConstructor,
  4956. destructorSignature,
  4957. rawDestructor
  4958. ) {
  4959. structRegistrations[rawType] = {
  4960. name: readLatin1String(name),
  4961. rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
  4962. rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
  4963. fields: [],
  4964. };
  4965. }
  4966. function __embind_register_value_object_field(
  4967. structType,
  4968. fieldName,
  4969. getterReturnType,
  4970. getterSignature,
  4971. getter,
  4972. getterContext,
  4973. setterArgumentType,
  4974. setterSignature,
  4975. setter,
  4976. setterContext
  4977. ) {
  4978. structRegistrations[structType].fields.push({
  4979. fieldName: readLatin1String(fieldName),
  4980. getterReturnType: getterReturnType,
  4981. getter: embind__requireFunction(getterSignature, getter),
  4982. getterContext: getterContext,
  4983. setterArgumentType: setterArgumentType,
  4984. setter: embind__requireFunction(setterSignature, setter),
  4985. setterContext: setterContext,
  4986. });
  4987. }
  4988. function __embind_register_void(rawType, name) {
  4989. name = readLatin1String(name);
  4990. registerType(rawType, {
  4991. isVoid: true, // void return values can be optimized out sometimes
  4992. name: name,
  4993. 'argPackAdvance': 0,
  4994. 'fromWireType': function() {
  4995. return undefined;
  4996. },
  4997. 'toWireType': function(destructors, o) {
  4998. // TODO: assert if anything else is given?
  4999. return undefined;
  5000. },
  5001. });
  5002. }
  5003. function _emscripten_get_sbrk_ptr() {
  5004. return 295216;
  5005. }
  5006. function _emscripten_memcpy_big(dest, src, num) {
  5007. HEAPU8.copyWithin(dest, src, src + num);
  5008. }
  5009. function _emscripten_get_heap_size() {
  5010. return HEAPU8.length;
  5011. }
  5012. function abortOnCannotGrowMemory(requestedSize) {
  5013. abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -s INITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ');
  5014. }function _emscripten_resize_heap(requestedSize) {
  5015. requestedSize = requestedSize >>> 0;
  5016. abortOnCannotGrowMemory(requestedSize);
  5017. }
  5018. function _fd_close(fd) {try {
  5019. var stream = SYSCALLS.getStreamFromFD(fd);
  5020. FS.close(stream);
  5021. return 0;
  5022. } catch (e) {
  5023. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  5024. return e.errno;
  5025. }
  5026. }
  5027. function _fd_read(fd, iov, iovcnt, pnum) {try {
  5028. var stream = SYSCALLS.getStreamFromFD(fd);
  5029. var num = SYSCALLS.doReadv(stream, iov, iovcnt);
  5030. HEAP32[((pnum)>>2)]=num
  5031. return 0;
  5032. } catch (e) {
  5033. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  5034. return e.errno;
  5035. }
  5036. }
  5037. function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {try {
  5038. var stream = SYSCALLS.getStreamFromFD(fd);
  5039. var HIGH_OFFSET = 0x100000000; // 2^32
  5040. // use an unsigned operator on low and shift high by 32-bits
  5041. var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0);
  5042. var DOUBLE_LIMIT = 0x20000000000000; // 2^53
  5043. // we also check for equality since DOUBLE_LIMIT + 1 == DOUBLE_LIMIT
  5044. if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) {
  5045. return -61;
  5046. }
  5047. FS.llseek(stream, offset, whence);
  5048. (tempI64 = [stream.position>>>0,(tempDouble=stream.position,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((newOffset)>>2)]=tempI64[0],HEAP32[(((newOffset)+(4))>>2)]=tempI64[1]);
  5049. if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
  5050. return 0;
  5051. } catch (e) {
  5052. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  5053. return e.errno;
  5054. }
  5055. }
  5056. function _fd_write(fd, iov, iovcnt, pnum) {try {
  5057. var stream = SYSCALLS.getStreamFromFD(fd);
  5058. var num = SYSCALLS.doWritev(stream, iov, iovcnt);
  5059. HEAP32[((pnum)>>2)]=num
  5060. return 0;
  5061. } catch (e) {
  5062. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  5063. return e.errno;
  5064. }
  5065. }
  5066. function _getTempRet0() {
  5067. return (getTempRet0() | 0);
  5068. }
  5069. function _gettimeofday(ptr) {
  5070. var now = Date.now();
  5071. HEAP32[((ptr)>>2)]=(now/1000)|0; // seconds
  5072. HEAP32[(((ptr)+(4))>>2)]=((now % 1000)*1000)|0; // microseconds
  5073. return 0;
  5074. }
  5075. var ___tm_current=295232;
  5076. var ___tm_timezone=(stringToUTF8("GMT", 295280, 4), 295280);
  5077. function _tzset() {
  5078. // TODO: Use (malleable) environment variables instead of system settings.
  5079. if (_tzset.called) return;
  5080. _tzset.called = true;
  5081. // timezone is specified as seconds west of UTC ("The external variable
  5082. // `timezone` shall be set to the difference, in seconds, between
  5083. // Coordinated Universal Time (UTC) and local standard time."), the same
  5084. // as returned by getTimezoneOffset().
  5085. // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
  5086. HEAP32[((__get_timezone())>>2)]=(new Date()).getTimezoneOffset() * 60;
  5087. var currentYear = new Date().getFullYear();
  5088. var winter = new Date(currentYear, 0, 1);
  5089. var summer = new Date(currentYear, 6, 1);
  5090. HEAP32[((__get_daylight())>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset());
  5091. function extractZone(date) {
  5092. var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
  5093. return match ? match[1] : "GMT";
  5094. };
  5095. var winterName = extractZone(winter);
  5096. var summerName = extractZone(summer);
  5097. var winterNamePtr = allocateUTF8(winterName);
  5098. var summerNamePtr = allocateUTF8(summerName);
  5099. if (summer.getTimezoneOffset() < winter.getTimezoneOffset()) {
  5100. // Northern hemisphere
  5101. HEAP32[((__get_tzname())>>2)]=winterNamePtr;
  5102. HEAP32[(((__get_tzname())+(4))>>2)]=summerNamePtr;
  5103. } else {
  5104. HEAP32[((__get_tzname())>>2)]=summerNamePtr;
  5105. HEAP32[(((__get_tzname())+(4))>>2)]=winterNamePtr;
  5106. }
  5107. }function _localtime_r(time, tmPtr) {
  5108. _tzset();
  5109. var date = new Date(HEAP32[((time)>>2)]*1000);
  5110. HEAP32[((tmPtr)>>2)]=date.getSeconds();
  5111. HEAP32[(((tmPtr)+(4))>>2)]=date.getMinutes();
  5112. HEAP32[(((tmPtr)+(8))>>2)]=date.getHours();
  5113. HEAP32[(((tmPtr)+(12))>>2)]=date.getDate();
  5114. HEAP32[(((tmPtr)+(16))>>2)]=date.getMonth();
  5115. HEAP32[(((tmPtr)+(20))>>2)]=date.getFullYear()-1900;
  5116. HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
  5117. var start = new Date(date.getFullYear(), 0, 1);
  5118. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  5119. HEAP32[(((tmPtr)+(28))>>2)]=yday;
  5120. HEAP32[(((tmPtr)+(36))>>2)]=-(date.getTimezoneOffset() * 60);
  5121. // Attention: DST is in December in South, and some regions don't have DST at all.
  5122. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  5123. var winterOffset = start.getTimezoneOffset();
  5124. var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
  5125. HEAP32[(((tmPtr)+(32))>>2)]=dst;
  5126. var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)];
  5127. HEAP32[(((tmPtr)+(40))>>2)]=zonePtr;
  5128. return tmPtr;
  5129. }function _localtime(time) {
  5130. return _localtime_r(time, ___tm_current);
  5131. }
  5132. function _mktime(tmPtr) {
  5133. _tzset();
  5134. var date = new Date(HEAP32[(((tmPtr)+(20))>>2)] + 1900,
  5135. HEAP32[(((tmPtr)+(16))>>2)],
  5136. HEAP32[(((tmPtr)+(12))>>2)],
  5137. HEAP32[(((tmPtr)+(8))>>2)],
  5138. HEAP32[(((tmPtr)+(4))>>2)],
  5139. HEAP32[((tmPtr)>>2)],
  5140. 0);
  5141. // There's an ambiguous hour when the time goes back; the tm_isdst field is
  5142. // used to disambiguate it. Date() basically guesses, so we fix it up if it
  5143. // guessed wrong, or fill in tm_isdst with the guess if it's -1.
  5144. var dst = HEAP32[(((tmPtr)+(32))>>2)];
  5145. var guessedOffset = date.getTimezoneOffset();
  5146. var start = new Date(date.getFullYear(), 0, 1);
  5147. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  5148. var winterOffset = start.getTimezoneOffset();
  5149. var dstOffset = Math.min(winterOffset, summerOffset); // DST is in December in South
  5150. if (dst < 0) {
  5151. // Attention: some regions don't have DST at all.
  5152. HEAP32[(((tmPtr)+(32))>>2)]=Number(summerOffset != winterOffset && dstOffset == guessedOffset);
  5153. } else if ((dst > 0) != (dstOffset == guessedOffset)) {
  5154. var nonDstOffset = Math.max(winterOffset, summerOffset);
  5155. var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
  5156. // Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
  5157. date.setTime(date.getTime() + (trueOffset - guessedOffset)*60000);
  5158. }
  5159. HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
  5160. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  5161. HEAP32[(((tmPtr)+(28))>>2)]=yday;
  5162. return (date.getTime() / 1000)|0;
  5163. }
  5164. function _pthread_create() {
  5165. return 6;
  5166. }
  5167. function _pthread_join() {}
  5168. function _pthread_mutexattr_init() {}
  5169. function _pthread_mutexattr_settype() {}
  5170. function _setTempRet0($i) {
  5171. setTempRet0(($i) | 0);
  5172. }
  5173. function _time(ptr) {
  5174. var ret = (Date.now()/1000)|0;
  5175. if (ptr) {
  5176. HEAP32[((ptr)>>2)]=ret;
  5177. }
  5178. return ret;
  5179. }
  5180. var _emscripten_get_now;if (ENVIRONMENT_IS_NODE) {
  5181. _emscripten_get_now = function() {
  5182. var t = process['hrtime']();
  5183. return t[0] * 1e3 + t[1] / 1e6;
  5184. };
  5185. } else if (typeof dateNow !== 'undefined') {
  5186. _emscripten_get_now = dateNow;
  5187. } else _emscripten_get_now = function() { return performance.now(); }
  5188. ;function _usleep(useconds) {
  5189. // int usleep(useconds_t useconds);
  5190. // http://pubs.opengroup.org/onlinepubs/000095399/functions/usleep.html
  5191. // We're single-threaded, so use a busy loop. Super-ugly.
  5192. var start = _emscripten_get_now();
  5193. while (_emscripten_get_now() - start < useconds / 1000) {
  5194. // Do nothing.
  5195. }
  5196. }
  5197. function readAsmConstArgs(sigPtr, buf) {
  5198. if (!readAsmConstArgs.array) {
  5199. readAsmConstArgs.array = [];
  5200. }
  5201. var args = readAsmConstArgs.array;
  5202. args.length = 0;
  5203. var ch;
  5204. while (ch = HEAPU8[sigPtr++]) {
  5205. if (ch === 100/*'d'*/ || ch === 102/*'f'*/) {
  5206. buf = (buf + 7) & ~7;
  5207. args.push(HEAPF64[(buf >> 3)]);
  5208. buf += 8;
  5209. } else
  5210. if (ch === 105 /*'i'*/)
  5211. {
  5212. buf = (buf + 3) & ~3;
  5213. args.push(HEAP32[(buf >> 2)]);
  5214. buf += 4;
  5215. }
  5216. else abort("unexpected char in asm const signature " + ch);
  5217. }
  5218. return args;
  5219. }
  5220. var FSNode = /** @constructor */ function(parent, name, mode, rdev) {
  5221. if (!parent) {
  5222. parent = this; // root node sets parent to itself
  5223. }
  5224. this.parent = parent;
  5225. this.mount = parent.mount;
  5226. this.mounted = null;
  5227. this.id = FS.nextInode++;
  5228. this.name = name;
  5229. this.mode = mode;
  5230. this.node_ops = {};
  5231. this.stream_ops = {};
  5232. this.rdev = rdev;
  5233. };
  5234. var readMode = 292/*292*/ | 73/*73*/;
  5235. var writeMode = 146/*146*/;
  5236. Object.defineProperties(FSNode.prototype, {
  5237. read: {
  5238. get: /** @this{FSNode} */function() {
  5239. return (this.mode & readMode) === readMode;
  5240. },
  5241. set: /** @this{FSNode} */function(val) {
  5242. val ? this.mode |= readMode : this.mode &= ~readMode;
  5243. }
  5244. },
  5245. write: {
  5246. get: /** @this{FSNode} */function() {
  5247. return (this.mode & writeMode) === writeMode;
  5248. },
  5249. set: /** @this{FSNode} */function(val) {
  5250. val ? this.mode |= writeMode : this.mode &= ~writeMode;
  5251. }
  5252. },
  5253. isFolder: {
  5254. get: /** @this{FSNode} */function() {
  5255. return FS.isDir(this.mode);
  5256. }
  5257. },
  5258. isDevice: {
  5259. get: /** @this{FSNode} */function() {
  5260. return FS.isChrdev(this.mode);
  5261. }
  5262. }
  5263. });
  5264. FS.FSNode = FSNode;
  5265. FS.staticInit();;
  5266. InternalError = Module['InternalError'] = extendError(Error, 'InternalError');;
  5267. embind_init_charCodes();
  5268. BindingError = Module['BindingError'] = extendError(Error, 'BindingError');;
  5269. init_emval();;
  5270. UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
  5271. var ASSERTIONS = true;
  5272. /**
  5273. * @license
  5274. * Copyright 2017 The Emscripten Authors
  5275. * SPDX-License-Identifier: MIT
  5276. */
  5277. /** @type {function(string, boolean=, number=)} */
  5278. function intArrayFromString(stringy, dontAddNull, length) {
  5279. var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
  5280. var u8array = new Array(len);
  5281. var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
  5282. if (dontAddNull) u8array.length = numBytesWritten;
  5283. return u8array;
  5284. }
  5285. function intArrayToString(array) {
  5286. var ret = [];
  5287. for (var i = 0; i < array.length; i++) {
  5288. var chr = array[i];
  5289. if (chr > 0xFF) {
  5290. if (ASSERTIONS) {
  5291. assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
  5292. }
  5293. chr &= 0xFF;
  5294. }
  5295. ret.push(String.fromCharCode(chr));
  5296. }
  5297. return ret.join('');
  5298. }
  5299. var asmGlobalArg = {};
  5300. var asmLibraryArg = { "__assert_fail": ___assert_fail, "__cxa_allocate_exception": ___cxa_allocate_exception, "__cxa_atexit": ___cxa_atexit, "__cxa_find_matching_catch_2": ___cxa_find_matching_catch_2, "__cxa_throw": ___cxa_throw, "__handle_stack_overflow": ___handle_stack_overflow, "__resumeException": ___resumeException, "__sys_fcntl64": ___sys_fcntl64, "__sys_ioctl": ___sys_ioctl, "__sys_open": ___sys_open, "__sys_rename": ___sys_rename, "__sys_rmdir": ___sys_rmdir, "__sys_unlink": ___sys_unlink, "_embind_finalize_value_object": __embind_finalize_value_object, "_embind_register_bool": __embind_register_bool, "_embind_register_emval": __embind_register_emval, "_embind_register_float": __embind_register_float, "_embind_register_function": __embind_register_function, "_embind_register_integer": __embind_register_integer, "_embind_register_memory_view": __embind_register_memory_view, "_embind_register_std_string": __embind_register_std_string, "_embind_register_std_wstring": __embind_register_std_wstring, "_embind_register_value_object": __embind_register_value_object, "_embind_register_value_object_field": __embind_register_value_object_field, "_embind_register_void": __embind_register_void, "emscripten_asm_const_iii": _emscripten_asm_const_iii, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "fd_close": _fd_close, "fd_read": _fd_read, "fd_seek": _fd_seek, "fd_write": _fd_write, "getTempRet0": _getTempRet0, "gettimeofday": _gettimeofday, "invoke_iii": invoke_iii, "localtime": _localtime, "localtime_r": _localtime_r, "memory": wasmMemory, "mktime": _mktime, "pthread_create": _pthread_create, "pthread_join": _pthread_join, "pthread_mutexattr_init": _pthread_mutexattr_init, "pthread_mutexattr_settype": _pthread_mutexattr_settype, "setTempRet0": _setTempRet0, "table": wasmTable, "time": _time, "usleep": _usleep };
  5301. var asm = createWasm();
  5302. Module["asm"] = asm;
  5303. /** @type {function(...*):?} */
  5304. var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
  5305. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5306. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5307. return Module["asm"]["__wasm_call_ctors"].apply(null, arguments)
  5308. };
  5309. /** @type {function(...*):?} */
  5310. var _CreatHandle = Module["_CreatHandle"] = function() {
  5311. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5312. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5313. return Module["asm"]["CreatHandle"].apply(null, arguments)
  5314. };
  5315. /** @type {function(...*):?} */
  5316. var _GetSDKVersion = Module["_GetSDKVersion"] = function() {
  5317. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5318. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5319. return Module["asm"]["GetSDKVersion"].apply(null, arguments)
  5320. };
  5321. /** @type {function(...*):?} */
  5322. var _SysTransStart = Module["_SysTransStart"] = function() {
  5323. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5324. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5325. return Module["asm"]["SysTransStart"].apply(null, arguments)
  5326. };
  5327. /** @type {function(...*):?} */
  5328. var _SysTransInputData = Module["_SysTransInputData"] = function() {
  5329. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5330. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5331. return Module["asm"]["SysTransInputData"].apply(null, arguments)
  5332. };
  5333. /** @type {function(...*):?} */
  5334. var _SysTransInputAudioPara = Module["_SysTransInputAudioPara"] = function() {
  5335. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5336. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5337. return Module["asm"]["SysTransInputAudioPara"].apply(null, arguments)
  5338. };
  5339. /** @type {function(...*):?} */
  5340. var _SysTransRegisterDataCallBack = Module["_SysTransRegisterDataCallBack"] = function() {
  5341. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5342. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5343. return Module["asm"]["SysTransRegisterDataCallBack"].apply(null, arguments)
  5344. };
  5345. /** @type {function(...*):?} */
  5346. var _SysTransStop = Module["_SysTransStop"] = function() {
  5347. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5348. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5349. return Module["asm"]["SysTransStop"].apply(null, arguments)
  5350. };
  5351. /** @type {function(...*):?} */
  5352. var _SysTransRelease = Module["_SysTransRelease"] = function() {
  5353. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5354. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5355. return Module["asm"]["SysTransRelease"].apply(null, arguments)
  5356. };
  5357. /** @type {function(...*):?} */
  5358. var _SysTransSetEncryptKey = Module["_SysTransSetEncryptKey"] = function() {
  5359. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5360. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5361. return Module["asm"]["SysTransSetEncryptKey"].apply(null, arguments)
  5362. };
  5363. /** @type {function(...*):?} */
  5364. var _SysTransSetGlobalTime = Module["_SysTransSetGlobalTime"] = function() {
  5365. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5366. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5367. return Module["asm"]["SysTransSetGlobalTime"].apply(null, arguments)
  5368. };
  5369. /** @type {function(...*):?} */
  5370. var _SysTransConfig = Module["_SysTransConfig"] = function() {
  5371. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5372. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5373. return Module["asm"]["SysTransConfig"].apply(null, arguments)
  5374. };
  5375. /** @type {function(...*):?} */
  5376. var _malloc = Module["_malloc"] = function() {
  5377. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5378. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5379. return Module["asm"]["malloc"].apply(null, arguments)
  5380. };
  5381. /** @type {function(...*):?} */
  5382. var _free = Module["_free"] = function() {
  5383. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5384. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5385. return Module["asm"]["free"].apply(null, arguments)
  5386. };
  5387. /** @type {function(...*):?} */
  5388. var _fflush = Module["_fflush"] = function() {
  5389. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5390. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5391. return Module["asm"]["fflush"].apply(null, arguments)
  5392. };
  5393. /** @type {function(...*):?} */
  5394. var ___getTypeName = Module["___getTypeName"] = function() {
  5395. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5396. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5397. return Module["asm"]["__getTypeName"].apply(null, arguments)
  5398. };
  5399. /** @type {function(...*):?} */
  5400. var ___embind_register_native_and_builtin_types = Module["___embind_register_native_and_builtin_types"] = function() {
  5401. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5402. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5403. return Module["asm"]["__embind_register_native_and_builtin_types"].apply(null, arguments)
  5404. };
  5405. /** @type {function(...*):?} */
  5406. var ___errno_location = Module["___errno_location"] = function() {
  5407. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5408. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5409. return Module["asm"]["__errno_location"].apply(null, arguments)
  5410. };
  5411. /** @type {function(...*):?} */
  5412. var __get_tzname = Module["__get_tzname"] = function() {
  5413. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5414. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5415. return Module["asm"]["_get_tzname"].apply(null, arguments)
  5416. };
  5417. /** @type {function(...*):?} */
  5418. var __get_daylight = Module["__get_daylight"] = function() {
  5419. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5420. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5421. return Module["asm"]["_get_daylight"].apply(null, arguments)
  5422. };
  5423. /** @type {function(...*):?} */
  5424. var __get_timezone = Module["__get_timezone"] = function() {
  5425. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5426. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5427. return Module["asm"]["_get_timezone"].apply(null, arguments)
  5428. };
  5429. /** @type {function(...*):?} */
  5430. var _setThrew = Module["_setThrew"] = function() {
  5431. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5432. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5433. return Module["asm"]["setThrew"].apply(null, arguments)
  5434. };
  5435. /** @type {function(...*):?} */
  5436. var _emscripten_main_thread_process_queued_calls = Module["_emscripten_main_thread_process_queued_calls"] = function() {
  5437. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5438. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5439. return Module["asm"]["emscripten_main_thread_process_queued_calls"].apply(null, arguments)
  5440. };
  5441. /** @type {function(...*):?} */
  5442. var dynCall_iii = Module["dynCall_iii"] = function() {
  5443. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5444. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5445. return Module["asm"]["dynCall_iii"].apply(null, arguments)
  5446. };
  5447. /** @type {function(...*):?} */
  5448. var ___set_stack_limit = Module["___set_stack_limit"] = function() {
  5449. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5450. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5451. return Module["asm"]["__set_stack_limit"].apply(null, arguments)
  5452. };
  5453. /** @type {function(...*):?} */
  5454. var stackSave = Module["stackSave"] = function() {
  5455. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5456. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5457. return Module["asm"]["stackSave"].apply(null, arguments)
  5458. };
  5459. /** @type {function(...*):?} */
  5460. var stackAlloc = Module["stackAlloc"] = function() {
  5461. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5462. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5463. return Module["asm"]["stackAlloc"].apply(null, arguments)
  5464. };
  5465. /** @type {function(...*):?} */
  5466. var stackRestore = Module["stackRestore"] = function() {
  5467. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5468. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5469. return Module["asm"]["stackRestore"].apply(null, arguments)
  5470. };
  5471. /** @type {function(...*):?} */
  5472. var __growWasmMemory = Module["__growWasmMemory"] = function() {
  5473. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5474. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5475. return Module["asm"]["__growWasmMemory"].apply(null, arguments)
  5476. };
  5477. /** @type {function(...*):?} */
  5478. var dynCall_vii = Module["dynCall_vii"] = function() {
  5479. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5480. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5481. return Module["asm"]["dynCall_vii"].apply(null, arguments)
  5482. };
  5483. /** @type {function(...*):?} */
  5484. var dynCall_ii = Module["dynCall_ii"] = function() {
  5485. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5486. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5487. return Module["asm"]["dynCall_ii"].apply(null, arguments)
  5488. };
  5489. /** @type {function(...*):?} */
  5490. var dynCall_vi = Module["dynCall_vi"] = function() {
  5491. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5492. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5493. return Module["asm"]["dynCall_vi"].apply(null, arguments)
  5494. };
  5495. /** @type {function(...*):?} */
  5496. var dynCall_i = Module["dynCall_i"] = function() {
  5497. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5498. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5499. return Module["asm"]["dynCall_i"].apply(null, arguments)
  5500. };
  5501. /** @type {function(...*):?} */
  5502. var dynCall_viii = Module["dynCall_viii"] = function() {
  5503. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5504. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5505. return Module["asm"]["dynCall_viii"].apply(null, arguments)
  5506. };
  5507. /** @type {function(...*):?} */
  5508. var dynCall_iiii = Module["dynCall_iiii"] = function() {
  5509. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5510. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5511. return Module["asm"]["dynCall_iiii"].apply(null, arguments)
  5512. };
  5513. /** @type {function(...*):?} */
  5514. var dynCall_jiji = Module["dynCall_jiji"] = function() {
  5515. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5516. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5517. return Module["asm"]["dynCall_jiji"].apply(null, arguments)
  5518. };
  5519. /** @type {function(...*):?} */
  5520. var dynCall_iidiiii = Module["dynCall_iidiiii"] = function() {
  5521. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5522. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5523. return Module["asm"]["dynCall_iidiiii"].apply(null, arguments)
  5524. };
  5525. /** @type {function(...*):?} */
  5526. var dynCall_viiiiii = Module["dynCall_viiiiii"] = function() {
  5527. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5528. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5529. return Module["asm"]["dynCall_viiiiii"].apply(null, arguments)
  5530. };
  5531. /** @type {function(...*):?} */
  5532. var dynCall_viiiii = Module["dynCall_viiiii"] = function() {
  5533. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5534. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5535. return Module["asm"]["dynCall_viiiii"].apply(null, arguments)
  5536. };
  5537. /** @type {function(...*):?} */
  5538. var dynCall_viiii = Module["dynCall_viiii"] = function() {
  5539. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5540. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5541. return Module["asm"]["dynCall_viiii"].apply(null, arguments)
  5542. };
  5543. /** @type {function(...*):?} */
  5544. var dynCall_iiiii = Module["dynCall_iiiii"] = function() {
  5545. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5546. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5547. return Module["asm"]["dynCall_iiiii"].apply(null, arguments)
  5548. };
  5549. function invoke_iii(index,a1,a2) {
  5550. var sp = stackSave();
  5551. try {
  5552. return dynCall_iii(index,a1,a2);
  5553. } catch(e) {
  5554. stackRestore(sp);
  5555. if (e !== e+0 && e !== 'longjmp') throw e;
  5556. _setThrew(1, 0);
  5557. }
  5558. }
  5559. /**
  5560. * @license
  5561. * Copyright 2010 The Emscripten Authors
  5562. * SPDX-License-Identifier: MIT
  5563. */
  5564. // === Auto-generated postamble setup entry stuff ===
  5565. Module['asm'] = asm;
  5566. if (!Object.getOwnPropertyDescriptor(Module, "intArrayFromString")) Module["intArrayFromString"] = function() { abort("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5567. if (!Object.getOwnPropertyDescriptor(Module, "intArrayToString")) Module["intArrayToString"] = function() { abort("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5568. Module["ccall"] = ccall;
  5569. if (!Object.getOwnPropertyDescriptor(Module, "cwrap")) Module["cwrap"] = function() { abort("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5570. if (!Object.getOwnPropertyDescriptor(Module, "setValue")) Module["setValue"] = function() { abort("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5571. Module["getValue"] = getValue;
  5572. if (!Object.getOwnPropertyDescriptor(Module, "allocate")) Module["allocate"] = function() { abort("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5573. if (!Object.getOwnPropertyDescriptor(Module, "getMemory")) Module["getMemory"] = function() { abort("'getMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5574. if (!Object.getOwnPropertyDescriptor(Module, "UTF8ArrayToString")) Module["UTF8ArrayToString"] = function() { abort("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5575. if (!Object.getOwnPropertyDescriptor(Module, "UTF8ToString")) Module["UTF8ToString"] = function() { abort("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5576. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8Array")) Module["stringToUTF8Array"] = function() { abort("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5577. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8")) Module["stringToUTF8"] = function() { abort("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5578. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF8")) Module["lengthBytesUTF8"] = function() { abort("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5579. if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5580. if (!Object.getOwnPropertyDescriptor(Module, "addOnPreRun")) Module["addOnPreRun"] = function() { abort("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5581. if (!Object.getOwnPropertyDescriptor(Module, "addOnInit")) Module["addOnInit"] = function() { abort("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5582. if (!Object.getOwnPropertyDescriptor(Module, "addOnPreMain")) Module["addOnPreMain"] = function() { abort("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5583. if (!Object.getOwnPropertyDescriptor(Module, "addOnExit")) Module["addOnExit"] = function() { abort("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5584. if (!Object.getOwnPropertyDescriptor(Module, "addOnPostRun")) Module["addOnPostRun"] = function() { abort("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5585. if (!Object.getOwnPropertyDescriptor(Module, "writeStringToMemory")) Module["writeStringToMemory"] = function() { abort("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5586. Module["writeArrayToMemory"] = writeArrayToMemory;
  5587. if (!Object.getOwnPropertyDescriptor(Module, "writeAsciiToMemory")) Module["writeAsciiToMemory"] = function() { abort("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5588. if (!Object.getOwnPropertyDescriptor(Module, "addRunDependency")) Module["addRunDependency"] = function() { abort("'addRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5589. if (!Object.getOwnPropertyDescriptor(Module, "removeRunDependency")) Module["removeRunDependency"] = function() { abort("'removeRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5590. if (!Object.getOwnPropertyDescriptor(Module, "FS_createFolder")) Module["FS_createFolder"] = function() { abort("'FS_createFolder' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5591. if (!Object.getOwnPropertyDescriptor(Module, "FS_createPath")) Module["FS_createPath"] = function() { abort("'FS_createPath' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5592. if (!Object.getOwnPropertyDescriptor(Module, "FS_createDataFile")) Module["FS_createDataFile"] = function() { abort("'FS_createDataFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5593. if (!Object.getOwnPropertyDescriptor(Module, "FS_createPreloadedFile")) Module["FS_createPreloadedFile"] = function() { abort("'FS_createPreloadedFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5594. if (!Object.getOwnPropertyDescriptor(Module, "FS_createLazyFile")) Module["FS_createLazyFile"] = function() { abort("'FS_createLazyFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5595. if (!Object.getOwnPropertyDescriptor(Module, "FS_createLink")) Module["FS_createLink"] = function() { abort("'FS_createLink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5596. if (!Object.getOwnPropertyDescriptor(Module, "FS_createDevice")) Module["FS_createDevice"] = function() { abort("'FS_createDevice' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5597. if (!Object.getOwnPropertyDescriptor(Module, "FS_unlink")) Module["FS_unlink"] = function() { abort("'FS_unlink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you") };
  5598. if (!Object.getOwnPropertyDescriptor(Module, "dynamicAlloc")) Module["dynamicAlloc"] = function() { abort("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5599. if (!Object.getOwnPropertyDescriptor(Module, "loadDynamicLibrary")) Module["loadDynamicLibrary"] = function() { abort("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5600. if (!Object.getOwnPropertyDescriptor(Module, "loadWebAssemblyModule")) Module["loadWebAssemblyModule"] = function() { abort("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5601. if (!Object.getOwnPropertyDescriptor(Module, "getLEB")) Module["getLEB"] = function() { abort("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5602. if (!Object.getOwnPropertyDescriptor(Module, "getFunctionTables")) Module["getFunctionTables"] = function() { abort("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5603. if (!Object.getOwnPropertyDescriptor(Module, "alignFunctionTables")) Module["alignFunctionTables"] = function() { abort("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5604. if (!Object.getOwnPropertyDescriptor(Module, "registerFunctions")) Module["registerFunctions"] = function() { abort("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5605. if (!Object.getOwnPropertyDescriptor(Module, "addFunction")) Module["addFunction"] = function() { abort("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5606. if (!Object.getOwnPropertyDescriptor(Module, "removeFunction")) Module["removeFunction"] = function() { abort("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5607. if (!Object.getOwnPropertyDescriptor(Module, "getFuncWrapper")) Module["getFuncWrapper"] = function() { abort("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5608. if (!Object.getOwnPropertyDescriptor(Module, "prettyPrint")) Module["prettyPrint"] = function() { abort("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5609. if (!Object.getOwnPropertyDescriptor(Module, "makeBigInt")) Module["makeBigInt"] = function() { abort("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5610. if (!Object.getOwnPropertyDescriptor(Module, "dynCall")) Module["dynCall"] = function() { abort("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5611. if (!Object.getOwnPropertyDescriptor(Module, "getCompilerSetting")) Module["getCompilerSetting"] = function() { abort("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5612. if (!Object.getOwnPropertyDescriptor(Module, "print")) Module["print"] = function() { abort("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5613. if (!Object.getOwnPropertyDescriptor(Module, "printErr")) Module["printErr"] = function() { abort("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5614. if (!Object.getOwnPropertyDescriptor(Module, "getTempRet0")) Module["getTempRet0"] = function() { abort("'getTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5615. if (!Object.getOwnPropertyDescriptor(Module, "setTempRet0")) Module["setTempRet0"] = function() { abort("'setTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5616. if (!Object.getOwnPropertyDescriptor(Module, "callMain")) Module["callMain"] = function() { abort("'callMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5617. if (!Object.getOwnPropertyDescriptor(Module, "abort")) Module["abort"] = function() { abort("'abort' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5618. if (!Object.getOwnPropertyDescriptor(Module, "stringToNewUTF8")) Module["stringToNewUTF8"] = function() { abort("'stringToNewUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5619. if (!Object.getOwnPropertyDescriptor(Module, "abortOnCannotGrowMemory")) Module["abortOnCannotGrowMemory"] = function() { abort("'abortOnCannotGrowMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5620. if (!Object.getOwnPropertyDescriptor(Module, "emscripten_realloc_buffer")) Module["emscripten_realloc_buffer"] = function() { abort("'emscripten_realloc_buffer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5621. if (!Object.getOwnPropertyDescriptor(Module, "ENV")) Module["ENV"] = function() { abort("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5622. if (!Object.getOwnPropertyDescriptor(Module, "setjmpId")) Module["setjmpId"] = function() { abort("'setjmpId' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5623. if (!Object.getOwnPropertyDescriptor(Module, "ERRNO_CODES")) Module["ERRNO_CODES"] = function() { abort("'ERRNO_CODES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5624. if (!Object.getOwnPropertyDescriptor(Module, "ERRNO_MESSAGES")) Module["ERRNO_MESSAGES"] = function() { abort("'ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5625. if (!Object.getOwnPropertyDescriptor(Module, "setErrNo")) Module["setErrNo"] = function() { abort("'setErrNo' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5626. if (!Object.getOwnPropertyDescriptor(Module, "DNS")) Module["DNS"] = function() { abort("'DNS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5627. if (!Object.getOwnPropertyDescriptor(Module, "GAI_ERRNO_MESSAGES")) Module["GAI_ERRNO_MESSAGES"] = function() { abort("'GAI_ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5628. if (!Object.getOwnPropertyDescriptor(Module, "Protocols")) Module["Protocols"] = function() { abort("'Protocols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5629. if (!Object.getOwnPropertyDescriptor(Module, "Sockets")) Module["Sockets"] = function() { abort("'Sockets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5630. if (!Object.getOwnPropertyDescriptor(Module, "UNWIND_CACHE")) Module["UNWIND_CACHE"] = function() { abort("'UNWIND_CACHE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5631. if (!Object.getOwnPropertyDescriptor(Module, "readAsmConstArgs")) Module["readAsmConstArgs"] = function() { abort("'readAsmConstArgs' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5632. if (!Object.getOwnPropertyDescriptor(Module, "jstoi_q")) Module["jstoi_q"] = function() { abort("'jstoi_q' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5633. if (!Object.getOwnPropertyDescriptor(Module, "jstoi_s")) Module["jstoi_s"] = function() { abort("'jstoi_s' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5634. if (!Object.getOwnPropertyDescriptor(Module, "reallyNegative")) Module["reallyNegative"] = function() { abort("'reallyNegative' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5635. if (!Object.getOwnPropertyDescriptor(Module, "formatString")) Module["formatString"] = function() { abort("'formatString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5636. if (!Object.getOwnPropertyDescriptor(Module, "PATH")) Module["PATH"] = function() { abort("'PATH' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5637. if (!Object.getOwnPropertyDescriptor(Module, "PATH_FS")) Module["PATH_FS"] = function() { abort("'PATH_FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5638. if (!Object.getOwnPropertyDescriptor(Module, "SYSCALLS")) Module["SYSCALLS"] = function() { abort("'SYSCALLS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5639. if (!Object.getOwnPropertyDescriptor(Module, "syscallMmap2")) Module["syscallMmap2"] = function() { abort("'syscallMmap2' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5640. if (!Object.getOwnPropertyDescriptor(Module, "syscallMunmap")) Module["syscallMunmap"] = function() { abort("'syscallMunmap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5641. if (!Object.getOwnPropertyDescriptor(Module, "JSEvents")) Module["JSEvents"] = function() { abort("'JSEvents' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5642. if (!Object.getOwnPropertyDescriptor(Module, "specialHTMLTargets")) Module["specialHTMLTargets"] = function() { abort("'specialHTMLTargets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5643. if (!Object.getOwnPropertyDescriptor(Module, "demangle")) Module["demangle"] = function() { abort("'demangle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5644. if (!Object.getOwnPropertyDescriptor(Module, "demangleAll")) Module["demangleAll"] = function() { abort("'demangleAll' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5645. if (!Object.getOwnPropertyDescriptor(Module, "jsStackTrace")) Module["jsStackTrace"] = function() { abort("'jsStackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5646. if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5647. if (!Object.getOwnPropertyDescriptor(Module, "getEnvStrings")) Module["getEnvStrings"] = function() { abort("'getEnvStrings' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5648. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64")) Module["writeI53ToI64"] = function() { abort("'writeI53ToI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5649. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Clamped")) Module["writeI53ToI64Clamped"] = function() { abort("'writeI53ToI64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5650. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Signaling")) Module["writeI53ToI64Signaling"] = function() { abort("'writeI53ToI64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5651. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Clamped")) Module["writeI53ToU64Clamped"] = function() { abort("'writeI53ToU64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5652. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Signaling")) Module["writeI53ToU64Signaling"] = function() { abort("'writeI53ToU64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5653. if (!Object.getOwnPropertyDescriptor(Module, "readI53FromI64")) Module["readI53FromI64"] = function() { abort("'readI53FromI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5654. if (!Object.getOwnPropertyDescriptor(Module, "readI53FromU64")) Module["readI53FromU64"] = function() { abort("'readI53FromU64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5655. if (!Object.getOwnPropertyDescriptor(Module, "convertI32PairToI53")) Module["convertI32PairToI53"] = function() { abort("'convertI32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5656. if (!Object.getOwnPropertyDescriptor(Module, "convertU32PairToI53")) Module["convertU32PairToI53"] = function() { abort("'convertU32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5657. if (!Object.getOwnPropertyDescriptor(Module, "Browser")) Module["Browser"] = function() { abort("'Browser' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5658. if (!Object.getOwnPropertyDescriptor(Module, "FS")) Module["FS"] = function() { abort("'FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5659. if (!Object.getOwnPropertyDescriptor(Module, "MEMFS")) Module["MEMFS"] = function() { abort("'MEMFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5660. if (!Object.getOwnPropertyDescriptor(Module, "TTY")) Module["TTY"] = function() { abort("'TTY' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5661. if (!Object.getOwnPropertyDescriptor(Module, "PIPEFS")) Module["PIPEFS"] = function() { abort("'PIPEFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5662. if (!Object.getOwnPropertyDescriptor(Module, "SOCKFS")) Module["SOCKFS"] = function() { abort("'SOCKFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5663. if (!Object.getOwnPropertyDescriptor(Module, "GL")) Module["GL"] = function() { abort("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5664. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGet")) Module["emscriptenWebGLGet"] = function() { abort("'emscriptenWebGLGet' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5665. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetTexPixelData")) Module["emscriptenWebGLGetTexPixelData"] = function() { abort("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5666. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetUniform")) Module["emscriptenWebGLGetUniform"] = function() { abort("'emscriptenWebGLGetUniform' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5667. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetVertexAttrib")) Module["emscriptenWebGLGetVertexAttrib"] = function() { abort("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5668. if (!Object.getOwnPropertyDescriptor(Module, "AL")) Module["AL"] = function() { abort("'AL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5669. if (!Object.getOwnPropertyDescriptor(Module, "SDL_unicode")) Module["SDL_unicode"] = function() { abort("'SDL_unicode' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5670. if (!Object.getOwnPropertyDescriptor(Module, "SDL_ttfContext")) Module["SDL_ttfContext"] = function() { abort("'SDL_ttfContext' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5671. if (!Object.getOwnPropertyDescriptor(Module, "SDL_audio")) Module["SDL_audio"] = function() { abort("'SDL_audio' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5672. if (!Object.getOwnPropertyDescriptor(Module, "SDL")) Module["SDL"] = function() { abort("'SDL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5673. if (!Object.getOwnPropertyDescriptor(Module, "SDL_gfx")) Module["SDL_gfx"] = function() { abort("'SDL_gfx' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5674. if (!Object.getOwnPropertyDescriptor(Module, "GLUT")) Module["GLUT"] = function() { abort("'GLUT' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5675. if (!Object.getOwnPropertyDescriptor(Module, "EGL")) Module["EGL"] = function() { abort("'EGL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5676. if (!Object.getOwnPropertyDescriptor(Module, "GLFW_Window")) Module["GLFW_Window"] = function() { abort("'GLFW_Window' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5677. if (!Object.getOwnPropertyDescriptor(Module, "GLFW")) Module["GLFW"] = function() { abort("'GLFW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5678. if (!Object.getOwnPropertyDescriptor(Module, "GLEW")) Module["GLEW"] = function() { abort("'GLEW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5679. if (!Object.getOwnPropertyDescriptor(Module, "IDBStore")) Module["IDBStore"] = function() { abort("'IDBStore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5680. if (!Object.getOwnPropertyDescriptor(Module, "runAndAbortIfError")) Module["runAndAbortIfError"] = function() { abort("'runAndAbortIfError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5681. if (!Object.getOwnPropertyDescriptor(Module, "emval_handle_array")) Module["emval_handle_array"] = function() { abort("'emval_handle_array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5682. if (!Object.getOwnPropertyDescriptor(Module, "emval_free_list")) Module["emval_free_list"] = function() { abort("'emval_free_list' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5683. if (!Object.getOwnPropertyDescriptor(Module, "emval_symbols")) Module["emval_symbols"] = function() { abort("'emval_symbols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5684. if (!Object.getOwnPropertyDescriptor(Module, "init_emval")) Module["init_emval"] = function() { abort("'init_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5685. if (!Object.getOwnPropertyDescriptor(Module, "count_emval_handles")) Module["count_emval_handles"] = function() { abort("'count_emval_handles' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5686. if (!Object.getOwnPropertyDescriptor(Module, "get_first_emval")) Module["get_first_emval"] = function() { abort("'get_first_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5687. if (!Object.getOwnPropertyDescriptor(Module, "getStringOrSymbol")) Module["getStringOrSymbol"] = function() { abort("'getStringOrSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5688. if (!Object.getOwnPropertyDescriptor(Module, "requireHandle")) Module["requireHandle"] = function() { abort("'requireHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5689. if (!Object.getOwnPropertyDescriptor(Module, "emval_newers")) Module["emval_newers"] = function() { abort("'emval_newers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5690. if (!Object.getOwnPropertyDescriptor(Module, "craftEmvalAllocator")) Module["craftEmvalAllocator"] = function() { abort("'craftEmvalAllocator' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5691. if (!Object.getOwnPropertyDescriptor(Module, "emval_get_global")) Module["emval_get_global"] = function() { abort("'emval_get_global' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5692. if (!Object.getOwnPropertyDescriptor(Module, "emval_methodCallers")) Module["emval_methodCallers"] = function() { abort("'emval_methodCallers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5693. if (!Object.getOwnPropertyDescriptor(Module, "InternalError")) Module["InternalError"] = function() { abort("'InternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5694. if (!Object.getOwnPropertyDescriptor(Module, "BindingError")) Module["BindingError"] = function() { abort("'BindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5695. if (!Object.getOwnPropertyDescriptor(Module, "UnboundTypeError")) Module["UnboundTypeError"] = function() { abort("'UnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5696. if (!Object.getOwnPropertyDescriptor(Module, "PureVirtualError")) Module["PureVirtualError"] = function() { abort("'PureVirtualError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5697. if (!Object.getOwnPropertyDescriptor(Module, "init_embind")) Module["init_embind"] = function() { abort("'init_embind' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5698. if (!Object.getOwnPropertyDescriptor(Module, "throwInternalError")) Module["throwInternalError"] = function() { abort("'throwInternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5699. if (!Object.getOwnPropertyDescriptor(Module, "throwBindingError")) Module["throwBindingError"] = function() { abort("'throwBindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5700. if (!Object.getOwnPropertyDescriptor(Module, "throwUnboundTypeError")) Module["throwUnboundTypeError"] = function() { abort("'throwUnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5701. if (!Object.getOwnPropertyDescriptor(Module, "ensureOverloadTable")) Module["ensureOverloadTable"] = function() { abort("'ensureOverloadTable' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5702. if (!Object.getOwnPropertyDescriptor(Module, "exposePublicSymbol")) Module["exposePublicSymbol"] = function() { abort("'exposePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5703. if (!Object.getOwnPropertyDescriptor(Module, "replacePublicSymbol")) Module["replacePublicSymbol"] = function() { abort("'replacePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5704. if (!Object.getOwnPropertyDescriptor(Module, "extendError")) Module["extendError"] = function() { abort("'extendError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5705. if (!Object.getOwnPropertyDescriptor(Module, "createNamedFunction")) Module["createNamedFunction"] = function() { abort("'createNamedFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5706. if (!Object.getOwnPropertyDescriptor(Module, "registeredInstances")) Module["registeredInstances"] = function() { abort("'registeredInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5707. if (!Object.getOwnPropertyDescriptor(Module, "getBasestPointer")) Module["getBasestPointer"] = function() { abort("'getBasestPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5708. if (!Object.getOwnPropertyDescriptor(Module, "registerInheritedInstance")) Module["registerInheritedInstance"] = function() { abort("'registerInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5709. if (!Object.getOwnPropertyDescriptor(Module, "unregisterInheritedInstance")) Module["unregisterInheritedInstance"] = function() { abort("'unregisterInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5710. if (!Object.getOwnPropertyDescriptor(Module, "getInheritedInstance")) Module["getInheritedInstance"] = function() { abort("'getInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5711. if (!Object.getOwnPropertyDescriptor(Module, "getInheritedInstanceCount")) Module["getInheritedInstanceCount"] = function() { abort("'getInheritedInstanceCount' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5712. if (!Object.getOwnPropertyDescriptor(Module, "getLiveInheritedInstances")) Module["getLiveInheritedInstances"] = function() { abort("'getLiveInheritedInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5713. if (!Object.getOwnPropertyDescriptor(Module, "registeredTypes")) Module["registeredTypes"] = function() { abort("'registeredTypes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5714. if (!Object.getOwnPropertyDescriptor(Module, "awaitingDependencies")) Module["awaitingDependencies"] = function() { abort("'awaitingDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5715. if (!Object.getOwnPropertyDescriptor(Module, "typeDependencies")) Module["typeDependencies"] = function() { abort("'typeDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5716. if (!Object.getOwnPropertyDescriptor(Module, "registeredPointers")) Module["registeredPointers"] = function() { abort("'registeredPointers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5717. if (!Object.getOwnPropertyDescriptor(Module, "registerType")) Module["registerType"] = function() { abort("'registerType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5718. if (!Object.getOwnPropertyDescriptor(Module, "whenDependentTypesAreResolved")) Module["whenDependentTypesAreResolved"] = function() { abort("'whenDependentTypesAreResolved' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5719. if (!Object.getOwnPropertyDescriptor(Module, "embind_charCodes")) Module["embind_charCodes"] = function() { abort("'embind_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5720. if (!Object.getOwnPropertyDescriptor(Module, "embind_init_charCodes")) Module["embind_init_charCodes"] = function() { abort("'embind_init_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5721. if (!Object.getOwnPropertyDescriptor(Module, "readLatin1String")) Module["readLatin1String"] = function() { abort("'readLatin1String' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5722. if (!Object.getOwnPropertyDescriptor(Module, "getTypeName")) Module["getTypeName"] = function() { abort("'getTypeName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5723. if (!Object.getOwnPropertyDescriptor(Module, "heap32VectorToArray")) Module["heap32VectorToArray"] = function() { abort("'heap32VectorToArray' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5724. if (!Object.getOwnPropertyDescriptor(Module, "requireRegisteredType")) Module["requireRegisteredType"] = function() { abort("'requireRegisteredType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5725. if (!Object.getOwnPropertyDescriptor(Module, "getShiftFromSize")) Module["getShiftFromSize"] = function() { abort("'getShiftFromSize' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5726. if (!Object.getOwnPropertyDescriptor(Module, "integerReadValueFromPointer")) Module["integerReadValueFromPointer"] = function() { abort("'integerReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5727. if (!Object.getOwnPropertyDescriptor(Module, "enumReadValueFromPointer")) Module["enumReadValueFromPointer"] = function() { abort("'enumReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5728. if (!Object.getOwnPropertyDescriptor(Module, "floatReadValueFromPointer")) Module["floatReadValueFromPointer"] = function() { abort("'floatReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5729. if (!Object.getOwnPropertyDescriptor(Module, "simpleReadValueFromPointer")) Module["simpleReadValueFromPointer"] = function() { abort("'simpleReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5730. if (!Object.getOwnPropertyDescriptor(Module, "runDestructors")) Module["runDestructors"] = function() { abort("'runDestructors' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5731. if (!Object.getOwnPropertyDescriptor(Module, "new_")) Module["new_"] = function() { abort("'new_' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5732. if (!Object.getOwnPropertyDescriptor(Module, "craftInvokerFunction")) Module["craftInvokerFunction"] = function() { abort("'craftInvokerFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5733. if (!Object.getOwnPropertyDescriptor(Module, "embind__requireFunction")) Module["embind__requireFunction"] = function() { abort("'embind__requireFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5734. if (!Object.getOwnPropertyDescriptor(Module, "tupleRegistrations")) Module["tupleRegistrations"] = function() { abort("'tupleRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5735. if (!Object.getOwnPropertyDescriptor(Module, "structRegistrations")) Module["structRegistrations"] = function() { abort("'structRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5736. if (!Object.getOwnPropertyDescriptor(Module, "genericPointerToWireType")) Module["genericPointerToWireType"] = function() { abort("'genericPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5737. if (!Object.getOwnPropertyDescriptor(Module, "constNoSmartPtrRawPointerToWireType")) Module["constNoSmartPtrRawPointerToWireType"] = function() { abort("'constNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5738. if (!Object.getOwnPropertyDescriptor(Module, "nonConstNoSmartPtrRawPointerToWireType")) Module["nonConstNoSmartPtrRawPointerToWireType"] = function() { abort("'nonConstNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5739. if (!Object.getOwnPropertyDescriptor(Module, "init_RegisteredPointer")) Module["init_RegisteredPointer"] = function() { abort("'init_RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5740. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer")) Module["RegisteredPointer"] = function() { abort("'RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5741. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer_getPointee")) Module["RegisteredPointer_getPointee"] = function() { abort("'RegisteredPointer_getPointee' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5742. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer_destructor")) Module["RegisteredPointer_destructor"] = function() { abort("'RegisteredPointer_destructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5743. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer_deleteObject")) Module["RegisteredPointer_deleteObject"] = function() { abort("'RegisteredPointer_deleteObject' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5744. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer_fromWireType")) Module["RegisteredPointer_fromWireType"] = function() { abort("'RegisteredPointer_fromWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5745. if (!Object.getOwnPropertyDescriptor(Module, "runDestructor")) Module["runDestructor"] = function() { abort("'runDestructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5746. if (!Object.getOwnPropertyDescriptor(Module, "releaseClassHandle")) Module["releaseClassHandle"] = function() { abort("'releaseClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5747. if (!Object.getOwnPropertyDescriptor(Module, "finalizationGroup")) Module["finalizationGroup"] = function() { abort("'finalizationGroup' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5748. if (!Object.getOwnPropertyDescriptor(Module, "detachFinalizer_deps")) Module["detachFinalizer_deps"] = function() { abort("'detachFinalizer_deps' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5749. if (!Object.getOwnPropertyDescriptor(Module, "detachFinalizer")) Module["detachFinalizer"] = function() { abort("'detachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5750. if (!Object.getOwnPropertyDescriptor(Module, "attachFinalizer")) Module["attachFinalizer"] = function() { abort("'attachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5751. if (!Object.getOwnPropertyDescriptor(Module, "makeClassHandle")) Module["makeClassHandle"] = function() { abort("'makeClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5752. if (!Object.getOwnPropertyDescriptor(Module, "init_ClassHandle")) Module["init_ClassHandle"] = function() { abort("'init_ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5753. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle")) Module["ClassHandle"] = function() { abort("'ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5754. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle_isAliasOf")) Module["ClassHandle_isAliasOf"] = function() { abort("'ClassHandle_isAliasOf' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5755. if (!Object.getOwnPropertyDescriptor(Module, "throwInstanceAlreadyDeleted")) Module["throwInstanceAlreadyDeleted"] = function() { abort("'throwInstanceAlreadyDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5756. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle_clone")) Module["ClassHandle_clone"] = function() { abort("'ClassHandle_clone' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5757. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle_delete")) Module["ClassHandle_delete"] = function() { abort("'ClassHandle_delete' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5758. if (!Object.getOwnPropertyDescriptor(Module, "deletionQueue")) Module["deletionQueue"] = function() { abort("'deletionQueue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5759. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle_isDeleted")) Module["ClassHandle_isDeleted"] = function() { abort("'ClassHandle_isDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5760. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle_deleteLater")) Module["ClassHandle_deleteLater"] = function() { abort("'ClassHandle_deleteLater' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5761. if (!Object.getOwnPropertyDescriptor(Module, "flushPendingDeletes")) Module["flushPendingDeletes"] = function() { abort("'flushPendingDeletes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5762. if (!Object.getOwnPropertyDescriptor(Module, "delayFunction")) Module["delayFunction"] = function() { abort("'delayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5763. if (!Object.getOwnPropertyDescriptor(Module, "setDelayFunction")) Module["setDelayFunction"] = function() { abort("'setDelayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5764. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredClass")) Module["RegisteredClass"] = function() { abort("'RegisteredClass' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5765. if (!Object.getOwnPropertyDescriptor(Module, "shallowCopyInternalPointer")) Module["shallowCopyInternalPointer"] = function() { abort("'shallowCopyInternalPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5766. if (!Object.getOwnPropertyDescriptor(Module, "downcastPointer")) Module["downcastPointer"] = function() { abort("'downcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5767. if (!Object.getOwnPropertyDescriptor(Module, "upcastPointer")) Module["upcastPointer"] = function() { abort("'upcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5768. if (!Object.getOwnPropertyDescriptor(Module, "validateThis")) Module["validateThis"] = function() { abort("'validateThis' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5769. if (!Object.getOwnPropertyDescriptor(Module, "char_0")) Module["char_0"] = function() { abort("'char_0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5770. if (!Object.getOwnPropertyDescriptor(Module, "char_9")) Module["char_9"] = function() { abort("'char_9' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5771. if (!Object.getOwnPropertyDescriptor(Module, "makeLegalFunctionName")) Module["makeLegalFunctionName"] = function() { abort("'makeLegalFunctionName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5772. if (!Object.getOwnPropertyDescriptor(Module, "warnOnce")) Module["warnOnce"] = function() { abort("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5773. if (!Object.getOwnPropertyDescriptor(Module, "stackSave")) Module["stackSave"] = function() { abort("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5774. if (!Object.getOwnPropertyDescriptor(Module, "stackRestore")) Module["stackRestore"] = function() { abort("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5775. if (!Object.getOwnPropertyDescriptor(Module, "stackAlloc")) Module["stackAlloc"] = function() { abort("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5776. if (!Object.getOwnPropertyDescriptor(Module, "AsciiToString")) Module["AsciiToString"] = function() { abort("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5777. if (!Object.getOwnPropertyDescriptor(Module, "stringToAscii")) Module["stringToAscii"] = function() { abort("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5778. if (!Object.getOwnPropertyDescriptor(Module, "UTF16ToString")) Module["UTF16ToString"] = function() { abort("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5779. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF16")) Module["stringToUTF16"] = function() { abort("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5780. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF16")) Module["lengthBytesUTF16"] = function() { abort("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5781. if (!Object.getOwnPropertyDescriptor(Module, "UTF32ToString")) Module["UTF32ToString"] = function() { abort("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5782. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF32")) Module["stringToUTF32"] = function() { abort("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5783. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF32")) Module["lengthBytesUTF32"] = function() { abort("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5784. if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8")) Module["allocateUTF8"] = function() { abort("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5785. if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8OnStack")) Module["allocateUTF8OnStack"] = function() { abort("'allocateUTF8OnStack' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5786. Module["writeStackCookie"] = writeStackCookie;
  5787. Module["checkStackCookie"] = checkStackCookie;
  5788. Module["abortStackOverflow"] = abortStackOverflow;if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_NORMAL")) Object.defineProperty(Module, "ALLOC_NORMAL", { configurable: true, get: function() { abort("'ALLOC_NORMAL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
  5789. if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_STACK")) Object.defineProperty(Module, "ALLOC_STACK", { configurable: true, get: function() { abort("'ALLOC_STACK' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
  5790. if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_DYNAMIC")) Object.defineProperty(Module, "ALLOC_DYNAMIC", { configurable: true, get: function() { abort("'ALLOC_DYNAMIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
  5791. if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_NONE")) Object.defineProperty(Module, "ALLOC_NONE", { configurable: true, get: function() { abort("'ALLOC_NONE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } });
  5792. var calledRun;
  5793. /**
  5794. * @constructor
  5795. * @this {ExitStatus}
  5796. */
  5797. function ExitStatus(status) {
  5798. this.name = "ExitStatus";
  5799. this.message = "Program terminated with exit(" + status + ")";
  5800. this.status = status;
  5801. }
  5802. var calledMain = false;
  5803. dependenciesFulfilled = function runCaller() {
  5804. // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
  5805. if (!calledRun) run();
  5806. if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
  5807. };
  5808. /** @type {function(Array=)} */
  5809. function run(args) {
  5810. args = args || arguments_;
  5811. if (runDependencies > 0) {
  5812. return;
  5813. }
  5814. writeStackCookie();
  5815. preRun();
  5816. if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
  5817. function doRun() {
  5818. // run may have just been called through dependencies being fulfilled just in this very frame,
  5819. // or while the async setStatus time below was happening
  5820. if (calledRun) return;
  5821. calledRun = true;
  5822. Module['calledRun'] = true;
  5823. if (ABORT) return;
  5824. initRuntime();
  5825. preMain();
  5826. if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
  5827. assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
  5828. postRun();
  5829. }
  5830. if (Module['setStatus']) {
  5831. Module['setStatus']('Running...');
  5832. setTimeout(function() {
  5833. setTimeout(function() {
  5834. Module['setStatus']('');
  5835. }, 1);
  5836. doRun();
  5837. }, 1);
  5838. } else
  5839. {
  5840. doRun();
  5841. }
  5842. checkStackCookie();
  5843. }
  5844. Module['run'] = run;
  5845. function checkUnflushedContent() {
  5846. // Compiler settings do not allow exiting the runtime, so flushing
  5847. // the streams is not possible. but in ASSERTIONS mode we check
  5848. // if there was something to flush, and if so tell the user they
  5849. // should request that the runtime be exitable.
  5850. // Normally we would not even include flush() at all, but in ASSERTIONS
  5851. // builds we do so just for this check, and here we see if there is any
  5852. // content to flush, that is, we check if there would have been
  5853. // something a non-ASSERTIONS build would have not seen.
  5854. // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
  5855. // mode (which has its own special function for this; otherwise, all
  5856. // the code is inside libc)
  5857. var print = out;
  5858. var printErr = err;
  5859. var has = false;
  5860. out = err = function(x) {
  5861. has = true;
  5862. }
  5863. try { // it doesn't matter if it fails
  5864. var flush = Module['_fflush'];
  5865. if (flush) flush(0);
  5866. // also flush in the JS FS layer
  5867. ['stdout', 'stderr'].forEach(function(name) {
  5868. var info = FS.analyzePath('/dev/' + name);
  5869. if (!info) return;
  5870. var stream = info.object;
  5871. var rdev = stream.rdev;
  5872. var tty = TTY.ttys[rdev];
  5873. if (tty && tty.output && tty.output.length) {
  5874. has = true;
  5875. }
  5876. });
  5877. } catch(e) {}
  5878. out = print;
  5879. err = printErr;
  5880. if (has) {
  5881. warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.');
  5882. }
  5883. }
  5884. /** @param {boolean|number=} implicit */
  5885. function exit(status, implicit) {
  5886. checkUnflushedContent();
  5887. // if this is just main exit-ing implicitly, and the status is 0, then we
  5888. // don't need to do anything here and can just leave. if the status is
  5889. // non-zero, though, then we need to report it.
  5890. // (we may have warned about this earlier, if a situation justifies doing so)
  5891. if (implicit && noExitRuntime && status === 0) {
  5892. return;
  5893. }
  5894. if (noExitRuntime) {
  5895. // if exit() was called, we may warn the user if the runtime isn't actually being shut down
  5896. if (!implicit) {
  5897. var msg = 'program exited (with status: ' + status + '), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)';
  5898. err(msg);
  5899. }
  5900. } else {
  5901. ABORT = true;
  5902. EXITSTATUS = status;
  5903. exitRuntime();
  5904. if (Module['onExit']) Module['onExit'](status);
  5905. }
  5906. quit_(status, new ExitStatus(status));
  5907. }
  5908. if (Module['preInit']) {
  5909. if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
  5910. while (Module['preInit'].length > 0) {
  5911. Module['preInit'].pop()();
  5912. }
  5913. }
  5914. noExitRuntime = true;
  5915. run();
  5916. // {{MODULE_ADDITIONS}}