libSystemTransform.js 284 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526
  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': 275,
  585. 'maximum': 275 + 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 = 5534128,
  1136. STACKTOP = STACK_BASE,
  1137. STACK_MAX = 291248,
  1138. DYNAMIC_BASE = 5534128,
  1139. DYNAMICTOP_PTR = 291072;
  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'] || 268435456;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 + 290224;
  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. var ___exception_infos={};
  1657. var ___exception_last=0;
  1658. function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
  1659. return __ZSt18uncaught_exceptionv.uncaught_exceptions > 0;
  1660. }function ___cxa_throw(ptr, type, destructor) {
  1661. ___exception_infos[ptr] = {
  1662. ptr: ptr,
  1663. adjusted: [ptr],
  1664. type: type,
  1665. destructor: destructor,
  1666. refcount: 0,
  1667. caught: false,
  1668. rethrown: false
  1669. };
  1670. ___exception_last = ptr;
  1671. if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
  1672. __ZSt18uncaught_exceptionv.uncaught_exceptions = 1;
  1673. } else {
  1674. __ZSt18uncaught_exceptionv.uncaught_exceptions++;
  1675. }
  1676. throw ptr;
  1677. }
  1678. function ___handle_stack_overflow() {
  1679. abort('stack overflow')
  1680. }
  1681. function setErrNo(value) {
  1682. HEAP32[((___errno_location())>>2)]=value;
  1683. return value;
  1684. }
  1685. var PATH={splitPath:function(filename) {
  1686. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  1687. return splitPathRe.exec(filename).slice(1);
  1688. },normalizeArray:function(parts, allowAboveRoot) {
  1689. // if the path tries to go above the root, `up` ends up > 0
  1690. var up = 0;
  1691. for (var i = parts.length - 1; i >= 0; i--) {
  1692. var last = parts[i];
  1693. if (last === '.') {
  1694. parts.splice(i, 1);
  1695. } else if (last === '..') {
  1696. parts.splice(i, 1);
  1697. up++;
  1698. } else if (up) {
  1699. parts.splice(i, 1);
  1700. up--;
  1701. }
  1702. }
  1703. // if the path is allowed to go above the root, restore leading ..s
  1704. if (allowAboveRoot) {
  1705. for (; up; up--) {
  1706. parts.unshift('..');
  1707. }
  1708. }
  1709. return parts;
  1710. },normalize:function(path) {
  1711. var isAbsolute = path.charAt(0) === '/',
  1712. trailingSlash = path.substr(-1) === '/';
  1713. // Normalize the path
  1714. path = PATH.normalizeArray(path.split('/').filter(function(p) {
  1715. return !!p;
  1716. }), !isAbsolute).join('/');
  1717. if (!path && !isAbsolute) {
  1718. path = '.';
  1719. }
  1720. if (path && trailingSlash) {
  1721. path += '/';
  1722. }
  1723. return (isAbsolute ? '/' : '') + path;
  1724. },dirname:function(path) {
  1725. var result = PATH.splitPath(path),
  1726. root = result[0],
  1727. dir = result[1];
  1728. if (!root && !dir) {
  1729. // No dirname whatsoever
  1730. return '.';
  1731. }
  1732. if (dir) {
  1733. // It has a dirname, strip trailing slash
  1734. dir = dir.substr(0, dir.length - 1);
  1735. }
  1736. return root + dir;
  1737. },basename:function(path) {
  1738. // EMSCRIPTEN return '/'' for '/', not an empty string
  1739. if (path === '/') return '/';
  1740. var lastSlash = path.lastIndexOf('/');
  1741. if (lastSlash === -1) return path;
  1742. return path.substr(lastSlash+1);
  1743. },extname:function(path) {
  1744. return PATH.splitPath(path)[3];
  1745. },join:function() {
  1746. var paths = Array.prototype.slice.call(arguments, 0);
  1747. return PATH.normalize(paths.join('/'));
  1748. },join2:function(l, r) {
  1749. return PATH.normalize(l + '/' + r);
  1750. }};
  1751. var PATH_FS={resolve:function() {
  1752. var resolvedPath = '',
  1753. resolvedAbsolute = false;
  1754. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  1755. var path = (i >= 0) ? arguments[i] : FS.cwd();
  1756. // Skip empty and invalid entries
  1757. if (typeof path !== 'string') {
  1758. throw new TypeError('Arguments to path.resolve must be strings');
  1759. } else if (!path) {
  1760. return ''; // an invalid portion invalidates the whole thing
  1761. }
  1762. resolvedPath = path + '/' + resolvedPath;
  1763. resolvedAbsolute = path.charAt(0) === '/';
  1764. }
  1765. // At this point the path should be resolved to a full absolute path, but
  1766. // handle relative paths to be safe (might happen when process.cwd() fails)
  1767. resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
  1768. return !!p;
  1769. }), !resolvedAbsolute).join('/');
  1770. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  1771. },relative:function(from, to) {
  1772. from = PATH_FS.resolve(from).substr(1);
  1773. to = PATH_FS.resolve(to).substr(1);
  1774. function trim(arr) {
  1775. var start = 0;
  1776. for (; start < arr.length; start++) {
  1777. if (arr[start] !== '') break;
  1778. }
  1779. var end = arr.length - 1;
  1780. for (; end >= 0; end--) {
  1781. if (arr[end] !== '') break;
  1782. }
  1783. if (start > end) return [];
  1784. return arr.slice(start, end - start + 1);
  1785. }
  1786. var fromParts = trim(from.split('/'));
  1787. var toParts = trim(to.split('/'));
  1788. var length = Math.min(fromParts.length, toParts.length);
  1789. var samePartsLength = length;
  1790. for (var i = 0; i < length; i++) {
  1791. if (fromParts[i] !== toParts[i]) {
  1792. samePartsLength = i;
  1793. break;
  1794. }
  1795. }
  1796. var outputParts = [];
  1797. for (var i = samePartsLength; i < fromParts.length; i++) {
  1798. outputParts.push('..');
  1799. }
  1800. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  1801. return outputParts.join('/');
  1802. }};
  1803. var TTY={ttys:[],init:function () {
  1804. // https://github.com/emscripten-core/emscripten/pull/1555
  1805. // if (ENVIRONMENT_IS_NODE) {
  1806. // // currently, FS.init does not distinguish if process.stdin is a file or TTY
  1807. // // device, it always assumes it's a TTY device. because of this, we're forcing
  1808. // // process.stdin to UTF8 encoding to at least make stdin reading compatible
  1809. // // with text files until FS.init can be refactored.
  1810. // process['stdin']['setEncoding']('utf8');
  1811. // }
  1812. },shutdown:function() {
  1813. // https://github.com/emscripten-core/emscripten/pull/1555
  1814. // if (ENVIRONMENT_IS_NODE) {
  1815. // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
  1816. // // 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
  1817. // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
  1818. // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
  1819. // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
  1820. // process['stdin']['pause']();
  1821. // }
  1822. },register:function(dev, ops) {
  1823. TTY.ttys[dev] = { input: [], output: [], ops: ops };
  1824. FS.registerDevice(dev, TTY.stream_ops);
  1825. },stream_ops:{open:function(stream) {
  1826. var tty = TTY.ttys[stream.node.rdev];
  1827. if (!tty) {
  1828. throw new FS.ErrnoError(43);
  1829. }
  1830. stream.tty = tty;
  1831. stream.seekable = false;
  1832. },close:function(stream) {
  1833. // flush any pending line data
  1834. stream.tty.ops.flush(stream.tty);
  1835. },flush:function(stream) {
  1836. stream.tty.ops.flush(stream.tty);
  1837. },read:function(stream, buffer, offset, length, pos /* ignored */) {
  1838. if (!stream.tty || !stream.tty.ops.get_char) {
  1839. throw new FS.ErrnoError(60);
  1840. }
  1841. var bytesRead = 0;
  1842. for (var i = 0; i < length; i++) {
  1843. var result;
  1844. try {
  1845. result = stream.tty.ops.get_char(stream.tty);
  1846. } catch (e) {
  1847. throw new FS.ErrnoError(29);
  1848. }
  1849. if (result === undefined && bytesRead === 0) {
  1850. throw new FS.ErrnoError(6);
  1851. }
  1852. if (result === null || result === undefined) break;
  1853. bytesRead++;
  1854. buffer[offset+i] = result;
  1855. }
  1856. if (bytesRead) {
  1857. stream.node.timestamp = Date.now();
  1858. }
  1859. return bytesRead;
  1860. },write:function(stream, buffer, offset, length, pos) {
  1861. if (!stream.tty || !stream.tty.ops.put_char) {
  1862. throw new FS.ErrnoError(60);
  1863. }
  1864. try {
  1865. for (var i = 0; i < length; i++) {
  1866. stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
  1867. }
  1868. } catch (e) {
  1869. throw new FS.ErrnoError(29);
  1870. }
  1871. if (length) {
  1872. stream.node.timestamp = Date.now();
  1873. }
  1874. return i;
  1875. }},default_tty_ops:{get_char:function(tty) {
  1876. if (!tty.input.length) {
  1877. var result = null;
  1878. if (ENVIRONMENT_IS_NODE) {
  1879. // we will read data by chunks of BUFSIZE
  1880. var BUFSIZE = 256;
  1881. var buf = Buffer.alloc ? Buffer.alloc(BUFSIZE) : new Buffer(BUFSIZE);
  1882. var bytesRead = 0;
  1883. try {
  1884. bytesRead = nodeFS.readSync(process.stdin.fd, buf, 0, BUFSIZE, null);
  1885. } catch(e) {
  1886. // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes,
  1887. // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0.
  1888. if (e.toString().indexOf('EOF') != -1) bytesRead = 0;
  1889. else throw e;
  1890. }
  1891. if (bytesRead > 0) {
  1892. result = buf.slice(0, bytesRead).toString('utf-8');
  1893. } else {
  1894. result = null;
  1895. }
  1896. } else
  1897. if (typeof window != 'undefined' &&
  1898. typeof window.prompt == 'function') {
  1899. // Browser.
  1900. result = window.prompt('Input: '); // returns null on cancel
  1901. if (result !== null) {
  1902. result += '\n';
  1903. }
  1904. } else if (typeof readline == 'function') {
  1905. // Command line.
  1906. result = readline();
  1907. if (result !== null) {
  1908. result += '\n';
  1909. }
  1910. }
  1911. if (!result) {
  1912. return null;
  1913. }
  1914. tty.input = intArrayFromString(result, true);
  1915. }
  1916. return tty.input.shift();
  1917. },put_char:function(tty, val) {
  1918. if (val === null || val === 10) {
  1919. out(UTF8ArrayToString(tty.output, 0));
  1920. tty.output = [];
  1921. } else {
  1922. if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
  1923. }
  1924. },flush:function(tty) {
  1925. if (tty.output && tty.output.length > 0) {
  1926. out(UTF8ArrayToString(tty.output, 0));
  1927. tty.output = [];
  1928. }
  1929. }},default_tty1_ops:{put_char:function(tty, val) {
  1930. if (val === null || val === 10) {
  1931. err(UTF8ArrayToString(tty.output, 0));
  1932. tty.output = [];
  1933. } else {
  1934. if (val != 0) tty.output.push(val);
  1935. }
  1936. },flush:function(tty) {
  1937. if (tty.output && tty.output.length > 0) {
  1938. err(UTF8ArrayToString(tty.output, 0));
  1939. tty.output = [];
  1940. }
  1941. }}};
  1942. var MEMFS={ops_table:null,mount:function(mount) {
  1943. return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
  1944. },createNode:function(parent, name, mode, dev) {
  1945. if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
  1946. // no supported
  1947. throw new FS.ErrnoError(63);
  1948. }
  1949. if (!MEMFS.ops_table) {
  1950. MEMFS.ops_table = {
  1951. dir: {
  1952. node: {
  1953. getattr: MEMFS.node_ops.getattr,
  1954. setattr: MEMFS.node_ops.setattr,
  1955. lookup: MEMFS.node_ops.lookup,
  1956. mknod: MEMFS.node_ops.mknod,
  1957. rename: MEMFS.node_ops.rename,
  1958. unlink: MEMFS.node_ops.unlink,
  1959. rmdir: MEMFS.node_ops.rmdir,
  1960. readdir: MEMFS.node_ops.readdir,
  1961. symlink: MEMFS.node_ops.symlink
  1962. },
  1963. stream: {
  1964. llseek: MEMFS.stream_ops.llseek
  1965. }
  1966. },
  1967. file: {
  1968. node: {
  1969. getattr: MEMFS.node_ops.getattr,
  1970. setattr: MEMFS.node_ops.setattr
  1971. },
  1972. stream: {
  1973. llseek: MEMFS.stream_ops.llseek,
  1974. read: MEMFS.stream_ops.read,
  1975. write: MEMFS.stream_ops.write,
  1976. allocate: MEMFS.stream_ops.allocate,
  1977. mmap: MEMFS.stream_ops.mmap,
  1978. msync: MEMFS.stream_ops.msync
  1979. }
  1980. },
  1981. link: {
  1982. node: {
  1983. getattr: MEMFS.node_ops.getattr,
  1984. setattr: MEMFS.node_ops.setattr,
  1985. readlink: MEMFS.node_ops.readlink
  1986. },
  1987. stream: {}
  1988. },
  1989. chrdev: {
  1990. node: {
  1991. getattr: MEMFS.node_ops.getattr,
  1992. setattr: MEMFS.node_ops.setattr
  1993. },
  1994. stream: FS.chrdev_stream_ops
  1995. }
  1996. };
  1997. }
  1998. var node = FS.createNode(parent, name, mode, dev);
  1999. if (FS.isDir(node.mode)) {
  2000. node.node_ops = MEMFS.ops_table.dir.node;
  2001. node.stream_ops = MEMFS.ops_table.dir.stream;
  2002. node.contents = {};
  2003. } else if (FS.isFile(node.mode)) {
  2004. node.node_ops = MEMFS.ops_table.file.node;
  2005. node.stream_ops = MEMFS.ops_table.file.stream;
  2006. node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity.
  2007. // 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
  2008. // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size
  2009. // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme.
  2010. node.contents = null;
  2011. } else if (FS.isLink(node.mode)) {
  2012. node.node_ops = MEMFS.ops_table.link.node;
  2013. node.stream_ops = MEMFS.ops_table.link.stream;
  2014. } else if (FS.isChrdev(node.mode)) {
  2015. node.node_ops = MEMFS.ops_table.chrdev.node;
  2016. node.stream_ops = MEMFS.ops_table.chrdev.stream;
  2017. }
  2018. node.timestamp = Date.now();
  2019. // add the new node to the parent
  2020. if (parent) {
  2021. parent.contents[name] = node;
  2022. }
  2023. return node;
  2024. },getFileDataAsRegularArray:function(node) {
  2025. if (node.contents && node.contents.subarray) {
  2026. var arr = [];
  2027. for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]);
  2028. return arr; // Returns a copy of the original data.
  2029. }
  2030. return node.contents; // No-op, the file contents are already in a JS array. Return as-is.
  2031. },getFileDataAsTypedArray:function(node) {
  2032. if (!node.contents) return new Uint8Array(0);
  2033. if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes.
  2034. return new Uint8Array(node.contents);
  2035. },expandFileStorage:function(node, newCapacity) {
  2036. var prevCapacity = node.contents ? node.contents.length : 0;
  2037. if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough.
  2038. // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity.
  2039. // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to
  2040. // avoid overshooting the allocation cap by a very large margin.
  2041. var CAPACITY_DOUBLING_MAX = 1024 * 1024;
  2042. newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0);
  2043. if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding.
  2044. var oldContents = node.contents;
  2045. node.contents = new Uint8Array(newCapacity); // Allocate new storage.
  2046. if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage.
  2047. return;
  2048. },resizeFileStorage:function(node, newSize) {
  2049. if (node.usedBytes == newSize) return;
  2050. if (newSize == 0) {
  2051. node.contents = null; // Fully decommit when requesting a resize to zero.
  2052. node.usedBytes = 0;
  2053. return;
  2054. }
  2055. if (!node.contents || node.contents.subarray) { // Resize a typed array if that is being used as the backing store.
  2056. var oldContents = node.contents;
  2057. node.contents = new Uint8Array(newSize); // Allocate new storage.
  2058. if (oldContents) {
  2059. node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
  2060. }
  2061. node.usedBytes = newSize;
  2062. return;
  2063. }
  2064. // Backing with a JS array.
  2065. if (!node.contents) node.contents = [];
  2066. if (node.contents.length > newSize) node.contents.length = newSize;
  2067. else while (node.contents.length < newSize) node.contents.push(0);
  2068. node.usedBytes = newSize;
  2069. },node_ops:{getattr:function(node) {
  2070. var attr = {};
  2071. // device numbers reuse inode numbers.
  2072. attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
  2073. attr.ino = node.id;
  2074. attr.mode = node.mode;
  2075. attr.nlink = 1;
  2076. attr.uid = 0;
  2077. attr.gid = 0;
  2078. attr.rdev = node.rdev;
  2079. if (FS.isDir(node.mode)) {
  2080. attr.size = 4096;
  2081. } else if (FS.isFile(node.mode)) {
  2082. attr.size = node.usedBytes;
  2083. } else if (FS.isLink(node.mode)) {
  2084. attr.size = node.link.length;
  2085. } else {
  2086. attr.size = 0;
  2087. }
  2088. attr.atime = new Date(node.timestamp);
  2089. attr.mtime = new Date(node.timestamp);
  2090. attr.ctime = new Date(node.timestamp);
  2091. // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
  2092. // but this is not required by the standard.
  2093. attr.blksize = 4096;
  2094. attr.blocks = Math.ceil(attr.size / attr.blksize);
  2095. return attr;
  2096. },setattr:function(node, attr) {
  2097. if (attr.mode !== undefined) {
  2098. node.mode = attr.mode;
  2099. }
  2100. if (attr.timestamp !== undefined) {
  2101. node.timestamp = attr.timestamp;
  2102. }
  2103. if (attr.size !== undefined) {
  2104. MEMFS.resizeFileStorage(node, attr.size);
  2105. }
  2106. },lookup:function(parent, name) {
  2107. throw FS.genericErrors[44];
  2108. },mknod:function(parent, name, mode, dev) {
  2109. return MEMFS.createNode(parent, name, mode, dev);
  2110. },rename:function(old_node, new_dir, new_name) {
  2111. // if we're overwriting a directory at new_name, make sure it's empty.
  2112. if (FS.isDir(old_node.mode)) {
  2113. var new_node;
  2114. try {
  2115. new_node = FS.lookupNode(new_dir, new_name);
  2116. } catch (e) {
  2117. }
  2118. if (new_node) {
  2119. for (var i in new_node.contents) {
  2120. throw new FS.ErrnoError(55);
  2121. }
  2122. }
  2123. }
  2124. // do the internal rewiring
  2125. delete old_node.parent.contents[old_node.name];
  2126. old_node.name = new_name;
  2127. new_dir.contents[new_name] = old_node;
  2128. old_node.parent = new_dir;
  2129. },unlink:function(parent, name) {
  2130. delete parent.contents[name];
  2131. },rmdir:function(parent, name) {
  2132. var node = FS.lookupNode(parent, name);
  2133. for (var i in node.contents) {
  2134. throw new FS.ErrnoError(55);
  2135. }
  2136. delete parent.contents[name];
  2137. },readdir:function(node) {
  2138. var entries = ['.', '..'];
  2139. for (var key in node.contents) {
  2140. if (!node.contents.hasOwnProperty(key)) {
  2141. continue;
  2142. }
  2143. entries.push(key);
  2144. }
  2145. return entries;
  2146. },symlink:function(parent, newname, oldpath) {
  2147. var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
  2148. node.link = oldpath;
  2149. return node;
  2150. },readlink:function(node) {
  2151. if (!FS.isLink(node.mode)) {
  2152. throw new FS.ErrnoError(28);
  2153. }
  2154. return node.link;
  2155. }},stream_ops:{read:function(stream, buffer, offset, length, position) {
  2156. var contents = stream.node.contents;
  2157. if (position >= stream.node.usedBytes) return 0;
  2158. var size = Math.min(stream.node.usedBytes - position, length);
  2159. assert(size >= 0);
  2160. if (size > 8 && contents.subarray) { // non-trivial, and typed array
  2161. buffer.set(contents.subarray(position, position + size), offset);
  2162. } else {
  2163. for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
  2164. }
  2165. return size;
  2166. },write:function(stream, buffer, offset, length, position, canOwn) {
  2167. // The data buffer should be a typed array view
  2168. assert(!(buffer instanceof ArrayBuffer));
  2169. if (!length) return 0;
  2170. var node = stream.node;
  2171. node.timestamp = Date.now();
  2172. if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array?
  2173. if (canOwn) {
  2174. assert(position === 0, 'canOwn must imply no weird position inside the file');
  2175. node.contents = buffer.subarray(offset, offset + length);
  2176. node.usedBytes = length;
  2177. return length;
  2178. } 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.
  2179. node.contents = buffer.slice(offset, offset + length);
  2180. node.usedBytes = length;
  2181. return length;
  2182. } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file?
  2183. node.contents.set(buffer.subarray(offset, offset + length), position);
  2184. return length;
  2185. }
  2186. }
  2187. // Appending to an existing file and we need to reallocate, or source data did not come as a typed array.
  2188. MEMFS.expandFileStorage(node, position+length);
  2189. if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position); // Use typed array write if available.
  2190. else {
  2191. for (var i = 0; i < length; i++) {
  2192. node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not.
  2193. }
  2194. }
  2195. node.usedBytes = Math.max(node.usedBytes, position + length);
  2196. return length;
  2197. },llseek:function(stream, offset, whence) {
  2198. var position = offset;
  2199. if (whence === 1) {
  2200. position += stream.position;
  2201. } else if (whence === 2) {
  2202. if (FS.isFile(stream.node.mode)) {
  2203. position += stream.node.usedBytes;
  2204. }
  2205. }
  2206. if (position < 0) {
  2207. throw new FS.ErrnoError(28);
  2208. }
  2209. return position;
  2210. },allocate:function(stream, offset, length) {
  2211. MEMFS.expandFileStorage(stream.node, offset + length);
  2212. stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
  2213. },mmap:function(stream, buffer, offset, length, position, prot, flags) {
  2214. // The data buffer should be a typed array view
  2215. assert(!(buffer instanceof ArrayBuffer));
  2216. if (!FS.isFile(stream.node.mode)) {
  2217. throw new FS.ErrnoError(43);
  2218. }
  2219. var ptr;
  2220. var allocated;
  2221. var contents = stream.node.contents;
  2222. // Only make a new copy when MAP_PRIVATE is specified.
  2223. if ( !(flags & 2) &&
  2224. contents.buffer === buffer.buffer ) {
  2225. // We can't emulate MAP_SHARED when the file is not backed by the buffer
  2226. // we're mapping to (e.g. the HEAP buffer).
  2227. allocated = false;
  2228. ptr = contents.byteOffset;
  2229. } else {
  2230. // Try to avoid unnecessary slices.
  2231. if (position > 0 || position + length < contents.length) {
  2232. if (contents.subarray) {
  2233. contents = contents.subarray(position, position + length);
  2234. } else {
  2235. contents = Array.prototype.slice.call(contents, position, position + length);
  2236. }
  2237. }
  2238. allocated = true;
  2239. // malloc() can lead to growing the heap. If targeting the heap, we need to
  2240. // re-acquire the heap buffer object in case growth had occurred.
  2241. var fromHeap = (buffer.buffer == HEAP8.buffer);
  2242. ptr = _malloc(length);
  2243. if (!ptr) {
  2244. throw new FS.ErrnoError(48);
  2245. }
  2246. (fromHeap ? HEAP8 : buffer).set(contents, ptr);
  2247. }
  2248. return { ptr: ptr, allocated: allocated };
  2249. },msync:function(stream, buffer, offset, length, mmapFlags) {
  2250. if (!FS.isFile(stream.node.mode)) {
  2251. throw new FS.ErrnoError(43);
  2252. }
  2253. if (mmapFlags & 2) {
  2254. // MAP_PRIVATE calls need not to be synced back to underlying fs
  2255. return 0;
  2256. }
  2257. var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
  2258. // should we check if bytesWritten and length are the same?
  2259. return 0;
  2260. }}};
  2261. 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"};
  2262. 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) {
  2263. if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
  2264. return setErrNo(e.errno);
  2265. },lookupPath:function(path, opts) {
  2266. path = PATH_FS.resolve(FS.cwd(), path);
  2267. opts = opts || {};
  2268. if (!path) return { path: '', node: null };
  2269. var defaults = {
  2270. follow_mount: true,
  2271. recurse_count: 0
  2272. };
  2273. for (var key in defaults) {
  2274. if (opts[key] === undefined) {
  2275. opts[key] = defaults[key];
  2276. }
  2277. }
  2278. if (opts.recurse_count > 8) { // max recursive lookup of 8
  2279. throw new FS.ErrnoError(32);
  2280. }
  2281. // split the path
  2282. var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
  2283. return !!p;
  2284. }), false);
  2285. // start at the root
  2286. var current = FS.root;
  2287. var current_path = '/';
  2288. for (var i = 0; i < parts.length; i++) {
  2289. var islast = (i === parts.length-1);
  2290. if (islast && opts.parent) {
  2291. // stop resolving
  2292. break;
  2293. }
  2294. current = FS.lookupNode(current, parts[i]);
  2295. current_path = PATH.join2(current_path, parts[i]);
  2296. // jump to the mount's root node if this is a mountpoint
  2297. if (FS.isMountpoint(current)) {
  2298. if (!islast || (islast && opts.follow_mount)) {
  2299. current = current.mounted.root;
  2300. }
  2301. }
  2302. // by default, lookupPath will not follow a symlink if it is the final path component.
  2303. // setting opts.follow = true will override this behavior.
  2304. if (!islast || opts.follow) {
  2305. var count = 0;
  2306. while (FS.isLink(current.mode)) {
  2307. var link = FS.readlink(current_path);
  2308. current_path = PATH_FS.resolve(PATH.dirname(current_path), link);
  2309. var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
  2310. current = lookup.node;
  2311. if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
  2312. throw new FS.ErrnoError(32);
  2313. }
  2314. }
  2315. }
  2316. }
  2317. return { path: current_path, node: current };
  2318. },getPath:function(node) {
  2319. var path;
  2320. while (true) {
  2321. if (FS.isRoot(node)) {
  2322. var mount = node.mount.mountpoint;
  2323. if (!path) return mount;
  2324. return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
  2325. }
  2326. path = path ? node.name + '/' + path : node.name;
  2327. node = node.parent;
  2328. }
  2329. },hashName:function(parentid, name) {
  2330. var hash = 0;
  2331. for (var i = 0; i < name.length; i++) {
  2332. hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
  2333. }
  2334. return ((parentid + hash) >>> 0) % FS.nameTable.length;
  2335. },hashAddNode:function(node) {
  2336. var hash = FS.hashName(node.parent.id, node.name);
  2337. node.name_next = FS.nameTable[hash];
  2338. FS.nameTable[hash] = node;
  2339. },hashRemoveNode:function(node) {
  2340. var hash = FS.hashName(node.parent.id, node.name);
  2341. if (FS.nameTable[hash] === node) {
  2342. FS.nameTable[hash] = node.name_next;
  2343. } else {
  2344. var current = FS.nameTable[hash];
  2345. while (current) {
  2346. if (current.name_next === node) {
  2347. current.name_next = node.name_next;
  2348. break;
  2349. }
  2350. current = current.name_next;
  2351. }
  2352. }
  2353. },lookupNode:function(parent, name) {
  2354. var errCode = FS.mayLookup(parent);
  2355. if (errCode) {
  2356. throw new FS.ErrnoError(errCode, parent);
  2357. }
  2358. var hash = FS.hashName(parent.id, name);
  2359. for (var node = FS.nameTable[hash]; node; node = node.name_next) {
  2360. var nodeName = node.name;
  2361. if (node.parent.id === parent.id && nodeName === name) {
  2362. return node;
  2363. }
  2364. }
  2365. // if we failed to find it in the cache, call into the VFS
  2366. return FS.lookup(parent, name);
  2367. },createNode:function(parent, name, mode, rdev) {
  2368. var node = new FS.FSNode(parent, name, mode, rdev);
  2369. FS.hashAddNode(node);
  2370. return node;
  2371. },destroyNode:function(node) {
  2372. FS.hashRemoveNode(node);
  2373. },isRoot:function(node) {
  2374. return node === node.parent;
  2375. },isMountpoint:function(node) {
  2376. return !!node.mounted;
  2377. },isFile:function(mode) {
  2378. return (mode & 61440) === 32768;
  2379. },isDir:function(mode) {
  2380. return (mode & 61440) === 16384;
  2381. },isLink:function(mode) {
  2382. return (mode & 61440) === 40960;
  2383. },isChrdev:function(mode) {
  2384. return (mode & 61440) === 8192;
  2385. },isBlkdev:function(mode) {
  2386. return (mode & 61440) === 24576;
  2387. },isFIFO:function(mode) {
  2388. return (mode & 61440) === 4096;
  2389. },isSocket:function(mode) {
  2390. return (mode & 49152) === 49152;
  2391. },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) {
  2392. var flags = FS.flagModes[str];
  2393. if (typeof flags === 'undefined') {
  2394. throw new Error('Unknown file open mode: ' + str);
  2395. }
  2396. return flags;
  2397. },flagsToPermissionString:function(flag) {
  2398. var perms = ['r', 'w', 'rw'][flag & 3];
  2399. if ((flag & 512)) {
  2400. perms += 'w';
  2401. }
  2402. return perms;
  2403. },nodePermissions:function(node, perms) {
  2404. if (FS.ignorePermissions) {
  2405. return 0;
  2406. }
  2407. // return 0 if any user, group or owner bits are set.
  2408. if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
  2409. return 2;
  2410. } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
  2411. return 2;
  2412. } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
  2413. return 2;
  2414. }
  2415. return 0;
  2416. },mayLookup:function(dir) {
  2417. var errCode = FS.nodePermissions(dir, 'x');
  2418. if (errCode) return errCode;
  2419. if (!dir.node_ops.lookup) return 2;
  2420. return 0;
  2421. },mayCreate:function(dir, name) {
  2422. try {
  2423. var node = FS.lookupNode(dir, name);
  2424. return 20;
  2425. } catch (e) {
  2426. }
  2427. return FS.nodePermissions(dir, 'wx');
  2428. },mayDelete:function(dir, name, isdir) {
  2429. var node;
  2430. try {
  2431. node = FS.lookupNode(dir, name);
  2432. } catch (e) {
  2433. return e.errno;
  2434. }
  2435. var errCode = FS.nodePermissions(dir, 'wx');
  2436. if (errCode) {
  2437. return errCode;
  2438. }
  2439. if (isdir) {
  2440. if (!FS.isDir(node.mode)) {
  2441. return 54;
  2442. }
  2443. if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
  2444. return 10;
  2445. }
  2446. } else {
  2447. if (FS.isDir(node.mode)) {
  2448. return 31;
  2449. }
  2450. }
  2451. return 0;
  2452. },mayOpen:function(node, flags) {
  2453. if (!node) {
  2454. return 44;
  2455. }
  2456. if (FS.isLink(node.mode)) {
  2457. return 32;
  2458. } else if (FS.isDir(node.mode)) {
  2459. if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write
  2460. (flags & 512)) { // TODO: check for O_SEARCH? (== search for dir only)
  2461. return 31;
  2462. }
  2463. }
  2464. return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
  2465. },MAX_OPEN_FDS:4096,nextfd:function(fd_start, fd_end) {
  2466. fd_start = fd_start || 0;
  2467. fd_end = fd_end || FS.MAX_OPEN_FDS;
  2468. for (var fd = fd_start; fd <= fd_end; fd++) {
  2469. if (!FS.streams[fd]) {
  2470. return fd;
  2471. }
  2472. }
  2473. throw new FS.ErrnoError(33);
  2474. },getStream:function(fd) {
  2475. return FS.streams[fd];
  2476. },createStream:function(stream, fd_start, fd_end) {
  2477. if (!FS.FSStream) {
  2478. FS.FSStream = /** @constructor */ function(){};
  2479. FS.FSStream.prototype = {
  2480. object: {
  2481. get: function() { return this.node; },
  2482. set: function(val) { this.node = val; }
  2483. },
  2484. isRead: {
  2485. get: function() { return (this.flags & 2097155) !== 1; }
  2486. },
  2487. isWrite: {
  2488. get: function() { return (this.flags & 2097155) !== 0; }
  2489. },
  2490. isAppend: {
  2491. get: function() { return (this.flags & 1024); }
  2492. }
  2493. };
  2494. }
  2495. // clone it, so we can return an instance of FSStream
  2496. var newStream = new FS.FSStream();
  2497. for (var p in stream) {
  2498. newStream[p] = stream[p];
  2499. }
  2500. stream = newStream;
  2501. var fd = FS.nextfd(fd_start, fd_end);
  2502. stream.fd = fd;
  2503. FS.streams[fd] = stream;
  2504. return stream;
  2505. },closeStream:function(fd) {
  2506. FS.streams[fd] = null;
  2507. },chrdev_stream_ops:{open:function(stream) {
  2508. var device = FS.getDevice(stream.node.rdev);
  2509. // override node's stream ops with the device's
  2510. stream.stream_ops = device.stream_ops;
  2511. // forward the open call
  2512. if (stream.stream_ops.open) {
  2513. stream.stream_ops.open(stream);
  2514. }
  2515. },llseek:function() {
  2516. throw new FS.ErrnoError(70);
  2517. }},major:function(dev) {
  2518. return ((dev) >> 8);
  2519. },minor:function(dev) {
  2520. return ((dev) & 0xff);
  2521. },makedev:function(ma, mi) {
  2522. return ((ma) << 8 | (mi));
  2523. },registerDevice:function(dev, ops) {
  2524. FS.devices[dev] = { stream_ops: ops };
  2525. },getDevice:function(dev) {
  2526. return FS.devices[dev];
  2527. },getMounts:function(mount) {
  2528. var mounts = [];
  2529. var check = [mount];
  2530. while (check.length) {
  2531. var m = check.pop();
  2532. mounts.push(m);
  2533. check.push.apply(check, m.mounts);
  2534. }
  2535. return mounts;
  2536. },syncfs:function(populate, callback) {
  2537. if (typeof(populate) === 'function') {
  2538. callback = populate;
  2539. populate = false;
  2540. }
  2541. FS.syncFSRequests++;
  2542. if (FS.syncFSRequests > 1) {
  2543. err('warning: ' + FS.syncFSRequests + ' FS.syncfs operations in flight at once, probably just doing extra work');
  2544. }
  2545. var mounts = FS.getMounts(FS.root.mount);
  2546. var completed = 0;
  2547. function doCallback(errCode) {
  2548. assert(FS.syncFSRequests > 0);
  2549. FS.syncFSRequests--;
  2550. return callback(errCode);
  2551. }
  2552. function done(errCode) {
  2553. if (errCode) {
  2554. if (!done.errored) {
  2555. done.errored = true;
  2556. return doCallback(errCode);
  2557. }
  2558. return;
  2559. }
  2560. if (++completed >= mounts.length) {
  2561. doCallback(null);
  2562. }
  2563. };
  2564. // sync all mounts
  2565. mounts.forEach(function (mount) {
  2566. if (!mount.type.syncfs) {
  2567. return done(null);
  2568. }
  2569. mount.type.syncfs(mount, populate, done);
  2570. });
  2571. },mount:function(type, opts, mountpoint) {
  2572. if (typeof type === 'string') {
  2573. // The filesystem was not included, and instead we have an error
  2574. // message stored in the variable.
  2575. throw type;
  2576. }
  2577. var root = mountpoint === '/';
  2578. var pseudo = !mountpoint;
  2579. var node;
  2580. if (root && FS.root) {
  2581. throw new FS.ErrnoError(10);
  2582. } else if (!root && !pseudo) {
  2583. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2584. mountpoint = lookup.path; // use the absolute path
  2585. node = lookup.node;
  2586. if (FS.isMountpoint(node)) {
  2587. throw new FS.ErrnoError(10);
  2588. }
  2589. if (!FS.isDir(node.mode)) {
  2590. throw new FS.ErrnoError(54);
  2591. }
  2592. }
  2593. var mount = {
  2594. type: type,
  2595. opts: opts,
  2596. mountpoint: mountpoint,
  2597. mounts: []
  2598. };
  2599. // create a root node for the fs
  2600. var mountRoot = type.mount(mount);
  2601. mountRoot.mount = mount;
  2602. mount.root = mountRoot;
  2603. if (root) {
  2604. FS.root = mountRoot;
  2605. } else if (node) {
  2606. // set as a mountpoint
  2607. node.mounted = mount;
  2608. // add the new mount to the current mount's children
  2609. if (node.mount) {
  2610. node.mount.mounts.push(mount);
  2611. }
  2612. }
  2613. return mountRoot;
  2614. },unmount:function (mountpoint) {
  2615. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2616. if (!FS.isMountpoint(lookup.node)) {
  2617. throw new FS.ErrnoError(28);
  2618. }
  2619. // destroy the nodes for this mount, and all its child mounts
  2620. var node = lookup.node;
  2621. var mount = node.mounted;
  2622. var mounts = FS.getMounts(mount);
  2623. Object.keys(FS.nameTable).forEach(function (hash) {
  2624. var current = FS.nameTable[hash];
  2625. while (current) {
  2626. var next = current.name_next;
  2627. if (mounts.indexOf(current.mount) !== -1) {
  2628. FS.destroyNode(current);
  2629. }
  2630. current = next;
  2631. }
  2632. });
  2633. // no longer a mountpoint
  2634. node.mounted = null;
  2635. // remove this mount from the child mounts
  2636. var idx = node.mount.mounts.indexOf(mount);
  2637. assert(idx !== -1);
  2638. node.mount.mounts.splice(idx, 1);
  2639. },lookup:function(parent, name) {
  2640. return parent.node_ops.lookup(parent, name);
  2641. },mknod:function(path, mode, dev) {
  2642. var lookup = FS.lookupPath(path, { parent: true });
  2643. var parent = lookup.node;
  2644. var name = PATH.basename(path);
  2645. if (!name || name === '.' || name === '..') {
  2646. throw new FS.ErrnoError(28);
  2647. }
  2648. var errCode = FS.mayCreate(parent, name);
  2649. if (errCode) {
  2650. throw new FS.ErrnoError(errCode);
  2651. }
  2652. if (!parent.node_ops.mknod) {
  2653. throw new FS.ErrnoError(63);
  2654. }
  2655. return parent.node_ops.mknod(parent, name, mode, dev);
  2656. },create:function(path, mode) {
  2657. mode = mode !== undefined ? mode : 438 /* 0666 */;
  2658. mode &= 4095;
  2659. mode |= 32768;
  2660. return FS.mknod(path, mode, 0);
  2661. },mkdir:function(path, mode) {
  2662. mode = mode !== undefined ? mode : 511 /* 0777 */;
  2663. mode &= 511 | 512;
  2664. mode |= 16384;
  2665. return FS.mknod(path, mode, 0);
  2666. },mkdirTree:function(path, mode) {
  2667. var dirs = path.split('/');
  2668. var d = '';
  2669. for (var i = 0; i < dirs.length; ++i) {
  2670. if (!dirs[i]) continue;
  2671. d += '/' + dirs[i];
  2672. try {
  2673. FS.mkdir(d, mode);
  2674. } catch(e) {
  2675. if (e.errno != 20) throw e;
  2676. }
  2677. }
  2678. },mkdev:function(path, mode, dev) {
  2679. if (typeof(dev) === 'undefined') {
  2680. dev = mode;
  2681. mode = 438 /* 0666 */;
  2682. }
  2683. mode |= 8192;
  2684. return FS.mknod(path, mode, dev);
  2685. },symlink:function(oldpath, newpath) {
  2686. if (!PATH_FS.resolve(oldpath)) {
  2687. throw new FS.ErrnoError(44);
  2688. }
  2689. var lookup = FS.lookupPath(newpath, { parent: true });
  2690. var parent = lookup.node;
  2691. if (!parent) {
  2692. throw new FS.ErrnoError(44);
  2693. }
  2694. var newname = PATH.basename(newpath);
  2695. var errCode = FS.mayCreate(parent, newname);
  2696. if (errCode) {
  2697. throw new FS.ErrnoError(errCode);
  2698. }
  2699. if (!parent.node_ops.symlink) {
  2700. throw new FS.ErrnoError(63);
  2701. }
  2702. return parent.node_ops.symlink(parent, newname, oldpath);
  2703. },rename:function(old_path, new_path) {
  2704. var old_dirname = PATH.dirname(old_path);
  2705. var new_dirname = PATH.dirname(new_path);
  2706. var old_name = PATH.basename(old_path);
  2707. var new_name = PATH.basename(new_path);
  2708. // parents must exist
  2709. var lookup, old_dir, new_dir;
  2710. try {
  2711. lookup = FS.lookupPath(old_path, { parent: true });
  2712. old_dir = lookup.node;
  2713. lookup = FS.lookupPath(new_path, { parent: true });
  2714. new_dir = lookup.node;
  2715. } catch (e) {
  2716. throw new FS.ErrnoError(10);
  2717. }
  2718. if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
  2719. // need to be part of the same mount
  2720. if (old_dir.mount !== new_dir.mount) {
  2721. throw new FS.ErrnoError(75);
  2722. }
  2723. // source must exist
  2724. var old_node = FS.lookupNode(old_dir, old_name);
  2725. // old path should not be an ancestor of the new path
  2726. var relative = PATH_FS.relative(old_path, new_dirname);
  2727. if (relative.charAt(0) !== '.') {
  2728. throw new FS.ErrnoError(28);
  2729. }
  2730. // new path should not be an ancestor of the old path
  2731. relative = PATH_FS.relative(new_path, old_dirname);
  2732. if (relative.charAt(0) !== '.') {
  2733. throw new FS.ErrnoError(55);
  2734. }
  2735. // see if the new path already exists
  2736. var new_node;
  2737. try {
  2738. new_node = FS.lookupNode(new_dir, new_name);
  2739. } catch (e) {
  2740. // not fatal
  2741. }
  2742. // early out if nothing needs to change
  2743. if (old_node === new_node) {
  2744. return;
  2745. }
  2746. // we'll need to delete the old entry
  2747. var isdir = FS.isDir(old_node.mode);
  2748. var errCode = FS.mayDelete(old_dir, old_name, isdir);
  2749. if (errCode) {
  2750. throw new FS.ErrnoError(errCode);
  2751. }
  2752. // need delete permissions if we'll be overwriting.
  2753. // need create permissions if new doesn't already exist.
  2754. errCode = new_node ?
  2755. FS.mayDelete(new_dir, new_name, isdir) :
  2756. FS.mayCreate(new_dir, new_name);
  2757. if (errCode) {
  2758. throw new FS.ErrnoError(errCode);
  2759. }
  2760. if (!old_dir.node_ops.rename) {
  2761. throw new FS.ErrnoError(63);
  2762. }
  2763. if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
  2764. throw new FS.ErrnoError(10);
  2765. }
  2766. // if we are going to change the parent, check write permissions
  2767. if (new_dir !== old_dir) {
  2768. errCode = FS.nodePermissions(old_dir, 'w');
  2769. if (errCode) {
  2770. throw new FS.ErrnoError(errCode);
  2771. }
  2772. }
  2773. try {
  2774. if (FS.trackingDelegate['willMovePath']) {
  2775. FS.trackingDelegate['willMovePath'](old_path, new_path);
  2776. }
  2777. } catch(e) {
  2778. err("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
  2779. }
  2780. // remove the node from the lookup hash
  2781. FS.hashRemoveNode(old_node);
  2782. // do the underlying fs rename
  2783. try {
  2784. old_dir.node_ops.rename(old_node, new_dir, new_name);
  2785. } catch (e) {
  2786. throw e;
  2787. } finally {
  2788. // add the node back to the hash (in case node_ops.rename
  2789. // changed its name)
  2790. FS.hashAddNode(old_node);
  2791. }
  2792. try {
  2793. if (FS.trackingDelegate['onMovePath']) FS.trackingDelegate['onMovePath'](old_path, new_path);
  2794. } catch(e) {
  2795. err("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
  2796. }
  2797. },rmdir:function(path) {
  2798. var lookup = FS.lookupPath(path, { parent: true });
  2799. var parent = lookup.node;
  2800. var name = PATH.basename(path);
  2801. var node = FS.lookupNode(parent, name);
  2802. var errCode = FS.mayDelete(parent, name, true);
  2803. if (errCode) {
  2804. throw new FS.ErrnoError(errCode);
  2805. }
  2806. if (!parent.node_ops.rmdir) {
  2807. throw new FS.ErrnoError(63);
  2808. }
  2809. if (FS.isMountpoint(node)) {
  2810. throw new FS.ErrnoError(10);
  2811. }
  2812. try {
  2813. if (FS.trackingDelegate['willDeletePath']) {
  2814. FS.trackingDelegate['willDeletePath'](path);
  2815. }
  2816. } catch(e) {
  2817. err("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
  2818. }
  2819. parent.node_ops.rmdir(parent, name);
  2820. FS.destroyNode(node);
  2821. try {
  2822. if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
  2823. } catch(e) {
  2824. err("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
  2825. }
  2826. },readdir:function(path) {
  2827. var lookup = FS.lookupPath(path, { follow: true });
  2828. var node = lookup.node;
  2829. if (!node.node_ops.readdir) {
  2830. throw new FS.ErrnoError(54);
  2831. }
  2832. return node.node_ops.readdir(node);
  2833. },unlink:function(path) {
  2834. var lookup = FS.lookupPath(path, { parent: true });
  2835. var parent = lookup.node;
  2836. var name = PATH.basename(path);
  2837. var node = FS.lookupNode(parent, name);
  2838. var errCode = FS.mayDelete(parent, name, false);
  2839. if (errCode) {
  2840. // According to POSIX, we should map EISDIR to EPERM, but
  2841. // we instead do what Linux does (and we must, as we use
  2842. // the musl linux libc).
  2843. throw new FS.ErrnoError(errCode);
  2844. }
  2845. if (!parent.node_ops.unlink) {
  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.unlink(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. },readlink:function(path) {
  2866. var lookup = FS.lookupPath(path);
  2867. var link = lookup.node;
  2868. if (!link) {
  2869. throw new FS.ErrnoError(44);
  2870. }
  2871. if (!link.node_ops.readlink) {
  2872. throw new FS.ErrnoError(28);
  2873. }
  2874. return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
  2875. },stat:function(path, dontFollow) {
  2876. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2877. var node = lookup.node;
  2878. if (!node) {
  2879. throw new FS.ErrnoError(44);
  2880. }
  2881. if (!node.node_ops.getattr) {
  2882. throw new FS.ErrnoError(63);
  2883. }
  2884. return node.node_ops.getattr(node);
  2885. },lstat:function(path) {
  2886. return FS.stat(path, true);
  2887. },chmod:function(path, mode, dontFollow) {
  2888. var node;
  2889. if (typeof path === 'string') {
  2890. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2891. node = lookup.node;
  2892. } else {
  2893. node = path;
  2894. }
  2895. if (!node.node_ops.setattr) {
  2896. throw new FS.ErrnoError(63);
  2897. }
  2898. node.node_ops.setattr(node, {
  2899. mode: (mode & 4095) | (node.mode & ~4095),
  2900. timestamp: Date.now()
  2901. });
  2902. },lchmod:function(path, mode) {
  2903. FS.chmod(path, mode, true);
  2904. },fchmod:function(fd, mode) {
  2905. var stream = FS.getStream(fd);
  2906. if (!stream) {
  2907. throw new FS.ErrnoError(8);
  2908. }
  2909. FS.chmod(stream.node, mode);
  2910. },chown:function(path, uid, gid, dontFollow) {
  2911. var node;
  2912. if (typeof path === 'string') {
  2913. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  2914. node = lookup.node;
  2915. } else {
  2916. node = path;
  2917. }
  2918. if (!node.node_ops.setattr) {
  2919. throw new FS.ErrnoError(63);
  2920. }
  2921. node.node_ops.setattr(node, {
  2922. timestamp: Date.now()
  2923. // we ignore the uid / gid for now
  2924. });
  2925. },lchown:function(path, uid, gid) {
  2926. FS.chown(path, uid, gid, true);
  2927. },fchown:function(fd, uid, gid) {
  2928. var stream = FS.getStream(fd);
  2929. if (!stream) {
  2930. throw new FS.ErrnoError(8);
  2931. }
  2932. FS.chown(stream.node, uid, gid);
  2933. },truncate:function(path, len) {
  2934. if (len < 0) {
  2935. throw new FS.ErrnoError(28);
  2936. }
  2937. var node;
  2938. if (typeof path === 'string') {
  2939. var lookup = FS.lookupPath(path, { follow: true });
  2940. node = lookup.node;
  2941. } else {
  2942. node = path;
  2943. }
  2944. if (!node.node_ops.setattr) {
  2945. throw new FS.ErrnoError(63);
  2946. }
  2947. if (FS.isDir(node.mode)) {
  2948. throw new FS.ErrnoError(31);
  2949. }
  2950. if (!FS.isFile(node.mode)) {
  2951. throw new FS.ErrnoError(28);
  2952. }
  2953. var errCode = FS.nodePermissions(node, 'w');
  2954. if (errCode) {
  2955. throw new FS.ErrnoError(errCode);
  2956. }
  2957. node.node_ops.setattr(node, {
  2958. size: len,
  2959. timestamp: Date.now()
  2960. });
  2961. },ftruncate:function(fd, len) {
  2962. var stream = FS.getStream(fd);
  2963. if (!stream) {
  2964. throw new FS.ErrnoError(8);
  2965. }
  2966. if ((stream.flags & 2097155) === 0) {
  2967. throw new FS.ErrnoError(28);
  2968. }
  2969. FS.truncate(stream.node, len);
  2970. },utime:function(path, atime, mtime) {
  2971. var lookup = FS.lookupPath(path, { follow: true });
  2972. var node = lookup.node;
  2973. node.node_ops.setattr(node, {
  2974. timestamp: Math.max(atime, mtime)
  2975. });
  2976. },open:function(path, flags, mode, fd_start, fd_end) {
  2977. if (path === "") {
  2978. throw new FS.ErrnoError(44);
  2979. }
  2980. flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
  2981. mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
  2982. if ((flags & 64)) {
  2983. mode = (mode & 4095) | 32768;
  2984. } else {
  2985. mode = 0;
  2986. }
  2987. var node;
  2988. if (typeof path === 'object') {
  2989. node = path;
  2990. } else {
  2991. path = PATH.normalize(path);
  2992. try {
  2993. var lookup = FS.lookupPath(path, {
  2994. follow: !(flags & 131072)
  2995. });
  2996. node = lookup.node;
  2997. } catch (e) {
  2998. // ignore
  2999. }
  3000. }
  3001. // perhaps we need to create the node
  3002. var created = false;
  3003. if ((flags & 64)) {
  3004. if (node) {
  3005. // if O_CREAT and O_EXCL are set, error out if the node already exists
  3006. if ((flags & 128)) {
  3007. throw new FS.ErrnoError(20);
  3008. }
  3009. } else {
  3010. // node doesn't exist, try to create it
  3011. node = FS.mknod(path, mode, 0);
  3012. created = true;
  3013. }
  3014. }
  3015. if (!node) {
  3016. throw new FS.ErrnoError(44);
  3017. }
  3018. // can't truncate a device
  3019. if (FS.isChrdev(node.mode)) {
  3020. flags &= ~512;
  3021. }
  3022. // if asked only for a directory, then this must be one
  3023. if ((flags & 65536) && !FS.isDir(node.mode)) {
  3024. throw new FS.ErrnoError(54);
  3025. }
  3026. // check permissions, if this is not a file we just created now (it is ok to
  3027. // create and write to a file with read-only permissions; it is read-only
  3028. // for later use)
  3029. if (!created) {
  3030. var errCode = FS.mayOpen(node, flags);
  3031. if (errCode) {
  3032. throw new FS.ErrnoError(errCode);
  3033. }
  3034. }
  3035. // do truncation if necessary
  3036. if ((flags & 512)) {
  3037. FS.truncate(node, 0);
  3038. }
  3039. // we've already handled these, don't pass down to the underlying vfs
  3040. flags &= ~(128 | 512 | 131072);
  3041. // register the stream with the filesystem
  3042. var stream = FS.createStream({
  3043. node: node,
  3044. path: FS.getPath(node), // we want the absolute path to the node
  3045. flags: flags,
  3046. seekable: true,
  3047. position: 0,
  3048. stream_ops: node.stream_ops,
  3049. // used by the file family libc calls (fopen, fwrite, ferror, etc.)
  3050. ungotten: [],
  3051. error: false
  3052. }, fd_start, fd_end);
  3053. // call the new stream's open function
  3054. if (stream.stream_ops.open) {
  3055. stream.stream_ops.open(stream);
  3056. }
  3057. if (Module['logReadFiles'] && !(flags & 1)) {
  3058. if (!FS.readFiles) FS.readFiles = {};
  3059. if (!(path in FS.readFiles)) {
  3060. FS.readFiles[path] = 1;
  3061. err("FS.trackingDelegate error on read file: " + path);
  3062. }
  3063. }
  3064. try {
  3065. if (FS.trackingDelegate['onOpenFile']) {
  3066. var trackingFlags = 0;
  3067. if ((flags & 2097155) !== 1) {
  3068. trackingFlags |= FS.tracking.openFlags.READ;
  3069. }
  3070. if ((flags & 2097155) !== 0) {
  3071. trackingFlags |= FS.tracking.openFlags.WRITE;
  3072. }
  3073. FS.trackingDelegate['onOpenFile'](path, trackingFlags);
  3074. }
  3075. } catch(e) {
  3076. err("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: " + e.message);
  3077. }
  3078. return stream;
  3079. },close:function(stream) {
  3080. if (FS.isClosed(stream)) {
  3081. throw new FS.ErrnoError(8);
  3082. }
  3083. if (stream.getdents) stream.getdents = null; // free readdir state
  3084. try {
  3085. if (stream.stream_ops.close) {
  3086. stream.stream_ops.close(stream);
  3087. }
  3088. } catch (e) {
  3089. throw e;
  3090. } finally {
  3091. FS.closeStream(stream.fd);
  3092. }
  3093. stream.fd = null;
  3094. },isClosed:function(stream) {
  3095. return stream.fd === null;
  3096. },llseek:function(stream, offset, whence) {
  3097. if (FS.isClosed(stream)) {
  3098. throw new FS.ErrnoError(8);
  3099. }
  3100. if (!stream.seekable || !stream.stream_ops.llseek) {
  3101. throw new FS.ErrnoError(70);
  3102. }
  3103. if (whence != 0 && whence != 1 && whence != 2) {
  3104. throw new FS.ErrnoError(28);
  3105. }
  3106. stream.position = stream.stream_ops.llseek(stream, offset, whence);
  3107. stream.ungotten = [];
  3108. return stream.position;
  3109. },read:function(stream, buffer, offset, length, position) {
  3110. if (length < 0 || position < 0) {
  3111. throw new FS.ErrnoError(28);
  3112. }
  3113. if (FS.isClosed(stream)) {
  3114. throw new FS.ErrnoError(8);
  3115. }
  3116. if ((stream.flags & 2097155) === 1) {
  3117. throw new FS.ErrnoError(8);
  3118. }
  3119. if (FS.isDir(stream.node.mode)) {
  3120. throw new FS.ErrnoError(31);
  3121. }
  3122. if (!stream.stream_ops.read) {
  3123. throw new FS.ErrnoError(28);
  3124. }
  3125. var seeking = typeof position !== 'undefined';
  3126. if (!seeking) {
  3127. position = stream.position;
  3128. } else if (!stream.seekable) {
  3129. throw new FS.ErrnoError(70);
  3130. }
  3131. var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
  3132. if (!seeking) stream.position += bytesRead;
  3133. return bytesRead;
  3134. },write:function(stream, buffer, offset, length, position, canOwn) {
  3135. if (length < 0 || position < 0) {
  3136. throw new FS.ErrnoError(28);
  3137. }
  3138. if (FS.isClosed(stream)) {
  3139. throw new FS.ErrnoError(8);
  3140. }
  3141. if ((stream.flags & 2097155) === 0) {
  3142. throw new FS.ErrnoError(8);
  3143. }
  3144. if (FS.isDir(stream.node.mode)) {
  3145. throw new FS.ErrnoError(31);
  3146. }
  3147. if (!stream.stream_ops.write) {
  3148. throw new FS.ErrnoError(28);
  3149. }
  3150. if (stream.seekable && stream.flags & 1024) {
  3151. // seek to the end before writing in append mode
  3152. FS.llseek(stream, 0, 2);
  3153. }
  3154. var seeking = typeof position !== 'undefined';
  3155. if (!seeking) {
  3156. position = stream.position;
  3157. } else if (!stream.seekable) {
  3158. throw new FS.ErrnoError(70);
  3159. }
  3160. var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
  3161. if (!seeking) stream.position += bytesWritten;
  3162. try {
  3163. if (stream.path && FS.trackingDelegate['onWriteToFile']) FS.trackingDelegate['onWriteToFile'](stream.path);
  3164. } catch(e) {
  3165. err("FS.trackingDelegate['onWriteToFile']('"+stream.path+"') threw an exception: " + e.message);
  3166. }
  3167. return bytesWritten;
  3168. },allocate:function(stream, offset, length) {
  3169. if (FS.isClosed(stream)) {
  3170. throw new FS.ErrnoError(8);
  3171. }
  3172. if (offset < 0 || length <= 0) {
  3173. throw new FS.ErrnoError(28);
  3174. }
  3175. if ((stream.flags & 2097155) === 0) {
  3176. throw new FS.ErrnoError(8);
  3177. }
  3178. if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
  3179. throw new FS.ErrnoError(43);
  3180. }
  3181. if (!stream.stream_ops.allocate) {
  3182. throw new FS.ErrnoError(138);
  3183. }
  3184. stream.stream_ops.allocate(stream, offset, length);
  3185. },mmap:function(stream, buffer, offset, length, position, prot, flags) {
  3186. // User requests writing to file (prot & PROT_WRITE != 0).
  3187. // Checking if we have permissions to write to the file unless
  3188. // MAP_PRIVATE flag is set. According to POSIX spec it is possible
  3189. // to write to file opened in read-only mode with MAP_PRIVATE flag,
  3190. // as all modifications will be visible only in the memory of
  3191. // the current process.
  3192. if ((prot & 2) !== 0
  3193. && (flags & 2) === 0
  3194. && (stream.flags & 2097155) !== 2) {
  3195. throw new FS.ErrnoError(2);
  3196. }
  3197. if ((stream.flags & 2097155) === 1) {
  3198. throw new FS.ErrnoError(2);
  3199. }
  3200. if (!stream.stream_ops.mmap) {
  3201. throw new FS.ErrnoError(43);
  3202. }
  3203. return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
  3204. },msync:function(stream, buffer, offset, length, mmapFlags) {
  3205. if (!stream || !stream.stream_ops.msync) {
  3206. return 0;
  3207. }
  3208. return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
  3209. },munmap:function(stream) {
  3210. return 0;
  3211. },ioctl:function(stream, cmd, arg) {
  3212. if (!stream.stream_ops.ioctl) {
  3213. throw new FS.ErrnoError(59);
  3214. }
  3215. return stream.stream_ops.ioctl(stream, cmd, arg);
  3216. },readFile:function(path, opts) {
  3217. opts = opts || {};
  3218. opts.flags = opts.flags || 'r';
  3219. opts.encoding = opts.encoding || 'binary';
  3220. if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
  3221. throw new Error('Invalid encoding type "' + opts.encoding + '"');
  3222. }
  3223. var ret;
  3224. var stream = FS.open(path, opts.flags);
  3225. var stat = FS.stat(path);
  3226. var length = stat.size;
  3227. var buf = new Uint8Array(length);
  3228. FS.read(stream, buf, 0, length, 0);
  3229. if (opts.encoding === 'utf8') {
  3230. ret = UTF8ArrayToString(buf, 0);
  3231. } else if (opts.encoding === 'binary') {
  3232. ret = buf;
  3233. }
  3234. FS.close(stream);
  3235. return ret;
  3236. },writeFile:function(path, data, opts) {
  3237. opts = opts || {};
  3238. opts.flags = opts.flags || 'w';
  3239. var stream = FS.open(path, opts.flags, opts.mode);
  3240. if (typeof data === 'string') {
  3241. var buf = new Uint8Array(lengthBytesUTF8(data)+1);
  3242. var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
  3243. FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn);
  3244. } else if (ArrayBuffer.isView(data)) {
  3245. FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
  3246. } else {
  3247. throw new Error('Unsupported data type');
  3248. }
  3249. FS.close(stream);
  3250. },cwd:function() {
  3251. return FS.currentPath;
  3252. },chdir:function(path) {
  3253. var lookup = FS.lookupPath(path, { follow: true });
  3254. if (lookup.node === null) {
  3255. throw new FS.ErrnoError(44);
  3256. }
  3257. if (!FS.isDir(lookup.node.mode)) {
  3258. throw new FS.ErrnoError(54);
  3259. }
  3260. var errCode = FS.nodePermissions(lookup.node, 'x');
  3261. if (errCode) {
  3262. throw new FS.ErrnoError(errCode);
  3263. }
  3264. FS.currentPath = lookup.path;
  3265. },createDefaultDirectories:function() {
  3266. FS.mkdir('/tmp');
  3267. FS.mkdir('/home');
  3268. FS.mkdir('/home/web_user');
  3269. },createDefaultDevices:function() {
  3270. // create /dev
  3271. FS.mkdir('/dev');
  3272. // setup /dev/null
  3273. FS.registerDevice(FS.makedev(1, 3), {
  3274. read: function() { return 0; },
  3275. write: function(stream, buffer, offset, length, pos) { return length; }
  3276. });
  3277. FS.mkdev('/dev/null', FS.makedev(1, 3));
  3278. // setup /dev/tty and /dev/tty1
  3279. // stderr needs to print output using Module['printErr']
  3280. // so we register a second tty just for it.
  3281. TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
  3282. TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
  3283. FS.mkdev('/dev/tty', FS.makedev(5, 0));
  3284. FS.mkdev('/dev/tty1', FS.makedev(6, 0));
  3285. // setup /dev/[u]random
  3286. var random_device;
  3287. if (typeof crypto === 'object' && typeof crypto['getRandomValues'] === 'function') {
  3288. // for modern web browsers
  3289. var randomBuffer = new Uint8Array(1);
  3290. random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; };
  3291. } else
  3292. if (ENVIRONMENT_IS_NODE) {
  3293. // for nodejs with or without crypto support included
  3294. try {
  3295. var crypto_module = require('crypto');
  3296. // nodejs has crypto support
  3297. random_device = function() { return crypto_module['randomBytes'](1)[0]; };
  3298. } catch (e) {
  3299. // nodejs doesn't have crypto support
  3300. }
  3301. } else
  3302. {}
  3303. if (!random_device) {
  3304. // we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
  3305. 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 } };"); };
  3306. }
  3307. FS.createDevice('/dev', 'random', random_device);
  3308. FS.createDevice('/dev', 'urandom', random_device);
  3309. // we're not going to emulate the actual shm device,
  3310. // just create the tmp dirs that reside in it commonly
  3311. FS.mkdir('/dev/shm');
  3312. FS.mkdir('/dev/shm/tmp');
  3313. },createSpecialDirectories:function() {
  3314. // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the name of the stream for fd 6 (see test_unistd_ttyname)
  3315. FS.mkdir('/proc');
  3316. FS.mkdir('/proc/self');
  3317. FS.mkdir('/proc/self/fd');
  3318. FS.mount({
  3319. mount: function() {
  3320. var node = FS.createNode('/proc/self', 'fd', 16384 | 511 /* 0777 */, 73);
  3321. node.node_ops = {
  3322. lookup: function(parent, name) {
  3323. var fd = +name;
  3324. var stream = FS.getStream(fd);
  3325. if (!stream) throw new FS.ErrnoError(8);
  3326. var ret = {
  3327. parent: null,
  3328. mount: { mountpoint: 'fake' },
  3329. node_ops: { readlink: function() { return stream.path } }
  3330. };
  3331. ret.parent = ret; // make it look like a simple root node
  3332. return ret;
  3333. }
  3334. };
  3335. return node;
  3336. }
  3337. }, {}, '/proc/self/fd');
  3338. },createStandardStreams:function() {
  3339. // TODO deprecate the old functionality of a single
  3340. // input / output callback and that utilizes FS.createDevice
  3341. // and instead require a unique set of stream ops
  3342. // by default, we symlink the standard streams to the
  3343. // default tty devices. however, if the standard streams
  3344. // have been overwritten we create a unique device for
  3345. // them instead.
  3346. if (Module['stdin']) {
  3347. FS.createDevice('/dev', 'stdin', Module['stdin']);
  3348. } else {
  3349. FS.symlink('/dev/tty', '/dev/stdin');
  3350. }
  3351. if (Module['stdout']) {
  3352. FS.createDevice('/dev', 'stdout', null, Module['stdout']);
  3353. } else {
  3354. FS.symlink('/dev/tty', '/dev/stdout');
  3355. }
  3356. if (Module['stderr']) {
  3357. FS.createDevice('/dev', 'stderr', null, Module['stderr']);
  3358. } else {
  3359. FS.symlink('/dev/tty1', '/dev/stderr');
  3360. }
  3361. // open default streams for the stdin, stdout and stderr devices
  3362. var stdin = FS.open('/dev/stdin', 'r');
  3363. var stdout = FS.open('/dev/stdout', 'w');
  3364. var stderr = FS.open('/dev/stderr', 'w');
  3365. assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
  3366. assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
  3367. assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
  3368. },ensureErrnoError:function() {
  3369. if (FS.ErrnoError) return;
  3370. FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) {
  3371. this.node = node;
  3372. this.setErrno = /** @this{Object} */ function(errno) {
  3373. this.errno = errno;
  3374. for (var key in ERRNO_CODES) {
  3375. if (ERRNO_CODES[key] === errno) {
  3376. this.code = key;
  3377. break;
  3378. }
  3379. }
  3380. };
  3381. this.setErrno(errno);
  3382. this.message = ERRNO_MESSAGES[errno];
  3383. // Try to get a maximally helpful stack trace. On Node.js, getting Error.stack
  3384. // now ensures it shows what we want.
  3385. if (this.stack) {
  3386. // Define the stack property for Node.js 4, which otherwise errors on the next line.
  3387. Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true });
  3388. this.stack = demangleAll(this.stack);
  3389. }
  3390. };
  3391. FS.ErrnoError.prototype = new Error();
  3392. FS.ErrnoError.prototype.constructor = FS.ErrnoError;
  3393. // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
  3394. [44].forEach(function(code) {
  3395. FS.genericErrors[code] = new FS.ErrnoError(code);
  3396. FS.genericErrors[code].stack = '<generic error, no stack>';
  3397. });
  3398. },staticInit:function() {
  3399. FS.ensureErrnoError();
  3400. FS.nameTable = new Array(4096);
  3401. FS.mount(MEMFS, {}, '/');
  3402. FS.createDefaultDirectories();
  3403. FS.createDefaultDevices();
  3404. FS.createSpecialDirectories();
  3405. FS.filesystems = {
  3406. 'MEMFS': MEMFS,
  3407. };
  3408. },init:function(input, output, error) {
  3409. 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)');
  3410. FS.init.initialized = true;
  3411. FS.ensureErrnoError();
  3412. // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
  3413. Module['stdin'] = input || Module['stdin'];
  3414. Module['stdout'] = output || Module['stdout'];
  3415. Module['stderr'] = error || Module['stderr'];
  3416. FS.createStandardStreams();
  3417. },quit:function() {
  3418. FS.init.initialized = false;
  3419. // force-flush all streams, so we get musl std streams printed out
  3420. var fflush = Module['_fflush'];
  3421. if (fflush) fflush(0);
  3422. // close all of our streams
  3423. for (var i = 0; i < FS.streams.length; i++) {
  3424. var stream = FS.streams[i];
  3425. if (!stream) {
  3426. continue;
  3427. }
  3428. FS.close(stream);
  3429. }
  3430. },getMode:function(canRead, canWrite) {
  3431. var mode = 0;
  3432. if (canRead) mode |= 292 | 73;
  3433. if (canWrite) mode |= 146;
  3434. return mode;
  3435. },joinPath:function(parts, forceRelative) {
  3436. var path = PATH.join.apply(null, parts);
  3437. if (forceRelative && path[0] == '/') path = path.substr(1);
  3438. return path;
  3439. },absolutePath:function(relative, base) {
  3440. return PATH_FS.resolve(base, relative);
  3441. },standardizePath:function(path) {
  3442. return PATH.normalize(path);
  3443. },findObject:function(path, dontResolveLastLink) {
  3444. var ret = FS.analyzePath(path, dontResolveLastLink);
  3445. if (ret.exists) {
  3446. return ret.object;
  3447. } else {
  3448. setErrNo(ret.error);
  3449. return null;
  3450. }
  3451. },analyzePath:function(path, dontResolveLastLink) {
  3452. // operate from within the context of the symlink's target
  3453. try {
  3454. var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3455. path = lookup.path;
  3456. } catch (e) {
  3457. }
  3458. var ret = {
  3459. isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
  3460. parentExists: false, parentPath: null, parentObject: null
  3461. };
  3462. try {
  3463. var lookup = FS.lookupPath(path, { parent: true });
  3464. ret.parentExists = true;
  3465. ret.parentPath = lookup.path;
  3466. ret.parentObject = lookup.node;
  3467. ret.name = PATH.basename(path);
  3468. lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3469. ret.exists = true;
  3470. ret.path = lookup.path;
  3471. ret.object = lookup.node;
  3472. ret.name = lookup.node.name;
  3473. ret.isRoot = lookup.path === '/';
  3474. } catch (e) {
  3475. ret.error = e.errno;
  3476. };
  3477. return ret;
  3478. },createFolder:function(parent, name, canRead, canWrite) {
  3479. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3480. var mode = FS.getMode(canRead, canWrite);
  3481. return FS.mkdir(path, mode);
  3482. },createPath:function(parent, path, canRead, canWrite) {
  3483. parent = typeof parent === 'string' ? parent : FS.getPath(parent);
  3484. var parts = path.split('/').reverse();
  3485. while (parts.length) {
  3486. var part = parts.pop();
  3487. if (!part) continue;
  3488. var current = PATH.join2(parent, part);
  3489. try {
  3490. FS.mkdir(current);
  3491. } catch (e) {
  3492. // ignore EEXIST
  3493. }
  3494. parent = current;
  3495. }
  3496. return current;
  3497. },createFile:function(parent, name, properties, canRead, canWrite) {
  3498. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3499. var mode = FS.getMode(canRead, canWrite);
  3500. return FS.create(path, mode);
  3501. },createDataFile:function(parent, name, data, canRead, canWrite, canOwn) {
  3502. var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
  3503. var mode = FS.getMode(canRead, canWrite);
  3504. var node = FS.create(path, mode);
  3505. if (data) {
  3506. if (typeof data === 'string') {
  3507. var arr = new Array(data.length);
  3508. for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
  3509. data = arr;
  3510. }
  3511. // make sure we can write to the file
  3512. FS.chmod(node, mode | 146);
  3513. var stream = FS.open(node, 'w');
  3514. FS.write(stream, data, 0, data.length, 0, canOwn);
  3515. FS.close(stream);
  3516. FS.chmod(node, mode);
  3517. }
  3518. return node;
  3519. },createDevice:function(parent, name, input, output) {
  3520. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3521. var mode = FS.getMode(!!input, !!output);
  3522. if (!FS.createDevice.major) FS.createDevice.major = 64;
  3523. var dev = FS.makedev(FS.createDevice.major++, 0);
  3524. // Create a fake device that a set of stream ops to emulate
  3525. // the old behavior.
  3526. FS.registerDevice(dev, {
  3527. open: function(stream) {
  3528. stream.seekable = false;
  3529. },
  3530. close: function(stream) {
  3531. // flush any pending line data
  3532. if (output && output.buffer && output.buffer.length) {
  3533. output(10);
  3534. }
  3535. },
  3536. read: function(stream, buffer, offset, length, pos /* ignored */) {
  3537. var bytesRead = 0;
  3538. for (var i = 0; i < length; i++) {
  3539. var result;
  3540. try {
  3541. result = input();
  3542. } catch (e) {
  3543. throw new FS.ErrnoError(29);
  3544. }
  3545. if (result === undefined && bytesRead === 0) {
  3546. throw new FS.ErrnoError(6);
  3547. }
  3548. if (result === null || result === undefined) break;
  3549. bytesRead++;
  3550. buffer[offset+i] = result;
  3551. }
  3552. if (bytesRead) {
  3553. stream.node.timestamp = Date.now();
  3554. }
  3555. return bytesRead;
  3556. },
  3557. write: function(stream, buffer, offset, length, pos) {
  3558. for (var i = 0; i < length; i++) {
  3559. try {
  3560. output(buffer[offset+i]);
  3561. } catch (e) {
  3562. throw new FS.ErrnoError(29);
  3563. }
  3564. }
  3565. if (length) {
  3566. stream.node.timestamp = Date.now();
  3567. }
  3568. return i;
  3569. }
  3570. });
  3571. return FS.mkdev(path, mode, dev);
  3572. },createLink:function(parent, name, target, canRead, canWrite) {
  3573. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3574. return FS.symlink(target, path);
  3575. },forceLoadFile:function(obj) {
  3576. if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
  3577. var success = true;
  3578. if (typeof XMLHttpRequest !== 'undefined') {
  3579. 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.");
  3580. } else if (read_) {
  3581. // Command-line.
  3582. try {
  3583. // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
  3584. // read() will try to parse UTF8.
  3585. obj.contents = intArrayFromString(read_(obj.url), true);
  3586. obj.usedBytes = obj.contents.length;
  3587. } catch (e) {
  3588. success = false;
  3589. }
  3590. } else {
  3591. throw new Error('Cannot load without read() or XMLHttpRequest.');
  3592. }
  3593. if (!success) setErrNo(29);
  3594. return success;
  3595. },createLazyFile:function(parent, name, url, canRead, canWrite) {
  3596. // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
  3597. /** @constructor */
  3598. function LazyUint8Array() {
  3599. this.lengthKnown = false;
  3600. this.chunks = []; // Loaded chunks. Index is the chunk number
  3601. }
  3602. LazyUint8Array.prototype.get = /** @this{Object} */ function LazyUint8Array_get(idx) {
  3603. if (idx > this.length-1 || idx < 0) {
  3604. return undefined;
  3605. }
  3606. var chunkOffset = idx % this.chunkSize;
  3607. var chunkNum = (idx / this.chunkSize)|0;
  3608. return this.getter(chunkNum)[chunkOffset];
  3609. };
  3610. LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
  3611. this.getter = getter;
  3612. };
  3613. LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
  3614. // Find length
  3615. var xhr = new XMLHttpRequest();
  3616. xhr.open('HEAD', url, false);
  3617. xhr.send(null);
  3618. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3619. var datalength = Number(xhr.getResponseHeader("Content-length"));
  3620. var header;
  3621. var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
  3622. var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
  3623. var chunkSize = 1024*1024; // Chunk size in bytes
  3624. if (!hasByteServing) chunkSize = datalength;
  3625. // Function to get a range from the remote URL.
  3626. var doXHR = (function(from, to) {
  3627. if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
  3628. if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
  3629. // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
  3630. var xhr = new XMLHttpRequest();
  3631. xhr.open('GET', url, false);
  3632. if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
  3633. // Some hints to the browser that we want binary data.
  3634. if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
  3635. if (xhr.overrideMimeType) {
  3636. xhr.overrideMimeType('text/plain; charset=x-user-defined');
  3637. }
  3638. xhr.send(null);
  3639. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3640. if (xhr.response !== undefined) {
  3641. return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
  3642. } else {
  3643. return intArrayFromString(xhr.responseText || '', true);
  3644. }
  3645. });
  3646. var lazyArray = this;
  3647. lazyArray.setDataGetter(function(chunkNum) {
  3648. var start = chunkNum * chunkSize;
  3649. var end = (chunkNum+1) * chunkSize - 1; // including this byte
  3650. end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
  3651. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
  3652. lazyArray.chunks[chunkNum] = doXHR(start, end);
  3653. }
  3654. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
  3655. return lazyArray.chunks[chunkNum];
  3656. });
  3657. if (usesGzip || !datalength) {
  3658. // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
  3659. chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
  3660. datalength = this.getter(0).length;
  3661. chunkSize = datalength;
  3662. out("LazyFiles on gzip forces download of the whole file when length is accessed");
  3663. }
  3664. this._length = datalength;
  3665. this._chunkSize = chunkSize;
  3666. this.lengthKnown = true;
  3667. };
  3668. if (typeof XMLHttpRequest !== 'undefined') {
  3669. if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
  3670. var lazyArray = new LazyUint8Array();
  3671. Object.defineProperties(lazyArray, {
  3672. length: {
  3673. get: /** @this{Object} */ function() {
  3674. if(!this.lengthKnown) {
  3675. this.cacheLength();
  3676. }
  3677. return this._length;
  3678. }
  3679. },
  3680. chunkSize: {
  3681. get: /** @this{Object} */ function() {
  3682. if(!this.lengthKnown) {
  3683. this.cacheLength();
  3684. }
  3685. return this._chunkSize;
  3686. }
  3687. }
  3688. });
  3689. var properties = { isDevice: false, contents: lazyArray };
  3690. } else {
  3691. var properties = { isDevice: false, url: url };
  3692. }
  3693. var node = FS.createFile(parent, name, properties, canRead, canWrite);
  3694. // This is a total hack, but I want to get this lazy file code out of the
  3695. // core of MEMFS. If we want to keep this lazy file concept I feel it should
  3696. // be its own thin LAZYFS proxying calls to MEMFS.
  3697. if (properties.contents) {
  3698. node.contents = properties.contents;
  3699. } else if (properties.url) {
  3700. node.contents = null;
  3701. node.url = properties.url;
  3702. }
  3703. // Add a function that defers querying the file size until it is asked the first time.
  3704. Object.defineProperties(node, {
  3705. usedBytes: {
  3706. get: /** @this {FSNode} */ function() { return this.contents.length; }
  3707. }
  3708. });
  3709. // override each stream op with one that tries to force load the lazy file first
  3710. var stream_ops = {};
  3711. var keys = Object.keys(node.stream_ops);
  3712. keys.forEach(function(key) {
  3713. var fn = node.stream_ops[key];
  3714. stream_ops[key] = function forceLoadLazyFile() {
  3715. if (!FS.forceLoadFile(node)) {
  3716. throw new FS.ErrnoError(29);
  3717. }
  3718. return fn.apply(null, arguments);
  3719. };
  3720. });
  3721. // use a custom read function
  3722. stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
  3723. if (!FS.forceLoadFile(node)) {
  3724. throw new FS.ErrnoError(29);
  3725. }
  3726. var contents = stream.node.contents;
  3727. if (position >= contents.length)
  3728. return 0;
  3729. var size = Math.min(contents.length - position, length);
  3730. assert(size >= 0);
  3731. if (contents.slice) { // normal array
  3732. for (var i = 0; i < size; i++) {
  3733. buffer[offset + i] = contents[position + i];
  3734. }
  3735. } else {
  3736. for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
  3737. buffer[offset + i] = contents.get(position + i);
  3738. }
  3739. }
  3740. return size;
  3741. };
  3742. node.stream_ops = stream_ops;
  3743. return node;
  3744. },createPreloadedFile:function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
  3745. Browser.init(); // XXX perhaps this method should move onto Browser?
  3746. // TODO we should allow people to just pass in a complete filename instead
  3747. // of parent and name being that we just join them anyways
  3748. var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
  3749. var dep = getUniqueRunDependency('cp ' + fullname); // might have several active requests for the same fullname
  3750. function processData(byteArray) {
  3751. function finish(byteArray) {
  3752. if (preFinish) preFinish();
  3753. if (!dontCreateFile) {
  3754. FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
  3755. }
  3756. if (onload) onload();
  3757. removeRunDependency(dep);
  3758. }
  3759. var handled = false;
  3760. Module['preloadPlugins'].forEach(function(plugin) {
  3761. if (handled) return;
  3762. if (plugin['canHandle'](fullname)) {
  3763. plugin['handle'](byteArray, fullname, finish, function() {
  3764. if (onerror) onerror();
  3765. removeRunDependency(dep);
  3766. });
  3767. handled = true;
  3768. }
  3769. });
  3770. if (!handled) finish(byteArray);
  3771. }
  3772. addRunDependency(dep);
  3773. if (typeof url == 'string') {
  3774. Browser.asyncLoad(url, function(byteArray) {
  3775. processData(byteArray);
  3776. }, onerror);
  3777. } else {
  3778. processData(url);
  3779. }
  3780. },indexedDB:function() {
  3781. return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
  3782. },DB_NAME:function() {
  3783. return 'EM_FS_' + window.location.pathname;
  3784. },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(paths, onload, onerror) {
  3785. onload = onload || function(){};
  3786. onerror = onerror || function(){};
  3787. var indexedDB = FS.indexedDB();
  3788. try {
  3789. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3790. } catch (e) {
  3791. return onerror(e);
  3792. }
  3793. openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
  3794. out('creating db');
  3795. var db = openRequest.result;
  3796. db.createObjectStore(FS.DB_STORE_NAME);
  3797. };
  3798. openRequest.onsuccess = function openRequest_onsuccess() {
  3799. var db = openRequest.result;
  3800. var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
  3801. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3802. var ok = 0, fail = 0, total = paths.length;
  3803. function finish() {
  3804. if (fail == 0) onload(); else onerror();
  3805. }
  3806. paths.forEach(function(path) {
  3807. var putRequest = files.put(FS.analyzePath(path).object.contents, path);
  3808. putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
  3809. putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3810. });
  3811. transaction.onerror = onerror;
  3812. };
  3813. openRequest.onerror = onerror;
  3814. },loadFilesFromDB:function(paths, onload, onerror) {
  3815. onload = onload || function(){};
  3816. onerror = onerror || function(){};
  3817. var indexedDB = FS.indexedDB();
  3818. try {
  3819. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3820. } catch (e) {
  3821. return onerror(e);
  3822. }
  3823. openRequest.onupgradeneeded = onerror; // no database to load from
  3824. openRequest.onsuccess = function openRequest_onsuccess() {
  3825. var db = openRequest.result;
  3826. try {
  3827. var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
  3828. } catch(e) {
  3829. onerror(e);
  3830. return;
  3831. }
  3832. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3833. var ok = 0, fail = 0, total = paths.length;
  3834. function finish() {
  3835. if (fail == 0) onload(); else onerror();
  3836. }
  3837. paths.forEach(function(path) {
  3838. var getRequest = files.get(path);
  3839. getRequest.onsuccess = function getRequest_onsuccess() {
  3840. if (FS.analyzePath(path).exists) {
  3841. FS.unlink(path);
  3842. }
  3843. FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
  3844. ok++;
  3845. if (ok + fail == total) finish();
  3846. };
  3847. getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3848. });
  3849. transaction.onerror = onerror;
  3850. };
  3851. openRequest.onerror = onerror;
  3852. }};var SYSCALLS={mappings:{},DEFAULT_POLLMASK:5,umask:511,calculateAt:function(dirfd, path) {
  3853. if (path[0] !== '/') {
  3854. // relative path
  3855. var dir;
  3856. if (dirfd === -100) {
  3857. dir = FS.cwd();
  3858. } else {
  3859. var dirstream = FS.getStream(dirfd);
  3860. if (!dirstream) throw new FS.ErrnoError(8);
  3861. dir = dirstream.path;
  3862. }
  3863. path = PATH.join2(dir, path);
  3864. }
  3865. return path;
  3866. },doStat:function(func, path, buf) {
  3867. try {
  3868. var stat = func(path);
  3869. } catch (e) {
  3870. if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
  3871. // an error occurred while trying to look up the path; we should just report ENOTDIR
  3872. return -54;
  3873. }
  3874. throw e;
  3875. }
  3876. HEAP32[((buf)>>2)]=stat.dev;
  3877. HEAP32[(((buf)+(4))>>2)]=0;
  3878. HEAP32[(((buf)+(8))>>2)]=stat.ino;
  3879. HEAP32[(((buf)+(12))>>2)]=stat.mode;
  3880. HEAP32[(((buf)+(16))>>2)]=stat.nlink;
  3881. HEAP32[(((buf)+(20))>>2)]=stat.uid;
  3882. HEAP32[(((buf)+(24))>>2)]=stat.gid;
  3883. HEAP32[(((buf)+(28))>>2)]=stat.rdev;
  3884. HEAP32[(((buf)+(32))>>2)]=0;
  3885. (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]);
  3886. HEAP32[(((buf)+(48))>>2)]=4096;
  3887. HEAP32[(((buf)+(52))>>2)]=stat.blocks;
  3888. HEAP32[(((buf)+(56))>>2)]=(stat.atime.getTime() / 1000)|0;
  3889. HEAP32[(((buf)+(60))>>2)]=0;
  3890. HEAP32[(((buf)+(64))>>2)]=(stat.mtime.getTime() / 1000)|0;
  3891. HEAP32[(((buf)+(68))>>2)]=0;
  3892. HEAP32[(((buf)+(72))>>2)]=(stat.ctime.getTime() / 1000)|0;
  3893. HEAP32[(((buf)+(76))>>2)]=0;
  3894. (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]);
  3895. return 0;
  3896. },doMsync:function(addr, stream, len, flags, offset) {
  3897. var buffer = HEAPU8.slice(addr, addr + len);
  3898. FS.msync(stream, buffer, offset, len, flags);
  3899. },doMkdir:function(path, mode) {
  3900. // remove a trailing slash, if one - /a/b/ has basename of '', but
  3901. // we want to create b in the context of this function
  3902. path = PATH.normalize(path);
  3903. if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
  3904. FS.mkdir(path, mode, 0);
  3905. return 0;
  3906. },doMknod:function(path, mode, dev) {
  3907. // we don't want this in the JS API as it uses mknod to create all nodes.
  3908. switch (mode & 61440) {
  3909. case 32768:
  3910. case 8192:
  3911. case 24576:
  3912. case 4096:
  3913. case 49152:
  3914. break;
  3915. default: return -28;
  3916. }
  3917. FS.mknod(path, mode, dev);
  3918. return 0;
  3919. },doReadlink:function(path, buf, bufsize) {
  3920. if (bufsize <= 0) return -28;
  3921. var ret = FS.readlink(path);
  3922. var len = Math.min(bufsize, lengthBytesUTF8(ret));
  3923. var endChar = HEAP8[buf+len];
  3924. stringToUTF8(ret, buf, bufsize+1);
  3925. // readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!)
  3926. // stringToUTF8() always appends a null byte, so restore the character under the null byte after the write.
  3927. HEAP8[buf+len] = endChar;
  3928. return len;
  3929. },doAccess:function(path, amode) {
  3930. if (amode & ~7) {
  3931. // need a valid mode
  3932. return -28;
  3933. }
  3934. var node;
  3935. var lookup = FS.lookupPath(path, { follow: true });
  3936. node = lookup.node;
  3937. if (!node) {
  3938. return -44;
  3939. }
  3940. var perms = '';
  3941. if (amode & 4) perms += 'r';
  3942. if (amode & 2) perms += 'w';
  3943. if (amode & 1) perms += 'x';
  3944. if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) {
  3945. return -2;
  3946. }
  3947. return 0;
  3948. },doDup:function(path, flags, suggestFD) {
  3949. var suggest = FS.getStream(suggestFD);
  3950. if (suggest) FS.close(suggest);
  3951. return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
  3952. },doReadv:function(stream, iov, iovcnt, offset) {
  3953. var ret = 0;
  3954. for (var i = 0; i < iovcnt; i++) {
  3955. var ptr = HEAP32[(((iov)+(i*8))>>2)];
  3956. var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
  3957. var curr = FS.read(stream, HEAP8,ptr, len, offset);
  3958. if (curr < 0) return -1;
  3959. ret += curr;
  3960. if (curr < len) break; // nothing more to read
  3961. }
  3962. return ret;
  3963. },doWritev:function(stream, iov, iovcnt, offset) {
  3964. var ret = 0;
  3965. for (var i = 0; i < iovcnt; i++) {
  3966. var ptr = HEAP32[(((iov)+(i*8))>>2)];
  3967. var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
  3968. var curr = FS.write(stream, HEAP8,ptr, len, offset);
  3969. if (curr < 0) return -1;
  3970. ret += curr;
  3971. }
  3972. return ret;
  3973. },varargs:undefined,get:function() {
  3974. assert(SYSCALLS.varargs != undefined);
  3975. SYSCALLS.varargs += 4;
  3976. var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
  3977. return ret;
  3978. },getStr:function(ptr) {
  3979. var ret = UTF8ToString(ptr);
  3980. return ret;
  3981. },getStreamFromFD:function(fd) {
  3982. var stream = FS.getStream(fd);
  3983. if (!stream) throw new FS.ErrnoError(8);
  3984. return stream;
  3985. },get64:function(low, high) {
  3986. if (low >= 0) assert(high === 0);
  3987. else assert(high === -1);
  3988. return low;
  3989. }};function ___sys_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs;
  3990. try {
  3991. var stream = SYSCALLS.getStreamFromFD(fd);
  3992. switch (cmd) {
  3993. case 0: {
  3994. var arg = SYSCALLS.get();
  3995. if (arg < 0) {
  3996. return -28;
  3997. }
  3998. var newStream;
  3999. newStream = FS.open(stream.path, stream.flags, 0, arg);
  4000. return newStream.fd;
  4001. }
  4002. case 1:
  4003. case 2:
  4004. return 0; // FD_CLOEXEC makes no sense for a single process.
  4005. case 3:
  4006. return stream.flags;
  4007. case 4: {
  4008. var arg = SYSCALLS.get();
  4009. stream.flags |= arg;
  4010. return 0;
  4011. }
  4012. case 12:
  4013. /* 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 */ {
  4014. var arg = SYSCALLS.get();
  4015. var offset = 0;
  4016. // We're always unlocked.
  4017. HEAP16[(((arg)+(offset))>>1)]=2;
  4018. return 0;
  4019. }
  4020. case 13:
  4021. case 14:
  4022. /* 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 */
  4023. /* 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 */
  4024. return 0; // Pretend that the locking is successful.
  4025. case 16:
  4026. case 8:
  4027. return -28; // These are for sockets. We don't have them fully implemented yet.
  4028. case 9:
  4029. // 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.
  4030. setErrNo(28);
  4031. return -1;
  4032. default: {
  4033. return -28;
  4034. }
  4035. }
  4036. } catch (e) {
  4037. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4038. return -e.errno;
  4039. }
  4040. }
  4041. function ___sys_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs;
  4042. try {
  4043. var stream = SYSCALLS.getStreamFromFD(fd);
  4044. switch (op) {
  4045. case 21509:
  4046. case 21505: {
  4047. if (!stream.tty) return -59;
  4048. return 0;
  4049. }
  4050. case 21510:
  4051. case 21511:
  4052. case 21512:
  4053. case 21506:
  4054. case 21507:
  4055. case 21508: {
  4056. if (!stream.tty) return -59;
  4057. return 0; // no-op, not actually adjusting terminal settings
  4058. }
  4059. case 21519: {
  4060. if (!stream.tty) return -59;
  4061. var argp = SYSCALLS.get();
  4062. HEAP32[((argp)>>2)]=0;
  4063. return 0;
  4064. }
  4065. case 21520: {
  4066. if (!stream.tty) return -59;
  4067. return -28; // not supported
  4068. }
  4069. case 21531: {
  4070. var argp = SYSCALLS.get();
  4071. return FS.ioctl(stream, op, argp);
  4072. }
  4073. case 21523: {
  4074. // TODO: in theory we should write to the winsize struct that gets
  4075. // passed in, but for now musl doesn't read anything on it
  4076. if (!stream.tty) return -59;
  4077. return 0;
  4078. }
  4079. case 21524: {
  4080. // TODO: technically, this ioctl call should change the window size.
  4081. // but, since emscripten doesn't have any concept of a terminal window
  4082. // yet, we'll just silently throw it away as we do TIOCGWINSZ
  4083. if (!stream.tty) return -59;
  4084. return 0;
  4085. }
  4086. default: abort('bad ioctl syscall ' + op);
  4087. }
  4088. } catch (e) {
  4089. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4090. return -e.errno;
  4091. }
  4092. }
  4093. function ___sys_open(path, flags, varargs) {SYSCALLS.varargs = varargs;
  4094. try {
  4095. var pathname = SYSCALLS.getStr(path);
  4096. var mode = SYSCALLS.get();
  4097. var stream = FS.open(pathname, flags, mode);
  4098. return stream.fd;
  4099. } catch (e) {
  4100. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4101. return -e.errno;
  4102. }
  4103. }
  4104. var structRegistrations={};
  4105. function runDestructors(destructors) {
  4106. while (destructors.length) {
  4107. var ptr = destructors.pop();
  4108. var del = destructors.pop();
  4109. del(ptr);
  4110. }
  4111. }
  4112. function simpleReadValueFromPointer(pointer) {
  4113. return this['fromWireType'](HEAPU32[pointer >> 2]);
  4114. }
  4115. var awaitingDependencies={};
  4116. var registeredTypes={};
  4117. var typeDependencies={};
  4118. var char_0=48;
  4119. var char_9=57;function makeLegalFunctionName(name) {
  4120. if (undefined === name) {
  4121. return '_unknown';
  4122. }
  4123. name = name.replace(/[^a-zA-Z0-9_]/g, '$');
  4124. var f = name.charCodeAt(0);
  4125. if (f >= char_0 && f <= char_9) {
  4126. return '_' + name;
  4127. } else {
  4128. return name;
  4129. }
  4130. }function createNamedFunction(name, body) {
  4131. name = makeLegalFunctionName(name);
  4132. /*jshint evil:true*/
  4133. return new Function(
  4134. "body",
  4135. "return function " + name + "() {\n" +
  4136. " \"use strict\";" +
  4137. " return body.apply(this, arguments);\n" +
  4138. "};\n"
  4139. )(body);
  4140. }function extendError(baseErrorType, errorName) {
  4141. var errorClass = createNamedFunction(errorName, function(message) {
  4142. this.name = errorName;
  4143. this.message = message;
  4144. var stack = (new Error(message)).stack;
  4145. if (stack !== undefined) {
  4146. this.stack = this.toString() + '\n' +
  4147. stack.replace(/^Error(:[^\n]*)?\n/, '');
  4148. }
  4149. });
  4150. errorClass.prototype = Object.create(baseErrorType.prototype);
  4151. errorClass.prototype.constructor = errorClass;
  4152. errorClass.prototype.toString = function() {
  4153. if (this.message === undefined) {
  4154. return this.name;
  4155. } else {
  4156. return this.name + ': ' + this.message;
  4157. }
  4158. };
  4159. return errorClass;
  4160. }var InternalError=undefined;function throwInternalError(message) {
  4161. throw new InternalError(message);
  4162. }function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
  4163. myTypes.forEach(function(type) {
  4164. typeDependencies[type] = dependentTypes;
  4165. });
  4166. function onComplete(typeConverters) {
  4167. var myTypeConverters = getTypeConverters(typeConverters);
  4168. if (myTypeConverters.length !== myTypes.length) {
  4169. throwInternalError('Mismatched type converter count');
  4170. }
  4171. for (var i = 0; i < myTypes.length; ++i) {
  4172. registerType(myTypes[i], myTypeConverters[i]);
  4173. }
  4174. }
  4175. var typeConverters = new Array(dependentTypes.length);
  4176. var unregisteredTypes = [];
  4177. var registered = 0;
  4178. dependentTypes.forEach(function(dt, i) {
  4179. if (registeredTypes.hasOwnProperty(dt)) {
  4180. typeConverters[i] = registeredTypes[dt];
  4181. } else {
  4182. unregisteredTypes.push(dt);
  4183. if (!awaitingDependencies.hasOwnProperty(dt)) {
  4184. awaitingDependencies[dt] = [];
  4185. }
  4186. awaitingDependencies[dt].push(function() {
  4187. typeConverters[i] = registeredTypes[dt];
  4188. ++registered;
  4189. if (registered === unregisteredTypes.length) {
  4190. onComplete(typeConverters);
  4191. }
  4192. });
  4193. }
  4194. });
  4195. if (0 === unregisteredTypes.length) {
  4196. onComplete(typeConverters);
  4197. }
  4198. }function __embind_finalize_value_object(structType) {
  4199. var reg = structRegistrations[structType];
  4200. delete structRegistrations[structType];
  4201. var rawConstructor = reg.rawConstructor;
  4202. var rawDestructor = reg.rawDestructor;
  4203. var fieldRecords = reg.fields;
  4204. var fieldTypes = fieldRecords.map(function(field) { return field.getterReturnType; }).
  4205. concat(fieldRecords.map(function(field) { return field.setterArgumentType; }));
  4206. whenDependentTypesAreResolved([structType], fieldTypes, function(fieldTypes) {
  4207. var fields = {};
  4208. fieldRecords.forEach(function(field, i) {
  4209. var fieldName = field.fieldName;
  4210. var getterReturnType = fieldTypes[i];
  4211. var getter = field.getter;
  4212. var getterContext = field.getterContext;
  4213. var setterArgumentType = fieldTypes[i + fieldRecords.length];
  4214. var setter = field.setter;
  4215. var setterContext = field.setterContext;
  4216. fields[fieldName] = {
  4217. read: function(ptr) {
  4218. return getterReturnType['fromWireType'](
  4219. getter(getterContext, ptr));
  4220. },
  4221. write: function(ptr, o) {
  4222. var destructors = [];
  4223. setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
  4224. runDestructors(destructors);
  4225. }
  4226. };
  4227. });
  4228. return [{
  4229. name: reg.name,
  4230. 'fromWireType': function(ptr) {
  4231. var rv = {};
  4232. for (var i in fields) {
  4233. rv[i] = fields[i].read(ptr);
  4234. }
  4235. rawDestructor(ptr);
  4236. return rv;
  4237. },
  4238. 'toWireType': function(destructors, o) {
  4239. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
  4240. // assume all fields are present without checking.
  4241. for (var fieldName in fields) {
  4242. if (!(fieldName in o)) {
  4243. throw new TypeError('Missing field');
  4244. }
  4245. }
  4246. var ptr = rawConstructor();
  4247. for (fieldName in fields) {
  4248. fields[fieldName].write(ptr, o[fieldName]);
  4249. }
  4250. if (destructors !== null) {
  4251. destructors.push(rawDestructor, ptr);
  4252. }
  4253. return ptr;
  4254. },
  4255. 'argPackAdvance': 8,
  4256. 'readValueFromPointer': simpleReadValueFromPointer,
  4257. destructorFunction: rawDestructor,
  4258. }];
  4259. });
  4260. }
  4261. function getShiftFromSize(size) {
  4262. switch (size) {
  4263. case 1: return 0;
  4264. case 2: return 1;
  4265. case 4: return 2;
  4266. case 8: return 3;
  4267. default:
  4268. throw new TypeError('Unknown type size: ' + size);
  4269. }
  4270. }
  4271. function embind_init_charCodes() {
  4272. var codes = new Array(256);
  4273. for (var i = 0; i < 256; ++i) {
  4274. codes[i] = String.fromCharCode(i);
  4275. }
  4276. embind_charCodes = codes;
  4277. }var embind_charCodes=undefined;function readLatin1String(ptr) {
  4278. var ret = "";
  4279. var c = ptr;
  4280. while (HEAPU8[c]) {
  4281. ret += embind_charCodes[HEAPU8[c++]];
  4282. }
  4283. return ret;
  4284. }
  4285. var BindingError=undefined;function throwBindingError(message) {
  4286. throw new BindingError(message);
  4287. }/** @param {Object=} options */
  4288. function registerType(rawType, registeredInstance, options) {
  4289. options = options || {};
  4290. if (!('argPackAdvance' in registeredInstance)) {
  4291. throw new TypeError('registerType registeredInstance requires argPackAdvance');
  4292. }
  4293. var name = registeredInstance.name;
  4294. if (!rawType) {
  4295. throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
  4296. }
  4297. if (registeredTypes.hasOwnProperty(rawType)) {
  4298. if (options.ignoreDuplicateRegistrations) {
  4299. return;
  4300. } else {
  4301. throwBindingError("Cannot register type '" + name + "' twice");
  4302. }
  4303. }
  4304. registeredTypes[rawType] = registeredInstance;
  4305. delete typeDependencies[rawType];
  4306. if (awaitingDependencies.hasOwnProperty(rawType)) {
  4307. var callbacks = awaitingDependencies[rawType];
  4308. delete awaitingDependencies[rawType];
  4309. callbacks.forEach(function(cb) {
  4310. cb();
  4311. });
  4312. }
  4313. }function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
  4314. var shift = getShiftFromSize(size);
  4315. name = readLatin1String(name);
  4316. registerType(rawType, {
  4317. name: name,
  4318. 'fromWireType': function(wt) {
  4319. // ambiguous emscripten ABI: sometimes return values are
  4320. // true or false, and sometimes integers (0 or 1)
  4321. return !!wt;
  4322. },
  4323. 'toWireType': function(destructors, o) {
  4324. return o ? trueValue : falseValue;
  4325. },
  4326. 'argPackAdvance': 8,
  4327. 'readValueFromPointer': function(pointer) {
  4328. // TODO: if heap is fixed (like in asm.js) this could be executed outside
  4329. var heap;
  4330. if (size === 1) {
  4331. heap = HEAP8;
  4332. } else if (size === 2) {
  4333. heap = HEAP16;
  4334. } else if (size === 4) {
  4335. heap = HEAP32;
  4336. } else {
  4337. throw new TypeError("Unknown boolean type size: " + name);
  4338. }
  4339. return this['fromWireType'](heap[pointer >> shift]);
  4340. },
  4341. destructorFunction: null, // This type does not need a destructor
  4342. });
  4343. }
  4344. var emval_free_list=[];
  4345. var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle) {
  4346. if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
  4347. emval_handle_array[handle] = undefined;
  4348. emval_free_list.push(handle);
  4349. }
  4350. }
  4351. function count_emval_handles() {
  4352. var count = 0;
  4353. for (var i = 5; i < emval_handle_array.length; ++i) {
  4354. if (emval_handle_array[i] !== undefined) {
  4355. ++count;
  4356. }
  4357. }
  4358. return count;
  4359. }
  4360. function get_first_emval() {
  4361. for (var i = 5; i < emval_handle_array.length; ++i) {
  4362. if (emval_handle_array[i] !== undefined) {
  4363. return emval_handle_array[i];
  4364. }
  4365. }
  4366. return null;
  4367. }function init_emval() {
  4368. Module['count_emval_handles'] = count_emval_handles;
  4369. Module['get_first_emval'] = get_first_emval;
  4370. }function __emval_register(value) {
  4371. switch(value){
  4372. case undefined :{ return 1; }
  4373. case null :{ return 2; }
  4374. case true :{ return 3; }
  4375. case false :{ return 4; }
  4376. default:{
  4377. var handle = emval_free_list.length ?
  4378. emval_free_list.pop() :
  4379. emval_handle_array.length;
  4380. emval_handle_array[handle] = {refcount: 1, value: value};
  4381. return handle;
  4382. }
  4383. }
  4384. }function __embind_register_emval(rawType, name) {
  4385. name = readLatin1String(name);
  4386. registerType(rawType, {
  4387. name: name,
  4388. 'fromWireType': function(handle) {
  4389. var rv = emval_handle_array[handle].value;
  4390. __emval_decref(handle);
  4391. return rv;
  4392. },
  4393. 'toWireType': function(destructors, value) {
  4394. return __emval_register(value);
  4395. },
  4396. 'argPackAdvance': 8,
  4397. 'readValueFromPointer': simpleReadValueFromPointer,
  4398. destructorFunction: null, // This type does not need a destructor
  4399. // TODO: do we need a deleteObject here? write a test where
  4400. // emval is passed into JS via an interface
  4401. });
  4402. }
  4403. function _embind_repr(v) {
  4404. if (v === null) {
  4405. return 'null';
  4406. }
  4407. var t = typeof v;
  4408. if (t === 'object' || t === 'array' || t === 'function') {
  4409. return v.toString();
  4410. } else {
  4411. return '' + v;
  4412. }
  4413. }
  4414. function floatReadValueFromPointer(name, shift) {
  4415. switch (shift) {
  4416. case 2: return function(pointer) {
  4417. return this['fromWireType'](HEAPF32[pointer >> 2]);
  4418. };
  4419. case 3: return function(pointer) {
  4420. return this['fromWireType'](HEAPF64[pointer >> 3]);
  4421. };
  4422. default:
  4423. throw new TypeError("Unknown float type: " + name);
  4424. }
  4425. }function __embind_register_float(rawType, name, size) {
  4426. var shift = getShiftFromSize(size);
  4427. name = readLatin1String(name);
  4428. registerType(rawType, {
  4429. name: name,
  4430. 'fromWireType': function(value) {
  4431. return value;
  4432. },
  4433. 'toWireType': function(destructors, value) {
  4434. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
  4435. // avoid the following if() and assume value is of proper type.
  4436. if (typeof value !== "number" && typeof value !== "boolean") {
  4437. throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
  4438. }
  4439. return value;
  4440. },
  4441. 'argPackAdvance': 8,
  4442. 'readValueFromPointer': floatReadValueFromPointer(name, shift),
  4443. destructorFunction: null, // This type does not need a destructor
  4444. });
  4445. }
  4446. function new_(constructor, argumentList) {
  4447. if (!(constructor instanceof Function)) {
  4448. throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
  4449. }
  4450. /*
  4451. * Previously, the following line was just:
  4452. function dummy() {};
  4453. * Unfortunately, Chrome was preserving 'dummy' as the object's name, even though at creation, the 'dummy' has the
  4454. * correct constructor name. Thus, objects created with IMVU.new would show up in the debugger as 'dummy', which
  4455. * isn't very helpful. Using IMVU.createNamedFunction addresses the issue. Doublely-unfortunately, there's no way
  4456. * to write a test for this behavior. -NRD 2013.02.22
  4457. */
  4458. var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
  4459. dummy.prototype = constructor.prototype;
  4460. var obj = new dummy;
  4461. var r = constructor.apply(obj, argumentList);
  4462. return (r instanceof Object) ? r : obj;
  4463. }function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {
  4464. // humanName: a human-readable string name for the function to be generated.
  4465. // argTypes: An array that contains the embind type objects for all types in the function signature.
  4466. // argTypes[0] is the type object for the function return value.
  4467. // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
  4468. // argTypes[2...] are the actual function parameters.
  4469. // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
  4470. // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
  4471. // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
  4472. var argCount = argTypes.length;
  4473. if (argCount < 2) {
  4474. throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
  4475. }
  4476. var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
  4477. // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
  4478. // TODO: This omits argument count check - enable only at -O3 or similar.
  4479. // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
  4480. // return FUNCTION_TABLE[fn];
  4481. // }
  4482. // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
  4483. // TODO: Remove this completely once all function invokers are being dynamically generated.
  4484. var needsDestructorStack = false;
  4485. for(var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
  4486. if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
  4487. needsDestructorStack = true;
  4488. break;
  4489. }
  4490. }
  4491. var returns = (argTypes[0].name !== "void");
  4492. var argsList = "";
  4493. var argsListWired = "";
  4494. for(var i = 0; i < argCount - 2; ++i) {
  4495. argsList += (i!==0?", ":"")+"arg"+i;
  4496. argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
  4497. }
  4498. var invokerFnBody =
  4499. "return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" +
  4500. "if (arguments.length !== "+(argCount - 2)+") {\n" +
  4501. "throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" +
  4502. "}\n";
  4503. if (needsDestructorStack) {
  4504. invokerFnBody +=
  4505. "var destructors = [];\n";
  4506. }
  4507. var dtorStack = needsDestructorStack ? "destructors" : "null";
  4508. var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
  4509. var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
  4510. if (isClassMethodFunc) {
  4511. invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
  4512. }
  4513. for(var i = 0; i < argCount - 2; ++i) {
  4514. invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
  4515. args1.push("argType"+i);
  4516. args2.push(argTypes[i+2]);
  4517. }
  4518. if (isClassMethodFunc) {
  4519. argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
  4520. }
  4521. invokerFnBody +=
  4522. (returns?"var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
  4523. if (needsDestructorStack) {
  4524. invokerFnBody += "runDestructors(destructors);\n";
  4525. } else {
  4526. 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.
  4527. var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
  4528. if (argTypes[i].destructorFunction !== null) {
  4529. invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
  4530. args1.push(paramName+"_dtor");
  4531. args2.push(argTypes[i].destructorFunction);
  4532. }
  4533. }
  4534. }
  4535. if (returns) {
  4536. invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
  4537. "return ret;\n";
  4538. } else {
  4539. }
  4540. invokerFnBody += "}\n";
  4541. args1.push(invokerFnBody);
  4542. var invokerFunction = new_(Function, args1).apply(null, args2);
  4543. return invokerFunction;
  4544. }
  4545. function ensureOverloadTable(proto, methodName, humanName) {
  4546. if (undefined === proto[methodName].overloadTable) {
  4547. var prevFunc = proto[methodName];
  4548. // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
  4549. proto[methodName] = function() {
  4550. // TODO This check can be removed in -O3 level "unsafe" optimizations.
  4551. if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
  4552. throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
  4553. }
  4554. return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
  4555. };
  4556. // Move the previous function into the overload table.
  4557. proto[methodName].overloadTable = [];
  4558. proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
  4559. }
  4560. }/** @param {number=} numArguments */
  4561. function exposePublicSymbol(name, value, numArguments) {
  4562. if (Module.hasOwnProperty(name)) {
  4563. if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
  4564. throwBindingError("Cannot register public name '" + name + "' twice");
  4565. }
  4566. // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
  4567. // that routes between the two.
  4568. ensureOverloadTable(Module, name, name);
  4569. if (Module.hasOwnProperty(numArguments)) {
  4570. throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
  4571. }
  4572. // Add the new function into the overload table.
  4573. Module[name].overloadTable[numArguments] = value;
  4574. }
  4575. else {
  4576. Module[name] = value;
  4577. if (undefined !== numArguments) {
  4578. Module[name].numArguments = numArguments;
  4579. }
  4580. }
  4581. }
  4582. function heap32VectorToArray(count, firstElement) {
  4583. var array = [];
  4584. for (var i = 0; i < count; i++) {
  4585. array.push(HEAP32[(firstElement >> 2) + i]);
  4586. }
  4587. return array;
  4588. }
  4589. /** @param {number=} numArguments */
  4590. function replacePublicSymbol(name, value, numArguments) {
  4591. if (!Module.hasOwnProperty(name)) {
  4592. throwInternalError('Replacing nonexistant public symbol');
  4593. }
  4594. // If there's an overload table for this symbol, replace the symbol in the overload table instead.
  4595. if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
  4596. Module[name].overloadTable[numArguments] = value;
  4597. }
  4598. else {
  4599. Module[name] = value;
  4600. Module[name].argCount = numArguments;
  4601. }
  4602. }
  4603. function embind__requireFunction(signature, rawFunction) {
  4604. signature = readLatin1String(signature);
  4605. function makeDynCaller(dynCall) {
  4606. var args = [];
  4607. for (var i = 1; i < signature.length; ++i) {
  4608. args.push('a' + i);
  4609. }
  4610. var name = 'dynCall_' + signature + '_' + rawFunction;
  4611. var body = 'return function ' + name + '(' + args.join(', ') + ') {\n';
  4612. body += ' return dynCall(rawFunction' + (args.length ? ', ' : '') + args.join(', ') + ');\n';
  4613. body += '};\n';
  4614. return (new Function('dynCall', 'rawFunction', body))(dynCall, rawFunction);
  4615. }
  4616. var dc = Module['dynCall_' + signature];
  4617. var fp = makeDynCaller(dc);
  4618. if (typeof fp !== "function") {
  4619. throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
  4620. }
  4621. return fp;
  4622. }
  4623. var UnboundTypeError=undefined;
  4624. function getTypeName(type) {
  4625. var ptr = ___getTypeName(type);
  4626. var rv = readLatin1String(ptr);
  4627. _free(ptr);
  4628. return rv;
  4629. }function throwUnboundTypeError(message, types) {
  4630. var unboundTypes = [];
  4631. var seen = {};
  4632. function visit(type) {
  4633. if (seen[type]) {
  4634. return;
  4635. }
  4636. if (registeredTypes[type]) {
  4637. return;
  4638. }
  4639. if (typeDependencies[type]) {
  4640. typeDependencies[type].forEach(visit);
  4641. return;
  4642. }
  4643. unboundTypes.push(type);
  4644. seen[type] = true;
  4645. }
  4646. types.forEach(visit);
  4647. throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
  4648. }function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn) {
  4649. var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
  4650. name = readLatin1String(name);
  4651. rawInvoker = embind__requireFunction(signature, rawInvoker);
  4652. exposePublicSymbol(name, function() {
  4653. throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes);
  4654. }, argCount - 1);
  4655. whenDependentTypesAreResolved([], argTypes, function(argTypes) {
  4656. var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
  4657. replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn), argCount - 1);
  4658. return [];
  4659. });
  4660. }
  4661. function integerReadValueFromPointer(name, shift, signed) {
  4662. // integers are quite common, so generate very specialized functions
  4663. switch (shift) {
  4664. case 0: return signed ?
  4665. function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
  4666. function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
  4667. case 1: return signed ?
  4668. function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
  4669. function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
  4670. case 2: return signed ?
  4671. function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
  4672. function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
  4673. default:
  4674. throw new TypeError("Unknown integer type: " + name);
  4675. }
  4676. }function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
  4677. name = readLatin1String(name);
  4678. 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.
  4679. maxRange = 4294967295;
  4680. }
  4681. var shift = getShiftFromSize(size);
  4682. var fromWireType = function(value) {
  4683. return value;
  4684. };
  4685. if (minRange === 0) {
  4686. var bitshift = 32 - 8*size;
  4687. fromWireType = function(value) {
  4688. return (value << bitshift) >>> bitshift;
  4689. };
  4690. }
  4691. var isUnsignedType = (name.indexOf('unsigned') != -1);
  4692. registerType(primitiveType, {
  4693. name: name,
  4694. 'fromWireType': fromWireType,
  4695. 'toWireType': function(destructors, value) {
  4696. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
  4697. // avoid the following two if()s and assume value is of proper type.
  4698. if (typeof value !== "number" && typeof value !== "boolean") {
  4699. throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
  4700. }
  4701. if (value < minRange || value > maxRange) {
  4702. 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 + ']!');
  4703. }
  4704. return isUnsignedType ? (value >>> 0) : (value | 0);
  4705. },
  4706. 'argPackAdvance': 8,
  4707. 'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
  4708. destructorFunction: null, // This type does not need a destructor
  4709. });
  4710. }
  4711. function __embind_register_memory_view(rawType, dataTypeIndex, name) {
  4712. var typeMapping = [
  4713. Int8Array,
  4714. Uint8Array,
  4715. Int16Array,
  4716. Uint16Array,
  4717. Int32Array,
  4718. Uint32Array,
  4719. Float32Array,
  4720. Float64Array,
  4721. ];
  4722. var TA = typeMapping[dataTypeIndex];
  4723. function decodeMemoryView(handle) {
  4724. handle = handle >> 2;
  4725. var heap = HEAPU32;
  4726. var size = heap[handle]; // in elements
  4727. var data = heap[handle + 1]; // byte offset into emscripten heap
  4728. return new TA(buffer, data, size);
  4729. }
  4730. name = readLatin1String(name);
  4731. registerType(rawType, {
  4732. name: name,
  4733. 'fromWireType': decodeMemoryView,
  4734. 'argPackAdvance': 8,
  4735. 'readValueFromPointer': decodeMemoryView,
  4736. }, {
  4737. ignoreDuplicateRegistrations: true,
  4738. });
  4739. }
  4740. function __embind_register_std_string(rawType, name) {
  4741. name = readLatin1String(name);
  4742. var stdStringIsUTF8
  4743. //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
  4744. = (name === "std::string");
  4745. registerType(rawType, {
  4746. name: name,
  4747. 'fromWireType': function(value) {
  4748. var length = HEAPU32[value >> 2];
  4749. var str;
  4750. if (stdStringIsUTF8) {
  4751. var decodeStartPtr = value + 4;
  4752. // Looping here to support possible embedded '0' bytes
  4753. for (var i = 0; i <= length; ++i) {
  4754. var currentBytePtr = value + 4 + i;
  4755. if (HEAPU8[currentBytePtr] == 0 || i == length) {
  4756. var maxRead = currentBytePtr - decodeStartPtr;
  4757. var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
  4758. if (str === undefined) {
  4759. str = stringSegment;
  4760. } else {
  4761. str += String.fromCharCode(0);
  4762. str += stringSegment;
  4763. }
  4764. decodeStartPtr = currentBytePtr + 1;
  4765. }
  4766. }
  4767. } else {
  4768. var a = new Array(length);
  4769. for (var i = 0; i < length; ++i) {
  4770. a[i] = String.fromCharCode(HEAPU8[value + 4 + i]);
  4771. }
  4772. str = a.join('');
  4773. }
  4774. _free(value);
  4775. return str;
  4776. },
  4777. 'toWireType': function(destructors, value) {
  4778. if (value instanceof ArrayBuffer) {
  4779. value = new Uint8Array(value);
  4780. }
  4781. var getLength;
  4782. var valueIsOfTypeString = (typeof value === 'string');
  4783. if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
  4784. throwBindingError('Cannot pass non-string to std::string');
  4785. }
  4786. if (stdStringIsUTF8 && valueIsOfTypeString) {
  4787. getLength = function() {return lengthBytesUTF8(value);};
  4788. } else {
  4789. getLength = function() {return value.length;};
  4790. }
  4791. // assumes 4-byte alignment
  4792. var length = getLength();
  4793. var ptr = _malloc(4 + length + 1);
  4794. HEAPU32[ptr >> 2] = length;
  4795. if (stdStringIsUTF8 && valueIsOfTypeString) {
  4796. stringToUTF8(value, ptr + 4, length + 1);
  4797. } else {
  4798. if (valueIsOfTypeString) {
  4799. for (var i = 0; i < length; ++i) {
  4800. var charCode = value.charCodeAt(i);
  4801. if (charCode > 255) {
  4802. _free(ptr);
  4803. throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
  4804. }
  4805. HEAPU8[ptr + 4 + i] = charCode;
  4806. }
  4807. } else {
  4808. for (var i = 0; i < length; ++i) {
  4809. HEAPU8[ptr + 4 + i] = value[i];
  4810. }
  4811. }
  4812. }
  4813. if (destructors !== null) {
  4814. destructors.push(_free, ptr);
  4815. }
  4816. return ptr;
  4817. },
  4818. 'argPackAdvance': 8,
  4819. 'readValueFromPointer': simpleReadValueFromPointer,
  4820. destructorFunction: function(ptr) { _free(ptr); },
  4821. });
  4822. }
  4823. function __embind_register_std_wstring(rawType, charSize, name) {
  4824. name = readLatin1String(name);
  4825. var decodeString, encodeString, getHeap, lengthBytesUTF, shift;
  4826. if (charSize === 2) {
  4827. decodeString = UTF16ToString;
  4828. encodeString = stringToUTF16;
  4829. lengthBytesUTF = lengthBytesUTF16;
  4830. getHeap = function() { return HEAPU16; };
  4831. shift = 1;
  4832. } else if (charSize === 4) {
  4833. decodeString = UTF32ToString;
  4834. encodeString = stringToUTF32;
  4835. lengthBytesUTF = lengthBytesUTF32;
  4836. getHeap = function() { return HEAPU32; };
  4837. shift = 2;
  4838. }
  4839. registerType(rawType, {
  4840. name: name,
  4841. 'fromWireType': function(value) {
  4842. // Code mostly taken from _embind_register_std_string fromWireType
  4843. var length = HEAPU32[value >> 2];
  4844. var HEAP = getHeap();
  4845. var str;
  4846. var decodeStartPtr = value + 4;
  4847. // Looping here to support possible embedded '0' bytes
  4848. for (var i = 0; i <= length; ++i) {
  4849. var currentBytePtr = value + 4 + i * charSize;
  4850. if (HEAP[currentBytePtr >> shift] == 0 || i == length) {
  4851. var maxReadBytes = currentBytePtr - decodeStartPtr;
  4852. var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
  4853. if (str === undefined) {
  4854. str = stringSegment;
  4855. } else {
  4856. str += String.fromCharCode(0);
  4857. str += stringSegment;
  4858. }
  4859. decodeStartPtr = currentBytePtr + charSize;
  4860. }
  4861. }
  4862. _free(value);
  4863. return str;
  4864. },
  4865. 'toWireType': function(destructors, value) {
  4866. if (!(typeof value === 'string')) {
  4867. throwBindingError('Cannot pass non-string to C++ string type ' + name);
  4868. }
  4869. // assumes 4-byte alignment
  4870. var length = lengthBytesUTF(value);
  4871. var ptr = _malloc(4 + length + charSize);
  4872. HEAPU32[ptr >> 2] = length >> shift;
  4873. encodeString(value, ptr + 4, length + charSize);
  4874. if (destructors !== null) {
  4875. destructors.push(_free, ptr);
  4876. }
  4877. return ptr;
  4878. },
  4879. 'argPackAdvance': 8,
  4880. 'readValueFromPointer': simpleReadValueFromPointer,
  4881. destructorFunction: function(ptr) { _free(ptr); },
  4882. });
  4883. }
  4884. function __embind_register_value_object(
  4885. rawType,
  4886. name,
  4887. constructorSignature,
  4888. rawConstructor,
  4889. destructorSignature,
  4890. rawDestructor
  4891. ) {
  4892. structRegistrations[rawType] = {
  4893. name: readLatin1String(name),
  4894. rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
  4895. rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
  4896. fields: [],
  4897. };
  4898. }
  4899. function __embind_register_value_object_field(
  4900. structType,
  4901. fieldName,
  4902. getterReturnType,
  4903. getterSignature,
  4904. getter,
  4905. getterContext,
  4906. setterArgumentType,
  4907. setterSignature,
  4908. setter,
  4909. setterContext
  4910. ) {
  4911. structRegistrations[structType].fields.push({
  4912. fieldName: readLatin1String(fieldName),
  4913. getterReturnType: getterReturnType,
  4914. getter: embind__requireFunction(getterSignature, getter),
  4915. getterContext: getterContext,
  4916. setterArgumentType: setterArgumentType,
  4917. setter: embind__requireFunction(setterSignature, setter),
  4918. setterContext: setterContext,
  4919. });
  4920. }
  4921. function __embind_register_void(rawType, name) {
  4922. name = readLatin1String(name);
  4923. registerType(rawType, {
  4924. isVoid: true, // void return values can be optimized out sometimes
  4925. name: name,
  4926. 'argPackAdvance': 0,
  4927. 'fromWireType': function() {
  4928. return undefined;
  4929. },
  4930. 'toWireType': function(destructors, o) {
  4931. // TODO: assert if anything else is given?
  4932. return undefined;
  4933. },
  4934. });
  4935. }
  4936. function _emscripten_get_sbrk_ptr() {
  4937. return 291072;
  4938. }
  4939. function _emscripten_memcpy_big(dest, src, num) {
  4940. HEAPU8.copyWithin(dest, src, src + num);
  4941. }
  4942. function _emscripten_get_heap_size() {
  4943. return HEAPU8.length;
  4944. }
  4945. function abortOnCannotGrowMemory(requestedSize) {
  4946. 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 ');
  4947. }function _emscripten_resize_heap(requestedSize) {
  4948. requestedSize = requestedSize >>> 0;
  4949. abortOnCannotGrowMemory(requestedSize);
  4950. }
  4951. function _fd_close(fd) {try {
  4952. var stream = SYSCALLS.getStreamFromFD(fd);
  4953. FS.close(stream);
  4954. return 0;
  4955. } catch (e) {
  4956. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4957. return e.errno;
  4958. }
  4959. }
  4960. function _fd_read(fd, iov, iovcnt, pnum) {try {
  4961. var stream = SYSCALLS.getStreamFromFD(fd);
  4962. var num = SYSCALLS.doReadv(stream, iov, iovcnt);
  4963. HEAP32[((pnum)>>2)]=num
  4964. return 0;
  4965. } catch (e) {
  4966. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4967. return e.errno;
  4968. }
  4969. }
  4970. function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {try {
  4971. var stream = SYSCALLS.getStreamFromFD(fd);
  4972. var HIGH_OFFSET = 0x100000000; // 2^32
  4973. // use an unsigned operator on low and shift high by 32-bits
  4974. var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0);
  4975. var DOUBLE_LIMIT = 0x20000000000000; // 2^53
  4976. // we also check for equality since DOUBLE_LIMIT + 1 == DOUBLE_LIMIT
  4977. if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) {
  4978. return -61;
  4979. }
  4980. FS.llseek(stream, offset, whence);
  4981. (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]);
  4982. if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
  4983. return 0;
  4984. } catch (e) {
  4985. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4986. return e.errno;
  4987. }
  4988. }
  4989. function _fd_write(fd, iov, iovcnt, pnum) {try {
  4990. var stream = SYSCALLS.getStreamFromFD(fd);
  4991. var num = SYSCALLS.doWritev(stream, iov, iovcnt);
  4992. HEAP32[((pnum)>>2)]=num
  4993. return 0;
  4994. } catch (e) {
  4995. if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
  4996. return e.errno;
  4997. }
  4998. }
  4999. function _gettimeofday(ptr) {
  5000. var now = Date.now();
  5001. HEAP32[((ptr)>>2)]=(now/1000)|0; // seconds
  5002. HEAP32[(((ptr)+(4))>>2)]=((now % 1000)*1000)|0; // microseconds
  5003. return 0;
  5004. }
  5005. var ___tm_current=291088;
  5006. var ___tm_timezone=(stringToUTF8("GMT", 291136, 4), 291136);
  5007. function _tzset() {
  5008. // TODO: Use (malleable) environment variables instead of system settings.
  5009. if (_tzset.called) return;
  5010. _tzset.called = true;
  5011. // timezone is specified as seconds west of UTC ("The external variable
  5012. // `timezone` shall be set to the difference, in seconds, between
  5013. // Coordinated Universal Time (UTC) and local standard time."), the same
  5014. // as returned by getTimezoneOffset().
  5015. // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
  5016. HEAP32[((__get_timezone())>>2)]=(new Date()).getTimezoneOffset() * 60;
  5017. var currentYear = new Date().getFullYear();
  5018. var winter = new Date(currentYear, 0, 1);
  5019. var summer = new Date(currentYear, 6, 1);
  5020. HEAP32[((__get_daylight())>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset());
  5021. function extractZone(date) {
  5022. var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
  5023. return match ? match[1] : "GMT";
  5024. };
  5025. var winterName = extractZone(winter);
  5026. var summerName = extractZone(summer);
  5027. var winterNamePtr = allocateUTF8(winterName);
  5028. var summerNamePtr = allocateUTF8(summerName);
  5029. if (summer.getTimezoneOffset() < winter.getTimezoneOffset()) {
  5030. // Northern hemisphere
  5031. HEAP32[((__get_tzname())>>2)]=winterNamePtr;
  5032. HEAP32[(((__get_tzname())+(4))>>2)]=summerNamePtr;
  5033. } else {
  5034. HEAP32[((__get_tzname())>>2)]=summerNamePtr;
  5035. HEAP32[(((__get_tzname())+(4))>>2)]=winterNamePtr;
  5036. }
  5037. }function _localtime_r(time, tmPtr) {
  5038. _tzset();
  5039. var date = new Date(HEAP32[((time)>>2)]*1000);
  5040. HEAP32[((tmPtr)>>2)]=date.getSeconds();
  5041. HEAP32[(((tmPtr)+(4))>>2)]=date.getMinutes();
  5042. HEAP32[(((tmPtr)+(8))>>2)]=date.getHours();
  5043. HEAP32[(((tmPtr)+(12))>>2)]=date.getDate();
  5044. HEAP32[(((tmPtr)+(16))>>2)]=date.getMonth();
  5045. HEAP32[(((tmPtr)+(20))>>2)]=date.getFullYear()-1900;
  5046. HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
  5047. var start = new Date(date.getFullYear(), 0, 1);
  5048. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  5049. HEAP32[(((tmPtr)+(28))>>2)]=yday;
  5050. HEAP32[(((tmPtr)+(36))>>2)]=-(date.getTimezoneOffset() * 60);
  5051. // Attention: DST is in December in South, and some regions don't have DST at all.
  5052. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  5053. var winterOffset = start.getTimezoneOffset();
  5054. var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
  5055. HEAP32[(((tmPtr)+(32))>>2)]=dst;
  5056. var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)];
  5057. HEAP32[(((tmPtr)+(40))>>2)]=zonePtr;
  5058. return tmPtr;
  5059. }function _localtime(time) {
  5060. return _localtime_r(time, ___tm_current);
  5061. }
  5062. function _mktime(tmPtr) {
  5063. _tzset();
  5064. var date = new Date(HEAP32[(((tmPtr)+(20))>>2)] + 1900,
  5065. HEAP32[(((tmPtr)+(16))>>2)],
  5066. HEAP32[(((tmPtr)+(12))>>2)],
  5067. HEAP32[(((tmPtr)+(8))>>2)],
  5068. HEAP32[(((tmPtr)+(4))>>2)],
  5069. HEAP32[((tmPtr)>>2)],
  5070. 0);
  5071. // There's an ambiguous hour when the time goes back; the tm_isdst field is
  5072. // used to disambiguate it. Date() basically guesses, so we fix it up if it
  5073. // guessed wrong, or fill in tm_isdst with the guess if it's -1.
  5074. var dst = HEAP32[(((tmPtr)+(32))>>2)];
  5075. var guessedOffset = date.getTimezoneOffset();
  5076. var start = new Date(date.getFullYear(), 0, 1);
  5077. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  5078. var winterOffset = start.getTimezoneOffset();
  5079. var dstOffset = Math.min(winterOffset, summerOffset); // DST is in December in South
  5080. if (dst < 0) {
  5081. // Attention: some regions don't have DST at all.
  5082. HEAP32[(((tmPtr)+(32))>>2)]=Number(summerOffset != winterOffset && dstOffset == guessedOffset);
  5083. } else if ((dst > 0) != (dstOffset == guessedOffset)) {
  5084. var nonDstOffset = Math.max(winterOffset, summerOffset);
  5085. var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
  5086. // Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
  5087. date.setTime(date.getTime() + (trueOffset - guessedOffset)*60000);
  5088. }
  5089. HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
  5090. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  5091. HEAP32[(((tmPtr)+(28))>>2)]=yday;
  5092. return (date.getTime() / 1000)|0;
  5093. }
  5094. function _pthread_create() {
  5095. return 6;
  5096. }
  5097. function _pthread_join() {}
  5098. function _pthread_mutexattr_init() {}
  5099. function _pthread_mutexattr_settype() {}
  5100. function _setTempRet0($i) {
  5101. setTempRet0(($i) | 0);
  5102. }
  5103. function _time(ptr) {
  5104. var ret = (Date.now()/1000)|0;
  5105. if (ptr) {
  5106. HEAP32[((ptr)>>2)]=ret;
  5107. }
  5108. return ret;
  5109. }
  5110. var _emscripten_get_now;if (ENVIRONMENT_IS_NODE) {
  5111. _emscripten_get_now = function() {
  5112. var t = process['hrtime']();
  5113. return t[0] * 1e3 + t[1] / 1e6;
  5114. };
  5115. } else if (typeof dateNow !== 'undefined') {
  5116. _emscripten_get_now = dateNow;
  5117. } else _emscripten_get_now = function() { return performance.now(); }
  5118. ;function _usleep(useconds) {
  5119. // int usleep(useconds_t useconds);
  5120. // http://pubs.opengroup.org/onlinepubs/000095399/functions/usleep.html
  5121. // We're single-threaded, so use a busy loop. Super-ugly.
  5122. var start = _emscripten_get_now();
  5123. while (_emscripten_get_now() - start < useconds / 1000) {
  5124. // Do nothing.
  5125. }
  5126. }
  5127. function readAsmConstArgs(sigPtr, buf) {
  5128. if (!readAsmConstArgs.array) {
  5129. readAsmConstArgs.array = [];
  5130. }
  5131. var args = readAsmConstArgs.array;
  5132. args.length = 0;
  5133. var ch;
  5134. while (ch = HEAPU8[sigPtr++]) {
  5135. if (ch === 100/*'d'*/ || ch === 102/*'f'*/) {
  5136. buf = (buf + 7) & ~7;
  5137. args.push(HEAPF64[(buf >> 3)]);
  5138. buf += 8;
  5139. } else
  5140. if (ch === 105 /*'i'*/)
  5141. {
  5142. buf = (buf + 3) & ~3;
  5143. args.push(HEAP32[(buf >> 2)]);
  5144. buf += 4;
  5145. }
  5146. else abort("unexpected char in asm const signature " + ch);
  5147. }
  5148. return args;
  5149. }
  5150. var FSNode = /** @constructor */ function(parent, name, mode, rdev) {
  5151. if (!parent) {
  5152. parent = this; // root node sets parent to itself
  5153. }
  5154. this.parent = parent;
  5155. this.mount = parent.mount;
  5156. this.mounted = null;
  5157. this.id = FS.nextInode++;
  5158. this.name = name;
  5159. this.mode = mode;
  5160. this.node_ops = {};
  5161. this.stream_ops = {};
  5162. this.rdev = rdev;
  5163. };
  5164. var readMode = 292/*292*/ | 73/*73*/;
  5165. var writeMode = 146/*146*/;
  5166. Object.defineProperties(FSNode.prototype, {
  5167. read: {
  5168. get: /** @this{FSNode} */function() {
  5169. return (this.mode & readMode) === readMode;
  5170. },
  5171. set: /** @this{FSNode} */function(val) {
  5172. val ? this.mode |= readMode : this.mode &= ~readMode;
  5173. }
  5174. },
  5175. write: {
  5176. get: /** @this{FSNode} */function() {
  5177. return (this.mode & writeMode) === writeMode;
  5178. },
  5179. set: /** @this{FSNode} */function(val) {
  5180. val ? this.mode |= writeMode : this.mode &= ~writeMode;
  5181. }
  5182. },
  5183. isFolder: {
  5184. get: /** @this{FSNode} */function() {
  5185. return FS.isDir(this.mode);
  5186. }
  5187. },
  5188. isDevice: {
  5189. get: /** @this{FSNode} */function() {
  5190. return FS.isChrdev(this.mode);
  5191. }
  5192. }
  5193. });
  5194. FS.FSNode = FSNode;
  5195. FS.staticInit();;
  5196. InternalError = Module['InternalError'] = extendError(Error, 'InternalError');;
  5197. embind_init_charCodes();
  5198. BindingError = Module['BindingError'] = extendError(Error, 'BindingError');;
  5199. init_emval();;
  5200. UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
  5201. var ASSERTIONS = true;
  5202. /**
  5203. * @license
  5204. * Copyright 2017 The Emscripten Authors
  5205. * SPDX-License-Identifier: MIT
  5206. */
  5207. /** @type {function(string, boolean=, number=)} */
  5208. function intArrayFromString(stringy, dontAddNull, length) {
  5209. var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
  5210. var u8array = new Array(len);
  5211. var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
  5212. if (dontAddNull) u8array.length = numBytesWritten;
  5213. return u8array;
  5214. }
  5215. function intArrayToString(array) {
  5216. var ret = [];
  5217. for (var i = 0; i < array.length; i++) {
  5218. var chr = array[i];
  5219. if (chr > 0xFF) {
  5220. if (ASSERTIONS) {
  5221. assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
  5222. }
  5223. chr &= 0xFF;
  5224. }
  5225. ret.push(String.fromCharCode(chr));
  5226. }
  5227. return ret.join('');
  5228. }
  5229. var asmGlobalArg = {};
  5230. var asmLibraryArg = { "__assert_fail": ___assert_fail, "__cxa_allocate_exception": ___cxa_allocate_exception, "__cxa_atexit": ___cxa_atexit, "__cxa_throw": ___cxa_throw, "__handle_stack_overflow": ___handle_stack_overflow, "__sys_fcntl64": ___sys_fcntl64, "__sys_ioctl": ___sys_ioctl, "__sys_open": ___sys_open, "_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, "gettimeofday": _gettimeofday, "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 };
  5231. var asm = createWasm();
  5232. Module["asm"] = asm;
  5233. /** @type {function(...*):?} */
  5234. var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
  5235. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5236. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5237. return Module["asm"]["__wasm_call_ctors"].apply(null, arguments)
  5238. };
  5239. /** @type {function(...*):?} */
  5240. var _CreatHandle = Module["_CreatHandle"] = function() {
  5241. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5242. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5243. return Module["asm"]["CreatHandle"].apply(null, arguments)
  5244. };
  5245. /** @type {function(...*):?} */
  5246. var _GetSDKVersion = Module["_GetSDKVersion"] = function() {
  5247. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5248. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5249. return Module["asm"]["GetSDKVersion"].apply(null, arguments)
  5250. };
  5251. /** @type {function(...*):?} */
  5252. var _SysTransStart = Module["_SysTransStart"] = function() {
  5253. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5254. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5255. return Module["asm"]["SysTransStart"].apply(null, arguments)
  5256. };
  5257. /** @type {function(...*):?} */
  5258. var _SysTransInputData = Module["_SysTransInputData"] = function() {
  5259. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5260. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5261. return Module["asm"]["SysTransInputData"].apply(null, arguments)
  5262. };
  5263. /** @type {function(...*):?} */
  5264. var _SysTransRegisterDataCallBack = Module["_SysTransRegisterDataCallBack"] = function() {
  5265. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5266. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5267. return Module["asm"]["SysTransRegisterDataCallBack"].apply(null, arguments)
  5268. };
  5269. /** @type {function(...*):?} */
  5270. var _SysTransStop = Module["_SysTransStop"] = function() {
  5271. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5272. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5273. return Module["asm"]["SysTransStop"].apply(null, arguments)
  5274. };
  5275. /** @type {function(...*):?} */
  5276. var _SysTransRelease = Module["_SysTransRelease"] = function() {
  5277. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5278. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5279. return Module["asm"]["SysTransRelease"].apply(null, arguments)
  5280. };
  5281. /** @type {function(...*):?} */
  5282. var _SysTransSetEncryptKey = Module["_SysTransSetEncryptKey"] = function() {
  5283. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5284. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5285. return Module["asm"]["SysTransSetEncryptKey"].apply(null, arguments)
  5286. };
  5287. /** @type {function(...*):?} */
  5288. var _SysTransSetGlobalTime = Module["_SysTransSetGlobalTime"] = function() {
  5289. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5290. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5291. return Module["asm"]["SysTransSetGlobalTime"].apply(null, arguments)
  5292. };
  5293. /** @type {function(...*):?} */
  5294. var _malloc = Module["_malloc"] = function() {
  5295. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5296. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5297. return Module["asm"]["malloc"].apply(null, arguments)
  5298. };
  5299. /** @type {function(...*):?} */
  5300. var _free = Module["_free"] = function() {
  5301. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5302. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5303. return Module["asm"]["free"].apply(null, arguments)
  5304. };
  5305. /** @type {function(...*):?} */
  5306. var _fflush = Module["_fflush"] = function() {
  5307. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5308. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5309. return Module["asm"]["fflush"].apply(null, arguments)
  5310. };
  5311. /** @type {function(...*):?} */
  5312. var ___getTypeName = Module["___getTypeName"] = function() {
  5313. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5314. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5315. return Module["asm"]["__getTypeName"].apply(null, arguments)
  5316. };
  5317. /** @type {function(...*):?} */
  5318. var ___embind_register_native_and_builtin_types = Module["___embind_register_native_and_builtin_types"] = function() {
  5319. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5320. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5321. return Module["asm"]["__embind_register_native_and_builtin_types"].apply(null, arguments)
  5322. };
  5323. /** @type {function(...*):?} */
  5324. var ___errno_location = Module["___errno_location"] = function() {
  5325. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5326. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5327. return Module["asm"]["__errno_location"].apply(null, arguments)
  5328. };
  5329. /** @type {function(...*):?} */
  5330. var __get_tzname = Module["__get_tzname"] = function() {
  5331. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5332. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5333. return Module["asm"]["_get_tzname"].apply(null, arguments)
  5334. };
  5335. /** @type {function(...*):?} */
  5336. var __get_daylight = Module["__get_daylight"] = function() {
  5337. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5338. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5339. return Module["asm"]["_get_daylight"].apply(null, arguments)
  5340. };
  5341. /** @type {function(...*):?} */
  5342. var __get_timezone = Module["__get_timezone"] = function() {
  5343. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5344. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5345. return Module["asm"]["_get_timezone"].apply(null, arguments)
  5346. };
  5347. /** @type {function(...*):?} */
  5348. var _setThrew = Module["_setThrew"] = function() {
  5349. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5350. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5351. return Module["asm"]["setThrew"].apply(null, arguments)
  5352. };
  5353. /** @type {function(...*):?} */
  5354. var _emscripten_main_thread_process_queued_calls = Module["_emscripten_main_thread_process_queued_calls"] = function() {
  5355. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5356. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5357. return Module["asm"]["emscripten_main_thread_process_queued_calls"].apply(null, arguments)
  5358. };
  5359. /** @type {function(...*):?} */
  5360. var ___set_stack_limit = Module["___set_stack_limit"] = function() {
  5361. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5362. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5363. return Module["asm"]["__set_stack_limit"].apply(null, arguments)
  5364. };
  5365. /** @type {function(...*):?} */
  5366. var stackSave = Module["stackSave"] = function() {
  5367. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5368. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5369. return Module["asm"]["stackSave"].apply(null, arguments)
  5370. };
  5371. /** @type {function(...*):?} */
  5372. var stackAlloc = Module["stackAlloc"] = function() {
  5373. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5374. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5375. return Module["asm"]["stackAlloc"].apply(null, arguments)
  5376. };
  5377. /** @type {function(...*):?} */
  5378. var stackRestore = Module["stackRestore"] = function() {
  5379. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5380. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5381. return Module["asm"]["stackRestore"].apply(null, arguments)
  5382. };
  5383. /** @type {function(...*):?} */
  5384. var __growWasmMemory = Module["__growWasmMemory"] = function() {
  5385. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5386. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5387. return Module["asm"]["__growWasmMemory"].apply(null, arguments)
  5388. };
  5389. /** @type {function(...*):?} */
  5390. var dynCall_vii = Module["dynCall_vii"] = function() {
  5391. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5392. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5393. return Module["asm"]["dynCall_vii"].apply(null, arguments)
  5394. };
  5395. /** @type {function(...*):?} */
  5396. var dynCall_ii = Module["dynCall_ii"] = function() {
  5397. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5398. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5399. return Module["asm"]["dynCall_ii"].apply(null, arguments)
  5400. };
  5401. /** @type {function(...*):?} */
  5402. var dynCall_vi = Module["dynCall_vi"] = function() {
  5403. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5404. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5405. return Module["asm"]["dynCall_vi"].apply(null, arguments)
  5406. };
  5407. /** @type {function(...*):?} */
  5408. var dynCall_i = Module["dynCall_i"] = function() {
  5409. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5410. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5411. return Module["asm"]["dynCall_i"].apply(null, arguments)
  5412. };
  5413. /** @type {function(...*):?} */
  5414. var dynCall_viii = Module["dynCall_viii"] = function() {
  5415. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5416. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5417. return Module["asm"]["dynCall_viii"].apply(null, arguments)
  5418. };
  5419. /** @type {function(...*):?} */
  5420. var dynCall_iii = Module["dynCall_iii"] = function() {
  5421. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5422. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5423. return Module["asm"]["dynCall_iii"].apply(null, arguments)
  5424. };
  5425. /** @type {function(...*):?} */
  5426. var dynCall_iiii = Module["dynCall_iiii"] = function() {
  5427. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5428. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5429. return Module["asm"]["dynCall_iiii"].apply(null, arguments)
  5430. };
  5431. /** @type {function(...*):?} */
  5432. var dynCall_jiji = Module["dynCall_jiji"] = function() {
  5433. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5434. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5435. return Module["asm"]["dynCall_jiji"].apply(null, arguments)
  5436. };
  5437. /** @type {function(...*):?} */
  5438. var dynCall_iidiiii = Module["dynCall_iidiiii"] = function() {
  5439. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5440. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5441. return Module["asm"]["dynCall_iidiiii"].apply(null, arguments)
  5442. };
  5443. /** @type {function(...*):?} */
  5444. var dynCall_viiiiii = Module["dynCall_viiiiii"] = function() {
  5445. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5446. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5447. return Module["asm"]["dynCall_viiiiii"].apply(null, arguments)
  5448. };
  5449. /** @type {function(...*):?} */
  5450. var dynCall_viiiii = Module["dynCall_viiiii"] = function() {
  5451. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5452. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5453. return Module["asm"]["dynCall_viiiii"].apply(null, arguments)
  5454. };
  5455. /** @type {function(...*):?} */
  5456. var dynCall_viiii = Module["dynCall_viiii"] = function() {
  5457. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5458. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5459. return Module["asm"]["dynCall_viiii"].apply(null, arguments)
  5460. };
  5461. /** @type {function(...*):?} */
  5462. var dynCall_iiiii = Module["dynCall_iiiii"] = function() {
  5463. assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
  5464. assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
  5465. return Module["asm"]["dynCall_iiiii"].apply(null, arguments)
  5466. };
  5467. /**
  5468. * @license
  5469. * Copyright 2010 The Emscripten Authors
  5470. * SPDX-License-Identifier: MIT
  5471. */
  5472. // === Auto-generated postamble setup entry stuff ===
  5473. Module['asm'] = asm;
  5474. if (!Object.getOwnPropertyDescriptor(Module, "intArrayFromString")) Module["intArrayFromString"] = function() { abort("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5475. if (!Object.getOwnPropertyDescriptor(Module, "intArrayToString")) Module["intArrayToString"] = function() { abort("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5476. Module["ccall"] = ccall;
  5477. if (!Object.getOwnPropertyDescriptor(Module, "cwrap")) Module["cwrap"] = function() { abort("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5478. if (!Object.getOwnPropertyDescriptor(Module, "setValue")) Module["setValue"] = function() { abort("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5479. Module["getValue"] = getValue;
  5480. if (!Object.getOwnPropertyDescriptor(Module, "allocate")) Module["allocate"] = function() { abort("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5481. 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") };
  5482. if (!Object.getOwnPropertyDescriptor(Module, "UTF8ArrayToString")) Module["UTF8ArrayToString"] = function() { abort("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5483. if (!Object.getOwnPropertyDescriptor(Module, "UTF8ToString")) Module["UTF8ToString"] = function() { abort("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5484. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8Array")) Module["stringToUTF8Array"] = function() { abort("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5485. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8")) Module["stringToUTF8"] = function() { abort("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5486. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF8")) Module["lengthBytesUTF8"] = function() { abort("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5487. if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5488. if (!Object.getOwnPropertyDescriptor(Module, "addOnPreRun")) Module["addOnPreRun"] = function() { abort("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5489. if (!Object.getOwnPropertyDescriptor(Module, "addOnInit")) Module["addOnInit"] = function() { abort("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5490. if (!Object.getOwnPropertyDescriptor(Module, "addOnPreMain")) Module["addOnPreMain"] = function() { abort("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5491. if (!Object.getOwnPropertyDescriptor(Module, "addOnExit")) Module["addOnExit"] = function() { abort("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5492. if (!Object.getOwnPropertyDescriptor(Module, "addOnPostRun")) Module["addOnPostRun"] = function() { abort("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5493. if (!Object.getOwnPropertyDescriptor(Module, "writeStringToMemory")) Module["writeStringToMemory"] = function() { abort("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5494. Module["writeArrayToMemory"] = writeArrayToMemory;
  5495. if (!Object.getOwnPropertyDescriptor(Module, "writeAsciiToMemory")) Module["writeAsciiToMemory"] = function() { abort("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5496. 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") };
  5497. 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") };
  5498. 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") };
  5499. 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") };
  5500. 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") };
  5501. 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") };
  5502. 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") };
  5503. 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") };
  5504. 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") };
  5505. 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") };
  5506. if (!Object.getOwnPropertyDescriptor(Module, "dynamicAlloc")) Module["dynamicAlloc"] = function() { abort("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5507. if (!Object.getOwnPropertyDescriptor(Module, "loadDynamicLibrary")) Module["loadDynamicLibrary"] = function() { abort("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5508. if (!Object.getOwnPropertyDescriptor(Module, "loadWebAssemblyModule")) Module["loadWebAssemblyModule"] = function() { abort("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5509. if (!Object.getOwnPropertyDescriptor(Module, "getLEB")) Module["getLEB"] = function() { abort("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5510. if (!Object.getOwnPropertyDescriptor(Module, "getFunctionTables")) Module["getFunctionTables"] = function() { abort("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5511. if (!Object.getOwnPropertyDescriptor(Module, "alignFunctionTables")) Module["alignFunctionTables"] = function() { abort("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5512. if (!Object.getOwnPropertyDescriptor(Module, "registerFunctions")) Module["registerFunctions"] = function() { abort("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5513. if (!Object.getOwnPropertyDescriptor(Module, "addFunction")) Module["addFunction"] = function() { abort("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5514. if (!Object.getOwnPropertyDescriptor(Module, "removeFunction")) Module["removeFunction"] = function() { abort("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5515. if (!Object.getOwnPropertyDescriptor(Module, "getFuncWrapper")) Module["getFuncWrapper"] = function() { abort("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5516. if (!Object.getOwnPropertyDescriptor(Module, "prettyPrint")) Module["prettyPrint"] = function() { abort("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5517. if (!Object.getOwnPropertyDescriptor(Module, "makeBigInt")) Module["makeBigInt"] = function() { abort("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5518. if (!Object.getOwnPropertyDescriptor(Module, "dynCall")) Module["dynCall"] = function() { abort("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5519. if (!Object.getOwnPropertyDescriptor(Module, "getCompilerSetting")) Module["getCompilerSetting"] = function() { abort("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5520. if (!Object.getOwnPropertyDescriptor(Module, "print")) Module["print"] = function() { abort("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5521. if (!Object.getOwnPropertyDescriptor(Module, "printErr")) Module["printErr"] = function() { abort("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5522. if (!Object.getOwnPropertyDescriptor(Module, "getTempRet0")) Module["getTempRet0"] = function() { abort("'getTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5523. if (!Object.getOwnPropertyDescriptor(Module, "setTempRet0")) Module["setTempRet0"] = function() { abort("'setTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5524. if (!Object.getOwnPropertyDescriptor(Module, "callMain")) Module["callMain"] = function() { abort("'callMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5525. if (!Object.getOwnPropertyDescriptor(Module, "abort")) Module["abort"] = function() { abort("'abort' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5526. if (!Object.getOwnPropertyDescriptor(Module, "stringToNewUTF8")) Module["stringToNewUTF8"] = function() { abort("'stringToNewUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5527. if (!Object.getOwnPropertyDescriptor(Module, "abortOnCannotGrowMemory")) Module["abortOnCannotGrowMemory"] = function() { abort("'abortOnCannotGrowMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5528. 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)") };
  5529. if (!Object.getOwnPropertyDescriptor(Module, "ENV")) Module["ENV"] = function() { abort("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5530. if (!Object.getOwnPropertyDescriptor(Module, "setjmpId")) Module["setjmpId"] = function() { abort("'setjmpId' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5531. 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)") };
  5532. 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)") };
  5533. if (!Object.getOwnPropertyDescriptor(Module, "setErrNo")) Module["setErrNo"] = function() { abort("'setErrNo' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5534. if (!Object.getOwnPropertyDescriptor(Module, "DNS")) Module["DNS"] = function() { abort("'DNS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5535. 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)") };
  5536. if (!Object.getOwnPropertyDescriptor(Module, "Protocols")) Module["Protocols"] = function() { abort("'Protocols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5537. if (!Object.getOwnPropertyDescriptor(Module, "Sockets")) Module["Sockets"] = function() { abort("'Sockets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5538. 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)") };
  5539. if (!Object.getOwnPropertyDescriptor(Module, "readAsmConstArgs")) Module["readAsmConstArgs"] = function() { abort("'readAsmConstArgs' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5540. 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)") };
  5541. 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)") };
  5542. if (!Object.getOwnPropertyDescriptor(Module, "reallyNegative")) Module["reallyNegative"] = function() { abort("'reallyNegative' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5543. if (!Object.getOwnPropertyDescriptor(Module, "formatString")) Module["formatString"] = function() { abort("'formatString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5544. if (!Object.getOwnPropertyDescriptor(Module, "PATH")) Module["PATH"] = function() { abort("'PATH' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5545. 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)") };
  5546. if (!Object.getOwnPropertyDescriptor(Module, "SYSCALLS")) Module["SYSCALLS"] = function() { abort("'SYSCALLS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5547. if (!Object.getOwnPropertyDescriptor(Module, "syscallMmap2")) Module["syscallMmap2"] = function() { abort("'syscallMmap2' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5548. if (!Object.getOwnPropertyDescriptor(Module, "syscallMunmap")) Module["syscallMunmap"] = function() { abort("'syscallMunmap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5549. if (!Object.getOwnPropertyDescriptor(Module, "JSEvents")) Module["JSEvents"] = function() { abort("'JSEvents' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5550. if (!Object.getOwnPropertyDescriptor(Module, "specialHTMLTargets")) Module["specialHTMLTargets"] = function() { abort("'specialHTMLTargets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5551. if (!Object.getOwnPropertyDescriptor(Module, "demangle")) Module["demangle"] = function() { abort("'demangle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5552. if (!Object.getOwnPropertyDescriptor(Module, "demangleAll")) Module["demangleAll"] = function() { abort("'demangleAll' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5553. if (!Object.getOwnPropertyDescriptor(Module, "jsStackTrace")) Module["jsStackTrace"] = function() { abort("'jsStackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5554. if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5555. if (!Object.getOwnPropertyDescriptor(Module, "getEnvStrings")) Module["getEnvStrings"] = function() { abort("'getEnvStrings' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5556. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64")) Module["writeI53ToI64"] = function() { abort("'writeI53ToI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5557. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Clamped")) Module["writeI53ToI64Clamped"] = function() { abort("'writeI53ToI64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5558. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Signaling")) Module["writeI53ToI64Signaling"] = function() { abort("'writeI53ToI64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5559. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Clamped")) Module["writeI53ToU64Clamped"] = function() { abort("'writeI53ToU64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5560. if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Signaling")) Module["writeI53ToU64Signaling"] = function() { abort("'writeI53ToU64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5561. if (!Object.getOwnPropertyDescriptor(Module, "readI53FromI64")) Module["readI53FromI64"] = function() { abort("'readI53FromI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5562. if (!Object.getOwnPropertyDescriptor(Module, "readI53FromU64")) Module["readI53FromU64"] = function() { abort("'readI53FromU64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5563. if (!Object.getOwnPropertyDescriptor(Module, "convertI32PairToI53")) Module["convertI32PairToI53"] = function() { abort("'convertI32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5564. if (!Object.getOwnPropertyDescriptor(Module, "convertU32PairToI53")) Module["convertU32PairToI53"] = function() { abort("'convertU32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5565. if (!Object.getOwnPropertyDescriptor(Module, "Browser")) Module["Browser"] = function() { abort("'Browser' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5566. if (!Object.getOwnPropertyDescriptor(Module, "FS")) Module["FS"] = function() { abort("'FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5567. if (!Object.getOwnPropertyDescriptor(Module, "MEMFS")) Module["MEMFS"] = function() { abort("'MEMFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5568. if (!Object.getOwnPropertyDescriptor(Module, "TTY")) Module["TTY"] = function() { abort("'TTY' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5569. if (!Object.getOwnPropertyDescriptor(Module, "PIPEFS")) Module["PIPEFS"] = function() { abort("'PIPEFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5570. if (!Object.getOwnPropertyDescriptor(Module, "SOCKFS")) Module["SOCKFS"] = function() { abort("'SOCKFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5571. if (!Object.getOwnPropertyDescriptor(Module, "GL")) Module["GL"] = function() { abort("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5572. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGet")) Module["emscriptenWebGLGet"] = function() { abort("'emscriptenWebGLGet' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5573. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetTexPixelData")) Module["emscriptenWebGLGetTexPixelData"] = function() { abort("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5574. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetUniform")) Module["emscriptenWebGLGetUniform"] = function() { abort("'emscriptenWebGLGetUniform' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5575. if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetVertexAttrib")) Module["emscriptenWebGLGetVertexAttrib"] = function() { abort("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5576. if (!Object.getOwnPropertyDescriptor(Module, "AL")) Module["AL"] = function() { abort("'AL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5577. 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)") };
  5578. 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)") };
  5579. 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)") };
  5580. if (!Object.getOwnPropertyDescriptor(Module, "SDL")) Module["SDL"] = function() { abort("'SDL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5581. 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)") };
  5582. if (!Object.getOwnPropertyDescriptor(Module, "GLUT")) Module["GLUT"] = function() { abort("'GLUT' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5583. if (!Object.getOwnPropertyDescriptor(Module, "EGL")) Module["EGL"] = function() { abort("'EGL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5584. 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)") };
  5585. if (!Object.getOwnPropertyDescriptor(Module, "GLFW")) Module["GLFW"] = function() { abort("'GLFW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5586. if (!Object.getOwnPropertyDescriptor(Module, "GLEW")) Module["GLEW"] = function() { abort("'GLEW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5587. if (!Object.getOwnPropertyDescriptor(Module, "IDBStore")) Module["IDBStore"] = function() { abort("'IDBStore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5588. if (!Object.getOwnPropertyDescriptor(Module, "runAndAbortIfError")) Module["runAndAbortIfError"] = function() { abort("'runAndAbortIfError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5589. 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)") };
  5590. 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)") };
  5591. 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)") };
  5592. 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)") };
  5593. 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)") };
  5594. 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)") };
  5595. if (!Object.getOwnPropertyDescriptor(Module, "getStringOrSymbol")) Module["getStringOrSymbol"] = function() { abort("'getStringOrSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5596. if (!Object.getOwnPropertyDescriptor(Module, "requireHandle")) Module["requireHandle"] = function() { abort("'requireHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5597. 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)") };
  5598. if (!Object.getOwnPropertyDescriptor(Module, "craftEmvalAllocator")) Module["craftEmvalAllocator"] = function() { abort("'craftEmvalAllocator' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5599. 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)") };
  5600. 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)") };
  5601. if (!Object.getOwnPropertyDescriptor(Module, "InternalError")) Module["InternalError"] = function() { abort("'InternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5602. if (!Object.getOwnPropertyDescriptor(Module, "BindingError")) Module["BindingError"] = function() { abort("'BindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5603. if (!Object.getOwnPropertyDescriptor(Module, "UnboundTypeError")) Module["UnboundTypeError"] = function() { abort("'UnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5604. if (!Object.getOwnPropertyDescriptor(Module, "PureVirtualError")) Module["PureVirtualError"] = function() { abort("'PureVirtualError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5605. 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)") };
  5606. if (!Object.getOwnPropertyDescriptor(Module, "throwInternalError")) Module["throwInternalError"] = function() { abort("'throwInternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5607. if (!Object.getOwnPropertyDescriptor(Module, "throwBindingError")) Module["throwBindingError"] = function() { abort("'throwBindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5608. if (!Object.getOwnPropertyDescriptor(Module, "throwUnboundTypeError")) Module["throwUnboundTypeError"] = function() { abort("'throwUnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5609. if (!Object.getOwnPropertyDescriptor(Module, "ensureOverloadTable")) Module["ensureOverloadTable"] = function() { abort("'ensureOverloadTable' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5610. if (!Object.getOwnPropertyDescriptor(Module, "exposePublicSymbol")) Module["exposePublicSymbol"] = function() { abort("'exposePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5611. if (!Object.getOwnPropertyDescriptor(Module, "replacePublicSymbol")) Module["replacePublicSymbol"] = function() { abort("'replacePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5612. if (!Object.getOwnPropertyDescriptor(Module, "extendError")) Module["extendError"] = function() { abort("'extendError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5613. if (!Object.getOwnPropertyDescriptor(Module, "createNamedFunction")) Module["createNamedFunction"] = function() { abort("'createNamedFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5614. if (!Object.getOwnPropertyDescriptor(Module, "registeredInstances")) Module["registeredInstances"] = function() { abort("'registeredInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5615. if (!Object.getOwnPropertyDescriptor(Module, "getBasestPointer")) Module["getBasestPointer"] = function() { abort("'getBasestPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5616. if (!Object.getOwnPropertyDescriptor(Module, "registerInheritedInstance")) Module["registerInheritedInstance"] = function() { abort("'registerInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5617. if (!Object.getOwnPropertyDescriptor(Module, "unregisterInheritedInstance")) Module["unregisterInheritedInstance"] = function() { abort("'unregisterInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5618. if (!Object.getOwnPropertyDescriptor(Module, "getInheritedInstance")) Module["getInheritedInstance"] = function() { abort("'getInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5619. if (!Object.getOwnPropertyDescriptor(Module, "getInheritedInstanceCount")) Module["getInheritedInstanceCount"] = function() { abort("'getInheritedInstanceCount' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5620. if (!Object.getOwnPropertyDescriptor(Module, "getLiveInheritedInstances")) Module["getLiveInheritedInstances"] = function() { abort("'getLiveInheritedInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5621. if (!Object.getOwnPropertyDescriptor(Module, "registeredTypes")) Module["registeredTypes"] = function() { abort("'registeredTypes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5622. if (!Object.getOwnPropertyDescriptor(Module, "awaitingDependencies")) Module["awaitingDependencies"] = function() { abort("'awaitingDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5623. if (!Object.getOwnPropertyDescriptor(Module, "typeDependencies")) Module["typeDependencies"] = function() { abort("'typeDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5624. if (!Object.getOwnPropertyDescriptor(Module, "registeredPointers")) Module["registeredPointers"] = function() { abort("'registeredPointers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5625. if (!Object.getOwnPropertyDescriptor(Module, "registerType")) Module["registerType"] = function() { abort("'registerType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5626. if (!Object.getOwnPropertyDescriptor(Module, "whenDependentTypesAreResolved")) Module["whenDependentTypesAreResolved"] = function() { abort("'whenDependentTypesAreResolved' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5627. 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)") };
  5628. 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)") };
  5629. if (!Object.getOwnPropertyDescriptor(Module, "readLatin1String")) Module["readLatin1String"] = function() { abort("'readLatin1String' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5630. if (!Object.getOwnPropertyDescriptor(Module, "getTypeName")) Module["getTypeName"] = function() { abort("'getTypeName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5631. if (!Object.getOwnPropertyDescriptor(Module, "heap32VectorToArray")) Module["heap32VectorToArray"] = function() { abort("'heap32VectorToArray' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5632. if (!Object.getOwnPropertyDescriptor(Module, "requireRegisteredType")) Module["requireRegisteredType"] = function() { abort("'requireRegisteredType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5633. if (!Object.getOwnPropertyDescriptor(Module, "getShiftFromSize")) Module["getShiftFromSize"] = function() { abort("'getShiftFromSize' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5634. if (!Object.getOwnPropertyDescriptor(Module, "integerReadValueFromPointer")) Module["integerReadValueFromPointer"] = function() { abort("'integerReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5635. if (!Object.getOwnPropertyDescriptor(Module, "enumReadValueFromPointer")) Module["enumReadValueFromPointer"] = function() { abort("'enumReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5636. if (!Object.getOwnPropertyDescriptor(Module, "floatReadValueFromPointer")) Module["floatReadValueFromPointer"] = function() { abort("'floatReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5637. if (!Object.getOwnPropertyDescriptor(Module, "simpleReadValueFromPointer")) Module["simpleReadValueFromPointer"] = function() { abort("'simpleReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5638. if (!Object.getOwnPropertyDescriptor(Module, "runDestructors")) Module["runDestructors"] = function() { abort("'runDestructors' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5639. if (!Object.getOwnPropertyDescriptor(Module, "new_")) Module["new_"] = function() { abort("'new_' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5640. if (!Object.getOwnPropertyDescriptor(Module, "craftInvokerFunction")) Module["craftInvokerFunction"] = function() { abort("'craftInvokerFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5641. 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)") };
  5642. if (!Object.getOwnPropertyDescriptor(Module, "tupleRegistrations")) Module["tupleRegistrations"] = function() { abort("'tupleRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5643. if (!Object.getOwnPropertyDescriptor(Module, "structRegistrations")) Module["structRegistrations"] = function() { abort("'structRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5644. if (!Object.getOwnPropertyDescriptor(Module, "genericPointerToWireType")) Module["genericPointerToWireType"] = function() { abort("'genericPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5645. if (!Object.getOwnPropertyDescriptor(Module, "constNoSmartPtrRawPointerToWireType")) Module["constNoSmartPtrRawPointerToWireType"] = function() { abort("'constNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5646. if (!Object.getOwnPropertyDescriptor(Module, "nonConstNoSmartPtrRawPointerToWireType")) Module["nonConstNoSmartPtrRawPointerToWireType"] = function() { abort("'nonConstNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5647. 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)") };
  5648. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredPointer")) Module["RegisteredPointer"] = function() { abort("'RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5649. 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)") };
  5650. 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)") };
  5651. 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)") };
  5652. 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)") };
  5653. if (!Object.getOwnPropertyDescriptor(Module, "runDestructor")) Module["runDestructor"] = function() { abort("'runDestructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5654. if (!Object.getOwnPropertyDescriptor(Module, "releaseClassHandle")) Module["releaseClassHandle"] = function() { abort("'releaseClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5655. if (!Object.getOwnPropertyDescriptor(Module, "finalizationGroup")) Module["finalizationGroup"] = function() { abort("'finalizationGroup' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5656. 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)") };
  5657. if (!Object.getOwnPropertyDescriptor(Module, "detachFinalizer")) Module["detachFinalizer"] = function() { abort("'detachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5658. if (!Object.getOwnPropertyDescriptor(Module, "attachFinalizer")) Module["attachFinalizer"] = function() { abort("'attachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5659. if (!Object.getOwnPropertyDescriptor(Module, "makeClassHandle")) Module["makeClassHandle"] = function() { abort("'makeClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5660. 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)") };
  5661. if (!Object.getOwnPropertyDescriptor(Module, "ClassHandle")) Module["ClassHandle"] = function() { abort("'ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5662. 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)") };
  5663. if (!Object.getOwnPropertyDescriptor(Module, "throwInstanceAlreadyDeleted")) Module["throwInstanceAlreadyDeleted"] = function() { abort("'throwInstanceAlreadyDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5664. 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)") };
  5665. 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)") };
  5666. if (!Object.getOwnPropertyDescriptor(Module, "deletionQueue")) Module["deletionQueue"] = function() { abort("'deletionQueue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5667. 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)") };
  5668. 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)") };
  5669. if (!Object.getOwnPropertyDescriptor(Module, "flushPendingDeletes")) Module["flushPendingDeletes"] = function() { abort("'flushPendingDeletes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5670. if (!Object.getOwnPropertyDescriptor(Module, "delayFunction")) Module["delayFunction"] = function() { abort("'delayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5671. if (!Object.getOwnPropertyDescriptor(Module, "setDelayFunction")) Module["setDelayFunction"] = function() { abort("'setDelayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5672. if (!Object.getOwnPropertyDescriptor(Module, "RegisteredClass")) Module["RegisteredClass"] = function() { abort("'RegisteredClass' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5673. if (!Object.getOwnPropertyDescriptor(Module, "shallowCopyInternalPointer")) Module["shallowCopyInternalPointer"] = function() { abort("'shallowCopyInternalPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5674. if (!Object.getOwnPropertyDescriptor(Module, "downcastPointer")) Module["downcastPointer"] = function() { abort("'downcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5675. if (!Object.getOwnPropertyDescriptor(Module, "upcastPointer")) Module["upcastPointer"] = function() { abort("'upcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5676. if (!Object.getOwnPropertyDescriptor(Module, "validateThis")) Module["validateThis"] = function() { abort("'validateThis' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5677. 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)") };
  5678. 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)") };
  5679. if (!Object.getOwnPropertyDescriptor(Module, "makeLegalFunctionName")) Module["makeLegalFunctionName"] = function() { abort("'makeLegalFunctionName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5680. if (!Object.getOwnPropertyDescriptor(Module, "warnOnce")) Module["warnOnce"] = function() { abort("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5681. if (!Object.getOwnPropertyDescriptor(Module, "stackSave")) Module["stackSave"] = function() { abort("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5682. if (!Object.getOwnPropertyDescriptor(Module, "stackRestore")) Module["stackRestore"] = function() { abort("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5683. if (!Object.getOwnPropertyDescriptor(Module, "stackAlloc")) Module["stackAlloc"] = function() { abort("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5684. if (!Object.getOwnPropertyDescriptor(Module, "AsciiToString")) Module["AsciiToString"] = function() { abort("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5685. if (!Object.getOwnPropertyDescriptor(Module, "stringToAscii")) Module["stringToAscii"] = function() { abort("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5686. if (!Object.getOwnPropertyDescriptor(Module, "UTF16ToString")) Module["UTF16ToString"] = function() { abort("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5687. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF16")) Module["stringToUTF16"] = function() { abort("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5688. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF16")) Module["lengthBytesUTF16"] = function() { abort("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5689. if (!Object.getOwnPropertyDescriptor(Module, "UTF32ToString")) Module["UTF32ToString"] = function() { abort("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5690. if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF32")) Module["stringToUTF32"] = function() { abort("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5691. if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF32")) Module["lengthBytesUTF32"] = function() { abort("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5692. if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8")) Module["allocateUTF8"] = function() { abort("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5693. if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8OnStack")) Module["allocateUTF8OnStack"] = function() { abort("'allocateUTF8OnStack' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") };
  5694. Module["writeStackCookie"] = writeStackCookie;
  5695. Module["checkStackCookie"] = checkStackCookie;
  5696. 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)") } });
  5697. 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)") } });
  5698. 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)") } });
  5699. 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)") } });
  5700. var calledRun;
  5701. /**
  5702. * @constructor
  5703. * @this {ExitStatus}
  5704. */
  5705. function ExitStatus(status) {
  5706. this.name = "ExitStatus";
  5707. this.message = "Program terminated with exit(" + status + ")";
  5708. this.status = status;
  5709. }
  5710. var calledMain = false;
  5711. dependenciesFulfilled = function runCaller() {
  5712. // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
  5713. if (!calledRun) run();
  5714. if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
  5715. };
  5716. /** @type {function(Array=)} */
  5717. function run(args) {
  5718. args = args || arguments_;
  5719. if (runDependencies > 0) {
  5720. return;
  5721. }
  5722. writeStackCookie();
  5723. preRun();
  5724. if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
  5725. function doRun() {
  5726. // run may have just been called through dependencies being fulfilled just in this very frame,
  5727. // or while the async setStatus time below was happening
  5728. if (calledRun) return;
  5729. calledRun = true;
  5730. Module['calledRun'] = true;
  5731. if (ABORT) return;
  5732. initRuntime();
  5733. preMain();
  5734. if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
  5735. assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
  5736. postRun();
  5737. }
  5738. if (Module['setStatus']) {
  5739. Module['setStatus']('Running...');
  5740. setTimeout(function() {
  5741. setTimeout(function() {
  5742. Module['setStatus']('');
  5743. }, 1);
  5744. doRun();
  5745. }, 1);
  5746. } else
  5747. {
  5748. doRun();
  5749. }
  5750. checkStackCookie();
  5751. }
  5752. Module['run'] = run;
  5753. function checkUnflushedContent() {
  5754. // Compiler settings do not allow exiting the runtime, so flushing
  5755. // the streams is not possible. but in ASSERTIONS mode we check
  5756. // if there was something to flush, and if so tell the user they
  5757. // should request that the runtime be exitable.
  5758. // Normally we would not even include flush() at all, but in ASSERTIONS
  5759. // builds we do so just for this check, and here we see if there is any
  5760. // content to flush, that is, we check if there would have been
  5761. // something a non-ASSERTIONS build would have not seen.
  5762. // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
  5763. // mode (which has its own special function for this; otherwise, all
  5764. // the code is inside libc)
  5765. var print = out;
  5766. var printErr = err;
  5767. var has = false;
  5768. out = err = function(x) {
  5769. has = true;
  5770. }
  5771. try { // it doesn't matter if it fails
  5772. var flush = Module['_fflush'];
  5773. if (flush) flush(0);
  5774. // also flush in the JS FS layer
  5775. ['stdout', 'stderr'].forEach(function(name) {
  5776. var info = FS.analyzePath('/dev/' + name);
  5777. if (!info) return;
  5778. var stream = info.object;
  5779. var rdev = stream.rdev;
  5780. var tty = TTY.ttys[rdev];
  5781. if (tty && tty.output && tty.output.length) {
  5782. has = true;
  5783. }
  5784. });
  5785. } catch(e) {}
  5786. out = print;
  5787. err = printErr;
  5788. if (has) {
  5789. 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.');
  5790. }
  5791. }
  5792. /** @param {boolean|number=} implicit */
  5793. function exit(status, implicit) {
  5794. checkUnflushedContent();
  5795. // if this is just main exit-ing implicitly, and the status is 0, then we
  5796. // don't need to do anything here and can just leave. if the status is
  5797. // non-zero, though, then we need to report it.
  5798. // (we may have warned about this earlier, if a situation justifies doing so)
  5799. if (implicit && noExitRuntime && status === 0) {
  5800. return;
  5801. }
  5802. if (noExitRuntime) {
  5803. // if exit() was called, we may warn the user if the runtime isn't actually being shut down
  5804. if (!implicit) {
  5805. 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)';
  5806. err(msg);
  5807. }
  5808. } else {
  5809. ABORT = true;
  5810. EXITSTATUS = status;
  5811. exitRuntime();
  5812. if (Module['onExit']) Module['onExit'](status);
  5813. }
  5814. quit_(status, new ExitStatus(status));
  5815. }
  5816. if (Module['preInit']) {
  5817. if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
  5818. while (Module['preInit'].length > 0) {
  5819. Module['preInit'].pop()();
  5820. }
  5821. }
  5822. noExitRuntime = true;
  5823. run();
  5824. // {{MODULE_ADDITIONS}}