123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920 |
- #!/usr/bin/env node
- var define = (function amdefine(module, requireFn) {
- 'use strict';
- var defineCache = {},
- loaderCache = {},
- alreadyCalled = false,
- path = require('path'),
- makeRequire, stringRequire;
- /**
- * Trims the . and .. from an array of path segments.
- * It will keep a leading path segment if a .. will become
- * the first path segment, to help with module name lookups,
- * which act like paths, but can be remapped. But the end result,
- * all paths that use this function should look normalized.
- * NOTE: this method MODIFIES the input array.
- * @param {Array} ary the array of path segments.
- */
- function trimDots(ary) {
- var i, part;
- for (i = 0; ary[i]; i+= 1) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
- //End of the line. Keep at least one non-dot
- //path segment at the front so it can be mapped
- //correctly to disk. Otherwise, there is likely
- //no path mapping for a path starting with '..'.
- //This can still fail, but catches the most reasonable
- //uses of ..
- break;
- } else if (i > 0) {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- }
- function normalize(name, baseName) {
- var baseParts;
- //Adjust any relative paths.
- if (name && name.charAt(0) === '.') {
- //If have a base name, try to normalize against it,
- //otherwise, assume it is a top-level require that will
- //be relative to baseUrl in the end.
- if (baseName) {
- baseParts = baseName.split('/');
- baseParts = baseParts.slice(0, baseParts.length - 1);
- baseParts = baseParts.concat(name.split('/'));
- trimDots(baseParts);
- name = baseParts.join('/');
- }
- }
- return name;
- }
- /**
- * Create the normalize() function passed to a loader plugin's
- * normalize method.
- */
- function makeNormalize(relName) {
- return function (name) {
- return normalize(name, relName);
- };
- }
- function makeLoad(id) {
- function load(value) {
- loaderCache[id] = value;
- }
- load.fromText = function (id, text) {
- //This one is difficult because the text can/probably uses
- //define, and any relative paths and requires should be relative
- //to that id was it would be found on disk. But this would require
- //bootstrapping a module/require fairly deeply from node core.
- //Not sure how best to go about that yet.
- throw new Error('amdefine does not implement load.fromText');
- };
- return load;
- }
- makeRequire = function (systemRequire, exports, module, relId) {
- function amdRequire(deps, callback) {
- if (typeof deps === 'string') {
- //Synchronous, single module require('')
- return stringRequire(systemRequire, exports, module, deps, relId);
- } else {
- //Array of dependencies with a callback.
- //Convert the dependencies to modules.
- deps = deps.map(function (depName) {
- return stringRequire(systemRequire, exports, module, depName, relId);
- });
- //Wait for next tick to call back the require call.
- process.nextTick(function () {
- callback.apply(null, deps);
- });
- }
- }
- amdRequire.toUrl = function (filePath) {
- if (filePath.indexOf('.') === 0) {
- return normalize(filePath, path.dirname(module.filename));
- } else {
- return filePath;
- }
- };
- return amdRequire;
- };
- //Favor explicit value, passed in if the module wants to support Node 0.4.
- requireFn = requireFn || function req() {
- return module.require.apply(module, arguments);
- };
- function runFactory(id, deps, factory) {
- var r, e, m, result;
- if (id) {
- e = loaderCache[id] = {};
- m = {
- id: id,
- uri: __filename,
- exports: e
- };
- r = makeRequire(requireFn, e, m, id);
- } else {
- //Only support one define call per file
- if (alreadyCalled) {
- throw new Error('amdefine with no module ID cannot be called more than once per file.');
- }
- alreadyCalled = true;
- //Use the real variables from node
- //Use module.exports for exports, since
- //the exports in here is amdefine exports.
- e = module.exports;
- m = module;
- r = makeRequire(requireFn, e, m, module.id);
- }
- //If there are dependencies, they are strings, so need
- //to convert them to dependency values.
- if (deps) {
- deps = deps.map(function (depName) {
- return r(depName);
- });
- }
- //Call the factory with the right dependencies.
- if (typeof factory === 'function') {
- result = factory.apply(m.exports, deps);
- } else {
- result = factory;
- }
- if (result !== undefined) {
- m.exports = result;
- if (id) {
- loaderCache[id] = m.exports;
- }
- }
- }
- stringRequire = function (systemRequire, exports, module, id, relId) {
- //Split the ID by a ! so that
- var index = id.indexOf('!'),
- originalId = id,
- prefix, plugin;
- if (index === -1) {
- id = normalize(id, relId);
- //Straight module lookup. If it is one of the special dependencies,
- //deal with it, otherwise, delegate to node.
- if (id === 'require') {
- return makeRequire(systemRequire, exports, module, relId);
- } else if (id === 'exports') {
- return exports;
- } else if (id === 'module') {
- return module;
- } else if (loaderCache.hasOwnProperty(id)) {
- return loaderCache[id];
- } else if (defineCache[id]) {
- runFactory.apply(null, defineCache[id]);
- return loaderCache[id];
- } else {
- if(systemRequire) {
- return systemRequire(originalId);
- } else {
- throw new Error('No module with ID: ' + id);
- }
- }
- } else {
- //There is a plugin in play.
- prefix = id.substring(0, index);
- id = id.substring(index + 1, id.length);
- plugin = stringRequire(systemRequire, exports, module, prefix, relId);
- if (plugin.normalize) {
- id = plugin.normalize(id, makeNormalize(relId));
- } else {
- //Normalize the ID normally.
- id = normalize(id, relId);
- }
- if (loaderCache[id]) {
- return loaderCache[id];
- } else {
- plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
- return loaderCache[id];
- }
- }
- };
- //Create a define function specific to the module asking for amdefine.
- function define(id, deps, factory) {
- if (Array.isArray(id)) {
- factory = deps;
- deps = id;
- id = undefined;
- } else if (typeof id !== 'string') {
- factory = id;
- id = deps = undefined;
- }
- if (deps && !Array.isArray(deps)) {
- factory = deps;
- deps = undefined;
- }
- if (!deps) {
- deps = ['require', 'exports', 'module'];
- }
- //Set up properties for this module. If an ID, then use
- //internal cache. If no ID, then use the external variables
- //for this node module.
- if (id) {
- //Put the module in deep freeze until there is a
- //require call for it.
- defineCache[id] = [id, deps, factory];
- } else {
- runFactory(id, deps, factory);
- }
- }
- //define.require, which has access to all the values in the
- //cache. Useful for AMD modules that all have IDs in the file,
- //but need to finally export a value to node based on one of those
- //IDs.
- define.require = function (id) {
- if (loaderCache[id]) {
- return loaderCache[id];
- }
- if (defineCache[id]) {
- runFactory.apply(null, defineCache[id]);
- return loaderCache[id];
- }
- };
- define.amd = {};
- return define;
- })(null, function (id) { throw new Error("Dependency not found: " + id); }), requirejs = define.require;
- define("amber_vm/browser-compatibility", [], {});
- /* ====================================================================
- |
- | Amber Smalltalk
- | http://amber-lang.net
- |
- ======================================================================
- ======================================================================
- |
- | Copyright (c) 2010-2014
- | Nicolas Petton <petton.nicolas@gmail.com>
- |
- | Copyright (c) 2012-2014
- | The Amber team https://github.com/amber-smalltalk?tab=members
- | Amber contributors https://github.com/amber-smalltalk/amber/graphs/contributors
- |
- | Amber is released under the MIT license
- |
- | Permission is hereby granted, free of charge, to any person obtaining
- | a copy of this software and associated documentation files (the
- | 'Software'), to deal in the Software without restriction, including
- | without limitation the rights to use, copy, modify, merge, publish,
- | distribute, sublicense, and/or sell copies of the Software, and to
- | permit persons to whom the Software is furnished to do so, subject to
- | the following conditions:
- |
- | The above copyright notice and this permission notice shall be
- | included in all copies or substantial portions of the Software.
- |
- | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
- | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- |
- ==================================================================== */
- define("amber_vm/boot", [ 'require', './browser-compatibility' ], function (require) {
- /* Reconfigurable micro composition system, https://github.com/amber-smalltalk/brikz */
- function Brikz(api, apiKey, initKey) {
- var brikz = this, backup = {};
- apiKey = apiKey || 'exports';
- initKey = initKey || '__init__';
- function mixin(src, target, what) {
- for (var keys = Object.keys(what||src), l=keys.length, i=0; i<l; ++i) {
- var value = src[keys[i]];
- if (typeof value !== "undefined") { target[keys[i]] = value; }
- }
- return target;
- }
- var d={value: null, enumerable: false, configurable: true, writable: true};
- Object.defineProperties(this, { ensure: d, rebuild: d });
- var exclude = mixin(this, {});
- this.rebuild = function () {
- Object.keys(backup).forEach(function (key) {
- mixin({}, api, (backup[key]||0)[apiKey]);
- });
- var oapi = mixin(api, {}), order = [], chk = {};
- brikz.ensure = function(key) {
- if (key in exclude) { return null; }
- var b = brikz[key], bak = backup[key];
- mixin({}, api, api);
- while (typeof b === "function") { b = new b(brikz, api, bak); }
- if (b && !chk[key]) { chk[key]=true; order.push(b); }
- if (b && !b[apiKey]) { b[apiKey] = mixin(api, {}); }
- return brikz[key] = b;
- };
- Object.keys(brikz).forEach(function (key) { brikz.ensure(key); });
- brikz.ensure = null;
- mixin(oapi, mixin({}, api, api));
- order.forEach(function(brik) { mixin(brik[apiKey] || {}, api); });
- order.forEach(function(brik) { brik[initKey] && brik[initKey](); });
- backup = mixin(brikz, {});
- };
- }
- /* Brikz end */
- function inherits(child, parent) {
- child.prototype = Object.create(parent.prototype, {
- constructor: { value: child,
- enumerable: false, configurable: true, writable: true }
- });
- return child;
- }
- var globals = {};
- globals.SmalltalkSettings = {};
- var api = Object.create(globals);
- var brikz = new Brikz(api);
- function RootBrik(brikz, st) {
- /* Smalltalk foundational objects */
- /* SmalltalkRoot is the hidden root of the Amber hierarchy.
- All objects including `Object` inherit from SmalltalkRoot */
- function SmalltalkRoot() {}
- function SmalltalkProtoObject() {}
- inherits(SmalltalkProtoObject, SmalltalkRoot);
- function SmalltalkObject() {}
- inherits(SmalltalkObject, SmalltalkProtoObject);
- function SmalltalkNil() {}
- inherits(SmalltalkNil, SmalltalkObject);
- this.Object = SmalltalkObject;
- this.nil = new SmalltalkNil();
- // Hidden root class of the system.
- this.rootAsClass = {fn: SmalltalkRoot};
- this.__init__ = function () {
- st.addPackage("Kernel-Objects");
- st.addPackage("Kernel-Infrastructure");
- st.wrapClassName("ProtoObject", "Kernel-Objects", SmalltalkProtoObject, undefined, false);
- st.wrapClassName("Object", "Kernel-Objects", SmalltalkObject, globals.ProtoObject, false);
- st.wrapClassName("UndefinedObject", "Kernel-Objects", SmalltalkNil, globals.Object, false);
- };
- }
- function OrganizeBrik(brikz, st) {
- brikz.ensure("augments");
- var SmalltalkObject = brikz.ensure("root").Object;
- function SmalltalkOrganizer () {}
- function SmalltalkPackageOrganizer () {
- this.elements = [];
- }
- function SmalltalkClassOrganizer () {
- this.elements = [];
- }
- inherits(SmalltalkOrganizer, SmalltalkObject);
- inherits(SmalltalkPackageOrganizer, SmalltalkOrganizer);
- inherits(SmalltalkClassOrganizer, SmalltalkOrganizer);
- this.__init__ = function () {
- st.wrapClassName("Organizer", "Kernel-Infrastructure", SmalltalkOrganizer, globals.Object, false);
- st.wrapClassName("PackageOrganizer", "Kernel-Infrastructure", SmalltalkPackageOrganizer, globals.Organizer, false);
- st.wrapClassName("ClassOrganizer", "Kernel-Infrastructure", SmalltalkClassOrganizer, globals.Organizer, false);
- };
- this.setupClassOrganization = function (klass) {
- klass.organization = new SmalltalkClassOrganizer();
- klass.organization.theClass = klass;
- };
- this.setupPackageOrganization = function (pkg) {
- pkg.organization = new SmalltalkPackageOrganizer();
- };
- this.addOrganizationElement = function (owner, element) {
- owner.organization.elements.addElement(element);
- };
- this.removeOrganizationElement = function (owner, element) {
- owner.organization.elements.removeElement(element);
- };
- }
- function DNUBrik(brikz, st) {
- brikz.ensure("selectorConversion");
- brikz.ensure("messageSend");
- var manip = brikz.ensure("manipulation");
- var rootAsClass = brikz.ensure("root").rootAsClass;
- /* Method not implemented handlers */
- var methods = [], checker = Object.create(null);
- this.selectors = [];
- this.get = function (string) {
- var index = this.selectors.indexOf(string);
- if(index !== -1) {
- return methods[index];
- }
- this.selectors.push(string);
- var selector = st.selector(string);
- checker[selector] = true;
- var method = {jsSelector: selector, fn: createHandler(selector)};
- methods.push(method);
- manip.installMethod(method, rootAsClass);
- return method;
- };
- this.isSelector = function (selector) {
- return checker[selector];
- };
- /* Dnu handler method */
- function createHandler(selector) {
- return function() {
- var args = Array.prototype.slice.call(arguments);
- return brikz.messageSend.messageNotUnderstood(this, selector, args);
- };
- }
- this.installHandlers = function (klass) {
- for(var i=0; i<methods.length; i++) {
- manip.installMethodIfAbsent(methods[i], klass);
- }
- };
- }
- function ClassInitBrik(brikz, st) {
- var dnu = brikz.ensure("dnu");
- var manip = brikz.ensure("manipulation");
- var nil = brikz.ensure("root").nil;
- /* Initialize a class in its class hierarchy. Handle both classes and
- metaclasses. */
- st.init = function(klass) {
- st.initClass(klass);
- if(klass.klass && !klass.meta) {
- st.initClass(klass.klass);
- }
- };
- st.initClass = function(klass) {
- if(klass.wrapped) {
- copySuperclass(klass);
- }
- if(klass.wrapped) {
- dnu.installHandlers(klass);
- }
- };
- function copySuperclass(klass, superclass) {
- var inheritedMethods = Object.create(null);
- deinstallAllMethods(klass);
- for (superclass = superclass || klass.superclass;
- superclass && superclass !== nil;
- superclass = superclass.superclass) {
- for (var keys = Object.keys(superclass.methods), i = 0; i < keys.length; i++) {
- inheritMethodIfAbsent(superclass.methods[keys[i]]);
- }
- }
- manip.reinstallMethods(klass);
- function inheritMethodIfAbsent(method) {
- var selector = method.selector;
- //TODO: prepare klass methods into inheritedMethods to only test once
- if(klass.methods[selector] || inheritedMethods[selector]) {
- return;
- }
- manip.installMethod(method, klass);
- inheritedMethods[method.selector] = true;
- }
- }
- function deinstallAllMethods(klass) {
- var proto = klass.fn.prototype;
- for(var keys = Object.getOwnPropertyNames(proto), i=0; i<keys.length; i++) {
- var key = keys[i];
- if (dnu.isSelector(key)) {
- proto[key] = null;
- }
- }
- }
- }
- function ManipulationBrik(brikz, st) {
- this.installMethodIfAbsent = function (handler, klass) {
- if(!klass.fn.prototype[handler.jsSelector]) {
- installMethod(handler, klass);
- }
- };
- function installMethod (method, klass) {
- Object.defineProperty(klass.fn.prototype, method.jsSelector, {
- value: method.fn,
- enumerable: false, configurable: true, writable: true
- });
- }
- this.installMethod = installMethod;
- this.reinstallMethods = function (klass) {
- var methods = klass.methods;
- for(var keys = Object.keys(methods), i=0; i<keys.length; i++) {
- installMethod(methods[keys[i]], klass);
- }
- };
- }
- function ClassesBrik(brikz, st) {
- var org = brikz.ensure("organize");
- var root = brikz.ensure("root");
- var nil = root.nil;
- var rootAsClass = root.rootAsClass;
- var SmalltalkObject = root.Object;
- rootAsClass.klass = {fn: SmalltalkClass};
- function SmalltalkPackage() {}
- function SmalltalkBehavior() {}
- function SmalltalkClass() {}
- function SmalltalkMetaclass() {}
- inherits(SmalltalkPackage, SmalltalkObject);
- inherits(SmalltalkBehavior, SmalltalkObject);
- inherits(SmalltalkClass, SmalltalkBehavior);
- inherits(SmalltalkMetaclass, SmalltalkBehavior);
- SmalltalkMetaclass.prototype.meta = true;
- this.__init__ = function () {
- st.addPackage("Kernel-Classes");
- st.wrapClassName("Behavior", "Kernel-Classes", SmalltalkBehavior, globals.Object, false);
- st.wrapClassName("Metaclass", "Kernel-Classes", SmalltalkMetaclass, globals.Behavior, false);
- st.wrapClassName("Class", "Kernel-Classes", SmalltalkClass, globals.Behavior, false);
- // Manually bootstrap the metaclass hierarchy
- globals.ProtoObject.klass.superclass = rootAsClass.klass = globals.Class;
- addSubclass(globals.ProtoObject.klass);
- st.wrapClassName("Package", "Kernel-Infrastructure", SmalltalkPackage, globals.Object, false);
- };
- /* Smalltalk classes */
- var classes = [];
- var wrappedClasses = [];
- /* We hold all Packages in a separate Object */
- st.packages = {};
- /* Smalltalk package creation. To add a Package, use smalltalk.addPackage() */
- function pkg(spec) {
- var that = new SmalltalkPackage();
- that.pkgName = spec.pkgName;
- org.setupPackageOrganization(that);
- that.properties = spec.properties || {};
- return that;
- }
- /* Smalltalk class creation. A class is an instance of an automatically
- created metaclass object. Newly created classes (not their metaclass)
- should be added to the smalltalk object, see smalltalk.addClass().
- Superclass linking is *not* handled here, see smalltalk.init() */
- function klass(spec) {
- spec = spec || {};
- var setSuperClass = spec.superclass;
- if(!spec.superclass) {
- spec.superclass = rootAsClass;
- }
- var meta = metaclass(spec);
- var that = meta.instanceClass;
- that.superclass = setSuperClass;
- that.fn = spec.fn || inherits(function () {}, spec.superclass.fn);
- that.subclasses = [];
- setupClass(that, spec);
- that.className = spec.className;
- that.wrapped = spec.wrapped || false;
- meta.className = spec.className + ' class';
- meta.superclass = spec.superclass.klass;
- return that;
- }
- function metaclass(spec) {
- spec = spec || {};
- var that = new SmalltalkMetaclass();
- that.fn = inherits(function () {}, spec.superclass.klass.fn);
- that.instanceClass = new that.fn();
- setupClass(that);
- return that;
- }
- SmalltalkBehavior.prototype.toString = function () {
- return 'Smalltalk ' + this.className;
- };
- function setupClass(klass, spec) {
- spec = spec || {};
- klass.iVarNames = spec.iVarNames || [];
- klass.pkg = spec.pkg;
- org.setupClassOrganization(klass);
- Object.defineProperty(klass, "methods", {
- value: Object.create(null),
- enumerable: false, configurable: true, writable: true
- });
- Object.defineProperty(klass.fn.prototype, "klass", {
- value: klass,
- enumerable: false, configurable: true, writable: true
- });
- }
- /* Add a package to the smalltalk.packages object, creating a new one if needed.
- If pkgName is null or empty we return nil, which is an allowed package for a class.
- If package already exists we still update the properties of it. */
- st.addPackage = function(pkgName, properties) {
- if(!pkgName) {return nil;}
- if(!(st.packages[pkgName])) {
- st.packages[pkgName] = pkg({
- pkgName: pkgName,
- properties: properties
- });
- } else {
- if(properties) {
- st.packages[pkgName].properties = properties;
- }
- }
- return st.packages[pkgName];
- };
- /* Add a class to the smalltalk object, creating a new one if needed.
- A Package is lazily created if it does not exist with given name. */
- st.addClass = function(className, superclass, iVarNames, pkgName) {
- if (superclass == nil) { superclass = null; }
- // While subclassing nil is allowed, it might be an error, so
- // warn about it.
- if (superclass === null) {
- console.warn('Compiling ' + className + ' as a subclass of `nil`. A dependency might be missing.');
- }
- rawAddClass(pkgName, className, superclass, iVarNames, false, null);
- };
- function rawAddClass(pkgName, className, superclass, iVarNames, wrapped, fn) {
- var pkg = st.packages[pkgName];
- if (!pkg) {
- throw new Error("Missing package "+pkgName);
- }
- if(globals[className] && globals[className].superclass == superclass) {
- // globals[className].superclass = superclass;
- globals[className].iVarNames = iVarNames || [];
- if (pkg) globals[className].pkg = pkg;
- if (fn) {
- fn.prototype = globals[className].fn.prototype;
- globals[className].fn = fn;
- fn.prototype.constructor = fn;
- }
- } else {
- if(globals[className]) {
- st.removeClass(globals[className]);
- }
- globals[className] = klass({
- className: className,
- superclass: superclass,
- pkg: pkg,
- iVarNames: iVarNames,
- fn: fn,
- wrapped: wrapped
- });
- addSubclass(globals[className]);
- }
- classes.addElement(globals[className]);
- org.addOrganizationElement(pkg, globals[className]);
- }
- st.removeClass = function(klass) {
- org.removeOrganizationElement(klass.pkg, klass);
- classes.removeElement(klass);
- removeSubclass(klass);
- delete globals[klass.className];
- };
- function addSubclass(klass) {
- if(klass.superclass) {
- klass.superclass.subclasses.addElement(klass);
- }
- }
- function removeSubclass(klass) {
- if(klass.superclass) {
- klass.superclass.subclasses.removeElement(klass);
- }
- }
- /* Create a new class wrapping a JavaScript constructor, and add it to the
- global smalltalk object. Package is lazily created if it does not exist with given name. */
- st.wrapClassName = function(className, pkgName, fn, superclass, wrapped) {
- wrapped = wrapped !== false;
- rawAddClass(pkgName, className, superclass, globals[className] && globals[className].iVarNames, wrapped, fn);
- if(wrapped) {
- wrappedClasses.addElement(globals[className]);
- }
- };
- /* Manually set the constructor of an existing Smalltalk klass, making it a wrapped class. */
- st.setClassConstructor = function(klass, constructor) {
- wrappedClasses.addElement(klass);
- klass.wrapped = true;
- klass.fn = constructor;
- // The fn property changed. We need to add back the klass property to the prototype
- Object.defineProperty(klass.fn.prototype, "klass", {
- value: klass,
- enumerable: false, configurable: true, writable: true
- });
- st.initClass(klass);
- };
- /* Create an alias for an existing class */
- st.alias = function(klass, alias) {
- globals[alias] = klass;
- };
- /* Answer all registered Smalltalk classes */
- //TODO: remove the function and make smalltalk.classes an array
- st.classes = function() {
- return classes;
- };
- st.wrappedClasses = function() {
- return wrappedClasses;
- };
- // Still used, but could go away now that subclasses are stored
- // into classes directly.
- st.allSubclasses = function(klass) {
- return klass._allSubclasses();
- };
- }
- function MethodsBrik(brikz, st) {
- var manip = brikz.ensure("manipulation");
- var org = brikz.ensure("organize");
- var stInit = brikz.ensure("stInit");
- var dnu = brikz.ensure("dnu");
- var SmalltalkObject = brikz.ensure("root").Object;
- brikz.ensure("selectorConversion");
- brikz.ensure("classes");
- brikz.ensure("classInit");
- function SmalltalkMethod() {}
- inherits(SmalltalkMethod, SmalltalkObject);
- this.__init__ = function () {
- st.addPackage("Kernel-Methods");
- st.wrapClassName("CompiledMethod", "Kernel-Methods", SmalltalkMethod, globals.Object, false);
- };
- /* Smalltalk method object. To add a method to a class,
- use smalltalk.addMethod() */
- st.method = function(spec) {
- var that = new SmalltalkMethod();
- that.selector = spec.selector;
- that.jsSelector = spec.jsSelector;
- that.args = spec.args || {};
- // spec.category is kept for compatibility
- that.protocol = spec.protocol || spec.category;
- that.source = spec.source;
- that.messageSends = spec.messageSends || [];
- that.referencedClasses = spec.referencedClasses || [];
- that.fn = spec.fn;
- return that;
- };
- function installNewDnuHandler(newHandler) {
- var wrappedClasses = st.wrappedClasses();
- for(var i = 0; i < wrappedClasses.length; i++) {
- manip.installMethodIfAbsent(newHandler, wrappedClasses[i]);
- }
- }
- /* Add/remove a method to/from a class */
- st.addMethod = function (method, klass) {
- if (!(method.jsSelector)) {
- method.jsSelector = st.selector(method.selector);
- }
- manip.installMethod(method, klass);
- klass.methods[method.selector] = method;
- method.methodClass = klass;
- // During the bootstrap, #addCompiledMethod is not used.
- // Therefore we populate the organizer here too
- org.addOrganizationElement(klass, method.protocol);
- propagateMethodChange(klass);
- for(var i=0; i<method.messageSends.length; i++) {
- var dnuHandler = dnu.get(method.messageSends[i]);
- if(stInit.initialized()) {
- installNewDnuHandler(dnuHandler);
- }
- }
- };
- function propagateMethodChange(klass) {
- // If already initialized (else it will be done later anyway),
- // re-initialize all subclasses to ensure the method change
- // propagation (for wrapped classes, not using the prototype
- // chain).
- //TODO: optimize, only one method need to be updated, not all of them
- if (stInit.initialized()) {
- st.allSubclasses(klass).forEach(function (subclass) {
- st.initClass(subclass);
- });
- }
- }
- st.removeMethod = function(method, klass) {
- if (klass !== method.methodClass) {
- throw new Error(
- "Refusing to remove method "
- + method.methodClass.className+">>"+method.selector
- + " from different class "
- + klass.className);
- }
- delete klass.fn.prototype[st.selector(method.selector)];
- delete klass.methods[method.selector];
- st.initClass(klass);
- propagateMethodChange(klass);
- // Do *not* delete protocols from here.
- // This is handled by #removeCompiledMethod
- };
- /* Answer all method selectors based on dnu handlers */
- st.allSelectors = function() {
- return dnu.selectors;
- };
- }
- function AugmentsBrik(brikz, st) {
- /* Make sure that console is defined */
- if(typeof console === "undefined") {
- this.console = {
- log: function() {},
- warn: function() {},
- info: function() {},
- debug: function() {},
- error: function() {}
- };
- }
- /* Array extensions */
- Array.prototype.addElement = function(el) {
- if(typeof el === 'undefined') { return; }
- if(this.indexOf(el) == -1) {
- this.push(el);
- }
- };
- Array.prototype.removeElement = function(el) {
- var i = this.indexOf(el);
- if (i !== -1) { this.splice(i, 1); }
- };
- }
- function SmalltalkInitBrik(brikz, st) {
- brikz.ensure("classInit");
- brikz.ensure("classes");
- var nil = brikz.ensure("root").nil;
- var initialized = false;
- /* Smalltalk initialization. Called on page load */
- st.initialize = function() {
- if(initialized) { return; }
- st.classes().forEach(function(klass) {
- st.init(klass);
- });
- runnable();
- st.classes().forEach(function(klass) {
- klass._initialize();
- });
- initialized = true;
- };
- this.initialized = function () {
- return initialized;
- };
- this.__init__ = function () {
- st.addPackage("Kernel-Methods");
- st.wrapClassName("Number", "Kernel-Objects", Number, globals.Object);
- st.wrapClassName("BlockClosure", "Kernel-Methods", Function, globals.Object);
- st.wrapClassName("Boolean", "Kernel-Objects", Boolean, globals.Object);
- st.wrapClassName("Date", "Kernel-Objects", Date, globals.Object);
- st.addPackage("Kernel-Collections");
- st.addClass("Collection", globals.Object, null, "Kernel-Collections");
- st.addClass("IndexableCollection", globals.Collection, null, "Kernel-Collections");
- st.addClass("SequenceableCollection", globals.IndexableCollection, null, "Kernel-Collections");
- st.addClass("CharacterArray", globals.SequenceableCollection, null, "Kernel-Collections");
- st.wrapClassName("String", "Kernel-Collections", String, globals.CharacterArray);
- st.wrapClassName("Array", "Kernel-Collections", Array, globals.SequenceableCollection);
- st.wrapClassName("RegularExpression", "Kernel-Collections", RegExp, globals.Object);
- st.addPackage("Kernel-Exceptions");
- st.wrapClassName("Error", "Kernel-Exceptions", Error, globals.Object);
- /* Alias definitions */
- st.alias(globals.Array, "OrderedCollection");
- st.alias(globals.Date, "Time");
- };
- }
- function PrimitivesBrik(brikz, st) {
- /* Unique ID number generator */
- var oid = 0;
- st.nextId = function() {
- oid += 1;
- return oid;
- };
- /* Converts a JavaScript object to valid Smalltalk Object */
- st.readJSObject = function(js) {
- var object = js;
- var readObject = (js.constructor === Object);
- var readArray = (js.constructor === Array);
- if(readObject) {
- object = globals.Dictionary._new();
- }
- for(var i in js) {
- if(readObject) {
- object._at_put_(i, st.readJSObject(js[i]));
- }
- if(readArray) {
- object[i] = st.readJSObject(js[i]);
- }
- }
- return object;
- };
- /* Boolean assertion */
- st.assert = function(shouldBeBoolean) {
- if (undefined !== shouldBeBoolean && shouldBeBoolean.klass === globals.Boolean) {
- return shouldBeBoolean == true;
- } else {
- globals.NonBooleanReceiver._new()._object_(shouldBeBoolean)._signal();
- }
- };
- /* List of all reserved words in JavaScript. They may not be used as variables
- in Smalltalk. */
- // list of reserved JavaScript keywords as of
- // http://es5.github.com/#x7.6.1.1
- // and
- // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.6.1
- st.reservedWords = ['break', 'case', 'catch', 'continue', 'debugger',
- 'default', 'delete', 'do', 'else', 'finally', 'for', 'function',
- 'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw',
- 'try', 'typeof', 'var', 'void', 'while', 'with',
- // ES5: future use: http://es5.github.com/#x7.6.1.2
- 'class', 'const', 'enum', 'export', 'extends', 'import', 'super',
- // ES5: future use in strict mode
- 'implements', 'interface', 'let', 'package', 'private', 'protected',
- 'public', 'static', 'yield'];
- st.globalJsVariables = ['jQuery', 'window', 'document', 'process', 'global'];
- }
- function RuntimeBrik(brikz, st) {
- brikz.ensure("selectorConversion");
- var root = brikz.ensure("root");
- var nil = root.nil;
- var SmalltalkObject = root.Object;
- function SmalltalkMethodContext(home, setup) {
- this.sendIdx = {};
- this.homeContext = home;
- this.setup = setup || function() {};
- }
- inherits(SmalltalkMethodContext, SmalltalkObject);
- this.__init__ = function () {
- st.addPackage("Kernel-Methods");
- st.wrapClassName("MethodContext", "Kernel-Methods", SmalltalkMethodContext, globals.Object, false);
- // Fallbacks
- SmalltalkMethodContext.prototype.locals = {};
- SmalltalkMethodContext.prototype.receiver = null;
- SmalltalkMethodContext.prototype.selector = null;
- SmalltalkMethodContext.prototype.lookupClass = null;
- SmalltalkMethodContext.prototype.fill = function(receiver, selector, locals, lookupClass) {
- this.receiver = receiver;
- this.selector = selector;
- this.locals = locals || {};
- this.lookupClass = lookupClass;
- if(this.homeContext) {
- this.homeContext.evaluatedSelector = selector;
- }
- };
- SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx, index) {
- this.locals = locals || {};
- this.outerContext = ctx;
- this.index = index || 0;
- };
- SmalltalkMethodContext.prototype.init = function() {
- var home = this.homeContext;
- if(home) {
- home.init();
- }
- this.setup(this);
- };
- SmalltalkMethodContext.prototype.method = function() {
- var method;
- var lookup = this.lookupClass || this.receiver.klass;
- while(!method && lookup) {
- method = lookup.methods[st.convertSelector(this.selector)];
- lookup = lookup.superclass;
- }
- return method;
- };
- };
- /* This is the current call context object. While it is publicly available,
- Use smalltalk.getThisContext() instead which will answer a safe copy of
- the current context */
- st.thisContext = undefined;
- st.withContext = function(worker, setup) {
- if(st.thisContext) {
- return inContext(worker, setup);
- } else {
- try {
- return inContext(worker, setup);
- } catch(error) {
- handleError(error);
- st.thisContext = null;
- // Rethrow the error in any case.
- throw error;
- }
- }
- };
- function inContext(worker, setup) {
- var context = pushContext(setup);
- var result = worker(context);
- popContext(context);
- return result;
- }
- /* Wrap a JavaScript exception in a Smalltalk Exception.
- In case of a RangeError, stub the stack after 100 contexts to
- avoid another RangeError later when the stack is manipulated. */
- function wrappedError(error) {
- var errorWrapper = globals.JavaScriptException._on_(error);
- // Add the error to the context, so it is visible in the stack
- try { errorWrapper._signal(); } catch (ex) {}
- var context = st.getThisContext();
- if(isRangeError(error)) {
- stubContextStack(context);
- }
- errorWrapper._context_(context);
- return errorWrapper;
- }
- /* Stub the context stack after 100 contexts */
- function stubContextStack(context) {
- var currentContext = context;
- var contexts = 0;
- while(contexts < 100) {
- if(currentContext) {
- currentContext = currentContext.homeContext;
- }
- contexts++;
- }
- if(currentContext) {
- currentContext.homeContext = undefined;
- }
- }
- function isRangeError(error) {
- return error instanceof RangeError;
- }
- /* Handles Smalltalk errors. Triggers the registered ErrorHandler
- (See the Smalltalk class ErrorHandler and its subclasses */
- function handleError(error) {
- if (!error.smalltalkError) {
- error = wrappedError(error);
- }
- globals.ErrorHandler._handleError_(error);
- }
- /* Handle thisContext pseudo variable */
- st.getThisContext = function() {
- if(st.thisContext) {
- st.thisContext.init();
- return st.thisContext;
- } else {
- return nil;
- }
- };
- function pushContext(setup) {
- return st.thisContext = new SmalltalkMethodContext(st.thisContext, setup);
- }
- function popContext(context) {
- st.thisContext = context.homeContext;
- }
- }
- function MessageSendBrik(brikz, st) {
- brikz.ensure("selectorConversion");
- var nil = brikz.ensure("root").nil;
- /* Handles unhandled errors during message sends */
- // simply send the message and handle #dnu:
- st.send = function(receiver, selector, args, klass) {
- var method;
- if(receiver === null) {
- receiver = nil;
- }
- method = klass ? klass.fn.prototype[selector] : receiver.klass && receiver[selector];
- if(method) {
- return method.apply(receiver, args);
- } else {
- return messageNotUnderstood(receiver, selector, args);
- }
- };
- /* Handles #dnu: *and* JavaScript method calls.
- if the receiver has no klass, we consider it a JS object (outside of the
- Amber system). Else assume that the receiver understands #doesNotUnderstand: */
- function messageNotUnderstood(receiver, selector, args) {
- /* Handles JS method calls. */
- if(receiver.klass === undefined || receiver.allowJavaScriptCalls) {
- return callJavaScriptMethod(receiver, selector, args);
- }
- /* Handles not understood messages. Also see the Amber counter-part
- Object>>doesNotUnderstand: */
- return receiver._doesNotUnderstand_(
- globals.Message._new()
- ._selector_(st.convertSelector(selector))
- ._arguments_(args)
- );
- }
- /* Call a method of a JS object, or answer a property if it exists.
- Else try wrapping a JSObjectProxy around the receiver.
- If the object property is a function, then call it, except if it starts with
- an uppercase character (we probably want to answer the function itself in this
- case and send it #new from Amber).
- Converts keyword-based selectors by using the first
- keyword only, but keeping all message arguments.
- Example:
- "self do: aBlock with: anObject" -> "self.do(aBlock, anObject)" */
- function callJavaScriptMethod(receiver, selector, args) {
- var jsSelector = selector._asJavaScriptSelector();
- var jsProperty = receiver[jsSelector];
- if(typeof jsProperty === "function" && !/^[A-Z]/.test(jsSelector)) {
- return jsProperty.apply(receiver, args);
- } else if(jsProperty !== undefined) {
- if(args[0]) {
- receiver[jsSelector] = args[0];
- return nil;
- } else {
- return jsProperty;
- }
- }
- return st.send(globals.JSObjectProxy._on_(receiver), selector, args);
- }
- this.messageNotUnderstood = messageNotUnderstood;
- }
- function SelectorConversionBrik(brikz, st) {
- /* Convert a Smalltalk selector into a JS selector */
- st.selector = function(string) {
- var selector = '_' + string;
- selector = selector.replace(/:/g, '_');
- selector = selector.replace(/[\&]/g, '_and');
- selector = selector.replace(/[\|]/g, '_or');
- selector = selector.replace(/[+]/g, '_plus');
- selector = selector.replace(/-/g, '_minus');
- selector = selector.replace(/[*]/g ,'_star');
- selector = selector.replace(/[\/]/g ,'_slash');
- selector = selector.replace(/[\\]/g ,'_backslash');
- selector = selector.replace(/[\~]/g ,'_tild');
- selector = selector.replace(/>/g ,'_gt');
- selector = selector.replace(/</g ,'_lt');
- selector = selector.replace(/=/g ,'_eq');
- selector = selector.replace(/,/g ,'_comma');
- selector = selector.replace(/[@]/g ,'_at');
- return selector;
- };
- /* Convert a string to a valid smalltalk selector.
- if you modify the following functions, also change String>>asSelector
- accordingly */
- st.convertSelector = function(selector) {
- if(selector.match(/__/)) {
- return convertBinarySelector(selector);
- } else {
- return convertKeywordSelector(selector);
- }
- };
- function convertKeywordSelector(selector) {
- return selector.replace(/^_/, '').replace(/_/g, ':');
- }
- function convertBinarySelector(selector) {
- return selector
- .replace(/^_/, '')
- .replace(/_and/g, '&')
- .replace(/_or/g, '|')
- .replace(/_plus/g, '+')
- .replace(/_minus/g, '-')
- .replace(/_star/g, '*')
- .replace(/_slash/g, '/')
- .replace(/_backslash/g, '\\')
- .replace(/_tild/g, '~')
- .replace(/_gt/g, '>')
- .replace(/_lt/g, '<')
- .replace(/_eq/g, '=')
- .replace(/_comma/g, ',')
- .replace(/_at/g, '@');
- }
- }
- /* Adds AMD and requirejs related methods to the smalltalk object */
- function AMDBrik(brikz, st) {
- this.__init__ = function () {
- st.amdRequire = require;
- st.defaultTransportType = st.defaultTransportType || "amd";
- st.defaultAmdNamespace = st.defaultAmdNamespace || "amber_core";
- };
- }
- /* Making smalltalk that can load */
- brikz.root = RootBrik;
- brikz.dnu = DNUBrik;
- brikz.organize = OrganizeBrik;
- brikz.selectorConversion = SelectorConversionBrik;
- brikz.classInit = ClassInitBrik;
- brikz.manipulation = ManipulationBrik;
- brikz.classes = ClassesBrik;
- brikz.methods = MethodsBrik;
- brikz.stInit = SmalltalkInitBrik;
- brikz.augments = AugmentsBrik;
- brikz.amdBrik = AMDBrik;
- brikz.rebuild();
- /* Making smalltalk that can run */
- function runnable () {
- brikz.messageSend = MessageSendBrik;
- brikz.runtime = RuntimeBrik;
- brikz.primitives = PrimitivesBrik;
- brikz.rebuild();
- };
- return { vm: api, nil: brikz.root.nil, globals: globals };
- });
- define("amber_vm/smalltalk", ["./boot"], function (boot) {
- return boot.vm;
- });
- define("amber_vm/globals", ["./boot"], function (boot) {
- return boot.globals;
- });
- define("amber_vm/nil", ["./boot"], function (boot) {
- return boot.nil;
- });
- /**
- * _st is a function used all over the compiled amber code that
- * takes any value (JavaScript or Smalltalk)
- * and returns a proper Amber Smalltalk receiver.
- *
- * null or undefined -> nil,
- * plain JS object -> wrapped JS object,
- * otherwise unchanged
- */
- define("amber_vm/_st", ["./globals", "./nil"], function (globals, nil) {
- return function (o) {
- if (o == null) { return nil; }
- if (o.klass) { return o; }
- return globals.JSObjectProxy._on_(o);
- };
- });
- define("amber_core/Kernel-Objects", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Objects');
- smalltalk.packages["Kernel-Objects"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('ProtoObject', globals.nil, [], 'Kernel-Objects');
- globals.ProtoObject.comment="I implement the basic behavior required for any object in Amber.\x0a\x0aIn most cases, subclassing `ProtoObject` is wrong and `Object` should be used instead. However subclassing `ProtoObject` can be useful in some special cases like proxy implementations. ";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__eq_eq(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"=",{anObject:anObject},globals.ProtoObject)})},
- args: ["anObject"],
- source: "= anObject\x0a\x09^ self == anObject",
- messageSends: ["=="],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "==",
- protocol: 'comparing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._identityHash();
- $ctx1.sendIdx["identityHash"]=1;
- $1=_st($2).__eq(_st(anObject)._identityHash());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"==",{anObject:anObject},globals.ProtoObject)})},
- args: ["anObject"],
- source: "== anObject\x0a\x09^ self identityHash = anObject identityHash",
- messageSends: ["=", "identityHash"],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._printString();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.ProtoObject)})},
- args: [],
- source: "asString\x0a\x09^ self printString",
- messageSends: ["printString"],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "class",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.klass;
- return self}, function($ctx1) {$ctx1.fill(self,"class",{},globals.ProtoObject)})},
- args: [],
- source: "class\x0a\x09<return self.klass>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "doesNotUnderstand:",
- protocol: 'error handling',
- fn: function (aMessage){
- var self=this;
- function $MessageNotUnderstood(){return globals.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($MessageNotUnderstood())._new();
- _st($1)._receiver_(self);
- _st($1)._message_(aMessage);
- $2=_st($1)._signal();
- return self}, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},globals.ProtoObject)})},
- args: ["aMessage"],
- source: "doesNotUnderstand: aMessage\x0a\x09MessageNotUnderstood new\x0a\x09\x09receiver: self;\x0a\x09\x09message: aMessage;\x0a\x09\x09signal",
- messageSends: ["receiver:", "new", "message:", "signal"],
- referencedClasses: ["MessageNotUnderstood"]
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "identityHash",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var hash=self.identityHash;
- if (hash) return hash;
- hash=smalltalk.nextId();
- Object.defineProperty(self, 'identityHash', {value:hash});
- return hash;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"identityHash",{},globals.ProtoObject)})},
- args: [],
- source: "identityHash\x0a\x09<\x0a\x09\x09var hash=self.identityHash;\x0a\x09\x09if (hash) return hash;\x0a\x09\x09hash=smalltalk.nextId();\x0a\x09\x09Object.defineProperty(self, 'identityHash', {value:hash});\x0a\x09\x09return hash;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "initialize",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspect",
- protocol: 'inspecting',
- fn: function (){
- var self=this;
- function $Inspector(){return globals.Inspector||(typeof Inspector=="undefined"?nil:Inspector)}
- return smalltalk.withContext(function($ctx1) {
- _st($Inspector())._inspect_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"inspect",{},globals.ProtoObject)})},
- args: [],
- source: "inspect\x0a\x09Inspector inspect: self",
- messageSends: ["inspect:"],
- referencedClasses: ["Inspector"]
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspectOn:",
- protocol: 'inspecting',
- fn: function (anInspector){
- var self=this;
- return self},
- args: ["anInspector"],
- source: "inspectOn: anInspector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instVarAt:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self['@'+aString] ;
- return self}, function($ctx1) {$ctx1.fill(self,"instVarAt:",{aString:aString},globals.ProtoObject)})},
- args: ["aString"],
- source: "instVarAt: aString\x0a\x09< return self['@'+aString] >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instVarAt:put:",
- protocol: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self['@' + aString] = anObject ;
- return self}, function($ctx1) {$ctx1.fill(self,"instVarAt:put:",{aString:aString,anObject:anObject},globals.ProtoObject)})},
- args: ["aString", "anObject"],
- source: "instVarAt: aString put: anObject\x0a\x09< self['@' + aString] = anObject >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "perform:",
- protocol: 'message handling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._perform_withArguments_(aString,[]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"perform:",{aString:aString},globals.ProtoObject)})},
- args: ["aString"],
- source: "perform: aString\x0a\x09^ self perform: aString withArguments: #()",
- messageSends: ["perform:withArguments:"],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "perform:withArguments:",
- protocol: 'message handling',
- fn: function (aString,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.send(self, aString._asSelector(), aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"perform:withArguments:",{aString:aString,aCollection:aCollection},globals.ProtoObject)})},
- args: ["aString", "aCollection"],
- source: "perform: aString withArguments: aCollection\x0a\x09<return smalltalk.send(self, aString._asSelector(), aCollection)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $5,$4,$3,$2,$1;
- $5=self._class();
- $ctx1.sendIdx["class"]=1;
- $4=_st($5)._name();
- $ctx1.sendIdx["name"]=1;
- $3=_st($4)._first();
- $2=_st($3)._isVowel();
- if(smalltalk.assert($2)){
- $1="an ";
- } else {
- $1="a ";
- };
- _st(aStream)._nextPutAll_($1);
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(_st(self._class())._name());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.ProtoObject)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: (self class name first isVowel\x0a\x09\x09ifTrue: [ 'an ' ]\x0a\x09\x09ifFalse: [ 'a ' ]).\x0a\x09aStream nextPutAll: self class name",
- messageSends: ["nextPutAll:", "ifTrue:ifFalse:", "isVowel", "first", "name", "class"],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printString",
- protocol: 'printing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($String())._streamContents_((function(str){
- return smalltalk.withContext(function($ctx2) {
- return self._printOn_(str);
- }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"printString",{},globals.ProtoObject)})},
- args: [],
- source: "printString\x0a\x09^ String streamContents: [ :str | \x0a\x09\x09self printOn: str ]",
- messageSends: ["streamContents:", "printOn:"],
- referencedClasses: ["String"]
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "yourself",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "yourself\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "~=",
- protocol: 'comparing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self.__eq(anObject)).__eq(false);
- $ctx1.sendIdx["="]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"~=",{anObject:anObject},globals.ProtoObject)})},
- args: ["anObject"],
- source: "~= anObject\x0a\x09^ (self = anObject) = false",
- messageSends: ["="],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "~~",
- protocol: 'comparing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self.__eq_eq(anObject)).__eq(false);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"~~",{anObject:anObject},globals.ProtoObject)})},
- args: ["anObject"],
- source: "~~ anObject\x0a\x09^ (self == anObject) = false",
- messageSends: ["=", "=="],
- referencedClasses: []
- }),
- globals.ProtoObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "class";
- },
- args: [],
- source: "heliosClass\x0a\x09\x22Should be an Helios extension. Unfortunately, since helios can browse remote\x0a\x09environments, we can't extend base classes\x22\x0a\x09\x0a\x09^ 'class'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "initialize",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtoObject.klass);
- smalltalk.addClass('Object', globals.ProtoObject, [], 'Kernel-Objects');
- globals.Object.comment="**I am the root of the Smalltalk class system**. With the exception of unual subclasses of `ProtoObject`, all other classes in the system are subclasses of me.\x0a\x0aI provide default behavior common to all normal objects (some of it inherited from `ProtoObject`), such as:\x0a\x0a- accessing\x0a- copying\x0a- comparison\x0a- error handling\x0a- message sending\x0a- reflection\x0a\x0aAlso utility messages that all objects should respond to are defined here.\x0a\x0aI have no instance variable.\x0a\x0a##Access\x0a\x0aInstance variables can be accessed with `#instVarAt:` and `#instVarAt:put:`. `#instanceVariableNames` answers a collection of all instance variable names.\x0aAccessing JavaScript properties of an object is done through `#basicAt:`, `#basicAt:put:` and `basicDelete:`.\x0a\x0a##Copying\x0a\x0aCopying an object is handled by `#copy` and `#deepCopy`. The first one performs a shallow copy of the receiver, while the second one performs a deep copy.\x0aThe hook method `#postCopy` can be overriden in subclasses to copy fields as necessary to complete the full copy. It will be sent by the copy of the receiver.\x0a\x0a##Comparison\x0a\x0aI understand equality `#=` and identity `#==` comparison.\x0a\x0a##Error handling\x0a\x0a- `#halt` is the typical message to use for inserting breakpoints during debugging.\x0a- `#error:` throws a generic error exception\x0a- `#doesNotUnderstand:` handles the fact that there was an attempt to send the given message to the receiver but the receiver does not understand this message.\x0a\x09Overriding this message can be useful to implement proxies for example.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "->",
- protocol: 'converting',
- fn: function (anObject){
- var self=this;
- function $Association(){return globals.Association||(typeof Association=="undefined"?nil:Association)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Association())._key_value_(self,anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"->",{anObject:anObject},globals.Object)})},
- args: ["anObject"],
- source: "-> anObject\x0a\x09^ Association key: self value: anObject",
- messageSends: ["key:value:"],
- referencedClasses: ["Association"]
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- var variables;
- function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- variables=_st($HashedCollection())._new();
- _st(_st(self._class())._allInstanceVariableNames())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(variables)._at_put_(each,_st(self._instVarAt_(each))._asJSON());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=variables;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJSON",{variables:variables},globals.Object)})},
- args: [],
- source: "asJSON\x0a\x09| variables |\x0a\x09variables := HashedCollection new.\x0a\x09self class allInstanceVariableNames do: [ :each |\x0a\x09\x09variables at: each put: (self instVarAt: each) asJSON ].\x0a\x09^ variables",
- messageSends: ["new", "do:", "allInstanceVariableNames", "class", "at:put:", "asJSON", "instVarAt:"],
- referencedClasses: ["HashedCollection"]
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSONString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $JSON(){return globals.JSON||(typeof JSON=="undefined"?nil:JSON)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($JSON())._stringify_(self._asJSON());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJSONString",{},globals.Object)})},
- args: [],
- source: "asJSONString\x0a\x09^ JSON stringify: self asJSON",
- messageSends: ["stringify:", "asJSON"],
- referencedClasses: ["JSON"]
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._asString();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.Object)})},
- args: [],
- source: "asJavascript\x0a\x09^ self asString",
- messageSends: ["asString"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicAt:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self[aString];
- return self}, function($ctx1) {$ctx1.fill(self,"basicAt:",{aString:aString},globals.Object)})},
- args: ["aString"],
- source: "basicAt: aString\x0a\x09<return self[aString]>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicAt:put:",
- protocol: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self[aString] = anObject;
- return self}, function($ctx1) {$ctx1.fill(self,"basicAt:put:",{aString:aString,anObject:anObject},globals.Object)})},
- args: ["aString", "anObject"],
- source: "basicAt: aString put: anObject\x0a\x09<return self[aString] = anObject>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicDelete:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- delete self[aString]; return aString;
- return self}, function($ctx1) {$ctx1.fill(self,"basicDelete:",{aString:aString},globals.Object)})},
- args: ["aString"],
- source: "basicDelete: aString\x0a\x09<delete self[aString]; return aString>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicPerform:",
- protocol: 'message handling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicPerform_withArguments_(aString,[]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"basicPerform:",{aString:aString},globals.Object)})},
- args: ["aString"],
- source: "basicPerform: aString\x0a\x09^ self basicPerform: aString withArguments: #()",
- messageSends: ["basicPerform:withArguments:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicPerform:withArguments:",
- protocol: 'message handling',
- fn: function (aString,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self[aString].apply(self, aCollection);;
- return self}, function($ctx1) {$ctx1.fill(self,"basicPerform:withArguments:",{aString:aString,aCollection:aCollection},globals.Object)})},
- args: ["aString", "aCollection"],
- source: "basicPerform: aString withArguments: aCollection\x0a\x09<return self[aString].apply(self, aCollection);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._shallowCopy())._postCopy();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"copy",{},globals.Object)})},
- args: [],
- source: "copy\x0a\x09^ self shallowCopy postCopy",
- messageSends: ["postCopy", "shallowCopy"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var copy = self.klass._new();
- Object.keys(self).forEach(function (i) {
- if(/^@.+/.test(i)) {
- copy[i] = self[i]._deepCopy();
- }
- });
- return copy;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"deepCopy",{},globals.Object)})},
- args: [],
- source: "deepCopy\x0a\x09<\x0a\x09\x09var copy = self.klass._new();\x0a\x09\x09Object.keys(self).forEach(function (i) {\x0a\x09\x09if(/^@.+/.test(i)) {\x0a\x09\x09\x09copy[i] = self[i]._deepCopy();\x0a\x09\x09}\x0a\x09\x09});\x0a\x09\x09return copy;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deprecatedAPI",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$6,$5,$4,$8,$7,$3,$2;
- $1=console;
- $6=smalltalk.getThisContext()._home();
- $ctx1.sendIdx["home"]=1;
- $5=_st($6)._asString();
- $ctx1.sendIdx["asString"]=1;
- $4=_st($5).__comma(" is deprecated! (in ");
- $8=_st(smalltalk.getThisContext()._home())._home();
- $ctx1.sendIdx["home"]=2;
- $7=_st($8)._asString();
- $3=_st($4).__comma($7);
- $ctx1.sendIdx[","]=2;
- $2=_st($3).__comma(")");
- $ctx1.sendIdx[","]=1;
- _st($1)._warn_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"deprecatedAPI",{},globals.Object)})},
- args: [],
- source: "deprecatedAPI\x0a\x09\x22Just a simple way to deprecate methods.\x0a\x09#deprecatedAPI is in the 'error handling' protocol even if it doesn't throw an error,\x0a\x09but it could in the future.\x22\x0a\x09console warn: thisContext home asString, ' is deprecated! (in ', thisContext home home asString, ')'",
- messageSends: ["warn:", ",", "asString", "home"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "error:",
- protocol: 'error handling',
- fn: function (aString){
- var self=this;
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- return smalltalk.withContext(function($ctx1) {
- _st($Error())._signal_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"error:",{aString:aString},globals.Object)})},
- args: ["aString"],
- source: "error: aString\x0a\x09Error signal: aString",
- messageSends: ["signal:"],
- referencedClasses: ["Error"]
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "halt",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("Halt encountered");
- return self}, function($ctx1) {$ctx1.fill(self,"halt",{},globals.Object)})},
- args: [],
- source: "halt\x0a\x09self error: 'Halt encountered'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return self;
- },
- args: ["aBlock"],
- source: "ifNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:ifNotNil:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anotherBlock)._value_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Object)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifNil: aBlock ifNotNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ anotherBlock value: self",
- messageSends: ["value:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aBlock)._value_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{aBlock:aBlock},globals.Object)})},
- args: ["aBlock"],
- source: "ifNotNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ aBlock value: self",
- messageSends: ["value:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:ifNil:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aBlock)._value_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Object)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifNotNil: aBlock ifNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ aBlock value: self",
- messageSends: ["value:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspectOn:",
- protocol: 'inspecting',
- fn: function (anInspector){
- var self=this;
- var variables;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- variables=_st($Dictionary())._new();
- _st(variables)._at_put_("#self",self);
- $ctx1.sendIdx["at:put:"]=1;
- _st(_st(self._class())._allInstanceVariableNames())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(variables)._at_put_(each,self._instVarAt_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(anInspector)._setLabel_(self._printString());
- $1=_st(anInspector)._setVariables_(variables);
- return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector,variables:variables},globals.Object)})},
- args: ["anInspector"],
- source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self.\x0a\x09self class allInstanceVariableNames do: [ :each |\x0a\x09\x09variables at: each put: (self instVarAt: each) ].\x0a\x09anInspector\x0a\x09\x09setLabel: self printString;\x0a\x09\x09setVariables: variables",
- messageSends: ["new", "at:put:", "do:", "allInstanceVariableNames", "class", "instVarAt:", "setLabel:", "printString", "setVariables:"],
- referencedClasses: ["Dictionary"]
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBehavior",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isBehavior\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBoolean",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isBoolean\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClass",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isClass\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCompiledMethod",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isCompiledMethod\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isImmutable\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isKindOf:",
- protocol: 'testing',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._isMemberOf_(aClass);
- if(smalltalk.assert($2)){
- $1=true;
- } else {
- $1=_st(self._class())._inheritsFrom_(aClass);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isKindOf:",{aClass:aClass},globals.Object)})},
- args: ["aClass"],
- source: "isKindOf: aClass\x0a\x09^ (self isMemberOf: aClass)\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: [ self class inheritsFrom: aClass ]",
- messageSends: ["ifTrue:ifFalse:", "isMemberOf:", "inheritsFrom:", "class"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMemberOf:",
- protocol: 'testing',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class()).__eq(aClass);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isMemberOf:",{aClass:aClass},globals.Object)})},
- args: ["aClass"],
- source: "isMemberOf: aClass\x0a\x09^ self class = aClass",
- messageSends: ["=", "class"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMetaclass",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isMetaclass\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNil",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isNil\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNumber",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isNumber\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isPackage",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isPackage\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isParseFailure",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isParseFailure\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isString",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isString\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSymbol",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSymbol\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "notNil",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._isNil())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"notNil",{},globals.Object)})},
- args: [],
- source: "notNil\x0a\x09^ self isNil not",
- messageSends: ["not", "isNil"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "postCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "postCopy",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "putOn:",
- protocol: 'streaming',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPut_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},globals.Object)})},
- args: ["aStream"],
- source: "putOn: aStream\x0a\x09aStream nextPut: self",
- messageSends: ["nextPut:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondsTo:",
- protocol: 'testing',
- fn: function (aSelector){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._canUnderstand_(aSelector);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"respondsTo:",{aSelector:aSelector},globals.Object)})},
- args: ["aSelector"],
- source: "respondsTo: aSelector\x0a\x09^ self class canUnderstand: aSelector",
- messageSends: ["canUnderstand:", "class"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var copy = self.klass._new();
- Object.keys(self).forEach(function(i) {
- if(/^@.+/.test(i)) {
- copy[i] = self[i];
- }
- });
- return copy;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"shallowCopy",{},globals.Object)})},
- args: [],
- source: "shallowCopy\x0a\x09<\x0a\x09\x09var copy = self.klass._new();\x0a\x09\x09Object.keys(self).forEach(function(i) {\x0a\x09\x09if(/^@.+/.test(i)) {\x0a\x09\x09\x09copy[i] = self[i];\x0a\x09\x09}\x0a\x09\x09});\x0a\x09\x09return copy;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldNotImplement",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("This method should not be implemented in ".__comma(_st(self._class())._name()));
- return self}, function($ctx1) {$ctx1.fill(self,"shouldNotImplement",{},globals.Object)})},
- args: [],
- source: "shouldNotImplement\x0a\x09self error: 'This method should not be implemented in ', self class name",
- messageSends: ["error:", ",", "name", "class"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("Object not indexable");
- return self}, function($ctx1) {$ctx1.fill(self,"size",{},globals.Object)})},
- args: [],
- source: "size\x0a\x09self error: 'Object not indexable'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclassResponsibility",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("This method is a responsibility of a subclass");
- return self}, function($ctx1) {$ctx1.fill(self,"subclassResponsibility",{},globals.Object)})},
- args: [],
- source: "subclassResponsibility\x0a\x09self error: 'This method is a responsibility of a subclass'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "throw:",
- protocol: 'error handling',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- throw anObject ;
- return self}, function($ctx1) {$ctx1.fill(self,"throw:",{anObject:anObject},globals.Object)})},
- args: ["anObject"],
- source: "throw: anObject\x0a\x09< throw anObject >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "try:catch:",
- protocol: 'error handling',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- try{return aBlock._value()} catch(e) {return anotherBlock._value_(e)};
- return self}, function($ctx1) {$ctx1.fill(self,"try:catch:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Object)})},
- args: ["aBlock", "anotherBlock"],
- source: "try: aBlock catch: anotherBlock\x0a\x09<try{return aBlock._value()} catch(e) {return anotherBlock._value_(e)}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.valueOf();
- return self}, function($ctx1) {$ctx1.fill(self,"value",{},globals.Object)})},
- args: [],
- source: "value\x0a\x09<return self.valueOf()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accessorProtocolWith:",
- protocol: 'helios',
- fn: function (aGenerator){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aGenerator)._accessorProtocolForObject();
- return self}, function($ctx1) {$ctx1.fill(self,"accessorProtocolWith:",{aGenerator:aGenerator},globals.Object.klass)})},
- args: ["aGenerator"],
- source: "accessorProtocolWith: aGenerator\x0a\x09aGenerator accessorProtocolForObject",
- messageSends: ["accessorProtocolForObject"],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accessorsSourceCodesWith:",
- protocol: 'helios',
- fn: function (aGenerator){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aGenerator)._accessorsForObject();
- return self}, function($ctx1) {$ctx1.fill(self,"accessorsSourceCodesWith:",{aGenerator:aGenerator},globals.Object.klass)})},
- args: ["aGenerator"],
- source: "accessorsSourceCodesWith: aGenerator\x0a\x09aGenerator accessorsForObject",
- messageSends: ["accessorsForObject"],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "class";
- },
- args: [],
- source: "heliosClass\x0a\x09\x22Should be an Helios extension. Unfortunately, since helios can browse remote\x0a\x09environments, we can't extend base classes\x22\x0a\x09\x0a\x09^ 'class'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "initialize\x0a\x09\x22no op\x22",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeProtocolWith:",
- protocol: 'helios',
- fn: function (aGenerator){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aGenerator)._initializeProtocolForObject();
- return self}, function($ctx1) {$ctx1.fill(self,"initializeProtocolWith:",{aGenerator:aGenerator},globals.Object.klass)})},
- args: ["aGenerator"],
- source: "initializeProtocolWith: aGenerator\x0a\x09aGenerator initializeProtocolForObject",
- messageSends: ["initializeProtocolForObject"],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeSourceCodesWith:",
- protocol: 'helios',
- fn: function (aGenerator){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aGenerator)._initializeForObject();
- return self}, function($ctx1) {$ctx1.fill(self,"initializeSourceCodesWith:",{aGenerator:aGenerator},globals.Object.klass)})},
- args: ["aGenerator"],
- source: "initializeSourceCodesWith: aGenerator\x0a\x09aGenerator initializeForObject",
- messageSends: ["initializeForObject"],
- referencedClasses: []
- }),
- globals.Object.klass);
- smalltalk.addClass('Boolean', globals.Object, [], 'Kernel-Objects');
- globals.Boolean.comment="I define the protocol for logic testing operations and conditional control structures for the logical values (see the `controlling` protocol).\x0a\x0aI have two instances, `true` and `false`.\x0a\x0aI am directly mapped to JavaScript Boolean. The `true` and `false` objects are the JavaScript boolean objects.\x0a\x0a## Usage Example:\x0a\x0a aBoolean not ifTrue: [ ... ] ifFalse: [ ... ]";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "&",
- protocol: 'controlling',
- fn: function (aBoolean){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self == true) {
- return aBoolean;
- } else {
- return false;
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"&",{aBoolean:aBoolean},globals.Boolean)})},
- args: ["aBoolean"],
- source: "& aBoolean\x0a\x09<\x0a\x09\x09if(self == true) {\x0a\x09\x09return aBoolean;\x0a\x09\x09} else {\x0a\x09\x09return false;\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (aBoolean){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return aBoolean != null &&
- typeof aBoolean._isBoolean === "function" &&
- aBoolean._isBoolean() &&
- Boolean(self == true) == aBoolean
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"=",{aBoolean:aBoolean},globals.Boolean)})},
- args: ["aBoolean"],
- source: "= aBoolean\x0a\x09<\x0a\x09\x09return aBoolean != null &&\x0a\x09\x09\x09typeof aBoolean._isBoolean === \x22function\x22 &&\x0a\x09\x09\x09aBoolean._isBoolean() &&\x0a\x09\x09\x09Boolean(self == true) == aBoolean\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "==",
- protocol: 'comparing',
- fn: function (aBoolean){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__eq(aBoolean);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"==",{aBoolean:aBoolean},globals.Boolean)})},
- args: ["aBoolean"],
- source: "== aBoolean\x0a\x09^ self = aBoolean",
- messageSends: ["="],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "and:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self.__eq(true);
- $1=_st($2)._ifTrue_ifFalse_(aBlock,(function(){
- return false;
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"and:",{aBlock:aBlock},globals.Boolean)})},
- args: ["aBlock"],
- source: "and: aBlock\x0a\x09^ self = true\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ false ]",
- messageSends: ["ifTrue:ifFalse:", "="],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asBit",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- if(smalltalk.assert(self)){
- $1=(1);
- } else {
- $1=(0);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asBit",{},globals.Boolean)})},
- args: [],
- source: "asBit\x0a\x09^ self ifTrue: [ 1 ] ifFalse: [ 0 ]",
- messageSends: ["ifTrue:ifFalse:"],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asJSON\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toString() ;
- return self}, function($ctx1) {$ctx1.fill(self,"asString",{},globals.Boolean)})},
- args: [],
- source: "asString\x0a\x09< return self.toString() >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "deepCopy\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifFalse:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._ifTrue_ifFalse_((function(){
- }),aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{aBlock:aBlock},globals.Boolean)})},
- args: ["aBlock"],
- source: "ifFalse: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self ifTrue: [] ifFalse: aBlock",
- messageSends: ["ifTrue:ifFalse:"],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifFalse:ifTrue:",
- protocol: 'controlling',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._ifTrue_ifFalse_(anotherBlock,aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Boolean)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifFalse: aBlock ifTrue: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self ifTrue: anotherBlock ifFalse: aBlock",
- messageSends: ["ifTrue:ifFalse:"],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifTrue:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._ifTrue_ifFalse_(aBlock,(function(){
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{aBlock:aBlock},globals.Boolean)})},
- args: ["aBlock"],
- source: "ifTrue: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self ifTrue: aBlock ifFalse: []",
- messageSends: ["ifTrue:ifFalse:"],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifTrue:ifFalse:",
- protocol: 'controlling',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self == true) {
- return aBlock._value();
- } else {
- return anotherBlock._value();
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Boolean)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifTrue: aBlock ifFalse: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<\x0a\x09\x09if(self == true) {\x0a\x09\x09return aBlock._value();\x0a\x09\x09} else {\x0a\x09\x09return anotherBlock._value();\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBoolean",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isBoolean\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "not",
- protocol: 'controlling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__eq(false);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"not",{},globals.Boolean)})},
- args: [],
- source: "not\x0a\x09^ self = false",
- messageSends: ["="],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "or:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self.__eq(true);
- $1=_st($2)._ifTrue_ifFalse_((function(){
- return true;
- }),aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"or:",{aBlock:aBlock},globals.Boolean)})},
- args: ["aBlock"],
- source: "or: aBlock\x0a\x09^ self = true\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: aBlock",
- messageSends: ["ifTrue:ifFalse:", "="],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_(self._asString());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Boolean)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: self asString",
- messageSends: ["nextPutAll:", "asString"],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "shallowCopy\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "|",
- protocol: 'controlling',
- fn: function (aBoolean){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self == true) {
- return true;
- } else {
- return aBoolean;
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"|",{aBoolean:aBoolean},globals.Boolean)})},
- args: ["aBoolean"],
- source: "| aBoolean\x0a\x09<\x0a\x09\x09if(self == true) {\x0a\x09\x09return true;\x0a\x09\x09} else {\x0a\x09\x09return aBoolean;\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Boolean);
- smalltalk.addClass('Date', globals.Object, [], 'Kernel-Objects');
- globals.Date.comment="I am used to work with both dates and times. Therefore `Date today` and `Date now` are both valid in\x0aAmber and answer the same date object.\x0a\x0aDate directly maps to the `Date()` JavaScript constructor, and Amber date objects are JavaScript date objects.\x0a\x0a## API\x0a\x0aThe class-side `instance creation` protocol contains some convenience methods for creating date/time objects such as `#fromSeconds:`.\x0a\x0aArithmetic and comparison is supported (see the `comparing` and `arithmetic` protocols).\x0a\x0aThe `converting` protocol provides convenience methods for various convertions (to numbers, strings, etc.).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "+",
- protocol: 'arithmetic',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self + aDate;
- return self}, function($ctx1) {$ctx1.fill(self,"+",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: "+ aDate\x0a\x09<return self + aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "-",
- protocol: 'arithmetic',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self - aDate;
- return self}, function($ctx1) {$ctx1.fill(self,"-",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: "- aDate\x0a\x09<return self - aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<",
- protocol: 'comparing',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self < aDate;
- return self}, function($ctx1) {$ctx1.fill(self,"<",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: "< aDate\x0a\x09<return self < aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<=",
- protocol: 'comparing',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self <= aDate;
- return self}, function($ctx1) {$ctx1.fill(self,"<=",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: "<= aDate\x0a\x09<return self <= aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">",
- protocol: 'comparing',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self > aDate;
- return self}, function($ctx1) {$ctx1.fill(self,">",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: "> aDate\x0a\x09<return self >> aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">=",
- protocol: 'comparing',
- fn: function (aDate){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self >= aDate;
- return self}, function($ctx1) {$ctx1.fill(self,">=",{aDate:aDate},globals.Date)})},
- args: ["aDate"],
- source: ">= aDate\x0a\x09<return self >>= aDate>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asDateString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toDateString();
- return self}, function($ctx1) {$ctx1.fill(self,"asDateString",{},globals.Date)})},
- args: [],
- source: "asDateString\x0a\x09<return self.toDateString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asLocaleString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toLocaleString();
- return self}, function($ctx1) {$ctx1.fill(self,"asLocaleString",{},globals.Date)})},
- args: [],
- source: "asLocaleString\x0a\x09<return self.toLocaleString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asMilliseconds",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._time();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asMilliseconds",{},globals.Date)})},
- args: [],
- source: "asMilliseconds\x0a\x09^ self time",
- messageSends: ["time"],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asNumber",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._asMilliseconds();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asNumber",{},globals.Date)})},
- args: [],
- source: "asNumber\x0a\x09^ self asMilliseconds",
- messageSends: ["asMilliseconds"],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toString();
- return self}, function($ctx1) {$ctx1.fill(self,"asString",{},globals.Date)})},
- args: [],
- source: "asString\x0a\x09<return self.toString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asTimeString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toTimeString();
- return self}, function($ctx1) {$ctx1.fill(self,"asTimeString",{},globals.Date)})},
- args: [],
- source: "asTimeString\x0a\x09<return self.toTimeString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "day",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._dayOfWeek();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"day",{},globals.Date)})},
- args: [],
- source: "day\x0a\x09^ self dayOfWeek",
- messageSends: ["dayOfWeek"],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "day:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._dayOfWeek_(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"day:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "day: aNumber\x0a\x09self dayOfWeek: aNumber",
- messageSends: ["dayOfWeek:"],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "dayOfMonth",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getDate();
- return self}, function($ctx1) {$ctx1.fill(self,"dayOfMonth",{},globals.Date)})},
- args: [],
- source: "dayOfMonth\x0a\x09<return self.getDate()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "dayOfMonth:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setDate(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"dayOfMonth:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "dayOfMonth: aNumber\x0a\x09<self.setDate(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "dayOfWeek",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getDay() + 1;
- return self}, function($ctx1) {$ctx1.fill(self,"dayOfWeek",{},globals.Date)})},
- args: [],
- source: "dayOfWeek\x0a\x09<return self.getDay() + 1>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "dayOfWeek:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.setDay(aNumber - 1);
- return self}, function($ctx1) {$ctx1.fill(self,"dayOfWeek:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "dayOfWeek: aNumber\x0a\x09<return self.setDay(aNumber - 1)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hours",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getHours();
- return self}, function($ctx1) {$ctx1.fill(self,"hours",{},globals.Date)})},
- args: [],
- source: "hours\x0a\x09<return self.getHours()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hours:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setHours(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"hours:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "hours: aNumber\x0a\x09<self.setHours(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "milliseconds",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getMilliseconds();
- return self}, function($ctx1) {$ctx1.fill(self,"milliseconds",{},globals.Date)})},
- args: [],
- source: "milliseconds\x0a\x09<return self.getMilliseconds()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "milliseconds:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setMilliseconds(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"milliseconds:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "milliseconds: aNumber\x0a\x09<self.setMilliseconds(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "minutes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getMinutes();
- return self}, function($ctx1) {$ctx1.fill(self,"minutes",{},globals.Date)})},
- args: [],
- source: "minutes\x0a\x09<return self.getMinutes()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "minutes:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setMinutes(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"minutes:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "minutes: aNumber\x0a\x09<self.setMinutes(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "month",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getMonth() + 1;
- return self}, function($ctx1) {$ctx1.fill(self,"month",{},globals.Date)})},
- args: [],
- source: "month\x0a\x09<return self.getMonth() + 1>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "month:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setMonth(aNumber - 1);
- return self}, function($ctx1) {$ctx1.fill(self,"month:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "month: aNumber\x0a\x09<self.setMonth(aNumber - 1)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_(self._asString());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Date)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: self asString",
- messageSends: ["nextPutAll:", "asString"],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "seconds",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getSeconds();
- return self}, function($ctx1) {$ctx1.fill(self,"seconds",{},globals.Date)})},
- args: [],
- source: "seconds\x0a\x09<return self.getSeconds()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "seconds:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setSeconds(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"seconds:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "seconds: aNumber\x0a\x09<self.setSeconds(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "time",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getTime();
- return self}, function($ctx1) {$ctx1.fill(self,"time",{},globals.Date)})},
- args: [],
- source: "time\x0a\x09<return self.getTime()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "time:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setTime(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"time:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "time: aNumber\x0a\x09<self.setTime(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "year",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.getFullYear();
- return self}, function($ctx1) {$ctx1.fill(self,"year",{},globals.Date)})},
- args: [],
- source: "year\x0a\x09<return self.getFullYear()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "year:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.setFullYear(aNumber);
- return self}, function($ctx1) {$ctx1.fill(self,"year:",{aNumber:aNumber},globals.Date)})},
- args: ["aNumber"],
- source: "year: aNumber\x0a\x09<self.setFullYear(aNumber)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromMilliseconds:",
- protocol: 'instance creation',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._new_(aNumber);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromMilliseconds:",{aNumber:aNumber},globals.Date.klass)})},
- args: ["aNumber"],
- source: "fromMilliseconds: aNumber\x0a\x09^ self new: aNumber",
- messageSends: ["new:"],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromSeconds:",
- protocol: 'instance creation',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._fromMilliseconds_(_st(aNumber).__star((1000)));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromSeconds:",{aNumber:aNumber},globals.Date.klass)})},
- args: ["aNumber"],
- source: "fromSeconds: aNumber\x0a\x09^ self fromMilliseconds: aNumber * 1000",
- messageSends: ["fromMilliseconds:", "*"],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromString:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._new_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},globals.Date.klass)})},
- args: ["aString"],
- source: "fromString: aString\x0a\x09\x22Example: Date fromString('2011/04/15 00:00:00')\x22\x0a\x09^ self new: aString",
- messageSends: ["new:"],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "magnitude";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'magnitude'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "millisecondsToRun:",
- protocol: 'instance creation',
- fn: function (aBlock){
- var self=this;
- var t;
- function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- t=_st($Date())._now();
- $ctx1.sendIdx["now"]=1;
- _st(aBlock)._value();
- $1=_st(_st($Date())._now()).__minus(t);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"millisecondsToRun:",{aBlock:aBlock,t:t},globals.Date.klass)})},
- args: ["aBlock"],
- source: "millisecondsToRun: aBlock\x0a\x09| t |\x0a\x09t := Date now.\x0a\x09aBlock value.\x0a\x09^ Date now - t",
- messageSends: ["now", "value", "-"],
- referencedClasses: ["Date"]
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new:",
- protocol: 'instance creation',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new Date(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"new:",{anObject:anObject},globals.Date.klass)})},
- args: ["anObject"],
- source: "new: anObject\x0a\x09<return new Date(anObject)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "now",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._today();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"now",{},globals.Date.klass)})},
- args: [],
- source: "now\x0a\x09^ self today",
- messageSends: ["today"],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "today",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"today",{},globals.Date.klass)})},
- args: [],
- source: "today\x0a\x09^ self new",
- messageSends: ["new"],
- referencedClasses: []
- }),
- globals.Date.klass);
- smalltalk.addClass('Number', globals.Object, [], 'Kernel-Objects');
- globals.Number.comment="I am the Amber representation for all numbers.\x0aI am directly mapped to JavaScript Number.\x0a\x0a## API\x0a\x0aI provide all necessary methods for arithmetic operations, comparison, conversion and so on with numbers.\x0a\x0aMy instances can also be used to evaluate a block a fixed number of times:\x0a\x0a\x095 timesRepeat: [ Transcript show: 'This will be printed 5 times'; cr ].\x0a\x09\x0a\x091 to: 5 do: [ :aNumber| Transcript show: aNumber asString; cr ].\x0a\x09\x0a\x091 to: 10 by: 2 do: [ :aNumber| Transcript show: aNumber asString; cr ].";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "&",
- protocol: 'converting',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self & aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"&",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "& aNumber\x0a\x09<return self & aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "*",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self * aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"*",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "* aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self * aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "**",
- protocol: 'mathematical functions',
- fn: function (exponent){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._raisedTo_(exponent);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"**",{exponent:exponent},globals.Number)})},
- args: ["exponent"],
- source: "** exponent\x0a\x09^ self raisedTo: exponent",
- messageSends: ["raisedTo:"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "+",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self + aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"+",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "+ aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self + aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "-",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self - aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"-",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "- aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self - aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "/",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self / aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"/",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "/ aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self / aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "//",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self.__slash(aNumber))._floor();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"//",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "// aNumber\x0a\x09^ (self / aNumber) floor",
- messageSends: ["floor", "/"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<",
- protocol: 'comparing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self < aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"<",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "< aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self < aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<=",
- protocol: 'comparing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self <= aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"<=",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "<= aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self <= aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return aNumber != null &&
- typeof aNumber._isNumber === "function" &&
- aNumber._isNumber() &&
- Number(self) == aNumber
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"=",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "= aNumber\x0a\x09<\x0a\x09\x09return aNumber != null &&\x0a\x09\x09\x09typeof aNumber._isNumber === \x22function\x22 &&\x0a\x09\x09\x09aNumber._isNumber() &&\x0a\x09\x09\x09Number(self) == aNumber\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">",
- protocol: 'comparing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self > aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,">",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "> aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self >> aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">=",
- protocol: 'comparing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self >= aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,">=",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: ">= aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self >>= aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "@",
- protocol: 'converting',
- fn: function (aNumber){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Point())._x_y_(self,aNumber);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"@",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "@ aNumber\x0a\x09^ Point x: self y: aNumber",
- messageSends: ["x:y:"],
- referencedClasses: ["Point"]
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "\x5c\x5c",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self % aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"\x5c\x5c",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "\x5c\x5c aNumber\x0a\x09<return self % aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "abs",
- protocol: 'arithmetic',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.abs(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"abs",{},globals.Number)})},
- args: [],
- source: "abs\x0a\x09<return Math.abs(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arcCos",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.acos(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"arcCos",{},globals.Number)})},
- args: [],
- source: "arcCos\x0a\x09<return Math.acos(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arcSin",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.asin(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"arcSin",{},globals.Number)})},
- args: [],
- source: "arcSin\x0a\x09<return Math.asin(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arcTan",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.atan(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"arcTan",{},globals.Number)})},
- args: [],
- source: "arcTan\x0a\x09<return Math.atan(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asJSON\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("(".__comma(self._printString())).__comma(")");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.Number)})},
- args: [],
- source: "asJavascript\x0a\x09^ '(', self printString, ')'",
- messageSends: [",", "printString"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asNumber",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asNumber\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asPoint",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Point())._x_y_(self,self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asPoint",{},globals.Number)})},
- args: [],
- source: "asPoint\x0a\x09^ Point x: self y: self",
- messageSends: ["x:y:"],
- referencedClasses: ["Point"]
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) ;
- return self}, function($ctx1) {$ctx1.fill(self,"asString",{},globals.Number)})},
- args: [],
- source: "asString\x0a\x09< return String(self) >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atRandom",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $Random(){return globals.Random||(typeof Random=="undefined"?nil:Random)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st(_st(_st($Random())._new())._next()).__star(self))._truncated()).__plus((1));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atRandom",{},globals.Number)})},
- args: [],
- source: "atRandom\x0a\x09^ (Random new next * self) truncated + 1",
- messageSends: ["+", "truncated", "*", "next", "new"],
- referencedClasses: ["Random"]
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ceiling",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.ceil(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"ceiling",{},globals.Number)})},
- args: [],
- source: "ceiling\x0a\x09<return Math.ceil(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "copy\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cos",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.cos(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"cos",{},globals.Number)})},
- args: [],
- source: "cos\x0a\x09<return Math.cos(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._copy();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"deepCopy",{},globals.Number)})},
- args: [],
- source: "deepCopy\x0a\x09^ self copy",
- messageSends: ["copy"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "even",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=(0).__eq(self.__backslash_backslash((2)));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"even",{},globals.Number)})},
- args: [],
- source: "even\x0a\x09^ 0 = (self \x5c\x5c 2)",
- messageSends: ["=", "\x5c\x5c"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "floor",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.floor(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"floor",{},globals.Number)})},
- args: [],
- source: "floor\x0a\x09<return Math.floor(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "identityHash",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asString()).__comma("n");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"identityHash",{},globals.Number)})},
- args: [],
- source: "identityHash\x0a\x09^ self asString, 'n'",
- messageSends: [",", "asString"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNumber",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isNumber\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isZero",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__eq((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isZero",{},globals.Number)})},
- args: [],
- source: "isZero\x0a\x09^ self = 0",
- messageSends: ["="],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ln",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.log(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"ln",{},globals.Number)})},
- args: [],
- source: "ln\x0a\x09<return Math.log(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "log",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.log(self) / Math.LN10;;
- return self}, function($ctx1) {$ctx1.fill(self,"log",{},globals.Number)})},
- args: [],
- source: "log\x0a\x09<return Math.log(self) / Math.LN10;>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "log:",
- protocol: 'mathematical functions',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.log(self) / Math.log(aNumber);;
- return self}, function($ctx1) {$ctx1.fill(self,"log:",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "log: aNumber\x0a\x09<return Math.log(self) / Math.log(aNumber);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "max:",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.max(self, aNumber);;
- return self}, function($ctx1) {$ctx1.fill(self,"max:",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "max: aNumber\x0a\x09<return Math.max(self, aNumber);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "min:",
- protocol: 'arithmetic',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.min(self, aNumber);;
- return self}, function($ctx1) {$ctx1.fill(self,"min:",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "min: aNumber\x0a\x09<return Math.min(self, aNumber);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "negated",
- protocol: 'arithmetic',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=(0).__minus(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"negated",{},globals.Number)})},
- args: [],
- source: "negated\x0a\x09^ 0 - self",
- messageSends: ["-"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "negative",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__lt((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"negative",{},globals.Number)})},
- args: [],
- source: "negative\x0a\x09\x22Answer whether the receiver is mathematically negative.\x22\x0a\x0a\x09^ self < 0",
- messageSends: ["<"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "odd",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._even())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"odd",{},globals.Number)})},
- args: [],
- source: "odd\x0a\x09^ self even not",
- messageSends: ["not", "even"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "positive",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__gt_eq((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"positive",{},globals.Number)})},
- args: [],
- source: "positive\x0a\x09\x22Answer whether the receiver is positive or equal to 0. (ST-80 protocol).\x22\x0a\x0a\x09^ self >= 0",
- messageSends: [">="],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_(self._asString());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Number)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: self asString",
- messageSends: ["nextPutAll:", "asString"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printShowingDecimalPlaces:",
- protocol: 'printing',
- fn: function (placesDesired){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toFixed(placesDesired);
- return self}, function($ctx1) {$ctx1.fill(self,"printShowingDecimalPlaces:",{placesDesired:placesDesired},globals.Number)})},
- args: ["placesDesired"],
- source: "printShowingDecimalPlaces: placesDesired\x0a\x09<return self.toFixed(placesDesired)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "raisedTo:",
- protocol: 'mathematical functions',
- fn: function (exponent){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.pow(self, exponent);;
- return self}, function($ctx1) {$ctx1.fill(self,"raisedTo:",{exponent:exponent},globals.Number)})},
- args: ["exponent"],
- source: "raisedTo: exponent\x0a\x09<return Math.pow(self, exponent);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "rounded",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.round(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"rounded",{},globals.Number)})},
- args: [],
- source: "rounded\x0a\x09<return Math.round(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sign",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self._isZero();
- if(smalltalk.assert($1)){
- return (0);
- };
- $2=self._positive();
- if(smalltalk.assert($2)){
- return (1);
- } else {
- return (-1);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"sign",{},globals.Number)})},
- args: [],
- source: "sign\x0a\x09self isZero \x0a\x09\x09ifTrue: [ ^ 0 ].\x0a\x09self positive\x0a\x09\x09ifTrue: [ ^ 1 ]\x0a\x09\x09ifFalse: [ ^ -1 ].",
- messageSends: ["ifTrue:", "isZero", "ifTrue:ifFalse:", "positive"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sin",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.sin(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"sin",{},globals.Number)})},
- args: [],
- source: "sin\x0a\x09<return Math.sin(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sqrt",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.sqrt(self);
- return self}, function($ctx1) {$ctx1.fill(self,"sqrt",{},globals.Number)})},
- args: [],
- source: "sqrt\x0a\x09<return Math.sqrt(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "squared",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__star(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"squared",{},globals.Number)})},
- args: [],
- source: "squared\x0a\x09^ self * self",
- messageSends: ["*"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "tan",
- protocol: 'mathematical functions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.tan(self);;
- return self}, function($ctx1) {$ctx1.fill(self,"tan",{},globals.Number)})},
- args: [],
- source: "tan\x0a\x09<return Math.tan(self);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "timesRepeat:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var count;
- return smalltalk.withContext(function($ctx1) {
- count=(1);
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(count).__gt(self);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(aBlock)._value();
- count=_st(count).__plus((1));
- return count;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"timesRepeat:",{aBlock:aBlock,count:count},globals.Number)})},
- args: ["aBlock"],
- source: "timesRepeat: aBlock\x0a\x09| count |\x0a\x09count := 1.\x0a\x09[ count > self ] whileFalse: [\x0a\x09\x09aBlock value.\x0a\x09\x09count := count + 1 ]",
- messageSends: ["whileFalse:", ">", "value", "+"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "to:",
- protocol: 'converting',
- fn: function (aNumber){
- var self=this;
- var array,first,last,count;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- first=self._truncated();
- $ctx1.sendIdx["truncated"]=1;
- last=_st(_st(aNumber)._truncated()).__plus((1));
- $ctx1.sendIdx["+"]=1;
- count=(1);
- array=_st($Array())._new();
- _st(_st(last).__minus(first))._timesRepeat_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(array)._at_put_(count,first);
- count=_st(count).__plus((1));
- $ctx2.sendIdx["+"]=2;
- count;
- first=_st(first).__plus((1));
- return first;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $1=array;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"to:",{aNumber:aNumber,array:array,first:first,last:last,count:count},globals.Number)})},
- args: ["aNumber"],
- source: "to: aNumber\x0a\x09| array first last count |\x0a\x09first := self truncated.\x0a\x09last := aNumber truncated + 1.\x0a\x09count := 1.\x0a\x09array := Array new.\x0a\x09(last - first) timesRepeat: [\x0a\x09\x09array at: count put: first.\x0a\x09\x09count := count + 1.\x0a\x09\x09first := first + 1 ].\x0a\x09^ array",
- messageSends: ["truncated", "+", "new", "timesRepeat:", "-", "at:put:"],
- referencedClasses: ["Array"]
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "to:by:",
- protocol: 'converting',
- fn: function (stop,step){
- var self=this;
- var array,value,pos;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- value=self;
- array=_st($Array())._new();
- pos=(1);
- $1=_st(step).__eq((0));
- if(smalltalk.assert($1)){
- self._error_("step must be non-zero");
- };
- $2=_st(step).__lt((0));
- if(smalltalk.assert($2)){
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(value).__gt_eq(stop);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(array)._at_put_(pos,value);
- $ctx2.sendIdx["at:put:"]=1;
- pos=_st(pos).__plus((1));
- $ctx2.sendIdx["+"]=1;
- pos;
- value=_st(value).__plus(step);
- $ctx2.sendIdx["+"]=2;
- return value;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
- $ctx1.sendIdx["whileTrue:"]=1;
- } else {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(value).__lt_eq(stop);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(array)._at_put_(pos,value);
- pos=_st(pos).__plus((1));
- $ctx2.sendIdx["+"]=3;
- pos;
- value=_st(value).__plus(step);
- return value;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})}));
- };
- $3=array;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"to:by:",{stop:stop,step:step,array:array,value:value,pos:pos},globals.Number)})},
- args: ["stop", "step"],
- source: "to: stop by: step\x0a\x09| array value pos |\x0a\x09value := self.\x0a\x09array := Array new.\x0a\x09pos := 1.\x0a\x09step = 0 ifTrue: [ self error: 'step must be non-zero' ].\x0a\x09step < 0\x0a\x09\x09ifTrue: [ [ value >= stop ] whileTrue: [\x0a\x09\x09\x09\x09\x09array at: pos put: value.\x0a\x09\x09\x09\x09\x09pos := pos + 1.\x0a\x09\x09\x09\x09\x09value := value + step ]]\x0a\x09\x09ifFalse: [ [ value <= stop ] whileTrue: [\x0a\x09\x09\x09\x09\x09array at: pos put: value.\x0a\x09\x09\x09\x09pos := pos + 1.\x0a\x09\x09\x09\x09\x09value := value + step ]].\x0a\x09^ array",
- messageSends: ["new", "ifTrue:", "=", "error:", "ifTrue:ifFalse:", "<", "whileTrue:", ">=", "at:put:", "+", "<="],
- referencedClasses: ["Array"]
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "to:by:do:",
- protocol: 'enumerating',
- fn: function (stop,step,aBlock){
- var self=this;
- var value;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- value=self;
- $1=_st(step).__eq((0));
- if(smalltalk.assert($1)){
- self._error_("step must be non-zero");
- };
- $2=_st(step).__lt((0));
- if(smalltalk.assert($2)){
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(value).__gt_eq(stop);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(aBlock)._value_(value);
- $ctx2.sendIdx["value:"]=1;
- value=_st(value).__plus(step);
- $ctx2.sendIdx["+"]=1;
- return value;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
- $ctx1.sendIdx["whileTrue:"]=1;
- } else {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(value).__lt_eq(stop);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(aBlock)._value_(value);
- value=_st(value).__plus(step);
- return value;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})}));
- };
- return self}, function($ctx1) {$ctx1.fill(self,"to:by:do:",{stop:stop,step:step,aBlock:aBlock,value:value},globals.Number)})},
- args: ["stop", "step", "aBlock"],
- source: "to: stop by: step do: aBlock\x0a\x09| value |\x0a\x09value := self.\x0a\x09step = 0 ifTrue: [ self error: 'step must be non-zero' ].\x0a\x09step < 0\x0a\x09\x09ifTrue: [ [ value >= stop ] whileTrue: [\x0a\x09\x09\x09\x09\x09aBlock value: value.\x0a\x09\x09\x09\x09\x09value := value + step ]]\x0a\x09\x09ifFalse: [ [ value <= stop ] whileTrue: [\x0a\x09\x09\x09\x09\x09aBlock value: value.\x0a\x09\x09\x09\x09\x09value := value + step ]]",
- messageSends: ["ifTrue:", "=", "error:", "ifTrue:ifFalse:", "<", "whileTrue:", ">=", "value:", "+", "<="],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "to:do:",
- protocol: 'enumerating',
- fn: function (stop,aBlock){
- var self=this;
- var nextValue;
- return smalltalk.withContext(function($ctx1) {
- nextValue=self;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(nextValue).__lt_eq(stop);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(aBlock)._value_(nextValue);
- nextValue=_st(nextValue).__plus((1));
- return nextValue;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"to:do:",{stop:stop,aBlock:aBlock,nextValue:nextValue},globals.Number)})},
- args: ["stop", "aBlock"],
- source: "to: stop do: aBlock\x0a\x09\x22Evaluate aBlock for each number from self to aNumber.\x22\x0a\x09| nextValue |\x0a\x09nextValue := self.\x0a\x09[ nextValue <= stop ]\x0a\x09\x09whileTrue:\x0a\x09\x09\x09[ aBlock value: nextValue.\x0a\x09\x09\x09nextValue := nextValue + 1 ]",
- messageSends: ["whileTrue:", "<=", "value:", "+"],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "truncated",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self >= 0) {
- return Math.floor(self);
- } else {
- return Math.floor(self * (-1)) * (-1);
- };
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"truncated",{},globals.Number)})},
- args: [],
- source: "truncated\x0a\x09<\x0a\x09\x09if(self >>= 0) {\x0a\x09\x09\x09return Math.floor(self);\x0a\x09\x09} else {\x0a\x09\x09\x09return Math.floor(self * (-1)) * (-1);\x0a\x09\x09};\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "|",
- protocol: 'converting',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self | aNumber;
- return self}, function($ctx1) {$ctx1.fill(self,"|",{aNumber:aNumber},globals.Number)})},
- args: ["aNumber"],
- source: "| aNumber\x0a\x09<return self | aNumber>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "e",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.E;;
- return self}, function($ctx1) {$ctx1.fill(self,"e",{},globals.Number.klass)})},
- args: [],
- source: "e\x0a\x09<return Math.E;>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "magnitude";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'magnitude'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pi",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.PI;
- return self}, function($ctx1) {$ctx1.fill(self,"pi",{},globals.Number.klass)})},
- args: [],
- source: "pi\x0a\x09<return Math.PI>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Number.klass);
- smalltalk.addClass('Point', globals.Object, ['x', 'y'], 'Kernel-Objects');
- globals.Point.comment="I represent an x-y pair of numbers usually designating a geometric coordinate.\x0a\x0a## API\x0a\x0aInstances are traditionally created using the binary `#@` message to a number:\x0a\x0a\x09100@120\x0a\x0aPoints can then be arithmetically manipulated:\x0a\x0a\x09100@100 + (10@10)\x0a\x0a...or for example:\x0a\x0a\x09(100@100) * 2\x0a\x0a**NOTE:** Creating a point with a negative y-value will need a space after `@` in order to avoid a parsing error:\x0a\x0a\x09100@ -100 \x22but 100@-100 would not parse\x22";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "*",
- protocol: 'arithmetic',
- fn: function (aPoint){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$5,$4,$2,$7,$6,$1;
- $3=self._x();
- $ctx1.sendIdx["x"]=1;
- $5=_st(aPoint)._asPoint();
- $ctx1.sendIdx["asPoint"]=1;
- $4=_st($5)._x();
- $2=_st($3).__star($4);
- $ctx1.sendIdx["*"]=1;
- $7=self._y();
- $ctx1.sendIdx["y"]=1;
- $6=_st($7).__star(_st(_st(aPoint)._asPoint())._y());
- $1=_st($Point())._x_y_($2,$6);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"*",{aPoint:aPoint},globals.Point)})},
- args: ["aPoint"],
- source: "* aPoint\x0a\x09^ Point x: self x * aPoint asPoint x y: self y * aPoint asPoint y",
- messageSends: ["x:y:", "*", "x", "asPoint", "y"],
- referencedClasses: ["Point"]
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "+",
- protocol: 'arithmetic',
- fn: function (aPoint){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$5,$4,$2,$7,$6,$1;
- $3=self._x();
- $ctx1.sendIdx["x"]=1;
- $5=_st(aPoint)._asPoint();
- $ctx1.sendIdx["asPoint"]=1;
- $4=_st($5)._x();
- $2=_st($3).__plus($4);
- $ctx1.sendIdx["+"]=1;
- $7=self._y();
- $ctx1.sendIdx["y"]=1;
- $6=_st($7).__plus(_st(_st(aPoint)._asPoint())._y());
- $1=_st($Point())._x_y_($2,$6);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"+",{aPoint:aPoint},globals.Point)})},
- args: ["aPoint"],
- source: "+ aPoint\x0a\x09^ Point x: self x + aPoint asPoint x y: self y + aPoint asPoint y",
- messageSends: ["x:y:", "+", "x", "asPoint", "y"],
- referencedClasses: ["Point"]
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "-",
- protocol: 'arithmetic',
- fn: function (aPoint){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$5,$4,$2,$7,$6,$1;
- $3=self._x();
- $ctx1.sendIdx["x"]=1;
- $5=_st(aPoint)._asPoint();
- $ctx1.sendIdx["asPoint"]=1;
- $4=_st($5)._x();
- $2=_st($3).__minus($4);
- $ctx1.sendIdx["-"]=1;
- $7=self._y();
- $ctx1.sendIdx["y"]=1;
- $6=_st($7).__minus(_st(_st(aPoint)._asPoint())._y());
- $1=_st($Point())._x_y_($2,$6);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"-",{aPoint:aPoint},globals.Point)})},
- args: ["aPoint"],
- source: "- aPoint\x0a\x09^ Point x: self x - aPoint asPoint x y: self y - aPoint asPoint y",
- messageSends: ["x:y:", "-", "x", "asPoint", "y"],
- referencedClasses: ["Point"]
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "/",
- protocol: 'arithmetic',
- fn: function (aPoint){
- var self=this;
- function $Point(){return globals.Point||(typeof Point=="undefined"?nil:Point)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$5,$4,$2,$7,$6,$1;
- $3=self._x();
- $ctx1.sendIdx["x"]=1;
- $5=_st(aPoint)._asPoint();
- $ctx1.sendIdx["asPoint"]=1;
- $4=_st($5)._x();
- $2=_st($3).__slash($4);
- $ctx1.sendIdx["/"]=1;
- $7=self._y();
- $ctx1.sendIdx["y"]=1;
- $6=_st($7).__slash(_st(_st(aPoint)._asPoint())._y());
- $1=_st($Point())._x_y_($2,$6);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"/",{aPoint:aPoint},globals.Point)})},
- args: ["aPoint"],
- source: "/ aPoint\x0a\x09^ Point x: self x / aPoint asPoint x y: self y / aPoint asPoint y",
- messageSends: ["x:y:", "/", "x", "asPoint", "y"],
- referencedClasses: ["Point"]
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'arithmetic',
- fn: function (aPoint){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$5,$4,$7,$6,$1;
- $3=_st(aPoint)._class();
- $ctx1.sendIdx["class"]=1;
- $2=_st($3).__eq(self._class());
- $ctx1.sendIdx["="]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $5=_st(aPoint)._x();
- $ctx2.sendIdx["x"]=1;
- $4=_st($5).__eq(self._x());
- $ctx2.sendIdx["="]=2;
- $7=_st(aPoint)._y();
- $ctx2.sendIdx["y"]=1;
- $6=_st($7).__eq(self._y());
- return _st($4).__and($6);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"=",{aPoint:aPoint},globals.Point)})},
- args: ["aPoint"],
- source: "= aPoint\x0a\x09^ aPoint class = self class and: [\x0a\x09\x09(aPoint x = self x) & (aPoint y = self y) ]",
- messageSends: ["and:", "=", "class", "&", "x", "y"],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asPoint",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asPoint\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(self["@x"])._printOn_(aStream);
- $ctx1.sendIdx["printOn:"]=1;
- _st(aStream)._nextPutAll_("@");
- $1=_st(_st(self["@y"])._notNil())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@y"])._negative();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($1)){
- _st(aStream)._space();
- };
- _st(self["@y"])._printOn_(aStream);
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Point)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09\x22Print receiver in classic x@y notation.\x22\x0a\x0a\x09x printOn: aStream.\x0a\x09\x0a\x09aStream nextPutAll: '@'.\x0a\x09(y notNil and: [ y negative ]) ifTrue: [\x0a\x09\x09\x09\x22Avoid ambiguous @- construct\x22\x0a\x09\x09\x09aStream space ].\x0a\x09\x0a\x09y printOn: aStream",
- messageSends: ["printOn:", "nextPutAll:", "ifTrue:", "and:", "notNil", "negative", "space"],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "translateBy:",
- protocol: 'transforming',
- fn: function (delta){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(_st(delta)._x()).__plus(self["@x"]);
- $ctx1.sendIdx["+"]=1;
- $1=_st($2).__at(_st(_st(delta)._y()).__plus(self["@y"]));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"translateBy:",{delta:delta},globals.Point)})},
- args: ["delta"],
- source: "translateBy: delta\x0a\x09\x22Answer a Point translated by delta (an instance of Point).\x22\x0a\x09^ (delta x + x) @ (delta y + y)",
- messageSends: ["@", "+", "x", "y"],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "x",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@x"];
- return $1;
- },
- args: [],
- source: "x\x0a\x09^ x",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "x:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- self["@x"]=aNumber;
- return self},
- args: ["aNumber"],
- source: "x: aNumber\x0a\x09x := aNumber",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "y",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@y"];
- return $1;
- },
- args: [],
- source: "y\x0a\x09^ y",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "y:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- self["@y"]=aNumber;
- return self},
- args: ["aNumber"],
- source: "y: aNumber\x0a\x09y := aNumber",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "magnitude";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'magnitude'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Point.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "x:y:",
- protocol: 'instance creation',
- fn: function (aNumber,anotherNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._x_(aNumber);
- _st($2)._y_(anotherNumber);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"x:y:",{aNumber:aNumber,anotherNumber:anotherNumber},globals.Point.klass)})},
- args: ["aNumber", "anotherNumber"],
- source: "x: aNumber y: anotherNumber\x0a\x09^ self new\x0a\x09\x09x: aNumber;\x0a\x09\x09y: anotherNumber;\x0a\x09\x09yourself",
- messageSends: ["x:", "new", "y:", "yourself"],
- referencedClasses: []
- }),
- globals.Point.klass);
- smalltalk.addClass('Random', globals.Object, [], 'Kernel-Objects');
- globals.Random.comment="I an used to generate a random number and I am implemented as a trivial wrapper around javascript `Math.random()`.\x0a\x0a## API\x0a\x0aThe typical use case it to use the `#next` method like the following:\x0a\x0a\x09Random new next\x0a\x0aThis will return a float x where x < 1 and x > 0. If you want a random integer from 1 to 10 you can use `#atRandom`\x0a\x0a\x0910 atRandom\x0a\x0aA random number in a specific interval can be obtained with the following:\x0a\x0a\x09(3 to: 7) atRandom\x0a\x0aBe aware that `#to:` does not create an Interval as in other Smalltalk implementations but in fact an `Array` of numbers, so it's better to use:\x0a\x0a\x095 atRandom + 2\x0a\x0aSince `#atRandom` is implemented in `SequencableCollection` you can easy pick an element at random:\x0a\x0a\x09#('a' 'b' 'c') atRandom\x0a\x0aAs well as letter from a `String`:\x0a\x0a\x09'abc' atRandom\x0a\x0aSince Amber does not have Characters this will return a `String` of length 1 like for example `'b'`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Math.random();
- return self}, function($ctx1) {$ctx1.fill(self,"next",{},globals.Random)})},
- args: [],
- source: "next\x0a\x09<return Math.random()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Random);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st((1)._to_(anInteger))._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._next();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"next:",{anInteger:anInteger},globals.Random)})},
- args: ["anInteger"],
- source: "next: anInteger\x0a\x09^ (1 to: anInteger) collect: [ :each | self next ]",
- messageSends: ["collect:", "to:", "next"],
- referencedClasses: []
- }),
- globals.Random);
- smalltalk.addClass('UndefinedObject', globals.Object, [], 'Kernel-Objects');
- globals.UndefinedObject.comment="I describe the behavior of my sole instance, `nil`. `nil` represents a prior value for variables that have not been initialized, or for results which are meaningless.\x0a\x0a`nil` is the Smalltalk equivalent of the `undefined` JavaScript object.\x0a\x0a__note:__ When sending messages to the `undefined` JavaScript object, it will be replaced by `nil`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- var $1;
- $1=null;
- return $1;
- },
- args: [],
- source: "asJSON\x0a\x09^ null",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "deepCopy\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._ifNil_ifNotNil_(aBlock,(function(){
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNil:",{aBlock:aBlock},globals.UndefinedObject)})},
- args: ["aBlock"],
- source: "ifNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self ifNil: aBlock ifNotNil: []",
- messageSends: ["ifNil:ifNotNil:"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:ifNotNil:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aBlock)._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.UndefinedObject)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifNil: aBlock ifNotNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ aBlock value",
- messageSends: ["value"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return self;
- },
- args: ["aBlock"],
- source: "ifNotNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:ifNil:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anotherBlock)._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.UndefinedObject)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifNotNil: aBlock ifNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^ anotherBlock value",
- messageSends: ["value"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNil",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isNil\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "notNil",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "notNil\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_("nil");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.UndefinedObject)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: 'nil'",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "shallowCopy\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:",
- protocol: 'class creation',
- fn: function (aString,anotherString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._subclass_instanceVariableNames_package_(aString,anotherString,nil);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:",{aString:aString,anotherString:anotherString},globals.UndefinedObject)})},
- args: ["aString", "anotherString"],
- source: "subclass: aString instanceVariableNames: anotherString\x0a\x09^ self subclass: aString instanceVariableNames: anotherString package: nil",
- messageSends: ["subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:category:",
- protocol: 'class creation',
- fn: function (aString,aString2,aString3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._subclass_instanceVariableNames_package_(aString,aString2,aString3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:category:",{aString:aString,aString2:aString2,aString3:aString3},globals.UndefinedObject)})},
- args: ["aString", "aString2", "aString3"],
- source: "subclass: aString instanceVariableNames: aString2 category: aString3\x0a\x09\x22Kept for compatibility.\x22\x0a\x09self deprecatedAPI.\x0a\x09^ self subclass: aString instanceVariableNames: aString2 package: aString3",
- messageSends: ["deprecatedAPI", "subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:package:",
- protocol: 'class creation',
- fn: function (aString,aString2,aString3){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($ClassBuilder())._new())._superclass_subclass_instanceVariableNames_package_(self,_st(aString)._asString(),aString2,aString3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:package:",{aString:aString,aString2:aString2,aString3:aString3},globals.UndefinedObject)})},
- args: ["aString", "aString2", "aString3"],
- source: "subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09^ ClassBuilder new\x0a\x09\x09superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3",
- messageSends: ["superclass:subclass:instanceVariableNames:package:", "new", "asString"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.UndefinedObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("You cannot create new instances of UndefinedObject. Use nil");
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.UndefinedObject.klass)})},
- args: [],
- source: "new\x0a\x09\x09self error: 'You cannot create new instances of UndefinedObject. Use nil'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.UndefinedObject.klass);
- });
- define("amber_core/Kernel-Classes", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Classes');
- smalltalk.packages["Kernel-Classes"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('Behavior', globals.Object, [], 'Kernel-Classes');
- globals.Behavior.comment="I am the superclass of all class objects.\x0a\x0aI define the protocol for creating instances of a class with `#basicNew` and `#new` (see `boot.js` for class constructors details).\x0a\x0aMy instances know about the subclass/superclass relationships between classes, contain the description that instances are created from,\x0aand hold the method dictionary that's associated with each class.\x0a\x0aI also provides methods for compiling methods, examining the method dictionary, and iterating over the class hierarchy.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">>",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._methodAt_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,">>",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: ">> aString\x0a\x09^ self methodAt: aString",
- messageSends: ["methodAt:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addCompiledMethod:",
- protocol: 'compiling',
- fn: function (aMethod){
- var self=this;
- var oldMethod,announcement;
- function $MethodAdded(){return globals.MethodAdded||(typeof MethodAdded=="undefined"?nil:MethodAdded)}
- function $MethodModified(){return globals.MethodModified||(typeof MethodModified=="undefined"?nil:MethodModified)}
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1,$4,$5,$6,$7,$8,$9,$10,$11;
- oldMethod=_st(self._methodDictionary())._at_ifAbsent_(_st(aMethod)._selector(),(function(){
- return nil;
- }));
- $2=self._protocols();
- $3=_st(aMethod)._protocol();
- $ctx1.sendIdx["protocol"]=1;
- $1=_st($2)._includes_($3);
- if(! smalltalk.assert($1)){
- $4=self._organization();
- $5=_st(aMethod)._protocol();
- $ctx1.sendIdx["protocol"]=2;
- _st($4)._addElement_($5);
- };
- self._basicAddCompiledMethod_(aMethod);
- $6=oldMethod;
- if(($receiver = $6) == nil || $receiver == null){
- $6;
- } else {
- self._removeProtocolIfEmpty_(_st(oldMethod)._protocol());
- };
- $7=oldMethod;
- if(($receiver = $7) == nil || $receiver == null){
- $8=_st($MethodAdded())._new();
- $ctx1.sendIdx["new"]=1;
- _st($8)._method_(aMethod);
- $ctx1.sendIdx["method:"]=1;
- $9=_st($8)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- announcement=$9;
- } else {
- $10=_st($MethodModified())._new();
- _st($10)._oldMethod_(oldMethod);
- _st($10)._method_(aMethod);
- $11=_st($10)._yourself();
- announcement=$11;
- };
- _st(_st($SystemAnnouncer())._current())._announce_(announcement);
- return self}, function($ctx1) {$ctx1.fill(self,"addCompiledMethod:",{aMethod:aMethod,oldMethod:oldMethod,announcement:announcement},globals.Behavior)})},
- args: ["aMethod"],
- source: "addCompiledMethod: aMethod\x0a\x09| oldMethod announcement |\x0a\x09\x0a\x09oldMethod := self methodDictionary\x0a\x09\x09at: aMethod selector\x0a\x09\x09ifAbsent: [ nil ].\x0a\x09\x0a\x09(self protocols includes: aMethod protocol)\x0a\x09\x09ifFalse: [ self organization addElement: aMethod protocol ].\x0a\x0a\x09self basicAddCompiledMethod: aMethod.\x0a\x09\x0a\x09oldMethod ifNotNil: [\x0a\x09\x09self removeProtocolIfEmpty: oldMethod protocol ].\x0a\x09\x0a\x09announcement := oldMethod\x0a\x09\x09ifNil: [\x0a\x09\x09\x09MethodAdded new\x0a\x09\x09\x09\x09\x09method: aMethod;\x0a\x09\x09\x09\x09\x09yourself ]\x0a\x09\x09ifNotNil: [\x0a\x09\x09\x09MethodModified new\x0a\x09\x09\x09\x09\x09oldMethod: oldMethod;\x0a\x09\x09\x09\x09\x09method: aMethod;\x0a\x09\x09\x09\x09\x09yourself ].\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09\x09\x09announce: announcement",
- messageSends: ["at:ifAbsent:", "methodDictionary", "selector", "ifFalse:", "includes:", "protocols", "protocol", "addElement:", "organization", "basicAddCompiledMethod:", "ifNotNil:", "removeProtocolIfEmpty:", "ifNil:ifNotNil:", "method:", "new", "yourself", "oldMethod:", "announce:", "current"],
- referencedClasses: ["MethodAdded", "MethodModified", "SystemAnnouncer"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allInstanceVariableNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var result;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- result=_st(self._instanceVariableNames())._copy();
- $1=self._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- _st(result)._addAll_(_st(self._superclass())._allInstanceVariableNames());
- };
- $2=result;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"allInstanceVariableNames",{result:result},globals.Behavior)})},
- args: [],
- source: "allInstanceVariableNames\x0a\x09| result |\x0a\x09result := self instanceVariableNames copy.\x0a\x09self superclass ifNotNil: [\x0a\x09\x09result addAll: self superclass allInstanceVariableNames ].\x0a\x09^ result",
- messageSends: ["copy", "instanceVariableNames", "ifNotNil:", "superclass", "addAll:", "allInstanceVariableNames"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSelectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$1;
- $2=self._allSuperclasses();
- $3=self._selectors();
- $ctx1.sendIdx["selectors"]=1;
- $1=_st($2)._inject_into_($3,(function(acc,each){
- return smalltalk.withContext(function($ctx2) {
- _st(acc)._addAll_(_st(each)._selectors());
- $4=_st(acc)._yourself();
- return $4;
- }, function($ctx2) {$ctx2.fillBlock({acc:acc,each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allSelectors",{},globals.Behavior)})},
- args: [],
- source: "allSelectors\x0a\x09^ self allSuperclasses\x0a\x09\x09inject: self selectors\x0a\x09\x09into: [ :acc :each | acc addAll: each selectors; yourself ]",
- messageSends: ["inject:into:", "allSuperclasses", "selectors", "addAll:", "yourself"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSubclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var subclasses,index;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- subclasses=self._subclasses();
- $ctx1.sendIdx["subclasses"]=1;
- index=(1);
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(index).__gt(_st(subclasses)._size());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(subclasses)._addAll_(_st(_st(subclasses)._at_(index))._subclasses());
- index=_st(index).__plus((1));
- return index;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $1=subclasses;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allSubclasses",{subclasses:subclasses,index:index},globals.Behavior)})},
- args: [],
- source: "allSubclasses\x0a\x09\x22Answer an collection of the receiver's and the receiver's descendent's subclasses. \x22\x0a\x0a\x09| subclasses index |\x0a\x09\x0a\x09subclasses := self subclasses.\x0a\x09index := 1.\x0a\x09[ index > subclasses size ]\x0a\x09\x09whileFalse: [ subclasses addAll: (subclasses at: index) subclasses.\x0a\x09\x09\x09index := index + 1 ].\x0a\x0a\x09^ subclasses",
- messageSends: ["subclasses", "whileFalse:", ">", "size", "addAll:", "at:", "+"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSubclassesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._allSubclasses())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"allSubclassesDo:",{aBlock:aBlock},globals.Behavior)})},
- args: ["aBlock"],
- source: "allSubclassesDo: aBlock\x0a\x09\x22Evaluate the argument, aBlock, for each of the receiver's subclasses.\x22\x0a\x0a\x09self allSubclasses do: [ :each |\x0a \x09aBlock value: each ]",
- messageSends: ["do:", "allSubclasses", "value:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSuperclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$5,$4,$6,$3;
- $1=self._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $2=[];
- return $2;
- } else {
- $1;
- };
- $5=self._superclass();
- $ctx1.sendIdx["superclass"]=2;
- $4=_st($OrderedCollection())._with_($5);
- _st($4)._addAll_(_st(self._superclass())._allSuperclasses());
- $6=_st($4)._yourself();
- $3=$6;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"allSuperclasses",{},globals.Behavior)})},
- args: [],
- source: "allSuperclasses\x0a\x09\x0a\x09self superclass ifNil: [ ^ #() ].\x0a\x09\x0a\x09^ (OrderedCollection with: self superclass)\x0a\x09\x09addAll: self superclass allSuperclasses;\x0a\x09\x09yourself",
- messageSends: ["ifNil:", "superclass", "addAll:", "with:", "allSuperclasses", "yourself"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicAddCompiledMethod:",
- protocol: 'private',
- fn: function (aMethod){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.addMethod(aMethod, self);
- return self}, function($ctx1) {$ctx1.fill(self,"basicAddCompiledMethod:",{aMethod:aMethod},globals.Behavior)})},
- args: ["aMethod"],
- source: "basicAddCompiledMethod: aMethod\x0a\x09<smalltalk.addMethod(aMethod, self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicNew",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new self.fn();
- return self}, function($ctx1) {$ctx1.fill(self,"basicNew",{},globals.Behavior)})},
- args: [],
- source: "basicNew\x0a\x09<return new self.fn()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicRemoveCompiledMethod:",
- protocol: 'private',
- fn: function (aMethod){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.removeMethod(aMethod,self);
- return self}, function($ctx1) {$ctx1.fill(self,"basicRemoveCompiledMethod:",{aMethod:aMethod},globals.Behavior)})},
- args: ["aMethod"],
- source: "basicRemoveCompiledMethod: aMethod\x0a\x09<smalltalk.removeMethod(aMethod,self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "canUnderstand:",
- protocol: 'testing',
- fn: function (aSelector){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $1=_st(self._includesSelector_(_st(aSelector)._asString()))._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- $3=self._superclass();
- $ctx2.sendIdx["superclass"]=1;
- $2=_st($3)._notNil();
- return _st($2)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(self._superclass())._canUnderstand_(aSelector);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"canUnderstand:",{aSelector:aSelector},globals.Behavior)})},
- args: ["aSelector"],
- source: "canUnderstand: aSelector\x0a\x09^ (self includesSelector: aSelector asString) or: [\x0a\x09\x09self superclass notNil and: [ self superclass canUnderstand: aSelector ]]",
- messageSends: ["or:", "includesSelector:", "asString", "and:", "notNil", "superclass", "canUnderstand:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "comment",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._basicAt_("comment");
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"comment",{},globals.Behavior)})},
- args: [],
- source: "comment\x0a\x09^ (self basicAt: 'comment') ifNil: [ '' ]",
- messageSends: ["ifNil:", "basicAt:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "comment:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassCommentChanged(){return globals.ClassCommentChanged||(typeof ClassCommentChanged=="undefined"?nil:ClassCommentChanged)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._basicAt_put_("comment",aString);
- $1=_st($ClassCommentChanged())._new();
- _st($1)._theClass_(self);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"comment:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "comment: aString\x0a\x09self basicAt: 'comment' put: aString.\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassCommentChanged new\x0a\x09\x09\x09theClass: self;\x0a\x09\x09\x09yourself)",
- messageSends: ["basicAt:put:", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassCommentChanged"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commentStamp",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $ClassCommentReader(){return globals.ClassCommentReader||(typeof ClassCommentReader=="undefined"?nil:ClassCommentReader)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($ClassCommentReader())._new();
- _st($2)._class_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"commentStamp",{},globals.Behavior)})},
- args: [],
- source: "commentStamp\x0a\x09^ ClassCommentReader new\x0a\x09class: self;\x0a\x09yourself",
- messageSends: ["class:", "new", "yourself"],
- referencedClasses: ["ClassCommentReader"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commentStamp:prior:",
- protocol: 'accessing',
- fn: function (aStamp,prior){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._commentStamp();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"commentStamp:prior:",{aStamp:aStamp,prior:prior},globals.Behavior)})},
- args: ["aStamp", "prior"],
- source: "commentStamp: aStamp prior: prior\x0a\x09\x09^ self commentStamp",
- messageSends: ["commentStamp"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compile:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._compile_protocol_(aString,"");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "compile: aString\x0a\x09^ self compile: aString protocol: ''",
- messageSends: ["compile:protocol:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compile:protocol:",
- protocol: 'compiling',
- fn: function (aString,anotherString){
- var self=this;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Compiler())._new())._install_forClass_protocol_(aString,self,anotherString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compile:protocol:",{aString:aString,anotherString:anotherString},globals.Behavior)})},
- args: ["aString", "anotherString"],
- source: "compile: aString protocol: anotherString\x0a\x09^ Compiler new\x0a\x09\x09install: aString\x0a\x09\x09forClass: self\x0a\x09\x09protocol: anotherString",
- messageSends: ["install:forClass:protocol:", "new"],
- referencedClasses: ["Compiler"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "definition",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "";
- },
- args: [],
- source: "definition\x0a\x09^ ''",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesBehavior:",
- protocol: 'testing',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self.__eq_eq(aClass))._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._inheritsFrom_(aClass);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includesBehavior:",{aClass:aClass},globals.Behavior)})},
- args: ["aClass"],
- source: "includesBehavior: aClass\x0a\x09^ self == aClass or: [\x0a\x09\x09\x09self inheritsFrom: aClass ]",
- messageSends: ["or:", "==", "inheritsFrom:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesSelector:",
- protocol: 'testing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methodDictionary())._includesKey_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includesSelector:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "includesSelector: aString\x0a\x09^ self methodDictionary includesKey: aString",
- messageSends: ["includesKey:", "methodDictionary"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inheritsFrom:",
- protocol: 'testing',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$4,$3,$2;
- $1=self._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- return false;
- } else {
- $1;
- };
- $4=self._superclass();
- $ctx1.sendIdx["superclass"]=2;
- $3=_st(aClass).__eq_eq($4);
- $2=_st($3)._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._superclass())._inheritsFrom_(aClass);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"inheritsFrom:",{aClass:aClass},globals.Behavior)})},
- args: ["aClass"],
- source: "inheritsFrom: aClass\x0a\x09self superclass ifNil: [ ^ false ].\x0a\x0a\x09^ aClass == self superclass or: [ \x0a\x09\x09self superclass inheritsFrom: aClass ]",
- messageSends: ["ifNil:", "superclass", "or:", "==", "inheritsFrom:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instanceVariableNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.iVarNames;
- return self}, function($ctx1) {$ctx1.fill(self,"instanceVariableNames",{},globals.Behavior)})},
- args: [],
- source: "instanceVariableNames\x0a\x09<return self.iVarNames>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBehavior",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isBehavior\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "javascriptConstructor",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.fn;
- return self}, function($ctx1) {$ctx1.fill(self,"javascriptConstructor",{},globals.Behavior)})},
- args: [],
- source: "javascriptConstructor\x0a\x09\x22Answer the JS constructor used to instantiate. See boot.js\x22\x0a\x09\x0a\x09<return self.fn>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "javascriptConstructor:",
- protocol: 'accessing',
- fn: function (aJavaScriptFunction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.setClassConstructor(self, aJavaScriptFunction);;
- return self}, function($ctx1) {$ctx1.fill(self,"javascriptConstructor:",{aJavaScriptFunction:aJavaScriptFunction},globals.Behavior)})},
- args: ["aJavaScriptFunction"],
- source: "javascriptConstructor: aJavaScriptFunction\x0a\x09\x22Set the JS constructor used to instantiate.\x0a\x09See the JS counter-part in boot.js `smalltalk.setClassConstructor'\x22\x0a\x09\x0a\x09<smalltalk.setClassConstructor(self, aJavaScriptFunction);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lookupSelector:",
- protocol: 'accessing',
- fn: function (selector){
- var self=this;
- var lookupClass;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- lookupClass=self;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(lookupClass).__eq(nil);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(lookupClass)._includesSelector_(selector);
- if(smalltalk.assert($1)){
- $2=_st(lookupClass)._methodAt_(selector);
- throw $early=[$2];
- };
- lookupClass=_st(lookupClass)._superclass();
- return lookupClass;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return nil;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"lookupSelector:",{selector:selector,lookupClass:lookupClass},globals.Behavior)})},
- args: ["selector"],
- source: "lookupSelector: selector\x0a\x09\x22Look up the given selector in my methodDictionary.\x0a\x09Return the corresponding method if found.\x0a\x09Otherwise chase the superclass chain and try again.\x0a\x09Return nil if no method is found.\x22\x0a\x09\x0a\x09| lookupClass |\x0a\x09\x0a\x09lookupClass := self.\x0a\x09[ lookupClass = nil ] whileFalse: [\x0a\x09\x09(lookupClass includesSelector: selector)\x0a\x09\x09\x09\x09ifTrue: [ ^ lookupClass methodAt: selector ].\x0a\x09\x09\x09lookupClass := lookupClass superclass ].\x0a\x09^ nil",
- messageSends: ["whileFalse:", "=", "ifTrue:", "includesSelector:", "methodAt:", "superclass"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodAt:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methodDictionary())._at_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodAt:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "methodAt: aString\x0a\x09^ self methodDictionary at: aString",
- messageSends: ["at:", "methodDictionary"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodDictionary",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var dict = globals.HashedCollection._new();
- var methods = self.methods;
- Object.keys(methods).forEach(function(i) {
- if(methods[i].selector) {
- dict._at_put_(methods[i].selector, methods[i]);
- }
- });
- return dict;
- return self}, function($ctx1) {$ctx1.fill(self,"methodDictionary",{},globals.Behavior)})},
- args: [],
- source: "methodDictionary\x0a\x09<var dict = globals.HashedCollection._new();\x0a\x09var methods = self.methods;\x0a\x09Object.keys(methods).forEach(function(i) {\x0a\x09\x09if(methods[i].selector) {\x0a\x09\x09\x09dict._at_put_(methods[i].selector, methods[i]);\x0a\x09\x09}\x0a\x09});\x0a\x09return dict>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodTemplate",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$4,$2,$7,$8,$6,$9,$5,$10,$1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- _st(stream)._nextPutAll_("messageSelectorAndArgumentNames");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $3=_st($String())._lf();
- $ctx2.sendIdx["lf"]=1;
- $4=_st($String())._tab();
- $ctx2.sendIdx["tab"]=1;
- $2=_st($3).__comma($4);
- $ctx2.sendIdx[","]=1;
- _st(stream)._nextPutAll_($2);
- $ctx2.sendIdx["nextPutAll:"]=2;
- _st(stream)._nextPutAll_("\x22comment stating purpose of message\x22");
- $ctx2.sendIdx["nextPutAll:"]=3;
- $7=_st($String())._lf();
- $ctx2.sendIdx["lf"]=2;
- $8=_st($String())._lf();
- $ctx2.sendIdx["lf"]=3;
- $6=_st($7).__comma($8);
- $ctx2.sendIdx[","]=3;
- $9=_st($String())._tab();
- $ctx2.sendIdx["tab"]=2;
- $5=_st($6).__comma($9);
- $ctx2.sendIdx[","]=2;
- _st(stream)._nextPutAll_($5);
- $ctx2.sendIdx["nextPutAll:"]=4;
- _st(stream)._nextPutAll_("| temporary variable names |");
- $ctx2.sendIdx["nextPutAll:"]=5;
- _st(stream)._nextPutAll_(_st(_st($String())._lf()).__comma(_st($String())._tab()));
- $ctx2.sendIdx["nextPutAll:"]=6;
- $10=_st(stream)._nextPutAll_("statements");
- return $10;
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodTemplate",{},globals.Behavior)})},
- args: [],
- source: "methodTemplate\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream \x0a\x09\x09\x09nextPutAll: 'messageSelectorAndArgumentNames';\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: '\x22comment stating purpose of message\x22';\x0a\x09\x09\x09nextPutAll: String lf, String lf, String tab;\x0a\x09\x09\x09nextPutAll: '| temporary variable names |';\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: 'statements' ]",
- messageSends: ["streamContents:", "nextPutAll:", ",", "lf", "tab"],
- referencedClasses: ["String"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methods",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methodDictionary())._values();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methods",{},globals.Behavior)})},
- args: [],
- source: "methods\x0a\x09^ self methodDictionary values",
- messageSends: ["values", "methodDictionary"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodsFor:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $ClassCategoryReader(){return globals.ClassCategoryReader||(typeof ClassCategoryReader=="undefined"?nil:ClassCategoryReader)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($ClassCategoryReader())._new();
- _st($2)._class_category_(self,aString);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodsFor:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "methodsFor: aString\x0a\x09^ ClassCategoryReader new\x0a\x09\x09class: self category: aString;\x0a\x09\x09yourself",
- messageSends: ["class:category:", "new", "yourself"],
- referencedClasses: ["ClassCategoryReader"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodsFor:stamp:",
- protocol: 'accessing',
- fn: function (aString,aStamp){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._methodsFor_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodsFor:stamp:",{aString:aString,aStamp:aStamp},globals.Behavior)})},
- args: ["aString", "aStamp"],
- source: "methodsFor: aString stamp: aStamp\x0a\x09\x22Added for compatibility, right now ignores stamp.\x22\x0a\x09^ self methodsFor: aString",
- messageSends: ["methodsFor:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodsInProtocol:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methods())._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._protocol()).__eq(aString);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodsInProtocol:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "methodsInProtocol: aString\x0a\x09^ self methods select: [ :each | each protocol = aString ]",
- messageSends: ["select:", "methods", "=", "protocol"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.className || nil;
- return self}, function($ctx1) {$ctx1.fill(self,"name",{},globals.Behavior)})},
- args: [],
- source: "name\x0a\x09<return self.className || nil>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._basicNew())._initialize();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"new",{},globals.Behavior)})},
- args: [],
- source: "new\x0a\x09^ self basicNew initialize",
- messageSends: ["initialize", "basicNew"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "organization",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("organization");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"organization",{},globals.Behavior)})},
- args: [],
- source: "organization\x0a\x09^ self basicAt: 'organization'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ownMethods",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st(_st(self._ownProtocols())._inject_into_(_st($OrderedCollection())._new(),(function(acc,each){
- return smalltalk.withContext(function($ctx2) {
- return _st(acc).__comma(self._methodsInProtocol_(each));
- }, function($ctx2) {$ctx2.fillBlock({acc:acc,each:each},$ctx1,1)})})))._sorted_((function(a,b){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(a)._selector();
- $ctx2.sendIdx["selector"]=1;
- return _st($2).__lt_eq(_st(b)._selector());
- }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,2)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ownMethods",{},globals.Behavior)})},
- args: [],
- source: "ownMethods\x0a\x09\x22Answer the methods of the receiver that are not package extensions\x22\x0a\x0a\x09^ (self ownProtocols \x0a\x09\x09inject: OrderedCollection new\x0a\x09\x09into: [ :acc :each | acc, (self methodsInProtocol: each) ])\x0a\x09\x09\x09sorted: [ :a :b | a selector <= b selector ]",
- messageSends: ["sorted:", "inject:into:", "ownProtocols", "new", ",", "methodsInProtocol:", "<=", "selector"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ownProtocols",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._protocols())._reject_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._match_("^\x5c*");
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ownProtocols",{},globals.Behavior)})},
- args: [],
- source: "ownProtocols\x0a\x09\x22Answer the protocols of the receiver that are not package extensions\x22\x0a\x0a\x09^ self protocols reject: [ :each |\x0a\x09\x09each match: '^\x5c*' ]",
- messageSends: ["reject:", "protocols", "match:"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocols",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._organization())._elements())._sorted();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"protocols",{},globals.Behavior)})},
- args: [],
- source: "protocols\x0a\x09^ self organization elements sorted",
- messageSends: ["sorted", "elements", "organization"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocolsDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var methodsByProtocol;
- function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- methodsByProtocol=_st($HashedCollection())._new();
- $ctx1.sendIdx["new"]=1;
- _st(self._methodDictionary())._valuesDo_((function(m){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(methodsByProtocol)._at_ifAbsentPut_(_st(m)._protocol(),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st($Array())._new();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})))._add_(m);
- }, function($ctx2) {$ctx2.fillBlock({m:m},$ctx1,1)})}));
- _st(self._protocols())._do_((function(protocol){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_value_(protocol,_st(methodsByProtocol)._at_(protocol));
- }, function($ctx2) {$ctx2.fillBlock({protocol:protocol},$ctx1,3)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"protocolsDo:",{aBlock:aBlock,methodsByProtocol:methodsByProtocol},globals.Behavior)})},
- args: ["aBlock"],
- source: "protocolsDo: aBlock\x0a\x09\x22Execute aBlock for each method protocol with\x0a\x09its collection of methods in the sort order of protocol name.\x22\x0a\x0a\x09| methodsByProtocol |\x0a\x09methodsByProtocol := HashedCollection new.\x0a\x09self methodDictionary valuesDo: [ :m |\x0a\x09\x09(methodsByProtocol at: m protocol ifAbsentPut: [ Array new ])\x0a\x09\x09\x09add: m ].\x0a\x09self protocols do: [ :protocol |\x0a\x09\x09aBlock value: protocol value: (methodsByProtocol at: protocol) ]",
- messageSends: ["new", "valuesDo:", "methodDictionary", "add:", "at:ifAbsentPut:", "protocol", "do:", "protocols", "value:value:", "at:"],
- referencedClasses: ["HashedCollection", "Array"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "prototype",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.fn.prototype;
- return self}, function($ctx1) {$ctx1.fill(self,"prototype",{},globals.Behavior)})},
- args: [],
- source: "prototype\x0a\x09<return self.fn.prototype>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "recompile",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Compiler())._new())._recompile_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"recompile",{},globals.Behavior)})},
- args: [],
- source: "recompile\x0a\x09^ Compiler new recompile: self",
- messageSends: ["recompile:", "new"],
- referencedClasses: ["Compiler"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeCompiledMethod:",
- protocol: 'compiling',
- fn: function (aMethod){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $MethodRemoved(){return globals.MethodRemoved||(typeof MethodRemoved=="undefined"?nil:MethodRemoved)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._basicRemoveCompiledMethod_(aMethod);
- self._removeProtocolIfEmpty_(_st(aMethod)._protocol());
- $1=_st($MethodRemoved())._new();
- _st($1)._method_(aMethod);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"removeCompiledMethod:",{aMethod:aMethod},globals.Behavior)})},
- args: ["aMethod"],
- source: "removeCompiledMethod: aMethod\x0a\x09self basicRemoveCompiledMethod: aMethod.\x0a\x09\x0a\x09self removeProtocolIfEmpty: aMethod protocol.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (MethodRemoved new\x0a\x09\x09\x09method: aMethod;\x0a\x09\x09\x09yourself)",
- messageSends: ["basicRemoveCompiledMethod:", "removeProtocolIfEmpty:", "protocol", "announce:", "current", "method:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "MethodRemoved"]
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeProtocolIfEmpty:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._methods())._detect_ifNone_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._protocol()).__eq(aString);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._organization())._removeElement_(aString);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"removeProtocolIfEmpty:",{aString:aString},globals.Behavior)})},
- args: ["aString"],
- source: "removeProtocolIfEmpty: aString\x0a\x09self methods\x0a\x09\x09detect: [ :each | each protocol = aString ]\x0a\x09\x09ifNone: [ self organization removeElement: aString ]",
- messageSends: ["detect:ifNone:", "methods", "=", "protocol", "removeElement:", "organization"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methodDictionary())._keys();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selectors",{},globals.Behavior)})},
- args: [],
- source: "selectors\x0a\x09^ self methodDictionary keys",
- messageSends: ["keys", "methodDictionary"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"subclasses",{},globals.Behavior)})},
- args: [],
- source: "subclasses\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superclass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.superclass || nil;
- return self}, function($ctx1) {$ctx1.fill(self,"superclass",{},globals.Behavior)})},
- args: [],
- source: "superclass\x0a\x09<return self.superclass || nil>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theMetaClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._class();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"theMetaClass",{},globals.Behavior)})},
- args: [],
- source: "theMetaClass\x0a\x09^ self class",
- messageSends: ["class"],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theNonMetaClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "theNonMetaClass\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Behavior);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withAllSubclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($Array())._with_(self);
- _st($2)._addAll_(self._allSubclasses());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"withAllSubclasses",{},globals.Behavior)})},
- args: [],
- source: "withAllSubclasses\x0a\x09^ (Array with: self) addAll: self allSubclasses; yourself",
- messageSends: ["addAll:", "with:", "allSubclasses", "yourself"],
- referencedClasses: ["Array"]
- }),
- globals.Behavior);
- smalltalk.addClass('Class', globals.Behavior, [], 'Kernel-Classes');
- globals.Class.comment="I am __the__ class object.\x0a\x0aMy instances are the classes of the system.\x0aClass creation is done throught a `ClassBuilder` instance.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1="globals.".__comma(self._name());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.Class)})},
- args: [],
- source: "asJavascript\x0a\x09^ 'globals.', self name",
- messageSends: [",", "name"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "category",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._package();
- $ctx1.sendIdx["package"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1="Unclassified";
- } else {
- $1=_st(self._package())._name();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"category",{},globals.Class)})},
- args: [],
- source: "category\x0a\x09^ self package ifNil: [ 'Unclassified' ] ifNotNil: [ self package name ]",
- messageSends: ["ifNil:ifNotNil:", "package", "name"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "definition",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$4,$2,$5,$6,$7,$1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- _st(stream)._nextPutAll_(_st(self._superclass())._asString());
- $ctx2.sendIdx["nextPutAll:"]=1;
- _st(stream)._nextPutAll_(" subclass: #");
- $ctx2.sendIdx["nextPutAll:"]=2;
- _st(stream)._nextPutAll_(self._name());
- $ctx2.sendIdx["nextPutAll:"]=3;
- $3=_st($String())._lf();
- $ctx2.sendIdx["lf"]=1;
- $4=_st($String())._tab();
- $ctx2.sendIdx["tab"]=1;
- $2=_st($3).__comma($4);
- $ctx2.sendIdx[","]=1;
- _st(stream)._nextPutAll_($2);
- $ctx2.sendIdx["nextPutAll:"]=4;
- $5=_st(stream)._nextPutAll_("instanceVariableNames: '");
- $ctx2.sendIdx["nextPutAll:"]=5;
- $5;
- _st(self._instanceVariableNames())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(each);
- $ctx3.sendIdx["nextPutAll:"]=6;
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(" ");
- $ctx3.sendIdx["nextPutAll:"]=7;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- $6=_st("'".__comma(_st($String())._lf())).__comma(_st($String())._tab());
- $ctx2.sendIdx[","]=2;
- _st(stream)._nextPutAll_($6);
- $ctx2.sendIdx["nextPutAll:"]=8;
- _st(stream)._nextPutAll_("package: '");
- $ctx2.sendIdx["nextPutAll:"]=9;
- _st(stream)._nextPutAll_(self._category());
- $ctx2.sendIdx["nextPutAll:"]=10;
- $7=_st(stream)._nextPutAll_("'");
- return $7;
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"definition",{},globals.Class)})},
- args: [],
- source: "definition\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream\x0a\x09\x09\x09nextPutAll: self superclass asString;\x0a\x09\x09\x09nextPutAll: ' subclass: #';\x0a\x09\x09\x09nextPutAll: self name;\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: 'instanceVariableNames: '''.\x0a\x09\x09self instanceVariableNames\x0a\x09\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ stream nextPutAll: ' ' ].\x0a\x09\x09stream\x0a\x09\x09\x09nextPutAll: '''', String lf, String tab;\x0a\x09\x09\x09nextPutAll: 'package: ''';\x0a\x09\x09\x09nextPutAll: self category;\x0a\x09\x09\x09nextPutAll: '''' ]",
- messageSends: ["streamContents:", "nextPutAll:", "asString", "superclass", "name", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category"],
- referencedClasses: ["String"]
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClass",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isClass\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("pkg");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"package",{},globals.Class)})},
- args: [],
- source: "package\x0a\x09^ self basicAt: 'pkg'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package:",
- protocol: 'accessing',
- fn: function (aPackage){
- var self=this;
- var oldPackage;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassMoved(){return globals.ClassMoved||(typeof ClassMoved=="undefined"?nil:ClassMoved)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4,$5;
- $2=self._package();
- $ctx1.sendIdx["package"]=1;
- $1=_st($2).__eq(aPackage);
- if(smalltalk.assert($1)){
- return self;
- };
- oldPackage=self._package();
- self._basicAt_put_("pkg",aPackage);
- $3=_st(oldPackage)._organization();
- $ctx1.sendIdx["organization"]=1;
- _st($3)._removeElement_(self);
- _st(_st(aPackage)._organization())._addElement_(self);
- $4=_st($ClassMoved())._new();
- _st($4)._theClass_(self);
- _st($4)._oldPackage_(oldPackage);
- $5=_st($4)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($5);
- return self}, function($ctx1) {$ctx1.fill(self,"package:",{aPackage:aPackage,oldPackage:oldPackage},globals.Class)})},
- args: ["aPackage"],
- source: "package: aPackage\x0a\x09| oldPackage |\x0a\x09\x0a\x09self package = aPackage ifTrue: [ ^ self ].\x0a\x09\x0a\x09oldPackage := self package.\x0a\x09\x0a\x09self basicAt: 'pkg' put: aPackage.\x0a\x09oldPackage organization removeElement: self.\x0a\x09aPackage organization addElement: self.\x0a\x0a\x09SystemAnnouncer current announce: (ClassMoved new\x0a\x09\x09theClass: self;\x0a\x09\x09oldPackage: oldPackage;\x0a\x09\x09yourself)",
- messageSends: ["ifTrue:", "=", "package", "basicAt:put:", "removeElement:", "organization", "addElement:", "announce:", "current", "theClass:", "new", "oldPackage:", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassMoved"]
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_(self._name());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Class)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: self name",
- messageSends: ["nextPutAll:", "name"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "rename:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($ClassBuilder())._new())._renameClass_to_(self,aString);
- return self}, function($ctx1) {$ctx1.fill(self,"rename:",{aString:aString},globals.Class)})},
- args: ["aString"],
- source: "rename: aString\x0a\x09ClassBuilder new renameClass: self to: aString",
- messageSends: ["renameClass:to:", "new"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:",
- protocol: 'class creation',
- fn: function (aString,anotherString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._subclass_instanceVariableNames_package_(aString,anotherString,nil);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:",{aString:aString,anotherString:anotherString},globals.Class)})},
- args: ["aString", "anotherString"],
- source: "subclass: aString instanceVariableNames: anotherString\x0a\x09\x22Kept for compatibility.\x22\x0a\x09^ self subclass: aString instanceVariableNames: anotherString package: nil",
- messageSends: ["subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:category:",
- protocol: 'class creation',
- fn: function (aString,aString2,aString3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._subclass_instanceVariableNames_package_(aString,aString2,aString3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:category:",{aString:aString,aString2:aString2,aString3:aString3},globals.Class)})},
- args: ["aString", "aString2", "aString3"],
- source: "subclass: aString instanceVariableNames: aString2 category: aString3\x0a\x09\x22Kept for compatibility.\x22\x0a\x09self deprecatedAPI.\x0a\x09^ self subclass: aString instanceVariableNames: aString2 package: aString3",
- messageSends: ["deprecatedAPI", "subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:",
- protocol: 'class creation',
- fn: function (aString,aString2,classVars,pools,aString3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._subclass_instanceVariableNames_package_(aString,aString2,aString3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:",{aString:aString,aString2:aString2,classVars:classVars,pools:pools,aString3:aString3},globals.Class)})},
- args: ["aString", "aString2", "classVars", "pools", "aString3"],
- source: "subclass: aString instanceVariableNames: aString2 classVariableNames: classVars poolDictionaries: pools category: aString3\x0a\x09\x22Just ignore class variables and pools. Added for compatibility.\x22\x0a\x09^ self subclass: aString instanceVariableNames: aString2 package: aString3",
- messageSends: ["subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:instanceVariableNames:package:",
- protocol: 'class creation',
- fn: function (aString,aString2,aString3){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($ClassBuilder())._new())._superclass_subclass_instanceVariableNames_package_(self,_st(aString)._asString(),aString2,aString3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:instanceVariableNames:package:",{aString:aString,aString2:aString2,aString3:aString3},globals.Class)})},
- args: ["aString", "aString2", "aString3"],
- source: "subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09^ ClassBuilder new\x0a\x09\x09superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3",
- messageSends: ["superclass:subclass:instanceVariableNames:package:", "new", "asString"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Class);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.subclasses._copy();
- return self}, function($ctx1) {$ctx1.fill(self,"subclasses",{},globals.Class)})},
- args: [],
- source: "subclasses\x0a\x09<return self.subclasses._copy()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Class);
- smalltalk.addClass('Metaclass', globals.Behavior, [], 'Kernel-Classes');
- globals.Metaclass.comment="I am the root of the class hierarchy.\x0a\x0aMy instances are metaclasses, one for each real class, and have a single instance, which they hold onto: the class that they are the metaclass of.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("globals.".__comma(_st(self._instanceClass())._name())).__comma(".klass");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.Metaclass)})},
- args: [],
- source: "asJavascript\x0a\x09^ 'globals.', self instanceClass name, '.klass'",
- messageSends: [",", "name", "instanceClass"],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "definition",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- _st(stream)._nextPutAll_(self._asString());
- $ctx2.sendIdx["nextPutAll:"]=1;
- $2=_st(stream)._nextPutAll_(" instanceVariableNames: '");
- $ctx2.sendIdx["nextPutAll:"]=2;
- $2;
- _st(self._instanceVariableNames())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(each);
- $ctx3.sendIdx["nextPutAll:"]=3;
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(" ");
- $ctx3.sendIdx["nextPutAll:"]=4;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- return _st(stream)._nextPutAll_("'");
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"definition",{},globals.Metaclass)})},
- args: [],
- source: "definition\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream\x0a\x09\x09\x09nextPutAll: self asString;\x0a\x09\x09\x09nextPutAll: ' instanceVariableNames: '''.\x0a\x09\x09self instanceVariableNames\x0a\x09\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ stream nextPutAll: ' ' ].\x0a\x09\x09stream nextPutAll: '''' ]",
- messageSends: ["streamContents:", "nextPutAll:", "asString", "do:separatedBy:", "instanceVariableNames"],
- referencedClasses: ["String"]
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instanceClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.instanceClass;
- return self}, function($ctx1) {$ctx1.fill(self,"instanceClass",{},globals.Metaclass)})},
- args: [],
- source: "instanceClass\x0a\x09<return self.instanceClass>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instanceVariableNames:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($ClassBuilder())._new())._class_instanceVariableNames_(self,aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"instanceVariableNames:",{aCollection:aCollection},globals.Metaclass)})},
- args: ["aCollection"],
- source: "instanceVariableNames: aCollection\x0a\x09ClassBuilder new\x0a\x09\x09class: self instanceVariableNames: aCollection",
- messageSends: ["class:instanceVariableNames:", "new"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMetaclass",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isMetaclass\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._instanceClass())._package();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"package",{},globals.Metaclass)})},
- args: [],
- source: "package\x0a\x09^ self instanceClass package",
- messageSends: ["package", "instanceClass"],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aStream)._nextPutAll_(_st(self._instanceClass())._name());
- $ctx1.sendIdx["nextPutAll:"]=1;
- $1=_st(aStream)._nextPutAll_(" class");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Metaclass)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: self instanceClass name;\x0a\x09\x09nextPutAll: ' class'",
- messageSends: ["nextPutAll:", "name", "instanceClass"],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st(self._instanceClass())._subclasses())._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._isMetaclass())._not();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._theMetaClass();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclasses",{},globals.Metaclass)})},
- args: [],
- source: "subclasses\x0a\x09^ (self instanceClass subclasses \x0a\x09\x09select: [ :each | each isMetaclass not ])\x0a\x09\x09collect: [ :each | each theMetaClass ]",
- messageSends: ["collect:", "select:", "subclasses", "instanceClass", "not", "isMetaclass", "theMetaClass"],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theMetaClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "theMetaClass\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theNonMetaClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._instanceClass();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"theNonMetaClass",{},globals.Metaclass)})},
- args: [],
- source: "theNonMetaClass\x0a\x09^ self instanceClass",
- messageSends: ["instanceClass"],
- referencedClasses: []
- }),
- globals.Metaclass);
- smalltalk.addClass('ClassBuilder', globals.Object, [], 'Kernel-Classes');
- globals.ClassBuilder.comment="I am responsible for compiling new classes or modifying existing classes in the system.\x0a\x0aRather than using me directly to compile a class, use `Class >> subclass:instanceVariableNames:package:`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addSubclassOf:named:instanceVariableNames:package:",
- protocol: 'class definition',
- fn: function (aClass,className,aCollection,packageName){
- var self=this;
- var theClass,thePackage;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- theClass=_st(_st($Smalltalk())._globals())._at_(className);
- thePackage=_st($Package())._named_(packageName);
- $1=theClass;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- _st(theClass)._package_(thePackage);
- $2=_st(_st(theClass)._superclass()).__eq_eq(aClass);
- if(! smalltalk.assert($2)){
- $3=self._migrateClassNamed_superclass_instanceVariableNames_package_(className,aClass,aCollection,packageName);
- return $3;
- };
- };
- $4=self._basicAddSubclassOf_named_instanceVariableNames_package_(aClass,className,aCollection,packageName);
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"addSubclassOf:named:instanceVariableNames:package:",{aClass:aClass,className:className,aCollection:aCollection,packageName:packageName,theClass:theClass,thePackage:thePackage},globals.ClassBuilder)})},
- args: ["aClass", "className", "aCollection", "packageName"],
- source: "addSubclassOf: aClass named: className instanceVariableNames: aCollection package: packageName\x0a\x09| theClass thePackage |\x0a\x09\x0a\x09theClass := Smalltalk globals at: className.\x0a\x09thePackage := Package named: packageName.\x0a\x09\x0a\x09theClass ifNotNil: [\x0a\x09\x09theClass package: thePackage.\x0a\x09\x09theClass superclass == aClass ifFalse: [\x0a\x09\x09\x09^ self\x0a\x09\x09\x09\x09migrateClassNamed: className\x0a\x09\x09\x09\x09superclass: aClass\x0a\x09\x09\x09\x09instanceVariableNames: aCollection\x0a\x09\x09\x09\x09package: packageName ] ].\x0a\x09\x09\x0a\x09^ self\x0a\x09\x09basicAddSubclassOf: aClass\x0a\x09\x09named: className\x0a\x09\x09instanceVariableNames: aCollection\x0a\x09\x09package: packageName",
- messageSends: ["at:", "globals", "named:", "ifNotNil:", "package:", "ifFalse:", "==", "superclass", "migrateClassNamed:superclass:instanceVariableNames:package:", "basicAddSubclassOf:named:instanceVariableNames:package:"],
- referencedClasses: ["Smalltalk", "Package"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicAddSubclassOf:named:instanceVariableNames:package:",
- protocol: 'private',
- fn: function (aClass,aString,aCollection,packageName){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.addClass(aString, aClass, aCollection, packageName);
- return globals[aString]
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"basicAddSubclassOf:named:instanceVariableNames:package:",{aClass:aClass,aString:aString,aCollection:aCollection,packageName:packageName},globals.ClassBuilder)})},
- args: ["aClass", "aString", "aCollection", "packageName"],
- source: "basicAddSubclassOf: aClass named: aString instanceVariableNames: aCollection package: packageName\x0a\x09<\x0a\x09\x09smalltalk.addClass(aString, aClass, aCollection, packageName);\x0a\x09\x09return globals[aString]\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicClass:instanceVariableNames:",
- protocol: 'private',
- fn: function (aClass,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicClass_instanceVariables_(aClass,self._instanceVariableNamesFor_(aString));
- return self}, function($ctx1) {$ctx1.fill(self,"basicClass:instanceVariableNames:",{aClass:aClass,aString:aString},globals.ClassBuilder)})},
- args: ["aClass", "aString"],
- source: "basicClass: aClass instanceVariableNames: aString\x0a\x09self basicClass: aClass instanceVariables: (self instanceVariableNamesFor: aString)",
- messageSends: ["basicClass:instanceVariables:", "instanceVariableNamesFor:"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicClass:instanceVariables:",
- protocol: 'private',
- fn: function (aClass,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aClass)._isMetaclass();
- if(! smalltalk.assert($1)){
- self._error_(_st(_st(aClass)._name()).__comma(" is not a metaclass"));
- };
- _st(aClass)._basicAt_put_("iVarNames",aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"basicClass:instanceVariables:",{aClass:aClass,aCollection:aCollection},globals.ClassBuilder)})},
- args: ["aClass", "aCollection"],
- source: "basicClass: aClass instanceVariables: aCollection\x0a\x0a\x09aClass isMetaclass ifFalse: [ self error: aClass name, ' is not a metaclass' ].\x0a\x09aClass basicAt: 'iVarNames' put: aCollection",
- messageSends: ["ifFalse:", "isMetaclass", "error:", ",", "name", "basicAt:put:"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicRemoveClass:",
- protocol: 'private',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.removeClass(aClass);
- return self}, function($ctx1) {$ctx1.fill(self,"basicRemoveClass:",{aClass:aClass},globals.ClassBuilder)})},
- args: ["aClass"],
- source: "basicRemoveClass: aClass\x0a\x09<smalltalk.removeClass(aClass)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicRenameClass:to:",
- protocol: 'private',
- fn: function (aClass,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals[aString] = aClass;
- delete globals[aClass.className];
- aClass.className = aString;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"basicRenameClass:to:",{aClass:aClass,aString:aString},globals.ClassBuilder)})},
- args: ["aClass", "aString"],
- source: "basicRenameClass: aClass to: aString\x0a\x09<\x0a\x09\x09globals[aString] = aClass;\x0a\x09\x09delete globals[aClass.className];\x0a\x09\x09aClass.className = aString;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicSwapClassNames:with:",
- protocol: 'private',
- fn: function (aClass,anotherClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var tmp = aClass.className;
- aClass.className = anotherClass.className;
- anotherClass.className = tmp;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"basicSwapClassNames:with:",{aClass:aClass,anotherClass:anotherClass},globals.ClassBuilder)})},
- args: ["aClass", "anotherClass"],
- source: "basicSwapClassNames: aClass with: anotherClass\x0a\x09<\x0a\x09\x09var tmp = aClass.className;\x0a\x09\x09aClass.className = anotherClass.className;\x0a\x09\x09anotherClass.className = tmp;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "class:instanceVariableNames:",
- protocol: 'class definition',
- fn: function (aClass,ivarNames){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassDefinitionChanged(){return globals.ClassDefinitionChanged||(typeof ClassDefinitionChanged=="undefined"?nil:ClassDefinitionChanged)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._basicClass_instanceVariableNames_(aClass,ivarNames);
- self._setupClass_(aClass);
- $1=_st($ClassDefinitionChanged())._new();
- _st($1)._theClass_(aClass);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"class:instanceVariableNames:",{aClass:aClass,ivarNames:ivarNames},globals.ClassBuilder)})},
- args: ["aClass", "ivarNames"],
- source: "class: aClass instanceVariableNames: ivarNames\x0a\x09self basicClass: aClass instanceVariableNames: ivarNames.\x0a\x09self setupClass: aClass.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassDefinitionChanged new\x0a\x09\x09\x09theClass: aClass;\x0a\x09\x09\x09yourself)",
- messageSends: ["basicClass:instanceVariableNames:", "setupClass:", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassDefinitionChanged"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyClass:named:",
- protocol: 'copying',
- fn: function (aClass,className){
- var self=this;
- var newClass;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassAdded(){return globals.ClassAdded||(typeof ClassAdded=="undefined"?nil:ClassAdded)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- newClass=self._addSubclassOf_named_instanceVariableNames_package_(_st(aClass)._superclass(),className,_st(aClass)._instanceVariableNames(),_st(_st(aClass)._package())._name());
- self._copyClass_to_(aClass,newClass);
- $1=_st($ClassAdded())._new();
- _st($1)._theClass_(newClass);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- $3=newClass;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"copyClass:named:",{aClass:aClass,className:className,newClass:newClass},globals.ClassBuilder)})},
- args: ["aClass", "className"],
- source: "copyClass: aClass named: className\x0a\x09| newClass |\x0a\x0a\x09newClass := self\x0a\x09\x09addSubclassOf: aClass superclass\x0a\x09\x09named: className\x0a\x09\x09instanceVariableNames: aClass instanceVariableNames\x0a\x09\x09package: aClass package name.\x0a\x0a\x09self copyClass: aClass to: newClass.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassAdded new\x0a\x09\x09\x09theClass: newClass;\x0a\x09\x09\x09yourself).\x0a\x09\x0a\x09^ newClass",
- messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "superclass", "instanceVariableNames", "name", "package", "copyClass:to:", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassAdded"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyClass:to:",
- protocol: 'copying',
- fn: function (aClass,anotherClass){
- var self=this;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$7,$6,$9,$8;
- _st(anotherClass)._comment_(_st(aClass)._comment());
- $1=_st(aClass)._methodDictionary();
- $ctx1.sendIdx["methodDictionary"]=1;
- _st($1)._valuesDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $2=_st($Compiler())._new();
- $ctx2.sendIdx["new"]=1;
- $3=_st(each)._source();
- $ctx2.sendIdx["source"]=1;
- $4=_st(each)._protocol();
- $ctx2.sendIdx["protocol"]=1;
- return _st($2)._install_forClass_protocol_($3,anotherClass,$4);
- $ctx2.sendIdx["install:forClass:protocol:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["valuesDo:"]=1;
- $5=_st(anotherClass)._class();
- $ctx1.sendIdx["class"]=1;
- $7=_st(aClass)._class();
- $ctx1.sendIdx["class"]=2;
- $6=_st($7)._instanceVariableNames();
- self._basicClass_instanceVariables_($5,$6);
- $9=_st(aClass)._class();
- $ctx1.sendIdx["class"]=3;
- $8=_st($9)._methodDictionary();
- _st($8)._valuesDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st($Compiler())._new())._install_forClass_protocol_(_st(each)._source(),_st(anotherClass)._class(),_st(each)._protocol());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- self._setupClass_(anotherClass);
- return self}, function($ctx1) {$ctx1.fill(self,"copyClass:to:",{aClass:aClass,anotherClass:anotherClass},globals.ClassBuilder)})},
- args: ["aClass", "anotherClass"],
- source: "copyClass: aClass to: anotherClass\x0a\x0a\x09anotherClass comment: aClass comment.\x0a\x0a\x09aClass methodDictionary valuesDo: [ :each |\x0a\x09\x09Compiler new install: each source forClass: anotherClass protocol: each protocol ].\x0a\x0a\x09self basicClass: anotherClass class instanceVariables: aClass class instanceVariableNames.\x0a\x0a\x09aClass class methodDictionary valuesDo: [ :each |\x0a\x09\x09Compiler new install: each source forClass: anotherClass class protocol: each protocol ].\x0a\x0a\x09self setupClass: anotherClass",
- messageSends: ["comment:", "comment", "valuesDo:", "methodDictionary", "install:forClass:protocol:", "new", "source", "protocol", "basicClass:instanceVariables:", "class", "instanceVariableNames", "setupClass:"],
- referencedClasses: ["Compiler"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "installMethod:forClass:protocol:",
- protocol: 'method definition',
- fn: function (aCompiledMethod,aBehavior,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aCompiledMethod)._protocol_(aString);
- _st(aBehavior)._addCompiledMethod_(aCompiledMethod);
- self._setupClass_(aBehavior);
- return aCompiledMethod;
- }, function($ctx1) {$ctx1.fill(self,"installMethod:forClass:protocol:",{aCompiledMethod:aCompiledMethod,aBehavior:aBehavior,aString:aString},globals.ClassBuilder)})},
- args: ["aCompiledMethod", "aBehavior", "aString"],
- source: "installMethod: aCompiledMethod forClass: aBehavior protocol: aString\x0a\x09aCompiledMethod protocol: aString.\x0a\x09aBehavior addCompiledMethod: aCompiledMethod.\x0a\x09self setupClass: aBehavior.\x0a\x09^ aCompiledMethod",
- messageSends: ["protocol:", "addCompiledMethod:", "setupClass:"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instanceVariableNamesFor:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(aString)._tokenize_(" "))._reject_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._isEmpty();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"instanceVariableNamesFor:",{aString:aString},globals.ClassBuilder)})},
- args: ["aString"],
- source: "instanceVariableNamesFor: aString\x0a\x09^ (aString tokenize: ' ') reject: [ :each | each isEmpty ]",
- messageSends: ["reject:", "tokenize:", "isEmpty"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "migrateClass:superclass:",
- protocol: 'class migration',
- fn: function (aClass,anotherClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(aClass)._name();
- $ctx1.sendIdx["name"]=1;
- $1=self._migrateClassNamed_superclass_instanceVariableNames_package_($2,anotherClass,_st(aClass)._instanceVariableNames(),_st(_st(aClass)._package())._name());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"migrateClass:superclass:",{aClass:aClass,anotherClass:anotherClass},globals.ClassBuilder)})},
- args: ["aClass", "anotherClass"],
- source: "migrateClass: aClass superclass: anotherClass\x0a\x09^ self\x0a\x09\x09migrateClassNamed: aClass name\x0a\x09\x09superclass: anotherClass\x0a\x09\x09instanceVariableNames: aClass instanceVariableNames\x0a\x09\x09package: aClass package name",
- messageSends: ["migrateClassNamed:superclass:instanceVariableNames:package:", "name", "instanceVariableNames", "package"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "migrateClassNamed:superclass:instanceVariableNames:package:",
- protocol: 'class migration',
- fn: function (className,aClass,aCollection,packageName){
- var self=this;
- var oldClass,newClass,tmp;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassMigrated(){return globals.ClassMigrated||(typeof ClassMigrated=="undefined"?nil:ClassMigrated)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$6,$7,$8;
- tmp="new*".__comma(className);
- $ctx1.sendIdx[","]=1;
- oldClass=_st(_st($Smalltalk())._globals())._at_(className);
- newClass=self._addSubclassOf_named_instanceVariableNames_package_(aClass,tmp,aCollection,packageName);
- self._basicSwapClassNames_with_(oldClass,newClass);
- $ctx1.sendIdx["basicSwapClassNames:with:"]=1;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._copyClass_to_(oldClass,newClass);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(exception){
- return smalltalk.withContext(function($ctx2) {
- self._basicSwapClassNames_with_(oldClass,newClass);
- $1=self._basicRemoveClass_(newClass);
- $ctx2.sendIdx["basicRemoveClass:"]=1;
- $1;
- return _st(exception)._signal();
- }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,2)})}));
- self._rawRenameClass_to_(oldClass,tmp);
- $ctx1.sendIdx["rawRenameClass:to:"]=1;
- $2=self._rawRenameClass_to_(newClass,className);
- $3=_st(oldClass)._subclasses();
- $4=(function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._migrateClass_superclass_(each,newClass);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})});
- $5=_st("Recompiling ".__comma(_st(newClass)._name())).__comma("...");
- $ctx1.sendIdx[","]=2;
- _st($3)._do_displayingProgress_($4,$5);
- self._basicRemoveClass_(oldClass);
- $6=_st($ClassMigrated())._new();
- _st($6)._theClass_(newClass);
- _st($6)._oldClass_(oldClass);
- $7=_st($6)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($7);
- $8=newClass;
- return $8;
- }, function($ctx1) {$ctx1.fill(self,"migrateClassNamed:superclass:instanceVariableNames:package:",{className:className,aClass:aClass,aCollection:aCollection,packageName:packageName,oldClass:oldClass,newClass:newClass,tmp:tmp},globals.ClassBuilder)})},
- args: ["className", "aClass", "aCollection", "packageName"],
- source: "migrateClassNamed: className superclass: aClass instanceVariableNames: aCollection package: packageName\x0a\x09| oldClass newClass tmp |\x0a\x09\x0a\x09tmp := 'new*', className.\x0a\x09oldClass := Smalltalk globals at: className.\x0a\x09\x0a\x09newClass := self\x0a\x09\x09addSubclassOf: aClass\x0a\x09\x09named: tmp\x0a\x09\x09instanceVariableNames: aCollection\x0a\x09\x09package: packageName.\x0a\x0a\x09self basicSwapClassNames: oldClass with: newClass.\x0a\x0a\x09[ self copyClass: oldClass to: newClass ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :exception |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09basicSwapClassNames: oldClass with: newClass;\x0a\x09\x09\x09\x09basicRemoveClass: newClass.\x0a\x09\x09\x09exception signal ].\x0a\x0a\x09self\x0a\x09\x09rawRenameClass: oldClass to: tmp;\x0a\x09\x09rawRenameClass: newClass to: className.\x0a\x0a\x09oldClass subclasses \x0a\x09\x09do: [ :each | self migrateClass: each superclass: newClass ]\x0a\x09\x09displayingProgress: 'Recompiling ', newClass name, '...'.\x0a\x0a\x09self basicRemoveClass: oldClass.\x0a\x09\x0a\x09SystemAnnouncer current announce: (ClassMigrated new\x0a\x09\x09theClass: newClass;\x0a\x09\x09oldClass: oldClass;\x0a\x09\x09yourself).\x0a\x09\x0a\x09^ newClass",
- messageSends: [",", "at:", "globals", "addSubclassOf:named:instanceVariableNames:package:", "basicSwapClassNames:with:", "on:do:", "copyClass:to:", "basicRemoveClass:", "signal", "rawRenameClass:to:", "do:displayingProgress:", "subclasses", "migrateClass:superclass:", "name", "announce:", "current", "theClass:", "new", "oldClass:", "yourself"],
- referencedClasses: ["Smalltalk", "Error", "SystemAnnouncer", "ClassMigrated"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "rawRenameClass:to:",
- protocol: 'private',
- fn: function (aClass,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals[aString] = aClass;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"rawRenameClass:to:",{aClass:aClass,aString:aString},globals.ClassBuilder)})},
- args: ["aClass", "aString"],
- source: "rawRenameClass: aClass to: aString\x0a\x09<\x0a\x09\x09globals[aString] = aClass;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "renameClass:to:",
- protocol: 'class migration',
- fn: function (aClass,className){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassRenamed(){return globals.ClassRenamed||(typeof ClassRenamed=="undefined"?nil:ClassRenamed)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._basicRenameClass_to_(aClass,className);
- _st(aClass)._recompile();
- $1=_st($ClassRenamed())._new();
- _st($1)._theClass_(aClass);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"renameClass:to:",{aClass:aClass,className:className},globals.ClassBuilder)})},
- args: ["aClass", "className"],
- source: "renameClass: aClass to: className\x0a\x09self basicRenameClass: aClass to: className.\x0a\x09\x0a\x09\x22Recompile the class to fix potential issues with super sends\x22\x0a\x09aClass recompile.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassRenamed new\x0a\x09\x09\x09theClass: aClass;\x0a\x09\x09\x09yourself)",
- messageSends: ["basicRenameClass:to:", "recompile", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassRenamed"]
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupClass:",
- protocol: 'public',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.init(aClass);;
- return self}, function($ctx1) {$ctx1.fill(self,"setupClass:",{aClass:aClass},globals.ClassBuilder)})},
- args: ["aClass"],
- source: "setupClass: aClass\x0a\x09<smalltalk.init(aClass);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superclass:subclass:",
- protocol: 'class definition',
- fn: function (aClass,className){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._superclass_subclass_instanceVariableNames_package_(aClass,className,"",nil);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"superclass:subclass:",{aClass:aClass,className:className},globals.ClassBuilder)})},
- args: ["aClass", "className"],
- source: "superclass: aClass subclass: className\x0a\x09^ self superclass: aClass subclass: className instanceVariableNames: '' package: nil",
- messageSends: ["superclass:subclass:instanceVariableNames:package:"],
- referencedClasses: []
- }),
- globals.ClassBuilder);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superclass:subclass:instanceVariableNames:package:",
- protocol: 'class definition',
- fn: function (aClass,className,ivarNames,packageName){
- var self=this;
- var newClass;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassAdded(){return globals.ClassAdded||(typeof ClassAdded=="undefined"?nil:ClassAdded)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5;
- $1=self._instanceVariableNamesFor_(ivarNames);
- if(($receiver = packageName) == nil || $receiver == null){
- $2="unclassified";
- } else {
- $2=packageName;
- };
- newClass=self._addSubclassOf_named_instanceVariableNames_package_(aClass,className,$1,$2);
- self._setupClass_(newClass);
- $3=_st($ClassAdded())._new();
- _st($3)._theClass_(newClass);
- $4=_st($3)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($4);
- $5=newClass;
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"superclass:subclass:instanceVariableNames:package:",{aClass:aClass,className:className,ivarNames:ivarNames,packageName:packageName,newClass:newClass},globals.ClassBuilder)})},
- args: ["aClass", "className", "ivarNames", "packageName"],
- source: "superclass: aClass subclass: className instanceVariableNames: ivarNames package: packageName\x0a\x09| newClass |\x0a\x09\x0a\x09newClass := self addSubclassOf: aClass\x0a\x09\x09named: className instanceVariableNames: (self instanceVariableNamesFor: ivarNames)\x0a\x09\x09package: (packageName ifNil: [ 'unclassified' ]).\x0a\x09self setupClass: newClass.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassAdded new\x0a\x09\x09\x09theClass: newClass;\x0a\x09\x09\x09yourself).\x0a\x09\x0a\x09^ newClass",
- messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "instanceVariableNamesFor:", "ifNil:", "setupClass:", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassAdded"]
- }),
- globals.ClassBuilder);
- smalltalk.addClass('ClassCategoryReader', globals.Object, ['class', 'category'], 'Kernel-Classes');
- globals.ClassCategoryReader.comment="I provide a mechanism for retrieving class descriptions stored on a file in the Smalltalk chunk format.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "class:category:",
- protocol: 'accessing',
- fn: function (aClass,aString){
- var self=this;
- self["@class"]=aClass;
- self["@category"]=aString;
- return self},
- args: ["aClass", "aString"],
- source: "class: aClass category: aString\x0a\x09class := aClass.\x0a\x09category := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassCategoryReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileMethod:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($Compiler())._new())._install_forClass_protocol_(aString,self["@class"],self["@category"]);
- return self}, function($ctx1) {$ctx1.fill(self,"compileMethod:",{aString:aString},globals.ClassCategoryReader)})},
- args: ["aString"],
- source: "compileMethod: aString\x0a\x09Compiler new install: aString forClass: class protocol: category",
- messageSends: ["install:forClass:protocol:", "new"],
- referencedClasses: ["Compiler"]
- }),
- globals.ClassCategoryReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.ClassCategoryReader.superclass.fn.prototype._initialize.apply(_st(self), []);
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ClassCategoryReader)})},
- args: [],
- source: "initialize\x0a\x09super initialize.",
- messageSends: ["initialize"],
- referencedClasses: []
- }),
- globals.ClassCategoryReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scanFrom:",
- protocol: 'fileIn',
- fn: function (aChunkParser){
- var self=this;
- var chunk;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- chunk=_st(aChunkParser)._nextChunk();
- chunk;
- return _st(chunk)._isEmpty();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._compileMethod_(chunk);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(_st($ClassBuilder())._new())._setupClass_(self["@class"]);
- return self}, function($ctx1) {$ctx1.fill(self,"scanFrom:",{aChunkParser:aChunkParser,chunk:chunk},globals.ClassCategoryReader)})},
- args: ["aChunkParser"],
- source: "scanFrom: aChunkParser\x0a\x09| chunk |\x0a\x09[ chunk := aChunkParser nextChunk.\x0a\x09chunk isEmpty ] whileFalse: [\x0a\x09\x09self compileMethod: chunk ].\x0a\x09ClassBuilder new setupClass: class",
- messageSends: ["whileFalse:", "nextChunk", "isEmpty", "compileMethod:", "setupClass:", "new"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.ClassCategoryReader);
- smalltalk.addClass('ClassCommentReader', globals.Object, ['class'], 'Kernel-Classes');
- globals.ClassCommentReader.comment="I provide a mechanism for retrieving class comments stored on a file.\x0a\x0aSee also `ClassCategoryReader`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "class:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@class"]=aClass;
- return self},
- args: ["aClass"],
- source: "class: aClass\x0a\x09class := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassCommentReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.ClassCommentReader.superclass.fn.prototype._initialize.apply(_st(self), []);
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ClassCommentReader)})},
- args: [],
- source: "initialize\x0a\x09super initialize.",
- messageSends: ["initialize"],
- referencedClasses: []
- }),
- globals.ClassCommentReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scanFrom:",
- protocol: 'fileIn',
- fn: function (aChunkParser){
- var self=this;
- var chunk;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- chunk=_st(aChunkParser)._nextChunk();
- $1=_st(chunk)._isEmpty();
- if(! smalltalk.assert($1)){
- self._setComment_(chunk);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"scanFrom:",{aChunkParser:aChunkParser,chunk:chunk},globals.ClassCommentReader)})},
- args: ["aChunkParser"],
- source: "scanFrom: aChunkParser\x0a\x09| chunk |\x0a\x09chunk := aChunkParser nextChunk.\x0a\x09chunk isEmpty ifFalse: [\x0a\x09\x09self setComment: chunk ].",
- messageSends: ["nextChunk", "ifFalse:", "isEmpty", "setComment:"],
- referencedClasses: []
- }),
- globals.ClassCommentReader);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setComment:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@class"])._comment_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"setComment:",{aString:aString},globals.ClassCommentReader)})},
- args: ["aString"],
- source: "setComment: aString\x0a\x09class comment: aString",
- messageSends: ["comment:"],
- referencedClasses: []
- }),
- globals.ClassCommentReader);
- smalltalk.addClass('ClassSorterNode', globals.Object, ['theClass', 'level', 'nodes'], 'Kernel-Classes');
- globals.ClassSorterNode.comment="I provide an algorithm for sorting classes alphabetically.\x0a\x0aSee [Issue #143](https://github.com/amber-smalltalk/amber/issues/143) on GitHub.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "getNodesFrom:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- var children,others;
- function $ClassSorterNode(){return globals.ClassSorterNode||(typeof ClassSorterNode=="undefined"?nil:ClassSorterNode)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- children=[];
- others=[];
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(_st(each)._superclass()).__eq(self._theClass());
- if(smalltalk.assert($1)){
- return _st(children)._add_(each);
- $ctx2.sendIdx["add:"]=1;
- } else {
- return _st(others)._add_(each);
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- self["@nodes"]=_st(children)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st($ClassSorterNode())._on_classes_level_(each,others,_st(self._level()).__plus((1)));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"getNodesFrom:",{aCollection:aCollection,children:children,others:others},globals.ClassSorterNode)})},
- args: ["aCollection"],
- source: "getNodesFrom: aCollection\x0a\x09| children others |\x0a\x09children := #().\x0a\x09others := #().\x0a\x09aCollection do: [ :each |\x0a\x09\x09(each superclass = self theClass)\x0a\x09\x09\x09ifTrue: [ children add: each ]\x0a\x09\x09\x09ifFalse: [ others add: each ]].\x0a\x09nodes:= children collect: [ :each |\x0a\x09\x09ClassSorterNode on: each classes: others level: self level + 1 ]",
- messageSends: ["do:", "ifTrue:ifFalse:", "=", "superclass", "theClass", "add:", "collect:", "on:classes:level:", "+", "level"],
- referencedClasses: ["ClassSorterNode"]
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "level",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@level"];
- return $1;
- },
- args: [],
- source: "level\x0a\x09^ level",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "level:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@level"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "level: anInteger\x0a\x09level := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nodes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@nodes"];
- return $1;
- },
- args: [],
- source: "nodes\x0a\x09^ nodes",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "traverseClassesWith:",
- protocol: 'visiting',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2;
- $1=self._theClass();
- $ctx1.sendIdx["theClass"]=1;
- _st(aCollection)._add_($1);
- _st(_st(self._nodes())._sorted_((function(a,b){
- return smalltalk.withContext(function($ctx2) {
- $3=_st(a)._theClass();
- $ctx2.sendIdx["theClass"]=2;
- $2=_st($3)._name();
- $ctx2.sendIdx["name"]=1;
- return _st($2).__lt_eq(_st(_st(b)._theClass())._name());
- }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})})))._do_((function(aNode){
- return smalltalk.withContext(function($ctx2) {
- return _st(aNode)._traverseClassesWith_(aCollection);
- }, function($ctx2) {$ctx2.fillBlock({aNode:aNode},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"traverseClassesWith:",{aCollection:aCollection},globals.ClassSorterNode)})},
- args: ["aCollection"],
- source: "traverseClassesWith: aCollection\x0a\x09\x22sort classes alphabetically Issue #143\x22\x0a\x0a\x09aCollection add: self theClass.\x0a\x09(self nodes sorted: [ :a :b | a theClass name <= b theClass name ]) do: [ :aNode |\x0a\x09\x09aNode traverseClassesWith: aCollection ].",
- messageSends: ["add:", "theClass", "do:", "sorted:", "nodes", "<=", "name", "traverseClassesWith:"],
- referencedClasses: []
- }),
- globals.ClassSorterNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:classes:level:",
- protocol: 'instance creation',
- fn: function (aClass,aCollection,anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._theClass_(aClass);
- _st($2)._level_(anInteger);
- _st($2)._getNodesFrom_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:classes:level:",{aClass:aClass,aCollection:aCollection,anInteger:anInteger},globals.ClassSorterNode.klass)})},
- args: ["aClass", "aCollection", "anInteger"],
- source: "on: aClass classes: aCollection level: anInteger\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09level: anInteger;\x0a\x09\x09getNodesFrom: aCollection;\x0a\x09\x09yourself",
- messageSends: ["theClass:", "new", "level:", "getNodesFrom:", "yourself"],
- referencedClasses: []
- }),
- globals.ClassSorterNode.klass);
- });
- define("amber_core/Kernel-Methods", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Methods');
- smalltalk.packages["Kernel-Methods"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('BlockClosure', globals.Object, [], 'Kernel-Methods');
- globals.BlockClosure.comment="I represent a lexical closure.\x0aI am is directly mapped to JavaScript Function.\x0a\x0a## API\x0a\x0a1. Evaluation\x0a\x0a My instances get evaluated with the `#value*` methods in the 'evaluating' protocol.\x0a\x0a Example: ` [ :x | x + 1 ] value: 3 \x22Answers 4\x22 `\x0a\x0a2. Control structures\x0a\x0a Blocks are used (together with `Boolean`) for control structures (methods in the `controlling` protocol).\x0a\x0a Example: `aBlock whileTrue: [ ... ]`\x0a\x0a3. Error handling\x0a\x0a I provide the `#on:do:` method for handling exceptions.\x0a\x0a Example: ` aBlock on: MessageNotUnderstood do: [ :ex | ... ] `";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "applyTo:arguments:",
- protocol: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.apply(anObject, aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.BlockClosure)})},
- args: ["anObject", "aCollection"],
- source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asCompiledMethod:",
- protocol: 'converting',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.method({selector:aString, fn:self});;
- return self}, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},globals.BlockClosure)})},
- args: ["aString"],
- source: "asCompiledMethod: aString\x0a\x09<return smalltalk.method({selector:aString, fn:self});>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compiledSource",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toString();
- return self}, function($ctx1) {$ctx1.fill(self,"compiledSource",{},globals.BlockClosure)})},
- args: [],
- source: "compiledSource\x0a\x09<return self.toString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currySelf",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return function () {
- var args = [ this ];
- args.push.apply(args, arguments);
- return self.apply(null, args);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},globals.BlockClosure)})},
- args: [],
- source: "currySelf\x0a\x09\x22Transforms [ :selfarg :x :y | stcode ] block\x0a\x09which represents JS function (selfarg, x, y, ...) {jscode}\x0a\x09into function (x, y, ...) {jscode} that takes selfarg from 'this'.\x0a\x09IOW, it is usable as JS method and first arg takes the receiver.\x22\x0a\x09\x0a\x09<\x0a\x09\x09return function () {\x0a\x09\x09\x09var args = [ this ];\x0a\x09\x09\x09args.push.apply(args, arguments);\x0a\x09\x09\x09return self.apply(null, args);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ensure:",
- protocol: 'evaluating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- try{return self._value()}finally{aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "ensure: aBlock\x0a\x09<try{return self._value()}finally{aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fork",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- function $ForkPool(){return globals.ForkPool||(typeof ForkPool=="undefined"?nil:ForkPool)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($ForkPool())._default())._fork_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"fork",{},globals.BlockClosure)})},
- args: [],
- source: "fork\x0a\x09ForkPool default fork: self",
- messageSends: ["fork:", "default"],
- referencedClasses: ["ForkPool"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new self();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.BlockClosure)})},
- args: [],
- source: "new\x0a\x09\x22Use the receiver as a JS constructor.\x0a\x09*Do not* use this method to instanciate Smalltalk objects!\x22\x0a\x09<return new self()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:",
- protocol: 'evaluating',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},globals.BlockClosure)})},
- args: ["anObject"],
- source: "newValue: anObject\x0a\x09^ self newWithValues: { anObject }",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:value:",
- protocol: 'evaluating',
- fn: function (anObject,anObject2){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject,anObject2]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},globals.BlockClosure)})},
- args: ["anObject", "anObject2"],
- source: "newValue: anObject value: anObject2\x0a\x09^ self newWithValues: { anObject. anObject2 }.",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newValue:value:value:",
- protocol: 'evaluating',
- fn: function (anObject,anObject2,anObject3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newWithValues_([anObject,anObject2,anObject3]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.BlockClosure)})},
- args: ["anObject", "anObject2", "anObject3"],
- source: "newValue: anObject value: anObject2 value: anObject3\x0a\x09^ self newWithValues: { anObject. anObject2. anObject3 }.",
- messageSends: ["newWithValues:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newWithValues:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var object = Object.create(self.prototype);
- var result = self.apply(object, aCollection);
- return typeof result === "object" ? result : object;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"newWithValues:",{aCollection:aCollection},globals.BlockClosure)})},
- args: ["aCollection"],
- source: "newWithValues: aCollection\x0a\x09\x22Simulates JS new operator by combination of Object.create and .apply\x22\x0a\x09<\x0a\x09\x09var object = Object.create(self.prototype);\x0a\x09\x09var result = self.apply(object, aCollection);\x0a\x09\x09return typeof result === \x22object\x22 ? result : object;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numArgs",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.length;
- return self}, function($ctx1) {$ctx1.fill(self,"numArgs",{},globals.BlockClosure)})},
- args: [],
- source: "numArgs\x0a\x09<return self.length>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:do:",
- protocol: 'error handling',
- fn: function (anErrorClass,aBlock){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=self._try_catch_(self,(function(error){
- var smalltalkError;
- return smalltalk.withContext(function($ctx2) {
- smalltalkError=_st($Smalltalk())._asSmalltalkException_(error);
- smalltalkError;
- $2=_st(smalltalkError)._isKindOf_(anErrorClass);
- if(smalltalk.assert($2)){
- return _st(aBlock)._value_(smalltalkError);
- } else {
- return _st(smalltalkError)._resignal();
- };
- }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},globals.BlockClosure)})},
- args: ["anErrorClass", "aBlock"],
- source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a\x09Convert all JS exceptions to JavaScriptException instances.\x22\x0a\x09\x0a\x09^ self try: self catch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError resignal ] ]",
- messageSends: ["try:catch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "resignal"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return nil;
- },
- args: [],
- source: "receiver\x0a\x09^ nil",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "timeToRun",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Date())._millisecondsToRun_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},globals.BlockClosure)})},
- args: [],
- source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
- messageSends: ["millisecondsToRun:"],
- referencedClasses: ["Date"]
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self();;
- return self}, function($ctx1) {$ctx1.fill(self,"value",{},globals.BlockClosure)})},
- args: [],
- source: "value\x0a\x09<return self();>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'evaluating',
- fn: function (anArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(anArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},globals.BlockClosure)})},
- args: ["anArg"],
- source: "value: anArg\x0a\x09<return self(anArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- protocol: 'evaluating',
- fn: function (firstArg,secondArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(firstArg, secondArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},globals.BlockClosure)})},
- args: ["firstArg", "secondArg"],
- source: "value: firstArg value: secondArg\x0a\x09<return self(firstArg, secondArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- protocol: 'evaluating',
- fn: function (firstArg,secondArg,thirdArg){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self(firstArg, secondArg, thirdArg);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},globals.BlockClosure)})},
- args: ["firstArg", "secondArg", "thirdArg"],
- source: "value: firstArg value: secondArg value: thirdArg\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithInterval:",
- protocol: 'timeout/interval',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var interval = setInterval(self, aNumber);
- return globals.Timeout._on_(interval);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},globals.BlockClosure)})},
- args: ["aNumber"],
- source: "valueWithInterval: aNumber\x0a\x09<\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(interval);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.apply(null, aCollection);;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.BlockClosure)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithTimeout:",
- protocol: 'timeout/interval',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var timeout = setTimeout(self, aNumber);
- return globals.Timeout._on_(timeout);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},globals.BlockClosure)})},
- args: ["aNumber"],
- source: "valueWithTimeout: aNumber\x0a\x09<\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(timeout);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileFalse",
- protocol: 'controlling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._whileFalse_((function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{},globals.BlockClosure)})},
- args: [],
- source: "whileFalse\x0a\x09self whileFalse: []",
- messageSends: ["whileFalse:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileFalse:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- while(!smalltalk.assert(self._value())) {aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "whileFalse: aBlock\x0a\x09<while(!smalltalk.assert(self._value())) {aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileTrue",
- protocol: 'controlling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._whileTrue_((function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{},globals.BlockClosure)})},
- args: [],
- source: "whileTrue\x0a\x09self whileTrue: []",
- messageSends: ["whileTrue:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "whileTrue:",
- protocol: 'controlling',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- while(smalltalk.assert(self._value())) {aBlock._value()};
- return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},globals.BlockClosure)})},
- args: ["aBlock"],
- source: "whileTrue: aBlock\x0a\x09<while(smalltalk.assert(self._value())) {aBlock._value()}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockClosure);
- smalltalk.addClass('CompiledMethod', globals.Object, [], 'Kernel-Methods');
- globals.CompiledMethod.comment="I represent a class method of the system. I hold the source and compiled code of a class method.\x0a\x0a## API\x0aMy instances can be accessed using `Behavior >> #methodAt:`\x0a\x0a Object methodAt: 'asString'\x0a\x0aSource code access:\x0a\x0a\x09(String methodAt: 'lines') source\x0a\x0aReferenced classes:\x0a\x0a\x09(String methodAt: 'lines') referencedClasses\x0a\x0aMessages sent from an instance:\x0a\x09\x0a\x09(String methodAt: 'lines') messageSends";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.args || [];
- return self}, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.CompiledMethod)})},
- args: [],
- source: "arguments\x0a\x09<return self.args || []>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "category",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._protocol();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"category",{},globals.CompiledMethod)})},
- args: [],
- source: "category\x0a\x09^ self protocol",
- messageSends: ["protocol"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultProtocol",
- protocol: 'defaults',
- fn: function (){
- var self=this;
- return "as yet unclassified";
- },
- args: [],
- source: "defaultProtocol\x0a\x09^ 'as yet unclassified'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fn",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("fn");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fn",{},globals.CompiledMethod)})},
- args: [],
- source: "fn\x0a\x09^ self basicAt: 'fn'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fn:",
- protocol: 'accessing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("fn",aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},globals.CompiledMethod)})},
- args: ["aBlock"],
- source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCompiledMethod",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isCompiledMethod\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isOverridden",
- protocol: 'testing',
- fn: function (){
- var self=this;
- var selector;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- selector=self._selector();
- _st(self._methodClass())._allSubclassesDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(each)._includesSelector_(selector);
- if(smalltalk.assert($1)){
- throw $early=[true];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return false;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},globals.CompiledMethod)})},
- args: [],
- source: "isOverridden\x0a\x09| selector |\x0a \x0a selector := self selector.\x0a self methodClass allSubclassesDo: [ :each |\x0a\x09 (each includesSelector: selector)\x0a \x09ifTrue: [ ^ true ] ].\x0a\x09^ false",
- messageSends: ["selector", "allSubclassesDo:", "methodClass", "ifTrue:", "includesSelector:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isOverride",
- protocol: 'testing',
- fn: function (){
- var self=this;
- var superclass;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=self._methodClass();
- $ctx1.sendIdx["methodClass"]=1;
- superclass=_st($1)._superclass();
- $ctx1.sendIdx["superclass"]=1;
- $2=superclass;
- if(($receiver = $2) == nil || $receiver == null){
- return false;
- } else {
- $2;
- };
- $3=_st(_st(_st(self._methodClass())._superclass())._lookupSelector_(self._selector()))._notNil();
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},globals.CompiledMethod)})},
- args: [],
- source: "isOverride\x0a\x09| superclass |\x0a \x0a superclass := self methodClass superclass.\x0a\x09superclass ifNil: [ ^ false ].\x0a\x09\x0a ^ (self methodClass superclass lookupSelector: self selector) notNil",
- messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("messageSends");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.CompiledMethod)})},
- args: [],
- source: "messageSends\x0a\x09^ self basicAt: 'messageSends'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("methodClass");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodClass",{},globals.CompiledMethod)})},
- args: [],
- source: "methodClass\x0a\x09^ self basicAt: 'methodClass'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5;
- $2=self._protocol();
- $ctx1.sendIdx["protocol"]=1;
- $1=_st($2)._beginsWith_("*");
- if(! smalltalk.assert($1)){
- $4=self._methodClass();
- $ctx1.sendIdx["methodClass"]=1;
- $3=_st($4)._package();
- $ctx1.sendIdx["package"]=1;
- return $3;
- };
- $5=_st($Package())._named_ifAbsent_(_st(self._protocol())._allButFirst(),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._methodClass())._package();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"package",{},globals.CompiledMethod)})},
- args: [],
- source: "package\x0a\x09\x22Answer the package the receiver belongs to:\x0a\x09- if it is an extension method, answer the corresponding package\x0a\x09- else answer the `methodClass` package\x22\x0a\x09\x0a\x09(self protocol beginsWith: '*') ifFalse: [\x0a\x09\x09^ self methodClass package ].\x0a\x09\x09\x0a\x09^ Package \x0a\x09\x09named: self protocol allButFirst\x0a\x09\x09ifAbsent: [ self methodClass package ]",
- messageSends: ["ifFalse:", "beginsWith:", "protocol", "package", "methodClass", "named:ifAbsent:", "allButFirst"],
- referencedClasses: ["Package"]
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._basicAt_("protocol");
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._defaultProtocol();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"protocol",{},globals.CompiledMethod)})},
- args: [],
- source: "protocol\x0a\x09^ (self basicAt: 'protocol') ifNil: [ self defaultProtocol ]",
- messageSends: ["ifNil:", "basicAt:", "defaultProtocol"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- var oldProtocol;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $MethodMoved(){return globals.MethodMoved||(typeof MethodMoved=="undefined"?nil:MethodMoved)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- oldProtocol=self._protocol();
- self._basicAt_put_("protocol",aString);
- $1=_st($MethodMoved())._new();
- _st($1)._method_(self);
- _st($1)._oldProtocol_(oldProtocol);
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- $3=self._methodClass();
- if(($receiver = $3) == nil || $receiver == null){
- $3;
- } else {
- var methodClass;
- methodClass=$receiver;
- _st(_st(methodClass)._organization())._addElement_(aString);
- _st(methodClass)._removeProtocolIfEmpty_(oldProtocol);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString,oldProtocol:oldProtocol},globals.CompiledMethod)})},
- args: ["aString"],
- source: "protocol: aString\x0a\x09| oldProtocol |\x0a\x09oldProtocol := self protocol.\x0a\x09self basicAt: 'protocol' put: aString.\x0a\x0a\x09SystemAnnouncer current announce: (MethodMoved new\x0a\x09\x09method: self;\x0a\x09\x09oldProtocol: oldProtocol;\x0a\x09\x09yourself).\x0a\x0a\x09self methodClass ifNotNil: [ :methodClass |\x0a\x09\x09methodClass organization addElement: aString.\x0a\x09\x09methodClass removeProtocolIfEmpty: oldProtocol ]",
- messageSends: ["protocol", "basicAt:put:", "announce:", "current", "method:", "new", "oldProtocol:", "yourself", "ifNotNil:", "methodClass", "addElement:", "organization", "removeProtocolIfEmpty:"],
- referencedClasses: ["SystemAnnouncer", "MethodMoved"]
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "referencedClasses",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("referencedClasses");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},globals.CompiledMethod)})},
- args: [],
- source: "referencedClasses\x0a\x09^ self basicAt: 'referencedClasses'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("selector");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.CompiledMethod)})},
- args: [],
- source: "selector\x0a\x09^ self basicAt: 'selector'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("selector",aString);
- return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.CompiledMethod)})},
- args: ["aString"],
- source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendTo:arguments:",
- protocol: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._fn())._applyTo_arguments_(anObject,aCollection);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.CompiledMethod)})},
- args: ["anObject", "aCollection"],
- source: "sendTo: anObject arguments: aCollection\x0a\x09^ self fn applyTo: anObject arguments: aCollection",
- messageSends: ["applyTo:arguments:", "fn"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._basicAt_("source");
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"source",{},globals.CompiledMethod)})},
- args: [],
- source: "source\x0a\x09^ (self basicAt: 'source') ifNil: [ '' ]",
- messageSends: ["ifNil:", "basicAt:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._basicAt_put_("source",aString);
- return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},globals.CompiledMethod)})},
- args: ["aString"],
- source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.CompiledMethod);
- smalltalk.addClass('ForkPool', globals.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
- globals.ForkPool.comment="I am responsible for handling forked blocks.\x0aThe pool size sets the maximum concurrent forked blocks.\x0a\x0a## API\x0a\x0aThe default instance is accessed with `#default`.\x0aThe maximum concurrent forked blocks can be set with `#maxPoolSize:`.\x0a\x0aForking is done via `BlockClosure >> #fork`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addWorker",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@worker"])._valueWithTimeout_((0));
- self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
- return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{},globals.ForkPool)})},
- args: [],
- source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1",
- messageSends: ["valueWithTimeout:", "+"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultMaxPoolSize",
- protocol: 'defaults',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._defaultMaxPoolSize();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},globals.ForkPool)})},
- args: [],
- source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
- messageSends: ["defaultMaxPoolSize", "class"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fork:",
- protocol: 'actions',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@poolSize"]).__lt(self._maxPoolSize());
- if(smalltalk.assert($1)){
- self._addWorker();
- };
- _st(self["@queue"])._nextPut_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},globals.ForkPool)})},
- args: ["aBlock"],
- source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock",
- messageSends: ["ifTrue:", "<", "maxPoolSize", "addWorker", "nextPut:"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Queue(){return globals.Queue||(typeof Queue=="undefined"?nil:Queue)}
- return smalltalk.withContext(function($ctx1) {
- globals.ForkPool.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@poolSize"]=(0);
- self["@queue"]=_st($Queue())._new();
- self["@worker"]=self._makeWorker();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ForkPool)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker",
- messageSends: ["initialize", "new", "makeWorker"],
- referencedClasses: ["Queue"]
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "makeWorker",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- var sentinel;
- function $Object(){return globals.Object||(typeof Object=="undefined"?nil:Object)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- sentinel=_st($Object())._new();
- $1=(function(){
- var block;
- return smalltalk.withContext(function($ctx2) {
- self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
- self["@poolSize"];
- block=_st(self["@queue"])._nextIfAbsent_((function(){
- return sentinel;
- }));
- block;
- $2=_st(block).__eq_eq(sentinel);
- if(! smalltalk.assert($2)){
- return _st((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(block)._value();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)})}))._ensure_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._addWorker();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
- };
- }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1,1)})});
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},globals.ForkPool)})},
- args: [],
- source: "makeWorker\x0a\x09| sentinel |\x0a\x09sentinel := Object new.\x0a\x09^ [ | block |\x0a\x09\x09poolSize := poolSize - 1.\x0a\x09\x09block := queue nextIfAbsent: [ sentinel ].\x0a\x09\x09block == sentinel ifFalse: [\x0a\x09\x09\x09[ block value ] ensure: [ self addWorker ] ]]",
- messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "==", "ensure:", "value", "addWorker"],
- referencedClasses: ["Object"]
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "maxPoolSize",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@maxPoolSize"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._defaultMaxPoolSize();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},globals.ForkPool)})},
- args: [],
- source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
- messageSends: ["ifNil:", "defaultMaxPoolSize"],
- referencedClasses: []
- }),
- globals.ForkPool);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "maxPoolSize:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@maxPoolSize"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool);
- globals.ForkPool.klass.iVarNames = ['default'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "default",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@default"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@default"]=self._new();
- $1=self["@default"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"default",{},globals.ForkPool.klass)})},
- args: [],
- source: "default\x0a\x09^ default ifNil: [ default := self new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultMaxPoolSize",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return (100);
- },
- args: [],
- source: "defaultMaxPoolSize\x0a\x09^ 100",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "resetDefault",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- self["@default"]=nil;
- return self},
- args: [],
- source: "resetDefault\x0a\x09default := nil",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ForkPool.klass);
- smalltalk.addClass('Message', globals.Object, ['selector', 'arguments'], 'Kernel-Methods');
- globals.Message.comment="In general, the system does not use instances of me for efficiency reasons.\x0aHowever, when a message is not understood by its receiver, the interpreter will make up an instance of it in order to capture the information involved in an actual message transmission.\x0aThis instance is sent it as an argument with the message `#doesNotUnderstand:` to the receiver.\x0a\x0aSee boot.js, `messageNotUnderstood` and its counterpart `Object >> #doesNotUnderstand:`\x0a\x0a## API\x0a\x0aBesides accessing methods, `#sendTo:` provides a convenient way to send a message to an object.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@arguments"];
- return $1;
- },
- args: [],
- source: "arguments\x0a\x09^ arguments",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (anArray){
- var self=this;
- self["@arguments"]=anArray;
- return self},
- args: ["anArray"],
- source: "arguments: anArray\x0a\x09arguments := anArray",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.Message.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._selector());
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Message)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "selector"],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendTo:",
- protocol: 'actions',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anObject)._perform_withArguments_(self._selector(),self._arguments());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject},globals.Message)})},
- args: ["anObject"],
- source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
- messageSends: ["perform:withArguments:", "selector", "arguments"],
- referencedClasses: []
- }),
- globals.Message);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:arguments:",
- protocol: 'instance creation',
- fn: function (aString,anArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._selector_(aString);
- _st($2)._arguments_(anArray);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray},globals.Message.klass)})},
- args: ["aString", "anArray"],
- source: "selector: aString arguments: anArray\x0a\x09^ self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
- messageSends: ["selector:", "new", "arguments:", "yourself"],
- referencedClasses: []
- }),
- globals.Message.klass);
- smalltalk.addClass('MessageSend', globals.Object, ['receiver', 'message'], 'Kernel-Methods');
- globals.MessageSend.comment="I encapsulate message sends to objects. Arguments can be either predefined or supplied when the message send is performed. \x0a\x0a## API\x0a\x0aUse `#value` to perform a message send with its predefined arguments and `#value:*` if additonal arguments have to supplied.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._arguments();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MessageSend)})},
- args: [],
- source: "arguments\x0a\x09^ message arguments",
- messageSends: ["arguments"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@message"])._arguments_(aCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.MessageSend)})},
- args: ["aCollection"],
- source: "arguments: aCollection\x0a\x09message arguments: aCollection",
- messageSends: ["arguments:"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Message(){return globals.Message||(typeof Message=="undefined"?nil:Message)}
- return smalltalk.withContext(function($ctx1) {
- globals.MessageSend.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@message"]=_st($Message())._new();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.MessageSend)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09message := Message new",
- messageSends: ["initialize", "new"],
- referencedClasses: ["Message"]
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.MessageSend.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._receiver());
- $ctx1.sendIdx["nextPutAll:"]=2;
- _st(aStream)._nextPutAll_(" >> ");
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st(aStream)._nextPutAll_(self._selector());
- $ctx1.sendIdx["nextPutAll:"]=4;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MessageSend)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self receiver;\x0a\x09\x09nextPutAll: ' >> ';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@receiver"];
- return $1;
- },
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@receiver"]=anObject;
- return self},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09receiver := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._selector();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MessageSend)})},
- args: [],
- source: "selector\x0a\x09^ message selector",
- messageSends: ["selector"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@message"])._selector_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.MessageSend)})},
- args: ["aString"],
- source: "selector: aString\x0a\x09message selector: aString",
- messageSends: ["selector:"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@message"])._sendTo_(self._receiver());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value",{},globals.MessageSend)})},
- args: [],
- source: "value\x0a\x09^ message sendTo: self receiver",
- messageSends: ["sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'evaluating',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([anObject]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},globals.MessageSend)})},
- args: ["anObject"],
- source: "value: anObject\x0a\x09^ message \x0a\x09\x09arguments: { anObject };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([firstArgument,secondArgument]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},globals.MessageSend)})},
- args: ["firstArgument", "secondArgument"],
- source: "value: firstArgument value: secondArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument,thirdArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@message"];
- _st($2)._arguments_([firstArgument,secondArgument,thirdArgument]);
- $3=_st($2)._sendTo_(self._receiver());
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},globals.MessageSend)})},
- args: ["firstArgument", "secondArgument", "thirdArgument"],
- source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument. thirdArgument };\x0a\x09\x09sendTo: self receiver",
- messageSends: ["arguments:", "sendTo:", "receiver"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._arguments_(aCollection);
- $1=self._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.MessageSend)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09self arguments: aCollection.\x0a\x09^ self value",
- messageSends: ["arguments:", "value"],
- referencedClasses: []
- }),
- globals.MessageSend);
- smalltalk.addClass('MethodContext', globals.Object, [], 'Kernel-Methods');
- globals.MethodContext.comment="I hold all the dynamic state associated with the execution of either a method activation resulting from a message send. I am used to build the call stack while debugging.\x0a\x0aMy instances are JavaScript `SmalltalkMethodContext` objects defined in `boot.js`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._isBlockContext();
- if(smalltalk.assert($2)){
- $3="a block (in ".__comma(_st(self._methodContext())._asString());
- $ctx1.sendIdx[","]=2;
- $1=_st($3).__comma(")");
- $ctx1.sendIdx[","]=1;
- } else {
- $1=_st(_st(_st(_st(self._receiver())._class())._name()).__comma(" >> ")).__comma(self._selector());
- $ctx1.sendIdx[","]=3;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.MethodContext)})},
- args: [],
- source: "asString\x0a\x09^ self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class name, ' >> ', self selector ]",
- messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "name", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluatedSelector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.evaluatedSelector;
- return self}, function($ctx1) {$ctx1.fill(self,"evaluatedSelector",{},globals.MethodContext)})},
- args: [],
- source: "evaluatedSelector\x0a\x09<return self.evaluatedSelector>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "home",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.homeContext;
- return self}, function($ctx1) {$ctx1.fill(self,"home",{},globals.MethodContext)})},
- args: [],
- source: "home\x0a\x09<return self.homeContext>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.index || 0;
- return self}, function($ctx1) {$ctx1.fill(self,"index",{},globals.MethodContext)})},
- args: [],
- source: "index\x0a\x09<return self.index || 0>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockContext",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._selector())._isNil();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},globals.MethodContext)})},
- args: [],
- source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
- messageSends: ["isNil", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "locals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.locals || {};
- return self}, function($ctx1) {$ctx1.fill(self,"locals",{},globals.MethodContext)})},
- args: [],
- source: "locals\x0a\x09<return self.locals || {}>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$5,$4,$3,$1;
- $2=self._methodContext();
- $ctx1.sendIdx["methodContext"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $5=self._methodContext();
- $ctx1.sendIdx["methodContext"]=2;
- $4=_st($5)._receiver();
- $3=_st($4)._class();
- $1=_st($3)._lookupSelector_(_st(self._methodContext())._selector());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.MethodContext)})},
- args: [],
- source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
- messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2;
- $1=self._isBlockContext();
- if(! smalltalk.assert($1)){
- return self;
- };
- $3=self._outerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $2=$3;
- } else {
- var outer;
- outer=$receiver;
- $2=_st(outer)._methodContext();
- };
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"methodContext",{},globals.MethodContext)})},
- args: [],
- source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
- messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.outerContext || self.homeContext;
- return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{},globals.MethodContext)})},
- args: [],
- source: "outerContext\x0a\x09<return self.outerContext || self.homeContext>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.MethodContext.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_("(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._asString());
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MethodContext)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self asString;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "asString"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.receiver;
- return self}, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.MethodContext)})},
- args: [],
- source: "receiver\x0a\x09<return self.receiver>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self.selector) {
- return smalltalk.convertSelector(self.selector);
- } else {
- return nil;
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MethodContext)})},
- args: [],
- source: "selector\x0a\x09<\x0a\x09\x09if(self.selector) {\x0a\x09\x09\x09return smalltalk.convertSelector(self.selector);\x0a\x09\x09} else {\x0a\x09\x09\x09return nil;\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexAt:",
- protocol: 'accessing',
- fn: function (aSelector){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.sendIdx[aSelector] || 0;
- return self}, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aSelector:aSelector},globals.MethodContext)})},
- args: ["aSelector"],
- source: "sendIndexAt: aSelector\x0a\x09<return self.sendIdx[aSelector] || 0>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.sendIdx;
- return self}, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},globals.MethodContext)})},
- args: [],
- source: "sendIndexes\x0a\x09<return self.sendIdx>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "temps",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._locals();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.MethodContext)})},
- args: [],
- source: "temps\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09^ self locals",
- messageSends: ["deprecatedAPI", "locals"],
- referencedClasses: []
- }),
- globals.MethodContext);
- smalltalk.addClass('NativeFunction', globals.Object, [], 'Kernel-Methods');
- globals.NativeFunction.comment="I am a wrapper around native functions, such as `WebSocket`.\x0aFor 'normal' functions (whose constructor is the JavaScript `Function` object), use `BlockClosure`.\x0a\x0a## API\x0a\x0aSee the class-side `instance creation` methods for instance creation.\x0a\x0aCreated instances will most probably be instance of `JSObjectProxy`.\x0a\x0a## Usage example:\x0a\x0a\x09| ws |\x0a\x09ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a\x09ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString},globals.NativeFunction.klass)})},
- args: ["aString"],
- source: "constructor: aString\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject},globals.NativeFunction.klass)})},
- args: ["aString", "anObject"],
- source: "constructor: aString value:anObject\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject,anObject2){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject,anObject2);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2},globals.NativeFunction.klass)})},
- args: ["aString", "anObject", "anObject2"],
- source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "constructor:value:value:value:",
- protocol: 'instance creation',
- fn: function (aString,anObject,anObject2,anObject3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var native=eval(aString);
- return new native(anObject,anObject2, anObject3);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.NativeFunction.klass)})},
- args: ["aString", "anObject", "anObject2", "anObject3"],
- source: "constructor: aString value:anObject value: anObject2 value:anObject3\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2, anObject3);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NativeFunction.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "exists:",
- protocol: 'testing',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._existsGlobal_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},globals.NativeFunction.klass)})},
- args: ["aString"],
- source: "exists: aString\x0a\x09^ PlatformInterface existsGlobal: aString",
- messageSends: ["existsGlobal:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.NativeFunction.klass);
- smalltalk.addClass('Timeout', globals.Object, ['rawTimeout'], 'Kernel-Methods');
- globals.Timeout.comment="I am wrapping the returns from `set{Timeout,Interval}`.\x0a\x0a## Motivation\x0a\x0aNumber suffices in browsers, but node.js returns an object.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clearInterval",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var interval = self["@rawTimeout"];
- clearInterval(interval);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"clearInterval",{},globals.Timeout)})},
- args: [],
- source: "clearInterval\x0a\x09<\x0a\x09\x09var interval = self[\x22@rawTimeout\x22];\x0a\x09\x09clearInterval(interval);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clearTimeout",
- protocol: 'timeout/interval',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var timeout = self["@rawTimeout"];
- clearTimeout(timeout);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"clearTimeout",{},globals.Timeout)})},
- args: [],
- source: "clearTimeout\x0a\x09<\x0a\x09\x09var timeout = self[\x22@rawTimeout\x22];\x0a\x09\x09clearTimeout(timeout);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "rawTimeout:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@rawTimeout"]=anObject;
- return self},
- args: ["anObject"],
- source: "rawTimeout: anObject\x0a\x09rawTimeout := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Timeout);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._rawTimeout_(anObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},globals.Timeout.klass)})},
- args: ["anObject"],
- source: "on: anObject\x0a\x09^ self new rawTimeout: anObject; yourself",
- messageSends: ["rawTimeout:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Timeout.klass);
- });
- define("amber_core/Kernel-Collections", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Collections');
- smalltalk.packages["Kernel-Collections"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('Association', globals.Object, ['key', 'value'], 'Kernel-Collections');
- globals.Association.comment="I represent a pair of associated objects, a key and a value. My instances can serve as entries in a dictionary.\x0a\x0aInstances can be created with the class-side method `#key:value:`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (anAssociation){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$5,$4,$6,$1;
- $3=self._class();
- $ctx1.sendIdx["class"]=1;
- $2=_st($3).__eq(_st(anAssociation)._class());
- $ctx1.sendIdx["="]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $5=self._key();
- $ctx2.sendIdx["key"]=1;
- $4=_st($5).__eq(_st(anAssociation)._key());
- $ctx2.sendIdx["="]=2;
- return _st($4)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- $6=self._value();
- $ctx3.sendIdx["value"]=1;
- return _st($6).__eq(_st(anAssociation)._value());
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["and:"]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"=",{anAssociation:anAssociation},globals.Association)})},
- args: ["anAssociation"],
- source: "= anAssociation\x0a\x09^ self class = anAssociation class and: [\x0a\x09\x09self key = anAssociation key and: [\x0a\x09\x09self value = anAssociation value ]]",
- messageSends: ["and:", "=", "class", "key", "value"],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "key",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@key"];
- return $1;
- },
- args: [],
- source: "key\x0a\x09^ key",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "key:",
- protocol: 'accessing',
- fn: function (aKey){
- var self=this;
- self["@key"]=aKey;
- return self},
- args: ["aKey"],
- source: "key: aKey\x0a\x09key := aKey",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._key())._printOn_(aStream);
- $ctx1.sendIdx["printOn:"]=1;
- _st(aStream)._nextPutAll_(" -> ");
- _st(self._value())._printOn_(aStream);
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Association)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09self key printOn: aStream.\x0a\x09aStream nextPutAll: ' -> '.\x0a\x09self value printOn: aStream",
- messageSends: ["printOn:", "key", "nextPutAll:", "value"],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@value"];
- return $1;
- },
- args: [],
- source: "value\x0a\x09^ value",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'accessing',
- fn: function (aValue){
- var self=this;
- self["@value"]=aValue;
- return self},
- args: ["aValue"],
- source: "value: aValue\x0a\x09value := aValue",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Association);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "key:value:",
- protocol: 'instance creation',
- fn: function (aKey,aValue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._key_(aKey);
- _st($2)._value_(aValue);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"key:value:",{aKey:aKey,aValue:aValue},globals.Association.klass)})},
- args: ["aKey", "aValue"],
- source: "key: aKey value: aValue\x0a\x09\x09^ self new\x0a\x09\x09key: aKey;\x0a\x09\x09value: aValue;\x0a\x09\x09yourself",
- messageSends: ["key:", "new", "value:", "yourself"],
- referencedClasses: []
- }),
- globals.Association.klass);
- smalltalk.addClass('BucketStore', globals.Object, ['buckets', 'hashBlock'], 'Kernel-Collections');
- globals.BucketStore.comment="I am an helper class for hash-based stores.\x0a\x0aI hold buckets which are selected by a hash, specified using `#hashBlock:`.\x0aThe hash can be any object, and\x0ait is used as a JS property (that is, in ES5\x0aits toString() value counts).\x0a\x0a## API\x0aI maintain a list of buckets. Client code can use this API:\x0a - `#bucketOfElement:` (to ask a bucket for element, I can return JS null if n/a)\x0a - `#do:` (to enumerate all elements of all buckets)\x0a - `#removeAll` (to remove all buckets)\x0a\x0aClient code itself should add/remove elements\x0ain a bucket. The `nil` object should not be put into any bucket.\x0a\x0aTypes of buckets are the responsibility of subclasses via `#newBucket`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "bucketOfElement:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var hash = self['@hashBlock'](anObject);
- if (!hash) return null;
- var buckets = self['@buckets'],
- bucket = buckets[hash];
- if (!bucket) { bucket = buckets[hash] = self._newBucket(); }
- return bucket;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"bucketOfElement:",{anObject:anObject},globals.BucketStore)})},
- args: ["anObject"],
- source: "bucketOfElement: anObject\x0a\x09<\x0a\x09\x09var hash = self['@hashBlock'](anObject);\x0a\x09\x09if (!hash) return null;\x0a\x09\x09var buckets = self['@buckets'],\x0a\x09\x09\x09bucket = buckets[hash];\x0a\x09\x09if (!bucket) { bucket = buckets[hash] = self._newBucket(); }\x0a\x09\x09return bucket;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var buckets = self['@buckets'];
- var keys = Object.keys(buckets);
- for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.BucketStore)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09<\x0a\x09\x09var buckets = self['@buckets'];\x0a\x09\x09var keys = Object.keys(buckets);\x0a\x09\x09for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); }\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hashBlock:",
- protocol: 'accessing',
- fn: function (aBlock){
- var self=this;
- self["@hashBlock"]=aBlock;
- return self},
- args: ["aBlock"],
- source: "hashBlock: aBlock\x0a\x09hashBlock := aBlock",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.BucketStore.superclass.fn.prototype._initialize.apply(_st(self), []);
- self._removeAll();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.BucketStore)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09self removeAll",
- messageSends: ["initialize", "removeAll"],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newBucket",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"newBucket",{},globals.BucketStore)})},
- args: [],
- source: "newBucket\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self['@buckets'] = Object.create(null);;
- return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.BucketStore)})},
- args: [],
- source: "removeAll\x0a\x09<self['@buckets'] = Object.create(null);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BucketStore);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hashBlock:",
- protocol: 'instance creation',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._hashBlock_(aBlock);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"hashBlock:",{aBlock:aBlock},globals.BucketStore.klass)})},
- args: ["aBlock"],
- source: "hashBlock: aBlock\x0a\x09^ self new\x0a\x09\x09hashBlock: aBlock;\x0a\x09\x09yourself",
- messageSends: ["hashBlock:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.BucketStore.klass);
- smalltalk.addClass('ArrayBucketStore', globals.BucketStore, [], 'Kernel-Collections');
- globals.ArrayBucketStore.comment="I am a concrete `BucketStore` with buckets being instance of `Array`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newBucket",
- protocol: 'private',
- fn: function (){
- var self=this;
- var $1;
- $1=[];
- return $1;
- },
- args: [],
- source: "newBucket\x0a\x09^ #()",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ArrayBucketStore);
- smalltalk.addClass('Collection', globals.Object, [], 'Kernel-Collections');
- globals.Collection.comment="I am the abstract superclass of all classes that represent a group of elements.\x0a\x0aI provide a set of useful methods to the Collection hierarchy such as enumerating and converting methods.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: ",",
- protocol: 'copying',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._copy();
- _st($2)._addAll_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,",",{aCollection:aCollection},globals.Collection)})},
- args: ["aCollection"],
- source: ", aCollection\x0a\x09^ self copy\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself",
- messageSends: ["addAll:", "copy", "yourself"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},globals.Collection)})},
- args: ["anObject"],
- source: "add: anObject\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addAll:",
- protocol: 'adding/removing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return aCollection;
- }, function($ctx1) {$ctx1.fill(self,"addAll:",{aCollection:aCollection},globals.Collection)})},
- args: ["aCollection"],
- source: "addAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self add: each ].\x0a\x09^ aCollection",
- messageSends: ["do:", "add:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSatisfy:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(each);
- if(! smalltalk.assert($1)){
- throw $early=[false];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"allSatisfy:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "allSatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns false for any element return false.\x0a\x09Otherwise return true.\x22\x0a\x0a\x09self do: [ :each | (aBlock value: each) ifFalse: [ ^ false ] ].\x0a\x09^ true",
- messageSends: ["do:", "ifFalse:", "value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "anyOne",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $early={};
- try {
- self._ifEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Collection is empty");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- self._do_((function(each){
- throw $early=[each];
- }));
- return self}
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"anyOne",{},globals.Collection)})},
- args: [],
- source: "anyOne\x0a\x09\x22Answer a representative sample of the receiver. This method can\x0a\x09be helpful when needing to preinfer the nature of the contents of \x0a\x09semi-homogeneous collections.\x22\x0a\x0a\x09self ifEmpty: [ self error: 'Collection is empty' ].\x0a\x09self do: [ :each | ^ each ]",
- messageSends: ["ifEmpty:", "error:", "do:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "anySatisfy:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(each);
- if(smalltalk.assert($1)){
- throw $early=[true];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return false;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"anySatisfy:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "anySatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns true for any element return true.\x0a\x09Otherwise return false.\x22\x0a\x0a\x09self do: [ :each | (aBlock value: each) ifTrue: [ ^ true ] ].\x0a\x09^ false",
- messageSends: ["do:", "ifTrue:", "value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asArray",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Array())._withAll_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asArray",{},globals.Collection)})},
- args: [],
- source: "asArray\x0a\x09^ Array withAll: self",
- messageSends: ["withAll:"],
- referencedClasses: ["Array"]
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asArray())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._asJSON();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJSON",{},globals.Collection)})},
- args: [],
- source: "asJSON\x0a\x09^ self asArray collect: [ :each | each asJSON ]",
- messageSends: ["collect:", "asArray", "asJSON"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asOrderedCollection",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._asArray();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asOrderedCollection",{},globals.Collection)})},
- args: [],
- source: "asOrderedCollection\x0a\x09^ self asArray",
- messageSends: ["asArray"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSet",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $Set(){return globals.Set||(typeof Set=="undefined"?nil:Set)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Set())._withAll_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asSet",{},globals.Collection)})},
- args: [],
- source: "asSet\x0a\x09^ Set withAll: self",
- messageSends: ["withAll:"],
- referencedClasses: ["Set"]
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "collect:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var stream;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- stream=_st(_st(self._class())._new())._writeStream();
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(stream)._nextPut_(_st(aBlock)._value_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=_st(stream)._contents();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,stream:stream},globals.Collection)})},
- args: ["aBlock"],
- source: "collect: aBlock\x0a\x09| stream |\x0a\x09stream := self class new writeStream.\x0a\x09self do: [ :each |\x0a\x09\x09stream nextPut: (aBlock value: each) ].\x0a\x09^ stream contents",
- messageSends: ["writeStream", "new", "class", "do:", "nextPut:", "value:", "contents"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "contains:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._anySatisfy_(aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"contains:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "contains: aBlock\x0a\x09self deprecatedAPI.\x0a\x0a\x09^ self anySatisfy: aBlock",
- messageSends: ["deprecatedAPI", "anySatisfy:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyWith:",
- protocol: 'copying',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._copy();
- _st($2)._add_(anObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"copyWith:",{anObject:anObject},globals.Collection)})},
- args: ["anObject"],
- source: "copyWith: anObject\x0a\x09^ self copy add: anObject; yourself",
- messageSends: ["add:", "copy", "yourself"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyWithAll:",
- protocol: 'copying',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._copy();
- _st($2)._addAll_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"copyWithAll:",{aCollection:aCollection},globals.Collection)})},
- args: ["aCollection"],
- source: "copyWithAll: aCollection\x0a\x09^ self copy addAll: aCollection; yourself",
- messageSends: ["addAll:", "copy", "yourself"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyWithoutAll:",
- protocol: 'copying',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._reject_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(aCollection)._includes_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"copyWithoutAll:",{aCollection:aCollection},globals.Collection)})},
- args: ["aCollection"],
- source: "copyWithoutAll: aCollection\x0a\x09\x22Answer a copy of the receiver that does not contain any elements\x0a\x09equal to those in aCollection.\x22\x0a\x0a\x09^ self reject: [ :each | aCollection includes: each ]",
- messageSends: ["reject:", "includes:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "detect:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._detect_ifNone_(aBlock,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._errorNotFound();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"detect:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "detect: aBlock\x0a\x09^ self detect: aBlock ifNone: [ self errorNotFound ]",
- messageSends: ["detect:ifNone:", "errorNotFound"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "detect:ifNone:",
- protocol: 'enumerating',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Collection)})},
- args: ["aBlock", "anotherBlock"],
- source: "detect: aBlock ifNone: anotherBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:separatedBy:",
- protocol: 'enumerating',
- fn: function (aBlock,anotherBlock){
- var self=this;
- var actionBeforeElement;
- return smalltalk.withContext(function($ctx1) {
- actionBeforeElement=(function(){
- actionBeforeElement=anotherBlock;
- return actionBeforeElement;
- });
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- _st(actionBeforeElement)._value();
- return _st(aBlock)._value_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"do:separatedBy:",{aBlock:aBlock,anotherBlock:anotherBlock,actionBeforeElement:actionBeforeElement},globals.Collection)})},
- args: ["aBlock", "anotherBlock"],
- source: "do: aBlock separatedBy: anotherBlock\x0a\x09| actionBeforeElement |\x0a\x09actionBeforeElement := [ actionBeforeElement := anotherBlock ].\x0a\x09self do: [ :each |\x0a\x09\x09actionBeforeElement value.\x0a\x09\x09aBlock value: each ]",
- messageSends: ["do:", "value", "value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "errorNotFound",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("Object is not in the collection");
- return self}, function($ctx1) {$ctx1.fill(self,"errorNotFound",{},globals.Collection)})},
- args: [],
- source: "errorNotFound\x0a\x09self error: 'Object is not in the collection'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifEmpty:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._isEmpty();
- $1=_st($2)._ifTrue_ifFalse_(aBlock,(function(){
- return self;
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "ifEmpty: aBlock\x0a\x09\x22Evaluate the given block with the receiver as argument, answering its value if the receiver is empty, otherwise answer the receiver. \x0a\x09Note that the fact that this method returns its argument in case the receiver is not empty allows one to write expressions like the following ones: \x0a\x09\x09self classifyMethodAs:\x0a\x09\x09\x09(myProtocol ifEmpty: ['As yet unclassified'])\x22\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ self ]",
- messageSends: ["ifTrue:ifFalse:", "isEmpty"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifEmpty:ifNotEmpty:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._isEmpty();
- $1=_st($2)._ifTrue_ifFalse_(aBlock,anotherBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifEmpty:ifNotEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Collection)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifEmpty: aBlock ifNotEmpty: anotherBlock\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: anotherBlock",
- messageSends: ["ifTrue:ifFalse:", "isEmpty"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotEmpty:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._notEmpty();
- $1=_st($2)._ifTrue_ifFalse_(aBlock,(function(){
- return self;
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "ifNotEmpty: aBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ self ]",
- messageSends: ["ifTrue:ifFalse:", "notEmpty"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotEmpty:ifEmpty:",
- protocol: 'testing',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._notEmpty();
- $1=_st($2)._ifTrue_ifFalse_(aBlock,anotherBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:ifEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Collection)})},
- args: ["aBlock", "anotherBlock"],
- source: "ifNotEmpty: aBlock ifEmpty: anotherBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: anotherBlock",
- messageSends: ["ifTrue:ifFalse:", "notEmpty"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includes:",
- protocol: 'testing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._anySatisfy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each).__eq(anObject);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},globals.Collection)})},
- args: ["anObject"],
- source: "includes: anObject\x0a\x09^ self anySatisfy: [ :each | each = anObject ]",
- messageSends: ["anySatisfy:", "="],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inject:into:",
- protocol: 'enumerating',
- fn: function (anObject,aBlock){
- var self=this;
- var result;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- result=anObject;
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- result=_st(aBlock)._value_value_(result,each);
- return result;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=result;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inject:into:",{anObject:anObject,aBlock:aBlock,result:result},globals.Collection)})},
- args: ["anObject", "aBlock"],
- source: "inject: anObject into: aBlock\x0a\x09| result |\x0a\x09result := anObject.\x0a\x09self do: [ :each |\x0a\x09\x09result := aBlock value: result value: each ].\x0a\x09^ result",
- messageSends: ["do:", "value:value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "intersection:",
- protocol: 'enumerating',
- fn: function (aCollection){
- var self=this;
- var set,outputSet;
- function $Set(){return globals.Set||(typeof Set=="undefined"?nil:Set)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3;
- set=self._asSet();
- outputSet=_st($Set())._new();
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(set)._includes_(each);
- $ctx2.sendIdx["includes:"]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(_st(outputSet)._includes_(each))._not();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- if(smalltalk.assert($1)){
- return _st(outputSet)._add_(each);
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $3=_st(self._class())._withAll_(_st(outputSet)._asArray());
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"intersection:",{aCollection:aCollection,set:set,outputSet:outputSet},globals.Collection)})},
- args: ["aCollection"],
- source: "intersection: aCollection\x0a\x09\x22Answer the set theoretic intersection of two collections.\x22\x0a\x0a\x09| set outputSet |\x0a\x09\x0a\x09set := self asSet.\x0a\x09outputSet := Set new.\x0a\x09\x0a\x09aCollection do: [ :each |\x0a\x09\x09((set includes: each) and: [ (outputSet includes: each) not ])\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09outputSet add: each ]].\x0a\x09\x09\x0a\x09^ self class withAll: outputSet asArray",
- messageSends: ["asSet", "new", "do:", "ifTrue:", "and:", "includes:", "not", "add:", "withAll:", "class", "asArray"],
- referencedClasses: ["Set"]
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isEmpty",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._size()).__eq((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isEmpty",{},globals.Collection)})},
- args: [],
- source: "isEmpty\x0a\x09^ self size = 0",
- messageSends: ["=", "size"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "noneSatisfy:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- self._do_((function(item){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(item);
- if(smalltalk.assert($1)){
- throw $early=[false];
- };
- }, function($ctx2) {$ctx2.fillBlock({item:item},$ctx1,1)})}));
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"noneSatisfy:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "noneSatisfy: aBlock\x0a\x09\x22Evaluate aBlock with the elements of the receiver.\x0a\x09If aBlock returns false for all elements return true.\x0a\x09Otherwise return false\x22\x0a\x0a\x09self do: [ :item | (aBlock value: item) ifTrue: [ ^ false ] ].\x0a\x09^ true",
- messageSends: ["do:", "ifTrue:", "value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "notEmpty",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._isEmpty())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"notEmpty",{},globals.Collection)})},
- args: [],
- source: "notEmpty\x0a\x09^ self isEmpty not",
- messageSends: ["not", "isEmpty"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "occurrencesOf:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- var tally;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- tally=(0);
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(anObject).__eq(each);
- if(smalltalk.assert($1)){
- tally=_st(tally).__plus((1));
- return tally;
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=tally;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"occurrencesOf:",{anObject:anObject,tally:tally},globals.Collection)})},
- args: ["anObject"],
- source: "occurrencesOf: anObject\x0a\x09\x22Answer how many of the receiver's elements are equal to anObject.\x22\x0a\x0a\x09| tally |\x0a\x09tally := 0.\x0a\x09self do: [ :each | anObject = each ifTrue: [ tally := tally + 1 ]].\x0a\x09^ tally",
- messageSends: ["do:", "ifTrue:", "=", "+"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "putOn:",
- protocol: 'streaming',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._putOn_(aStream);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},globals.Collection)})},
- args: ["aStream"],
- source: "putOn: aStream\x0a\x09self do: [ :each | each putOn: aStream ]",
- messageSends: ["do:", "putOn:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reject:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(aBlock)._value_(each)).__eq(false);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"reject:",{aBlock:aBlock},globals.Collection)})},
- args: ["aBlock"],
- source: "reject: aBlock\x0a\x09^ self select: [ :each | (aBlock value: each) = false ]",
- messageSends: ["select:", "=", "value:"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._remove_ifAbsent_(anObject,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._errorNotFound();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"remove:",{anObject:anObject},globals.Collection)})},
- args: ["anObject"],
- source: "remove: anObject\x0a\x09^ self remove: anObject ifAbsent: [ self errorNotFound ]",
- messageSends: ["remove:ifAbsent:", "errorNotFound"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (anObject,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock},globals.Collection)})},
- args: ["anObject", "aBlock"],
- source: "remove: anObject ifAbsent: aBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.Collection)})},
- args: [],
- source: "removeAll\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "select:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var stream;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- stream=_st(_st(self._class())._new())._writeStream();
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(each);
- if(smalltalk.assert($1)){
- return _st(stream)._nextPut_(each);
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=_st(stream)._contents();
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,stream:stream},globals.Collection)})},
- args: ["aBlock"],
- source: "select: aBlock\x0a\x09| stream |\x0a\x09stream := self class new writeStream.\x0a\x09self do: [ :each |\x0a\x09\x09(aBlock value: each) ifTrue: [\x0a\x09\x09stream nextPut: each ] ].\x0a\x09^ stream contents",
- messageSends: ["writeStream", "new", "class", "do:", "ifTrue:", "value:", "nextPut:", "contents"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "select:thenCollect:",
- protocol: 'enumerating',
- fn: function (selectBlock,collectBlock){
- var self=this;
- var stream;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- stream=_st(_st(self._class())._new())._writeStream();
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(selectBlock)._value_(each);
- $ctx2.sendIdx["value:"]=1;
- if(smalltalk.assert($1)){
- return _st(stream)._nextPut_(_st(collectBlock)._value_(each));
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=_st(stream)._contents();
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"select:thenCollect:",{selectBlock:selectBlock,collectBlock:collectBlock,stream:stream},globals.Collection)})},
- args: ["selectBlock", "collectBlock"],
- source: "select: selectBlock thenCollect: collectBlock\x0a\x09| stream |\x0a\x09stream := self class new writeStream.\x0a\x09self do: [ :each |\x0a\x09\x09(selectBlock value: each) ifTrue: [\x0a\x09\x09stream nextPut: (collectBlock value: each) ] ].\x0a\x09^ stream contents",
- messageSends: ["writeStream", "new", "class", "do:", "ifTrue:", "value:", "nextPut:", "contents"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"size",{},globals.Collection)})},
- args: [],
- source: "size\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.Collection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "collection";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'collection'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new:",
- protocol: 'instance creation',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"new:",{anInteger:anInteger},globals.Collection.klass)})},
- args: ["anInteger"],
- source: "new: anInteger\x0a\x09^ self new",
- messageSends: ["new"],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:",
- protocol: 'instance creation',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._add_(anObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:",{anObject:anObject},globals.Collection.klass)})},
- args: ["anObject"],
- source: "with: anObject\x0a\x09\x09^ self new\x0a\x09\x09add: anObject;\x0a\x09\x09yourself",
- messageSends: ["add:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:with:",
- protocol: 'instance creation',
- fn: function (anObject,anotherObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._add_(anObject);
- $ctx1.sendIdx["add:"]=1;
- _st($2)._add_(anotherObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:with:",{anObject:anObject,anotherObject:anotherObject},globals.Collection.klass)})},
- args: ["anObject", "anotherObject"],
- source: "with: anObject with: anotherObject\x0a\x09\x09^ self new\x0a\x09\x09add: anObject;\x0a\x09\x09add: anotherObject;\x0a\x09\x09yourself",
- messageSends: ["add:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:with:with:",
- protocol: 'instance creation',
- fn: function (firstObject,secondObject,thirdObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._add_(firstObject);
- $ctx1.sendIdx["add:"]=1;
- _st($2)._add_(secondObject);
- $ctx1.sendIdx["add:"]=2;
- _st($2)._add_(thirdObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:with:with:",{firstObject:firstObject,secondObject:secondObject,thirdObject:thirdObject},globals.Collection.klass)})},
- args: ["firstObject", "secondObject", "thirdObject"],
- source: "with: firstObject with: secondObject with: thirdObject\x0a\x09\x09^ self new\x0a\x09\x09add: firstObject;\x0a\x09\x09add: secondObject;\x0a\x09\x09add: thirdObject;\x0a\x09\x09yourself",
- messageSends: ["add:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withAll:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._addAll_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"withAll:",{aCollection:aCollection},globals.Collection.klass)})},
- args: ["aCollection"],
- source: "withAll: aCollection\x0a\x09\x09^ self new\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself",
- messageSends: ["addAll:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.Collection.klass);
- smalltalk.addClass('IndexableCollection', globals.Collection, [], 'Kernel-Collections');
- globals.IndexableCollection.comment="I am a key-value store collection, that is,\x0aI store values under indexes.\x0a\x0aAs a rule of thumb, if a collection has `#at:` and `#at:put:`,\x0ait is an IndexableCollection.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:",
- protocol: 'accessing',
- fn: function (anIndex){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_ifAbsent_(anIndex,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._errorNotFound();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:",{anIndex:anIndex},globals.IndexableCollection)})},
- args: ["anIndex"],
- source: "at: anIndex\x0a\x09\x22Lookup the given index in the receiver.\x0a\x09If it is present, answer the value stored at anIndex.\x0a\x09Otherwise, raise an error.\x22\x0a\x0a\x09^ self at: anIndex ifAbsent: [ self errorNotFound ]",
- messageSends: ["at:ifAbsent:", "errorNotFound"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},globals.IndexableCollection)})},
- args: ["anIndex", "aBlock"],
- source: "at: anIndex ifAbsent: aBlock\x0a\x09\x22Lookup the given index in the receiver.\x0a\x09If it is present, answer the value stored at anIndex.\x0a\x09Otherwise, answer the value of aBlock.\x22\x0a\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsentPut:",
- protocol: 'accessing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_ifAbsent_(aKey,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._at_put_(aKey,_st(aBlock)._value());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifAbsentPut:",{aKey:aKey,aBlock:aBlock},globals.IndexableCollection)})},
- args: ["aKey", "aBlock"],
- source: "at: aKey ifAbsentPut: aBlock\x0a\x09^ self at: aKey ifAbsent: [\x0a\x09\x09self at: aKey put: aBlock value ]",
- messageSends: ["at:ifAbsent:", "at:put:", "value"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_ifPresent_ifAbsent_(anIndex,aBlock,(function(){
- return nil;
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifPresent:",{anIndex:anIndex,aBlock:aBlock},globals.IndexableCollection)})},
- args: ["anIndex", "aBlock"],
- source: "at: anIndex ifPresent: aBlock\x0a\x09\x22Lookup the given index in the receiver.\x0a\x09If it is present, answer the value of evaluating aBlock with the value stored at anIndex.\x0a\x09Otherwise, answer nil.\x22\x0a\x0a\x09^ self at: anIndex ifPresent: aBlock ifAbsent: [ nil ]",
- messageSends: ["at:ifPresent:ifAbsent:"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},globals.IndexableCollection)})},
- args: ["anIndex", "aBlock", "anotherBlock"],
- source: "at: anIndex ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09\x22Lookup the given index in the receiver.\x0a\x09If it is present, answer the value of evaluating aBlock with the value stored at anIndex.\x0a\x09Otherwise, answer the value of anotherBlock.\x22\x0a\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (anIndex,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},globals.IndexableCollection)})},
- args: ["anIndex", "anObject"],
- source: "at: anIndex put: anObject\x0a\x09\x22Store anObject under the given index in the receiver.\x22\x0a\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._indexOf_ifAbsent_(anObject,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._errorNotFound();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"indexOf:",{anObject:anObject},globals.IndexableCollection)})},
- args: ["anObject"],
- source: "indexOf: anObject\x0a\x09\x22Lookup index at which anObject is stored in the receiver.\x0a\x09If not present, raise an error.\x22\x0a\x0a\x09^ self indexOf: anObject ifAbsent: [ self errorNotFound ]",
- messageSends: ["indexOf:ifAbsent:", "errorNotFound"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},globals.IndexableCollection)})},
- args: ["anObject", "aBlock"],
- source: "indexOf: anObject ifAbsent: aBlock\x0a\x09\x22Lookup index at which anObject is stored in the receiver.\x0a\x09If not present, return value of executing aBlock.\x22\x0a\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:do:",
- protocol: 'enumarating',
- fn: function (anotherCollection,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._withIndexDo_((function(each,index){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_value_(each,_st(anotherCollection)._at_(index));
- }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anotherCollection:anotherCollection,aBlock:aBlock},globals.IndexableCollection)})},
- args: ["anotherCollection", "aBlock"],
- source: "with: anotherCollection do: aBlock\x0a\x09\x22Calls aBlock with every value from self\x0a\x09and with indetically-indexed value from anotherCollection\x22\x0a\x0a\x09self withIndexDo: [ :each :index |\x0a\x09\x09aBlock value: each value: (anotherCollection at: index) ]",
- messageSends: ["withIndexDo:", "value:value:", "at:"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withIndexDo:",
- protocol: 'enumarating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},globals.IndexableCollection)})},
- args: ["aBlock"],
- source: "withIndexDo: aBlock\x0a\x09\x22Calls aBlock with every value from self\x0a\x09and with its index as the second argument\x22\x0a\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.IndexableCollection);
- smalltalk.addClass('AssociativeCollection', globals.IndexableCollection, [], 'Kernel-Collections');
- globals.AssociativeCollection.comment="I am a base class for object-indexed collections (Dictionary et.al.).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (anAssocitativeCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$6,$5;
- $2=self._class();
- $ctx1.sendIdx["class"]=1;
- $1=_st($2).__eq(_st(anAssocitativeCollection)._class());
- $ctx1.sendIdx["="]=1;
- if(! smalltalk.assert($1)){
- return false;
- };
- $4=self._size();
- $ctx1.sendIdx["size"]=1;
- $3=_st($4).__eq(_st(anAssocitativeCollection)._size());
- $ctx1.sendIdx["="]=2;
- if(! smalltalk.assert($3)){
- return false;
- };
- $6=self._associations();
- $ctx1.sendIdx["associations"]=1;
- $5=_st($6).__eq(_st(anAssocitativeCollection)._associations());
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"=",{anAssocitativeCollection:anAssocitativeCollection},globals.AssociativeCollection)})},
- args: ["anAssocitativeCollection"],
- source: "= anAssocitativeCollection\x0a\x09self class = anAssocitativeCollection class ifFalse: [ ^ false ].\x0a\x09self size = anAssocitativeCollection size ifFalse: [ ^ false ].\x0a\x09^ self associations = anAssocitativeCollection associations",
- messageSends: ["ifFalse:", "=", "class", "size", "associations"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'adding/removing',
- fn: function (anAssociation){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._at_put_(_st(anAssociation)._key(),_st(anAssociation)._value());
- return self}, function($ctx1) {$ctx1.fill(self,"add:",{anAssociation:anAssociation},globals.AssociativeCollection)})},
- args: ["anAssociation"],
- source: "add: anAssociation\x0a\x09self at: anAssociation key put: anAssociation value",
- messageSends: ["at:put:", "key", "value"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addAll:",
- protocol: 'adding/removing',
- fn: function (anAssociativeCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.AssociativeCollection.superclass.fn.prototype._addAll_.apply(_st(self), [_st(anAssociativeCollection)._associations()]);
- return anAssociativeCollection;
- }, function($ctx1) {$ctx1.fill(self,"addAll:",{anAssociativeCollection:anAssociativeCollection},globals.AssociativeCollection)})},
- args: ["anAssociativeCollection"],
- source: "addAll: anAssociativeCollection\x0a\x09super addAll: anAssociativeCollection associations.\x0a\x09^ anAssociativeCollection",
- messageSends: ["addAll:", "associations"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asDictionary",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Dictionary())._from_(self._associations());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asDictionary",{},globals.AssociativeCollection)})},
- args: [],
- source: "asDictionary\x0a\x09^ Dictionary from: self associations",
- messageSends: ["from:", "associations"],
- referencedClasses: ["Dictionary"]
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asHashedCollection",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($HashedCollection())._from_(self._associations());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asHashedCollection",{},globals.AssociativeCollection)})},
- args: [],
- source: "asHashedCollection\x0a\x09^ HashedCollection from: self associations",
- messageSends: ["from:", "associations"],
- referencedClasses: ["HashedCollection"]
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- var hash;
- function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- hash=_st($HashedCollection())._new();
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(hash)._at_put_(key,_st(value)._asJSON());
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- $1=hash;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJSON",{hash:hash},globals.AssociativeCollection)})},
- args: [],
- source: "asJSON\x0a\x09| hash |\x0a\x09hash := HashedCollection new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09hash at: key put: value asJSON ].\x0a\x09^ hash",
- messageSends: ["new", "keysAndValuesDo:", "at:put:", "asJSON"],
- referencedClasses: ["HashedCollection"]
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "associations",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var associations;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- associations=[];
- self._associationsDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(associations)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=associations;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"associations",{associations:associations},globals.AssociativeCollection)})},
- args: [],
- source: "associations\x0a\x09| associations |\x0a\x09associations := #().\x0a\x09self associationsDo: [ :each | associations add: each ].\x0a\x09^ associations",
- messageSends: ["associationsDo:", "add:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "associationsDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- function $Association(){return globals.Association||(typeof Association=="undefined"?nil:Association)}
- return smalltalk.withContext(function($ctx1) {
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_(_st($Association())._key_value_(key,value));
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"associationsDo:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "associationsDo: aBlock\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09aBlock value: (Association key: key value: value) ]",
- messageSends: ["keysAndValuesDo:", "value:", "key:value:"],
- referencedClasses: ["Association"]
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:ifAbsent:",
- protocol: 'accessing',
- fn: function (aKey,aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._includesKey_(aKey);
- if(smalltalk.assert($2)){
- $1=_st(aBlock)._value_(self._at_(aKey));
- } else {
- $1=_st(anotherBlock)._value();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{aKey:aKey,aBlock:aBlock,anotherBlock:anotherBlock},globals.AssociativeCollection)})},
- args: ["aKey", "aBlock", "anotherBlock"],
- source: "at: aKey ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09\x22Lookup the given key in the receiver.\x0a\x09If it is present, answer the value of evaluating the oneArgBlock \x0a\x09with the value associated with the key, otherwise answer the value \x0a\x09of absentBlock.\x22\x0a\x09\x0a\x09^ (self includesKey: aKey)\x0a\x09\x09ifTrue: [ aBlock value: (self at: aKey) ]\x0a\x09\x09ifFalse: [ anotherBlock value ]",
- messageSends: ["ifTrue:ifFalse:", "includesKey:", "value:", "at:", "value"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "collect:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var newDict;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- newDict=_st(self._class())._new();
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(newDict)._at_put_(key,_st(aBlock)._value_(value));
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- $1=newDict;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,newDict:newDict},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "collect: aBlock\x0a\x09| newDict |\x0a\x09newDict := self class new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09newDict at: key put: (aBlock value: value) ].\x0a\x09^ newDict",
- messageSends: ["new", "class", "keysAndValuesDo:", "at:put:", "value:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- var copy;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- copy=_st(self._class())._new();
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(copy)._at_put_(key,_st(value)._deepCopy());
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- $1=copy;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"deepCopy",{copy:copy},globals.AssociativeCollection)})},
- args: [],
- source: "deepCopy\x0a\x09| copy |\x0a\x09copy := self class new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09copy at: key put: value deepCopy ].\x0a\x09^ copy",
- messageSends: ["new", "class", "keysAndValuesDo:", "at:put:", "deepCopy"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "detect:ifNone:",
- protocol: 'enumerating',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._values())._detect_ifNone_(aBlock,anotherBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.AssociativeCollection)})},
- args: ["aBlock", "anotherBlock"],
- source: "detect: aBlock ifNone: anotherBlock\x0a\x09^ self values detect: aBlock ifNone: anotherBlock",
- messageSends: ["detect:ifNone:", "values"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._valuesDo_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09self valuesDo: aBlock",
- messageSends: ["valuesDo:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includes:",
- protocol: 'enumerating',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._values())._includes_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},globals.AssociativeCollection)})},
- args: ["anObject"],
- source: "includes: anObject\x0a\x09^ self values includes: anObject",
- messageSends: ["includes:", "values"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesKey:",
- protocol: 'testing',
- fn: function (aKey){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},globals.AssociativeCollection)})},
- args: ["aKey"],
- source: "includesKey: aKey\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._keys())._detect_ifNone_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._at_(each)).__eq(anObject);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["anObject", "aBlock"],
- source: "indexOf: anObject ifAbsent: aBlock\x0a\x09^ self keys \x0a\x09\x09detect: [ :each | (self at: each) = anObject ] \x0a\x09\x09ifNone: aBlock",
- messageSends: ["detect:ifNone:", "keys", "=", "at:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keyAtValue:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._keyAtValue_ifAbsent_(anObject,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._errorNotFound();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"keyAtValue:",{anObject:anObject},globals.AssociativeCollection)})},
- args: ["anObject"],
- source: "keyAtValue: anObject\x0a\x09^ self keyAtValue: anObject ifAbsent: [ self errorNotFound ]",
- messageSends: ["keyAtValue:ifAbsent:", "errorNotFound"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keyAtValue:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._indexOf_ifAbsent_(anObject,aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"keyAtValue:ifAbsent:",{anObject:anObject,aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["anObject", "aBlock"],
- source: "keyAtValue: anObject ifAbsent: aBlock\x0a\x09^ self indexOf: anObject ifAbsent: aBlock",
- messageSends: ["indexOf:ifAbsent:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keys",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"keys",{},globals.AssociativeCollection)})},
- args: [],
- source: "keys\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysAndValuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._keysDo_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_value_(each,self._at_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "keysAndValuesDo: aBlock\x0a\x09self keysDo: [ :each |\x0a\x09\x09aBlock value: each value: (self at: each) ]",
- messageSends: ["keysDo:", "value:value:", "at:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "keysDo: aBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.AssociativeCollection.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- $ctx1.sendIdx["printOn:"]=1;
- _st(aStream)._nextPutAll_(" (");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(self._associations())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._printOn_(aStream);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(aStream)._nextPutAll_(" , ");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.AssociativeCollection)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09\x0a\x09aStream nextPutAll: ' ('.\x0a\x09self associations\x0a\x09\x09do: [ :each | each printOn: aStream ]\x0a\x09\x09separatedBy: [ aStream nextPutAll: ' , ' ].\x0a\x09aStream nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:", "associations"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._removeKey_ifAbsent_(aKey,aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aKey", "aBlock"],
- source: "remove: aKey ifAbsent: aBlock\x0a\x09^ self removeKey: aKey ifAbsent: aBlock",
- messageSends: ["removeKey:ifAbsent:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._keys())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._removeKey_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.AssociativeCollection)})},
- args: [],
- source: "removeAll\x0a\x09^ self keys do: [ :each | self removeKey: each ]",
- messageSends: ["do:", "keys", "removeKey:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeKey:",
- protocol: 'adding/removing',
- fn: function (aKey){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._remove_(aKey);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"removeKey:",{aKey:aKey},globals.AssociativeCollection)})},
- args: ["aKey"],
- source: "removeKey: aKey\x0a\x09^ self remove: aKey",
- messageSends: ["remove:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeKey:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aKey", "aBlock"],
- source: "removeKey: aKey ifAbsent: aBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "select:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var newDict;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- newDict=_st(self._class())._new();
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(value);
- if(smalltalk.assert($1)){
- return _st(newDict)._at_put_(key,value);
- };
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- $2=newDict;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,newDict:newDict},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "select: aBlock\x0a\x09| newDict |\x0a\x09newDict := self class new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09(aBlock value: value) ifTrue: [ newDict at: key put: value ]].\x0a\x09^ newDict",
- messageSends: ["new", "class", "keysAndValuesDo:", "ifTrue:", "value:", "at:put:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- var copy;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- copy=_st(self._class())._new();
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(copy)._at_put_(key,value);
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- $1=copy;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{copy:copy},globals.AssociativeCollection)})},
- args: [],
- source: "shallowCopy\x0a\x09| copy |\x0a\x09copy := self class new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09copy at: key put: value ].\x0a\x09^ copy",
- messageSends: ["new", "class", "keysAndValuesDo:", "at:put:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._keys())._size();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"size",{},globals.AssociativeCollection)})},
- args: [],
- source: "size\x0a\x09^ self keys size",
- messageSends: ["size", "keys"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "values",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"values",{},globals.AssociativeCollection)})},
- args: [],
- source: "values\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "valuesDo: aBlock\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withIndexDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_value_(value,key);
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},globals.AssociativeCollection)})},
- args: ["aBlock"],
- source: "withIndexDo: aBlock\x0a\x09self keysAndValuesDo: [ :key :value | aBlock value: value value: key ]",
- messageSends: ["keysAndValuesDo:", "value:value:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "from:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- var newCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- newCollection=self._new();
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(newCollection)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=newCollection;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"from:",{aCollection:aCollection,newCollection:newCollection},globals.AssociativeCollection.klass)})},
- args: ["aCollection"],
- source: "from: aCollection\x0a\x09| newCollection |\x0a\x09newCollection := self new.\x0a\x09aCollection do: [ :each | newCollection add: each ].\x0a\x09^ newCollection",
- messageSends: ["new", "do:", "add:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromPairs:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._from_(aCollection);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromPairs:",{aCollection:aCollection},globals.AssociativeCollection.klass)})},
- args: ["aCollection"],
- source: "fromPairs: aCollection\x0a\x09\x22This message is poorly named and has been replaced by #from:\x22\x0a\x09^ self from: aCollection",
- messageSends: ["from:"],
- referencedClasses: []
- }),
- globals.AssociativeCollection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newFromPairs:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- var newCollection;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4,$5;
- $2=_st(aCollection)._size();
- $ctx1.sendIdx["size"]=1;
- $1=_st($2)._even();
- if(! smalltalk.assert($1)){
- self._error_("#newFromPairs only accepts arrays of an even length");
- };
- newCollection=self._new();
- _st((1)._to_by_(_st(aCollection)._size(),(2)))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $3=newCollection;
- $4=_st(aCollection)._at_(each);
- $ctx2.sendIdx["at:"]=1;
- return _st($3)._at_put_($4,_st(aCollection)._at_(_st(each).__plus((1))));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- $5=newCollection;
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"newFromPairs:",{aCollection:aCollection,newCollection:newCollection},globals.AssociativeCollection.klass)})},
- args: ["aCollection"],
- source: "newFromPairs: aCollection\x0a\x09\x22Accept an array of elements where every two elements form an \x0a\x09association - the odd element being the key, and the even element the value.\x22\x0a\x09\x0a\x09| newCollection |\x0a\x09\x0a\x09aCollection size even ifFalse: [ \x0a\x09\x09self error: '#newFromPairs only accepts arrays of an even length' ].\x0a\x09\x09\x0a\x09newCollection := self new.\x0a\x09( 1 to: aCollection size by: 2 ) do: [ :each | \x0a\x09\x09newCollection at: (aCollection at: each) put: (aCollection at: each + 1) ].\x0a\x09\x09\x0a\x09^ newCollection",
- messageSends: ["ifFalse:", "even", "size", "error:", "new", "do:", "to:by:", "at:put:", "at:", "+"],
- referencedClasses: []
- }),
- globals.AssociativeCollection.klass);
- smalltalk.addClass('Dictionary', globals.AssociativeCollection, ['keys', 'values'], 'Kernel-Collections');
- globals.Dictionary.comment="I represent a set of elements that can be viewed from one of two perspectives: a set of associations,\x0aor a container of values that are externally named where the name can be any object that responds to `=`.\x0a\x0aThe external name is referred to as the key.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var index = self._positionOfKey_(aKey);
- return index >=0 ? self['@values'][index] : aBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.Dictionary)})},
- args: ["aKey", "aBlock"],
- source: "at: aKey ifAbsent: aBlock\x0a\x09<\x0a\x09\x09var index = self._positionOfKey_(aKey);\x0a\x09\x09return index >>=0 ? self['@values'][index] : aBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (aKey,aValue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var index = self._positionOfKey_(aKey);
- if(index === -1) {
- var keys = self['@keys'];
- index = keys.length;
- keys.push(aKey);
- }
- return self['@values'][index] = aValue;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aKey:aKey,aValue:aValue},globals.Dictionary)})},
- args: ["aKey", "aValue"],
- source: "at: aKey put: aValue\x0a\x09<\x0a\x09\x09var index = self._positionOfKey_(aKey);\x0a\x09\x09if(index === -1) {\x0a\x09\x09\x09var keys = self['@keys'];\x0a\x09\x09\x09index = keys.length;\x0a\x09\x09\x09keys.push(aKey);\x0a\x09\x09}\x0a\x0a\x09\x09return self['@values'][index] = aValue;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesKey:",
- protocol: 'testing',
- fn: function (aKey){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self._positionOfKey_(aKey) >= 0; ;
- return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},globals.Dictionary)})},
- args: ["aKey"],
- source: "includesKey: aKey\x0a\x09< return self._positionOfKey_(aKey) >>= 0; >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,aBlock){
- var self=this;
- var index;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- index=_st(self["@values"])._indexOf_ifAbsent_(anObject,(function(){
- return (0);
- }));
- $2=_st(index).__eq((0));
- if(smalltalk.assert($2)){
- $1=_st(aBlock)._value();
- } else {
- $1=_st(self["@keys"])._at_(index);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock,index:index},globals.Dictionary)})},
- args: ["anObject", "aBlock"],
- source: "indexOf: anObject ifAbsent: aBlock\x0a\x09| index |\x0a\x09index := values \x0a\x09\x09indexOf: anObject \x0a\x09\x09ifAbsent: [ 0 ].\x0a\x09^ index = 0 \x0a\x09\x09ifTrue: [ aBlock value ] \x0a\x09\x09ifFalse: [ keys at: index ]",
- messageSends: ["indexOf:ifAbsent:", "ifTrue:ifFalse:", "=", "value", "at:"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.Dictionary.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@keys"]=[];
- self["@values"]=[];
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Dictionary)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09keys := #().\x0a\x09values := #()",
- messageSends: ["initialize"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keys",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@keys"])._copy();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"keys",{},globals.Dictionary)})},
- args: [],
- source: "keys\x0a\x09^ keys copy",
- messageSends: ["copy"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysAndValuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@keys"])._with_do_(self["@values"],aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},globals.Dictionary)})},
- args: ["aBlock"],
- source: "keysAndValuesDo: aBlock\x0a\x09^ keys with: values do: aBlock",
- messageSends: ["with:do:"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@keys"])._do_(aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},globals.Dictionary)})},
- args: ["aBlock"],
- source: "keysDo: aBlock\x0a\x09^ keys do: aBlock",
- messageSends: ["do:"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "positionOfKey:",
- protocol: 'private',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var keys = self['@keys'];
- for(var i=0;i<keys.length;i++){
- if(keys[i].__eq(anObject)) { return i;}
- }
- return -1;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"positionOfKey:",{anObject:anObject},globals.Dictionary)})},
- args: ["anObject"],
- source: "positionOfKey: anObject\x0a\x09<\x0a\x09\x09var keys = self['@keys'];\x0a\x09\x09for(var i=0;i<keys.length;i++){\x0a\x09\x09\x09if(keys[i].__eq(anObject)) { return i;}\x0a\x09\x09}\x0a\x09\x09return -1;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@keys"])._removeAll();
- $ctx1.sendIdx["removeAll"]=1;
- _st(self["@values"])._removeAll();
- return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.Dictionary)})},
- args: [],
- source: "removeAll\x0a\x09keys removeAll.\x0a\x09values removeAll",
- messageSends: ["removeAll"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeKey:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var index = self._positionOfKey_(aKey);
- if(index === -1) {
- return aBlock._value()
- } else {
- var keys = self['@keys'], values = self['@values'];
- var value = values[index], l = keys.length;
- keys[index] = keys[l-1];
- keys.pop();
- values[index] = values[l-1];
- values.pop();
- return value;
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.Dictionary)})},
- args: ["aKey", "aBlock"],
- source: "removeKey: aKey ifAbsent: aBlock\x0a\x09<\x0a\x09\x09var index = self._positionOfKey_(aKey);\x0a\x09\x09if(index === -1) {\x0a\x09\x09\x09return aBlock._value()\x0a\x09\x09} else {\x0a\x09\x09\x09var keys = self['@keys'], values = self['@values'];\x0a\x09\x09\x09var value = values[index], l = keys.length;\x0a\x09\x09\x09keys[index] = keys[l-1];\x0a\x09\x09\x09keys.pop();\x0a\x09\x09\x09values[index] = values[l-1];\x0a\x09\x09\x09values.pop();\x0a\x09\x09\x09return value;\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "values",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@values"];
- return $1;
- },
- args: [],
- source: "values\x0a\x09^ values",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@values"])._do_(aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},globals.Dictionary)})},
- args: ["aBlock"],
- source: "valuesDo: aBlock\x0a\x09^ values do: aBlock",
- messageSends: ["do:"],
- referencedClasses: []
- }),
- globals.Dictionary);
- smalltalk.addClass('HashedCollection', globals.AssociativeCollection, [], 'Kernel-Collections');
- globals.HashedCollection.comment="I am a traditional JavaScript object, or a Smalltalk `Dictionary`.\x0a\x0aUnlike a `Dictionary`, I can only have strings as keys.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._includesKey_(aKey);
- if(smalltalk.assert($2)){
- $1=self._basicAt_(aKey);
- } else {
- $1=_st(aBlock)._value();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.HashedCollection)})},
- args: ["aKey", "aBlock"],
- source: "at: aKey ifAbsent: aBlock\x0a\x09^ (self includesKey: aKey)\x0a\x09\x09ifTrue: [ self basicAt: aKey ]\x0a\x09\x09ifFalse: [ aBlock value ]",
- messageSends: ["ifTrue:ifFalse:", "includesKey:", "basicAt:", "value"],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (aKey,aValue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_put_(aKey,aValue);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:put:",{aKey:aKey,aValue:aValue},globals.HashedCollection)})},
- args: ["aKey", "aValue"],
- source: "at: aKey put: aValue\x0a\x09^ self basicAt: aKey put: aValue",
- messageSends: ["basicAt:put:"],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesKey:",
- protocol: 'testing',
- fn: function (aKey){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.hasOwnProperty(aKey);
- return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},globals.HashedCollection)})},
- args: ["aKey"],
- source: "includesKey: aKey\x0a\x09<return self.hasOwnProperty(aKey)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keys",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Object.keys(self);
- return self}, function($ctx1) {$ctx1.fill(self,"keys",{},globals.HashedCollection)})},
- args: [],
- source: "keys\x0a\x09<return Object.keys(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._keys())._do_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},globals.HashedCollection)})},
- args: ["aBlock"],
- source: "keysDo: aBlock\x0a\x09self keys do: aBlock",
- messageSends: ["do:", "keys"],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeKey:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_ifPresent_ifAbsent_(aKey,(function(removed){
- return smalltalk.withContext(function($ctx2) {
- self._basicDelete_(aKey);
- return removed;
- }, function($ctx2) {$ctx2.fillBlock({removed:removed},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.HashedCollection)})},
- args: ["aKey", "aBlock"],
- source: "removeKey: aKey ifAbsent: aBlock\x0a\x09^ self\x0a\x09\x09at: aKey\x0a\x09\x09ifPresent: [ :removed | self basicDelete: aKey. removed ]\x0a\x09\x09ifAbsent: [ aBlock value ]",
- messageSends: ["at:ifPresent:ifAbsent:", "basicDelete:", "value"],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "values",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self._keys().map(function(key){
- return self._at_(key);
- });
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"values",{},globals.HashedCollection)})},
- args: [],
- source: "values\x0a\x09<\x0a\x09\x09return self._keys().map(function(key){\x0a\x09\x09\x09return self._at_(key);\x0a\x09\x09});\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._values())._do_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},globals.HashedCollection)})},
- args: ["aBlock"],
- source: "valuesDo: aBlock\x0a\x09self values do: aBlock",
- messageSends: ["do:", "values"],
- referencedClasses: []
- }),
- globals.HashedCollection);
- smalltalk.addClass('SequenceableCollection', globals.IndexableCollection, [], 'Kernel-Collections');
- globals.SequenceableCollection.comment="I am an IndexableCollection\x0awith numeric indexes starting with 1.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$4,$1,$5;
- var $early={};
- try {
- $3=self._class();
- $ctx1.sendIdx["class"]=1;
- $2=_st($3).__eq(_st(aCollection)._class());
- $ctx1.sendIdx["="]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $4=self._size();
- $ctx2.sendIdx["size"]=1;
- return _st($4).__eq(_st(aCollection)._size());
- $ctx2.sendIdx["="]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(! smalltalk.assert($1)){
- return false;
- };
- self._withIndexDo_((function(each,i){
- return smalltalk.withContext(function($ctx2) {
- $5=_st(_st(aCollection)._at_(i)).__eq(each);
- if(! smalltalk.assert($5)){
- throw $early=[false];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,3)})}));
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"=",{aCollection:aCollection},globals.SequenceableCollection)})},
- args: ["aCollection"],
- source: "= aCollection\x0a\x09(self class = aCollection class and: [\x0a\x09\x09self size = aCollection size ]) ifFalse: [ ^ false ].\x0a\x09self withIndexDo: [ :each :i |\x0a\x09\x09\x09\x09(aCollection at: i) = each ifFalse: [ ^ false ]].\x0a\x09^ true",
- messageSends: ["ifFalse:", "and:", "=", "class", "size", "withIndexDo:", "at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addLast:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._add_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"addLast:",{anObject:anObject},globals.SequenceableCollection)})},
- args: ["anObject"],
- source: "addLast: anObject\x0a\x09self add: anObject",
- messageSends: ["add:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allButFirst",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._copyFrom_to_((2),self._size());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allButFirst",{},globals.SequenceableCollection)})},
- args: [],
- source: "allButFirst\x0a\x09^ self copyFrom: 2 to: self size",
- messageSends: ["copyFrom:to:", "size"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allButLast",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._copyFrom_to_((1),_st(self._size()).__minus((1)));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allButLast",{},globals.SequenceableCollection)})},
- args: [],
- source: "allButLast\x0a\x09^ self copyFrom: 1 to: self size - 1",
- messageSends: ["copyFrom:to:", "-", "size"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atRandom",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_(_st(self._size())._atRandom());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atRandom",{},globals.SequenceableCollection)})},
- args: [],
- source: "atRandom\x0a\x09^ self at: self size atRandom",
- messageSends: ["at:", "atRandom", "size"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "beginsWith:",
- protocol: 'testing',
- fn: function (prefix){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1,$4;
- $2=self._size();
- $ctx1.sendIdx["size"]=1;
- $3=_st(prefix)._size();
- $ctx1.sendIdx["size"]=2;
- $1=_st($2).__lt($3);
- if(smalltalk.assert($1)){
- return false;
- };
- $4=_st(self._first_(_st(prefix)._size())).__eq(prefix);
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"beginsWith:",{prefix:prefix},globals.SequenceableCollection)})},
- args: ["prefix"],
- source: "beginsWith: prefix\x0a\x09self size < prefix size ifTrue: [ ^ false ].\x0a\x09^ (self first: prefix size) = prefix",
- messageSends: ["ifTrue:", "<", "size", "=", "first:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyFrom:to:",
- protocol: 'copying',
- fn: function (anIndex,anotherIndex){
- var self=this;
- var range,newCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- range=_st(anIndex)._to_(anotherIndex);
- newCollection=_st(self._class())._new_(_st(range)._size());
- _st(range)._withIndexDo_((function(each,i){
- return smalltalk.withContext(function($ctx2) {
- return _st(newCollection)._at_put_(i,self._at_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,1)})}));
- $1=newCollection;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"copyFrom:to:",{anIndex:anIndex,anotherIndex:anotherIndex,range:range,newCollection:newCollection},globals.SequenceableCollection)})},
- args: ["anIndex", "anotherIndex"],
- source: "copyFrom: anIndex to: anotherIndex\x0a\x09| range newCollection |\x0a\x09range := anIndex to: anotherIndex.\x0a\x09newCollection := self class new: range size.\x0a\x09range withIndexDo: [ :each :i |\x0a\x09\x09newCollection at: i put: (self at: each) ].\x0a\x09^ newCollection",
- messageSends: ["to:", "new:", "class", "size", "withIndexDo:", "at:put:", "at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- var newCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- newCollection=_st(self._class())._new_(self._size());
- self._withIndexDo_((function(each,index){
- return smalltalk.withContext(function($ctx2) {
- return _st(newCollection)._at_put_(index,_st(each)._deepCopy());
- }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
- $1=newCollection;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"deepCopy",{newCollection:newCollection},globals.SequenceableCollection)})},
- args: [],
- source: "deepCopy\x0a\x09| newCollection |\x0a\x09newCollection := self class new: self size.\x0a\x09self withIndexDo: [ :each :index |\x0a\x09\x09newCollection at: index put: each deepCopy ].\x0a\x09^ newCollection",
- messageSends: ["new:", "class", "size", "withIndexDo:", "at:put:", "deepCopy"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "detect:ifNone:",
- protocol: 'enumerating',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- for(var i = 0; i < self.length; i++)
- if(aBlock._value_(self[i]))
- return self[i];
- return anotherBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.SequenceableCollection)})},
- args: ["aBlock", "anotherBlock"],
- source: "detect: aBlock ifNone: anotherBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09for(var i = 0; i < self.length; i++)\x0a\x09\x09\x09if(aBlock._value_(self[i]))\x0a\x09\x09\x09\x09return self[i];\x0a\x09\x09return anotherBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- for(var i=0; i < self.length; i++) {
- aBlock._value_(self[i]);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.SequenceableCollection)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09for(var i=0; i < self.length; i++) {\x0a\x09\x09\x09aBlock._value_(self[i]);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "endsWith:",
- protocol: 'testing',
- fn: function (suffix){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1,$4;
- $2=self._size();
- $ctx1.sendIdx["size"]=1;
- $3=_st(suffix)._size();
- $ctx1.sendIdx["size"]=2;
- $1=_st($2).__lt($3);
- if(smalltalk.assert($1)){
- return false;
- };
- $4=_st(self._last_(_st(suffix)._size())).__eq(suffix);
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"endsWith:",{suffix:suffix},globals.SequenceableCollection)})},
- args: ["suffix"],
- source: "endsWith: suffix\x0a\x09self size < suffix size ifTrue: [ ^ false ].\x0a\x09^ (self last: suffix size) = suffix",
- messageSends: ["ifTrue:", "<", "size", "=", "last:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "first",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_((1));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"first",{},globals.SequenceableCollection)})},
- args: [],
- source: "first\x0a\x09^ self at: 1",
- messageSends: ["at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "first:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(self._size()).__lt(aNumber);
- if(smalltalk.assert($1)){
- self._error_("Invalid number of elements");
- };
- $2=self._copyFrom_to_((1),aNumber);
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"first:",{aNumber:aNumber},globals.SequenceableCollection)})},
- args: ["aNumber"],
- source: "first: aNumber\x0a\x09\x22Answer the first `aNumber` elements of the receiver.\x0a\x09Raise an error if there are not enough elements in the receiver.\x22\x0a\x0a\x09self size < aNumber ifTrue: [ self error: 'Invalid number of elements' ].\x0a\x0a\x09^ self copyFrom: 1 to: aNumber",
- messageSends: ["ifTrue:", "<", "size", "error:", "copyFrom:to:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fourth",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_((4));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fourth",{},globals.SequenceableCollection)})},
- args: [],
- source: "fourth\x0a\x09^ self at: 4",
- messageSends: ["at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includes:",
- protocol: 'testing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._indexOf_ifAbsent_(anObject,(function(){
- return nil;
- })))._notNil();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},globals.SequenceableCollection)})},
- args: ["anObject"],
- source: "includes: anObject\x0a\x09^ (self indexOf: anObject ifAbsent: [ nil ]) notNil",
- messageSends: ["notNil", "indexOf:ifAbsent:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- for(var i=0; i < self.length; i++) {
- if(_st(self[i]).__eq(anObject)) {return i+1}
- };
- return aBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},globals.SequenceableCollection)})},
- args: ["anObject", "aBlock"],
- source: "indexOf: anObject ifAbsent: aBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09for(var i=0; i < self.length; i++) {\x0a\x09\x09\x09if(_st(self[i]).__eq(anObject)) {return i+1}\x0a\x09\x09};\x0a\x09\x09return aBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:startingAt:",
- protocol: 'accessing',
- fn: function (anObject,start){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._indexOf_startingAt_ifAbsent_(anObject,start,(function(){
- return (0);
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"indexOf:startingAt:",{anObject:anObject,start:start},globals.SequenceableCollection)})},
- args: ["anObject", "start"],
- source: "indexOf: anObject startingAt: start\x0a\x09\x22Answer the index of the first occurence of anElement after start\x0a\x09within the receiver. If the receiver does not contain anElement,\x0a\x09answer 0.\x22\x0a\x09^ self indexOf: anObject startingAt: start ifAbsent: [ 0 ]",
- messageSends: ["indexOf:startingAt:ifAbsent:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "indexOf:startingAt:ifAbsent:",
- protocol: 'accessing',
- fn: function (anObject,start,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- for(var i=start - 1; i < self.length; i++){
- if(_st(self[i]).__eq(anObject)) {return i+1}
- }
- return aBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"indexOf:startingAt:ifAbsent:",{anObject:anObject,start:start,aBlock:aBlock},globals.SequenceableCollection)})},
- args: ["anObject", "start", "aBlock"],
- source: "indexOf: anObject startingAt: start ifAbsent: aBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09for(var i=start - 1; i < self.length; i++){\x0a\x09\x09\x09if(_st(self[i]).__eq(anObject)) {return i+1}\x0a\x09\x09}\x0a\x09\x09return aBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "last",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_(self._size());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"last",{},globals.SequenceableCollection)})},
- args: [],
- source: "last\x0a\x09^ self at: self size",
- messageSends: ["at:", "size"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "last:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$6,$5,$4,$3;
- $2=self._size();
- $ctx1.sendIdx["size"]=1;
- $1=_st($2).__lt(aNumber);
- if(smalltalk.assert($1)){
- self._error_("Invalid number of elements");
- };
- $6=self._size();
- $ctx1.sendIdx["size"]=2;
- $5=_st($6).__minus(aNumber);
- $4=_st($5).__plus((1));
- $3=self._copyFrom_to_($4,self._size());
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"last:",{aNumber:aNumber},globals.SequenceableCollection)})},
- args: ["aNumber"],
- source: "last: aNumber\x0a\x09\x22Answer the last aNumber elements of the receiver.\x0a\x09Raise an error if there are not enough elements in the receiver.\x22\x0a\x0a\x09self size < aNumber ifTrue: [ self error: 'Invalid number of elements' ].\x0a\x0a\x09^ self copyFrom: self size - aNumber + 1 to: self size",
- messageSends: ["ifTrue:", "<", "size", "error:", "copyFrom:to:", "+", "-"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newStream",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._streamClass())._on_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newStream",{},globals.SequenceableCollection)})},
- args: [],
- source: "newStream\x0a\x09^ self streamClass on: self",
- messageSends: ["on:", "streamClass"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numericallyIndexable",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"numericallyIndexable",{},globals.SequenceableCollection)})},
- args: [],
- source: "numericallyIndexable\x0a\x09\x22This is an internal converting message.\x0a\x09It answeres a representation of the receiver\x0a\x09that can use foo[i] in JavaScript code.\x0a\x09\x0a\x09It fixes IE8, where boxed String is unable\x0a\x09to numerically index its characters,\x0a\x09but primitive string can.\x22\x0a\x09\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "readStream",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"readStream",{},globals.SequenceableCollection)})},
- args: [],
- source: "readStream\x0a\x09\x22For Pharo compatibility\x22\x0a\x09\x0a\x09^ self stream",
- messageSends: ["stream"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeLast",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._remove_(self._last());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"removeLast",{},globals.SequenceableCollection)})},
- args: [],
- source: "removeLast\x0a\x09^ self remove: self last",
- messageSends: ["remove:", "last"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reversed",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},globals.SequenceableCollection)})},
- args: [],
- source: "reversed\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "second",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_((2));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"second",{},globals.SequenceableCollection)})},
- args: [],
- source: "second\x0a\x09^ self at: 2",
- messageSends: ["at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- var newCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- newCollection=_st(self._class())._new_(self._size());
- self._withIndexDo_((function(each,index){
- return smalltalk.withContext(function($ctx2) {
- return _st(newCollection)._at_put_(index,each);
- }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
- $1=newCollection;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{newCollection:newCollection},globals.SequenceableCollection)})},
- args: [],
- source: "shallowCopy\x0a\x09| newCollection |\x0a\x09newCollection := self class new: self size.\x0a\x09self withIndexDo: [ :each :index |\x0a\x09\x09newCollection at: index put: each ].\x0a\x09^ newCollection",
- messageSends: ["new:", "class", "size", "withIndexDo:", "at:put:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stream",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newStream();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"stream",{},globals.SequenceableCollection)})},
- args: [],
- source: "stream\x0a\x09^ self newStream",
- messageSends: ["newStream"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "streamClass",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._streamClass();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"streamClass",{},globals.SequenceableCollection)})},
- args: [],
- source: "streamClass\x0a\x09^ self class streamClass",
- messageSends: ["streamClass", "class"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "third",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._at_((3));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"third",{},globals.SequenceableCollection)})},
- args: [],
- source: "third\x0a\x09^ self at: 3",
- messageSends: ["at:"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:do:",
- protocol: 'enumerating',
- fn: function (anotherCollection,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- anotherCollection = anotherCollection._numericallyIndexable();
- for(var i=0; i<self.length; i++) {
- aBlock._value_value_(self[i], anotherCollection[i]);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anotherCollection:anotherCollection,aBlock:aBlock},globals.SequenceableCollection)})},
- args: ["anotherCollection", "aBlock"],
- source: "with: anotherCollection do: aBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09anotherCollection = anotherCollection._numericallyIndexable();\x0a\x09\x09for(var i=0; i<self.length; i++) {\x0a\x09\x09\x09aBlock._value_value_(self[i], anotherCollection[i]);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withIndexDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self = self._numericallyIndexable();
- for(var i=0; i < self.length; i++) {
- aBlock._value_value_(self[i], i+1);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},globals.SequenceableCollection)})},
- args: ["aBlock"],
- source: "withIndexDo: aBlock\x0a\x09<\x0a\x09\x09self = self._numericallyIndexable();\x0a\x09\x09for(var i=0; i < self.length; i++) {\x0a\x09\x09\x09aBlock._value_value_(self[i], i+1);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "writeStream",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"writeStream",{},globals.SequenceableCollection)})},
- args: [],
- source: "writeStream\x0a\x09\x22For Pharo compatibility\x22\x0a\x09\x0a\x09^ self stream",
- messageSends: ["stream"],
- referencedClasses: []
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "streamClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Stream(){return globals.Stream||(typeof Stream=="undefined"?nil:Stream)}
- return $Stream();
- },
- args: [],
- source: "streamClass\x0a\x09\x09^ Stream",
- messageSends: [],
- referencedClasses: ["Stream"]
- }),
- globals.SequenceableCollection.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "streamContents:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- var stream;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- stream=_st(self._streamClass())._on_(self._new());
- _st(aBlock)._value_(stream);
- $1=_st(stream)._contents();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"streamContents:",{aBlock:aBlock,stream:stream},globals.SequenceableCollection.klass)})},
- args: ["aBlock"],
- source: "streamContents: aBlock\x0a\x09| stream |\x0a\x09stream := (self streamClass on: self new).\x0a\x09aBlock value: stream.\x0a\x09^ stream contents",
- messageSends: ["on:", "streamClass", "new", "value:", "contents"],
- referencedClasses: []
- }),
- globals.SequenceableCollection.klass);
- smalltalk.addClass('Array', globals.SequenceableCollection, [], 'Kernel-Collections');
- globals.Array.comment="I represent a collection of objects ordered by the collector. The size of arrays is dynamic.\x0a\x0aI am directly mapped to JavaScript Number.\x0a\x0a*Note* In Amber, `OrderedCollection` is an alias for `Array`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.push(anObject); return anObject;;
- return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},globals.Array)})},
- args: ["anObject"],
- source: "add: anObject\x0a\x09<self.push(anObject); return anObject;>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addFirst:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.unshift(anObject); return anObject;;
- return self}, function($ctx1) {$ctx1.fill(self,"addFirst:",{anObject:anObject},globals.Array)})},
- args: ["anObject"],
- source: "addFirst: anObject\x0a\x09<self.unshift(anObject); return anObject;>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("[".__comma(_st(self._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._asJavascript();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._join_(", "))).__comma("]");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.Array)})},
- args: [],
- source: "asJavascript\x0a\x09^ '[', ((self collect: [:each | each asJavascript ]) join: ', '), ']'",
- messageSends: [",", "join:", "collect:", "asJavascript"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return anIndex >= 1 && anIndex <= self.length
- ? self[anIndex - 1]
- : aBlock._value()
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},globals.Array)})},
- args: ["anIndex", "aBlock"],
- source: "at: anIndex ifAbsent: aBlock\x0a\x09<\x0a\x09\x09return anIndex >>= 1 && anIndex <= self.length\x0a\x09\x09\x09? self[anIndex - 1]\x0a\x09\x09\x09: aBlock._value()\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return anIndex >= 1 && anIndex <= self.length
- ? aBlock._value_(self[anIndex - 1])
- : anotherBlock._value()
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},globals.Array)})},
- args: ["anIndex", "aBlock", "anotherBlock"],
- source: "at: anIndex ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09<\x0a\x09\x09return anIndex >>= 1 && anIndex <= self.length\x0a\x09\x09\x09? aBlock._value_(self[anIndex - 1])\x0a\x09\x09\x09: anotherBlock._value()\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (anIndex,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self[anIndex - 1] = anObject;
- return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},globals.Array)})},
- args: ["anIndex", "anObject"],
- source: "at: anIndex put: anObject\x0a\x09<return self[anIndex - 1] = anObject>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "collect:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.map(function(each) {return aBlock._value_(each)});
- return self}, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock},globals.Array)})},
- args: ["aBlock"],
- source: "collect: aBlock\x0a\x09\x22Optimized version\x22\x0a\x09\x0a\x09<return self.map(function(each) {return aBlock._value_(each)})>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "join:",
- protocol: 'enumerating',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.join(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"join:",{aString:aString},globals.Array)})},
- args: ["aString"],
- source: "join: aString\x0a\x09<return self.join(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numericallyIndexable",
- protocol: 'private',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "numericallyIndexable\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.Array.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- $ctx1.sendIdx["printOn:"]=1;
- _st(aStream)._nextPutAll_(" (");
- $ctx1.sendIdx["nextPutAll:"]=1;
- self._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._printOn_(aStream);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(aStream)._nextPutAll_(" ");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Array)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09\x0a\x09aStream nextPutAll: ' ('.\x0a\x09self \x0a\x09\x09do: [ :each | each printOn: aStream ]\x0a\x09\x09separatedBy: [ aStream nextPutAll: ' ' ].\x0a\x09aStream nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (anObject,aBlock){
- var self=this;
- var index;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- index=self._indexOf_ifAbsent_(anObject,(function(){
- return (0);
- }));
- $2=_st(index).__eq((0));
- if(smalltalk.assert($2)){
- $1=_st(aBlock)._value();
- } else {
- self._removeIndex_(index);
- $1=anObject;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock,index:index},globals.Array)})},
- args: ["anObject", "aBlock"],
- source: "remove: anObject ifAbsent: aBlock\x0a\x09| index |\x0a\x09index := self indexOf: anObject ifAbsent: [ 0 ].\x0a\x09^ index = 0\x0a\x09\x09ifFalse: [ self removeIndex: index. anObject ]\x0a\x09\x09ifTrue: [ aBlock value ]",
- messageSends: ["indexOf:ifAbsent:", "ifFalse:ifTrue:", "=", "removeIndex:", "value"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.length = 0;
- return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.Array)})},
- args: [],
- source: "removeAll\x0a\x09<self.length = 0>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeFrom:to:",
- protocol: 'adding/removing',
- fn: function (aNumber,anotherNumber){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.splice(aNumber -1, anotherNumber - aNumber + 1);
- return self}, function($ctx1) {$ctx1.fill(self,"removeFrom:to:",{aNumber:aNumber,anotherNumber:anotherNumber},globals.Array)})},
- args: ["aNumber", "anotherNumber"],
- source: "removeFrom: aNumber to: anotherNumber\x0a\x09<self.splice(aNumber -1, anotherNumber - aNumber + 1)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeIndex:",
- protocol: 'adding/removing',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.splice(anInteger - 1, 1);
- return self}, function($ctx1) {$ctx1.fill(self,"removeIndex:",{anInteger:anInteger},globals.Array)})},
- args: ["anInteger"],
- source: "removeIndex: anInteger\x0a\x09<self.splice(anInteger - 1, 1)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeLast",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.pop();;
- return self}, function($ctx1) {$ctx1.fill(self,"removeLast",{},globals.Array)})},
- args: [],
- source: "removeLast\x0a\x09<return self.pop();>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reversed",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self._copy().reverse();
- return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},globals.Array)})},
- args: [],
- source: "reversed\x0a\x09<return self._copy().reverse()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "select:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var result = self.klass._new();
- for(var i=0; i<self.length; i++) {
- if(aBlock._value_(self[i])) {
- result.push(self[i]);
- }
- }
- return result;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock},globals.Array)})},
- args: ["aBlock"],
- source: "select: aBlock\x0a\x09\x22Optimized version\x22\x0a\x09\x0a\x09<\x0a\x09\x09var result = self.klass._new();\x0a\x09\x09for(var i=0; i<self.length; i++) {\x0a\x09\x09\x09if(aBlock._value_(self[i])) {\x0a\x09\x09\x09\x09result.push(self[i]);\x0a\x09\x09\x09}\x0a\x09\x09}\x0a\x09\x09return result;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.length;
- return self}, function($ctx1) {$ctx1.fill(self,"size",{},globals.Array)})},
- args: [],
- source: "size\x0a\x09<return self.length>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sort",
- protocol: 'enumerating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._sort_((function(a,b){
- return smalltalk.withContext(function($ctx2) {
- return _st(a).__lt(b);
- }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sort",{},globals.Array)})},
- args: [],
- source: "sort\x0a\x09^ self sort: [ :a :b | a < b ]",
- messageSends: ["sort:", "<"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sort:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.sort(function(a, b) {
- if(aBlock._value_value_(a,b)) {return -1} else {return 1}
- })
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"sort:",{aBlock:aBlock},globals.Array)})},
- args: ["aBlock"],
- source: "sort: aBlock\x0a\x09<\x0a\x09\x09return self.sort(function(a, b) {\x0a\x09\x09\x09if(aBlock._value_value_(a,b)) {return -1} else {return 1}\x0a\x09\x09})\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sorted",
- protocol: 'enumerating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._copy())._sort();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sorted",{},globals.Array)})},
- args: [],
- source: "sorted\x0a\x09^ self copy sort",
- messageSends: ["sort", "copy"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sorted:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._copy())._sort_(aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sorted:",{aBlock:aBlock},globals.Array)})},
- args: ["aBlock"],
- source: "sorted: aBlock\x0a\x09^ self copy sort: aBlock",
- messageSends: ["sort:", "copy"],
- referencedClasses: []
- }),
- globals.Array);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new:",
- protocol: 'instance creation',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new Array(anInteger);
- return self}, function($ctx1) {$ctx1.fill(self,"new:",{anInteger:anInteger},globals.Array.klass)})},
- args: ["anInteger"],
- source: "new: anInteger\x0a\x09<return new Array(anInteger)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Array.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:",
- protocol: 'instance creation',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new_((1));
- _st($2)._at_put_((1),anObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:",{anObject:anObject},globals.Array.klass)})},
- args: ["anObject"],
- source: "with: anObject\x0a\x09\x09^ (self new: 1)\x0a\x09\x09at: 1 put: anObject;\x0a\x09\x09yourself",
- messageSends: ["at:put:", "new:", "yourself"],
- referencedClasses: []
- }),
- globals.Array.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:with:",
- protocol: 'instance creation',
- fn: function (anObject,anObject2){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new_((2));
- _st($2)._at_put_((1),anObject);
- $ctx1.sendIdx["at:put:"]=1;
- _st($2)._at_put_((2),anObject2);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:with:",{anObject:anObject,anObject2:anObject2},globals.Array.klass)})},
- args: ["anObject", "anObject2"],
- source: "with: anObject with: anObject2\x0a\x09\x09^ (self new: 2)\x0a\x09\x09at: 1 put: anObject;\x0a\x09\x09at: 2 put: anObject2;\x0a\x09\x09yourself",
- messageSends: ["at:put:", "new:", "yourself"],
- referencedClasses: []
- }),
- globals.Array.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "with:with:with:",
- protocol: 'instance creation',
- fn: function (anObject,anObject2,anObject3){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new_((3));
- _st($2)._at_put_((1),anObject);
- $ctx1.sendIdx["at:put:"]=1;
- _st($2)._at_put_((2),anObject2);
- $ctx1.sendIdx["at:put:"]=2;
- _st($2)._at_put_((3),anObject3);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"with:with:with:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.Array.klass)})},
- args: ["anObject", "anObject2", "anObject3"],
- source: "with: anObject with: anObject2 with: anObject3\x0a\x09\x09^ (self new: 3)\x0a\x09\x09at: 1 put: anObject;\x0a\x09\x09at: 2 put: anObject2;\x0a\x09\x09at: 3 put: anObject3;\x0a\x09\x09yourself",
- messageSends: ["at:put:", "new:", "yourself"],
- referencedClasses: []
- }),
- globals.Array.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withAll:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- var instance,index;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- index=(1);
- instance=self._new_(_st(aCollection)._size());
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- _st(instance)._at_put_(index,each);
- index=_st(index).__plus((1));
- return index;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=instance;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"withAll:",{aCollection:aCollection,instance:instance,index:index},globals.Array.klass)})},
- args: ["aCollection"],
- source: "withAll: aCollection\x0a\x09| instance index |\x0a\x09index := 1.\x0a\x09instance := self new: aCollection size.\x0a\x09aCollection do: [ :each |\x0a\x09\x09instance at: index put: each.\x0a\x09\x09index := index + 1 ].\x0a\x09^ instance",
- messageSends: ["new:", "size", "do:", "at:put:", "+"],
- referencedClasses: []
- }),
- globals.Array.klass);
- smalltalk.addClass('CharacterArray', globals.SequenceableCollection, [], 'Kernel-Collections');
- globals.CharacterArray.comment="I am the abstract superclass of string-like collections.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: ",",
- protocol: 'copying',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._asString();
- $ctx1.sendIdx["asString"]=1;
- $1=_st($2).__comma(_st(aString)._asString());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,",",{aString:aString},globals.CharacterArray)})},
- args: ["aString"],
- source: ", aString\x0a\x09^ self asString, aString asString",
- messageSends: [",", "asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._errorReadOnly();
- return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},globals.CharacterArray)})},
- args: ["anObject"],
- source: "add: anObject\x0a\x09self errorReadOnly",
- messageSends: ["errorReadOnly"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asLowercase",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._fromString_(_st(self._asString())._asLowercase());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asLowercase",{},globals.CharacterArray)})},
- args: [],
- source: "asLowercase\x0a\x09^ self class fromString: self asString asLowercase",
- messageSends: ["fromString:", "class", "asLowercase", "asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asNumber",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asString())._asNumber();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asNumber",{},globals.CharacterArray)})},
- args: [],
- source: "asNumber\x0a\x09^ self asString asNumber",
- messageSends: ["asNumber", "asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._subclassResponsibility();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.CharacterArray)})},
- args: [],
- source: "asString\x0a\x09^ self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSymbol",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._asString();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asSymbol",{},globals.CharacterArray)})},
- args: [],
- source: "asSymbol\x0a\x09^ self asString",
- messageSends: ["asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asUppercase",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._fromString_(_st(self._asString())._asUppercase());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asUppercase",{},globals.CharacterArray)})},
- args: [],
- source: "asUppercase\x0a\x09^ self class fromString: self asString asUppercase",
- messageSends: ["fromString:", "class", "asUppercase", "asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (anIndex,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._errorReadOnly();
- return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},globals.CharacterArray)})},
- args: ["anIndex", "anObject"],
- source: "at: anIndex put: anObject\x0a\x09self errorReadOnly",
- messageSends: ["errorReadOnly"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "errorReadOnly",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._error_("Object is read-only");
- return self}, function($ctx1) {$ctx1.fill(self,"errorReadOnly",{},globals.CharacterArray)})},
- args: [],
- source: "errorReadOnly\x0a\x09self error: 'Object is read-only'",
- messageSends: ["error:"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._asString())._printOn_(aStream);
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.CharacterArray)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09self asString printOn: aStream",
- messageSends: ["printOn:", "asString"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "putOn:",
- protocol: 'streaming',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutString_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},globals.CharacterArray)})},
- args: ["aStream"],
- source: "putOn: aStream\x0a\x09aStream nextPutString: self",
- messageSends: ["nextPutString:"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._errorReadOnly();
- return self}, function($ctx1) {$ctx1.fill(self,"remove:",{anObject:anObject},globals.CharacterArray)})},
- args: ["anObject"],
- source: "remove: anObject\x0a\x09self errorReadOnly",
- messageSends: ["errorReadOnly"],
- referencedClasses: []
- }),
- globals.CharacterArray);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromString:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},globals.CharacterArray.klass)})},
- args: ["aString"],
- source: "fromString: aString\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.CharacterArray.klass);
- smalltalk.addClass('String', globals.CharacterArray, [], 'Kernel-Collections');
- globals.String.comment="I am an indexed collection of Characters. Unlike most Smalltalk dialects, Amber doesn't provide the Character class. Instead, elements of a String are single character strings.\x0a\x0aString inherits many useful methods from its hierarchy, such as\x0a\x09`Collection >> #,`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: ",",
- protocol: 'copying',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) + aString;
- return self}, function($ctx1) {$ctx1.fill(self,",",{aString:aString},globals.String)})},
- args: ["aString"],
- source: ", aString\x0a\x09<return String(self) + aString>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) < aString._asString();
- return self}, function($ctx1) {$ctx1.fill(self,"<",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "< aString\x0a\x09<return String(self) < aString._asString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<=",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) <= aString._asString();
- return self}, function($ctx1) {$ctx1.fill(self,"<=",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "<= aString\x0a\x09<return String(self) <= aString._asString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return aString != null &&
- typeof aString._isString === "function" &&
- aString._isString() &&
- String(self) === String(aString)
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"=",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "= aString\x0a\x09<\x0a\x09\x09return aString != null &&\x0a\x09\x09\x09typeof aString._isString === \x22function\x22 &&\x0a\x09\x09\x09aString._isString() &&\x0a\x09\x09\x09String(self) === String(aString)\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "==",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__eq(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"==",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "== aString\x0a\x09^ self = aString",
- messageSends: ["="],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) > aString._asString();
- return self}, function($ctx1) {$ctx1.fill(self,">",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "> aString\x0a\x09<return String(self) >> aString._asString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: ">=",
- protocol: 'comparing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self) >= aString._asString();
- return self}, function($ctx1) {$ctx1.fill(self,">=",{aString:aString},globals.String)})},
- args: ["aString"],
- source: ">= aString\x0a\x09<return String(self) >>= aString._asString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asJSON\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavascript",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if(self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1)
- return "\"" + self.replace(/[\x00-\x1f"\\\x7f-\x9f]/g, function(ch){var c=ch.charCodeAt(0);return "\\x"+("0"+c.toString(16)).slice(-2)}) + "\"";
- else
- return "\"" + self + "\"";
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"asJavascript",{},globals.String)})},
- args: [],
- source: "asJavascript\x0a\x09<\x0a\x09\x09if(self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1)\x0a\x09\x09\x09return \x22\x5c\x22\x22 + self.replace(/[\x5cx00-\x5cx1f\x22\x5c\x5c\x5cx7f-\x5cx9f]/g, function(ch){var c=ch.charCodeAt(0);return \x22\x5c\x5cx\x22+(\x220\x22+c.toString(16)).slice(-2)}) + \x22\x5c\x22\x22;\x0a\x09\x09else\x0a\x09\x09\x09return \x22\x5c\x22\x22 + self + \x22\x5c\x22\x22;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asLowercase",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toLowerCase();
- return self}, function($ctx1) {$ctx1.fill(self,"asLowercase",{},globals.String)})},
- args: [],
- source: "asLowercase\x0a\x09<return self.toLowerCase()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asMutator",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(self._last()).__eq(":");
- if(! smalltalk.assert($1)){
- $2=self.__comma(":");
- return $2;
- };
- return self;
- }, function($ctx1) {$ctx1.fill(self,"asMutator",{},globals.String)})},
- args: [],
- source: "asMutator\x0a\x09\x22Answer a setter selector. For example,\x0a\x09#name asMutator returns #name:\x22\x0a\x0a\x09self last = ':' ifFalse: [ ^ self, ':' ].\x0a\x09^ self",
- messageSends: ["ifFalse:", "=", "last", ","],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asNumber",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Number(self);
- return self}, function($ctx1) {$ctx1.fill(self,"asNumber",{},globals.String)})},
- args: [],
- source: "asNumber\x0a\x09<return Number(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asRegexp",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $RegularExpression(){return globals.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($RegularExpression())._fromString_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asRegexp",{},globals.String)})},
- args: [],
- source: "asRegexp\x0a\x09^ RegularExpression fromString: self",
- messageSends: ["fromString:"],
- referencedClasses: ["RegularExpression"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSelector",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.selector(self);
- return self}, function($ctx1) {$ctx1.fill(self,"asSelector",{},globals.String)})},
- args: [],
- source: "asSelector\x0a\x09<return smalltalk.selector(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asString",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asString\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSymbol",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "asSymbol\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asUppercase",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.toUpperCase();
- return self}, function($ctx1) {$ctx1.fill(self,"asUppercase",{},globals.String)})},
- args: [],
- source: "asUppercase\x0a\x09<return self.toUpperCase()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asciiValue",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.charCodeAt(0);;
- return self}, function($ctx1) {$ctx1.fill(self,"asciiValue",{},globals.String)})},
- args: [],
- source: "asciiValue\x0a\x09<return self.charCodeAt(0);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self)[anIndex - 1] || aBlock._value();
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},globals.String)})},
- args: ["anIndex", "aBlock"],
- source: "at: anIndex ifAbsent: aBlock\x0a\x09<return String(self)[anIndex - 1] || aBlock._value()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:ifAbsent:",
- protocol: 'accessing',
- fn: function (anIndex,aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var result = String(self)[anIndex - 1];
- return result ? aBlock._value_(result) : anotherBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},globals.String)})},
- args: ["anIndex", "aBlock", "anotherBlock"],
- source: "at: anIndex ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09<\x0a\x09\x09var result = String(self)[anIndex - 1];\x0a\x09\x09return result ? aBlock._value_(result) : anotherBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "capitalized",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._isEmpty();
- if(smalltalk.assert($2)){
- $1=self;
- } else {
- $1=_st(_st(self._first())._asUppercase()).__comma(self._allButFirst());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"capitalized",{},globals.String)})},
- args: [],
- source: "capitalized\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self first asUppercase, self allButFirst ]",
- messageSends: ["ifTrue:ifFalse:", "isEmpty", ",", "asUppercase", "first", "allButFirst"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "charCodeAt:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.charCodeAt(anInteger - 1);
- return self}, function($ctx1) {$ctx1.fill(self,"charCodeAt:",{anInteger:anInteger},globals.String)})},
- args: ["anInteger"],
- source: "charCodeAt: anInteger\x0a\x09<return self.charCodeAt(anInteger - 1)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyFrom:to:",
- protocol: 'copying',
- fn: function (anIndex,anotherIndex){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.substring(anIndex - 1, anotherIndex);
- return self}, function($ctx1) {$ctx1.fill(self,"copyFrom:to:",{anIndex:anIndex,anotherIndex:anotherIndex},globals.String)})},
- args: ["anIndex", "anotherIndex"],
- source: "copyFrom: anIndex to: anotherIndex\x0a\x09<return self.substring(anIndex - 1, anotherIndex)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "crlfSanitized",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._lines())._join_(_st($String())._lf());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"crlfSanitized",{},globals.String)})},
- args: [],
- source: "crlfSanitized\x0a\x09^ self lines join: String lf",
- messageSends: ["join:", "lines", "lf"],
- referencedClasses: ["String"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deepCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._shallowCopy();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"deepCopy",{},globals.String)})},
- args: [],
- source: "deepCopy\x0a\x09^ self shallowCopy",
- messageSends: ["shallowCopy"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "escaped",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return escape(self);
- return self}, function($ctx1) {$ctx1.fill(self,"escaped",{},globals.String)})},
- args: [],
- source: "escaped\x0a\x09<return escape(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "identityHash",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self.__comma("s");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"identityHash",{},globals.String)})},
- args: [],
- source: "identityHash\x0a\x09^ self, 's'",
- messageSends: [","],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesSubString:",
- protocol: 'testing',
- fn: function (subString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.indexOf(subString) != -1;
- return self}, function($ctx1) {$ctx1.fill(self,"includesSubString:",{subString:subString},globals.String)})},
- args: ["subString"],
- source: "includesSubString: subString\x0a\x09<return self.indexOf(subString) != -1>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCapitalized",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $3=self._first();
- $ctx1.sendIdx["first"]=1;
- $2=_st($3)._asUppercase();
- $1=_st($2).__eq_eq(self._first());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isCapitalized",{},globals.String)})},
- args: [],
- source: "isCapitalized\x0a\x09^ self first asUppercase == self first",
- messageSends: ["==", "asUppercase", "first"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isString",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isString\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVowel",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._size()).__eq((1)))._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return "aeiou"._includes_(self._asLowercase());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isVowel",{},globals.String)})},
- args: [],
- source: "isVowel\x0a\x09\x22Answer true if the receiver is a one character string containing a voyel\x22\x0a\x09\x0a\x09^ self size = 1 and: [ 'aeiou' includes: self asLowercase ]",
- messageSends: ["and:", "=", "size", "includes:", "asLowercase"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "join:",
- protocol: 'split join',
- fn: function (aCollection){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- return _st(aCollection)._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(_st(each)._asString());
- $ctx3.sendIdx["nextPutAll:"]=1;
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(stream)._nextPutAll_(self);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"join:",{aCollection:aCollection},globals.String)})},
- args: ["aCollection"],
- source: "join: aCollection\x0a\x09^ String\x0a\x09\x09streamContents: [ :stream | aCollection\x0a\x09\x09\x09\x09do: [ :each | stream nextPutAll: each asString ]\x0a\x09\x09\x09\x09separatedBy: [ stream nextPutAll: self ]]",
- messageSends: ["streamContents:", "do:separatedBy:", "nextPutAll:", "asString"],
- referencedClasses: ["String"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lineIndicesDo:",
- protocol: 'split join',
- fn: function (aBlock){
- var self=this;
- var cr,lf,start,sz,nextLF,nextCR;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$5,$3,$6,$7,$9,$8,$10,$11;
- var $early={};
- try {
- start=(1);
- sz=self._size();
- cr=_st($String())._cr();
- nextCR=self._indexOf_startingAt_(cr,(1));
- $ctx1.sendIdx["indexOf:startingAt:"]=1;
- lf=_st($String())._lf();
- nextLF=self._indexOf_startingAt_(lf,(1));
- $ctx1.sendIdx["indexOf:startingAt:"]=2;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(start).__lt_eq(sz);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(nextLF).__eq((0));
- $ctx2.sendIdx["="]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(nextCR).__eq((0));
- $ctx3.sendIdx["="]=2;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- $ctx2.sendIdx["and:"]=1;
- if(smalltalk.assert($1)){
- _st(aBlock)._value_value_value_(start,sz,sz);
- $ctx2.sendIdx["value:value:value:"]=1;
- throw $early=[self];
- };
- $4=_st(nextCR).__eq((0));
- $ctx2.sendIdx["="]=3;
- $3=_st($4)._or_((function(){
- return smalltalk.withContext(function($ctx3) {
- $5=(0).__lt(nextLF);
- $ctx3.sendIdx["<"]=1;
- return _st($5)._and_((function(){
- return smalltalk.withContext(function($ctx4) {
- return _st(nextLF).__lt(nextCR);
- }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)})}));
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
- if(smalltalk.assert($3)){
- $6=start;
- $7=_st(nextLF).__minus((1));
- $ctx2.sendIdx["-"]=1;
- _st(aBlock)._value_value_value_($6,$7,nextLF);
- $ctx2.sendIdx["value:value:value:"]=2;
- start=(1).__plus(nextLF);
- $ctx2.sendIdx["+"]=1;
- start;
- nextLF=self._indexOf_startingAt_(lf,start);
- $ctx2.sendIdx["indexOf:startingAt:"]=3;
- return nextLF;
- } else {
- $9=(1).__plus(nextCR);
- $ctx2.sendIdx["+"]=2;
- $8=_st($9).__eq(nextLF);
- if(smalltalk.assert($8)){
- $10=start;
- $11=_st(nextCR).__minus((1));
- $ctx2.sendIdx["-"]=2;
- _st(aBlock)._value_value_value_($10,$11,nextLF);
- $ctx2.sendIdx["value:value:value:"]=3;
- start=(1).__plus(nextLF);
- $ctx2.sendIdx["+"]=3;
- start;
- nextCR=self._indexOf_startingAt_(cr,start);
- $ctx2.sendIdx["indexOf:startingAt:"]=4;
- nextCR;
- nextLF=self._indexOf_startingAt_(lf,start);
- $ctx2.sendIdx["indexOf:startingAt:"]=5;
- return nextLF;
- } else {
- _st(aBlock)._value_value_value_(start,_st(nextCR).__minus((1)),nextCR);
- start=(1).__plus(nextCR);
- start;
- nextCR=self._indexOf_startingAt_(cr,start);
- return nextCR;
- };
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"lineIndicesDo:",{aBlock:aBlock,cr:cr,lf:lf,start:start,sz:sz,nextLF:nextLF,nextCR:nextCR},globals.String)})},
- args: ["aBlock"],
- source: "lineIndicesDo: aBlock\x0a\x09\x22execute aBlock with 3 arguments for each line:\x0a\x09- start index of line\x0a\x09- end index of line without line delimiter\x0a\x09- end index of line including line delimiter(s) CR, LF or CRLF\x22\x0a\x09\x0a\x09| cr lf start sz nextLF nextCR |\x0a\x09start := 1.\x0a\x09sz := self size.\x0a\x09cr := String cr.\x0a\x09nextCR := self indexOf: cr startingAt: 1.\x0a\x09lf := String lf.\x0a\x09nextLF := self indexOf: lf startingAt: 1.\x0a\x09[ start <= sz ] whileTrue: [ \x0a\x09\x09(nextLF = 0 and: [ nextCR = 0 ])\x0a\x09\x09\x09ifTrue: [ \x22No more CR, nor LF, the string is over\x22\x0a\x09\x09\x09\x09\x09aBlock value: start value: sz value: sz.\x0a\x09\x09\x09\x09\x09^ self ].\x0a\x09\x09(nextCR = 0 or: [ 0 < nextLF and: [ nextLF < nextCR ] ])\x0a\x09\x09\x09ifTrue: [ \x22Found a LF\x22\x0a\x09\x09\x09\x09\x09aBlock value: start value: nextLF - 1 value: nextLF.\x0a\x09\x09\x09\x09\x09start := 1 + nextLF.\x0a\x09\x09\x09\x09\x09nextLF := self indexOf: lf startingAt: start ]\x0a\x09\x09\x09ifFalse: [ 1 + nextCR = nextLF\x0a\x09\x09\x09\x09ifTrue: [ \x22Found a CR-LF pair\x22\x0a\x09\x09\x09\x09\x09aBlock value: start value: nextCR - 1 value: nextLF.\x0a\x09\x09\x09\x09\x09start := 1 + nextLF.\x0a\x09\x09\x09\x09\x09nextCR := self indexOf: cr startingAt: start.\x0a\x09\x09\x09\x09\x09nextLF := self indexOf: lf startingAt: start ]\x0a\x09\x09\x09\x09ifFalse: [ \x22Found a CR\x22\x0a\x09\x09\x09\x09\x09aBlock value: start value: nextCR - 1 value: nextCR.\x0a\x09\x09\x09\x09\x09start := 1 + nextCR.\x0a\x09\x09\x09\x09\x09nextCR := self indexOf: cr startingAt: start ] ]]",
- messageSends: ["size", "cr", "indexOf:startingAt:", "lf", "whileTrue:", "<=", "ifTrue:", "and:", "=", "value:value:value:", "ifTrue:ifFalse:", "or:", "<", "-", "+"],
- referencedClasses: ["String"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lineNumber:",
- protocol: 'split join',
- fn: function (anIndex){
- var self=this;
- var lineCount;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3;
- var $early={};
- try {
- lineCount=(0);
- self._lineIndicesDo_((function(start,endWithoutDelimiters,end){
- return smalltalk.withContext(function($ctx2) {
- lineCount=_st(lineCount).__plus((1));
- $2=lineCount;
- $1=_st($2).__eq(anIndex);
- if(smalltalk.assert($1)){
- $3=self._copyFrom_to_(start,endWithoutDelimiters);
- throw $early=[$3];
- };
- }, function($ctx2) {$ctx2.fillBlock({start:start,endWithoutDelimiters:endWithoutDelimiters,end:end},$ctx1,1)})}));
- return nil;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"lineNumber:",{anIndex:anIndex,lineCount:lineCount},globals.String)})},
- args: ["anIndex"],
- source: "lineNumber: anIndex\x0a\x09\x22Answer a string containing the characters in the given line number.\x22\x0a\x0a\x09| lineCount |\x0a\x09lineCount := 0.\x0a\x09self lineIndicesDo: [ :start :endWithoutDelimiters :end |\x0a\x09\x09(lineCount := lineCount + 1) = anIndex ifTrue: [ ^ self copyFrom: start to: endWithoutDelimiters ]].\x0a\x09^ nil",
- messageSends: ["lineIndicesDo:", "ifTrue:", "=", "+", "copyFrom:to:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lines",
- protocol: 'split join',
- fn: function (){
- var self=this;
- var lines;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- lines=_st($Array())._new();
- self._linesDo_((function(aLine){
- return smalltalk.withContext(function($ctx2) {
- return _st(lines)._add_(aLine);
- }, function($ctx2) {$ctx2.fillBlock({aLine:aLine},$ctx1,1)})}));
- $1=lines;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"lines",{lines:lines},globals.String)})},
- args: [],
- source: "lines\x0a\x09\x22Answer an array of lines composing this receiver without the line ending delimiters.\x22\x0a\x0a\x09| lines |\x0a\x09lines := Array new.\x0a\x09self linesDo: [ :aLine | lines add: aLine ].\x0a\x09^ lines",
- messageSends: ["new", "linesDo:", "add:"],
- referencedClasses: ["Array"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "linesDo:",
- protocol: 'split join',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._lineIndicesDo_((function(start,endWithoutDelimiters,end){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_(self._copyFrom_to_(start,endWithoutDelimiters));
- }, function($ctx2) {$ctx2.fillBlock({start:start,endWithoutDelimiters:endWithoutDelimiters,end:end},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"linesDo:",{aBlock:aBlock},globals.String)})},
- args: ["aBlock"],
- source: "linesDo: aBlock\x0a\x09\x22Execute aBlock with each line in this string. The terminating line\x0a\x09delimiters CR, LF or CRLF pairs are not included in what is passed to aBlock\x22\x0a\x0a\x09self lineIndicesDo: [ :start :endWithoutDelimiters :end |\x0a\x09\x09aBlock value: (self copyFrom: start to: endWithoutDelimiters) ]",
- messageSends: ["lineIndicesDo:", "value:", "copyFrom:to:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "match:",
- protocol: 'regular expressions',
- fn: function (aRegexp){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.search(aRegexp) != -1;
- return self}, function($ctx1) {$ctx1.fill(self,"match:",{aRegexp:aRegexp},globals.String)})},
- args: ["aRegexp"],
- source: "match: aRegexp\x0a\x09<return self.search(aRegexp) != -1>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "matchesOf:",
- protocol: 'regular expressions',
- fn: function (aRegularExpression){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.match(aRegularExpression);
- return self}, function($ctx1) {$ctx1.fill(self,"matchesOf:",{aRegularExpression:aRegularExpression},globals.String)})},
- args: ["aRegularExpression"],
- source: "matchesOf: aRegularExpression\x0a\x09<return self.match(aRegularExpression)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numericallyIndexable",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(self);
- return self}, function($ctx1) {$ctx1.fill(self,"numericallyIndexable",{},globals.String)})},
- args: [],
- source: "numericallyIndexable\x0a\x09<return String(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printNl",
- protocol: 'printing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- console.log(self);
- return self}, function($ctx1) {$ctx1.fill(self,"printNl",{},globals.String)})},
- args: [],
- source: "printNl\x0a\x09<console.log(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aStream)._nextPutAll_("'");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self);
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_("'");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.String)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream \x0a\x09\x09nextPutAll: '''';\x0a\x09\x09nextPutAll: self;\x0a\x09\x09nextPutAll: ''''",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "replace:with:",
- protocol: 'regular expressions',
- fn: function (aString,anotherString){
- var self=this;
- function $RegularExpression(){return globals.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._replaceRegexp_with_(_st($RegularExpression())._fromString_flag_(aString,"g"),anotherString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"replace:with:",{aString:aString,anotherString:anotherString},globals.String)})},
- args: ["aString", "anotherString"],
- source: "replace: aString with: anotherString\x0a\x09^ self replaceRegexp: (RegularExpression fromString: aString flag: 'g') with: anotherString",
- messageSends: ["replaceRegexp:with:", "fromString:flag:"],
- referencedClasses: ["RegularExpression"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "replaceRegexp:with:",
- protocol: 'regular expressions',
- fn: function (aRegexp,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.replace(aRegexp, aString);
- return self}, function($ctx1) {$ctx1.fill(self,"replaceRegexp:with:",{aRegexp:aRegexp,aString:aString},globals.String)})},
- args: ["aRegexp", "aString"],
- source: "replaceRegexp: aRegexp with: aString\x0a\x09<return self.replace(aRegexp, aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reversed",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.split("").reverse().join("");
- return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},globals.String)})},
- args: [],
- source: "reversed\x0a\x09<return self.split(\x22\x22).reverse().join(\x22\x22)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shallowCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._fromString_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{},globals.String)})},
- args: [],
- source: "shallowCopy\x0a\x09^ self class fromString: self",
- messageSends: ["fromString:", "class"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.length;
- return self}, function($ctx1) {$ctx1.fill(self,"size",{},globals.String)})},
- args: [],
- source: "size\x0a\x09<return self.length>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subStrings:",
- protocol: 'split join',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._tokenize_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subStrings:",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "subStrings: aString\x0a\x09^ self tokenize: aString",
- messageSends: ["tokenize:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "tokenize:",
- protocol: 'split join',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.split(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"tokenize:",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "tokenize: aString\x0a\x09<return self.split(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimBoth",
- protocol: 'regular expressions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._trimBoth_("\x5cs");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimBoth",{},globals.String)})},
- args: [],
- source: "trimBoth\x0a\x09^ self trimBoth: '\x5cs'",
- messageSends: ["trimBoth:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimBoth:",
- protocol: 'regular expressions',
- fn: function (separators){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._trimLeft_(separators))._trimRight_(separators);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimBoth:",{separators:separators},globals.String)})},
- args: ["separators"],
- source: "trimBoth: separators\x0a\x09^ (self trimLeft: separators) trimRight: separators",
- messageSends: ["trimRight:", "trimLeft:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimLeft",
- protocol: 'regular expressions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._trimLeft_("\x5cs");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimLeft",{},globals.String)})},
- args: [],
- source: "trimLeft\x0a\x09^ self trimLeft: '\x5cs'",
- messageSends: ["trimLeft:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimLeft:",
- protocol: 'regular expressions',
- fn: function (separators){
- var self=this;
- function $RegularExpression(){return globals.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $3=_st("^[".__comma(separators)).__comma("]+");
- $ctx1.sendIdx[","]=1;
- $2=_st($RegularExpression())._fromString_flag_($3,"g");
- $1=self._replaceRegexp_with_($2,"");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimLeft:",{separators:separators},globals.String)})},
- args: ["separators"],
- source: "trimLeft: separators\x0a\x09^ self replaceRegexp: (RegularExpression fromString: '^[', separators, ']+' flag: 'g') with: ''",
- messageSends: ["replaceRegexp:with:", "fromString:flag:", ","],
- referencedClasses: ["RegularExpression"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimRight",
- protocol: 'regular expressions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._trimRight_("\x5cs");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimRight",{},globals.String)})},
- args: [],
- source: "trimRight\x0a\x09^ self trimRight: '\x5cs'",
- messageSends: ["trimRight:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "trimRight:",
- protocol: 'regular expressions',
- fn: function (separators){
- var self=this;
- function $RegularExpression(){return globals.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $3=_st("[".__comma(separators)).__comma("]+$");
- $ctx1.sendIdx[","]=1;
- $2=_st($RegularExpression())._fromString_flag_($3,"g");
- $1=self._replaceRegexp_with_($2,"");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"trimRight:",{separators:separators},globals.String)})},
- args: ["separators"],
- source: "trimRight: separators\x0a\x09^ self replaceRegexp: (RegularExpression fromString: '[', separators, ']+$' flag: 'g') with: ''",
- messageSends: ["replaceRegexp:with:", "fromString:flag:", ","],
- referencedClasses: ["RegularExpression"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "unescaped",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return unescape(self);
- return self}, function($ctx1) {$ctx1.fill(self,"unescaped",{},globals.String)})},
- args: [],
- source: "unescaped\x0a\x09<return unescape(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "uriComponentDecoded",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return decodeURIComponent(self);
- return self}, function($ctx1) {$ctx1.fill(self,"uriComponentDecoded",{},globals.String)})},
- args: [],
- source: "uriComponentDecoded\x0a\x09<return decodeURIComponent(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "uriComponentEncoded",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return encodeURIComponent(self);
- return self}, function($ctx1) {$ctx1.fill(self,"uriComponentEncoded",{},globals.String)})},
- args: [],
- source: "uriComponentEncoded\x0a\x09<return encodeURIComponent(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "uriDecoded",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return decodeURI(self);
- return self}, function($ctx1) {$ctx1.fill(self,"uriDecoded",{},globals.String)})},
- args: [],
- source: "uriDecoded\x0a\x09<return decodeURI(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "uriEncoded",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return encodeURI(self);
- return self}, function($ctx1) {$ctx1.fill(self,"uriEncoded",{},globals.String)})},
- args: [],
- source: "uriEncoded\x0a\x09<return encodeURI(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cr",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return '\r';
- return self}, function($ctx1) {$ctx1.fill(self,"cr",{},globals.String.klass)})},
- args: [],
- source: "cr\x0a\x09<return '\x5cr'>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "crlf",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return '\r\n';
- return self}, function($ctx1) {$ctx1.fill(self,"crlf",{},globals.String.klass)})},
- args: [],
- source: "crlf\x0a\x09<return '\x5cr\x5cn'>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "esc",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._fromCharCode_((27));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"esc",{},globals.String.klass)})},
- args: [],
- source: "esc\x0a\x09^ self fromCharCode: 27",
- messageSends: ["fromCharCode:"],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromCharCode:",
- protocol: 'instance creation',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String.fromCharCode(anInteger);
- return self}, function($ctx1) {$ctx1.fill(self,"fromCharCode:",{anInteger:anInteger},globals.String.klass)})},
- args: ["anInteger"],
- source: "fromCharCode: anInteger\x0a\x09<return String.fromCharCode(anInteger)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromString:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},globals.String.klass)})},
- args: ["aString"],
- source: "fromString: aString\x0a\x09\x09<return String(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lf",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return '\n';
- return self}, function($ctx1) {$ctx1.fill(self,"lf",{},globals.String.klass)})},
- args: [],
- source: "lf\x0a\x09<return '\x5cn'>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "random",
- protocol: 'random',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return (Math.random()*(22/32)+(10/32)).toString(32).slice(2);;
- return self}, function($ctx1) {$ctx1.fill(self,"random",{},globals.String.klass)})},
- args: [],
- source: "random\x0a\x09\x22Returns random alphanumeric string beginning with letter\x22\x0a\x09<return (Math.random()*(22/32)+(10/32)).toString(32).slice(2);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "randomNotIn:",
- protocol: 'random',
- fn: function (aString){
- var self=this;
- var result;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- result=self._random();
- result;
- return _st(aString)._includesSubString_(result);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue();
- $1=result;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"randomNotIn:",{aString:aString,result:result},globals.String.klass)})},
- args: ["aString"],
- source: "randomNotIn: aString\x0a\x09| result |\x0a\x09[ result := self random. aString includesSubString: result ] whileTrue.\x0a\x09^ result",
- messageSends: ["whileTrue", "random", "includesSubString:"],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "space",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return ' ';
- return self}, function($ctx1) {$ctx1.fill(self,"space",{},globals.String.klass)})},
- args: [],
- source: "space\x0a\x09<return ' '>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "streamClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $StringStream(){return globals.StringStream||(typeof StringStream=="undefined"?nil:StringStream)}
- return $StringStream();
- },
- args: [],
- source: "streamClass\x0a\x09\x09^ StringStream",
- messageSends: [],
- referencedClasses: ["StringStream"]
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "tab",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return '\t';
- return self}, function($ctx1) {$ctx1.fill(self,"tab",{},globals.String.klass)})},
- args: [],
- source: "tab\x0a\x09<return '\x5ct'>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'instance creation',
- fn: function (aUTFCharCode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return String.fromCharCode(aUTFCharCode);;
- return self}, function($ctx1) {$ctx1.fill(self,"value:",{aUTFCharCode:aUTFCharCode},globals.String.klass)})},
- args: ["aUTFCharCode"],
- source: "value: aUTFCharCode\x0a\x0a\x09<return String.fromCharCode(aUTFCharCode);>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.String.klass);
- smalltalk.addClass('Set', globals.Collection, ['defaultBucket', 'slowBucketStores', 'fastBuckets', 'size'], 'Kernel-Collections');
- globals.Set.comment="I represent an unordered set of objects without duplicates.\x0a\x0a## Implementation notes\x0a\x0aI put elements into different stores based on their type.\x0aThe goal is to store some elements into native JS object property names to be fast.\x0a\x0aIf an unboxed element has typeof 'string', 'boolean' or 'number', or an element is nil, null or undefined,\x0aI store it as a property name in an empty (== Object.create(null)) JS object, different for each type\x0a(for simplicity, nil/null/undefined is treated as one and included with the two booleans).\x0a\x0aIf element happen to be an object, I try to store them in `ArrayBucketStore`. I have two of them by default,\x0aone hashed using the Smalltalk class name, the other one using the JS constructor name. It is possible to have more or less\x0ainstances of `ArrayBucketStores`, see `#initializeSlowBucketStores`.\x0a\x0aAs a last resort, if none of the `ArrayBucketStore` instances can find a suitable bucket, the `defaultBucket` is used,\x0awhich is an `Array`.\x0a";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5;
- var $early={};
- try {
- $2=self._class();
- $ctx1.sendIdx["class"]=1;
- $1=_st($2).__eq(_st(aCollection)._class());
- $ctx1.sendIdx["="]=1;
- if(! smalltalk.assert($1)){
- return false;
- };
- $4=self._size();
- $ctx1.sendIdx["size"]=1;
- $3=_st($4).__eq(_st(aCollection)._size());
- if(! smalltalk.assert($3)){
- return false;
- };
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $5=_st(aCollection)._includes_(each);
- if(! smalltalk.assert($5)){
- throw $early=[false];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"=",{aCollection:aCollection},globals.Set)})},
- args: ["aCollection"],
- source: "= aCollection\x0a\x09self class = aCollection class ifFalse: [ ^ false ].\x0a\x09self size = aCollection size ifFalse: [ ^ false ].\x0a\x09self do: [ :each | (aCollection includes: each) ifFalse: [ ^ false ] ].\x0a\x09^ true",
- messageSends: ["ifFalse:", "=", "class", "size", "do:", "includes:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'adding/removing',
- fn: function (anObject){
- var self=this;
- var bucket;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- bucket=self._bucketsOfElement_(anObject);
- $2=_st(bucket)._second();
- if(($receiver = $2) == nil || $receiver == null){
- var object,slowBucket;
- object=_st(bucket)._first();
- $ctx1.sendIdx["first"]=1;
- object;
- slowBucket=_st(bucket)._third();
- slowBucket;
- _st(slowBucket)._indexOf_ifAbsent_(object,(function(){
- return smalltalk.withContext(function($ctx2) {
- _st(slowBucket)._add_(object);
- self["@size"]=_st(self["@size"]).__plus((1));
- return self["@size"];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $1=object;
- } else {
- var primitiveBucket;
- primitiveBucket=$receiver;
- $1=self._add_in_(_st(bucket)._first(),primitiveBucket);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject,bucket:bucket},globals.Set)})},
- args: ["anObject"],
- source: "add: anObject\x0a\x09| bucket |\x0a\x09bucket := self bucketsOfElement: anObject.\x0a\x09^ bucket second\x0a\x09\x09ifNil: [\x0a\x09\x09\x09| object slowBucket |\x0a\x09\x09\x09object := bucket first.\x0a\x09\x09\x09slowBucket := bucket third.\x0a\x09\x09\x09slowBucket \x0a\x09\x09\x09\x09indexOf: object \x0a\x09\x09\x09\x09ifAbsent: [ \x0a\x09\x09\x09\x09\x09slowBucket add: object. \x0a\x09\x09\x09\x09\x09size := size + 1 ].\x0a\x09\x09\x09object ]\x0a\x09\x09ifNotNil: [ :primitiveBucket | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09add: bucket first \x0a\x09\x09\x09\x09in: primitiveBucket ]",
- messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "first", "third", "indexOf:ifAbsent:", "add:", "+", "add:in:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:in:",
- protocol: 'private',
- fn: function (anObject,anotherObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if (anObject in anotherObject.store) { return false; }
- self['@size']++;
- return anotherObject.store[anObject] = true;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"add:in:",{anObject:anObject,anotherObject:anotherObject},globals.Set)})},
- args: ["anObject", "anotherObject"],
- source: "add: anObject in: anotherObject\x0a\x09<\x0a\x09\x09if (anObject in anotherObject.store) { return false; }\x0a\x09\x09self['@size']++;\x0a\x09\x09return anotherObject.store[anObject] = true;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "bucketsOfElement:",
- protocol: 'private',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var type, bucket, prim = anObject == null ? (anObject = nil) : anObject.valueOf();
- if ((type = typeof prim) === "object") {
- if (anObject !== nil) {
- bucket = null;
- self['@slowBucketStores'].some(function (store) {
- return bucket = store._bucketOfElement_(anObject);
- });
- return [ anObject, null, bucket || self['@defaultBucket'] ];
- }
-
- // include nil to well-known objects under 'boolean' fastBucket
- prim = null;
- type = 'boolean';
- }
- return [ prim, self['@fastBuckets'][type] ];
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"bucketsOfElement:",{anObject:anObject},globals.Set)})},
- args: ["anObject"],
- source: "bucketsOfElement: anObject\x0a\x09\x22Find the appropriate bucket for `anObject`.\x0a\x09For optimization purposes, directly answer an array with: \x0a\x09- the object to be store\x0a\x09- the primitive bucket\x0a\x09- the slow bucket\x22\x0a\x09\x0a\x09<\x0a\x09\x09var type, bucket, prim = anObject == null ? (anObject = nil) : anObject.valueOf();\x0a\x09\x09if ((type = typeof prim) === \x22object\x22) {\x0a\x09\x09\x09if (anObject !== nil) {\x0a\x09\x09\x09\x09bucket = null;\x0a\x09\x09\x09\x09self['@slowBucketStores'].some(function (store) {\x0a\x09\x09\x09\x09\x09return bucket = store._bucketOfElement_(anObject);\x0a\x09\x09\x09\x09});\x0a\x09\x09\x09\x09return [ anObject, null, bucket || self['@defaultBucket'] ];\x0a\x09\x09\x09}\x0a\x09\x09\x09\x0a\x09\x09\x09// include nil to well-known objects under 'boolean' fastBucket\x0a\x09\x09\x09prim = null;\x0a\x09\x09\x09type = 'boolean';\x0a\x09\x09}\x0a\x09\x09return [ prim, self['@fastBuckets'][type] ];\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classNameOf:",
- protocol: 'private',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return anObject.klass && anObject.klass.className;
- return self}, function($ctx1) {$ctx1.fill(self,"classNameOf:",{anObject:anObject},globals.Set)})},
- args: ["anObject"],
- source: "classNameOf: anObject\x0a\x09\x22Answer the class name of `anObject`, or `undefined` \x0a\x09if `anObject` is not an Smalltalk object\x22\x0a\x09\x0a\x09<return anObject.klass && anObject.klass.className>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "collect:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var collection;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- collection=_st(self._class())._new();
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(collection)._add_(_st(aBlock)._value_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=collection;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,collection:collection},globals.Set)})},
- args: ["aBlock"],
- source: "collect: aBlock\x0a\x09| collection |\x0a\x09collection := self class new.\x0a\x09self do: [ :each | collection add: (aBlock value: each) ].\x0a\x09^ collection",
- messageSends: ["new", "class", "do:", "add:", "value:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "detect:ifNone:",
- protocol: 'enumerating',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(each);
- if(smalltalk.assert($1)){
- throw $early=[each];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=_st(anotherBlock)._value();
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.Set)})},
- args: ["aBlock", "anotherBlock"],
- source: "detect: aBlock ifNone: anotherBlock\x0a\x09self do: [ :each | (aBlock value: each) ifTrue: [ ^each ] ].\x0a\x09^ anotherBlock value",
- messageSends: ["do:", "ifTrue:", "value:", "value"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var el, keys, i;
- el = self['@fastBuckets'];
- keys = Object.keys(el);
- for (i = 0; i < keys.length; ++i) {
- var fastBucket = el[keys[i]], fn = fastBucket.fn, store = Object.keys(fastBucket.store);
- if (fn) { for (var j = 0; j < store.length; ++j) { aBlock._value_(fn(store[j])); } }
- else { store._do_(aBlock); }
- }
- el = self['@slowBucketStores'];
- for (i = 0; i < el.length; ++i) { el[i]._do_(aBlock); }
- self['@defaultBucket']._do_(aBlock);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.Set)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09<\x0a\x09\x09var el, keys, i;\x0a\x09\x09el = self['@fastBuckets'];\x0a\x09\x09keys = Object.keys(el);\x0a\x09\x09for (i = 0; i < keys.length; ++i) {\x0a\x09\x09\x09var fastBucket = el[keys[i]], fn = fastBucket.fn, store = Object.keys(fastBucket.store);\x0a\x09\x09\x09if (fn) { for (var j = 0; j < store.length; ++j) { aBlock._value_(fn(store[j])); } }\x0a\x09\x09\x09else { store._do_(aBlock); }\x0a\x09\x09}\x0a\x09\x09el = self['@slowBucketStores'];\x0a\x09\x09for (i = 0; i < el.length; ++i) { el[i]._do_(aBlock); }\x0a\x09\x09self['@defaultBucket']._do_(aBlock);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includes:",
- protocol: 'testing',
- fn: function (anObject){
- var self=this;
- var bucket;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$1;
- bucket=self._bucketsOfElement_(anObject);
- $2=_st(bucket)._second();
- if(($receiver = $2) == nil || $receiver == null){
- $3=_st(bucket)._third();
- $4=_st(bucket)._first();
- $ctx1.sendIdx["first"]=1;
- $1=_st($3)._includes_($4);
- } else {
- var primitiveBucket;
- primitiveBucket=$receiver;
- $1=self._includes_in_(_st(bucket)._first(),primitiveBucket);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject,bucket:bucket},globals.Set)})},
- args: ["anObject"],
- source: "includes: anObject\x0a\x09| bucket |\x0a\x09bucket := self bucketsOfElement: anObject.\x0a\x09^ bucket second\x0a\x09\x09ifNil: [ bucket third includes: bucket first ]\x0a\x09\x09ifNotNil: [ :primitiveBucket | self includes: bucket first in: primitiveBucket ]",
- messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "includes:", "third", "first", "includes:in:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includes:in:",
- protocol: 'private',
- fn: function (anObject,anotherObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return anObject in anotherObject.store;
- return self}, function($ctx1) {$ctx1.fill(self,"includes:in:",{anObject:anObject,anotherObject:anotherObject},globals.Set)})},
- args: ["anObject", "anotherObject"],
- source: "includes: anObject in: anotherObject\x0a\x09<return anObject in anotherObject.store>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.Set.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@defaultBucket"]=[];
- self._initializeSlowBucketStores();
- $1=self._removeAll();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Set)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09defaultBucket := #().\x0a\x09self\x0a\x09\x09initializeSlowBucketStores;\x0a\x09\x09removeAll",
- messageSends: ["initialize", "initializeSlowBucketStores", "removeAll"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeSlowBucketStores",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $ArrayBucketStore(){return globals.ArrayBucketStore||(typeof ArrayBucketStore=="undefined"?nil:ArrayBucketStore)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($ArrayBucketStore())._hashBlock_((function(x){
- return smalltalk.withContext(function($ctx2) {
- return self._classNameOf_(x);
- }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})}));
- $ctx1.sendIdx["hashBlock:"]=1;
- self["@slowBucketStores"]=[$1,_st($ArrayBucketStore())._hashBlock_((function(x){
- return smalltalk.withContext(function($ctx2) {
- return self._jsConstructorNameOf_(x);
- }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,2)})}))];
- return self}, function($ctx1) {$ctx1.fill(self,"initializeSlowBucketStores",{},globals.Set)})},
- args: [],
- source: "initializeSlowBucketStores\x0a\x09slowBucketStores := {\x0a\x09\x09ArrayBucketStore hashBlock: [ :x | self classNameOf: x ].\x0a\x09\x09ArrayBucketStore hashBlock: [ :x | self jsConstructorNameOf: x ]\x0a\x09}",
- messageSends: ["hashBlock:", "classNameOf:", "jsConstructorNameOf:"],
- referencedClasses: ["ArrayBucketStore"]
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "jsConstructorNameOf:",
- protocol: 'private',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return anObject.constructor && anObject.constructor.name;
- return self}, function($ctx1) {$ctx1.fill(self,"jsConstructorNameOf:",{anObject:anObject},globals.Set)})},
- args: ["anObject"],
- source: "jsConstructorNameOf: anObject\x0a\x09<return anObject.constructor && anObject.constructor.name>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.Set.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- $ctx1.sendIdx["printOn:"]=1;
- _st(aStream)._nextPutAll_(" (");
- $ctx1.sendIdx["nextPutAll:"]=1;
- self._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._printOn_(aStream);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(aStream)._nextPutAll_(" ");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Set)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09\x0a\x09aStream nextPutAll: ' ('.\x0a\x09self \x0a\x09\x09do: [ :each | each printOn: aStream ]\x0a\x09\x09separatedBy: [ aStream nextPutAll: ' ' ].\x0a\x09aStream nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:ifAbsent:",
- protocol: 'adding/removing',
- fn: function (anObject,aBlock){
- var self=this;
- var bucket;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$5,$1;
- var $early={};
- try {
- bucket=self._bucketsOfElement_(anObject);
- $2=_st(bucket)._second();
- if(($receiver = $2) == nil || $receiver == null){
- $3=_st(bucket)._third();
- $4=_st(bucket)._first();
- $ctx1.sendIdx["first"]=1;
- _st($3)._remove_ifAbsent_($4,(function(){
- return smalltalk.withContext(function($ctx2) {
- $5=_st(aBlock)._value();
- throw $early=[$5];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- self["@size"]=_st(self["@size"]).__minus((1));
- $1=self["@size"];
- } else {
- var primitiveBucket;
- primitiveBucket=$receiver;
- $1=self._remove_in_(_st(bucket)._first(),primitiveBucket);
- };
- return $1;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock,bucket:bucket},globals.Set)})},
- args: ["anObject", "aBlock"],
- source: "remove: anObject ifAbsent: aBlock\x0a\x09| bucket |\x0a\x09bucket := self bucketsOfElement: anObject.\x0a\x09^ bucket second\x0a\x09\x09ifNil: [ bucket third remove: bucket first ifAbsent: [ ^aBlock value ]. size := size - 1 ]\x0a\x09\x09ifNotNil: [ :primitiveBucket | self remove: bucket first in: primitiveBucket ]",
- messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "remove:ifAbsent:", "third", "first", "value", "-", "remove:in:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:in:",
- protocol: 'private',
- fn: function (anObject,anotherObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- if (delete anotherObject.store[anObject]) self['@size']--;
- return self}, function($ctx1) {$ctx1.fill(self,"remove:in:",{anObject:anObject,anotherObject:anotherObject},globals.Set)})},
- args: ["anObject", "anotherObject"],
- source: "remove: anObject in: anotherObject\x0a\x09<if (delete anotherObject.store[anObject]) self['@size']-->",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeAll",
- protocol: 'adding/removing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self['@fastBuckets'] = {
- 'boolean': { store: Object.create(null), fn: function (x) { return {'true': true, 'false': false, 'null': null}[x]; } },
- 'number': { store: Object.create(null), fn: Number },
- 'string': { store: Object.create(null) }
- };
- self['@slowBucketStores'].forEach(function (x) { x._removeAll(); });
- self['@defaultBucket']._removeAll();
- self['@size'] = 0;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},globals.Set)})},
- args: [],
- source: "removeAll\x0a\x09<\x0a\x09\x09self['@fastBuckets'] = {\x0a\x09\x09\x09'boolean': { store: Object.create(null), fn: function (x) { return {'true': true, 'false': false, 'null': null}[x]; } },\x0a\x09\x09\x09'number': { store: Object.create(null), fn: Number },\x0a\x09\x09\x09'string': { store: Object.create(null) }\x0a\x09\x09};\x0a\x09\x09self['@slowBucketStores'].forEach(function (x) { x._removeAll(); });\x0a\x09\x09self['@defaultBucket']._removeAll();\x0a\x09\x09self['@size'] = 0;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "select:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- var collection;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- collection=_st(self._class())._new();
- self._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(aBlock)._value_(each);
- if(smalltalk.assert($1)){
- return _st(collection)._add_(each);
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=collection;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,collection:collection},globals.Set)})},
- args: ["aBlock"],
- source: "select: aBlock\x0a\x09| collection |\x0a\x09collection := self class new.\x0a\x09self do: [ :each |\x0a\x09\x09(aBlock value: each) ifTrue: [\x0a\x09\x09\x09collection add: each ] ].\x0a\x09^ collection",
- messageSends: ["new", "class", "do:", "ifTrue:", "value:", "add:"],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@size"];
- return $1;
- },
- args: [],
- source: "size\x0a\x09^ size",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Set);
- smalltalk.addClass('Queue', globals.Object, ['read', 'readIndex', 'write'], 'Kernel-Collections');
- globals.Queue.comment="I am a one-sided queue.\x0a\x0a## Usage\x0a\x0aUse `#nextPut:` to add items to the queue.\x0aUse `#next` or `#nextIfAbsent:` to get (and remove) the next item in the queue.\x0a\x0a## Implementation notes\x0a\x0aA Queue uses two OrderedCollections inside,\x0a`read` is at the front, is not modified and only read using `readIndex`.\x0a`write` is at the back and is appended new items.\x0aWhen `read` is exhausted, `write` is promoted to `read` and new `write` is created.\x0a\x0aAs a consequence, no data moving is done by me, write appending may do data moving\x0awhen growing `write`, but this is left to engine to implement as good as it chooses to.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- globals.Queue.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@read"]=_st($OrderedCollection())._new();
- $ctx1.sendIdx["new"]=1;
- self["@write"]=_st($OrderedCollection())._new();
- self["@readIndex"]=(1);
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Queue)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09read := OrderedCollection new.\x0a\x09write := OrderedCollection new.\x0a\x09readIndex := 1",
- messageSends: ["initialize", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.Queue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._nextIfAbsent_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Cannot read from empty Queue.");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"next",{},globals.Queue)})},
- args: [],
- source: "next\x0a\x09^ self nextIfAbsent: [ self error: 'Cannot read from empty Queue.' ]",
- messageSends: ["nextIfAbsent:", "error:"],
- referencedClasses: []
- }),
- globals.Queue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextIfAbsent:",
- protocol: 'accessing',
- fn: function (aBlock){
- var self=this;
- var result;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- var $early={};
- try {
- result=_st(self["@read"])._at_ifAbsent_(self["@readIndex"],(function(){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(self["@write"])._isEmpty();
- if(smalltalk.assert($1)){
- $2=_st(self["@readIndex"]).__gt((1));
- if(smalltalk.assert($2)){
- self["@read"]=[];
- self["@read"];
- self["@readIndex"]=(1);
- self["@readIndex"];
- };
- $3=_st(aBlock)._value();
- throw $early=[$3];
- };
- self["@read"]=self["@write"];
- self["@read"];
- self["@readIndex"]=(1);
- self["@readIndex"];
- self["@write"]=_st($OrderedCollection())._new();
- self["@write"];
- return _st(self["@read"])._first();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- _st(self["@read"])._at_put_(self["@readIndex"],nil);
- self["@readIndex"]=_st(self["@readIndex"]).__plus((1));
- $4=result;
- return $4;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"nextIfAbsent:",{aBlock:aBlock,result:result},globals.Queue)})},
- args: ["aBlock"],
- source: "nextIfAbsent: aBlock\x0a\x09| result |\x0a\x09result := read at: readIndex ifAbsent: [\x0a\x09\x09write isEmpty ifTrue: [\x0a\x09\x09\x09readIndex > 1 ifTrue: [ read := #(). readIndex := 1 ].\x0a\x09\x09\x09^ aBlock value ].\x0a\x09\x09read := write.\x0a\x09\x09readIndex := 1.\x0a\x09\x09write := OrderedCollection new.\x0a\x09\x09read first ].\x0a\x09read at: readIndex put: nil.\x0a\x09readIndex := readIndex + 1.\x0a\x09^ result",
- messageSends: ["at:ifAbsent:", "ifTrue:", "isEmpty", ">", "value", "new", "first", "at:put:", "+"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.Queue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPut:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@write"])._add_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{anObject:anObject},globals.Queue)})},
- args: ["anObject"],
- source: "nextPut: anObject\x0a\x09write add: anObject",
- messageSends: ["add:"],
- referencedClasses: []
- }),
- globals.Queue);
- smalltalk.addClass('RegularExpression', globals.Object, [], 'Kernel-Collections');
- globals.RegularExpression.comment="I represent a regular expression object. My instances are JavaScript `RegExp` object.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compile:",
- protocol: 'evaluating',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.compile(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},globals.RegularExpression)})},
- args: ["aString"],
- source: "compile: aString\x0a\x09<return self.compile(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.RegularExpression);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "exec:",
- protocol: 'evaluating',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.exec(aString) || nil;
- return self}, function($ctx1) {$ctx1.fill(self,"exec:",{aString:aString},globals.RegularExpression)})},
- args: ["aString"],
- source: "exec: aString\x0a\x09<return self.exec(aString) || nil>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.RegularExpression);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "test:",
- protocol: 'evaluating',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.test(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"test:",{aString:aString},globals.RegularExpression)})},
- args: ["aString"],
- source: "test: aString\x0a\x09<return self.test(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.RegularExpression);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromString:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._fromString_flag_(aString,"");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},globals.RegularExpression.klass)})},
- args: ["aString"],
- source: "fromString: aString\x0a\x09\x09^ self fromString: aString flag: ''",
- messageSends: ["fromString:flag:"],
- referencedClasses: []
- }),
- globals.RegularExpression.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromString:flag:",
- protocol: 'instance creation',
- fn: function (aString,anotherString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return new RegExp(aString, anotherString);
- return self}, function($ctx1) {$ctx1.fill(self,"fromString:flag:",{aString:aString,anotherString:anotherString},globals.RegularExpression.klass)})},
- args: ["aString", "anotherString"],
- source: "fromString: aString flag: anotherString\x0a\x09<return new RegExp(aString, anotherString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.RegularExpression.klass);
- smalltalk.addClass('Stream', globals.Object, ['collection', 'position', 'streamSize'], 'Kernel-Collections');
- globals.Stream.comment="I represent an accessor for a sequence of objects. This sequence is referred to as my \x22contents\x22.\x0aMy instances are read/write streams to the contents sequence collection.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "<<",
- protocol: 'writing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._write_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"<<",{anObject:anObject},globals.Stream)})},
- args: ["anObject"],
- source: "<< anObject\x0a\x09self write: anObject",
- messageSends: ["write:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atEnd",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._position()).__eq(self._size());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atEnd",{},globals.Stream)})},
- args: [],
- source: "atEnd\x0a\x09^ self position = self size",
- messageSends: ["=", "position", "size"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atStart",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._position()).__eq((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atStart",{},globals.Stream)})},
- args: [],
- source: "atStart\x0a\x09^ self position = 0",
- messageSends: ["=", "position"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "close",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "close",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "collection",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@collection"];
- return $1;
- },
- args: [],
- source: "collection\x0a\x09^ collection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "contents",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._collection())._copyFrom_to_((1),self._streamSize());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"contents",{},globals.Stream)})},
- args: [],
- source: "contents\x0a\x09^ self collection\x0a\x09\x09copyFrom: 1\x0a\x09\x09to: self streamSize",
- messageSends: ["copyFrom:to:", "collection", "streamSize"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._atEnd();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(aBlock)._value_(self._next());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},globals.Stream)})},
- args: ["aBlock"],
- source: "do: aBlock\x0a\x09[ self atEnd ] whileFalse: [ aBlock value: self next ]",
- messageSends: ["whileFalse:", "atEnd", "value:", "next"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "flush",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "flush",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isEmpty",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._size()).__eq((0));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isEmpty",{},globals.Stream)})},
- args: [],
- source: "isEmpty\x0a\x09^ self size = 0",
- messageSends: ["=", "size"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next",
- protocol: 'reading',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$4,$3,$1;
- $2=self._atEnd();
- if(smalltalk.assert($2)){
- $1=nil;
- } else {
- $4=self._position();
- $ctx1.sendIdx["position"]=1;
- $3=_st($4).__plus((1));
- self._position_($3);
- $1=_st(self["@collection"])._at_(self._position());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"next",{},globals.Stream)})},
- args: [],
- source: "next\x0a\x09^ self atEnd\x0a\x09\x09ifTrue: [ nil ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09self position: self position + 1.\x0a\x09\x09\x09collection at: self position ]",
- messageSends: ["ifTrue:ifFalse:", "atEnd", "position:", "+", "position", "at:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next:",
- protocol: 'reading',
- fn: function (anInteger){
- var self=this;
- var tempCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- tempCollection=_st(_st(self._collection())._class())._new();
- _st(anInteger)._timesRepeat_((function(){
- return smalltalk.withContext(function($ctx2) {
- $1=self._atEnd();
- if(! smalltalk.assert($1)){
- return _st(tempCollection)._add_(self._next());
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $2=tempCollection;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"next:",{anInteger:anInteger,tempCollection:tempCollection},globals.Stream)})},
- args: ["anInteger"],
- source: "next: anInteger\x0a\x09| tempCollection |\x0a\x09tempCollection := self collection class new.\x0a\x09anInteger timesRepeat: [\x0a\x09\x09self atEnd ifFalse: [\x0a\x09\x09tempCollection add: self next ]].\x0a\x09^ tempCollection",
- messageSends: ["new", "class", "collection", "timesRepeat:", "ifFalse:", "atEnd", "add:", "next"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPut:",
- protocol: 'writing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4;
- $2=self._position();
- $ctx1.sendIdx["position"]=1;
- $1=_st($2).__plus((1));
- self._position_($1);
- $3=self._collection();
- $4=self._position();
- $ctx1.sendIdx["position"]=2;
- _st($3)._at_put_($4,anObject);
- self._setStreamSize_(_st(self._streamSize())._max_(self._position()));
- return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{anObject:anObject},globals.Stream)})},
- args: ["anObject"],
- source: "nextPut: anObject\x0a\x09self position: self position + 1.\x0a\x09self collection at: self position put: anObject.\x0a\x09self setStreamSize: (self streamSize max: self position)",
- messageSends: ["position:", "+", "position", "at:put:", "collection", "setStreamSize:", "max:", "streamSize"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutAll:",
- protocol: 'writing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._nextPut_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aCollection:aCollection},globals.Stream)})},
- args: ["aCollection"],
- source: "nextPutAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self nextPut: each ]",
- messageSends: ["do:", "nextPut:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutString:",
- protocol: 'writing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._nextPut_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},globals.Stream)})},
- args: ["aString"],
- source: "nextPutString: aString\x0a\x09self nextPut: aString",
- messageSends: ["nextPut:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "peek",
- protocol: 'reading',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._atEnd();
- if(! smalltalk.assert($2)){
- $1=_st(self._collection())._at_(_st(self._position()).__plus((1)));
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"peek",{},globals.Stream)})},
- args: [],
- source: "peek\x0a\x09^ self atEnd ifFalse: [\x0a\x09\x09self collection at: self position + 1 ]",
- messageSends: ["ifFalse:", "atEnd", "at:", "collection", "+", "position"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "position",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@position"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@position"]=(0);
- $1=self["@position"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"position",{},globals.Stream)})},
- args: [],
- source: "position\x0a\x09^ position ifNil: [ position := 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "position:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@position"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "position: anInteger\x0a\x09position := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reset",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._position_((0));
- return self}, function($ctx1) {$ctx1.fill(self,"reset",{},globals.Stream)})},
- args: [],
- source: "reset\x0a\x09self position: 0",
- messageSends: ["position:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "resetContents",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._reset();
- self._setStreamSize_((0));
- return self}, function($ctx1) {$ctx1.fill(self,"resetContents",{},globals.Stream)})},
- args: [],
- source: "resetContents\x0a\x09self reset.\x0a\x09self setStreamSize: 0",
- messageSends: ["reset", "setStreamSize:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setCollection:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@collection"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "setCollection: aCollection\x0a\x09collection := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setStreamSize:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@streamSize"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "setStreamSize: anInteger\x0a\x09streamSize := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setToEnd",
- protocol: 'positioning',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._position_(self._size());
- return self}, function($ctx1) {$ctx1.fill(self,"setToEnd",{},globals.Stream)})},
- args: [],
- source: "setToEnd\x0a\x09self position: self size",
- messageSends: ["position:", "size"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._streamSize();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"size",{},globals.Stream)})},
- args: [],
- source: "size\x0a\x09^ self streamSize",
- messageSends: ["streamSize"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "skip:",
- protocol: 'positioning',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._position_(_st(_st(self._position()).__plus(anInteger))._min_max_(self._size(),(0)));
- return self}, function($ctx1) {$ctx1.fill(self,"skip:",{anInteger:anInteger},globals.Stream)})},
- args: ["anInteger"],
- source: "skip: anInteger\x0a\x09self position: ((self position + anInteger) min: self size max: 0)",
- messageSends: ["position:", "min:max:", "+", "position", "size"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "streamSize",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@streamSize"];
- return $1;
- },
- args: [],
- source: "streamSize\x0a\x09^ streamSize",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "write:",
- protocol: 'writing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(anObject)._putOn_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"write:",{anObject:anObject},globals.Stream)})},
- args: ["anObject"],
- source: "write: anObject\x0a\x09anObject putOn: self",
- messageSends: ["putOn:"],
- referencedClasses: []
- }),
- globals.Stream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._setCollection_(aCollection);
- _st($2)._setStreamSize_(_st(aCollection)._size());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},globals.Stream.klass)})},
- args: ["aCollection"],
- source: "on: aCollection\x0a\x09\x09^ self new\x0a\x09\x09setCollection: aCollection;\x0a\x09\x09setStreamSize: aCollection size;\x0a\x09\x09yourself",
- messageSends: ["setCollection:", "new", "setStreamSize:", "size", "yourself"],
- referencedClasses: []
- }),
- globals.Stream.klass);
- smalltalk.addClass('StringStream', globals.Stream, [], 'Kernel-Collections');
- globals.StringStream.comment="I am a Stream specific to `String` objects.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cr",
- protocol: 'writing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._nextPutAll_(_st($String())._cr());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"cr",{},globals.StringStream)})},
- args: [],
- source: "cr\x0a\x09^ self nextPutAll: String cr",
- messageSends: ["nextPutAll:", "cr"],
- referencedClasses: ["String"]
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "crlf",
- protocol: 'writing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._nextPutAll_(_st($String())._crlf());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"crlf",{},globals.StringStream)})},
- args: [],
- source: "crlf\x0a\x09^ self nextPutAll: String crlf",
- messageSends: ["nextPutAll:", "crlf"],
- referencedClasses: ["String"]
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lf",
- protocol: 'writing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._nextPutAll_(_st($String())._lf());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"lf",{},globals.StringStream)})},
- args: [],
- source: "lf\x0a\x09^ self nextPutAll: String lf",
- messageSends: ["nextPutAll:", "lf"],
- referencedClasses: ["String"]
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next:",
- protocol: 'reading',
- fn: function (anInteger){
- var self=this;
- var tempCollection;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- tempCollection=_st(_st(self._collection())._class())._new();
- _st(anInteger)._timesRepeat_((function(){
- return smalltalk.withContext(function($ctx2) {
- $1=self._atEnd();
- if(! smalltalk.assert($1)){
- tempCollection=_st(tempCollection).__comma(self._next());
- return tempCollection;
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $2=tempCollection;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"next:",{anInteger:anInteger,tempCollection:tempCollection},globals.StringStream)})},
- args: ["anInteger"],
- source: "next: anInteger\x0a\x09| tempCollection |\x0a\x09tempCollection := self collection class new.\x0a\x09anInteger timesRepeat: [\x0a\x09\x09self atEnd ifFalse: [\x0a\x09\x09tempCollection := tempCollection, self next ]].\x0a\x09^ tempCollection",
- messageSends: ["new", "class", "collection", "timesRepeat:", "ifFalse:", "atEnd", ",", "next"],
- referencedClasses: []
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPut:",
- protocol: 'writing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._nextPutAll_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{aString:aString},globals.StringStream)})},
- args: ["aString"],
- source: "nextPut: aString\x0a\x09self nextPutAll: aString",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutAll:",
- protocol: 'writing',
- fn: function (aString){
- var self=this;
- var pre,post;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5,$6,$9,$8,$10,$7,$11,$12,$14,$13;
- $1=self._atEnd();
- if(smalltalk.assert($1)){
- $3=self._collection();
- $ctx1.sendIdx["collection"]=1;
- $2=_st($3).__comma(aString);
- $ctx1.sendIdx[","]=1;
- self._setCollection_($2);
- $ctx1.sendIdx["setCollection:"]=1;
- } else {
- $4=self._collection();
- $ctx1.sendIdx["collection"]=2;
- $5=self._position();
- $ctx1.sendIdx["position"]=1;
- pre=_st($4)._copyFrom_to_((1),$5);
- $ctx1.sendIdx["copyFrom:to:"]=1;
- pre;
- $6=self._collection();
- $ctx1.sendIdx["collection"]=3;
- $9=self._position();
- $ctx1.sendIdx["position"]=2;
- $8=_st($9).__plus((1));
- $ctx1.sendIdx["+"]=2;
- $10=_st(aString)._size();
- $ctx1.sendIdx["size"]=1;
- $7=_st($8).__plus($10);
- $ctx1.sendIdx["+"]=1;
- $11=_st(self._collection())._size();
- $ctx1.sendIdx["size"]=2;
- post=_st($6)._copyFrom_to_($7,$11);
- post;
- $12=_st(_st(pre).__comma(aString)).__comma(post);
- $ctx1.sendIdx[","]=2;
- self._setCollection_($12);
- };
- $14=self._position();
- $ctx1.sendIdx["position"]=3;
- $13=_st($14).__plus(_st(aString)._size());
- self._position_($13);
- self._setStreamSize_(_st(self._streamSize())._max_(self._position()));
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aString:aString,pre:pre,post:post},globals.StringStream)})},
- args: ["aString"],
- source: "nextPutAll: aString\x0a\x09| pre post |\x0a\x09self atEnd ifTrue: [ self setCollection: self collection, aString ] ifFalse: [\x0a\x09\x09pre := self collection copyFrom: 1 to: self position.\x0a\x09\x09post := self collection copyFrom: (self position + 1 + aString size) to: self collection size.\x0a\x09\x09self setCollection: pre, aString, post\x0a\x09].\x0a\x09self position: self position + aString size.\x0a\x09self setStreamSize: (self streamSize max: self position)",
- messageSends: ["ifTrue:ifFalse:", "atEnd", "setCollection:", ",", "collection", "copyFrom:to:", "position", "+", "size", "position:", "setStreamSize:", "max:", "streamSize"],
- referencedClasses: []
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutString:",
- protocol: 'writing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._nextPutAll_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},globals.StringStream)})},
- args: ["aString"],
- source: "nextPutString: aString\x0a\x09self nextPutAll: aString",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "space",
- protocol: 'writing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._nextPut_(" ");
- return self}, function($ctx1) {$ctx1.fill(self,"space",{},globals.StringStream)})},
- args: [],
- source: "space\x0a\x09self nextPut: ' '",
- messageSends: ["nextPut:"],
- referencedClasses: []
- }),
- globals.StringStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "tab",
- protocol: 'writing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._nextPutAll_(_st($String())._tab());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"tab",{},globals.StringStream)})},
- args: [],
- source: "tab\x0a\x09^ self nextPutAll: String tab",
- messageSends: ["nextPutAll:", "tab"],
- referencedClasses: ["String"]
- }),
- globals.StringStream);
- });
- define("amber_core/Kernel-Infrastructure", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Infrastructure');
- smalltalk.packages["Kernel-Infrastructure"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('ConsoleErrorHandler', globals.Object, [], 'Kernel-Infrastructure');
- globals.ConsoleErrorHandler.comment="I am manage Smalltalk errors, displaying the stack in the console.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleError:",
- protocol: 'error handling',
- fn: function (anError){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anError)._context();
- $ctx1.sendIdx["context"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- self._logErrorContext_(_st(anError)._context());
- };
- self._logError_(anError);
- return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.ConsoleErrorHandler)})},
- args: ["anError"],
- source: "handleError: anError\x0a\x09anError context ifNotNil: [ self logErrorContext: anError context ].\x0a\x09self logError: anError",
- messageSends: ["ifNotNil:", "context", "logErrorContext:", "logError:"],
- referencedClasses: []
- }),
- globals.ConsoleErrorHandler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "log:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(console)._log_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"log:",{aString:aString},globals.ConsoleErrorHandler)})},
- args: ["aString"],
- source: "log: aString\x0a\x09console log: aString",
- messageSends: ["log:"],
- referencedClasses: []
- }),
- globals.ConsoleErrorHandler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "logContext:",
- protocol: 'private',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aContext)._home();
- $ctx1.sendIdx["home"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- self._logContext_(_st(aContext)._home());
- };
- self._log_(_st(aContext)._asString());
- return self}, function($ctx1) {$ctx1.fill(self,"logContext:",{aContext:aContext},globals.ConsoleErrorHandler)})},
- args: ["aContext"],
- source: "logContext: aContext\x0a\x09aContext home ifNotNil: [\x0a\x09\x09self logContext: aContext home ].\x0a\x09self log: aContext asString",
- messageSends: ["ifNotNil:", "home", "logContext:", "log:", "asString"],
- referencedClasses: []
- }),
- globals.ConsoleErrorHandler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "logError:",
- protocol: 'private',
- fn: function (anError){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._log_(_st(anError)._messageText());
- return self}, function($ctx1) {$ctx1.fill(self,"logError:",{anError:anError},globals.ConsoleErrorHandler)})},
- args: ["anError"],
- source: "logError: anError\x0a\x09self log: anError messageText",
- messageSends: ["log:", "messageText"],
- referencedClasses: []
- }),
- globals.ConsoleErrorHandler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "logErrorContext:",
- protocol: 'private',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- if(($receiver = aContext) == nil || $receiver == null){
- aContext;
- } else {
- $1=_st(aContext)._home();
- $ctx1.sendIdx["home"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- self._logContext_(_st(aContext)._home());
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"logErrorContext:",{aContext:aContext},globals.ConsoleErrorHandler)})},
- args: ["aContext"],
- source: "logErrorContext: aContext\x0a\x09aContext ifNotNil: [\x0a\x09\x09aContext home ifNotNil: [\x0a\x09\x09\x09self logContext: aContext home ]]",
- messageSends: ["ifNotNil:", "home", "logContext:"],
- referencedClasses: []
- }),
- globals.ConsoleErrorHandler);
- globals.ConsoleErrorHandler.klass.iVarNames = ['current'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $ErrorHandler(){return globals.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
- return smalltalk.withContext(function($ctx1) {
- _st($ErrorHandler())._registerIfNone_(self._new());
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ConsoleErrorHandler.klass)})},
- args: [],
- source: "initialize\x0a\x09ErrorHandler registerIfNone: self new",
- messageSends: ["registerIfNone:", "new"],
- referencedClasses: ["ErrorHandler"]
- }),
- globals.ConsoleErrorHandler.klass);
- smalltalk.addClass('InterfacingObject', globals.Object, [], 'Kernel-Infrastructure');
- globals.InterfacingObject.comment="I am superclass of all object that interface with user or environment. `Widget` and a few other classes are subclasses of me. I delegate all of the above APIs to `PlatformInterface`.\x0a\x0a## API\x0a\x0a self alert: 'Hey, there is a problem'.\x0a self confirm: 'Affirmative?'.\x0a self prompt: 'Your name:'.\x0a\x0a self ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ajax:",
- protocol: 'actions',
- fn: function (anObject){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._ajax_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},globals.InterfacingObject)})},
- args: ["anObject"],
- source: "ajax: anObject\x0a\x09^ PlatformInterface ajax: anObject",
- messageSends: ["ajax:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.InterfacingObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alert:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._alert_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},globals.InterfacingObject)})},
- args: ["aString"],
- source: "alert: aString\x0a\x09^ PlatformInterface alert: aString",
- messageSends: ["alert:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.InterfacingObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "confirm:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._confirm_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},globals.InterfacingObject)})},
- args: ["aString"],
- source: "confirm: aString\x0a\x09^ PlatformInterface confirm: aString",
- messageSends: ["confirm:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.InterfacingObject);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "prompt:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($PlatformInterface())._prompt_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},globals.InterfacingObject)})},
- args: ["aString"],
- source: "prompt: aString\x0a\x09^ PlatformInterface prompt: aString",
- messageSends: ["prompt:"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.InterfacingObject);
- smalltalk.addClass('Environment', globals.InterfacingObject, [], 'Kernel-Infrastructure');
- globals.Environment.comment="I provide an unified entry point to manipulate Amber packages, classes and methods.\x0a\x0aTypical use cases include IDEs, remote access and restricting browsing.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addInstVarNamed:to:",
- protocol: 'compiling',
- fn: function (aString,aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5;
- $1=self._classBuilder();
- $2=_st(aClass)._superclass();
- $3=_st(aClass)._name();
- $ctx1.sendIdx["name"]=1;
- $4=_st(_st(aClass)._instanceVariableNames())._copy();
- _st($4)._add_(aString);
- $5=_st($4)._yourself();
- _st($1)._addSubclassOf_named_instanceVariableNames_package_($2,$3,$5,_st(_st(aClass)._package())._name());
- return self}, function($ctx1) {$ctx1.fill(self,"addInstVarNamed:to:",{aString:aString,aClass:aClass},globals.Environment)})},
- args: ["aString", "aClass"],
- source: "addInstVarNamed: aString to: aClass\x0a\x09self classBuilder\x0a\x09\x09addSubclassOf: aClass superclass \x0a\x09\x09named: aClass name \x0a\x09\x09instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)\x0a\x09\x09package: aClass package name",
- messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "classBuilder", "superclass", "name", "add:", "copy", "instanceVariableNames", "yourself", "package"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allSelectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Smalltalk())._vm())._allSelectors();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allSelectors",{},globals.Environment)})},
- args: [],
- source: "allSelectors\x0a\x09^ Smalltalk vm allSelectors",
- messageSends: ["allSelectors", "vm"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "availableClassNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Smalltalk())._classes())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._name();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"availableClassNames",{},globals.Environment)})},
- args: [],
- source: "availableClassNames\x0a\x09^ Smalltalk classes \x0a\x09\x09collect: [ :each | each name ]",
- messageSends: ["collect:", "classes", "name"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "availablePackageNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Smalltalk())._packages())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._name();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"availablePackageNames",{},globals.Environment)})},
- args: [],
- source: "availablePackageNames\x0a\x09^ Smalltalk packages \x0a\x09\x09collect: [ :each | each name ]",
- messageSends: ["collect:", "packages", "name"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "availableProtocolsFor:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- var protocols;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- protocols=_st(aClass)._protocols();
- $1=_st(aClass)._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- _st(protocols)._addAll_(self._availableProtocolsFor_(_st(aClass)._superclass()));
- };
- $2=_st(_st(_st(protocols)._asSet())._asArray())._sort();
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"availableProtocolsFor:",{aClass:aClass,protocols:protocols},globals.Environment)})},
- args: ["aClass"],
- source: "availableProtocolsFor: aClass\x0a\x09| protocols |\x0a\x09\x0a\x09protocols := aClass protocols.\x0a\x09aClass superclass ifNotNil: [ protocols addAll: (self availableProtocolsFor: aClass superclass) ].\x0a\x09^ protocols asSet asArray sort",
- messageSends: ["protocols", "ifNotNil:", "superclass", "addAll:", "availableProtocolsFor:", "sort", "asArray", "asSet"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classBuilder",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($ClassBuilder())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classBuilder",{},globals.Environment)})},
- args: [],
- source: "classBuilder\x0a\x09^ ClassBuilder new",
- messageSends: ["new"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classNamed:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(_st($Smalltalk())._globals())._at_(_st(aString)._asSymbol());
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._error_("Invalid class name");
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classNamed:",{aString:aString},globals.Environment)})},
- args: ["aString"],
- source: "classNamed: aString\x0a\x09^ (Smalltalk globals at: aString asSymbol)\x0a\x09\x09ifNil: [ self error: 'Invalid class name' ]",
- messageSends: ["ifNil:", "at:", "globals", "asSymbol", "error:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._classes();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classes",{},globals.Environment)})},
- args: [],
- source: "classes\x0a\x09^ Smalltalk classes",
- messageSends: ["classes"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commitPackage:",
- protocol: 'actions',
- fn: function (aPackage){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aPackage)._commit();
- return self}, function($ctx1) {$ctx1.fill(self,"commitPackage:",{aPackage:aPackage},globals.Environment)})},
- args: ["aPackage"],
- source: "commitPackage: aPackage\x0a\x09aPackage commit",
- messageSends: ["commit"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileClassComment:for:",
- protocol: 'compiling',
- fn: function (aString,aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aClass)._comment_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"compileClassComment:for:",{aString:aString,aClass:aClass},globals.Environment)})},
- args: ["aString", "aClass"],
- source: "compileClassComment: aString for: aClass\x0a\x09aClass comment: aString",
- messageSends: ["comment:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileClassDefinition:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- return smalltalk.withContext(function($ctx1) {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._eval_on_(aString,_st($DoIt())._new());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(error){
- return smalltalk.withContext(function($ctx2) {
- return self._alert_(_st(error)._messageText());
- }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"compileClassDefinition:",{aString:aString},globals.Environment)})},
- args: ["aString"],
- source: "compileClassDefinition: aString\x0a\x09[ self eval: aString on: DoIt new ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :error | self alert: error messageText ]",
- messageSends: ["on:do:", "eval:on:", "new", "alert:", "messageText"],
- referencedClasses: ["DoIt", "Error"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileMethod:for:protocol:",
- protocol: 'compiling',
- fn: function (sourceCode,class_,protocol){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(class_)._compile_protocol_(sourceCode,protocol);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compileMethod:for:protocol:",{sourceCode:sourceCode,class_:class_,protocol:protocol},globals.Environment)})},
- args: ["sourceCode", "class", "protocol"],
- source: "compileMethod: sourceCode for: class protocol: protocol\x0a\x09^ class\x0a\x09\x09compile: sourceCode\x0a\x09\x09protocol: protocol",
- messageSends: ["compile:protocol:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "copyClass:to:",
- protocol: 'actions',
- fn: function (aClass,aClassName){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(_st($Smalltalk())._globals())._at_(aClassName);
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- $2=_st("A class named ".__comma(aClassName)).__comma(" already exists");
- $ctx1.sendIdx[","]=1;
- self._error_($2);
- };
- _st(_st($ClassBuilder())._new())._copyClass_named_(aClass,aClassName);
- return self}, function($ctx1) {$ctx1.fill(self,"copyClass:to:",{aClass:aClass,aClassName:aClassName},globals.Environment)})},
- args: ["aClass", "aClassName"],
- source: "copyClass: aClass to: aClassName\x0a\x09(Smalltalk globals at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new copyClass: aClass named: aClassName",
- messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "copyClass:named:", "new"],
- referencedClasses: ["Smalltalk", "ClassBuilder"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "doItReceiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($DoIt())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"doItReceiver",{},globals.Environment)})},
- args: [],
- source: "doItReceiver\x0a\x09^ DoIt new",
- messageSends: ["new"],
- referencedClasses: ["DoIt"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:on:",
- protocol: 'evaluating',
- fn: function (aString,aReceiver){
- var self=this;
- var compiler;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- compiler=_st($Compiler())._new();
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(compiler)._parseExpression_(aString);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
- return smalltalk.withContext(function($ctx2) {
- $1=self._alert_(_st(ex)._messageText());
- throw $early=[$1];
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
- $2=_st(compiler)._evaluateExpression_on_(aString,aReceiver);
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"eval:on:",{aString:aString,aReceiver:aReceiver,compiler:compiler},globals.Environment)})},
- args: ["aString", "aReceiver"],
- source: "eval: aString on: aReceiver\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09[ compiler parseExpression: aString ] on: Error do: [ :ex |\x0a\x09\x09^ self alert: ex messageText ].\x0a\x09^ compiler evaluateExpression: aString on: aReceiver",
- messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"],
- referencedClasses: ["Compiler", "Error"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluate:on:do:",
- protocol: 'error handling',
- fn: function (aBlock,anErrorClass,exceptionBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._try_catch_(aBlock,(function(exception){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(exception)._isKindOf_(self._classNamed_(_st(anErrorClass)._name()));
- if(smalltalk.assert($1)){
- return _st(exceptionBlock)._value_(exception);
- } else {
- return _st(exception)._signal();
- };
- }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"evaluate:on:do:",{aBlock:aBlock,anErrorClass:anErrorClass,exceptionBlock:exceptionBlock},globals.Environment)})},
- args: ["aBlock", "anErrorClass", "exceptionBlock"],
- source: "evaluate: aBlock on: anErrorClass do: exceptionBlock\x0a\x09\x22Evaluate a block and catch exceptions happening on the environment stack\x22\x0a\x09\x0a\x09self try: aBlock catch: [ :exception | \x0a\x09\x09(exception isKindOf: (self classNamed: anErrorClass name))\x0a\x09\x09\x09ifTrue: [ exceptionBlock value: exception ]\x0a \x09\x09\x09ifFalse: [ exception signal ] ]",
- messageSends: ["try:catch:", "ifTrue:ifFalse:", "isKindOf:", "classNamed:", "name", "value:", "signal"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspect:",
- protocol: 'actions',
- fn: function (anObject){
- var self=this;
- function $Inspector(){return globals.Inspector||(typeof Inspector=="undefined"?nil:Inspector)}
- return smalltalk.withContext(function($ctx1) {
- _st($Inspector())._inspect_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Environment)})},
- args: ["anObject"],
- source: "inspect: anObject\x0a\x09Inspector inspect: anObject",
- messageSends: ["inspect:"],
- referencedClasses: ["Inspector"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpret:inContext:",
- protocol: 'evaluating',
- fn: function (aString,anAIContext){
- var self=this;
- var compiler,ast;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- function $SemanticAnalyzer(){return globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- compiler=_st($Compiler())._new();
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- ast=_st(compiler)._parseExpression_(aString);
- return ast;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
- return smalltalk.withContext(function($ctx2) {
- $1=self._alert_(_st(ex)._messageText());
- throw $early=[$1];
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
- _st(_st($SemanticAnalyzer())._on_(_st(_st(anAIContext)._receiver())._class()))._visit_(ast);
- $2=_st(anAIContext)._evaluateNode_(ast);
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"interpret:inContext:",{aString:aString,anAIContext:anAIContext,compiler:compiler,ast:ast},globals.Environment)})},
- args: ["aString", "anAIContext"],
- source: "interpret: aString inContext: anAIContext\x0a\x09\x22Similar to #eval:on:, with the following differences:\x0a\x09- instead of compiling and running `aString`, `aString` is interpreted using an `ASTInterpreter`\x0a\x09- instead of evaluating against a receiver, evaluate in the context of `anAIContext`\x22\x0a\x0a\x09| compiler ast |\x0a\x09compiler := Compiler new.\x0a\x09[ ast := compiler parseExpression: aString ] on: Error do: [ :ex |\x0a\x09\x09^ self alert: ex messageText ].\x0a\x09(SemanticAnalyzer on: anAIContext receiver class)\x0a\x09\x09visit: ast.\x0a\x09^ anAIContext evaluateNode: ast",
- messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "visit:", "on:", "class", "receiver", "evaluateNode:"],
- referencedClasses: ["Compiler", "Error", "SemanticAnalyzer"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "moveClass:toPackage:",
- protocol: 'actions',
- fn: function (aClass,aPackageName){
- var self=this;
- var package_;
- function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- package_=_st($Package())._named_(aPackageName);
- $1=package_;
- if(($receiver = $1) == nil || $receiver == null){
- self._error_("Invalid package name");
- } else {
- $1;
- };
- $2=_st(package_).__eq_eq(_st(aClass)._package());
- if(smalltalk.assert($2)){
- return self;
- };
- _st(aClass)._package_(package_);
- return self}, function($ctx1) {$ctx1.fill(self,"moveClass:toPackage:",{aClass:aClass,aPackageName:aPackageName,package_:package_},globals.Environment)})},
- args: ["aClass", "aPackageName"],
- source: "moveClass: aClass toPackage: aPackageName\x0a\x09| package |\x0a\x09\x0a\x09package := Package named: aPackageName.\x0a\x09package ifNil: [ self error: 'Invalid package name' ].\x0a\x09package == aClass package ifTrue: [ ^ self ].\x0a\x09\x0a\x09aClass package: package",
- messageSends: ["named:", "ifNil:", "error:", "ifTrue:", "==", "package", "package:"],
- referencedClasses: ["Package"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "moveMethod:toClass:",
- protocol: 'actions',
- fn: function (aMethod,aClassName){
- var self=this;
- var destinationClass;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- destinationClass=self._classNamed_(aClassName);
- $2=destinationClass;
- $3=_st(aMethod)._methodClass();
- $ctx1.sendIdx["methodClass"]=1;
- $1=_st($2).__eq_eq($3);
- if(smalltalk.assert($1)){
- return self;
- };
- _st(destinationClass)._compile_protocol_(_st(aMethod)._source(),_st(aMethod)._protocol());
- _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
- return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},globals.Environment)})},
- args: ["aMethod", "aClassName"],
- source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := self classNamed: aClassName.\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass \x0a\x09\x09compile: aMethod source\x0a\x09\x09protocol: aMethod protocol.\x0a\x09aMethod methodClass \x0a\x09\x09removeCompiledMethod: aMethod",
- messageSends: ["classNamed:", "ifTrue:", "==", "methodClass", "compile:protocol:", "source", "protocol", "removeCompiledMethod:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "moveMethod:toProtocol:",
- protocol: 'actions',
- fn: function (aMethod,aProtocol){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aMethod)._protocol_(aProtocol);
- return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toProtocol:",{aMethod:aMethod,aProtocol:aProtocol},globals.Environment)})},
- args: ["aMethod", "aProtocol"],
- source: "moveMethod: aMethod toProtocol: aProtocol\x0a\x09aMethod protocol: aProtocol",
- messageSends: ["protocol:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "packages",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._packages();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"packages",{},globals.Environment)})},
- args: [],
- source: "packages\x0a\x09^ Smalltalk packages",
- messageSends: ["packages"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "registerErrorHandler:",
- protocol: 'services',
- fn: function (anErrorHandler){
- var self=this;
- function $ErrorHandler(){return globals.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
- return smalltalk.withContext(function($ctx1) {
- _st($ErrorHandler())._register_(anErrorHandler);
- return self}, function($ctx1) {$ctx1.fill(self,"registerErrorHandler:",{anErrorHandler:anErrorHandler},globals.Environment)})},
- args: ["anErrorHandler"],
- source: "registerErrorHandler: anErrorHandler\x0a\x09ErrorHandler register: anErrorHandler",
- messageSends: ["register:"],
- referencedClasses: ["ErrorHandler"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "registerInspector:",
- protocol: 'services',
- fn: function (anInspector){
- var self=this;
- function $Inspector(){return globals.Inspector||(typeof Inspector=="undefined"?nil:Inspector)}
- return smalltalk.withContext(function($ctx1) {
- _st($Inspector())._register_(anInspector);
- return self}, function($ctx1) {$ctx1.fill(self,"registerInspector:",{anInspector:anInspector},globals.Environment)})},
- args: ["anInspector"],
- source: "registerInspector: anInspector\x0a\x09Inspector register: anInspector",
- messageSends: ["register:"],
- referencedClasses: ["Inspector"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "registerProgressHandler:",
- protocol: 'services',
- fn: function (aProgressHandler){
- var self=this;
- function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
- return smalltalk.withContext(function($ctx1) {
- _st($ProgressHandler())._register_(aProgressHandler);
- return self}, function($ctx1) {$ctx1.fill(self,"registerProgressHandler:",{aProgressHandler:aProgressHandler},globals.Environment)})},
- args: ["aProgressHandler"],
- source: "registerProgressHandler: aProgressHandler\x0a\x09ProgressHandler register: aProgressHandler",
- messageSends: ["register:"],
- referencedClasses: ["ProgressHandler"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "registerTranscript:",
- protocol: 'services',
- fn: function (aTranscript){
- var self=this;
- function $Transcript(){return globals.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
- return smalltalk.withContext(function($ctx1) {
- _st($Transcript())._register_(aTranscript);
- return self}, function($ctx1) {$ctx1.fill(self,"registerTranscript:",{aTranscript:aTranscript},globals.Environment)})},
- args: ["aTranscript"],
- source: "registerTranscript: aTranscript\x0a\x09Transcript register: aTranscript",
- messageSends: ["register:"],
- referencedClasses: ["Transcript"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeClass:",
- protocol: 'actions',
- fn: function (aClass){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- _st($Smalltalk())._removeClass_(aClass);
- return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},globals.Environment)})},
- args: ["aClass"],
- source: "removeClass: aClass\x0a\x09Smalltalk removeClass: aClass",
- messageSends: ["removeClass:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeMethod:",
- protocol: 'actions',
- fn: function (aMethod){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
- return self}, function($ctx1) {$ctx1.fill(self,"removeMethod:",{aMethod:aMethod},globals.Environment)})},
- args: ["aMethod"],
- source: "removeMethod: aMethod\x0a\x09aMethod methodClass removeCompiledMethod: aMethod",
- messageSends: ["removeCompiledMethod:", "methodClass"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeProtocol:from:",
- protocol: 'actions',
- fn: function (aString,aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(aClass)._methodsInProtocol_(aString))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(aClass)._removeCompiledMethod_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"removeProtocol:from:",{aString:aString,aClass:aClass},globals.Environment)})},
- args: ["aString", "aClass"],
- source: "removeProtocol: aString from: aClass\x0a\x09(aClass methodsInProtocol: aString)\x0a\x09\x09do: [ :each | aClass removeCompiledMethod: each ]",
- messageSends: ["do:", "methodsInProtocol:", "removeCompiledMethod:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "renameClass:to:",
- protocol: 'actions',
- fn: function (aClass,aClassName){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(_st($Smalltalk())._globals())._at_(aClassName);
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- $2=_st("A class named ".__comma(aClassName)).__comma(" already exists");
- $ctx1.sendIdx[","]=1;
- self._error_($2);
- };
- _st(_st($ClassBuilder())._new())._renameClass_to_(aClass,aClassName);
- return self}, function($ctx1) {$ctx1.fill(self,"renameClass:to:",{aClass:aClass,aClassName:aClassName},globals.Environment)})},
- args: ["aClass", "aClassName"],
- source: "renameClass: aClass to: aClassName\x0a\x09(Smalltalk globals at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new renameClass: aClass to: aClassName",
- messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "renameClass:to:", "new"],
- referencedClasses: ["Smalltalk", "ClassBuilder"]
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "renameProtocol:to:in:",
- protocol: 'actions',
- fn: function (aString,anotherString,aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(aClass)._methodsInProtocol_(aString))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._protocol_(anotherString);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"renameProtocol:to:in:",{aString:aString,anotherString:anotherString,aClass:aClass},globals.Environment)})},
- args: ["aString", "anotherString", "aClass"],
- source: "renameProtocol: aString to: anotherString in: aClass\x0a\x09(aClass methodsInProtocol: aString)\x0a\x09\x09do: [ :each | each protocol: anotherString ]",
- messageSends: ["do:", "methodsInProtocol:", "protocol:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setClassCommentOf:to:",
- protocol: 'actions',
- fn: function (aClass,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aClass)._comment_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"setClassCommentOf:to:",{aClass:aClass,aString:aString},globals.Environment)})},
- args: ["aClass", "aString"],
- source: "setClassCommentOf: aClass to: aString\x0a\x09aClass comment: aString",
- messageSends: ["comment:"],
- referencedClasses: []
- }),
- globals.Environment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "systemAnnouncer",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st($Smalltalk())._globals())._at_("SystemAnnouncer"))._current();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"systemAnnouncer",{},globals.Environment)})},
- args: [],
- source: "systemAnnouncer\x0a\x09^ (Smalltalk globals at: #SystemAnnouncer) current",
- messageSends: ["current", "at:", "globals"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Environment);
- smalltalk.addClass('JSObjectProxy', globals.ProtoObject, ['jsObject'], 'Kernel-Infrastructure');
- globals.JSObjectProxy.comment="I handle sending messages to JavaScript objects, making JavaScript object accessing from Amber fully transparent.\x0aMy instances make intensive use of `#doesNotUnderstand:`.\x0a\x0aMy instances are automatically created by Amber whenever a message is sent to a JavaScript object.\x0a\x0a## Usage examples\x0a\x0aJSObjectProxy objects are instanciated by Amber when a Smalltalk message is sent to a JavaScript object.\x0a\x0a\x09window alert: 'hello world'.\x0a\x09window inspect.\x0a\x09(window jQuery: 'body') append: 'hello world'\x0a\x0aAmber messages sends are converted to JavaScript function calls or object property access _(in this order)_. If n one of them match, a `MessageNotUnderstood` error will be thrown.\x0a\x0a## Message conversion rules\x0a\x0a- `someUser name` becomes `someUser.name`\x0a- `someUser name: 'John'` becomes `someUser name = \x22John\x22`\x0a- `console log: 'hello world'` becomes `console.log('hello world')`\x0a- `(window jQuery: 'foo') css: 'background' color: 'red'` becomes `window.jQuery('foo').css('background', 'red')`\x0a\x0a__Note:__ For keyword-based messages, only the first keyword is kept: `window foo: 1 bar: 2` is equivalent to `window foo: 1 baz: 2`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "=",
- protocol: 'comparing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3;
- $2=_st(anObject)._class();
- $ctx1.sendIdx["class"]=1;
- $1=_st($2).__eq_eq(self._class());
- if(! smalltalk.assert($1)){
- return false;
- };
- $3=self._compareJSObjectWith_(_st(anObject)._jsObject());
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"=",{anObject:anObject},globals.JSObjectProxy)})},
- args: ["anObject"],
- source: "= anObject\x0a\x09anObject class == self class ifFalse: [ ^ false ].\x0a\x09^ self compareJSObjectWith: anObject jsObject",
- messageSends: ["ifFalse:", "==", "class", "compareJSObjectWith:", "jsObject"],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addObjectVariablesTo:",
- protocol: 'proxy',
- fn: function (aDictionary){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- for(var i in self['@jsObject']) {
- aDictionary._at_put_(i, self['@jsObject'][i]);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"addObjectVariablesTo:",{aDictionary:aDictionary},globals.JSObjectProxy)})},
- args: ["aDictionary"],
- source: "addObjectVariablesTo: aDictionary\x0a\x09<\x0a\x09\x09for(var i in self['@jsObject']) {\x0a\x09\x09\x09aDictionary._at_put_(i, self['@jsObject'][i]);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJSON",
- protocol: 'enumerating',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@jsObject"];
- return $1;
- },
- args: [],
- source: "asJSON\x0a\x09\x22Answers the receiver in a stringyfy-friendly fashion\x22\x0a\x0a\x09^ jsObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self['@jsObject'][aString];
- return self}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},globals.JSObjectProxy)})},
- args: ["aString"],
- source: "at: aString\x0a\x09<return self['@jsObject'][aString]>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (aString,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var obj = self['@jsObject'];
- return aString in obj ? obj[aString] : aBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aString:aString,aBlock:aBlock},globals.JSObjectProxy)})},
- args: ["aString", "aBlock"],
- source: "at: aString ifAbsent: aBlock\x0a\x09\x22return the aString property or evaluate aBlock if the property is not defined on the object\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? obj[aString] : aBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:",
- protocol: 'accessing',
- fn: function (aString,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var obj = self['@jsObject'];
- return aString in obj ? aBlock._value_(obj[aString]) : nil;
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:",{aString:aString,aBlock:aBlock},globals.JSObjectProxy)})},
- args: ["aString", "aBlock"],
- source: "at: aString ifPresent: aBlock\x0a\x09\x22return the evaluation of aBlock with the value if the property is defined or return nil\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? aBlock._value_(obj[aString]) : nil;\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifPresent:ifAbsent:",
- protocol: 'accessing',
- fn: function (aString,aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var obj = self['@jsObject'];
- return aString in obj ? aBlock._value_(obj[aString]) : anotherBlock._value();
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{aString:aString,aBlock:aBlock,anotherBlock:anotherBlock},globals.JSObjectProxy)})},
- args: ["aString", "aBlock", "anotherBlock"],
- source: "at: aString ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09\x22return the evaluation of aBlock with the value if the property is defined\x0a\x09or return value of anotherBlock\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? aBlock._value_(obj[aString]) : anotherBlock._value();\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self['@jsObject'][aString] = anObject;
- return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},globals.JSObjectProxy)})},
- args: ["aString", "anObject"],
- source: "at: aString put: anObject\x0a\x09<return self['@jsObject'][aString] = anObject>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compareJSObjectWith:",
- protocol: 'private',
- fn: function (aJSObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self["@jsObject"] === aJSObject;
- return self}, function($ctx1) {$ctx1.fill(self,"compareJSObjectWith:",{aJSObject:aJSObject},globals.JSObjectProxy)})},
- args: ["aJSObject"],
- source: " compareJSObjectWith: aJSObject\x0a \x09<return self[\x22@jsObject\x22] === aJSObject>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "doesNotUnderstand:",
- protocol: 'proxy',
- fn: function (aMessage){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._lookupProperty_(_st(_st(aMessage)._selector())._asJavaScriptSelector());
- if(($receiver = $2) == nil || $receiver == null){
- $1=globals.JSObjectProxy.superclass.fn.prototype._doesNotUnderstand_.apply(_st(self), [aMessage]);
- } else {
- var jsSelector;
- jsSelector=$receiver;
- $1=self._forwardMessage_withArguments_(jsSelector,_st(aMessage)._arguments());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},globals.JSObjectProxy)})},
- args: ["aMessage"],
- source: "doesNotUnderstand: aMessage\x0a\x09^ (self lookupProperty: aMessage selector asJavaScriptSelector)\x0a\x09\x09ifNil: [ super doesNotUnderstand: aMessage ]\x0a\x09\x09ifNotNil: [ :jsSelector | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09forwardMessage: jsSelector \x0a\x09\x09\x09\x09withArguments: aMessage arguments ]",
- messageSends: ["ifNil:ifNotNil:", "lookupProperty:", "asJavaScriptSelector", "selector", "doesNotUnderstand:", "forwardMessage:withArguments:", "arguments"],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "forwardMessage:withArguments:",
- protocol: 'proxy',
- fn: function (aString,anArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.send(self._jsObject(), aString, anArray);
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"forwardMessage:withArguments:",{aString:aString,anArray:anArray},globals.JSObjectProxy)})},
- args: ["aString", "anArray"],
- source: "forwardMessage: aString withArguments: anArray\x0a\x09<\x0a\x09\x09return smalltalk.send(self._jsObject(), aString, anArray);\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspectOn:",
- protocol: 'proxy',
- fn: function (anInspector){
- var self=this;
- var variables;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- variables=_st($Dictionary())._new();
- _st(variables)._at_put_("#self",self._jsObject());
- _st(anInspector)._setLabel_(self._printString());
- self._addObjectVariablesTo_(variables);
- _st(anInspector)._setVariables_(variables);
- return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector,variables:variables},globals.JSObjectProxy)})},
- args: ["anInspector"],
- source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self jsObject.\x0a\x09anInspector setLabel: self printString.\x0a\x09self addObjectVariablesTo: variables.\x0a\x09anInspector setVariables: variables",
- messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "addObjectVariablesTo:", "setVariables:"],
- referencedClasses: ["Dictionary"]
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "jsObject",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@jsObject"];
- return $1;
- },
- args: [],
- source: "jsObject\x0a\x09^ jsObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "jsObject:",
- protocol: 'accessing',
- fn: function (aJSObject){
- var self=this;
- self["@jsObject"]=aJSObject;
- return self},
- args: ["aJSObject"],
- source: "jsObject: aJSObject\x0a\x09jsObject := aJSObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "keysAndValuesDo:",
- protocol: 'enumerating',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var o = self['@jsObject'];
- for(var i in o) {
- aBlock._value_value_(i, o[i]);
- }
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},globals.JSObjectProxy)})},
- args: ["aBlock"],
- source: "keysAndValuesDo: aBlock\x0a\x09<\x0a\x09\x09var o = self['@jsObject'];\x0a\x09\x09for(var i in o) {\x0a\x09\x09\x09aBlock._value_value_(i, o[i]);\x0a\x09\x09}\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lookupProperty:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return aString in self._jsObject() ? aString : nil;
- return self}, function($ctx1) {$ctx1.fill(self,"lookupProperty:",{aString:aString},globals.JSObjectProxy)})},
- args: ["aString"],
- source: "lookupProperty: aString\x0a\x09\x22Looks up a property in JS object.\x0a\x09Answer the property if it is present, or nil if it is not present.\x22\x0a\x09\x0a\x09<return aString in self._jsObject() ? aString : nil>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aStream)._nextPutAll_(self._printString());
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.JSObjectProxy)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09aStream nextPutAll: self printString",
- messageSends: ["nextPutAll:", "printString"],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printString",
- protocol: 'printing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var js = self['@jsObject'];
- return js.toString
- ? js.toString()
- : Object.prototype.toString.call(js)
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"printString",{},globals.JSObjectProxy)})},
- args: [],
- source: "printString\x0a\x09<\x0a\x09\x09var js = self['@jsObject'];\x0a\x09\x09return js.toString\x0a\x09\x09\x09? js.toString()\x0a\x09\x09\x09: Object.prototype.toString.call(js)\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSObjectProxy);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aJSObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._jsObject_(aJSObject);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{aJSObject:aJSObject},globals.JSObjectProxy.klass)})},
- args: ["aJSObject"],
- source: "on: aJSObject\x0a\x09^ self new\x0a\x09\x09jsObject: aJSObject;\x0a\x09\x09yourself",
- messageSends: ["jsObject:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.JSObjectProxy.klass);
- smalltalk.addClass('NullProgressHandler', globals.Object, [], 'Kernel-Infrastructure');
- globals.NullProgressHandler.comment="I am the default progress handler. I do not display any progress, and simply iterate over the collection.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:on:displaying:",
- protocol: 'progress handling',
- fn: function (aBlock,aCollection,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aCollection)._do_(aBlock);
- return self}, function($ctx1) {$ctx1.fill(self,"do:on:displaying:",{aBlock:aBlock,aCollection:aCollection,aString:aString},globals.NullProgressHandler)})},
- args: ["aBlock", "aCollection", "aString"],
- source: "do: aBlock on: aCollection displaying: aString\x0a\x09aCollection do: aBlock",
- messageSends: ["do:"],
- referencedClasses: []
- }),
- globals.NullProgressHandler);
- globals.NullProgressHandler.klass.iVarNames = ['current'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
- return smalltalk.withContext(function($ctx1) {
- _st($ProgressHandler())._registerIfNone_(self._new());
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.NullProgressHandler.klass)})},
- args: [],
- source: "initialize\x0a\x09ProgressHandler registerIfNone: self new",
- messageSends: ["registerIfNone:", "new"],
- referencedClasses: ["ProgressHandler"]
- }),
- globals.NullProgressHandler.klass);
- smalltalk.addClass('Organizer', globals.Object, [], 'Kernel-Infrastructure');
- globals.Organizer.comment="I represent categorization information. \x0a\x0a## API\x0a\x0aUse `#addElement:` and `#removeElement:` to manipulate instances.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addElement:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.elements.addElement(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"addElement:",{anObject:anObject},globals.Organizer)})},
- args: ["anObject"],
- source: "addElement: anObject\x0a\x09<self.elements.addElement(anObject)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Organizer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "elements",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._basicAt_("elements"))._copy();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"elements",{},globals.Organizer)})},
- args: [],
- source: "elements\x0a\x09^ (self basicAt: 'elements') copy",
- messageSends: ["copy", "basicAt:"],
- referencedClasses: []
- }),
- globals.Organizer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeElement:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.elements.removeElement(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"removeElement:",{anObject:anObject},globals.Organizer)})},
- args: ["anObject"],
- source: "removeElement: anObject\x0a\x09<self.elements.removeElement(anObject)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Organizer);
- smalltalk.addClass('ClassOrganizer', globals.Organizer, [], 'Kernel-Infrastructure');
- globals.ClassOrganizer.comment="I am an organizer specific to classes. I hold method categorization information for classes.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addElement:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ProtocolAdded(){return globals.ProtocolAdded||(typeof ProtocolAdded=="undefined"?nil:ProtocolAdded)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- globals.ClassOrganizer.superclass.fn.prototype._addElement_.apply(_st(self), [aString]);
- $1=_st($ProtocolAdded())._new();
- _st($1)._protocol_(aString);
- _st($1)._theClass_(self._theClass());
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"addElement:",{aString:aString},globals.ClassOrganizer)})},
- args: ["aString"],
- source: "addElement: aString\x0a\x09super addElement: aString.\x0a\x0a\x09SystemAnnouncer current announce: (ProtocolAdded new\x0a\x09\x09protocol: aString;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09yourself)",
- messageSends: ["addElement:", "announce:", "current", "protocol:", "new", "theClass:", "theClass", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ProtocolAdded"]
- }),
- globals.ClassOrganizer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeElement:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ProtocolRemoved(){return globals.ProtocolRemoved||(typeof ProtocolRemoved=="undefined"?nil:ProtocolRemoved)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- globals.ClassOrganizer.superclass.fn.prototype._removeElement_.apply(_st(self), [aString]);
- $1=_st($ProtocolRemoved())._new();
- _st($1)._protocol_(aString);
- _st($1)._theClass_(self._theClass());
- $2=_st($1)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"removeElement:",{aString:aString},globals.ClassOrganizer)})},
- args: ["aString"],
- source: "removeElement: aString\x0a\x09super removeElement: aString.\x0a\x0a\x09SystemAnnouncer current announce: (ProtocolRemoved new\x0a\x09\x09protocol: aString;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09yourself)",
- messageSends: ["removeElement:", "announce:", "current", "protocol:", "new", "theClass:", "theClass", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ProtocolRemoved"]
- }),
- globals.ClassOrganizer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.theClass ;
- return self}, function($ctx1) {$ctx1.fill(self,"theClass",{},globals.ClassOrganizer)})},
- args: [],
- source: "theClass\x0a\x09< return self.theClass >",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassOrganizer);
- smalltalk.addClass('PackageOrganizer', globals.Organizer, [], 'Kernel-Infrastructure');
- globals.PackageOrganizer.comment="I am an organizer specific to packages. I hold classes categorization information.";
- smalltalk.addClass('Package', globals.Object, ['transport'], 'Kernel-Infrastructure');
- globals.Package.comment="I am similar to a \x22class category\x22 typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.\x0a\x0aEach package has a name and can be queried for its classes, but it will then resort to a reverse scan of all classes to find them.\x0a\x0a## API\x0a\x0aPackages are manipulated through \x22Smalltalk current\x22, like for example finding one based on a name or with `Package class >> #name` directly:\x0a\x0a Smalltalk current packageAt: 'Kernel'\x0a Package named: 'Kernel'\x0a\x0aA package differs slightly from a Monticello package which can span multiple class categories using a naming convention based on hyphenation. But just as in Monticello a package supports \x22class extensions\x22 so a package can define behaviors in foreign classes using a naming convention for method categories where the category starts with an asterisk and then the name of the owning package follows.\x0a\x0aYou can fetch a package from the server:\x0a\x0a\x09Package load: 'Additional-Examples'";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicTransport",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.transport;
- return self}, function($ctx1) {$ctx1.fill(self,"basicTransport",{},globals.Package)})},
- args: [],
- source: "basicTransport\x0a\x09\x22Answer the transport literal JavaScript object as setup in the JavaScript file, if any\x22\x0a\x09\x0a\x09<return self.transport>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classTemplate",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$4,$2,$5,$6,$7,$1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- _st(stream)._nextPutAll_("Object");
- $ctx2.sendIdx["nextPutAll:"]=1;
- _st(stream)._nextPutAll_(" subclass: #NameOfSubclass");
- $ctx2.sendIdx["nextPutAll:"]=2;
- $3=_st($String())._lf();
- $ctx2.sendIdx["lf"]=1;
- $4=_st($String())._tab();
- $ctx2.sendIdx["tab"]=1;
- $2=_st($3).__comma($4);
- $ctx2.sendIdx[","]=1;
- _st(stream)._nextPutAll_($2);
- $ctx2.sendIdx["nextPutAll:"]=3;
- $5=_st(stream)._nextPutAll_("instanceVariableNames: ''");
- $ctx2.sendIdx["nextPutAll:"]=4;
- $5;
- $6=_st("'".__comma(_st($String())._lf())).__comma(_st($String())._tab());
- $ctx2.sendIdx[","]=2;
- _st(stream)._nextPutAll_($6);
- $ctx2.sendIdx["nextPutAll:"]=5;
- _st(stream)._nextPutAll_("package: '");
- $ctx2.sendIdx["nextPutAll:"]=6;
- _st(stream)._nextPutAll_(self._name());
- $ctx2.sendIdx["nextPutAll:"]=7;
- $7=_st(stream)._nextPutAll_("'");
- return $7;
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classTemplate",{},globals.Package)})},
- args: [],
- source: "classTemplate\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream\x0a\x09\x09\x09nextPutAll: 'Object';\x0a\x09\x09\x09nextPutAll: ' subclass: #NameOfSubclass';\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: 'instanceVariableNames: '''''.\x0a\x09\x09stream\x0a\x09\x09\x09nextPutAll: '''', String lf, String tab;\x0a\x09\x09\x09nextPutAll: 'package: ''';\x0a\x09\x09\x09nextPutAll: self name;\x0a\x09\x09\x09nextPutAll: '''' ]",
- messageSends: ["streamContents:", "nextPutAll:", ",", "lf", "tab", "name"],
- referencedClasses: ["String"]
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classes",
- protocol: 'classes',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._organization())._elements();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classes",{},globals.Package)})},
- args: [],
- source: "classes\x0a\x09^ self organization elements",
- messageSends: ["elements", "organization"],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "definition",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$4,$5,$3,$7,$6,$8,$9,$1;
- $1=_st($String())._streamContents_((function(stream){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(self._class())._name();
- $ctx2.sendIdx["name"]=1;
- _st(stream)._nextPutAll_($2);
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st($String())._lf();
- $ctx2.sendIdx["lf"]=1;
- $5=_st($String())._tab();
- $ctx2.sendIdx["tab"]=1;
- $3=_st($4).__comma($5);
- $ctx2.sendIdx[","]=1;
- _st(stream)._nextPutAll_($3);
- $ctx2.sendIdx["nextPutAll:"]=2;
- _st(stream)._nextPutAll_(" named: ");
- $ctx2.sendIdx["nextPutAll:"]=3;
- $7="'".__comma(self._name());
- $ctx2.sendIdx[","]=3;
- $6=_st($7).__comma("'");
- $ctx2.sendIdx[","]=2;
- _st(stream)._nextPutAll_($6);
- $ctx2.sendIdx["nextPutAll:"]=4;
- $8=_st(_st($String())._lf()).__comma(_st($String())._tab());
- $ctx2.sendIdx[","]=4;
- _st(stream)._nextPutAll_($8);
- $ctx2.sendIdx["nextPutAll:"]=5;
- _st(stream)._nextPutAll_(" transport: (");
- $ctx2.sendIdx["nextPutAll:"]=6;
- $9=_st(stream)._nextPutAll_(_st(_st(self._transport())._definition()).__comma(")"));
- return $9;
- }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"definition",{},globals.Package)})},
- args: [],
- source: "definition\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream \x0a\x09\x09\x09nextPutAll: self class name;\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: ' named: ';\x0a\x09\x09\x09nextPutAll: '''', self name, '''';\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: ' transport: (';\x0a\x09\x09\x09nextPutAll: self transport definition, ')' ]",
- messageSends: ["streamContents:", "nextPutAll:", "name", "class", ",", "lf", "tab", "definition", "transport"],
- referencedClasses: ["String"]
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isPackage",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isPackage\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "loadDependencies",
- protocol: 'dependencies',
- fn: function (){
- var self=this;
- var classes,packages;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- classes=self._loadDependencyClasses();
- $2=_st(_st(classes)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._package();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._asSet();
- _st($2)._remove_ifAbsent_(self,(function(){
- }));
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"loadDependencies",{classes:classes,packages:packages},globals.Package)})},
- args: [],
- source: "loadDependencies\x0a\x09\x22Returns list of packages that need to be loaded\x0a\x09before loading this package.\x22\x0a\x09\x0a\x09| classes packages |\x0a\x09classes := self loadDependencyClasses.\x0a\x09^ (classes collect: [ :each | each package ]) asSet\x0a\x09\x09remove: self ifAbsent: [];\x0a\x09\x09yourself",
- messageSends: ["loadDependencyClasses", "remove:ifAbsent:", "asSet", "collect:", "package", "yourself"],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "loadDependencyClasses",
- protocol: 'dependencies',
- fn: function (){
- var self=this;
- var starCategoryName;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $4,$3,$2,$6,$5,$7,$1;
- starCategoryName="*".__comma(self._name());
- $ctx1.sendIdx[","]=1;
- $4=self._classes();
- $ctx1.sendIdx["classes"]=1;
- $3=_st($4)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._superclass();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $2=_st($3)._asSet();
- _st($2)._remove_ifAbsent_(nil,(function(){
- }));
- _st($2)._addAll_(_st(_st($Smalltalk())._classes())._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $6=_st(each)._protocols();
- $ctx2.sendIdx["protocols"]=1;
- $5=_st($6).__comma(_st(_st(each)._class())._protocols());
- return _st($5)._includes_(starCategoryName);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})})));
- $7=_st($2)._yourself();
- $1=$7;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"loadDependencyClasses",{starCategoryName:starCategoryName},globals.Package)})},
- args: [],
- source: "loadDependencyClasses\x0a\x09\x22Returns classes needed at the time of loading a package.\x0a\x09These are all that are used to subclass\x0a\x09and to define an extension method\x22\x0a\x09\x0a\x09| starCategoryName |\x0a\x09starCategoryName := '*', self name.\x0a\x09^ (self classes collect: [ :each | each superclass ]) asSet\x0a\x09\x09remove: nil ifAbsent: [];\x0a\x09\x09addAll: (Smalltalk classes select: [ :each | each protocols, each class protocols includes: starCategoryName ]);\x0a\x09\x09yourself",
- messageSends: [",", "name", "remove:ifAbsent:", "asSet", "collect:", "classes", "superclass", "addAll:", "select:", "includes:", "protocols", "class", "yourself"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.pkgName;
- return self}, function($ctx1) {$ctx1.fill(self,"name",{},globals.Package)})},
- args: [],
- source: "name\x0a\x09<return self.pkgName>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.pkgName = aString;
- return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},globals.Package)})},
- args: ["aString"],
- source: "name: aString\x0a\x09<self.pkgName = aString>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "organization",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._basicAt_("organization");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"organization",{},globals.Package)})},
- args: [],
- source: "organization\x0a\x09^ self basicAt: 'organization'",
- messageSends: ["basicAt:"],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printOn:",
- protocol: 'printing',
- fn: function (aStream){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.Package.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
- _st(aStream)._nextPutAll_(" (");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aStream)._nextPutAll_(self._name());
- $ctx1.sendIdx["nextPutAll:"]=2;
- $1=_st(aStream)._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Package)})},
- args: ["aStream"],
- source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: ' (';\x0a\x09\x09nextPutAll: self name;\x0a\x09\x09nextPutAll: ')'",
- messageSends: ["printOn:", "nextPutAll:", "name"],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupClasses",
- protocol: 'classes',
- fn: function (){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self._classes();
- _st($1)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st($ClassBuilder())._new())._setupClass_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- $2=_st($1)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._initialize();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"setupClasses",{},globals.Package)})},
- args: [],
- source: "setupClasses\x0a\x09self classes\x0a\x09\x09do: [ :each | ClassBuilder new setupClass: each ];\x0a\x09\x09do: [ :each | each initialize ]",
- messageSends: ["do:", "classes", "setupClass:", "new", "initialize"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sortedClasses",
- protocol: 'classes',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._class())._sortedClasses_(self._classes());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sortedClasses",{},globals.Package)})},
- args: [],
- source: "sortedClasses\x0a\x09\x22Answer all classes in the receiver, sorted by superclass/subclasses and by class name for common subclasses (Issue #143).\x22\x0a\x0a\x09^ self class sortedClasses: self classes",
- messageSends: ["sortedClasses:", "class", "classes"],
- referencedClasses: []
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "transport",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $PackageTransport(){return globals.PackageTransport||(typeof PackageTransport=="undefined"?nil:PackageTransport)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$1;
- $2=self["@transport"];
- if(($receiver = $2) == nil || $receiver == null){
- $3=_st($PackageTransport())._fromJson_(self._basicTransport());
- _st($3)._package_(self);
- $4=_st($3)._yourself();
- self["@transport"]=$4;
- $1=self["@transport"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"transport",{},globals.Package)})},
- args: [],
- source: "transport\x0a\x09^ transport ifNil: [ \x0a\x09\x09transport := (PackageTransport fromJson: self basicTransport)\x0a\x09\x09\x09package: self;\x0a\x09\x09\x09yourself ]",
- messageSends: ["ifNil:", "package:", "fromJson:", "basicTransport", "yourself"],
- referencedClasses: ["PackageTransport"]
- }),
- globals.Package);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "transport:",
- protocol: 'accessing',
- fn: function (aPackageTransport){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@transport"]=aPackageTransport;
- _st(aPackageTransport)._package_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"transport:",{aPackageTransport:aPackageTransport},globals.Package)})},
- args: ["aPackageTransport"],
- source: "transport: aPackageTransport\x0a\x09transport := aPackageTransport.\x0a\x09aPackageTransport package: self",
- messageSends: ["package:"],
- referencedClasses: []
- }),
- globals.Package);
- globals.Package.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "named:",
- protocol: 'accessing',
- fn: function (aPackageName){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._packageAt_ifAbsent_(aPackageName,(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st($Smalltalk())._createPackage_(aPackageName);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"named:",{aPackageName:aPackageName},globals.Package.klass)})},
- args: ["aPackageName"],
- source: "named: aPackageName\x0a\x09^ Smalltalk \x0a\x09\x09packageAt: aPackageName\x0a\x09\x09ifAbsent: [ \x0a\x09\x09\x09Smalltalk createPackage: aPackageName ]",
- messageSends: ["packageAt:ifAbsent:", "createPackage:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Package.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "named:ifAbsent:",
- protocol: 'accessing',
- fn: function (aPackageName,aBlock){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._packageAt_ifAbsent_(aPackageName,aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"named:ifAbsent:",{aPackageName:aPackageName,aBlock:aBlock},globals.Package.klass)})},
- args: ["aPackageName", "aBlock"],
- source: "named: aPackageName ifAbsent: aBlock\x0a\x09^ Smalltalk packageAt: aPackageName ifAbsent: aBlock",
- messageSends: ["packageAt:ifAbsent:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Package.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "named:transport:",
- protocol: 'accessing',
- fn: function (aPackageName,aTransport){
- var self=this;
- var package_;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- package_=self._named_(aPackageName);
- _st(package_)._transport_(aTransport);
- $1=package_;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"named:transport:",{aPackageName:aPackageName,aTransport:aTransport,package_:package_},globals.Package.klass)})},
- args: ["aPackageName", "aTransport"],
- source: "named: aPackageName transport: aTransport\x0a\x09| package |\x0a\x09\x0a\x09package := self named: aPackageName.\x0a\x09package transport: aTransport.\x0a\x09\x0a\x09^ package",
- messageSends: ["named:", "transport:"],
- referencedClasses: []
- }),
- globals.Package.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sortedClasses:",
- protocol: 'sorting',
- fn: function (classes){
- var self=this;
- var children,others,nodes,expandedClasses;
- function $ClassSorterNode(){return globals.ClassSorterNode||(typeof ClassSorterNode=="undefined"?nil:ClassSorterNode)}
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4;
- children=[];
- others=[];
- _st(classes)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(classes)._includes_(_st(each)._superclass());
- if(smalltalk.assert($1)){
- return _st(others)._add_(each);
- } else {
- return _st(children)._add_(each);
- $ctx2.sendIdx["add:"]=1;
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- nodes=_st(children)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st($ClassSorterNode())._on_classes_level_(each,others,(0));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
- nodes=_st(nodes)._sorted_((function(a,b){
- return smalltalk.withContext(function($ctx2) {
- $3=_st(a)._theClass();
- $ctx2.sendIdx["theClass"]=1;
- $2=_st($3)._name();
- $ctx2.sendIdx["name"]=1;
- return _st($2).__lt_eq(_st(_st(b)._theClass())._name());
- }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,5)})}));
- expandedClasses=_st($Array())._new();
- _st(nodes)._do_((function(aNode){
- return smalltalk.withContext(function($ctx2) {
- return _st(aNode)._traverseClassesWith_(expandedClasses);
- }, function($ctx2) {$ctx2.fillBlock({aNode:aNode},$ctx1,6)})}));
- $4=expandedClasses;
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"sortedClasses:",{classes:classes,children:children,others:others,nodes:nodes,expandedClasses:expandedClasses},globals.Package.klass)})},
- args: ["classes"],
- source: "sortedClasses: classes\x0a\x09\x22Answer classes, sorted by superclass/subclasses and by class name for common subclasses (Issue #143)\x22\x0a\x0a\x09| children others nodes expandedClasses |\x0a\x09children := #().\x0a\x09others := #().\x0a\x09classes do: [ :each |\x0a\x09\x09(classes includes: each superclass)\x0a\x09\x09\x09ifFalse: [ children add: each ]\x0a\x09\x09\x09ifTrue: [ others add: each ]].\x0a\x09nodes := children collect: [ :each |\x0a\x09\x09ClassSorterNode on: each classes: others level: 0 ].\x0a\x09nodes := nodes sorted: [ :a :b | a theClass name <= b theClass name ].\x0a\x09expandedClasses := Array new.\x0a\x09nodes do: [ :aNode |\x0a\x09\x09aNode traverseClassesWith: expandedClasses ].\x0a\x09^ expandedClasses",
- messageSends: ["do:", "ifFalse:ifTrue:", "includes:", "superclass", "add:", "collect:", "on:classes:level:", "sorted:", "<=", "name", "theClass", "new", "traverseClassesWith:"],
- referencedClasses: ["ClassSorterNode", "Array"]
- }),
- globals.Package.klass);
- smalltalk.addClass('PlatformInterface', globals.Object, [], 'Kernel-Infrastructure');
- globals.PlatformInterface.comment="I am single entry point to UI and environment interface.\x0aMy `initialize` tries several options (for now, browser environment only) to set myself up.\x0a\x0a## API\x0a\x0a PlatformInterface alert: 'Hey, there is a problem'.\x0a PlatformInterface confirm: 'Affirmative?'.\x0a PlatformInterface prompt: 'Your name:'.\x0a\x0a PlatformInterface ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.";
- globals.PlatformInterface.klass.iVarNames = ['worker'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ajax:",
- protocol: 'actions',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@worker"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._error_("ajax: not available");
- } else {
- $1=_st(self["@worker"])._ajax_(anObject);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},globals.PlatformInterface.klass)})},
- args: ["anObject"],
- source: "ajax: anObject\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker ajax: anObject ]\x0a\x09\x09ifNil: [ self error: 'ajax: not available' ]",
- messageSends: ["ifNotNil:ifNil:", "ajax:", "error:"],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alert:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@worker"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._error_("alert: not available");
- } else {
- $1=_st(self["@worker"])._alert_(aString);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},globals.PlatformInterface.klass)})},
- args: ["aString"],
- source: "alert: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker alert: aString ]\x0a\x09\x09ifNil: [ self error: 'alert: not available' ]",
- messageSends: ["ifNotNil:ifNil:", "alert:", "error:"],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "confirm:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@worker"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._error_("confirm: not available");
- } else {
- $1=_st(self["@worker"])._confirm_(aString);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},globals.PlatformInterface.klass)})},
- args: ["aString"],
- source: "confirm: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker confirm: aString ]\x0a\x09\x09ifNil: [ self error: 'confirm: not available' ]",
- messageSends: ["ifNotNil:ifNil:", "confirm:", "error:"],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "existsGlobal:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($PlatformInterface())._globals())._at_ifPresent_ifAbsent_(aString,(function(){
- return true;
- }),(function(){
- return false;
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"existsGlobal:",{aString:aString},globals.PlatformInterface.klass)})},
- args: ["aString"],
- source: "existsGlobal: aString\x0a\x09^ PlatformInterface globals \x0a\x09\x09at: aString \x0a\x09\x09ifPresent: [ true ] \x0a\x09\x09ifAbsent: [ false ]",
- messageSends: ["at:ifPresent:ifAbsent:", "globals"],
- referencedClasses: ["PlatformInterface"]
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "globals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return (new Function('return this'))();;
- return self}, function($ctx1) {$ctx1.fill(self,"globals",{},globals.PlatformInterface.klass)})},
- args: [],
- source: "globals\x0a\x09<return (new Function('return this'))();>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- var candidate;
- function $BrowserInterface(){return globals.BrowserInterface||(typeof BrowserInterface=="undefined"?nil:BrowserInterface)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.PlatformInterface.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
- if(($receiver = $BrowserInterface()) == nil || $receiver == null){
- $BrowserInterface();
- } else {
- candidate=_st($BrowserInterface())._new();
- candidate;
- $1=_st(candidate)._isAvailable();
- if(smalltalk.assert($1)){
- self._setWorker_(candidate);
- return self;
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{candidate:candidate},globals.PlatformInterface.klass)})},
- args: [],
- source: "initialize\x0a\x09| candidate |\x0a\x09\x0a\x09super initialize.\x0a\x09\x0a\x09BrowserInterface ifNotNil: [\x0a\x09\x09candidate := BrowserInterface new.\x0a\x09\x09candidate isAvailable ifTrue: [ self setWorker: candidate. ^ self ]\x0a\x09]",
- messageSends: ["initialize", "ifNotNil:", "new", "ifTrue:", "isAvailable", "setWorker:"],
- referencedClasses: ["BrowserInterface"]
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "prompt:",
- protocol: 'actions',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@worker"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=self._error_("prompt: not available");
- } else {
- $1=_st(self["@worker"])._prompt_(aString);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},globals.PlatformInterface.klass)})},
- args: ["aString"],
- source: "prompt: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker prompt: aString ]\x0a\x09\x09ifNil: [ self error: 'prompt: not available' ]",
- messageSends: ["ifNotNil:ifNil:", "prompt:", "error:"],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setWorker:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@worker"]=anObject;
- return self},
- args: ["anObject"],
- source: "setWorker: anObject\x0a\x09worker := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PlatformInterface.klass);
- smalltalk.addClass('Service', globals.Object, [], 'Kernel-Infrastructure');
- globals.Service.comment="I implement the basic behavior for class registration to a service.\x0a\x0aSee the `Transcript` class for a concrete service.\x0a\x0a## API\x0a\x0aUse class-side methods `#register:` and `#registerIfNone:` to register classes to a specific service.";
- globals.Service.klass.iVarNames = ['current'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "current",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@current"];
- return $1;
- },
- args: [],
- source: "current\x0a\x09^ current",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Service.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldNotImplement();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.Service.klass)})},
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- messageSends: ["shouldNotImplement"],
- referencedClasses: []
- }),
- globals.Service.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "register:",
- protocol: 'registration',
- fn: function (anObject){
- var self=this;
- self["@current"]=anObject;
- return self},
- args: ["anObject"],
- source: "register: anObject\x0a\x09current := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Service.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "registerIfNone:",
- protocol: 'registration',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._current();
- if(($receiver = $1) == nil || $receiver == null){
- self._register_(anObject);
- } else {
- $1;
- };
- return self}, function($ctx1) {$ctx1.fill(self,"registerIfNone:",{anObject:anObject},globals.Service.klass)})},
- args: ["anObject"],
- source: "registerIfNone: anObject\x0a\x09self current ifNil: [ self register: anObject ]",
- messageSends: ["ifNil:", "current", "register:"],
- referencedClasses: []
- }),
- globals.Service.klass);
- smalltalk.addClass('ErrorHandler', globals.Service, [], 'Kernel-Infrastructure');
- globals.ErrorHandler.comment="I am the service used to handle Smalltalk errors.\x0aSee `boot.js` `handleError()` function.\x0a\x0aRegistered service instances must implement `#handleError:` to perform an action on the thrown exception.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleError:",
- protocol: 'error handling',
- fn: function (anError){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._handleError_(anError);
- return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.ErrorHandler.klass)})},
- args: ["anError"],
- source: "handleError: anError\x0a\x09self current handleError: anError",
- messageSends: ["handleError:", "current"],
- referencedClasses: []
- }),
- globals.ErrorHandler.klass);
- smalltalk.addClass('Inspector', globals.Service, [], 'Kernel-Infrastructure');
- globals.Inspector.comment="I am the service responsible for inspecting objects.\x0a\x0aThe default inspector object is the transcript.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspect:",
- protocol: 'inspecting',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._current())._inspect_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Inspector.klass)})},
- args: ["anObject"],
- source: "inspect: anObject\x0a\x09^ self current inspect: anObject",
- messageSends: ["inspect:", "current"],
- referencedClasses: []
- }),
- globals.Inspector.klass);
- smalltalk.addClass('ProgressHandler', globals.Service, [], 'Kernel-Infrastructure');
- globals.ProgressHandler.comment="I am used to manage progress in collection iterations, see `SequenceableCollection >> #do:displayingProgress:`.\x0a\x0aRegistered instances must implement `#do:on:displaying:`.\x0a\x0aThe default behavior is to simply iterate over the collection, using `NullProgressHandler`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:on:displaying:",
- protocol: 'progress handling',
- fn: function (aBlock,aCollection,aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._do_on_displaying_(aBlock,aCollection,aString);
- return self}, function($ctx1) {$ctx1.fill(self,"do:on:displaying:",{aBlock:aBlock,aCollection:aCollection,aString:aString},globals.ProgressHandler.klass)})},
- args: ["aBlock", "aCollection", "aString"],
- source: "do: aBlock on: aCollection displaying: aString\x0a\x09self current do: aBlock on: aCollection displaying: aString",
- messageSends: ["do:on:displaying:", "current"],
- referencedClasses: []
- }),
- globals.ProgressHandler.klass);
- smalltalk.addClass('Transcript', globals.Service, [], 'Kernel-Infrastructure');
- globals.Transcript.comment="I am a facade for Transcript actions.\x0a\x0aI delegate actions to the currently registered transcript.\x0a\x0a## API\x0a\x0a Transcript \x0a show: 'hello world';\x0a cr;\x0a show: anObject.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clear",
- protocol: 'printing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._clear();
- return self}, function($ctx1) {$ctx1.fill(self,"clear",{},globals.Transcript.klass)})},
- args: [],
- source: "clear\x0a\x09self current clear",
- messageSends: ["clear", "current"],
- referencedClasses: []
- }),
- globals.Transcript.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cr",
- protocol: 'printing',
- fn: function (){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._show_(_st($String())._cr());
- return self}, function($ctx1) {$ctx1.fill(self,"cr",{},globals.Transcript.klass)})},
- args: [],
- source: "cr\x0a\x09self current show: String cr",
- messageSends: ["show:", "current", "cr"],
- referencedClasses: ["String"]
- }),
- globals.Transcript.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inspect:",
- protocol: 'printing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._show_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Transcript.klass)})},
- args: ["anObject"],
- source: "inspect: anObject\x0a\x09self show: anObject",
- messageSends: ["show:"],
- referencedClasses: []
- }),
- globals.Transcript.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "open",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._open();
- return self}, function($ctx1) {$ctx1.fill(self,"open",{},globals.Transcript.klass)})},
- args: [],
- source: "open\x0a\x09self current open",
- messageSends: ["open", "current"],
- referencedClasses: []
- }),
- globals.Transcript.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "show:",
- protocol: 'printing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._current())._show_(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},globals.Transcript.klass)})},
- args: ["anObject"],
- source: "show: anObject\x0a\x09self current show: anObject",
- messageSends: ["show:", "current"],
- referencedClasses: []
- }),
- globals.Transcript.klass);
- smalltalk.addClass('Setting', globals.Object, ['key', 'value', 'defaultValue'], 'Kernel-Infrastructure');
- globals.Setting.comment="I represent a setting accessible via `Smalltalk settings`.\x0a\x0a## API\x0a\x0aA `Setting` value can be read using `value` and set using `value:`.\x0a\x0aSettings are accessed with `'key' asSetting` or `'key' asSettingIfAbsent: 'defaultValue'`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultValue",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@defaultValue"];
- return $1;
- },
- args: [],
- source: "defaultValue\x0a\x09^ defaultValue",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultValue:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@defaultValue"]=anObject;
- return self},
- args: ["anObject"],
- source: "defaultValue: anObject\x0a\x09defaultValue := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "key",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@key"];
- return $1;
- },
- args: [],
- source: "key\x0a\x09^ key",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "key:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@key"]=anObject;
- return self},
- args: ["anObject"],
- source: "key: anObject\x0a\x09key := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Smalltalk())._settings())._at_ifAbsent_(self._key(),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._defaultValue();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value",{},globals.Setting)})},
- args: [],
- source: "value\x0a\x09^ Smalltalk settings at: self key ifAbsent: [ self defaultValue ]",
- messageSends: ["at:ifAbsent:", "settings", "key", "defaultValue"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Smalltalk())._settings())._at_put_(self._key(),aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:",{aString:aString},globals.Setting)})},
- args: ["aString"],
- source: "value: aString\x0a\x09^ Smalltalk settings at: self key put: aString",
- messageSends: ["at:put:", "settings", "key"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Setting);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'instance creation',
- fn: function (aString,anotherString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=globals.Setting.klass.superclass.fn.prototype._new.apply(_st(self), []);
- _st($2)._key_(aString);
- _st($2)._defaultValue_(anotherString);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aString:aString,anotherString:anotherString},globals.Setting.klass)})},
- args: ["aString", "anotherString"],
- source: "at: aString ifAbsent: anotherString\x0a\x09^ super new\x0a\x09\x09key: aString;\x0a\x09\x09defaultValue: anotherString;\x0a\x09\x09yourself",
- messageSends: ["key:", "new", "defaultValue:", "yourself"],
- referencedClasses: []
- }),
- globals.Setting.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldNotImplement();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.Setting.klass)})},
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- messageSends: ["shouldNotImplement"],
- referencedClasses: []
- }),
- globals.Setting.klass);
- smalltalk.addClass('SmalltalkImage', globals.Object, [], 'Kernel-Infrastructure');
- globals.SmalltalkImage.comment="I represent the Smalltalk system, wrapping\x0aoperations of variable `smalltalk` declared in `js/boot.js`.\x0a\x0a## API\x0a\x0aI have only one instance, accessed with global variable `Smalltalk`.\x0a\x0aThe `smalltalk` object holds all class and packages defined in the system.\x0a\x0a## Classes\x0a\x0aClasses can be accessed using the following methods:\x0a\x0a- `#classes` answers the full list of Smalltalk classes in the system\x0a- `#at:` answers a specific class or `nil`\x0a\x0a## Packages\x0a\x0aPackages can be accessed using the following methods:\x0a\x0a- `#packages` answers the full list of packages\x0a- `#packageAt:` answers a specific package or `nil`\x0a\x0a## Parsing\x0a\x0aThe `#parse:` method is used to parse Amber source code.\x0aIt requires the `Compiler` package and the `js/parser.js` parser file in order to work.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addGlobalJsVariable:",
- protocol: 'globals',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._globalJsVariables())._add_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"addGlobalJsVariable:",{aString:aString},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "addGlobalJsVariable: aString\x0a\x09self globalJsVariables add: aString",
- messageSends: ["add:", "globalJsVariables"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "amdRequire",
- protocol: 'accessing amd',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._vm())._at_("amdRequire");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"amdRequire",{},globals.SmalltalkImage)})},
- args: [],
- source: "amdRequire\x0a\x09^ self vm at: 'amdRequire'",
- messageSends: ["at:", "vm"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSmalltalkException:",
- protocol: 'error handling',
- fn: function (anObject){
- var self=this;
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- function $JavaScriptException(){return globals.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(self._isSmalltalkObject_(anObject))._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(anObject)._isKindOf_($Error());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($2)){
- $1=anObject;
- } else {
- $1=_st($JavaScriptException())._on_(anObject);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asSmalltalkException:",{anObject:anObject},globals.SmalltalkImage)})},
- args: ["anObject"],
- source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
- messageSends: ["ifTrue:ifFalse:", "and:", "isSmalltalkObject:", "isKindOf:", "on:"],
- referencedClasses: ["Error", "JavaScriptException"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=_st(self._globals())._at_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "at: aString\x0a\x09self deprecatedAPI.\x0a\x09^ self globals at: aString",
- messageSends: ["deprecatedAPI", "at:", "globals"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:ifAbsent:",
- protocol: 'accessing',
- fn: function (aKey,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._includesKey_(aKey);
- if(smalltalk.assert($2)){
- $1=self._at_(aKey);
- } else {
- $1=_st(aBlock)._value();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.SmalltalkImage)})},
- args: ["aKey", "aBlock"],
- source: "at: aKey ifAbsent: aBlock\x0a\x09^ (self includesKey: aKey)\x0a\x09\x09ifTrue: [ self at: aKey ]\x0a\x09\x09ifFalse: [ aBlock value ]",
- messageSends: ["ifTrue:ifFalse:", "includesKey:", "at:", "value"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "at:put:",
- protocol: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=_st(self._globals())._at_put_(aString,anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},globals.SmalltalkImage)})},
- args: ["aString", "anObject"],
- source: "at: aString put: anObject\x0a\x09self deprecatedAPI.\x0a\x09^ self globals at: aString put: anObject",
- messageSends: ["deprecatedAPI", "at:put:", "globals"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicCreatePackage:",
- protocol: 'private',
- fn: function (packageName){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.addPackage(packageName);
- return self}, function($ctx1) {$ctx1.fill(self,"basicCreatePackage:",{packageName:packageName},globals.SmalltalkImage)})},
- args: ["packageName"],
- source: "basicCreatePackage: packageName\x0a\x09\x22Create and bind a new bare package with given name and return it.\x22\x0a\x09<return smalltalk.addPackage(packageName)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicParse:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- function $SmalltalkParser(){return globals.SmalltalkParser||(typeof SmalltalkParser=="undefined"?nil:SmalltalkParser)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($SmalltalkParser())._parse_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"basicParse:",{aString:aString},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "basicParse: aString\x0a\x09^ SmalltalkParser parse: aString",
- messageSends: ["parse:"],
- referencedClasses: ["SmalltalkParser"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classes",
- protocol: 'classes',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.classes();
- return self}, function($ctx1) {$ctx1.fill(self,"classes",{},globals.SmalltalkImage)})},
- args: [],
- source: "classes\x0a\x09<return smalltalk.classes()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "createPackage:",
- protocol: 'packages',
- fn: function (packageName){
- var self=this;
- var package_,announcement;
- function $PackageAdded(){return globals.PackageAdded||(typeof PackageAdded=="undefined"?nil:PackageAdded)}
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- package_=self._basicCreatePackage_(packageName);
- $1=_st($PackageAdded())._new();
- _st($1)._package_(package_);
- $2=_st($1)._yourself();
- announcement=$2;
- _st(_st($SystemAnnouncer())._current())._announce_(announcement);
- $3=package_;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"createPackage:",{packageName:packageName,package_:package_,announcement:announcement},globals.SmalltalkImage)})},
- args: ["packageName"],
- source: "createPackage: packageName\x0a\x09| package announcement |\x0a\x09\x0a\x09package := self basicCreatePackage: packageName.\x0a\x09announcement := PackageAdded new\x0a\x09\x09package: package;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09SystemAnnouncer current announce: announcement.\x0a\x09\x0a\x09^ package",
- messageSends: ["basicCreatePackage:", "package:", "new", "yourself", "announce:", "current"],
- referencedClasses: ["PackageAdded", "SystemAnnouncer"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "createPackage:properties:",
- protocol: 'private',
- fn: function (packageName,aDict){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._deprecatedAPI();
- $1=_st(aDict)._isEmpty();
- if(! smalltalk.assert($1)){
- self._error_("createPackage:properties: called with nonempty properties");
- };
- $2=self._createPackage_(packageName);
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"createPackage:properties:",{packageName:packageName,aDict:aDict},globals.SmalltalkImage)})},
- args: ["packageName", "aDict"],
- source: "createPackage: packageName properties: aDict\x0a\x09\x22Needed to import .st files: they begin with this call.\x22\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09aDict isEmpty ifFalse: [ self error: 'createPackage:properties: called with nonempty properties' ].\x0a\x09^ self createPackage: packageName",
- messageSends: ["deprecatedAPI", "ifFalse:", "isEmpty", "error:", "createPackage:"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "current",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._deprecatedAPI();
- return self;
- }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SmalltalkImage)})},
- args: [],
- source: "current\x0a\x09\x22Backward compatibility for Smalltalk current ...\x22\x0a\x09self deprecatedAPI.\x0a\x09^ self",
- messageSends: ["deprecatedAPI"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultAmdNamespace",
- protocol: 'accessing amd',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1="transport.defaultAmdNamespace"._settingValue();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"defaultAmdNamespace",{},globals.SmalltalkImage)})},
- args: [],
- source: "defaultAmdNamespace\x0a\x09^ 'transport.defaultAmdNamespace' settingValue",
- messageSends: ["settingValue"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultAmdNamespace:",
- protocol: 'accessing amd',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- "transport.defaultAmdNamespace"._settingValue_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"defaultAmdNamespace:",{aString:aString},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "defaultAmdNamespace: aString\x0a\x09'transport.defaultAmdNamespace' settingValue: aString",
- messageSends: ["settingValue:"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deleteClass:",
- protocol: 'private',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- smalltalk.removeClass(aClass);
- return self}, function($ctx1) {$ctx1.fill(self,"deleteClass:",{aClass:aClass},globals.SmalltalkImage)})},
- args: ["aClass"],
- source: "deleteClass: aClass\x0a\x09\x22Deletes a class by deleting its binding only. Use #removeClass instead\x22\x0a\x09\x0a\x09<smalltalk.removeClass(aClass)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deleteGlobalJsVariable:",
- protocol: 'globals',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._globalJsVariables())._remove_ifAbsent_(aString,(function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"deleteGlobalJsVariable:",{aString:aString},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "deleteGlobalJsVariable: aString\x0a\x09self globalJsVariables remove: aString ifAbsent:[]",
- messageSends: ["remove:ifAbsent:", "globalJsVariables"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deletePackage:",
- protocol: 'private',
- fn: function (packageName){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- delete smalltalk.packages[packageName];
- return self}, function($ctx1) {$ctx1.fill(self,"deletePackage:",{packageName:packageName},globals.SmalltalkImage)})},
- args: ["packageName"],
- source: "deletePackage: packageName\x0a\x09\x22Deletes a package by deleting its binding, but does not check if it contains classes etc.\x0a\x09To remove a package, use #removePackage instead.\x22\x0a\x0a\x09<delete smalltalk.packages[packageName]>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "globalJsVariables",
- protocol: 'globals',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.globalJsVariables;
- return self}, function($ctx1) {$ctx1.fill(self,"globalJsVariables",{},globals.SmalltalkImage)})},
- args: [],
- source: "globalJsVariables\x0a\x09\x22Array of global JavaScript variables\x22\x0a\x09<return smalltalk.globalJsVariables>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "globals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return globals;
- return self}, function($ctx1) {$ctx1.fill(self,"globals",{},globals.SmalltalkImage)})},
- args: [],
- source: "globals\x0a\x09\x22Future compatibility to be able to use Smalltalk globals at: ...\x22\x0a\x09<return globals>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "includesKey:",
- protocol: 'accessing',
- fn: function (aKey){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.hasOwnProperty(aKey);
- return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},globals.SmalltalkImage)})},
- args: ["aKey"],
- source: "includesKey: aKey\x0a\x09<return smalltalk.hasOwnProperty(aKey)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSmalltalkObject:",
- protocol: 'testing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return typeof anObject.klass !== 'undefined';
- return self}, function($ctx1) {$ctx1.fill(self,"isSmalltalkObject:",{anObject:anObject},globals.SmalltalkImage)})},
- args: ["anObject"],
- source: "isSmalltalkObject: anObject\x0a\x09\x22Consider anObject a Smalltalk object if it has a 'klass' property.\x0a\x09Note that this may be unaccurate\x22\x0a\x09\x0a\x09<return typeof anObject.klass !== 'undefined'>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "packageAt:",
- protocol: 'packages',
- fn: function (packageName){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.packages[packageName];
- return self}, function($ctx1) {$ctx1.fill(self,"packageAt:",{packageName:packageName},globals.SmalltalkImage)})},
- args: ["packageName"],
- source: "packageAt: packageName\x0a\x09<return smalltalk.packages[packageName]>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "packageAt:ifAbsent:",
- protocol: 'packages',
- fn: function (packageName,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._packageAt_(packageName);
- $1=_st($2)._ifNil_(aBlock);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"packageAt:ifAbsent:",{packageName:packageName,aBlock:aBlock},globals.SmalltalkImage)})},
- args: ["packageName", "aBlock"],
- source: "packageAt: packageName ifAbsent: aBlock\x0a\x09^ (self packageAt: packageName) ifNil: aBlock",
- messageSends: ["ifNil:", "packageAt:"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "packages",
- protocol: 'packages',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return Object.keys(smalltalk.packages).map(function(k) {
- return smalltalk.packages[k];
- })
- ;
- return self}, function($ctx1) {$ctx1.fill(self,"packages",{},globals.SmalltalkImage)})},
- args: [],
- source: "packages\x0a\x09\x22Return all Package instances in the system.\x22\x0a\x0a\x09<\x0a\x09\x09return Object.keys(smalltalk.packages).map(function(k) {\x0a\x09\x09\x09return smalltalk.packages[k];\x0a\x09\x09})\x0a\x09>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parse:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- var result;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- self._try_catch_((function(){
- return smalltalk.withContext(function($ctx2) {
- result=self._basicParse_(aString);
- return result;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(ex){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._parseError_parsing_(ex,aString))._signal();
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
- $2=result;
- _st($2)._source_(aString);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString,result:result},globals.SmalltalkImage)})},
- args: ["aString"],
- source: "parse: aString\x0a\x09| result |\x0a\x09\x0a\x09self \x0a\x09\x09try: [ result := self basicParse: aString ] \x0a\x09\x09catch: [ :ex | (self parseError: ex parsing: aString) signal ].\x0a\x09\x09\x0a\x09^ result\x0a\x09\x09source: aString;\x0a\x09\x09yourself",
- messageSends: ["try:catch:", "basicParse:", "signal", "parseError:parsing:", "source:", "yourself"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parseError:parsing:",
- protocol: 'error handling',
- fn: function (anException,aString){
- var self=this;
- function $ParseError(){return globals.ParseError||(typeof ParseError=="undefined"?nil:ParseError)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$8,$7,$6,$9,$5,$4,$3,$1;
- $2=_st($ParseError())._new();
- $8=_st(anException)._basicAt_("line");
- $ctx1.sendIdx["basicAt:"]=1;
- $7="Parse error on line ".__comma($8);
- $6=_st($7).__comma(" column ");
- $ctx1.sendIdx[","]=4;
- $9=_st(anException)._basicAt_("column");
- $ctx1.sendIdx["basicAt:"]=2;
- $5=_st($6).__comma($9);
- $ctx1.sendIdx[","]=3;
- $4=_st($5).__comma(" : Unexpected character ");
- $ctx1.sendIdx[","]=2;
- $3=_st($4).__comma(_st(anException)._basicAt_("found"));
- $ctx1.sendIdx[","]=1;
- $1=_st($2)._messageText_($3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parseError:parsing:",{anException:anException,aString:aString},globals.SmalltalkImage)})},
- args: ["anException", "aString"],
- source: "parseError: anException parsing: aString\x0a\x09^ ParseError new messageText: 'Parse error on line ', (anException basicAt: 'line') ,' column ' , (anException basicAt: 'column') ,' : Unexpected character ', (anException basicAt: 'found')",
- messageSends: ["messageText:", "new", ",", "basicAt:"],
- referencedClasses: ["ParseError"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pseudoVariableNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=["self", "super", "nil", "true", "false", "thisContext"];
- return $1;
- },
- args: [],
- source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "readJSObject:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.readJSObject(anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"readJSObject:",{anObject:anObject},globals.SmalltalkImage)})},
- args: ["anObject"],
- source: "readJSObject: anObject\x0a\x09<return smalltalk.readJSObject(anObject)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeClass:",
- protocol: 'classes',
- fn: function (aClass){
- var self=this;
- function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
- function $ClassRemoved(){return globals.ClassRemoved||(typeof ClassRemoved=="undefined"?nil:ClassRemoved)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st(aClass)._isMetaclass();
- if(smalltalk.assert($1)){
- self._error_(_st(_st(aClass)._asString()).__comma(" is a Metaclass and cannot be removed!"));
- };
- self._deleteClass_(aClass);
- $2=_st($ClassRemoved())._new();
- _st($2)._theClass_(aClass);
- $3=_st($2)._yourself();
- _st(_st($SystemAnnouncer())._current())._announce_($3);
- return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},globals.SmalltalkImage)})},
- args: ["aClass"],
- source: "removeClass: aClass\x0a\x09aClass isMetaclass ifTrue: [ self error: aClass asString, ' is a Metaclass and cannot be removed!' ].\x0a\x09\x0a\x09self deleteClass: aClass.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassRemoved new\x0a\x09\x09\x09theClass: aClass;\x0a\x09\x09\x09yourself)",
- messageSends: ["ifTrue:", "isMetaclass", "error:", ",", "asString", "deleteClass:", "announce:", "current", "theClass:", "new", "yourself"],
- referencedClasses: ["SystemAnnouncer", "ClassRemoved"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removePackage:",
- protocol: 'packages',
- fn: function (packageName){
- var self=this;
- var pkg;
- return smalltalk.withContext(function($ctx1) {
- pkg=self._packageAt_ifAbsent_(packageName,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Missing package: ".__comma(packageName));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- _st(_st(pkg)._classes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._removeClass_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- self._deletePackage_(packageName);
- return self}, function($ctx1) {$ctx1.fill(self,"removePackage:",{packageName:packageName,pkg:pkg},globals.SmalltalkImage)})},
- args: ["packageName"],
- source: "removePackage: packageName\x0a\x09\x22Removes a package and all its classes.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [ self error: 'Missing package: ', packageName ].\x0a\x09pkg classes do: [ :each |\x0a\x09\x09\x09self removeClass: each ].\x0a\x09self deletePackage: packageName",
- messageSends: ["packageAt:ifAbsent:", "error:", ",", "do:", "classes", "removeClass:", "deletePackage:"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "renamePackage:to:",
- protocol: 'packages',
- fn: function (packageName,newName){
- var self=this;
- var pkg;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- pkg=self._packageAt_ifAbsent_(packageName,(function(){
- return smalltalk.withContext(function($ctx2) {
- $1="Missing package: ".__comma(packageName);
- $ctx2.sendIdx[","]=1;
- return self._error_($1);
- $ctx2.sendIdx["error:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $2=self._packageAt_(newName);
- if(($receiver = $2) == nil || $receiver == null){
- $2;
- } else {
- self._error_("Already exists a package called: ".__comma(newName));
- };
- _st(self._at_("packages"))._at_put_(newName,pkg);
- _st(pkg)._name_(newName);
- self._deletePackage_(packageName);
- return self}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},globals.SmalltalkImage)})},
- args: ["packageName", "newName"],
- source: "renamePackage: packageName to: newName\x0a\x09\x22Rename a package.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [ self error: 'Missing package: ', packageName ].\x0a\x09(self packageAt: newName) ifNotNil: [ self error: 'Already exists a package called: ', newName ].\x0a\x09(self at: 'packages') at: newName put: pkg.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
- messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "at:", "name:", "deletePackage:"],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "reservedWords",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk.reservedWords;
- return self}, function($ctx1) {$ctx1.fill(self,"reservedWords",{},globals.SmalltalkImage)})},
- args: [],
- source: "reservedWords\x0a\x09\x22JavaScript reserved words\x22\x0a\x09<return smalltalk.reservedWords>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "settings",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $SmalltalkSettings(){return globals.SmalltalkSettings||(typeof SmalltalkSettings=="undefined"?nil:SmalltalkSettings)}
- return $SmalltalkSettings();
- },
- args: [],
- source: "settings\x0a\x09^ SmalltalkSettings",
- messageSends: [],
- referencedClasses: ["SmalltalkSettings"]
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "version",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "0.13.0-pre";
- },
- args: [],
- source: "version\x0a\x09\x22Answer the version string of Amber\x22\x0a\x09\x0a\x09^ '0.13.0-pre'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "vm",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return smalltalk;
- return self}, function($ctx1) {$ctx1.fill(self,"vm",{},globals.SmalltalkImage)})},
- args: [],
- source: "vm\x0a\x09\x22Future compatibility to be able to use Smalltalk vm ...\x22\x0a\x09<return smalltalk>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SmalltalkImage);
- globals.SmalltalkImage.klass.iVarNames = ['current'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "current",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@current"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@current"]=globals.SmalltalkImage.klass.superclass.fn.prototype._new.apply(_st(self), []);
- $1=self["@current"];
- } else {
- self._deprecatedAPI();
- $1=self["@current"];
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SmalltalkImage.klass)})},
- args: [],
- source: "current\x0a\x09^ current ifNil: [ current := super new ] ifNotNil: [ self deprecatedAPI. current ]",
- messageSends: ["ifNil:ifNotNil:", "new", "deprecatedAPI"],
- referencedClasses: []
- }),
- globals.SmalltalkImage.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(globals)._at_put_("Smalltalk",self._current());
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.SmalltalkImage.klass)})},
- args: [],
- source: "initialize\x0a\x09globals at: 'Smalltalk' put: self current",
- messageSends: ["at:put:", "current"],
- referencedClasses: []
- }),
- globals.SmalltalkImage.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldNotImplement();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.SmalltalkImage.klass)})},
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- messageSends: ["shouldNotImplement"],
- referencedClasses: []
- }),
- globals.SmalltalkImage.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "do:displayingProgress:",
- protocol: '*Kernel-Infrastructure',
- fn: function (aBlock,aString){
- var self=this;
- function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
- return smalltalk.withContext(function($ctx1) {
- _st($ProgressHandler())._do_on_displaying_(aBlock,self,aString);
- return self}, function($ctx1) {$ctx1.fill(self,"do:displayingProgress:",{aBlock:aBlock,aString:aString},globals.SequenceableCollection)})},
- args: ["aBlock", "aString"],
- source: "do: aBlock displayingProgress: aString\x0a\x09ProgressHandler \x0a\x09\x09do: aBlock \x0a\x09\x09on: self \x0a\x09\x09displaying: aString",
- messageSends: ["do:on:displaying:"],
- referencedClasses: ["ProgressHandler"]
- }),
- globals.SequenceableCollection);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asJavaScriptSelector",
- protocol: '*Kernel-Infrastructure',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._replace_with_("^([a-zA-Z0-9]*).*$","$1");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asJavaScriptSelector",{},globals.String)})},
- args: [],
- source: "asJavaScriptSelector\x0a\x09\x22Return first keyword of the selector, without trailing colon.\x22\x0a\x09^ self replace: '^([a-zA-Z0-9]*).*$' with: '$1'",
- messageSends: ["replace:with:"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSetting",
- protocol: '*Kernel-Infrastructure',
- fn: function (){
- var self=this;
- function $Setting(){return globals.Setting||(typeof Setting=="undefined"?nil:Setting)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Setting())._at_ifAbsent_(self,nil);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asSetting",{},globals.String)})},
- args: [],
- source: "asSetting\x0a\x09^ Setting at: self ifAbsent: nil",
- messageSends: ["at:ifAbsent:"],
- referencedClasses: ["Setting"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asSettingIfAbsent:",
- protocol: '*Kernel-Infrastructure',
- fn: function (aString){
- var self=this;
- function $Setting(){return globals.Setting||(typeof Setting=="undefined"?nil:Setting)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Setting())._at_ifAbsent_(self,aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asSettingIfAbsent:",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "asSettingIfAbsent: aString\x0a\x09^ Setting at: self ifAbsent: aString",
- messageSends: ["at:ifAbsent:"],
- referencedClasses: ["Setting"]
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "settingValue",
- protocol: '*Kernel-Infrastructure',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asSetting())._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"settingValue",{},globals.String)})},
- args: [],
- source: "settingValue\x0a\x09^ self asSetting value",
- messageSends: ["value", "asSetting"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "settingValue:",
- protocol: '*Kernel-Infrastructure',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asSetting())._value_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"settingValue:",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "settingValue: aString\x0a\x09^ self asSetting value: aString",
- messageSends: ["value:", "asSetting"],
- referencedClasses: []
- }),
- globals.String);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "settingValueIfAbsent:",
- protocol: '*Kernel-Infrastructure',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._asSettingIfAbsent_(aString))._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"settingValueIfAbsent:",{aString:aString},globals.String)})},
- args: ["aString"],
- source: "settingValueIfAbsent: aString\x0a\x09^ (self asSettingIfAbsent: aString) value",
- messageSends: ["value", "asSettingIfAbsent:"],
- referencedClasses: []
- }),
- globals.String);
- });
- define("amber_core/Kernel-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Exceptions');
- smalltalk.packages["Kernel-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('Error', globals.Object, ['messageText'], 'Kernel-Exceptions');
- globals.Error.comment="From the ANSI standard:\x0a\x0aThis protocol describes the behavior of instances of class `Error`.\x0aThese are used to represent error conditions that prevent the normal continuation of processing.\x0aActual error exceptions used by an application may be subclasses of this class.\x0aAs `Error` is explicitly specified to be subclassable, conforming implementations must implement its behavior in a non-fragile manner.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.context;
- return self}, function($ctx1) {$ctx1.fill(self,"context",{},globals.Error)})},
- args: [],
- source: "context\x0a\x09<return self.context>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._messageText_("Errorclass: ".__comma(_st(self._class())._name()));
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Error)})},
- args: [],
- source: "initialize\x0a\x09self messageText: 'Errorclass: ', (self class name).",
- messageSends: ["messageText:", ",", "name", "class"],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSmalltalkError",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.smalltalkError === true;
- return self}, function($ctx1) {$ctx1.fill(self,"isSmalltalkError",{},globals.Error)})},
- args: [],
- source: "isSmalltalkError\x0a\x09<return self.smalltalkError === true>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "jsStack",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self.stack;
- return self}, function($ctx1) {$ctx1.fill(self,"jsStack",{},globals.Error)})},
- args: [],
- source: "jsStack\x0a\x09<return self.stack>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@messageText"];
- return $1;
- },
- args: [],
- source: "messageText\x0a\x09^ messageText",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@messageText"]=aString;
- return self},
- args: ["aString"],
- source: "messageText: aString\x0a\x09messageText := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "resignal",
- protocol: 'signaling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- throw(self);
- return self}, function($ctx1) {$ctx1.fill(self,"resignal",{},globals.Error)})},
- args: [],
- source: "resignal\x0a\x09\x22Resignal the receiver without changing its exception context\x22\x0a\x09\x0a\x09<throw(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "signal",
- protocol: 'signaling',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self);
- return self}, function($ctx1) {$ctx1.fill(self,"signal",{},globals.Error)})},
- args: [],
- source: "signal\x0a\x09<self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "signal:",
- protocol: 'signaling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._messageText_(aString);
- self._signal();
- return self}, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},globals.Error)})},
- args: ["aString"],
- source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
- messageSends: ["messageText:", "signal"],
- referencedClasses: []
- }),
- globals.Error);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "exception";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'exception'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Error.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "signal",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._new())._signal();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"signal",{},globals.Error.klass)})},
- args: [],
- source: "signal\x0a\x09^ self new signal",
- messageSends: ["signal", "new"],
- referencedClasses: []
- }),
- globals.Error.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "signal:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._new())._signal_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},globals.Error.klass)})},
- args: ["aString"],
- source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
- messageSends: ["signal:", "new"],
- referencedClasses: []
- }),
- globals.Error.klass);
- smalltalk.addClass('JavaScriptException', globals.Error, ['exception'], 'Kernel-Exceptions');
- globals.JavaScriptException.comment="A JavaScriptException is thrown when a non-Smalltalk exception occurs while in the Smalltalk stack.\x0aSee `boot.js` `inContext()` and `BlockClosure >> on:do:`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- protocol: 'accessing',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self.context = aMethodContext;
- return self}, function($ctx1) {$ctx1.fill(self,"context:",{aMethodContext:aMethodContext},globals.JavaScriptException)})},
- args: ["aMethodContext"],
- source: "context: aMethodContext\x0a\x09\x22Set the context from the outside.\x0a\x09See boot.js `inContext()` exception handling\x22\x0a\x09\x0a\x09<self.context = aMethodContext>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JavaScriptException);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "exception",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@exception"];
- return $1;
- },
- args: [],
- source: "exception\x0a\x09^ exception",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JavaScriptException);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "exception:",
- protocol: 'accessing',
- fn: function (anException){
- var self=this;
- self["@exception"]=anException;
- return self},
- args: ["anException"],
- source: "exception: anException\x0a\x09exception := anException",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JavaScriptException);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return 'JavaScript exception: ' + self["@exception"].toString();
- return self}, function($ctx1) {$ctx1.fill(self,"messageText",{},globals.JavaScriptException)})},
- args: [],
- source: "messageText\x0a\x09<return 'JavaScript exception: ' + self[\x22@exception\x22].toString()>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JavaScriptException);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (anException){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._exception_(anException);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException},globals.JavaScriptException.klass)})},
- args: ["anException"],
- source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
- messageSends: ["exception:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.JavaScriptException.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:context:",
- protocol: 'instance creation',
- fn: function (anException,aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._exception_(anException);
- _st($2)._context_(aMethodContext);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext},globals.JavaScriptException.klass)})},
- args: ["anException", "aMethodContext"],
- source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
- messageSends: ["exception:", "new", "context:", "yourself"],
- referencedClasses: []
- }),
- globals.JavaScriptException.klass);
- smalltalk.addClass('MessageNotUnderstood', globals.Error, ['message', 'receiver'], 'Kernel-Exceptions');
- globals.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "message",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@message"];
- return $1;
- },
- args: [],
- source: "message\x0a\x09^ message",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageNotUnderstood);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "message:",
- protocol: 'accessing',
- fn: function (aMessage){
- var self=this;
- self["@message"]=aMessage;
- return self},
- args: ["aMessage"],
- source: "message: aMessage\x0a\x09message := aMessage",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageNotUnderstood);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st(self._receiver())._asString()).__comma(" does not understand #")).__comma(_st(self._message())._selector());
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageText",{},globals.MessageNotUnderstood)})},
- args: [],
- source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
- messageSends: [",", "asString", "receiver", "selector", "message"],
- referencedClasses: []
- }),
- globals.MessageNotUnderstood);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@receiver"];
- return $1;
- },
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageNotUnderstood);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@receiver"]=anObject;
- return self},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09receiver := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MessageNotUnderstood);
- smalltalk.addClass('NonBooleanReceiver', globals.Error, ['object'], 'Kernel-Exceptions');
- globals.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "object",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@object"];
- return $1;
- },
- args: [],
- source: "object\x0a\x09^ object",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NonBooleanReceiver);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "object:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@object"]=anObject;
- return self},
- args: ["anObject"],
- source: "object: anObject\x0a\x09object := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.NonBooleanReceiver);
- });
- define("amber_core/Kernel-Transcript", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Transcript');
- smalltalk.packages["Kernel-Transcript"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('ConsoleTranscript', globals.Object, ['textarea'], 'Kernel-Transcript');
- globals.ConsoleTranscript.comment="I am a specific transcript emitting to the JavaScript console.\x0a\x0aIf no other transcript is registered, I am the default.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clear",
- protocol: 'printing',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "clear\x0a\x09\x22no op\x22",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ConsoleTranscript);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cr",
- protocol: 'printing',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "cr\x0a\x09\x22no op\x22",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ConsoleTranscript);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "open",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return self},
- args: [],
- source: "open",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ConsoleTranscript);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "show:",
- protocol: 'printing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- console.log(String(_st(anObject)._asString()));
- return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},globals.ConsoleTranscript)})},
- args: ["anObject"],
- source: "show: anObject\x0a\x22Smalltalk objects should have no trouble displaying themselves on the Transcript; Javascript objects don't know how, so must be wrapped in a JSObectProxy.\x22\x0a<console.log(String(_st(anObject)._asString()))>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ConsoleTranscript);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Transcript(){return globals.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
- return smalltalk.withContext(function($ctx1) {
- _st($Transcript())._registerIfNone_(self._new());
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ConsoleTranscript.klass)})},
- args: [],
- source: "initialize\x0a\x09Transcript registerIfNone: self new",
- messageSends: ["registerIfNone:", "new"],
- referencedClasses: ["Transcript"]
- }),
- globals.ConsoleTranscript.klass);
- });
- define("amber_core/Kernel-Announcements", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Kernel-Announcements');
- smalltalk.packages["Kernel-Announcements"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('AnnouncementSubscription', globals.Object, ['valuable', 'announcementClass'], 'Kernel-Announcements');
- globals.AnnouncementSubscription.comment="I am a single entry in a subscription registry of an `Announcer`.\x0aSeveral subscriptions by the same object is possible.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "announcementClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@announcementClass"];
- return $1;
- },
- args: [],
- source: "announcementClass\x0a\x09^ announcementClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "announcementClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@announcementClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "announcementClass: aClass\x0a\x09announcementClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "block",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._deprecatedAPI();
- $1=self._valuable();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"block",{},globals.AnnouncementSubscription)})},
- args: [],
- source: "block\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09^ self valuable",
- messageSends: ["deprecatedAPI", "valuable"],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "block:",
- protocol: 'accessing',
- fn: function (aValuable){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._deprecatedAPI();
- self._valuable_(aValuable);
- return self}, function($ctx1) {$ctx1.fill(self,"block:",{aValuable:aValuable},globals.AnnouncementSubscription)})},
- args: ["aValuable"],
- source: "block: aValuable\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09self valuable: aValuable",
- messageSends: ["deprecatedAPI", "valuable:"],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "deliver:",
- protocol: 'announcing',
- fn: function (anAnnouncement){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._handlesAnnouncement_(anAnnouncement);
- if(smalltalk.assert($1)){
- _st(self._valuable())._value_(anAnnouncement);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"deliver:",{anAnnouncement:anAnnouncement},globals.AnnouncementSubscription)})},
- args: ["anAnnouncement"],
- source: "deliver: anAnnouncement\x0a\x09(self handlesAnnouncement: anAnnouncement)\x0a\x09\x09ifTrue: [ self valuable value: anAnnouncement ]",
- messageSends: ["ifTrue:", "handlesAnnouncement:", "value:", "valuable"],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handlesAnnouncement:",
- protocol: 'announcing',
- fn: function (anAnnouncement){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$4,$2,$1;
- $3=_st($Smalltalk())._globals();
- $ctx1.sendIdx["globals"]=1;
- $4=_st(self._announcementClass())._name();
- $ctx1.sendIdx["name"]=1;
- $2=_st($3)._at_($4);
- $ctx1.sendIdx["at:"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- return false;
- } else {
- var class_;
- class_=$receiver;
- $1=_st(_st(_st($Smalltalk())._globals())._at_(_st(_st(_st(anAnnouncement)._class())._theNonMetaClass())._name()))._includesBehavior_(class_);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"handlesAnnouncement:",{anAnnouncement:anAnnouncement},globals.AnnouncementSubscription)})},
- args: ["anAnnouncement"],
- source: "handlesAnnouncement: anAnnouncement\x0a\x09\x22anAnnouncement might be announced from within another Amber environment\x22\x0a\x09\x0a\x09^ (Smalltalk globals at: self announcementClass name)\x0a\x09\x09ifNil: [ ^ false ]\x0a\x09\x09ifNotNil: [ :class |\x0a\x09\x09(Smalltalk globals at: anAnnouncement class theNonMetaClass name) includesBehavior: class ]",
- messageSends: ["ifNil:ifNotNil:", "at:", "globals", "name", "announcementClass", "includesBehavior:", "theNonMetaClass", "class"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._valuable())._receiver();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.AnnouncementSubscription)})},
- args: [],
- source: "receiver\x0a\x09^ self valuable receiver",
- messageSends: ["receiver", "valuable"],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valuable",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@valuable"];
- return $1;
- },
- args: [],
- source: "valuable\x0a\x09^ valuable",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valuable:",
- protocol: 'accessing',
- fn: function (aValuable){
- var self=this;
- self["@valuable"]=aValuable;
- return self},
- args: ["aValuable"],
- source: "valuable: aValuable\x0a\x09valuable := aValuable",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AnnouncementSubscription);
- smalltalk.addClass('Announcer', globals.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
- globals.Announcer.comment="I hold annoncement subscriptions (instances of `AnnouncementSubscription`) in a private registry.\x0aI announce (trigger) announces, which are then dispatched to all subscriptions.\x0a\x0aThe code is based on the announcements as [described by Vassili Bykov](http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?searchCategory=Announcements%20Framework).\x0a\x0a## API\x0a\x0aUse `#announce:` to trigger an announcement.\x0a\x0aUse `#on:do:` or `#on:send:to:` to register subscriptions.\x0a\x0aWhen using `#on:send:to:`, unregistration can be done with `#unregister:`.\x0a\x0a## Usage example:\x0a\x0a SystemAnnouncer current\x0a on: ClassAdded\x0a do: [ :ann | window alert: ann theClass name, ' added' ].";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "announce:",
- protocol: 'announcing',
- fn: function (anAnnouncement){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@subscriptions"])._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._deliver_(anAnnouncement);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement},globals.Announcer)})},
- args: ["anAnnouncement"],
- source: "announce: anAnnouncement\x0a\x09subscriptions do: [ :each |\x0a\x09\x09each deliver: anAnnouncement ]",
- messageSends: ["do:", "deliver:"],
- referencedClasses: []
- }),
- globals.Announcer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- globals.Announcer.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@subscriptions"]=_st($OrderedCollection())._new();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Announcer)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09subscriptions := OrderedCollection new",
- messageSends: ["initialize", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.Announcer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:do:",
- protocol: 'subscribing',
- fn: function (aClass,aBlock){
- var self=this;
- function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($AnnouncementSubscription())._new();
- _st($1)._valuable_(aBlock);
- _st($1)._announcementClass_(aClass);
- $2=_st($1)._yourself();
- _st(self["@subscriptions"])._add_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock},globals.Announcer)})},
- args: ["aClass", "aBlock"],
- source: "on: aClass do: aBlock\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09valuable: aBlock;\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
- messageSends: ["add:", "valuable:", "new", "announcementClass:", "yourself"],
- referencedClasses: ["AnnouncementSubscription"]
- }),
- globals.Announcer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:doOnce:",
- protocol: 'subscribing',
- fn: function (aClass,aBlock){
- var self=this;
- var subscription;
- function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($AnnouncementSubscription())._new();
- _st($1)._announcementClass_(aClass);
- $2=_st($1)._yourself();
- subscription=$2;
- _st(subscription)._valuable_((function(ann){
- return smalltalk.withContext(function($ctx2) {
- _st(self["@subscriptions"])._remove_(subscription);
- return _st(aBlock)._value_(ann);
- }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,1)})}));
- _st(self["@subscriptions"])._add_(subscription);
- return self}, function($ctx1) {$ctx1.fill(self,"on:doOnce:",{aClass:aClass,aBlock:aBlock,subscription:subscription},globals.Announcer)})},
- args: ["aClass", "aBlock"],
- source: "on: aClass doOnce: aBlock\x0a\x09| subscription |\x0a\x09\x0a\x09subscription := AnnouncementSubscription new\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself.\x0a\x09subscription valuable: [ :ann |\x0a\x09\x09subscriptions remove: subscription.\x0a\x09\x09aBlock value: ann ].\x0a\x0a\x09subscriptions add: subscription",
- messageSends: ["announcementClass:", "new", "yourself", "valuable:", "remove:", "value:", "add:"],
- referencedClasses: ["AnnouncementSubscription"]
- }),
- globals.Announcer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:send:to:",
- protocol: 'subscribing',
- fn: function (aClass,aSelector,anObject){
- var self=this;
- function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
- function $MessageSend(){return globals.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$4,$6,$7,$5,$8,$2;
- $1=self["@subscriptions"];
- $3=_st($AnnouncementSubscription())._new();
- $ctx1.sendIdx["new"]=1;
- $4=$3;
- $6=_st($MessageSend())._new();
- _st($6)._receiver_(anObject);
- _st($6)._selector_(aSelector);
- $7=_st($6)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- $5=$7;
- _st($4)._valuable_($5);
- _st($3)._announcementClass_(aClass);
- $8=_st($3)._yourself();
- $2=$8;
- _st($1)._add_($2);
- return self}, function($ctx1) {$ctx1.fill(self,"on:send:to:",{aClass:aClass,aSelector:aSelector,anObject:anObject},globals.Announcer)})},
- args: ["aClass", "aSelector", "anObject"],
- source: "on: aClass send: aSelector to: anObject\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09valuable: (MessageSend new\x0a\x09\x09\x09receiver: anObject;\x0a\x09\x09\x09selector: aSelector;\x0a\x09\x09\x09yourself);\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
- messageSends: ["add:", "valuable:", "new", "receiver:", "selector:", "yourself", "announcementClass:"],
- referencedClasses: ["AnnouncementSubscription", "MessageSend"]
- }),
- globals.Announcer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "unsubscribe:",
- protocol: 'subscribing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@subscriptions"]=_st(self["@subscriptions"])._reject_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._receiver()).__eq(anObject);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"unsubscribe:",{anObject:anObject},globals.Announcer)})},
- args: ["anObject"],
- source: "unsubscribe: anObject\x0a\x09subscriptions := subscriptions reject: [ :each |\x0a\x09\x09each receiver = anObject ]",
- messageSends: ["reject:", "=", "receiver"],
- referencedClasses: []
- }),
- globals.Announcer);
- smalltalk.addClass('SystemAnnouncer', globals.Announcer, [], 'Kernel-Announcements');
- globals.SystemAnnouncer.comment="My unique instance is the global announcer handling all Amber system-related announces.\x0a\x0a## API\x0a\x0aAccess to the unique instance is done via `#current`";
- globals.SystemAnnouncer.klass.iVarNames = ['current'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "current",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@current"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@current"]=globals.SystemAnnouncer.klass.superclass.fn.prototype._new.apply(_st(self), []);
- $1=self["@current"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SystemAnnouncer.klass)})},
- args: [],
- source: "current\x0a\x09^ current ifNil: [ current := super new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: []
- }),
- globals.SystemAnnouncer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldNotImplement();
- return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.SystemAnnouncer.klass)})},
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- messageSends: ["shouldNotImplement"],
- referencedClasses: []
- }),
- globals.SystemAnnouncer.klass);
- smalltalk.addClass('SystemAnnouncement', globals.Object, [], 'Kernel-Announcements');
- globals.SystemAnnouncement.comment="I am the superclass of all system announcements";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "heliosClass",
- protocol: 'helios',
- fn: function (){
- var self=this;
- return "announcement";
- },
- args: [],
- source: "heliosClass\x0a\x09^ 'announcement'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SystemAnnouncement.klass);
- smalltalk.addClass('ClassAnnouncement', globals.SystemAnnouncement, ['theClass'], 'Kernel-Announcements');
- globals.ClassAnnouncement.comment="I am the abstract superclass of class-related announcements.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassAnnouncement);
- smalltalk.addClass('ClassAdded', globals.ClassAnnouncement, [], 'Kernel-Announcements');
- globals.ClassAdded.comment="I am emitted when a class is added to the system.\x0aSee ClassBuilder >> #addSubclassOf:... methods";
- smalltalk.addClass('ClassCommentChanged', globals.ClassAnnouncement, [], 'Kernel-Announcements');
- globals.ClassCommentChanged.comment="I am emitted when the comment of a class changes. (Behavior >> #comment)";
- smalltalk.addClass('ClassDefinitionChanged', globals.ClassAnnouncement, [], 'Kernel-Announcements');
- globals.ClassDefinitionChanged.comment="I am emitted when the definition of a class changes.\x0aSee ClassBuilder >> #class:instanceVariableNames:";
- smalltalk.addClass('ClassMigrated', globals.ClassAnnouncement, ['oldClass'], 'Kernel-Announcements');
- globals.ClassMigrated.comment="I am emitted when a class is migrated.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@oldClass"];
- return $1;
- },
- args: [],
- source: "oldClass\x0a\x09^ oldClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassMigrated);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@oldClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "oldClass: aClass\x0a\x09oldClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassMigrated);
- smalltalk.addClass('ClassMoved', globals.ClassAnnouncement, ['oldPackage'], 'Kernel-Announcements');
- globals.ClassMoved.comment="I am emitted when a class is moved from one package to another.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldPackage",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@oldPackage"];
- return $1;
- },
- args: [],
- source: "oldPackage\x0a\x09^ oldPackage",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassMoved);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldPackage:",
- protocol: 'accessing',
- fn: function (aPackage){
- var self=this;
- self["@oldPackage"]=aPackage;
- return self},
- args: ["aPackage"],
- source: "oldPackage: aPackage\x0a\x09oldPackage := aPackage",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassMoved);
- smalltalk.addClass('ClassRemoved', globals.ClassAnnouncement, [], 'Kernel-Announcements');
- globals.ClassRemoved.comment="I am emitted when a class is removed.\x0aSee Smalltalk >> #removeClass:";
- smalltalk.addClass('ClassRenamed', globals.ClassAnnouncement, [], 'Kernel-Announcements');
- globals.ClassRenamed.comment="I am emitted when a class is renamed.\x0aSee ClassBuilder >> #renameClass:to:";
- smalltalk.addClass('MethodAnnouncement', globals.SystemAnnouncement, ['method'], 'Kernel-Announcements');
- globals.MethodAnnouncement.comment="I am the abstract superclass of method-related announcements.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@method"];
- return $1;
- },
- args: [],
- source: "method\x0a\x09^ method",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method:",
- protocol: 'accessing',
- fn: function (aCompiledMethod){
- var self=this;
- self["@method"]=aCompiledMethod;
- return self},
- args: ["aCompiledMethod"],
- source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodAnnouncement);
- smalltalk.addClass('MethodAdded', globals.MethodAnnouncement, [], 'Kernel-Announcements');
- globals.MethodAdded.comment="I am emitted when a `CompiledMethod` is added to a class.";
- smalltalk.addClass('MethodModified', globals.MethodAnnouncement, ['oldMethod'], 'Kernel-Announcements');
- globals.MethodModified.comment="I am emitted when a `CompiledMethod` is modified (a new method is installed). I hold a reference to the old method being replaced.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldMethod",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@oldMethod"];
- return $1;
- },
- args: [],
- source: "oldMethod\x0a\x09^ oldMethod",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodModified);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldMethod:",
- protocol: 'accessing',
- fn: function (aMethod){
- var self=this;
- self["@oldMethod"]=aMethod;
- return self},
- args: ["aMethod"],
- source: "oldMethod: aMethod\x0a\x09oldMethod := aMethod",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodModified);
- smalltalk.addClass('MethodMoved', globals.MethodAnnouncement, ['oldProtocol'], 'Kernel-Announcements');
- globals.MethodMoved.comment="I am emitted when a `CompiledMethod` is moved to another protocol. I hold a refernce to the old protocol of the method.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldProtocol",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@oldProtocol"];
- return $1;
- },
- args: [],
- source: "oldProtocol\x0a\x09^ oldProtocol",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodMoved);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "oldProtocol:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@oldProtocol"]=aString;
- return self},
- args: ["aString"],
- source: "oldProtocol: aString\x0a\x09oldProtocol := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodMoved);
- smalltalk.addClass('MethodRemoved', globals.MethodAnnouncement, [], 'Kernel-Announcements');
- globals.MethodRemoved.comment="I am emitted when a `CompiledMethod` is removed from a class.";
- smalltalk.addClass('PackageAnnouncement', globals.SystemAnnouncement, ['package'], 'Kernel-Announcements');
- globals.PackageAnnouncement.comment="I am the abstract superclass of package-related announcements.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@package"];
- return $1;
- },
- args: [],
- source: "package\x0a\x09^ package",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PackageAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "package:",
- protocol: 'accessing',
- fn: function (aPackage){
- var self=this;
- self["@package"]=aPackage;
- return self},
- args: ["aPackage"],
- source: "package: aPackage\x0a\x09package := aPackage",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PackageAnnouncement);
- smalltalk.addClass('PackageAdded', globals.PackageAnnouncement, [], 'Kernel-Announcements');
- globals.PackageAdded.comment="I am emitted when a `Package` is added to the system.";
- smalltalk.addClass('PackageRemoved', globals.PackageAnnouncement, [], 'Kernel-Announcements');
- globals.PackageRemoved.comment="I am emitted when a `Package` is removed from the system.";
- smalltalk.addClass('ProtocolAnnouncement', globals.SystemAnnouncement, ['theClass', 'protocol'], 'Kernel-Announcements');
- globals.ProtocolAnnouncement.comment="I am the abstract superclass of protocol-related announcements.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@protocol"];
- return $1;
- },
- args: [],
- source: "protocol\x0a\x09^ protocol",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtocolAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "protocol:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@protocol"]=aString;
- return self},
- args: ["aString"],
- source: "protocol: aString\x0a\x09protocol := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtocolAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtocolAnnouncement);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ProtocolAnnouncement);
- smalltalk.addClass('ProtocolAdded', globals.ProtocolAnnouncement, [], 'Kernel-Announcements');
- globals.ProtocolAdded.comment="I am emitted when a protocol is added to a class.";
- smalltalk.addClass('ProtocolRemoved', globals.ProtocolAnnouncement, [], 'Kernel-Announcements');
- globals.ProtocolRemoved.comment="I am emitted when a protocol is removed from a class.";
- });
- define("amber_core/Compiler-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-Exceptions');
- smalltalk.packages["Compiler-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('CompilerError', globals.Error, [], 'Compiler-Exceptions');
- globals.CompilerError.comment="I am the common superclass of all compiling errors.";
- smalltalk.addClass('ParseError', globals.CompilerError, [], 'Compiler-Exceptions');
- globals.ParseError.comment="Instance of ParseError are signaled on any parsing error.\x0aSee `Smalltalk >> #parse:`";
- smalltalk.addClass('SemanticError', globals.CompilerError, [], 'Compiler-Exceptions');
- globals.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling";
- smalltalk.addClass('InliningError', globals.SemanticError, [], 'Compiler-Exceptions');
- globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
- smalltalk.addClass('InvalidAssignmentError', globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
- globals.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=" Invalid assignment to variable: ".__comma(self._variableName());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageText",{},globals.InvalidAssignmentError)})},
- args: [],
- source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
- messageSends: [",", "variableName"],
- referencedClasses: []
- }),
- globals.InvalidAssignmentError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@variableName"];
- return $1;
- },
- args: [],
- source: "variableName\x0a\x09^ variableName",
- messageSends: [],
- referencedClasses: []
- }),
- globals.InvalidAssignmentError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@variableName"]=aString;
- return self},
- args: ["aString"],
- source: "variableName: aString\x0a\x09variableName := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.InvalidAssignmentError);
- smalltalk.addClass('ShadowingVariableError', globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
- globals.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("Variable shadowing error: ".__comma(self._variableName())).__comma(" is already defined");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageText",{},globals.ShadowingVariableError)})},
- args: [],
- source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
- messageSends: [",", "variableName"],
- referencedClasses: []
- }),
- globals.ShadowingVariableError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@variableName"];
- return $1;
- },
- args: [],
- source: "variableName\x0a\x09^ variableName",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ShadowingVariableError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@variableName"]=aString;
- return self},
- args: ["aString"],
- source: "variableName: aString\x0a\x09variableName := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ShadowingVariableError);
- smalltalk.addClass('UnknownVariableError', globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
- globals.UnknownVariableError.comment="I get signaled when a variable is not defined.\x0aThe default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageText",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("Unknown Variable error: ".__comma(self._variableName())).__comma(" is not defined");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageText",{},globals.UnknownVariableError)})},
- args: [],
- source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
- messageSends: [",", "variableName"],
- referencedClasses: []
- }),
- globals.UnknownVariableError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@variableName"];
- return $1;
- },
- args: [],
- source: "variableName\x0a\x09^ variableName",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UnknownVariableError);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variableName:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@variableName"]=aString;
- return self},
- args: ["aString"],
- source: "variableName: aString\x0a\x09variableName := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UnknownVariableError);
- smalltalk.addClass('RethrowErrorHandler', globals.Object, [], 'Compiler-Exceptions');
- globals.RethrowErrorHandler.comment="This class is used in the commandline version of the compiler.\x0aIt uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.\x0aAs a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basicSignal:",
- protocol: 'error handling',
- fn: function (anError){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- throw anError;
- return self}, function($ctx1) {$ctx1.fill(self,"basicSignal:",{anError:anError},globals.RethrowErrorHandler)})},
- args: ["anError"],
- source: "basicSignal: anError\x0a <throw anError>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.RethrowErrorHandler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleError:",
- protocol: 'error handling',
- fn: function (anError){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.RethrowErrorHandler.superclass.fn.prototype._handleError_.apply(_st(self), [anError]);
- self._basicSignal_(anError);
- return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.RethrowErrorHandler)})},
- args: ["anError"],
- source: "handleError: anError\x0a super handleError: anError.\x0a self basicSignal: anError",
- messageSends: ["handleError:", "basicSignal:"],
- referencedClasses: []
- }),
- globals.RethrowErrorHandler);
- });
- define("amber_core/Compiler-Core", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-Core');
- smalltalk.packages["Compiler-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('AbstractCodeGenerator', globals.Object, ['currentClass', 'source'], 'Compiler-Core');
- globals.AbstractCodeGenerator.comment="I am the abstract super class of all code generators and provide their common API.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classNameFor:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$1;
- $2=_st(aClass)._isMetaclass();
- if(smalltalk.assert($2)){
- $3=_st(_st(aClass)._instanceClass())._name();
- $ctx1.sendIdx["name"]=1;
- $1=_st($3).__comma(".klass");
- } else {
- $4=_st(aClass)._isNil();
- if(smalltalk.assert($4)){
- $1="nil";
- } else {
- $1=_st(aClass)._name();
- };
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},globals.AbstractCodeGenerator)})},
- args: ["aClass"],
- source: "classNameFor: aClass\x0a\x09^ aClass isMetaclass\x0a\x09\x09ifTrue: [ aClass instanceClass name, '.klass' ]\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: [ 'nil' ]\x0a\x09\x09\x09ifFalse: [ aClass name ]]",
- messageSends: ["ifTrue:ifFalse:", "isMetaclass", ",", "name", "instanceClass", "isNil"],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._subclassResponsibility();
- return self}, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode},globals.AbstractCodeGenerator)})},
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09self subclassResponsibility",
- messageSends: ["subclassResponsibility"],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentClass"];
- return $1;
- },
- args: [],
- source: "currentClass\x0a\x09^ currentClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@currentClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "currentClass: aClass\x0a\x09currentClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pseudoVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._pseudoVariableNames();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pseudoVariables",{},globals.AbstractCodeGenerator)})},
- args: [],
- source: "pseudoVariables\x0a\x09^ Smalltalk pseudoVariableNames",
- messageSends: ["pseudoVariableNames"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@source"];
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"source",{},globals.AbstractCodeGenerator)})},
- args: [],
- source: "source\x0a\x09^ source ifNil: [ '' ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AbstractCodeGenerator);
- smalltalk.addClass('CodeGenerator', globals.AbstractCodeGenerator, [], 'Compiler-Core');
- globals.CodeGenerator.comment="I am a basic code generator. I generate a valid JavaScript output, but no not perform any inlining.\x0aSee `InliningCodeGenerator` for an optimized JavaScript code generation.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- var ir,stream;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- _st(self._semanticAnalyzer())._visit_(aNode);
- $ctx1.sendIdx["visit:"]=1;
- ir=_st(self._translator())._visit_(aNode);
- $ctx1.sendIdx["visit:"]=2;
- $2=self._irTranslator();
- _st($2)._currentClass_(self._currentClass());
- _st($2)._visit_(ir);
- $3=_st($2)._contents();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},globals.CodeGenerator)})},
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09^ self irTranslator\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
- messageSends: ["visit:", "semanticAnalyzer", "translator", "currentClass:", "irTranslator", "currentClass", "contents"],
- referencedClasses: []
- }),
- globals.CodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "irTranslator",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRJSTranslator(){return globals.IRJSTranslator||(typeof IRJSTranslator=="undefined"?nil:IRJSTranslator)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRJSTranslator())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},globals.CodeGenerator)})},
- args: [],
- source: "irTranslator\x0a\x09^ IRJSTranslator new",
- messageSends: ["new"],
- referencedClasses: ["IRJSTranslator"]
- }),
- globals.CodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "semanticAnalyzer",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $SemanticAnalyzer(){return globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($SemanticAnalyzer())._on_(self._currentClass());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"semanticAnalyzer",{},globals.CodeGenerator)})},
- args: [],
- source: "semanticAnalyzer\x0a\x09^ SemanticAnalyzer on: self currentClass",
- messageSends: ["on:", "currentClass"],
- referencedClasses: ["SemanticAnalyzer"]
- }),
- globals.CodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "translator",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRASTTranslator(){return globals.IRASTTranslator||(typeof IRASTTranslator=="undefined"?nil:IRASTTranslator)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRASTTranslator())._new();
- _st($2)._source_(self._source());
- _st($2)._theClass_(self._currentClass());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"translator",{},globals.CodeGenerator)})},
- args: [],
- source: "translator\x0a\x09^ IRASTTranslator new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self currentClass;\x0a\x09\x09yourself",
- messageSends: ["source:", "new", "source", "theClass:", "currentClass", "yourself"],
- referencedClasses: ["IRASTTranslator"]
- }),
- globals.CodeGenerator);
- smalltalk.addClass('Compiler', globals.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
- globals.Compiler.comment="I provide the public interface for compiling Amber source code into JavaScript.\x0a\x0aThe code generator used to produce JavaScript can be plugged with `#codeGeneratorClass`.\x0aThe default code generator is an instance of `InlinedCodeGenerator`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "codeGeneratorClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $InliningCodeGenerator(){return globals.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@codeGeneratorClass"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=$InliningCodeGenerator();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},globals.Compiler)})},
- args: [],
- source: "codeGeneratorClass\x0a\x09^ codeGeneratorClass ifNil: [ InliningCodeGenerator ]",
- messageSends: ["ifNil:"],
- referencedClasses: ["InliningCodeGenerator"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "codeGeneratorClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@codeGeneratorClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compile:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._compileNode_(self._parse_(aString));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "compile: aString\x0a\x09^ self compileNode: (self parse: aString)",
- messageSends: ["compileNode:", "parse:"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compile:forClass:",
- protocol: 'compiling',
- fn: function (aString,aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._currentClass_(aClass);
- self._source_(aString);
- $1=self._compile_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compile:forClass:",{aString:aString,aClass:aClass},globals.Compiler)})},
- args: ["aString", "aClass"],
- source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^ self compile: aString",
- messageSends: ["currentClass:", "source:", "compile:"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._currentClass_($DoIt());
- $1=_st("doIt ^ [ ".__comma(aString)).__comma(" ] value");
- $ctx1.sendIdx[","]=1;
- self._source_($1);
- $2=self._compileNode_(self._parse_(self._source()));
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"compileExpression:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
- messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"],
- referencedClasses: ["DoIt"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileExpression:on:",
- protocol: 'compiling',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._currentClass_(_st(anObject)._class());
- $1=_st("xxxDoIt ^ [ ".__comma(aString)).__comma(" ] value");
- $ctx1.sendIdx[","]=1;
- self._source_($1);
- $2=self._compileNode_(self._parse_(self._source()));
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"compileExpression:on:",{aString:aString,anObject:anObject},globals.Compiler)})},
- args: ["aString", "anObject"],
- source: "compileExpression: aString on: anObject\x0a\x09self currentClass: anObject class.\x0a\x09self source: 'xxxDoIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
- messageSends: ["currentClass:", "class", "source:", ",", "compileNode:", "parse:", "source"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- var generator,result;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- generator=_st(self._codeGeneratorClass())._new();
- $1=generator;
- _st($1)._source_(self._source());
- $2=_st($1)._currentClass_(self._currentClass());
- result=_st(generator)._compileNode_(aNode);
- self._unknownVariables_([]);
- $3=result;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result},globals.Compiler)})},
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09| generator result |\x0a\x09generator := self codeGeneratorClass new.\x0a\x09generator\x0a\x09\x09source: self source;\x0a\x09\x09currentClass: self currentClass.\x0a\x09result := generator compileNode: aNode.\x0a\x09self unknownVariables: #().\x0a\x09^ result",
- messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentClass"];
- return $1;
- },
- args: [],
- source: "currentClass\x0a\x09^ currentClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@currentClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "currentClass: aClass\x0a\x09currentClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return eval(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "eval: aString\x0a\x09<return eval(aString)>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluateExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._evaluateExpression_on_(aString,_st($DoIt())._new());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "evaluateExpression: aString\x0a\x09\x22Unlike #eval: evaluate a Smalltalk expression and answer the returned object\x22\x0a\x09^ self evaluateExpression: aString on: DoIt new",
- messageSends: ["evaluateExpression:on:", "new"],
- referencedClasses: ["DoIt"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluateExpression:on:",
- protocol: 'compiling',
- fn: function (aString,anObject){
- var self=this;
- var result,method;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- method=self._eval_(self._compileExpression_on_(aString,anObject));
- _st(method)._protocol_("xxxDoIt");
- $1=_st(anObject)._class();
- $ctx1.sendIdx["class"]=1;
- _st($1)._addCompiledMethod_(method);
- result=_st(anObject)._xxxDoIt();
- _st(_st(anObject)._class())._removeCompiledMethod_(method);
- $2=result;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:on:",{aString:aString,anObject:anObject,result:result,method:method},globals.Compiler)})},
- args: ["aString", "anObject"],
- source: "evaluateExpression: aString on: anObject\x0a\x09\x22Unlike #eval: evaluate a Smalltalk expression with anObject as the receiver and answer the returned object\x22\x0a\x09| result method |\x0a\x09method := self eval: (self compileExpression: aString on: anObject).\x0a\x09method protocol: 'xxxDoIt'.\x0a\x09anObject class addCompiledMethod: method.\x0a\x09result := anObject xxxDoIt.\x0a\x09anObject class removeCompiledMethod: method.\x0a\x09^ result",
- messageSends: ["eval:", "compileExpression:on:", "protocol:", "addCompiledMethod:", "class", "xxxDoIt", "removeCompiledMethod:"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "install:forClass:protocol:",
- protocol: 'compiling',
- fn: function (aString,aBehavior,anotherString){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($ClassBuilder())._new())._installMethod_forClass_protocol_(self._eval_(self._compile_forClass_(aString,aBehavior)),aBehavior,anotherString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"install:forClass:protocol:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString},globals.Compiler)})},
- args: ["aString", "aBehavior", "anotherString"],
- source: "install: aString forClass: aBehavior protocol: anotherString\x0a\x09^ ClassBuilder new\x0a\x09\x09installMethod: (self eval: (self compile: aString forClass: aBehavior))\x0a\x09\x09forClass: aBehavior\x0a\x09\x09protocol: anotherString",
- messageSends: ["installMethod:forClass:protocol:", "new", "eval:", "compile:forClass:"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parse:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Smalltalk())._parse_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
- messageSends: ["parse:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parseExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st("doIt ^ [ ".__comma(aString)).__comma(" ] value");
- $ctx1.sendIdx[","]=1;
- $1=self._parse_($2);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parseExpression:",{aString:aString},globals.Compiler)})},
- args: ["aString"],
- source: "parseExpression: aString\x0a\x09^ self parse: 'doIt ^ [ ', aString, ' ] value'",
- messageSends: ["parse:", ","],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "recompile:",
- protocol: 'compiling',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(_st(_st(aClass)._methodDictionary())._values())._do_displayingProgress_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._install_forClass_protocol_(_st(each)._source(),aClass,_st(each)._protocol());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),"Recompiling ".__comma(_st(aClass)._name()));
- $1=_st(aClass)._isMetaclass();
- if(! smalltalk.assert($1)){
- self._recompile_(_st(aClass)._class());
- };
- return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},globals.Compiler)})},
- args: ["aClass"],
- source: "recompile: aClass\x0a\x09aClass methodDictionary values\x0a\x09\x09do: [ :each | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09install: each source \x0a\x09\x09\x09\x09forClass: aClass \x0a\x09\x09\x09\x09protocol: each protocol ]\x0a\x09\x09displayingProgress: 'Recompiling ', aClass name.\x0a\x09aClass isMetaclass ifFalse: [ self recompile: aClass class ]",
- messageSends: ["do:displayingProgress:", "values", "methodDictionary", "install:forClass:protocol:", "source", "protocol", ",", "name", "ifFalse:", "isMetaclass", "recompile:", "class"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "recompileAll",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($Smalltalk())._classes())._do_displayingProgress_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._recompile_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),"Compiling all classes...");
- return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{},globals.Compiler)})},
- args: [],
- source: "recompileAll\x0a\x09Smalltalk classes \x0a\x09\x09do: [ :each | self recompile: each ]\x0a\x09\x09displayingProgress: 'Compiling all classes...'",
- messageSends: ["do:displayingProgress:", "classes", "recompile:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@source"];
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"source",{},globals.Compiler)})},
- args: [],
- source: "source\x0a\x09^ source ifNil: [ '' ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "unknownVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@unknownVariables"];
- return $1;
- },
- args: [],
- source: "unknownVariables\x0a\x09^ unknownVariables",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "unknownVariables:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@unknownVariables"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Compiler);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "recompile:",
- protocol: 'compiling',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._new())._recompile_(aClass);
- return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},globals.Compiler.klass)})},
- args: ["aClass"],
- source: "recompile: aClass\x0a\x09self new recompile: aClass",
- messageSends: ["recompile:", "new"],
- referencedClasses: []
- }),
- globals.Compiler.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "recompileAll",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- _st(_st($Smalltalk())._classes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._recompile_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{},globals.Compiler.klass)})},
- args: [],
- source: "recompileAll\x0a\x09Smalltalk classes do: [ :each |\x0a\x09\x09self recompile: each ]",
- messageSends: ["do:", "classes", "recompile:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.Compiler.klass);
- smalltalk.addClass('DoIt', globals.Object, [], 'Compiler-Core');
- globals.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "foo",
- protocol: 'tests',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($Array())._new();
- _st($2)._add_((3));
- $ctx1.sendIdx["add:"]=1;
- _st($2)._add_((4));
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"foo",{},globals.DoIt)})},
- args: [],
- source: "foo ^ Array new add: 3; add: 4; yourself",
- messageSends: ["add:", "new", "yourself"],
- referencedClasses: ["Array"]
- }),
- globals.DoIt);
- smalltalk.addClass('NodeVisitor', globals.Object, [], 'Compiler-Core');
- globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visit:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aNode)._accept_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visit: aNode\x0a\x09^ aNode accept: self",
- messageSends: ["accept:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAll:",
- protocol: 'visiting',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aCollection)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},globals.NodeVisitor)})},
- args: ["aCollection"],
- source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
- messageSends: ["collect:", "visit:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAssignmentNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitSequenceNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
- messageSends: ["visitSequenceNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitCascadeNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicArrayNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicDictionaryNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitMethodNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitAll_(_st(aNode)._nodes());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
- messageSends: ["visitAll:", "nodes"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReturnNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitValueNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitVariableNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},globals.NodeVisitor)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.NodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asVariableName",
- protocol: '*Compiler-Core',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(_st($Smalltalk())._reservedWords())._includes_(self);
- if(smalltalk.assert($2)){
- $1=self.__comma("_");
- } else {
- $1=self;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asVariableName",{},globals.String)})},
- args: [],
- source: "asVariableName\x0a\x09^ (Smalltalk reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
- messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", ","],
- referencedClasses: ["Smalltalk"]
- }),
- globals.String);
- });
- define("amber_core/Compiler-AST", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Methods"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-AST');
- smalltalk.packages["Compiler-AST"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('Node', globals.Object, ['parent', 'position', 'source', 'nodes', 'shouldBeInlined', 'shouldBeAliased'], 'Compiler-AST');
- globals.Node.comment="I am the abstract root class of the abstract syntax tree.\x0a\x0aConcrete classes should implement `#accept:` to allow visiting.\x0a\x0a`position` holds a point containing line and column number of the symbol location in the original source file.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.Node)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitNode: self",
- messageSends: ["visitNode:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addNode:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._nodes())._add_(aNode);
- _st(aNode)._parent_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"addNode:",{aNode:aNode},globals.Node)})},
- args: ["aNode"],
- source: "addNode: aNode\x0a\x09self nodes add: aNode.\x0a\x09aNode parent: self",
- messageSends: ["add:", "nodes", "parent:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isAssignmentNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isAssignmentNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isBlockNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockSequenceNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isBlockSequenceNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCascadeNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isCascadeNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isImmutable\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isJSStatementNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isJSStatementNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isLastChild",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st(self._parent())._nodes())._last()).__eq(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isLastChild",{},globals.Node)})},
- args: [],
- source: "isLastChild\x0a\x09^ self parent nodes last = self",
- messageSends: ["=", "last", "nodes", "parent"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isReferenced",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $4,$3,$2,$1;
- $4=self._parent();
- $ctx1.sendIdx["parent"]=1;
- $3=_st($4)._isSequenceNode();
- $2=_st($3)._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._parent())._isAssignmentNode();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $1=_st($2)._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isReferenced",{},globals.Node)})},
- args: [],
- source: "isReferenced\x0a\x09\x22Answer true if the receiver is referenced by other nodes.\x0a\x09Do not take sequences or assignments into account\x22\x0a\x09\x0a\x09^ (self parent isSequenceNode or: [\x0a\x09\x09self parent isAssignmentNode ]) not",
- messageSends: ["not", "or:", "isSequenceNode", "parent", "isAssignmentNode"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isReturnNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isReturnNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSendNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSendNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSequenceNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSequenceNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isValueNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isValueNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariableNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isVariableNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._parent();
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- var node;
- node=$receiver;
- $1=_st(node)._method();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.Node)})},
- args: [],
- source: "method\x0a\x09^ self parent ifNotNil: [ :node | node method ]",
- messageSends: ["ifNotNil:", "parent", "method"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextChild",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $3=self._nodes();
- $ctx1.sendIdx["nodes"]=1;
- $2=_st($3)._isEmpty();
- if(smalltalk.assert($2)){
- $1=self;
- } else {
- $1=_st(_st(self._nodes())._first())._nextChild();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nextChild",{},globals.Node)})},
- args: [],
- source: "nextChild\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the receiver to answer the next node to be evaluated\x22\x0a\x09\x0a\x09^ self nodes isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self nodes first nextChild ]",
- messageSends: ["ifTrue:ifFalse:", "isEmpty", "nodes", "nextChild", "first"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextNode",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._parent();
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- var node;
- node=$receiver;
- $1=_st(node)._nextNode_(self);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nextNode",{},globals.Node)})},
- args: [],
- source: "nextNode\x0a\x09^ self parent ifNotNil: [ :node |\x0a\x09\x09node nextNode: self ]",
- messageSends: ["ifNotNil:", "parent", "nextNode:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextNode:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- var next;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- $1=self._nodes();
- $ctx1.sendIdx["nodes"]=1;
- next=_st($1)._at_ifAbsent_(_st(_st(self._nodes())._indexOf_(aNode)).__plus((1)),(function(){
- throw $early=[self];
- }));
- $2=_st(next)._nextChild();
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode,next:next},globals.Node)})},
- args: ["aNode"],
- source: "nextNode: aNode\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the next node to answer the next node to be evaluated\x22\x0a\x09\x0a\x09| next |\x0a\x09\x0a\x09next := self nodes \x0a\x09\x09at: (self nodes indexOf: aNode) + 1\x0a\x09\x09ifAbsent: [ ^ self ].\x0a\x09\x0a\x09^ next nextChild",
- messageSends: ["at:ifAbsent:", "nodes", "+", "indexOf:", "nextChild"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nodes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@nodes"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@nodes"]=_st($Array())._new();
- $1=self["@nodes"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.Node)})},
- args: [],
- source: "nodes\x0a\x09^ nodes ifNil: [ nodes := Array new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Array"]
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nodes:",
- protocol: 'building',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@nodes"]=aCollection;
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._parent_(self);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"nodes:",{aCollection:aCollection},globals.Node)})},
- args: ["aCollection"],
- source: "nodes: aCollection\x0a\x09nodes := aCollection.\x0a\x09aCollection do: [ :each | each parent: self ]",
- messageSends: ["do:", "parent:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parent",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@parent"];
- return $1;
- },
- args: [],
- source: "parent\x0a\x09^ parent",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parent:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@parent"]=aNode;
- return self},
- args: ["aNode"],
- source: "parent: aNode\x0a\x09parent := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "position",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self["@position"];
- if(($receiver = $2) == nil || $receiver == null){
- $3=self._parent();
- if(($receiver = $3) == nil || $receiver == null){
- $1=$3;
- } else {
- var node;
- node=$receiver;
- $1=_st(node)._position();
- };
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"position",{},globals.Node)})},
- args: [],
- source: "position\x0a\x09\x22answer the line and column of the receiver in the source code\x22\x0a\x09\x0a\x09^ position ifNil: [ \x0a\x09\x09self parent ifNotNil: [ :node | node position ] ]",
- messageSends: ["ifNil:", "ifNotNil:", "parent", "position"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "position:",
- protocol: 'accessing',
- fn: function (aPosition){
- var self=this;
- self["@position"]=aPosition;
- return self},
- args: ["aPosition"],
- source: "position: aPosition\x0a\x09position := aPosition",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "positionEnd",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$7,$6,$5,$4,$3,$1;
- $2=self._positionStart();
- $7=self._source();
- $ctx1.sendIdx["source"]=1;
- $6=_st($7)._lines();
- $ctx1.sendIdx["lines"]=1;
- $5=_st($6)._size();
- $ctx1.sendIdx["size"]=1;
- $4=_st($5).__minus((1));
- $ctx1.sendIdx["-"]=1;
- $3=_st($4).__at(_st(_st(_st(_st(self._source())._lines())._last())._size()).__minus((1)));
- $1=_st($2).__plus($3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"positionEnd",{},globals.Node)})},
- args: [],
- source: "positionEnd\x0a\x09^ self positionStart + ((self source lines size - 1) @ (self source lines last size - 1))",
- messageSends: ["+", "positionStart", "@", "-", "size", "lines", "source", "last"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "positionStart",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._position();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"positionStart",{},globals.Node)})},
- args: [],
- source: "positionStart\x0a\x09^ self position",
- messageSends: ["position"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "postCopy",
- protocol: 'copying',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.Node.superclass.fn.prototype._postCopy.apply(_st(self), []);
- _st(self._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._parent_(self);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"postCopy",{},globals.Node)})},
- args: [],
- source: "postCopy\x0a\x09super postCopy.\x0a\x09self nodes do: [ :each | each parent: self ]",
- messageSends: ["postCopy", "do:", "nodes", "parent:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "requiresSmalltalkContext",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._nodes())._detect_ifNone_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._requiresSmalltalkContext();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return nil;
- })))._notNil();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"requiresSmalltalkContext",{},globals.Node)})},
- args: [],
- source: "requiresSmalltalkContext\x0a\x09\x22Answer true if the receiver requires a smalltalk context.\x0a\x09Only send nodes require a context.\x0a\x09\x0a\x09If no node requires a context, the method will be compiled without one.\x0a\x09See `IRJSTranslator` and `JSStream` for context creation\x22\x0a\x09\x0a\x09^ (self nodes \x0a\x09\x09detect: [ :each | each requiresSmalltalkContext ]\x0a\x09\x09ifNone: [ nil ]) notNil",
- messageSends: ["notNil", "detect:ifNone:", "nodes", "requiresSmalltalkContext"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeAliased",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@shouldBeAliased"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},globals.Node)})},
- args: [],
- source: "shouldBeAliased\x0a\x09^ shouldBeAliased ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeAliased:",
- protocol: 'accessing',
- fn: function (aBoolean){
- var self=this;
- self["@shouldBeAliased"]=aBoolean;
- return self},
- args: ["aBoolean"],
- source: "shouldBeAliased: aBoolean\x0a\x09shouldBeAliased := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeInlined",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@shouldBeInlined"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldBeInlined",{},globals.Node)})},
- args: [],
- source: "shouldBeInlined\x0a\x09^ shouldBeInlined ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeInlined:",
- protocol: 'accessing',
- fn: function (aBoolean){
- var self=this;
- self["@shouldBeInlined"]=aBoolean;
- return self},
- args: ["aBoolean"],
- source: "shouldBeInlined: aBoolean\x0a\x09shouldBeInlined := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "size",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._source())._size();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"size",{},globals.Node)})},
- args: [],
- source: "size\x0a\x09^ self source size",
- messageSends: ["size", "source"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@source"];
- if(($receiver = $2) == nil || $receiver == null){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"source",{},globals.Node)})},
- args: [],
- source: "source\x0a\x09^ source ifNil: [ '' ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stopOnStepping",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "stopOnStepping\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subtreeNeedsAliasing",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._shouldBeAliased())._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._shouldBeInlined();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._nodes())._anySatisfy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(each)._subtreeNeedsAliasing();
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $ctx1.sendIdx["or:"]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.Node)})},
- args: [],
- source: "subtreeNeedsAliasing\x0a\x09^ (self shouldBeAliased or: [ self shouldBeInlined ]) or: [\x0a\x09\x09self nodes anySatisfy: [ :each | each subtreeNeedsAliasing ] ]",
- messageSends: ["or:", "shouldBeAliased", "shouldBeInlined", "anySatisfy:", "nodes", "subtreeNeedsAliasing"],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addClass('AssignmentNode', globals.Node, ['left', 'right'], 'Compiler-AST');
- globals.AssignmentNode.comment="I represent an assignment node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitAssignmentNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.AssignmentNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitAssignmentNode: self",
- messageSends: ["visitAssignmentNode:"],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isAssignmentNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isAssignmentNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "left",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@left"];
- return $1;
- },
- args: [],
- source: "left\x0a\x09^ left",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "left:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@left"]=aNode;
- _st(aNode)._parent_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"left:",{aNode:aNode},globals.AssignmentNode)})},
- args: ["aNode"],
- source: "left: aNode\x0a\x09left := aNode.\x0a\x09aNode parent: self",
- messageSends: ["parent:"],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nodes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($Array())._with_with_(self._left(),self._right());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.AssignmentNode)})},
- args: [],
- source: "nodes\x0a\x09^ Array with: self left with: self right",
- messageSends: ["with:with:", "left", "right"],
- referencedClasses: ["Array"]
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "right",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@right"];
- return $1;
- },
- args: [],
- source: "right\x0a\x09^ right",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "right:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@right"]=aNode;
- _st(aNode)._parent_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"right:",{aNode:aNode},globals.AssignmentNode)})},
- args: ["aNode"],
- source: "right: aNode\x0a\x09right := aNode.\x0a\x09aNode parent: self",
- messageSends: ["parent:"],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeAliased",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(globals.AssignmentNode.superclass.fn.prototype._shouldBeAliased.apply(_st(self), []))._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._isReferenced();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},globals.AssignmentNode)})},
- args: [],
- source: "shouldBeAliased\x0a\x09^ super shouldBeAliased or: [ self isReferenced ]",
- messageSends: ["or:", "shouldBeAliased", "isReferenced"],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addClass('BlockNode', globals.Node, ['parameters', 'scope'], 'Compiler-AST');
- globals.BlockNode.comment="I represent an block closure node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitBlockNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockNode: self",
- messageSends: ["visitBlockNode:"],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isBlockNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextChild",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "nextChild\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextNode:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return self;
- },
- args: ["aNode"],
- source: "nextNode: aNode\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parameters",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@parameters"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@parameters"]=_st($Array())._new();
- $1=self["@parameters"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parameters",{},globals.BlockNode)})},
- args: [],
- source: "parameters\x0a\x09^ parameters ifNil: [ parameters := Array new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Array"]
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parameters:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@parameters"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "parameters: aCollection\x0a\x09parameters := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aLexicalScope){
- var self=this;
- self["@scope"]=aLexicalScope;
- return self},
- args: ["aLexicalScope"],
- source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subtreeNeedsAliasing",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._shouldBeAliased())._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._shouldBeInlined();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.BlockNode)})},
- args: [],
- source: "subtreeNeedsAliasing\x0a\x09^ self shouldBeAliased or: [ self shouldBeInlined ]",
- messageSends: ["or:", "shouldBeAliased", "shouldBeInlined"],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addClass('CascadeNode', globals.Node, ['receiver'], 'Compiler-AST');
- globals.CascadeNode.comment="I represent an cascade node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitCascadeNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.CascadeNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitCascadeNode: self",
- messageSends: ["visitCascadeNode:"],
- referencedClasses: []
- }),
- globals.CascadeNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCascadeNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isCascadeNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CascadeNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@receiver"];
- return $1;
- },
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CascadeNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@receiver"]=aNode;
- return self},
- args: ["aNode"],
- source: "receiver: aNode\x0a\x09receiver := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.CascadeNode);
- smalltalk.addClass('DynamicArrayNode', globals.Node, [], 'Compiler-AST');
- globals.DynamicArrayNode.comment="I represent an dynamic array node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitDynamicArrayNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicArrayNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicArrayNode: self",
- messageSends: ["visitDynamicArrayNode:"],
- referencedClasses: []
- }),
- globals.DynamicArrayNode);
- smalltalk.addClass('DynamicDictionaryNode', globals.Node, [], 'Compiler-AST');
- globals.DynamicDictionaryNode.comment="I represent an dynamic dictionary node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitDynamicDictionaryNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicDictionaryNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicDictionaryNode: self",
- messageSends: ["visitDynamicDictionaryNode:"],
- referencedClasses: []
- }),
- globals.DynamicDictionaryNode);
- smalltalk.addClass('JSStatementNode', globals.Node, [], 'Compiler-AST');
- globals.JSStatementNode.comment="I represent an JavaScript statement node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitJSStatementNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.JSStatementNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitJSStatementNode: self",
- messageSends: ["visitJSStatementNode:"],
- referencedClasses: []
- }),
- globals.JSStatementNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isJSStatementNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isJSStatementNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSStatementNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "requiresSmalltalkContext",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "requiresSmalltalkContext\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSStatementNode);
- smalltalk.addClass('MethodNode', globals.Node, ['selector', 'arguments', 'source', 'scope', 'classReferences', 'sendIndexes', 'superSends'], 'Compiler-AST');
- globals.MethodNode.comment="I represent an method node.\x0a\x0aA method node must be the root and only method node of a valid AST.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitMethodNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.MethodNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitMethodNode: self",
- messageSends: ["visitMethodNode:"],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@arguments"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=[];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MethodNode)})},
- args: [],
- source: "arguments\x0a\x09^ arguments ifNil: [ #() ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@arguments"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "arguments: aCollection\x0a\x09arguments := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classReferences",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@classReferences"];
- return $1;
- },
- args: [],
- source: "classReferences\x0a\x09^ classReferences",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classReferences:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@classReferences"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "classReferences: aCollection\x0a\x09classReferences := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._sendIndexes())._keys();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.MethodNode)})},
- args: [],
- source: "messageSends\x0a\x09^ self sendIndexes keys",
- messageSends: ["keys", "sendIndexes"],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "method\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aMethodScope){
- var self=this;
- self["@scope"]=aMethodScope;
- return self},
- args: ["aMethodScope"],
- source: "scope: aMethodScope\x0a\x09scope := aMethodScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@sendIndexes"];
- return $1;
- },
- args: [],
- source: "sendIndexes\x0a\x09^ sendIndexes",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes:",
- protocol: 'accessing',
- fn: function (aDictionary){
- var self=this;
- self["@sendIndexes"]=aDictionary;
- return self},
- args: ["aDictionary"],
- source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@source"];
- return $1;
- },
- args: [],
- source: "source\x0a\x09^ source",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@superSends"];
- return $1;
- },
- args: [],
- source: "superSends\x0a\x09^ superSends",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSends:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@superSends"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "superSends: aCollection\x0a\x09superSends := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodNode);
- smalltalk.addClass('ReturnNode', globals.Node, ['scope'], 'Compiler-AST');
- globals.ReturnNode.comment="I represent an return node. At the AST level, there is not difference between a local return or non-local return.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitReturnNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.ReturnNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitReturnNode: self",
- messageSends: ["visitReturnNode:"],
- referencedClasses: []
- }),
- globals.ReturnNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isReturnNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isReturnNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ReturnNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nonLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._scope())._isMethodScope())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nonLocalReturn",{},globals.ReturnNode)})},
- args: [],
- source: "nonLocalReturn\x0a\x09^ self scope isMethodScope not",
- messageSends: ["not", "isMethodScope", "scope"],
- referencedClasses: []
- }),
- globals.ReturnNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ReturnNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aLexicalScope){
- var self=this;
- self["@scope"]=aLexicalScope;
- return self},
- args: ["aLexicalScope"],
- source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ReturnNode);
- smalltalk.addClass('SendNode', globals.Node, ['selector', 'arguments', 'receiver', 'superSend', 'index'], 'Compiler-AST');
- globals.SendNode.comment="I represent an message send node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitSendNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.SendNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitSendNode: self",
- messageSends: ["visitSendNode:"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@arguments"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@arguments"]=[];
- $1=self["@arguments"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.SendNode)})},
- args: [],
- source: "arguments\x0a\x09^ arguments ifNil: [ arguments := #() ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@arguments"]=aCollection;
- _st(aCollection)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._parent_(self);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.SendNode)})},
- args: ["aCollection"],
- source: "arguments: aCollection\x0a\x09arguments := aCollection.\x0a\x09aCollection do: [ :each | each parent: self ]",
- messageSends: ["do:", "parent:"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "cascadeNodeWithMessages:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- var first;
- function $SendNode(){return globals.SendNode||(typeof SendNode=="undefined"?nil:SendNode)}
- function $CascadeNode(){return globals.CascadeNode||(typeof CascadeNode=="undefined"?nil:CascadeNode)}
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$5,$3;
- $1=_st($SendNode())._new();
- $ctx1.sendIdx["new"]=1;
- _st($1)._selector_(self._selector());
- _st($1)._arguments_(self._arguments());
- $2=_st($1)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- first=$2;
- $4=_st($CascadeNode())._new();
- _st($4)._receiver_(self._receiver());
- _st($4)._nodes_(_st(_st($Array())._with_(first)).__comma(aCollection));
- $5=_st($4)._yourself();
- $3=$5;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"cascadeNodeWithMessages:",{aCollection:aCollection,first:first},globals.SendNode)})},
- args: ["aCollection"],
- source: "cascadeNodeWithMessages: aCollection\x0a\x09| first |\x0a\x09first := SendNode new\x0a\x09\x09selector: self selector;\x0a\x09\x09arguments: self arguments;\x0a\x09\x09yourself.\x0a\x09^ CascadeNode new\x0a\x09\x09receiver: self receiver;\x0a\x09\x09nodes: (Array with: first), aCollection;\x0a\x09\x09yourself",
- messageSends: ["selector:", "new", "selector", "arguments:", "arguments", "yourself", "receiver:", "receiver", "nodes:", ",", "with:"],
- referencedClasses: ["SendNode", "CascadeNode", "Array"]
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@index"];
- return $1;
- },
- args: [],
- source: "index\x0a\x09^ index",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@index"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "index: anInteger\x0a\x09index := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isCascadeSendNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._parent())._isCascadeNode();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isCascadeSendNode",{},globals.SendNode)})},
- args: [],
- source: "isCascadeSendNode\x0a\x09^ self parent isCascadeNode",
- messageSends: ["isCascadeNode", "parent"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSendNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSendNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nodes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$5,$6,$4;
- $1=self._receiver();
- $ctx1.sendIdx["receiver"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- $3=self._arguments();
- $ctx1.sendIdx["arguments"]=1;
- $2=_st($3)._copy();
- return $2;
- } else {
- $1;
- };
- $5=_st($Array())._with_(self._receiver());
- _st($5)._addAll_(self._arguments());
- $6=_st($5)._yourself();
- $4=$6;
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.SendNode)})},
- args: [],
- source: "nodes\x0a\x09self receiver ifNil: [ ^ self arguments copy ].\x0a\x09\x0a\x09^ (Array with: self receiver)\x0a\x09\x09addAll: self arguments;\x0a\x09\x09yourself",
- messageSends: ["ifNil:", "receiver", "copy", "arguments", "addAll:", "with:", "yourself"],
- referencedClasses: ["Array"]
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@receiver"];
- return $1;
- },
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self["@receiver"]=aNode;
- $1=_st(aNode)._isNode();
- if(smalltalk.assert($1)){
- _st(aNode)._parent_(self);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{aNode:aNode},globals.SendNode)})},
- args: ["aNode"],
- source: "receiver: aNode\x0a\x09receiver := aNode.\x0a\x09aNode isNode ifTrue: [\x0a\x09\x09aNode parent: self ]",
- messageSends: ["ifTrue:", "isNode", "parent:"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "requiresSmalltalkContext",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "requiresSmalltalkContext\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldBeAliased",
- protocol: 'testing',
- fn: function (){
- var self=this;
- var sends;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- sends=_st(_st(_st(self._method())._sendIndexes())._at_(self._selector()))._size();
- $1=_st(globals.SendNode.superclass.fn.prototype._shouldBeAliased.apply(_st(self), []))._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(_st(sends).__gt((1)))._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(self._index()).__lt(sends);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})))._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._isReferenced();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- $ctx2.sendIdx["and:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{sends:sends},globals.SendNode)})},
- args: [],
- source: "shouldBeAliased\x0a\x09\x22Because we keep track of send indexes, some send nodes need additional care for aliasing. \x0a\x09See IRJSVisitor >> visitIRSend:\x22\x0a\x09\x0a\x09| sends |\x0a\x09\x0a\x09sends := (self method sendIndexes at: self selector) size.\x0a\x09\x0a\x09^ super shouldBeAliased or: [\x0a\x09\x09(sends > 1 and: [ self index < sends ]) and: [ self isReferenced ] ]",
- messageSends: ["size", "at:", "sendIndexes", "method", "selector", "or:", "shouldBeAliased", "and:", ">", "<", "index", "isReferenced"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stopOnStepping",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "stopOnStepping\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSend",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@superSend"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"superSend",{},globals.SendNode)})},
- args: [],
- source: "superSend\x0a\x09^ superSend ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSend:",
- protocol: 'accessing',
- fn: function (aBoolean){
- var self=this;
- self["@superSend"]=aBoolean;
- return self},
- args: ["aBoolean"],
- source: "superSend: aBoolean\x0a\x09superSend := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueForReceiver:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- function $SendNode(){return globals.SendNode||(typeof SendNode=="undefined"?nil:SendNode)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$5,$4,$6,$1;
- $2=_st($SendNode())._new();
- _st($2)._position_(self._position());
- _st($2)._source_(self._source());
- $3=$2;
- $5=self._receiver();
- $ctx1.sendIdx["receiver"]=1;
- if(($receiver = $5) == nil || $receiver == null){
- $4=anObject;
- } else {
- $4=_st(self._receiver())._valueForReceiver_(anObject);
- };
- _st($3)._receiver_($4);
- _st($2)._selector_(self._selector());
- _st($2)._arguments_(self._arguments());
- $6=_st($2)._yourself();
- $1=$6;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"valueForReceiver:",{anObject:anObject},globals.SendNode)})},
- args: ["anObject"],
- source: "valueForReceiver: anObject\x0a\x09^ SendNode new\x0a\x09\x09position: self position;\x0a\x09\x09source: self source;\x0a\x09\x09receiver: (self receiver\x0a\x09\x09ifNil: [ anObject ] \x0a\x09\x09ifNotNil: [ self receiver valueForReceiver: anObject ]);\x0a\x09\x09selector: self selector;\x0a\x09\x09arguments: self arguments;\x0a\x09\x09yourself",
- messageSends: ["position:", "new", "position", "source:", "source", "receiver:", "ifNil:ifNotNil:", "receiver", "valueForReceiver:", "selector:", "selector", "arguments:", "arguments", "yourself"],
- referencedClasses: ["SendNode"]
- }),
- globals.SendNode);
- smalltalk.addClass('SequenceNode', globals.Node, ['temps', 'scope'], 'Compiler-AST');
- globals.SequenceNode.comment="I represent an sequence node. A sequence represent a set of instructions inside the same scope (the method scope or a block scope).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitSequenceNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.SequenceNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitSequenceNode: self",
- messageSends: ["visitSequenceNode:"],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "asBlockSequenceNode",
- protocol: 'converting',
- fn: function (){
- var self=this;
- function $BlockSequenceNode(){return globals.BlockSequenceNode||(typeof BlockSequenceNode=="undefined"?nil:BlockSequenceNode)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($BlockSequenceNode())._new();
- _st($2)._position_(self._position());
- _st($2)._source_(self._source());
- _st($2)._nodes_(self._nodes());
- _st($2)._temps_(self._temps());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"asBlockSequenceNode",{},globals.SequenceNode)})},
- args: [],
- source: "asBlockSequenceNode\x0a\x09^ BlockSequenceNode new\x0a\x09\x09position: self position;\x0a\x09\x09source: self source;\x0a\x09\x09nodes: self nodes;\x0a\x09\x09temps: self temps;\x0a\x09\x09yourself",
- messageSends: ["position:", "new", "position", "source:", "source", "nodes:", "nodes", "temps:", "temps", "yourself"],
- referencedClasses: ["BlockSequenceNode"]
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSequenceNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSequenceNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aLexicalScope){
- var self=this;
- self["@scope"]=aLexicalScope;
- return self},
- args: ["aLexicalScope"],
- source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "temps",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@temps"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=[];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.SequenceNode)})},
- args: [],
- source: "temps\x0a\x09^ temps ifNil: [ #() ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "temps:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@temps"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "temps: aCollection\x0a\x09temps := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SequenceNode);
- smalltalk.addClass('BlockSequenceNode', globals.SequenceNode, [], 'Compiler-AST');
- globals.BlockSequenceNode.comment="I represent an special sequence node for block scopes.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitBlockSequenceNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockSequenceNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockSequenceNode: self",
- messageSends: ["visitBlockSequenceNode:"],
- referencedClasses: []
- }),
- globals.BlockSequenceNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockSequenceNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isBlockSequenceNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockSequenceNode);
- smalltalk.addClass('ValueNode', globals.Node, ['value'], 'Compiler-AST');
- globals.ValueNode.comment="I represent a value node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitValueNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.ValueNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitValueNode: self",
- messageSends: ["visitValueNode:"],
- referencedClasses: []
- }),
- globals.ValueNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._value())._isImmutable();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.ValueNode)})},
- args: [],
- source: "isImmutable\x0a\x09^ self value isImmutable",
- messageSends: ["isImmutable", "value"],
- referencedClasses: []
- }),
- globals.ValueNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isValueNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isValueNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ValueNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@value"];
- return $1;
- },
- args: [],
- source: "value\x0a\x09^ value",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ValueNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@value"]=anObject;
- return self},
- args: ["anObject"],
- source: "value: anObject\x0a\x09value := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ValueNode);
- smalltalk.addClass('VariableNode', globals.ValueNode, ['assigned', 'binding'], 'Compiler-AST');
- globals.VariableNode.comment="I represent an variable node.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitVariableNode_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.VariableNode)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitVariableNode: self",
- messageSends: ["visitVariableNode:"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._binding())._alias();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.VariableNode)})},
- args: [],
- source: "alias\x0a\x09^ self binding alias",
- messageSends: ["alias", "binding"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assigned",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@assigned"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"assigned",{},globals.VariableNode)})},
- args: [],
- source: "assigned\x0a\x09^ assigned ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assigned:",
- protocol: 'accessing',
- fn: function (aBoolean){
- var self=this;
- self["@assigned"]=aBoolean;
- return self},
- args: ["aBoolean"],
- source: "assigned: aBoolean\x0a\x09assigned := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "beAssigned",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._binding())._validateAssignment();
- self["@assigned"]=true;
- return self}, function($ctx1) {$ctx1.fill(self,"beAssigned",{},globals.VariableNode)})},
- args: [],
- source: "beAssigned\x0a\x09self binding validateAssignment.\x0a\x09assigned := true",
- messageSends: ["validateAssignment", "binding"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "binding",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@binding"];
- return $1;
- },
- args: [],
- source: "binding\x0a\x09^ binding",
- messageSends: [],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "binding:",
- protocol: 'accessing',
- fn: function (aScopeVar){
- var self=this;
- self["@binding"]=aScopeVar;
- return self},
- args: ["aScopeVar"],
- source: "binding: aScopeVar\x0a\x09binding := aScopeVar",
- messageSends: [],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isArgument",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._binding())._isArgVar();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isArgument",{},globals.VariableNode)})},
- args: [],
- source: "isArgument\x0a\x09^ self binding isArgVar",
- messageSends: ["isArgVar", "binding"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._binding())._isImmutable();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.VariableNode)})},
- args: [],
- source: "isImmutable\x0a\x09^ self binding isImmutable",
- messageSends: ["isImmutable", "binding"],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariableNode",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isVariableNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.VariableNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ast",
- protocol: '*Compiler-AST',
- fn: function (){
- var self=this;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self._source();
- $ctx1.sendIdx["source"]=1;
- _st($1)._ifEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Method source is empty");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $2=_st($Smalltalk())._parse_(self._source());
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"ast",{},globals.CompiledMethod)})},
- args: [],
- source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Smalltalk parse: self source",
- messageSends: ["ifEmpty:", "source", "error:", "parse:"],
- referencedClasses: ["Smalltalk"]
- }),
- globals.CompiledMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNode",
- protocol: '*Compiler-AST',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Object);
- });
- define("amber_core/Compiler-IR", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Compiler-Core", "amber_core/Kernel-Objects", "amber_core/Kernel-Methods"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-IR');
- smalltalk.packages["Compiler-IR"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('IRASTTranslator', globals.NodeVisitor, ['source', 'theClass', 'method', 'sequence', 'nextAlias'], 'Compiler-IR');
- globals.IRASTTranslator.comment="I am the AST (abstract syntax tree) visitor responsible for building the intermediate representation graph.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var variable;
- function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
- function $AliasVar(){return globals.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
- function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$6,$5,$7,$8,$10,$11,$9,$12;
- $1=_st(aNode)._isImmutable();
- if(smalltalk.assert($1)){
- $2=self._visit_(aNode);
- $ctx1.sendIdx["visit:"]=1;
- return $2;
- };
- $3=_st($IRVariable())._new();
- $ctx1.sendIdx["new"]=1;
- $4=$3;
- $6=_st($AliasVar())._new();
- $ctx1.sendIdx["new"]=2;
- $5=_st($6)._name_("$".__comma(self._nextAlias()));
- _st($4)._variable_($5);
- $7=_st($3)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- variable=$7;
- $8=self._sequence();
- $10=_st($IRAssignment())._new();
- _st($10)._add_(variable);
- $ctx1.sendIdx["add:"]=2;
- _st($10)._add_(self._visit_(aNode));
- $ctx1.sendIdx["add:"]=3;
- $11=_st($10)._yourself();
- $9=$11;
- _st($8)._add_($9);
- $ctx1.sendIdx["add:"]=1;
- _st(_st(self._method())._internalVariables())._add_(variable);
- $12=variable;
- return $12;
- }, function($ctx1) {$ctx1.fill(self,"alias:",{aNode:aNode,variable:variable},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "alias: aNode\x0a\x09| variable |\x0a\x0a\x09aNode isImmutable ifTrue: [ ^ self visit: aNode ].\x0a\x0a\x09variable := IRVariable new\x0a\x09\x09variable: (AliasVar new name: '$', self nextAlias);\x0a\x09\x09yourself.\x0a\x0a\x09self sequence add: (IRAssignment new\x0a\x09\x09add: variable;\x0a\x09\x09add: (self visit: aNode);\x0a\x09\x09yourself).\x0a\x0a\x09self method internalVariables add: variable.\x0a\x0a\x09^ variable",
- messageSends: ["ifTrue:", "isImmutable", "visit:", "variable:", "new", "name:", ",", "nextAlias", "yourself", "add:", "sequence", "internalVariables", "method"],
- referencedClasses: ["IRVariable", "AliasVar", "IRAssignment"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "aliasTemporally:",
- protocol: 'visiting',
- fn: function (aCollection){
- var self=this;
- var threshold,result;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$5;
- threshold=(0);
- _st(aCollection)._withIndexDo_((function(each,i){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(each)._subtreeNeedsAliasing();
- if(smalltalk.assert($1)){
- threshold=i;
- return threshold;
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,1)})}));
- $ctx1.sendIdx["withIndexDo:"]=1;
- result=_st($OrderedCollection())._new();
- _st(aCollection)._withIndexDo_((function(each,i){
- return smalltalk.withContext(function($ctx2) {
- $2=result;
- $4=_st(i).__lt_eq(threshold);
- if(smalltalk.assert($4)){
- $3=self._alias_(each);
- } else {
- $3=self._visit_(each);
- };
- return _st($2)._add_($3);
- }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,3)})}));
- $5=result;
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"aliasTemporally:",{aCollection:aCollection,threshold:threshold,result:result},globals.IRASTTranslator)})},
- args: ["aCollection"],
- source: "aliasTemporally: aCollection\x0a\x09\x22https://github.com/NicolasPetton/amber/issues/296\x0a\x09\x0a\x09If a node is aliased, all preceding ones are aliased as well.\x0a\x09The tree is iterated twice. First we get the aliasing dependency,\x0a\x09then the aliasing itself is done\x22\x0a\x0a\x09| threshold result |\x0a\x09threshold := 0.\x0a\x09\x0a\x09aCollection withIndexDo: [ :each :i |\x0a\x09\x09each subtreeNeedsAliasing\x0a\x09\x09\x09ifTrue: [ threshold := i ] ].\x0a\x0a\x09result := OrderedCollection new.\x0a\x09aCollection withIndexDo: [ :each :i |\x0a\x09\x09result add: (i <= threshold\x0a\x09\x09\x09ifTrue: [ self alias: each ]\x0a\x09\x09\x09ifFalse: [ self visit: each ]) ].\x0a\x0a\x09^ result",
- messageSends: ["withIndexDo:", "ifTrue:", "subtreeNeedsAliasing", "new", "add:", "ifTrue:ifFalse:", "<=", "alias:", "visit:"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@method"];
- return $1;
- },
- args: [],
- source: "method\x0a\x09^ method",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method:",
- protocol: 'accessing',
- fn: function (anIRMethod){
- var self=this;
- self["@method"]=anIRMethod;
- return self},
- args: ["anIRMethod"],
- source: "method: anIRMethod\x0a\x09method := anIRMethod",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextAlias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@nextAlias"];
- if(($receiver = $1) == nil || $receiver == null){
- self["@nextAlias"]=(0);
- self["@nextAlias"];
- } else {
- $1;
- };
- self["@nextAlias"]=_st(self["@nextAlias"]).__plus((1));
- $2=_st(self["@nextAlias"])._asString();
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"nextAlias",{},globals.IRASTTranslator)})},
- args: [],
- source: "nextAlias\x0a\x09nextAlias ifNil: [ nextAlias := 0 ].\x0a\x09nextAlias := nextAlias + 1.\x0a\x09^ nextAlias asString",
- messageSends: ["ifNil:", "+", "asString"],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sequence",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@sequence"];
- return $1;
- },
- args: [],
- source: "sequence\x0a\x09^ sequence",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sequence:",
- protocol: 'accessing',
- fn: function (anIRSequence){
- var self=this;
- self["@sequence"]=anIRSequence;
- return self},
- args: ["anIRSequence"],
- source: "sequence: anIRSequence\x0a\x09sequence := anIRSequence",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@source"];
- return $1;
- },
- args: [],
- source: "source\x0a\x09^ source",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAssignmentNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var left,right,assignment;
- function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$4,$2,$5;
- right=self._visit_(_st(aNode)._right());
- $ctx1.sendIdx["visit:"]=1;
- left=self._visit_(_st(aNode)._left());
- $1=self._sequence();
- $3=_st($IRAssignment())._new();
- _st($3)._add_(left);
- $ctx1.sendIdx["add:"]=2;
- _st($3)._add_(right);
- $4=_st($3)._yourself();
- $2=$4;
- _st($1)._add_($2);
- $ctx1.sendIdx["add:"]=1;
- $5=left;
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,left:left,right:right,assignment:assignment},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09| left right assignment |\x0a\x09right := self visit: aNode right.\x0a\x09left := self visit: aNode left.\x0a\x09self sequence add: (IRAssignment new\x0a\x09\x09add: left;\x0a\x09\x09add: right;\x0a\x09\x09yourself).\x0a\x09^ left",
- messageSends: ["visit:", "right", "left", "add:", "sequence", "new", "yourself"],
- referencedClasses: ["IRAssignment"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var closure;
- function $IRClosure(){return globals.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
- function $IRTempDeclaration(){return globals.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$6,$5,$7,$8,$9;
- $1=_st($IRClosure())._new();
- $ctx1.sendIdx["new"]=1;
- _st($1)._arguments_(_st(aNode)._parameters());
- _st($1)._requiresSmalltalkContext_(_st(aNode)._requiresSmalltalkContext());
- $2=$1;
- $3=_st(aNode)._scope();
- $ctx1.sendIdx["scope"]=1;
- _st($2)._scope_($3);
- $ctx1.sendIdx["scope:"]=1;
- $4=_st($1)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- closure=$4;
- $6=_st(aNode)._scope();
- $ctx1.sendIdx["scope"]=2;
- $5=_st($6)._temps();
- _st($5)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $7=_st($IRTempDeclaration())._new();
- _st($7)._name_(_st(each)._name());
- _st($7)._scope_(_st(aNode)._scope());
- $8=_st($7)._yourself();
- return _st(closure)._add_($8);
- $ctx2.sendIdx["add:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(closure)._add_(self._visit_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- $9=closure;
- return $9;
- }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,closure:closure},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09| closure |\x0a\x09closure := IRClosure new\x0a\x09\x09arguments: aNode parameters;\x0a\x09\x09requiresSmalltalkContext: aNode requiresSmalltalkContext;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself.\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09closure add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x09aNode nodes do: [ :each | closure add: (self visit: each) ].\x0a\x09^ closure",
- messageSends: ["arguments:", "new", "parameters", "requiresSmalltalkContext:", "requiresSmalltalkContext", "scope:", "scope", "yourself", "do:", "temps", "add:", "name:", "name", "nodes", "visit:"],
- referencedClasses: ["IRClosure", "IRTempDeclaration"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRBlockSequence(){return globals.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
- function $IRBlockReturn(){return globals.IRBlockReturn||(typeof IRBlockReturn=="undefined"?nil:IRBlockReturn)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$5,$4,$6,$7,$10,$9,$8,$11,$13,$14,$17,$16,$15,$18,$12,$1;
- $2=_st($IRBlockSequence())._new();
- $ctx1.sendIdx["new"]=1;
- $1=self._withSequence_do_($2,(function(){
- return smalltalk.withContext(function($ctx2) {
- $3=_st(aNode)._nodes();
- $ctx2.sendIdx["nodes"]=1;
- return _st($3)._ifNotEmpty_((function(){
- return smalltalk.withContext(function($ctx3) {
- $5=_st(aNode)._nodes();
- $ctx3.sendIdx["nodes"]=2;
- $4=_st($5)._allButLast();
- _st($4)._do_((function(each){
- return smalltalk.withContext(function($ctx4) {
- $6=self._sequence();
- $ctx4.sendIdx["sequence"]=1;
- $7=self._visitOrAlias_(each);
- $ctx4.sendIdx["visitOrAlias:"]=1;
- return _st($6)._add_($7);
- $ctx4.sendIdx["add:"]=1;
- }, function($ctx4) {$ctx4.fillBlock({each:each},$ctx3,3)})}));
- $10=_st(aNode)._nodes();
- $ctx3.sendIdx["nodes"]=3;
- $9=_st($10)._last();
- $ctx3.sendIdx["last"]=1;
- $8=_st($9)._isReturnNode();
- if(smalltalk.assert($8)){
- return _st(self._sequence())._add_(self._visitOrAlias_(_st(_st(aNode)._nodes())._last()));
- } else {
- $11=self._sequence();
- $ctx3.sendIdx["sequence"]=2;
- $13=_st($IRBlockReturn())._new();
- $14=$13;
- $17=_st(aNode)._nodes();
- $ctx3.sendIdx["nodes"]=4;
- $16=_st($17)._last();
- $ctx3.sendIdx["last"]=2;
- $15=self._visitOrAlias_($16);
- $ctx3.sendIdx["visitOrAlias:"]=2;
- _st($14)._add_($15);
- $ctx3.sendIdx["add:"]=3;
- $18=_st($13)._yourself();
- $12=$18;
- return _st($11)._add_($12);
- $ctx3.sendIdx["add:"]=2;
- };
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitBlockSequenceNode: aNode\x0a\x09^ self\x0a\x09\x09withSequence: IRBlockSequence new\x0a\x09\x09do: [\x0a\x09\x09\x09aNode nodes ifNotEmpty: [\x0a\x09\x09\x09\x09aNode nodes allButLast do: [ :each |\x0a\x09\x09\x09\x09\x09self sequence add: (self visitOrAlias: each) ].\x0a\x09\x09\x09\x09aNode nodes last isReturnNode\x0a\x09\x09\x09\x09\x09ifFalse: [ self sequence add: (IRBlockReturn new add: (self visitOrAlias: aNode nodes last); yourself) ]\x0a\x09\x09\x09\x09\x09ifTrue: [ self sequence add: (self visitOrAlias: aNode nodes last) ] ]]",
- messageSends: ["withSequence:do:", "new", "ifNotEmpty:", "nodes", "do:", "allButLast", "add:", "sequence", "visitOrAlias:", "ifFalse:ifTrue:", "isReturnNode", "last", "yourself"],
- referencedClasses: ["IRBlockSequence", "IRBlockReturn"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitCascadeNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var alias,receiver;
- function $VariableNode(){return globals.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$5,$4,$6;
- $2=_st(aNode)._receiver();
- $ctx1.sendIdx["receiver"]=1;
- $1=_st($2)._isImmutable();
- if(smalltalk.assert($1)){
- receiver=_st(aNode)._receiver();
- $ctx1.sendIdx["receiver"]=2;
- receiver;
- } else {
- alias=self._alias_(_st(aNode)._receiver());
- $ctx1.sendIdx["alias:"]=1;
- alias;
- receiver=_st(_st($VariableNode())._new())._binding_(_st(alias)._variable());
- receiver;
- };
- $3=_st(aNode)._nodes();
- $ctx1.sendIdx["nodes"]=1;
- _st($3)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._receiver_(receiver);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
- $ctx1.sendIdx["do:"]=1;
- $5=_st(aNode)._nodes();
- $ctx1.sendIdx["nodes"]=2;
- $4=_st($5)._allButLast();
- _st($4)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._sequence())._add_(self._visit_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
- $6=self._alias_(_st(_st(aNode)._nodes())._last());
- return $6;
- }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode,alias:alias,receiver:receiver},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitCascadeNode: aNode\x0a\x09| alias receiver |\x0a\x0a\x09aNode receiver isImmutable \x0a\x09\x09ifTrue: [ receiver := aNode receiver ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09alias := self alias: aNode receiver.\x0a\x09\x09\x09receiver := VariableNode new binding: alias variable ].\x0a\x09\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09\x09each receiver: receiver ].\x0a\x0a\x09aNode nodes allButLast do: [ :each |\x0a\x09\x09self sequence add: (self visit: each) ].\x0a\x0a\x09^ self alias: aNode nodes last",
- messageSends: ["ifTrue:ifFalse:", "isImmutable", "receiver", "alias:", "binding:", "new", "variable", "do:", "nodes", "receiver:", "allButLast", "add:", "sequence", "visit:", "last"],
- referencedClasses: ["VariableNode"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicArrayNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var array;
- function $IRDynamicArray(){return globals.IRDynamicArray||(typeof IRDynamicArray=="undefined"?nil:IRDynamicArray)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- array=_st($IRDynamicArray())._new();
- _st(self._aliasTemporally_(_st(aNode)._nodes()))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(array)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=array;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09array := IRDynamicArray new.\x0a\x09(self aliasTemporally: aNode nodes) do: [ :each | array add: each ].\x0a\x09^ array",
- messageSends: ["new", "do:", "aliasTemporally:", "nodes", "add:"],
- referencedClasses: ["IRDynamicArray"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicDictionaryNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var dictionary;
- function $IRDynamicDictionary(){return globals.IRDynamicDictionary||(typeof IRDynamicDictionary=="undefined"?nil:IRDynamicDictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- dictionary=_st($IRDynamicDictionary())._new();
- _st(self._aliasTemporally_(_st(aNode)._nodes()))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(dictionary)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $1=dictionary;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,dictionary:dictionary},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitDynamicDictionaryNode: aNode\x0a\x09| dictionary |\x0a\x09dictionary := IRDynamicDictionary new.\x0a\x09(self aliasTemporally: aNode nodes) do: [ :each | dictionary add: each ].\x0a\x09^ dictionary",
- messageSends: ["new", "do:", "aliasTemporally:", "nodes", "add:"],
- referencedClasses: ["IRDynamicDictionary"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRVerbatim(){return globals.IRVerbatim||(typeof IRVerbatim=="undefined"?nil:IRVerbatim)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRVerbatim())._new();
- _st($2)._source_(_st(_st(aNode)._source())._crlfSanitized());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09^ IRVerbatim new\x0a\x09\x09source: aNode source crlfSanitized;\x0a\x09\x09yourself",
- messageSends: ["source:", "new", "crlfSanitized", "source", "yourself"],
- referencedClasses: ["IRVerbatim"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitMethodNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRMethod(){return globals.IRMethod||(typeof IRMethod=="undefined"?nil:IRMethod)}
- function $IRTempDeclaration(){return globals.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
- function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
- function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$5,$1,$7,$6,$8,$10,$11,$12,$13,$9,$14,$16,$15,$18,$19,$17,$20,$21,$22;
- $2=_st($IRMethod())._new();
- $ctx1.sendIdx["new"]=1;
- _st($2)._source_(_st(self._source())._crlfSanitized());
- _st($2)._theClass_(self._theClass());
- _st($2)._arguments_(_st(aNode)._arguments());
- _st($2)._selector_(_st(aNode)._selector());
- _st($2)._sendIndexes_(_st(aNode)._sendIndexes());
- _st($2)._superSends_(_st(aNode)._superSends());
- _st($2)._requiresSmalltalkContext_(_st(aNode)._requiresSmalltalkContext());
- _st($2)._classReferences_(_st(aNode)._classReferences());
- $3=$2;
- $4=_st(aNode)._scope();
- $ctx1.sendIdx["scope"]=1;
- _st($3)._scope_($4);
- $ctx1.sendIdx["scope:"]=1;
- $5=_st($2)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- $1=$5;
- self._method_($1);
- $7=_st(aNode)._scope();
- $ctx1.sendIdx["scope"]=2;
- $6=_st($7)._temps();
- _st($6)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $8=self._method();
- $ctx2.sendIdx["method"]=1;
- $10=_st($IRTempDeclaration())._new();
- $ctx2.sendIdx["new"]=2;
- _st($10)._name_(_st(each)._name());
- $11=$10;
- $12=_st(aNode)._scope();
- $ctx2.sendIdx["scope"]=3;
- _st($11)._scope_($12);
- $13=_st($10)._yourself();
- $ctx2.sendIdx["yourself"]=2;
- $9=$13;
- return _st($8)._add_($9);
- $ctx2.sendIdx["add:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $14=self._method();
- $ctx2.sendIdx["method"]=2;
- return _st($14)._add_(self._visit_(each));
- $ctx2.sendIdx["add:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- $16=_st(aNode)._scope();
- $ctx1.sendIdx["scope"]=4;
- $15=_st($16)._hasLocalReturn();
- if(! smalltalk.assert($15)){
- $18=self._method();
- $ctx1.sendIdx["method"]=3;
- $19=_st($IRReturn())._new();
- $ctx1.sendIdx["new"]=3;
- $17=_st($18)._add_($19);
- $20=_st($IRVariable())._new();
- _st($20)._variable_(_st(_st(_st(aNode)._scope())._pseudoVars())._at_("self"));
- $21=_st($20)._yourself();
- _st($17)._add_($21);
- $ctx1.sendIdx["add:"]=3;
- };
- $22=self._method();
- return $22;
- }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitMethodNode: aNode\x0a\x0a\x09self method: (IRMethod new\x0a\x09\x09source: self source crlfSanitized;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09sendIndexes: aNode sendIndexes;\x0a\x09\x09superSends: aNode superSends;\x0a\x09\x09requiresSmalltalkContext: aNode requiresSmalltalkContext;\x0a\x09\x09classReferences: aNode classReferences;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself).\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self method add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09aNode nodes do: [ :each | self method add: (self visit: each) ].\x0a\x0a\x09aNode scope hasLocalReturn ifFalse: [\x0a\x09\x09(self method add: IRReturn new) add: (IRVariable new\x0a\x09\x09\x09variable: (aNode scope pseudoVars at: 'self');\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09^ self method",
- messageSends: ["method:", "source:", "new", "crlfSanitized", "source", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "sendIndexes:", "sendIndexes", "superSends:", "superSends", "requiresSmalltalkContext:", "requiresSmalltalkContext", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "temps", "add:", "method", "name:", "name", "nodes", "visit:", "ifFalse:", "hasLocalReturn", "variable:", "at:", "pseudoVars"],
- referencedClasses: ["IRMethod", "IRTempDeclaration", "IRReturn", "IRVariable"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitOrAlias:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(aNode)._shouldBeAliased();
- if(smalltalk.assert($2)){
- $1=self._alias_(aNode);
- } else {
- $1=self._visit_(aNode);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitOrAlias:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitOrAlias: aNode\x0a\x09^ aNode shouldBeAliased\x0a\x09\x09ifTrue: [ self alias: aNode ]\x0a\x09\x09ifFalse: [ self visit: aNode ]",
- messageSends: ["ifTrue:ifFalse:", "shouldBeAliased", "alias:", "visit:"],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReturnNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var return_;
- function $IRNonLocalReturn(){return globals.IRNonLocalReturn||(typeof IRNonLocalReturn=="undefined"?nil:IRNonLocalReturn)}
- function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(aNode)._nonLocalReturn();
- if(smalltalk.assert($1)){
- return_=_st($IRNonLocalReturn())._new();
- $ctx1.sendIdx["new"]=1;
- } else {
- return_=_st($IRReturn())._new();
- };
- _st(return_)._scope_(_st(aNode)._scope());
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(return_)._add_(self._alias_(each));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
- $2=return_;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode,return_:return_},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09| return |\x0a\x09return := aNode nonLocalReturn\x0a\x09\x09ifTrue: [ IRNonLocalReturn new ]\x0a\x09\x09ifFalse: [ IRReturn new ].\x0a\x09return scope: aNode scope.\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09return add: (self alias: each) ].\x0a\x09^ return",
- messageSends: ["ifTrue:ifFalse:", "nonLocalReturn", "new", "scope:", "scope", "do:", "nodes", "add:", "alias:"],
- referencedClasses: ["IRNonLocalReturn", "IRReturn"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var send,all,receiver,arguments;
- function $IRSend(){return globals.IRSend||(typeof IRSend=="undefined"?nil:IRSend)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- send=_st($IRSend())._new();
- $1=send;
- _st($1)._selector_(_st(aNode)._selector());
- $2=_st($1)._index_(_st(aNode)._index());
- $3=_st(aNode)._superSend();
- if(smalltalk.assert($3)){
- _st(send)._classSend_(_st(self._theClass())._superclass());
- };
- all=self._aliasTemporally_(_st([_st(aNode)._receiver()]).__comma(_st(aNode)._arguments()));
- receiver=_st(all)._first();
- arguments=_st(all)._allButFirst();
- _st(send)._add_(receiver);
- $ctx1.sendIdx["add:"]=1;
- _st(arguments)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(send)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- $4=send;
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,send:send,all:all,receiver:receiver,arguments:arguments},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09| send all receiver arguments |\x0a\x09send := IRSend new.\x0a\x09send\x0a\x09\x09selector: aNode selector;\x0a\x09\x09index: aNode index.\x0a\x09aNode superSend ifTrue: [ send classSend: self theClass superclass ].\x0a\x09\x0a\x09all := self aliasTemporally: { aNode receiver }, aNode arguments.\x0a\x09receiver := all first.\x0a\x09arguments := all allButFirst.\x0a\x0a\x09send add: receiver.\x0a\x09arguments do: [ :each | send add: each ].\x0a\x0a\x09^ send",
- messageSends: ["new", "selector:", "selector", "index:", "index", "ifTrue:", "superSend", "classSend:", "superclass", "theClass", "aliasTemporally:", ",", "receiver", "arguments", "first", "allButFirst", "add:", "do:"],
- referencedClasses: ["IRSend"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRSequence(){return globals.IRSequence||(typeof IRSequence=="undefined"?nil:IRSequence)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=self._withSequence_do_(_st($IRSequence())._new(),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(aNode)._nodes())._do_((function(each){
- var instruction;
- return smalltalk.withContext(function($ctx3) {
- instruction=self._visitOrAlias_(each);
- instruction;
- $2=_st(instruction)._isVariable();
- if(! smalltalk.assert($2)){
- return _st(self._sequence())._add_(instruction);
- };
- }, function($ctx3) {$ctx3.fillBlock({each:each,instruction:instruction},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitSequenceNode: aNode\x0a\x09^ self\x0a\x09\x09withSequence: IRSequence new\x0a\x09\x09do: [\x0a\x09\x09\x09aNode nodes do: [ :each | | instruction |\x0a\x09\x09\x09\x09instruction := self visitOrAlias: each.\x0a\x09\x09\x09\x09instruction isVariable ifFalse: [\x0a\x09\x09\x09\x09\x09self sequence add: instruction ] ]]",
- messageSends: ["withSequence:do:", "new", "do:", "nodes", "visitOrAlias:", "ifFalse:", "isVariable", "add:", "sequence"],
- referencedClasses: ["IRSequence"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitValueNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRValue(){return globals.IRValue||(typeof IRValue=="undefined"?nil:IRValue)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRValue())._new();
- _st($2)._value_(_st(aNode)._value());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09^ IRValue new\x0a\x09\x09value: aNode value;\x0a\x09\x09yourself",
- messageSends: ["value:", "new", "value", "yourself"],
- referencedClasses: ["IRValue"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitVariableNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRVariable())._new();
- _st($2)._variable_(_st(aNode)._binding());
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},globals.IRASTTranslator)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09^ IRVariable new\x0a\x09\x09variable: aNode binding;\x0a\x09\x09yourself",
- messageSends: ["variable:", "new", "binding", "yourself"],
- referencedClasses: ["IRVariable"]
- }),
- globals.IRASTTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withSequence:do:",
- protocol: 'accessing',
- fn: function (aSequence,aBlock){
- var self=this;
- var outerSequence;
- return smalltalk.withContext(function($ctx1) {
- outerSequence=self._sequence();
- self._sequence_(aSequence);
- $ctx1.sendIdx["sequence:"]=1;
- _st(aBlock)._value();
- self._sequence_(outerSequence);
- return aSequence;
- }, function($ctx1) {$ctx1.fill(self,"withSequence:do:",{aSequence:aSequence,aBlock:aBlock,outerSequence:outerSequence},globals.IRASTTranslator)})},
- args: ["aSequence", "aBlock"],
- source: "withSequence: aSequence do: aBlock\x0a\x09| outerSequence |\x0a\x09outerSequence := self sequence.\x0a\x09self sequence: aSequence.\x0a\x09aBlock value.\x0a\x09self sequence: outerSequence.\x0a\x09^ aSequence",
- messageSends: ["sequence", "sequence:", "value"],
- referencedClasses: []
- }),
- globals.IRASTTranslator);
- smalltalk.addClass('IRInstruction', globals.Object, ['parent', 'instructions'], 'Compiler-IR');
- globals.IRInstruction.comment="I am the abstract root class of the IR (intermediate representation) instructions class hierarchy.\x0aThe IR graph is used to emit JavaScript code using a JSStream.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRInstruction_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInstruction)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInstruction: self",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "add:",
- protocol: 'building',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(anObject)._parent_(self);
- $1=_st(self._instructions())._add_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},globals.IRInstruction)})},
- args: ["anObject"],
- source: "add: anObject\x0a\x09anObject parent: self.\x0a\x09^ self instructions add: anObject",
- messageSends: ["parent:", "add:", "instructions"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "canBeAssigned",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "canBeAssigned\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instructions",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@instructions"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@instructions"]=_st($OrderedCollection())._new();
- $1=self["@instructions"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"instructions",{},globals.IRInstruction)})},
- args: [],
- source: "instructions\x0a\x09^ instructions ifNil: [ instructions := OrderedCollection new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClosure",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isClosure\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isInlined\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isLocalReturn\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMethod",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isMethod\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isReturn\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSend",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSend\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSequence",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSequence\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isTempDeclaration",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isTempDeclaration\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isVariable\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._parent())._method();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.IRInstruction)})},
- args: [],
- source: "method\x0a\x09^ self parent method",
- messageSends: ["method", "parent"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "needsBoxingAsReceiver",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "needsBoxingAsReceiver\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parent",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@parent"];
- return $1;
- },
- args: [],
- source: "parent\x0a\x09^ parent",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parent:",
- protocol: 'accessing',
- fn: function (anIRInstruction){
- var self=this;
- self["@parent"]=anIRInstruction;
- return self},
- args: ["anIRInstruction"],
- source: "parent: anIRInstruction\x0a\x09parent := anIRInstruction",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove",
- protocol: 'building',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._parent())._remove_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"remove",{},globals.IRInstruction)})},
- args: [],
- source: "remove\x0a\x09self parent remove: self",
- messageSends: ["remove:", "parent"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "remove:",
- protocol: 'building',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._instructions())._remove_(anIRInstruction);
- return self}, function($ctx1) {$ctx1.fill(self,"remove:",{anIRInstruction:anIRInstruction},globals.IRInstruction)})},
- args: ["anIRInstruction"],
- source: "remove: anIRInstruction\x0a\x09self instructions remove: anIRInstruction",
- messageSends: ["remove:", "instructions"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "replace:with:",
- protocol: 'building',
- fn: function (anIRInstruction,anotherIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(anotherIRInstruction)._parent_(self);
- $1=self._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st($1)._at_put_(_st(self._instructions())._indexOf_(anIRInstruction),anotherIRInstruction);
- return self}, function($ctx1) {$ctx1.fill(self,"replace:with:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRInstruction)})},
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "replace: anIRInstruction with: anotherIRInstruction\x0a\x09anotherIRInstruction parent: self.\x0a\x09self instructions\x0a\x09\x09at: (self instructions indexOf: anIRInstruction)\x0a\x09\x09put: anotherIRInstruction",
- messageSends: ["parent:", "at:put:", "instructions", "indexOf:"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "replaceWith:",
- protocol: 'building',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._parent())._replace_with_(self,anIRInstruction);
- return self}, function($ctx1) {$ctx1.fill(self,"replaceWith:",{anIRInstruction:anIRInstruction},globals.IRInstruction)})},
- args: ["anIRInstruction"],
- source: "replaceWith: anIRInstruction\x0a\x09self parent replace: self with: anIRInstruction",
- messageSends: ["replace:with:", "parent"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._parent();
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- var node;
- node=$receiver;
- $1=_st(node)._scope();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"scope",{},globals.IRInstruction)})},
- args: [],
- source: "scope\x0a\x09^ self parent ifNotNil: [ :node | \x0a\x09\x09node scope ]",
- messageSends: ["ifNotNil:", "parent", "scope"],
- referencedClasses: []
- }),
- globals.IRInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aBuilder){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._builder_(aBuilder);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{aBuilder:aBuilder},globals.IRInstruction.klass)})},
- args: ["aBuilder"],
- source: "on: aBuilder\x0a\x09^ self new\x0a\x09\x09builder: aBuilder;\x0a\x09\x09yourself",
- messageSends: ["builder:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.IRInstruction.klass);
- smalltalk.addClass('IRAssignment', globals.IRInstruction, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRAssignment_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRAssignment)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRAssignment: self",
- messageSends: ["visitIRAssignment:"],
- referencedClasses: []
- }),
- globals.IRAssignment);
- smalltalk.addClass('IRDynamicArray', globals.IRInstruction, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRDynamicArray_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRDynamicArray)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRDynamicArray: self",
- messageSends: ["visitIRDynamicArray:"],
- referencedClasses: []
- }),
- globals.IRDynamicArray);
- smalltalk.addClass('IRDynamicDictionary', globals.IRInstruction, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRDynamicDictionary_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRDynamicDictionary)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRDynamicDictionary: self",
- messageSends: ["visitIRDynamicDictionary:"],
- referencedClasses: []
- }),
- globals.IRDynamicDictionary);
- smalltalk.addClass('IRScopedInstruction', globals.IRInstruction, ['scope'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRScopedInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aScope){
- var self=this;
- self["@scope"]=aScope;
- return self},
- args: ["aScope"],
- source: "scope: aScope\x0a\x09scope := aScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRScopedInstruction);
- smalltalk.addClass('IRClosureInstruction', globals.IRScopedInstruction, ['arguments', 'requiresSmalltalkContext'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@arguments"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=[];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.IRClosureInstruction)})},
- args: [],
- source: "arguments\x0a\x09^ arguments ifNil: [ #() ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@arguments"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "arguments: aCollection\x0a\x09arguments := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "locals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st(self._arguments())._copy();
- _st($2)._addAll_(_st(self._tempDeclarations())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._name();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"locals",{},globals.IRClosureInstruction)})},
- args: [],
- source: "locals\x0a\x09^ self arguments copy\x0a\x09\x09addAll: (self tempDeclarations collect: [ :each | each name ]);\x0a\x09\x09yourself",
- messageSends: ["addAll:", "copy", "arguments", "collect:", "tempDeclarations", "name", "yourself"],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "requiresSmalltalkContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@requiresSmalltalkContext"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"requiresSmalltalkContext",{},globals.IRClosureInstruction)})},
- args: [],
- source: "requiresSmalltalkContext\x0a\x09^ requiresSmalltalkContext ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "requiresSmalltalkContext:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@requiresSmalltalkContext"]=anObject;
- return self},
- args: ["anObject"],
- source: "requiresSmalltalkContext: anObject\x0a\x09requiresSmalltalkContext := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aScope){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.IRClosureInstruction.superclass.fn.prototype._scope_.apply(_st(self), [aScope]);
- _st(aScope)._instruction_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"scope:",{aScope:aScope},globals.IRClosureInstruction)})},
- args: ["aScope"],
- source: "scope: aScope\x0a\x09super scope: aScope.\x0a\x09aScope instruction: self",
- messageSends: ["scope:", "instruction:"],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "tempDeclarations",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._instructions())._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._isTempDeclaration();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"tempDeclarations",{},globals.IRClosureInstruction)})},
- args: [],
- source: "tempDeclarations\x0a\x09^ self instructions select: [ :each |\x0a\x09\x09each isTempDeclaration ]",
- messageSends: ["select:", "instructions", "isTempDeclaration"],
- referencedClasses: []
- }),
- globals.IRClosureInstruction);
- smalltalk.addClass('IRClosure', globals.IRClosureInstruction, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRClosure_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRClosure)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRClosure: self",
- messageSends: ["visitIRClosure:"],
- referencedClasses: []
- }),
- globals.IRClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClosure",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isClosure\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sequence",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._instructions())._last();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sequence",{},globals.IRClosure)})},
- args: [],
- source: "sequence\x0a\x09^ self instructions last",
- messageSends: ["last", "instructions"],
- referencedClasses: []
- }),
- globals.IRClosure);
- smalltalk.addClass('IRMethod', globals.IRClosureInstruction, ['theClass', 'source', 'selector', 'classReferences', 'sendIndexes', 'superSends', 'requiresSmalltalkContext', 'internalVariables'], 'Compiler-IR');
- globals.IRMethod.comment="I am a method instruction";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRMethod_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRMethod)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRMethod: self",
- messageSends: ["visitIRMethod:"],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classReferences",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@classReferences"];
- return $1;
- },
- args: [],
- source: "classReferences\x0a\x09^ classReferences",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classReferences:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@classReferences"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "classReferences: aCollection\x0a\x09classReferences := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "internalVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Set(){return globals.Set||(typeof Set=="undefined"?nil:Set)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@internalVariables"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@internalVariables"]=_st($Set())._new();
- $1=self["@internalVariables"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"internalVariables",{},globals.IRMethod)})},
- args: [],
- source: "internalVariables\x0a\x09^ internalVariables ifNil: [ internalVariables := Set new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Set"]
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMethod",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isMethod\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._sendIndexes())._keys();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.IRMethod)})},
- args: [],
- source: "messageSends\x0a\x09^ self sendIndexes keys",
- messageSends: ["keys", "sendIndexes"],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "method\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@sendIndexes"];
- return $1;
- },
- args: [],
- source: "sendIndexes\x0a\x09^ sendIndexes",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes:",
- protocol: 'accessing',
- fn: function (aDictionary){
- var self=this;
- self["@sendIndexes"]=aDictionary;
- return self},
- args: ["aDictionary"],
- source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@source"];
- return $1;
- },
- args: [],
- source: "source\x0a\x09^ source",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@superSends"];
- return $1;
- },
- args: [],
- source: "superSends\x0a\x09^ superSends",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSends:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@superSends"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "superSends: aCollection\x0a\x09superSends := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRMethod);
- smalltalk.addClass('IRReturn', globals.IRScopedInstruction, [], 'Compiler-IR');
- globals.IRReturn.comment="I am a local return instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRReturn_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRReturn)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRReturn: self",
- messageSends: ["visitIRReturn:"],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "canBeAssigned",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "canBeAssigned\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isBlockReturn\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isLocalReturn\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isNonLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._isLocalReturn())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isNonLocalReturn",{},globals.IRReturn)})},
- args: [],
- source: "isNonLocalReturn\x0a\x09^ self isLocalReturn not",
- messageSends: ["not", "isLocalReturn"],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isReturn\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@scope"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st(self._parent())._scope();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"scope",{},globals.IRReturn)})},
- args: [],
- source: "scope\x0a\x09^ scope ifNil: [ self parent scope ]",
- messageSends: ["ifNil:", "scope", "parent"],
- referencedClasses: []
- }),
- globals.IRReturn);
- smalltalk.addClass('IRBlockReturn', globals.IRReturn, [], 'Compiler-IR');
- globals.IRBlockReturn.comment="Smalltalk blocks return their last statement. I am a implicit block return instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRBlockReturn_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRBlockReturn)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRBlockReturn: self",
- messageSends: ["visitIRBlockReturn:"],
- referencedClasses: []
- }),
- globals.IRBlockReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isBlockReturn\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRBlockReturn);
- smalltalk.addClass('IRNonLocalReturn', globals.IRReturn, [], 'Compiler-IR');
- globals.IRNonLocalReturn.comment="I am a non local return instruction.\x0aNon local returns are handled using a try/catch JavaScript statement.\x0a\x0aSee `IRNonLocalReturnHandling` class.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRNonLocalReturn_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRNonLocalReturn)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRNonLocalReturn: self",
- messageSends: ["visitIRNonLocalReturn:"],
- referencedClasses: []
- }),
- globals.IRNonLocalReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isLocalReturn\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRNonLocalReturn);
- smalltalk.addClass('IRTempDeclaration', globals.IRScopedInstruction, ['name'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRTempDeclaration_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRTempDeclaration)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRTempDeclaration: self",
- messageSends: ["visitIRTempDeclaration:"],
- referencedClasses: []
- }),
- globals.IRTempDeclaration);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isTempDeclaration",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isTempDeclaration\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRTempDeclaration);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@name"];
- return $1;
- },
- args: [],
- source: "name\x0a\x09^ name",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRTempDeclaration);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@name"]=aString;
- return self},
- args: ["aString"],
- source: "name: aString\x0a\x09name := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRTempDeclaration);
- smalltalk.addClass('IRSend', globals.IRInstruction, ['selector', 'classSend', 'index'], 'Compiler-IR');
- globals.IRSend.comment="I am a message send instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRSend_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRSend)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRSend: self",
- messageSends: ["visitIRSend:"],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classSend",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@classSend"];
- return $1;
- },
- args: [],
- source: "classSend\x0a\x09^ classSend",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classSend:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@classSend"]=aClass;
- return self},
- args: ["aClass"],
- source: "classSend: aClass\x0a\x09classSend := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@index"];
- return $1;
- },
- args: [],
- source: "index\x0a\x09^ index",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@index"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "index: anInteger\x0a\x09index := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSend",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSend\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSend);
- smalltalk.addClass('IRSequence', globals.IRInstruction, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRSequence_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRSequence)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRSequence: self",
- messageSends: ["visitIRSequence:"],
- referencedClasses: []
- }),
- globals.IRSequence);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSequence",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSequence\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSequence);
- smalltalk.addClass('IRBlockSequence', globals.IRSequence, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRBlockSequence_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRBlockSequence)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRBlockSequence: self",
- messageSends: ["visitIRBlockSequence:"],
- referencedClasses: []
- }),
- globals.IRBlockSequence);
- smalltalk.addClass('IRValue', globals.IRInstruction, ['value'], 'Compiler-IR');
- globals.IRValue.comment="I am the simplest possible instruction. I represent a value.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRValue_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRValue)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRValue: self",
- messageSends: ["visitIRValue:"],
- referencedClasses: []
- }),
- globals.IRValue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "needsBoxingAsReceiver",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "needsBoxingAsReceiver\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRValue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@value"];
- return $1;
- },
- args: [],
- source: "value\x0a\x09^ value",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRValue);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@value"]=aString;
- return self},
- args: ["aString"],
- source: "value: aString\x0a\x09value := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRValue);
- smalltalk.addClass('IRVariable', globals.IRInstruction, ['variable'], 'Compiler-IR');
- globals.IRVariable.comment="I am a variable instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRVariable_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRVariable)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRVariable: self",
- messageSends: ["visitIRVariable:"],
- referencedClasses: []
- }),
- globals.IRVariable);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isVariable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRVariable);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "needsBoxingAsReceiver",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._variable())._isPseudoVar())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"needsBoxingAsReceiver",{},globals.IRVariable)})},
- args: [],
- source: "needsBoxingAsReceiver\x0a\x09^ self variable isPseudoVar not",
- messageSends: ["not", "isPseudoVar", "variable"],
- referencedClasses: []
- }),
- globals.IRVariable);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variable",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@variable"];
- return $1;
- },
- args: [],
- source: "variable\x0a\x09^ variable",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRVariable);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "variable:",
- protocol: 'accessing',
- fn: function (aScopeVariable){
- var self=this;
- self["@variable"]=aScopeVariable;
- return self},
- args: ["aScopeVariable"],
- source: "variable: aScopeVariable\x0a\x09variable := aScopeVariable",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRVariable);
- smalltalk.addClass('IRVerbatim', globals.IRInstruction, ['source'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRVerbatim_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRVerbatim)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRVerbatim: self",
- messageSends: ["visitIRVerbatim:"],
- referencedClasses: []
- }),
- globals.IRVerbatim);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@source"];
- return $1;
- },
- args: [],
- source: "source\x0a\x09^ source",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRVerbatim);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self},
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRVerbatim);
- smalltalk.addClass('IRVisitor', globals.Object, [], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visit:",
- protocol: 'visiting',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(anIRInstruction)._accept_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visit:",{anIRInstruction:anIRInstruction},globals.IRVisitor)})},
- args: ["anIRInstruction"],
- source: "visit: anIRInstruction\x0a\x09^ anIRInstruction accept: self",
- messageSends: ["accept:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRAssignment:",
- protocol: 'visiting',
- fn: function (anIRAssignment){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRAssignment);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},globals.IRVisitor)})},
- args: ["anIRAssignment"],
- source: "visitIRAssignment: anIRAssignment\x0a\x09^ self visitIRInstruction: anIRAssignment",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRBlockReturn:",
- protocol: 'visiting',
- fn: function (anIRBlockReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRReturn_(anIRBlockReturn);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRBlockReturn:",{anIRBlockReturn:anIRBlockReturn},globals.IRVisitor)})},
- args: ["anIRBlockReturn"],
- source: "visitIRBlockReturn: anIRBlockReturn\x0a\x09^ self visitIRReturn: anIRBlockReturn",
- messageSends: ["visitIRReturn:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRBlockSequence:",
- protocol: 'visiting',
- fn: function (anIRBlockSequence){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRSequence_(anIRBlockSequence);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRBlockSequence:",{anIRBlockSequence:anIRBlockSequence},globals.IRVisitor)})},
- args: ["anIRBlockSequence"],
- source: "visitIRBlockSequence: anIRBlockSequence\x0a\x09^ self visitIRSequence: anIRBlockSequence",
- messageSends: ["visitIRSequence:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRClosure:",
- protocol: 'visiting',
- fn: function (anIRClosure){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRClosure);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRClosure:",{anIRClosure:anIRClosure},globals.IRVisitor)})},
- args: ["anIRClosure"],
- source: "visitIRClosure: anIRClosure\x0a\x09^ self visitIRInstruction: anIRClosure",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRDynamicArray:",
- protocol: 'visiting',
- fn: function (anIRDynamicArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRDynamicArray);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRDynamicArray:",{anIRDynamicArray:anIRDynamicArray},globals.IRVisitor)})},
- args: ["anIRDynamicArray"],
- source: "visitIRDynamicArray: anIRDynamicArray\x0a\x09^ self visitIRInstruction: anIRDynamicArray",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRDynamicDictionary:",
- protocol: 'visiting',
- fn: function (anIRDynamicDictionary){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRDynamicDictionary);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRDynamicDictionary:",{anIRDynamicDictionary:anIRDynamicDictionary},globals.IRVisitor)})},
- args: ["anIRDynamicDictionary"],
- source: "visitIRDynamicDictionary: anIRDynamicDictionary\x0a\x09^ self visitIRInstruction: anIRDynamicDictionary",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedClosure:",
- protocol: 'visiting',
- fn: function (anIRInlinedClosure){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRClosure_(anIRInlinedClosure);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},globals.IRVisitor)})},
- args: ["anIRInlinedClosure"],
- source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09^ self visitIRClosure: anIRInlinedClosure",
- messageSends: ["visitIRClosure:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedSequence:",
- protocol: 'visiting',
- fn: function (anIRInlinedSequence){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRSequence_(anIRInlinedSequence);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},globals.IRVisitor)})},
- args: ["anIRInlinedSequence"],
- source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09^ self visitIRSequence: anIRInlinedSequence",
- messageSends: ["visitIRSequence:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInstruction:",
- protocol: 'visiting',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(anIRInstruction)._instructions())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return anIRInstruction;
- }, function($ctx1) {$ctx1.fill(self,"visitIRInstruction:",{anIRInstruction:anIRInstruction},globals.IRVisitor)})},
- args: ["anIRInstruction"],
- source: "visitIRInstruction: anIRInstruction\x0a\x09anIRInstruction instructions do: [ :each | self visit: each ].\x0a\x09^ anIRInstruction",
- messageSends: ["do:", "instructions", "visit:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRMethod:",
- protocol: 'visiting',
- fn: function (anIRMethod){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRMethod);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRMethod:",{anIRMethod:anIRMethod},globals.IRVisitor)})},
- args: ["anIRMethod"],
- source: "visitIRMethod: anIRMethod\x0a\x09^ self visitIRInstruction: anIRMethod",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRNonLocalReturn:",
- protocol: 'visiting',
- fn: function (anIRNonLocalReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRNonLocalReturn);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},globals.IRVisitor)})},
- args: ["anIRNonLocalReturn"],
- source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ self visitIRInstruction: anIRNonLocalReturn",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRNonLocalReturnHandling:",
- protocol: 'visiting',
- fn: function (anIRNonLocalReturnHandling){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRNonLocalReturnHandling);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturnHandling:",{anIRNonLocalReturnHandling:anIRNonLocalReturnHandling},globals.IRVisitor)})},
- args: ["anIRNonLocalReturnHandling"],
- source: "visitIRNonLocalReturnHandling: anIRNonLocalReturnHandling\x0a\x09^ self visitIRInstruction: anIRNonLocalReturnHandling",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRReturn:",
- protocol: 'visiting',
- fn: function (anIRReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRReturn);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},globals.IRVisitor)})},
- args: ["anIRReturn"],
- source: "visitIRReturn: anIRReturn\x0a\x09^ self visitIRInstruction: anIRReturn",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRSend:",
- protocol: 'visiting',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRSend);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},globals.IRVisitor)})},
- args: ["anIRSend"],
- source: "visitIRSend: anIRSend\x0a\x09^ self visitIRInstruction: anIRSend",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRSequence:",
- protocol: 'visiting',
- fn: function (anIRSequence){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRSequence);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRSequence:",{anIRSequence:anIRSequence},globals.IRVisitor)})},
- args: ["anIRSequence"],
- source: "visitIRSequence: anIRSequence\x0a\x09^ self visitIRInstruction: anIRSequence",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRTempDeclaration:",
- protocol: 'visiting',
- fn: function (anIRTempDeclaration){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRTempDeclaration);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRTempDeclaration:",{anIRTempDeclaration:anIRTempDeclaration},globals.IRVisitor)})},
- args: ["anIRTempDeclaration"],
- source: "visitIRTempDeclaration: anIRTempDeclaration\x0a\x09^ self visitIRInstruction: anIRTempDeclaration",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRValue:",
- protocol: 'visiting',
- fn: function (anIRValue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRValue);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRValue:",{anIRValue:anIRValue},globals.IRVisitor)})},
- args: ["anIRValue"],
- source: "visitIRValue: anIRValue\x0a\x09^ self visitIRInstruction: anIRValue",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRVariable:",
- protocol: 'visiting',
- fn: function (anIRVariable){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRVariable);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRVariable:",{anIRVariable:anIRVariable},globals.IRVisitor)})},
- args: ["anIRVariable"],
- source: "visitIRVariable: anIRVariable\x0a\x09^ self visitIRInstruction: anIRVariable",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRVerbatim:",
- protocol: 'visiting',
- fn: function (anIRVerbatim){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._visitIRInstruction_(anIRVerbatim);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRVerbatim:",{anIRVerbatim:anIRVerbatim},globals.IRVisitor)})},
- args: ["anIRVerbatim"],
- source: "visitIRVerbatim: anIRVerbatim\x0a\x09^ self visitIRInstruction: anIRVerbatim",
- messageSends: ["visitIRInstruction:"],
- referencedClasses: []
- }),
- globals.IRVisitor);
- smalltalk.addClass('IRJSTranslator', globals.IRVisitor, ['stream', 'currentClass'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "contents",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._stream())._contents();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"contents",{},globals.IRJSTranslator)})},
- args: [],
- source: "contents\x0a\x09^ self stream contents",
- messageSends: ["contents", "stream"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentClass"];
- return $1;
- },
- args: [],
- source: "currentClass\x0a\x09^ currentClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@currentClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "currentClass: aClass\x0a\x09currentClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $JSStream(){return globals.JSStream||(typeof JSStream=="undefined"?nil:JSStream)}
- return smalltalk.withContext(function($ctx1) {
- globals.IRJSTranslator.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@stream"]=_st($JSStream())._new();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.IRJSTranslator)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09stream := JSStream new.",
- messageSends: ["initialize", "new"],
- referencedClasses: ["JSStream"]
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stream",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@stream"];
- return $1;
- },
- args: [],
- source: "stream\x0a\x09^ stream",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stream:",
- protocol: 'accessing',
- fn: function (aStream){
- var self=this;
- self["@stream"]=aStream;
- return self},
- args: ["aStream"],
- source: "stream: aStream\x0a\x09stream := aStream",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRAssignment:",
- protocol: 'visiting',
- fn: function (anIRAssignment){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(anIRAssignment)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- $1=_st($2)._first();
- self._visit_($1);
- $ctx1.sendIdx["visit:"]=1;
- _st(self._stream())._nextPutAssignment();
- self._visit_(_st(_st(anIRAssignment)._instructions())._last());
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},globals.IRJSTranslator)})},
- args: ["anIRAssignment"],
- source: "visitIRAssignment: anIRAssignment\x0a\x09self visit: anIRAssignment instructions first.\x0a\x09self stream nextPutAssignment.\x0a\x09self visit: anIRAssignment instructions last.",
- messageSends: ["visit:", "first", "instructions", "nextPutAssignment", "stream", "last"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRClosure:",
- protocol: 'visiting',
- fn: function (anIRClosure){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutClosureWith_arguments_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutVars_(_st(_st(anIRClosure)._tempDeclarations())._collect_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(_st(each)._name())._asVariableName();
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})})));
- return _st(self._stream())._nextPutBlockContextFor_during_(anIRClosure,(function(){
- return smalltalk.withContext(function($ctx3) {
- return globals.IRJSTranslator.superclass.fn.prototype._visitIRClosure_.apply(_st(self), [anIRClosure]);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),_st(anIRClosure)._arguments());
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRClosure:",{anIRClosure:anIRClosure},globals.IRJSTranslator)})},
- args: ["anIRClosure"],
- source: "visitIRClosure: anIRClosure\x0a\x09self stream\x0a\x09\x09nextPutClosureWith: [\x0a\x09\x09\x09self stream nextPutVars: (anIRClosure tempDeclarations collect: [ :each |\x0a\x09\x09\x09\x09\x09each name asVariableName ]).\x0a\x09\x09\x09self stream\x0a\x09\x09\x09\x09nextPutBlockContextFor: anIRClosure\x0a\x09\x09\x09\x09during: [ super visitIRClosure: anIRClosure ] ]\x0a\x09\x09arguments: anIRClosure arguments",
- messageSends: ["nextPutClosureWith:arguments:", "stream", "nextPutVars:", "collect:", "tempDeclarations", "asVariableName", "name", "nextPutBlockContextFor:during:", "visitIRClosure:", "arguments"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRDynamicArray:",
- protocol: 'visiting',
- fn: function (anIRDynamicArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutAll_("[");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(_st(anIRDynamicArray)._instructions())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._stream())._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(self["@stream"])._nextPutAll_("]");
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRDynamicArray:",{anIRDynamicArray:anIRDynamicArray},globals.IRJSTranslator)})},
- args: ["anIRDynamicArray"],
- source: "visitIRDynamicArray: anIRDynamicArray\x0a\x09self stream nextPutAll: '['.\x0a\x09anIRDynamicArray instructions\x0a\x09\x09do: [ :each | self visit: each ]\x0a\x09\x09separatedBy: [ self stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: ']'",
- messageSends: ["nextPutAll:", "stream", "do:separatedBy:", "instructions", "visit:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRDynamicDictionary:",
- protocol: 'visiting',
- fn: function (anIRDynamicDictionary){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutAll_("globals.HashedCollection._newFromPairs_([");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(_st(anIRDynamicDictionary)._instructions())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- return _st($2)._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(self._stream())._nextPutAll_("])");
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRDynamicDictionary:",{anIRDynamicDictionary:anIRDynamicDictionary},globals.IRJSTranslator)})},
- args: ["anIRDynamicDictionary"],
- source: "visitIRDynamicDictionary: anIRDynamicDictionary\x0a\x09self stream nextPutAll: 'globals.HashedCollection._newFromPairs_(['.\x0a\x09\x09anIRDynamicDictionary instructions\x0a\x09\x09\x09do: [ :each | self visit: each ]\x0a\x09\x09\x09separatedBy: [ self stream nextPutAll: ',' ].\x0a\x09self stream nextPutAll: '])'",
- messageSends: ["nextPutAll:", "stream", "do:separatedBy:", "instructions", "visit:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRMethod:",
- protocol: 'visiting',
- fn: function (anIRMethod){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$6,$8,$7,$9,$10;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutMethodDeclaration_with_(anIRMethod,(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- return _st($2)._nextPutFunctionWith_arguments_((function(){
- return smalltalk.withContext(function($ctx3) {
- $3=self._stream();
- $ctx3.sendIdx["stream"]=3;
- $4=_st(_st(anIRMethod)._tempDeclarations())._collect_((function(each){
- return smalltalk.withContext(function($ctx4) {
- return _st(_st(each)._name())._asVariableName();
- }, function($ctx4) {$ctx4.fillBlock({each:each},$ctx3,3)})}));
- $ctx3.sendIdx["collect:"]=1;
- _st($3)._nextPutVars_($4);
- $ctx3.sendIdx["nextPutVars:"]=1;
- _st(_st(anIRMethod)._classReferences())._do_((function(each){
- return smalltalk.withContext(function($ctx4) {
- $5=self._stream();
- $ctx4.sendIdx["stream"]=4;
- return _st($5)._nextPutClassRefFunction_(each);
- }, function($ctx4) {$ctx4.fillBlock({each:each},$ctx3,4)})}));
- $6=self._stream();
- $ctx3.sendIdx["stream"]=5;
- return _st($6)._nextPutContextFor_during_(anIRMethod,(function(){
- return smalltalk.withContext(function($ctx4) {
- $8=_st(anIRMethod)._internalVariables();
- $ctx4.sendIdx["internalVariables"]=1;
- $7=_st($8)._notEmpty();
- if(smalltalk.assert($7)){
- $9=self._stream();
- $ctx4.sendIdx["stream"]=6;
- _st($9)._nextPutVars_(_st(_st(_st(anIRMethod)._internalVariables())._asArray())._collect_((function(each){
- return smalltalk.withContext(function($ctx5) {
- return _st(_st(each)._variable())._alias();
- }, function($ctx5) {$ctx5.fillBlock({each:each},$ctx4,7)})})));
- };
- $10=_st(_st(anIRMethod)._scope())._hasNonLocalReturn();
- if(smalltalk.assert($10)){
- return _st(self._stream())._nextPutNonLocalReturnHandlingWith_((function(){
- return smalltalk.withContext(function($ctx5) {
- return globals.IRJSTranslator.superclass.fn.prototype._visitIRMethod_.apply(_st(self), [anIRMethod]);
- $ctx5.sendIdx["visitIRMethod:"]=1;
- }, function($ctx5) {$ctx5.fillBlock({},$ctx4,9)})}));
- } else {
- return globals.IRJSTranslator.superclass.fn.prototype._visitIRMethod_.apply(_st(self), [anIRMethod]);
- };
- }, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)})}));
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}),_st(anIRMethod)._arguments());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRMethod:",{anIRMethod:anIRMethod},globals.IRJSTranslator)})},
- args: ["anIRMethod"],
- source: "visitIRMethod: anIRMethod\x0a\x0a\x09self stream\x0a\x09\x09nextPutMethodDeclaration: anIRMethod\x0a\x09\x09with: [ self stream\x0a\x09\x09\x09nextPutFunctionWith: [\x0a\x09\x09\x09\x09self stream nextPutVars: (anIRMethod tempDeclarations collect: [ :each |\x0a\x09\x09\x09\x09\x09each name asVariableName ]).\x0a\x09\x09\x09\x09anIRMethod classReferences do: [ :each | self stream nextPutClassRefFunction: each ].\x0a\x09\x09\x09\x09self stream nextPutContextFor: anIRMethod during: [\x0a\x09\x09\x09\x09anIRMethod internalVariables notEmpty ifTrue: [\x0a\x09\x09\x09\x09\x09self stream nextPutVars: (anIRMethod internalVariables asArray collect: [ :each |\x0a\x09\x09\x09\x09\x09\x09each variable alias ]) ].\x0a\x09\x09\x09\x09anIRMethod scope hasNonLocalReturn\x0a\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09self stream nextPutNonLocalReturnHandlingWith: [\x0a\x09\x09\x09\x09\x09\x09\x09super visitIRMethod: anIRMethod ] ]\x0a\x09\x09\x09\x09\x09ifFalse: [ super visitIRMethod: anIRMethod ] ]]\x0a\x09\x09\x09arguments: anIRMethod arguments ]",
- messageSends: ["nextPutMethodDeclaration:with:", "stream", "nextPutFunctionWith:arguments:", "nextPutVars:", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "classReferences", "nextPutClassRefFunction:", "nextPutContextFor:during:", "ifTrue:", "notEmpty", "internalVariables", "asArray", "alias", "variable", "ifTrue:ifFalse:", "hasNonLocalReturn", "scope", "nextPutNonLocalReturnHandlingWith:", "visitIRMethod:", "arguments"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRNonLocalReturn:",
- protocol: 'visiting',
- fn: function (anIRNonLocalReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._stream())._nextPutNonLocalReturnWith_((function(){
- return smalltalk.withContext(function($ctx2) {
- return globals.IRJSTranslator.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},globals.IRJSTranslator)})},
- args: ["anIRNonLocalReturn"],
- source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09self stream nextPutNonLocalReturnWith: [\x0a\x09\x09super visitIRNonLocalReturn: anIRNonLocalReturn ]",
- messageSends: ["nextPutNonLocalReturnWith:", "stream", "visitIRNonLocalReturn:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRReturn:",
- protocol: 'visiting',
- fn: function (anIRReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._stream())._nextPutReturnWith_((function(){
- return smalltalk.withContext(function($ctx2) {
- return globals.IRJSTranslator.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},globals.IRJSTranslator)})},
- args: ["anIRReturn"],
- source: "visitIRReturn: anIRReturn\x0a\x09self stream nextPutReturnWith: [\x0a\x09\x09super visitIRReturn: anIRReturn ]",
- messageSends: ["nextPutReturnWith:", "stream", "visitIRReturn:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRSend:",
- protocol: 'visiting',
- fn: function (anIRSend){
- var self=this;
- var sends;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- sends=_st(_st(_st(_st(anIRSend)._method())._sendIndexes())._at_(_st(anIRSend)._selector()))._size();
- $1=_st(anIRSend)._classSend();
- if(($receiver = $1) == nil || $receiver == null){
- self._visitSend_(anIRSend);
- } else {
- self._visitSuperSend_(anIRSend);
- };
- $2=_st(_st(sends).__gt((1)))._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(anIRSend)._index()).__lt(sends);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- if(smalltalk.assert($2)){
- _st(self._stream())._nextPutSendIndexFor_(anIRSend);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend,sends:sends},globals.IRJSTranslator)})},
- args: ["anIRSend"],
- source: "visitIRSend: anIRSend\x0a\x09| sends |\x0a\x09sends := (anIRSend method sendIndexes at: anIRSend selector) size.\x0a\x09\x0a\x09anIRSend classSend\x0a\x09\x09ifNil: [ self visitSend: anIRSend ]\x0a\x09\x09ifNotNil: [ self visitSuperSend: anIRSend ].\x0a\x09\x09\x0a\x09(sends > 1 and: [ anIRSend index < sends ])\x0a\x09\x09ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]",
- messageSends: ["size", "at:", "sendIndexes", "method", "selector", "ifNil:ifNotNil:", "classSend", "visitSend:", "visitSuperSend:", "ifTrue:", "and:", ">", "<", "index", "nextPutSendIndexFor:", "stream"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRSequence:",
- protocol: 'visiting',
- fn: function (anIRSequence){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutSequenceWith_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(anIRSequence)._instructions())._do_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(self._stream())._nextPutStatementWith_(self._visit_(each));
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRSequence:",{anIRSequence:anIRSequence},globals.IRJSTranslator)})},
- args: ["anIRSequence"],
- source: "visitIRSequence: anIRSequence\x0a\x09self stream nextPutSequenceWith: [\x0a\x09\x09anIRSequence instructions do: [ :each |\x0a\x09\x09\x09self stream nextPutStatementWith: (self visit: each) ] ]",
- messageSends: ["nextPutSequenceWith:", "stream", "do:", "instructions", "nextPutStatementWith:", "visit:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRTempDeclaration:",
- protocol: 'visiting',
- fn: function (anIRTempDeclaration){
- var self=this;
- return self},
- args: ["anIRTempDeclaration"],
- source: "visitIRTempDeclaration: anIRTempDeclaration\x0a\x09\x22self stream\x0a\x09\x09nextPutAll: 'var ', anIRTempDeclaration name asVariableName, ';';\x0a\x09\x09lf\x22",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRValue:",
- protocol: 'visiting',
- fn: function (anIRValue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._stream())._nextPutAll_(_st(_st(anIRValue)._value())._asJavascript());
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRValue:",{anIRValue:anIRValue},globals.IRJSTranslator)})},
- args: ["anIRValue"],
- source: "visitIRValue: anIRValue\x0a\x09self stream nextPutAll: anIRValue value asJavascript",
- messageSends: ["nextPutAll:", "stream", "asJavascript", "value"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRVariable:",
- protocol: 'visiting',
- fn: function (anIRVariable){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4;
- $3=_st(anIRVariable)._variable();
- $ctx1.sendIdx["variable"]=1;
- $2=_st($3)._name();
- $1=_st($2).__eq("thisContext");
- if(smalltalk.assert($1)){
- $4=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($4)._nextPutAll_("smalltalk.getThisContext()");
- $ctx1.sendIdx["nextPutAll:"]=1;
- } else {
- _st(self._stream())._nextPutAll_(_st(_st(anIRVariable)._variable())._alias());
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRVariable:",{anIRVariable:anIRVariable},globals.IRJSTranslator)})},
- args: ["anIRVariable"],
- source: "visitIRVariable: anIRVariable\x0a\x09anIRVariable variable name = 'thisContext'\x0a\x09\x09ifTrue: [ self stream nextPutAll: 'smalltalk.getThisContext()' ]\x0a\x09\x09ifFalse: [ self stream nextPutAll: anIRVariable variable alias ]",
- messageSends: ["ifTrue:ifFalse:", "=", "name", "variable", "nextPutAll:", "stream", "alias"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRVerbatim:",
- protocol: 'visiting',
- fn: function (anIRVerbatim){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutStatementWith_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._stream())._nextPutAll_(_st(anIRVerbatim)._source());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRVerbatim:",{anIRVerbatim:anIRVerbatim},globals.IRJSTranslator)})},
- args: ["anIRVerbatim"],
- source: "visitIRVerbatim: anIRVerbatim\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self stream nextPutAll: anIRVerbatim source ]",
- messageSends: ["nextPutStatementWith:", "stream", "nextPutAll:", "source"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReceiver:",
- protocol: 'visiting',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st(anIRInstruction)._needsBoxingAsReceiver();
- if(! smalltalk.assert($1)){
- $2=self._visit_(anIRInstruction);
- $ctx1.sendIdx["visit:"]=1;
- return $2;
- };
- $3=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($3)._nextPutAll_("_st(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- self._visit_(anIRInstruction);
- _st(self._stream())._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"visitReceiver:",{anIRInstruction:anIRInstruction},globals.IRJSTranslator)})},
- args: ["anIRInstruction"],
- source: "visitReceiver: anIRInstruction\x0a\x09anIRInstruction needsBoxingAsReceiver ifFalse: [ ^ self visit: anIRInstruction ].\x0a\x09\x0a\x09self stream nextPutAll: '_st('.\x0a\x09self visit: anIRInstruction.\x0a\x09self stream nextPutAll: ')'",
- messageSends: ["ifFalse:", "needsBoxingAsReceiver", "visit:", "nextPutAll:", "stream"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSend:",
- protocol: 'visiting',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4,$5;
- $2=_st(anIRSend)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- $1=_st($2)._first();
- self._visitReceiver_($1);
- $3=self._stream();
- $ctx1.sendIdx["stream"]=1;
- $4=_st(".".__comma(_st(_st(anIRSend)._selector())._asSelector())).__comma("(");
- $ctx1.sendIdx[","]=1;
- _st($3)._nextPutAll_($4);
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(_st(_st(anIRSend)._instructions())._allButFirst())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- $5=self._stream();
- $ctx2.sendIdx["stream"]=2;
- return _st($5)._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(self._stream())._nextPutAll_(")");
- return self}, function($ctx1) {$ctx1.fill(self,"visitSend:",{anIRSend:anIRSend},globals.IRJSTranslator)})},
- args: ["anIRSend"],
- source: "visitSend: anIRSend\x0a\x09self visitReceiver: anIRSend instructions first.\x0a\x09self stream nextPutAll: '.', anIRSend selector asSelector, '('.\x0a\x09anIRSend instructions allButFirst\x0a\x09\x09do: [ :each | self visit: each ]\x0a\x09\x09separatedBy: [ self stream nextPutAll: ',' ].\x0a\x09self stream nextPutAll: ')'",
- messageSends: ["visitReceiver:", "first", "instructions", "nextPutAll:", "stream", ",", "asSelector", "selector", "do:separatedBy:", "allButFirst", "visit:"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSuperSend:",
- protocol: 'visiting',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$5,$6;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutAll_(_st(self._currentClass())._asJavascript());
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st($1)._nextPutAll_(".superclass.fn.prototype.");
- $ctx1.sendIdx["nextPutAll:"]=2;
- _st($1)._nextPutAll_(_st(_st(_st(anIRSend)._selector())._asSelector()).__comma(".apply("));
- $ctx1.sendIdx["nextPutAll:"]=3;
- $2=_st($1)._nextPutAll_("_st(");
- $ctx1.sendIdx["nextPutAll:"]=4;
- $4=_st(anIRSend)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx1.sendIdx["visit:"]=1;
- $5=self._stream();
- $ctx1.sendIdx["stream"]=2;
- _st($5)._nextPutAll_("), [");
- $ctx1.sendIdx["nextPutAll:"]=5;
- _st(_st(_st(anIRSend)._instructions())._allButFirst())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- $6=self._stream();
- $ctx2.sendIdx["stream"]=3;
- return _st($6)._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=6;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- _st(self._stream())._nextPutAll_("])");
- return self}, function($ctx1) {$ctx1.fill(self,"visitSuperSend:",{anIRSend:anIRSend},globals.IRJSTranslator)})},
- args: ["anIRSend"],
- source: "visitSuperSend: anIRSend\x0a\x09self stream\x0a\x09\x09nextPutAll: self currentClass asJavascript;\x0a\x09\x09nextPutAll: '.superclass.fn.prototype.';\x0a\x09\x09nextPutAll: anIRSend selector asSelector, '.apply(';\x0a\x09\x09nextPutAll: '_st('.\x0a\x09self visit: anIRSend instructions first.\x0a\x09self stream nextPutAll: '), ['.\x0a\x09anIRSend instructions allButFirst\x0a\x09\x09do: [ :each | self visit: each ]\x0a\x09\x09separatedBy: [ self stream nextPutAll: ',' ].\x0a\x09self stream nextPutAll: '])'",
- messageSends: ["nextPutAll:", "stream", "asJavascript", "currentClass", ",", "asSelector", "selector", "visit:", "first", "instructions", "do:separatedBy:", "allButFirst"],
- referencedClasses: []
- }),
- globals.IRJSTranslator);
- smalltalk.addClass('JSStream', globals.Object, ['stream'], 'Compiler-IR');
- smalltalk.addMethod(
- smalltalk.method({
- selector: "contents",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@stream"])._contents();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"contents",{},globals.JSStream)})},
- args: [],
- source: "contents\x0a\x09^ stream contents",
- messageSends: ["contents"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.JSStream.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@stream"]=""._writeStream();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.JSStream)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09stream := '' writeStream.",
- messageSends: ["initialize", "writeStream"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lf",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._lf();
- return self}, function($ctx1) {$ctx1.fill(self,"lf",{},globals.JSStream)})},
- args: [],
- source: "lf\x0a\x09stream lf",
- messageSends: ["lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPut:",
- protocol: 'streaming',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._nextPut_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{aString:aString},globals.JSStream)})},
- args: ["aString"],
- source: "nextPut: aString\x0a\x09stream nextPut: aString",
- messageSends: ["nextPut:"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutAll:",
- protocol: 'streaming',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._nextPutAll_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aString:aString},globals.JSStream)})},
- args: ["aString"],
- source: "nextPutAll: aString\x0a\x09stream nextPutAll: aString",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutAssignment",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._nextPutAll_("=");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutAssignment",{},globals.JSStream)})},
- args: [],
- source: "nextPutAssignment\x0a\x09stream nextPutAll: '='",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutBlockContextFor:during:",
- protocol: 'streaming',
- fn: function (anIRClosure,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$6,$5,$4,$3,$7,$11,$10,$9,$8,$15,$14,$13,$12,$16,$17,$24,$23,$22,$21,$20,$19,$18;
- $1=_st(anIRClosure)._requiresSmalltalkContext();
- if(! smalltalk.assert($1)){
- $2=_st(aBlock)._value();
- $ctx1.sendIdx["value"]=1;
- return $2;
- };
- $6=_st(anIRClosure)._scope();
- $ctx1.sendIdx["scope"]=1;
- $5=_st($6)._alias();
- $ctx1.sendIdx["alias"]=1;
- $4="return smalltalk.withContext(function(".__comma($5);
- $ctx1.sendIdx[","]=2;
- $3=_st($4).__comma(") {");
- $ctx1.sendIdx[","]=1;
- self._nextPutAll_($3);
- $ctx1.sendIdx["nextPutAll:"]=1;
- $7=self._lf();
- _st(aBlock)._value();
- $11=_st(anIRClosure)._scope();
- $ctx1.sendIdx["scope"]=2;
- $10=_st($11)._alias();
- $ctx1.sendIdx["alias"]=2;
- $9="}, function(".__comma($10);
- $ctx1.sendIdx[","]=4;
- $8=_st($9).__comma(") {");
- $ctx1.sendIdx[","]=3;
- self._nextPutAll_($8);
- $ctx1.sendIdx["nextPutAll:"]=2;
- $15=_st(anIRClosure)._scope();
- $ctx1.sendIdx["scope"]=3;
- $14=_st($15)._alias();
- $ctx1.sendIdx["alias"]=3;
- $13=_st($14).__comma(".fillBlock({");
- $ctx1.sendIdx[","]=5;
- $12=self._nextPutAll_($13);
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st(_st(anIRClosure)._locals())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $16=_st(each)._asVariableName();
- $ctx2.sendIdx["asVariableName"]=1;
- self._nextPutAll_($16);
- $ctx2.sendIdx["nextPutAll:"]=4;
- self._nextPutAll_(":");
- $ctx2.sendIdx["nextPutAll:"]=5;
- $17=self._nextPutAll_(_st(each)._asVariableName());
- $ctx2.sendIdx["nextPutAll:"]=6;
- return $17;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=7;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- self._nextPutAll_("},");
- $ctx1.sendIdx["nextPutAll:"]=8;
- $24=_st(anIRClosure)._scope();
- $ctx1.sendIdx["scope"]=4;
- $23=_st($24)._outerScope();
- $22=_st($23)._alias();
- $21=_st($22).__comma(",");
- $20=_st($21).__comma(_st(_st(_st(anIRClosure)._scope())._blockIndex())._asString());
- $ctx1.sendIdx[","]=7;
- $19=_st($20).__comma(")})");
- $ctx1.sendIdx[","]=6;
- $18=self._nextPutAll_($19);
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutBlockContextFor:during:",{anIRClosure:anIRClosure,aBlock:aBlock},globals.JSStream)})},
- args: ["anIRClosure", "aBlock"],
- source: "nextPutBlockContextFor: anIRClosure during: aBlock\x0a\x09anIRClosure requiresSmalltalkContext ifFalse: [ ^ aBlock value ].\x0a\x09self\x0a\x09\x09nextPutAll: 'return smalltalk.withContext(function(', anIRClosure scope alias, ') {'; lf.\x0a\x09\x0a\x09aBlock value.\x0a\x09\x0a\x09self\x0a\x09\x09nextPutAll: '}, function(', anIRClosure scope alias, ') {';\x0a\x09\x09nextPutAll: anIRClosure scope alias, '.fillBlock({'.\x0a\x09\x0a\x09anIRClosure locals\x0a\x09\x09do: [ :each |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09nextPutAll: each asVariableName;\x0a\x09\x09\x09\x09nextPutAll: ':';\x0a\x09\x09\x09\x09nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ self nextPutAll: ',' ].\x0a\x09\x0a\x09self\x0a\x09\x09nextPutAll: '},';\x0a\x09\x09nextPutAll: anIRClosure scope outerScope alias, ',', anIRClosure scope blockIndex asString, ')})'",
- messageSends: ["ifFalse:", "requiresSmalltalkContext", "value", "nextPutAll:", ",", "alias", "scope", "lf", "do:separatedBy:", "locals", "asVariableName", "outerScope", "asString", "blockIndex"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutClassRefFunction:",
- protocol: 'streaming',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@stream"];
- _st($1)._nextPutAll_("function $");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st($1)._nextPutAll_(aString);
- $ctx1.sendIdx["nextPutAll:"]=2;
- _st($1)._nextPutAll_("(){return globals.");
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st($1)._nextPutAll_(aString);
- $ctx1.sendIdx["nextPutAll:"]=4;
- _st($1)._nextPutAll_("||(typeof ");
- $ctx1.sendIdx["nextPutAll:"]=5;
- _st($1)._nextPutAll_(aString);
- $ctx1.sendIdx["nextPutAll:"]=6;
- _st($1)._nextPutAll_("==\x22undefined\x22?nil:");
- $ctx1.sendIdx["nextPutAll:"]=7;
- _st($1)._nextPutAll_(aString);
- $ctx1.sendIdx["nextPutAll:"]=8;
- _st($1)._nextPutAll_(")}");
- $2=_st($1)._lf();
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutClassRefFunction:",{aString:aString},globals.JSStream)})},
- args: ["aString"],
- source: "nextPutClassRefFunction: aString\x0a\x09\x22Creates an inner function $aString into method and called as `$Foo()`whenever the global is accessed.\x0a\x09This ensures that undefined global access will answer `nil`\x22\x0a\x09\x0a\x09stream\x0a\x09\x09nextPutAll: 'function $';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '(){return globals.';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '||(typeof ';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '==\x22undefined\x22?nil:';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: ')}';\x0a\x09\x09lf",
- messageSends: ["nextPutAll:", "lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutClosureWith:arguments:",
- protocol: 'streaming',
- fn: function (aBlock,anArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- _st(self["@stream"])._nextPutAll_("(function(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(anArray)._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(_st(each)._asVariableName());
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPut_(",");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $1=self["@stream"];
- _st($1)._nextPutAll_("){");
- $ctx1.sendIdx["nextPutAll:"]=3;
- $2=_st($1)._lf();
- _st(aBlock)._value();
- _st(self["@stream"])._nextPutAll_("})");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutClosureWith:arguments:",{aBlock:aBlock,anArray:anArray},globals.JSStream)})},
- args: ["aBlock", "anArray"],
- source: "nextPutClosureWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: '(function('.\x0a\x09anArray\x0a\x09\x09do: [ :each | stream nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '})'",
- messageSends: ["nextPutAll:", "do:separatedBy:", "asVariableName", "nextPut:", "lf", "value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutContextFor:during:",
- protocol: 'streaming',
- fn: function (aMethod,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$6,$5,$4,$3,$7,$12,$11,$10,$9,$8,$16,$15,$14,$13,$17,$18,$19;
- $1=_st(aMethod)._requiresSmalltalkContext();
- if(! smalltalk.assert($1)){
- $2=_st(aBlock)._value();
- $ctx1.sendIdx["value"]=1;
- return $2;
- };
- $6=_st(aMethod)._scope();
- $ctx1.sendIdx["scope"]=1;
- $5=_st($6)._alias();
- $ctx1.sendIdx["alias"]=1;
- $4="return smalltalk.withContext(function(".__comma($5);
- $ctx1.sendIdx[","]=2;
- $3=_st($4).__comma(") { ");
- $ctx1.sendIdx[","]=1;
- self._nextPutAll_($3);
- $ctx1.sendIdx["nextPutAll:"]=1;
- $7=self._lf();
- _st(aBlock)._value();
- $12=_st(aMethod)._scope();
- $ctx1.sendIdx["scope"]=2;
- $11=_st($12)._alias();
- $ctx1.sendIdx["alias"]=2;
- $10="}, function(".__comma($11);
- $ctx1.sendIdx[","]=5;
- $9=_st($10).__comma(") {");
- $ctx1.sendIdx[","]=4;
- $8=_st($9).__comma(_st(_st(aMethod)._scope())._alias());
- $ctx1.sendIdx[","]=3;
- self._nextPutAll_($8);
- $ctx1.sendIdx["nextPutAll:"]=2;
- $16=_st(_st(aMethod)._selector())._asJavascript();
- $ctx1.sendIdx["asJavascript"]=1;
- $15=".fill(self,".__comma($16);
- $14=_st($15).__comma(",{");
- $ctx1.sendIdx[","]=6;
- $13=self._nextPutAll_($14);
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st(_st(aMethod)._locals())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $17=_st(each)._asVariableName();
- $ctx2.sendIdx["asVariableName"]=1;
- self._nextPutAll_($17);
- $ctx2.sendIdx["nextPutAll:"]=4;
- self._nextPutAll_(":");
- $ctx2.sendIdx["nextPutAll:"]=5;
- $18=self._nextPutAll_(_st(each)._asVariableName());
- $ctx2.sendIdx["nextPutAll:"]=6;
- return $18;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=7;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- self._nextPutAll_("},");
- $ctx1.sendIdx["nextPutAll:"]=8;
- self._nextPutAll_(_st(_st(aMethod)._theClass())._asJavascript());
- $ctx1.sendIdx["nextPutAll:"]=9;
- $19=self._nextPutAll_(")})");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutContextFor:during:",{aMethod:aMethod,aBlock:aBlock},globals.JSStream)})},
- args: ["aMethod", "aBlock"],
- source: "nextPutContextFor: aMethod during: aBlock\x0a\x09aMethod requiresSmalltalkContext ifFalse: [ ^ aBlock value ].\x0a\x09\x0a\x09self\x0a\x09\x09nextPutAll: 'return smalltalk.withContext(function(', aMethod scope alias, ') { '; lf.\x0a\x09aBlock value.\x0a\x09\x0a\x09self\x0a\x09\x09nextPutAll: '}, function(', aMethod scope alias, ') {', aMethod scope alias;\x0a\x09\x09nextPutAll: '.fill(self,', aMethod selector asJavascript, ',{'.\x0a\x0a\x09aMethod locals\x0a\x09\x09do: [ :each |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09nextPutAll: each asVariableName;\x0a\x09\x09\x09\x09nextPutAll: ':';\x0a\x09\x09\x09\x09nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ self nextPutAll: ',' ].\x0a\x09\x0a\x09self\x0a\x09\x09nextPutAll: '},';\x0a\x09\x09nextPutAll: aMethod theClass asJavascript;\x0a\x09\x09nextPutAll: ')})'",
- messageSends: ["ifFalse:", "requiresSmalltalkContext", "value", "nextPutAll:", ",", "alias", "scope", "lf", "asJavascript", "selector", "do:separatedBy:", "locals", "asVariableName", "theClass"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutFunctionWith:arguments:",
- protocol: 'streaming',
- fn: function (aBlock,anArray){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- _st(self["@stream"])._nextPutAll_("fn: function(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(anArray)._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(_st(each)._asVariableName());
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPut_(",");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $1=self["@stream"];
- _st($1)._nextPutAll_("){");
- $ctx1.sendIdx["nextPutAll:"]=3;
- $2=_st($1)._lf();
- $ctx1.sendIdx["lf"]=1;
- $3=self["@stream"];
- _st($3)._nextPutAll_("var self=this;");
- $ctx1.sendIdx["nextPutAll:"]=4;
- $4=_st($3)._lf();
- _st(aBlock)._value();
- _st(self["@stream"])._nextPutAll_("}");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutFunctionWith:arguments:",{aBlock:aBlock,anArray:anArray},globals.JSStream)})},
- args: ["aBlock", "anArray"],
- source: "nextPutFunctionWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: 'fn: function('.\x0a\x09anArray\x0a\x09\x09do: [ :each | stream nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09stream nextPutAll: 'var self=this;'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '}'",
- messageSends: ["nextPutAll:", "do:separatedBy:", "asVariableName", "nextPut:", "lf", "value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutIf:with:",
- protocol: 'streaming',
- fn: function (aBlock,anotherBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- _st(self["@stream"])._nextPutAll_("if(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aBlock)._value();
- $ctx1.sendIdx["value"]=1;
- $1=self["@stream"];
- _st($1)._nextPutAll_("){");
- $ctx1.sendIdx["nextPutAll:"]=2;
- $2=_st($1)._lf();
- _st(anotherBlock)._value();
- _st(self["@stream"])._nextPutAll_("}");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutIf:with:",{aBlock:aBlock,anotherBlock:anotherBlock},globals.JSStream)})},
- args: ["aBlock", "anotherBlock"],
- source: "nextPutIf: aBlock with: anotherBlock\x0a\x09stream nextPutAll: 'if('.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09anotherBlock value.\x0a\x09stream nextPutAll: '}'",
- messageSends: ["nextPutAll:", "value", "lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutIfElse:with:with:",
- protocol: 'streaming',
- fn: function (aBlock,ifBlock,elseBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- _st(self["@stream"])._nextPutAll_("if(");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aBlock)._value();
- $ctx1.sendIdx["value"]=1;
- $1=self["@stream"];
- _st($1)._nextPutAll_("){");
- $ctx1.sendIdx["nextPutAll:"]=2;
- $2=_st($1)._lf();
- $ctx1.sendIdx["lf"]=1;
- _st(ifBlock)._value();
- $ctx1.sendIdx["value"]=2;
- $3=self["@stream"];
- _st($3)._nextPutAll_("} else {");
- $ctx1.sendIdx["nextPutAll:"]=3;
- $4=_st($3)._lf();
- _st(elseBlock)._value();
- _st(self["@stream"])._nextPutAll_("}");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutIfElse:with:with:",{aBlock:aBlock,ifBlock:ifBlock,elseBlock:elseBlock},globals.JSStream)})},
- args: ["aBlock", "ifBlock", "elseBlock"],
- source: "nextPutIfElse: aBlock with: ifBlock with: elseBlock\x0a\x09stream nextPutAll: 'if('.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09ifBlock value.\x0a\x09stream nextPutAll: '} else {'; lf.\x0a\x09elseBlock value.\x0a\x09stream nextPutAll: '}'",
- messageSends: ["nextPutAll:", "value", "lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutMethodDeclaration:with:",
- protocol: 'streaming',
- fn: function (aMethod,aBlock){
- var self=this;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$5,$4,$3,$6,$9,$8,$7,$10,$11,$12,$15,$14,$13,$16,$19,$18,$17,$20,$23,$22,$21,$24,$25,$26;
- $1=self["@stream"];
- _st($1)._nextPutAll_("smalltalk.method({");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st($1)._lf();
- $ctx1.sendIdx["lf"]=1;
- $2=$1;
- $5=_st(_st(aMethod)._selector())._asJavascript();
- $ctx1.sendIdx["asJavascript"]=1;
- $4="selector: ".__comma($5);
- $ctx1.sendIdx[","]=2;
- $3=_st($4).__comma(",");
- $ctx1.sendIdx[","]=1;
- _st($2)._nextPutAll_($3);
- $ctx1.sendIdx["nextPutAll:"]=2;
- _st($1)._lf();
- $ctx1.sendIdx["lf"]=2;
- $6=$1;
- $9=_st(_st(aMethod)._source())._asJavascript();
- $ctx1.sendIdx["asJavascript"]=2;
- $8="source: ".__comma($9);
- $ctx1.sendIdx[","]=4;
- $7=_st($8).__comma(",");
- $ctx1.sendIdx[","]=3;
- _st($6)._nextPutAll_($7);
- $ctx1.sendIdx["nextPutAll:"]=3;
- $10=_st($1)._lf();
- $ctx1.sendIdx["lf"]=3;
- _st(aBlock)._value();
- $ctx1.sendIdx["value"]=1;
- $11=self["@stream"];
- $12=$11;
- $15=_st($String())._lf();
- $ctx1.sendIdx["lf"]=4;
- $14=",".__comma($15);
- $ctx1.sendIdx[","]=6;
- $13=_st($14).__comma("messageSends: ");
- $ctx1.sendIdx[","]=5;
- _st($12)._nextPutAll_($13);
- $ctx1.sendIdx["nextPutAll:"]=4;
- $16=$11;
- $19=_st(_st(aMethod)._messageSends())._asArray();
- $ctx1.sendIdx["asArray"]=1;
- $18=_st($19)._asJavascript();
- $ctx1.sendIdx["asJavascript"]=3;
- $17=_st($18).__comma(",");
- $ctx1.sendIdx[","]=7;
- _st($16)._nextPutAll_($17);
- $ctx1.sendIdx["nextPutAll:"]=5;
- _st($11)._lf();
- $ctx1.sendIdx["lf"]=5;
- $20=$11;
- $23=_st(_st(_st(_st(aMethod)._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._value();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._asArray())._asJavascript();
- $ctx1.sendIdx["asJavascript"]=4;
- $22="args: ".__comma($23);
- $21=_st($22).__comma(",");
- $ctx1.sendIdx[","]=8;
- _st($20)._nextPutAll_($21);
- $ctx1.sendIdx["nextPutAll:"]=6;
- _st($11)._lf();
- $24=_st($11)._nextPutAll_("referencedClasses: [");
- $ctx1.sendIdx["nextPutAll:"]=7;
- _st(_st(aMethod)._classReferences())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(_st(each)._asJavascript());
- $ctx2.sendIdx["nextPutAll:"]=8;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=9;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $25=self["@stream"];
- _st($25)._nextPutAll_("]");
- $ctx1.sendIdx["nextPutAll:"]=10;
- $26=_st($25)._nextPutAll_("})");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutMethodDeclaration:with:",{aMethod:aMethod,aBlock:aBlock},globals.JSStream)})},
- args: ["aMethod", "aBlock"],
- source: "nextPutMethodDeclaration: aMethod with: aBlock\x0a\x09stream\x0a\x09\x09nextPutAll: 'smalltalk.method({'; lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf.\x0a\x09aBlock value.\x0a\x09stream\x0a\x09\x09nextPutAll: ',', String lf, 'messageSends: ';\x0a\x09\x09nextPutAll: aMethod messageSends asArray asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'args: ', (aMethod arguments collect: [ :each | each value ]) asArray asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ['.\x0a\x09aMethod classReferences\x0a\x09\x09do: [ :each | stream nextPutAll: each asJavascript ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream\x0a\x09\x09nextPutAll: ']';\x0a\x09\x09nextPutAll: '})'",
- messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "source", "value", "asArray", "messageSends", "collect:", "arguments", "do:separatedBy:", "classReferences"],
- referencedClasses: ["String"]
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutNonLocalReturnHandlingWith:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- $1=self["@stream"];
- _st($1)._nextPutAll_("var $early={};");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st($1)._lf();
- $ctx1.sendIdx["lf"]=1;
- _st($1)._nextPutAll_("try {");
- $ctx1.sendIdx["nextPutAll:"]=2;
- $2=_st($1)._lf();
- $ctx1.sendIdx["lf"]=2;
- _st(aBlock)._value();
- $3=self["@stream"];
- _st($3)._nextPutAll_("}");
- $ctx1.sendIdx["nextPutAll:"]=3;
- _st($3)._lf();
- $ctx1.sendIdx["lf"]=3;
- _st($3)._nextPutAll_("catch(e) {if(e===$early)return e[0]; throw e}");
- $4=_st($3)._lf();
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutNonLocalReturnHandlingWith:",{aBlock:aBlock},globals.JSStream)})},
- args: ["aBlock"],
- source: "nextPutNonLocalReturnHandlingWith: aBlock\x0a\x09stream\x0a\x09\x09nextPutAll: 'var $early={};'; lf;\x0a\x09\x09nextPutAll: 'try {'; lf.\x0a\x09aBlock value.\x0a\x09stream\x0a\x09\x09nextPutAll: '}'; lf;\x0a\x09\x09nextPutAll: 'catch(e) {if(e===$early)return e[0]; throw e}'; lf",
- messageSends: ["nextPutAll:", "lf", "value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutNonLocalReturnWith:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._nextPutAll_("throw $early=[");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aBlock)._value();
- _st(self["@stream"])._nextPutAll_("]");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutNonLocalReturnWith:",{aBlock:aBlock},globals.JSStream)})},
- args: ["aBlock"],
- source: "nextPutNonLocalReturnWith: aBlock\x0a\x09stream nextPutAll: 'throw $early=['.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: ']'",
- messageSends: ["nextPutAll:", "value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutReturn",
- protocol: 'streaming',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@stream"])._nextPutAll_("return ");
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutReturn",{},globals.JSStream)})},
- args: [],
- source: "nextPutReturn\x0a\x09stream nextPutAll: 'return '",
- messageSends: ["nextPutAll:"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutReturnWith:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._nextPutReturn();
- _st(aBlock)._value();
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutReturnWith:",{aBlock:aBlock},globals.JSStream)})},
- args: ["aBlock"],
- source: "nextPutReturnWith: aBlock\x0a\x09self nextPutReturn.\x0a\x09aBlock value",
- messageSends: ["nextPutReturn", "value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutSendIndexFor:",
- protocol: 'streaming',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._nextPutAll_(";");
- $ctx1.sendIdx["nextPutAll:"]=1;
- self._lf();
- self._nextPutAll_(_st(_st(anIRSend)._scope())._alias());
- $ctx1.sendIdx["nextPutAll:"]=2;
- self._nextPutAll_(".sendIdx[");
- $ctx1.sendIdx["nextPutAll:"]=3;
- self._nextPutAll_(_st(_st(anIRSend)._selector())._asJavascript());
- $ctx1.sendIdx["nextPutAll:"]=4;
- self._nextPutAll_("]=");
- $ctx1.sendIdx["nextPutAll:"]=5;
- $1=self._nextPutAll_(_st(_st(anIRSend)._index())._asString());
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutSendIndexFor:",{anIRSend:anIRSend},globals.JSStream)})},
- args: ["anIRSend"],
- source: "nextPutSendIndexFor: anIRSend\x0a\x09self \x0a\x09\x09nextPutAll: ';'; lf;\x0a\x09\x09nextPutAll: anIRSend scope alias;\x0a\x09\x09nextPutAll: '.sendIdx[';\x0a\x09\x09nextPutAll: anIRSend selector asJavascript;\x0a\x09\x09nextPutAll: ']=';\x0a\x09\x09nextPutAll: anIRSend index asString",
- messageSends: ["nextPutAll:", "lf", "alias", "scope", "asJavascript", "selector", "asString", "index"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutSequenceWith:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aBlock)._value();
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutSequenceWith:",{aBlock:aBlock},globals.JSStream)})},
- args: ["aBlock"],
- source: "nextPutSequenceWith: aBlock\x0a\x09\x22stream\x0a\x09\x09nextPutAll: 'switch(smalltalk.thisContext.pc){'; lf.\x22\x0a\x09aBlock value.\x0a\x09\x22stream\x0a\x09\x09nextPutAll: '};'; lf\x22",
- messageSends: ["value"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutStatementWith:",
- protocol: 'streaming',
- fn: function (aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- _st(aBlock)._value();
- $1=self["@stream"];
- _st($1)._nextPutAll_(";");
- $2=_st($1)._lf();
- return self}, function($ctx1) {$ctx1.fill(self,"nextPutStatementWith:",{aBlock:aBlock},globals.JSStream)})},
- args: ["aBlock"],
- source: "nextPutStatementWith: aBlock\x0a\x09aBlock value.\x0a\x09stream nextPutAll: ';'; lf",
- messageSends: ["value", "nextPutAll:", "lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextPutVars:",
- protocol: 'streaming',
- fn: function (aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- _st(aCollection)._ifEmpty_((function(){
- throw $early=[self];
- }));
- _st(self["@stream"])._nextPutAll_("var ");
- $ctx1.sendIdx["nextPutAll:"]=1;
- _st(aCollection)._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(each);
- $ctx2.sendIdx["nextPutAll:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@stream"])._nextPutAll_(",");
- $ctx2.sendIdx["nextPutAll:"]=3;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $1=self["@stream"];
- _st($1)._nextPutAll_(";");
- $2=_st($1)._lf();
- return self}
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"nextPutVars:",{aCollection:aCollection},globals.JSStream)})},
- args: ["aCollection"],
- source: "nextPutVars: aCollection\x0a\x09aCollection ifEmpty: [ ^ self ].\x0a\x09\x0a\x09stream nextPutAll: 'var '.\x0a\x09aCollection\x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: ';'; lf",
- messageSends: ["ifEmpty:", "nextPutAll:", "do:separatedBy:", "lf"],
- referencedClasses: []
- }),
- globals.JSStream);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "appendToInstruction:",
- protocol: '*Compiler-IR',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(anIRInstruction)._appendBlock_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"appendToInstruction:",{anIRInstruction:anIRInstruction},globals.BlockClosure)})},
- args: ["anIRInstruction"],
- source: "appendToInstruction: anIRInstruction\x0a\x09anIRInstruction appendBlock: self",
- messageSends: ["appendBlock:"],
- referencedClasses: []
- }),
- globals.BlockClosure);
- });
- define("amber_core/Compiler-Inlining", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Compiler-IR", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-Inlining');
- smalltalk.packages["Compiler-Inlining"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('IRInlinedAssignment', globals.IRAssignment, [], 'Compiler-Inlining');
- globals.IRInlinedAssignment.comment="I represent an inlined assignment instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRInlinedAssignment_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedAssignment)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedAssignment: self",
- messageSends: ["visitIRInlinedAssignment:"],
- referencedClasses: []
- }),
- globals.IRInlinedAssignment);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInlinedAssignment);
- smalltalk.addClass('IRInlinedClosure', globals.IRClosure, [], 'Compiler-Inlining');
- globals.IRInlinedClosure.comment="I represent an inlined closure instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedClosure_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedClosure)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
- messageSends: ["visitIRInlinedClosure:"],
- referencedClasses: []
- }),
- globals.IRInlinedClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInlinedClosure);
- smalltalk.addClass('IRInlinedReturn', globals.IRReturn, [], 'Compiler-Inlining');
- globals.IRInlinedReturn.comment="I represent an inlined local return instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aVisitor)._visitIRInlinedReturn_(self);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedReturn)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedReturn: self",
- messageSends: ["visitIRInlinedReturn:"],
- referencedClasses: []
- }),
- globals.IRInlinedReturn);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInlinedReturn);
- smalltalk.addClass('IRInlinedSend', globals.IRSend, [], 'Compiler-Inlining');
- globals.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitInlinedSend_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedSend)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
- messageSends: ["visitInlinedSend:"],
- referencedClasses: []
- }),
- globals.IRInlinedSend);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInlinedSend);
- smalltalk.addClass('IRInlinedIfFalse', globals.IRInlinedSend, [], 'Compiler-Inlining');
- globals.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedIfFalse_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfFalse)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
- messageSends: ["visitIRInlinedIfFalse:"],
- referencedClasses: []
- }),
- globals.IRInlinedIfFalse);
- smalltalk.addClass('IRInlinedIfNilIfNotNil', globals.IRInlinedSend, [], 'Compiler-Inlining');
- globals.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfNilIfNotNil)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
- messageSends: ["visitIRInlinedIfNilIfNotNil:"],
- referencedClasses: []
- }),
- globals.IRInlinedIfNilIfNotNil);
- smalltalk.addClass('IRInlinedIfTrue', globals.IRInlinedSend, [], 'Compiler-Inlining');
- globals.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedIfTrue_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfTrue)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
- messageSends: ["visitIRInlinedIfTrue:"],
- referencedClasses: []
- }),
- globals.IRInlinedIfTrue);
- smalltalk.addClass('IRInlinedIfTrueIfFalse', globals.IRInlinedSend, [], 'Compiler-Inlining');
- globals.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfTrueIfFalse)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
- messageSends: ["visitIRInlinedIfTrueIfFalse:"],
- referencedClasses: []
- }),
- globals.IRInlinedIfTrueIfFalse);
- smalltalk.addClass('IRInlinedSequence', globals.IRBlockSequence, [], 'Compiler-Inlining');
- globals.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "accept:",
- protocol: 'visiting',
- fn: function (aVisitor){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aVisitor)._visitIRInlinedSequence_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedSequence)})},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
- messageSends: ["visitIRInlinedSequence:"],
- referencedClasses: []
- }),
- globals.IRInlinedSequence);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRInlinedSequence);
- smalltalk.addClass('IRInliner', globals.IRVisitor, [], 'Compiler-Inlining');
- globals.IRInliner.comment="I visit an IR tree, inlining message sends and block closures.\x0a\x0aMessage selectors that can be inlined are answered by `IRSendInliner >> #inlinedSelectors`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assignmentInliner",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRAssignmentInliner(){return globals.IRAssignmentInliner||(typeof IRAssignmentInliner=="undefined"?nil:IRAssignmentInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRAssignmentInliner())._new();
- _st($2)._translator_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},globals.IRInliner)})},
- args: [],
- source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRAssignmentInliner"]
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "returnInliner",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRReturnInliner(){return globals.IRReturnInliner||(typeof IRReturnInliner=="undefined"?nil:IRReturnInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRReturnInliner())._new();
- _st($2)._translator_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},globals.IRInliner)})},
- args: [],
- source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRReturnInliner"]
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendInliner",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRSendInliner(){return globals.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($IRSendInliner())._new();
- _st($2)._translator_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},globals.IRInliner)})},
- args: [],
- source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRSendInliner"]
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldInlineAssignment:",
- protocol: 'testing',
- fn: function (anIRAssignment){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $4,$3,$2,$1;
- $1=_st(_st(_st(anIRAssignment)._isInlined())._not())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $4=_st(anIRAssignment)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._last();
- $ctx2.sendIdx["last"]=1;
- $2=_st($3)._isSend();
- return _st($2)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._shouldInlineSend_(_st(_st(anIRAssignment)._instructions())._last());
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["and:"]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},globals.IRInliner)})},
- args: ["anIRAssignment"],
- source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment instructions last isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRAssignment instructions last) ]]",
- messageSends: ["and:", "not", "isInlined", "isSend", "last", "instructions", "shouldInlineSend:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldInlineReturn:",
- protocol: 'testing',
- fn: function (anIRReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $4,$3,$2,$1;
- $1=_st(_st(_st(anIRReturn)._isInlined())._not())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $4=_st(anIRReturn)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- $ctx2.sendIdx["first"]=1;
- $2=_st($3)._isSend();
- return _st($2)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._shouldInlineSend_(_st(_st(anIRReturn)._instructions())._first());
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["and:"]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},globals.IRInliner)})},
- args: ["anIRReturn"],
- source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn instructions first isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRReturn instructions first) ]]",
- messageSends: ["and:", "not", "isInlined", "isSend", "first", "instructions", "shouldInlineSend:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldInlineSend:",
- protocol: 'testing',
- fn: function (anIRSend){
- var self=this;
- function $IRSendInliner(){return globals.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(_st(anIRSend)._isInlined())._not())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st($IRSendInliner())._shouldInline_(anIRSend);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},globals.IRInliner)})},
- args: ["anIRSend"],
- source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
- messageSends: ["and:", "not", "isInlined", "shouldInline:"],
- referencedClasses: ["IRSendInliner"]
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "transformNonLocalReturn:",
- protocol: 'visiting',
- fn: function (anIRNonLocalReturn){
- var self=this;
- var localReturn;
- function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5,$6,$7,$8,$9;
- $2=_st(anIRNonLocalReturn)._scope();
- $ctx1.sendIdx["scope"]=1;
- $1=_st($2)._canInlineNonLocalReturns();
- if(smalltalk.assert($1)){
- $4=_st(anIRNonLocalReturn)._scope();
- $ctx1.sendIdx["scope"]=2;
- $3=_st($4)._methodScope();
- $5=_st(anIRNonLocalReturn)._scope();
- $ctx1.sendIdx["scope"]=3;
- _st($3)._removeNonLocalReturn_($5);
- $6=_st($IRReturn())._new();
- _st($6)._scope_(_st(anIRNonLocalReturn)._scope());
- $7=_st($6)._yourself();
- localReturn=$7;
- localReturn;
- _st(_st(anIRNonLocalReturn)._instructions())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(localReturn)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- _st(anIRNonLocalReturn)._replaceWith_(localReturn);
- $8=localReturn;
- return $8;
- };
- $9=globals.IRInliner.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]);
- return $9;
- }, function($ctx1) {$ctx1.fill(self,"transformNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},globals.IRInliner)})},
- args: ["anIRNonLocalReturn"],
- source: "transformNonLocalReturn: anIRNonLocalReturn\x0a\x09\x22Replace a non local return into a local return\x22\x0a\x0a\x09| localReturn |\x0a\x09anIRNonLocalReturn scope canInlineNonLocalReturns ifTrue: [\x0a\x09\x09anIRNonLocalReturn scope methodScope removeNonLocalReturn: anIRNonLocalReturn scope.\x0a\x09\x09localReturn := IRReturn new\x0a\x09\x09\x09scope: anIRNonLocalReturn scope;\x0a\x09\x09\x09yourself.\x0a\x09\x09anIRNonLocalReturn instructions do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
- messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "instructions", "add:", "replaceWith:", "visitIRNonLocalReturn:"],
- referencedClasses: ["IRReturn"]
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRAssignment:",
- protocol: 'visiting',
- fn: function (anIRAssignment){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._shouldInlineAssignment_(anIRAssignment);
- if(smalltalk.assert($2)){
- $1=_st(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
- } else {
- $1=globals.IRInliner.superclass.fn.prototype._visitIRAssignment_.apply(_st(self), [anIRAssignment]);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},globals.IRInliner)})},
- args: ["anIRAssignment"],
- source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
- messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRNonLocalReturn:",
- protocol: 'visiting',
- fn: function (anIRNonLocalReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._transformNonLocalReturn_(anIRNonLocalReturn);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},globals.IRInliner)})},
- args: ["anIRNonLocalReturn"],
- source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ self transformNonLocalReturn: anIRNonLocalReturn",
- messageSends: ["transformNonLocalReturn:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRReturn:",
- protocol: 'visiting',
- fn: function (anIRReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._shouldInlineReturn_(anIRReturn);
- if(smalltalk.assert($2)){
- $1=_st(self._returnInliner())._inlineReturn_(anIRReturn);
- } else {
- $1=globals.IRInliner.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},globals.IRInliner)})},
- args: ["anIRReturn"],
- source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
- messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRSend:",
- protocol: 'visiting',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._shouldInlineSend_(anIRSend);
- if(smalltalk.assert($2)){
- $1=_st(self._sendInliner())._inlineSend_(anIRSend);
- } else {
- $1=globals.IRInliner.superclass.fn.prototype._visitIRSend_.apply(_st(self), [anIRSend]);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},globals.IRInliner)})},
- args: ["anIRSend"],
- source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
- messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"],
- referencedClasses: []
- }),
- globals.IRInliner);
- smalltalk.addClass('IRInliningJSTranslator', globals.IRJSTranslator, [], 'Compiler-Inlining');
- globals.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedAssignment:",
- protocol: 'visiting',
- fn: function (anIRInlinedAssignment){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._visit_(_st(_st(anIRInlinedAssignment)._instructions())._last());
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedAssignment:",{anIRInlinedAssignment:anIRInlinedAssignment},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedAssignment"],
- source: "visitIRInlinedAssignment: anIRInlinedAssignment\x0a\x09self visit: anIRInlinedAssignment instructions last",
- messageSends: ["visit:", "last", "instructions"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedClosure:",
- protocol: 'visiting',
- fn: function (anIRInlinedClosure){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._stream())._nextPutVars_(_st(_st(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._name())._asVariableName();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
- _st(_st(anIRInlinedClosure)._instructions())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedClosure"],
- source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09self stream nextPutVars: (anIRInlinedClosure tempDeclarations collect: [ :each |\x0a\x09\x09each name asVariableName ]).\x0a\x09anIRInlinedClosure instructions do: [ :each |\x0a\x09\x09self visit: each ]",
- messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "instructions", "visit:"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedIfFalse:",
- protocol: 'visiting',
- fn: function (anIRInlinedIfFalse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutIf_with_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutAll_("! smalltalk.assert(");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st(anIRInlinedIfFalse)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx2.sendIdx["visit:"]=1;
- return _st(self._stream())._nextPutAll_(")");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedIfFalse)._instructions())._last());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedIfFalse"],
- source: "visitIRInlinedIfFalse: anIRInlinedIfFalse\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '! smalltalk.assert('.\x0a\x09\x09self visit: anIRInlinedIfFalse instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfFalse instructions last ]",
- messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedIfNil:",
- protocol: 'visiting',
- fn: function (anIRInlinedIfNil){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutIf_with_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutAll_("($receiver = ");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st(anIRInlinedIfNil)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx2.sendIdx["visit:"]=1;
- return _st(self._stream())._nextPutAll_(") == nil || $receiver == null");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedIfNil)._instructions())._last());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNil:",{anIRInlinedIfNil:anIRInlinedIfNil},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedIfNil"],
- source: "visitIRInlinedIfNil: anIRInlinedIfNil\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '($receiver = '.\x0a\x09\x09self visit: anIRInlinedIfNil instructions first.\x0a\x09\x09self stream nextPutAll: ') == nil || $receiver == null' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNil instructions last ]",
- messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedIfNilIfNotNil:",
- protocol: 'visiting',
- fn: function (anIRInlinedIfNilIfNotNil){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$6,$5;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutIfElse_with_with_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutAll_("($receiver = ");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st(anIRInlinedIfNilIfNotNil)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx2.sendIdx["visit:"]=1;
- return _st(self._stream())._nextPutAll_(") == nil || $receiver == null");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- $6=_st(anIRInlinedIfNilIfNotNil)._instructions();
- $ctx2.sendIdx["instructions"]=2;
- $5=_st($6)._second();
- return self._visit_($5);
- $ctx2.sendIdx["visit:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._third());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedIfNilIfNotNil"],
- source: "visitIRInlinedIfNilIfNotNil: anIRInlinedIfNilIfNotNil\x0a\x09self stream\x0a\x09\x09nextPutIfElse: [\x0a\x09\x09\x09self stream nextPutAll: '($receiver = '.\x0a\x09\x09\x09self visit: anIRInlinedIfNilIfNotNil instructions first.\x0a\x09\x09\x09self stream nextPutAll: ') == nil || $receiver == null' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions second ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions third ]",
- messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedIfTrue:",
- protocol: 'visiting',
- fn: function (anIRInlinedIfTrue){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutIf_with_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutAll_("smalltalk.assert(");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st(anIRInlinedIfTrue)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx2.sendIdx["visit:"]=1;
- return _st(self._stream())._nextPutAll_(")");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedIfTrue)._instructions())._last());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedIfTrue"],
- source: "visitIRInlinedIfTrue: anIRInlinedIfTrue\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: 'smalltalk.assert('.\x0a\x09\x09self visit: anIRInlinedIfTrue instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrue instructions last ]",
- messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedIfTrueIfFalse:",
- protocol: 'visiting',
- fn: function (anIRInlinedIfTrueIfFalse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$6,$5;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutIfElse_with_with_((function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._stream();
- $ctx2.sendIdx["stream"]=2;
- _st($2)._nextPutAll_("smalltalk.assert(");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $4=_st(anIRInlinedIfTrueIfFalse)._instructions();
- $ctx2.sendIdx["instructions"]=1;
- $3=_st($4)._first();
- self._visit_($3);
- $ctx2.sendIdx["visit:"]=1;
- return _st(self._stream())._nextPutAll_(")");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- $6=_st(anIRInlinedIfTrueIfFalse)._instructions();
- $ctx2.sendIdx["instructions"]=2;
- $5=_st($6)._second();
- return self._visit_($5);
- $ctx2.sendIdx["visit:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._third());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedIfTrueIfFalse"],
- source: "visitIRInlinedIfTrueIfFalse: anIRInlinedIfTrueIfFalse\x0a\x09self stream\x0a\x09\x09nextPutIfElse: [\x0a\x09\x09\x09self stream nextPutAll: 'smalltalk.assert('.\x0a\x09\x09\x09self visit: anIRInlinedIfTrueIfFalse instructions first.\x0a\x09\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrueIfFalse instructions second ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrueIfFalse instructions third ]",
- messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedNonLocalReturn:",
- protocol: 'visiting',
- fn: function (anIRInlinedReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._stream();
- $ctx1.sendIdx["stream"]=1;
- _st($1)._nextPutStatementWith_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- _st(self._stream())._nextPutNonLocalReturnWith_((function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedNonLocalReturn:",{anIRInlinedReturn:anIRInlinedReturn},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedReturn"],
- source: "visitIRInlinedNonLocalReturn: anIRInlinedReturn\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self visit: anIRInlinedReturn instructions last ].\x0a\x09self stream nextPutNonLocalReturnWith: [ ]",
- messageSends: ["nextPutStatementWith:", "stream", "visit:", "last", "instructions", "nextPutNonLocalReturnWith:"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedReturn:",
- protocol: 'visiting',
- fn: function (anIRInlinedReturn){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedReturn:",{anIRInlinedReturn:anIRInlinedReturn},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedReturn"],
- source: "visitIRInlinedReturn: anIRInlinedReturn\x0a\x09self visit: anIRInlinedReturn instructions last",
- messageSends: ["visit:", "last", "instructions"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitIRInlinedSequence:",
- protocol: 'visiting',
- fn: function (anIRInlinedSequence){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(anIRInlinedSequence)._instructions())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._stream())._nextPutStatementWith_((function(){
- return smalltalk.withContext(function($ctx3) {
- return self._visit_(each);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},globals.IRInliningJSTranslator)})},
- args: ["anIRInlinedSequence"],
- source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each |\x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
- messageSends: ["do:", "instructions", "nextPutStatementWith:", "stream", "visit:"],
- referencedClasses: []
- }),
- globals.IRInliningJSTranslator);
- smalltalk.addClass('IRSendInliner', globals.Object, ['send', 'translator'], 'Compiler-Inlining');
- globals.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifFalse:",
- protocol: 'inlining',
- fn: function (anIRInstruction){
- var self=this;
- function $IRInlinedIfFalse(){return globals.IRInlinedIfFalse||(typeof IRInlinedIfFalse=="undefined"?nil:IRInlinedIfFalse)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._inlinedSend_with_(_st($IRInlinedIfFalse())._new(),anIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction"],
- source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new with: anIRInstruction",
- messageSends: ["inlinedSend:with:", "new"],
- referencedClasses: ["IRInlinedIfFalse"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifFalse:ifTrue:",
- protocol: 'inlining',
- fn: function (anIRInstruction,anotherIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
- messageSends: ["perform:withArguments:"],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:",
- protocol: 'inlining',
- fn: function (anIRInstruction){
- var self=this;
- function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
- function $IRClosure(){return globals.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
- function $IRBlockSequence(){return globals.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$4,$5,$7,$8,$6,$9,$3,$1;
- $2=_st($IRInlinedIfNilIfNotNil())._new();
- $ctx1.sendIdx["new"]=1;
- $4=_st($IRClosure())._new();
- $ctx1.sendIdx["new"]=2;
- _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
- $5=$4;
- $7=_st($IRBlockSequence())._new();
- _st($7)._add_(_st(_st(self._send())._instructions())._first());
- $8=_st($7)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- $6=$8;
- _st($5)._add_($6);
- $ctx1.sendIdx["add:"]=1;
- $9=_st($4)._yourself();
- $3=$9;
- $1=self._inlinedSend_with_with_($2,anIRInstruction,$3);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction"],
- source: "ifNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09with: anIRInstruction\x0a\x09\x09with: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send instructions first;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)",
- messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
- referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNil:ifNotNil:",
- protocol: 'inlining',
- fn: function (anIRInstruction,anotherIRInstruction){
- var self=this;
- function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,anotherIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifNil: anIRInstruction ifNotNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anIRInstruction with: anotherIRInstruction",
- messageSends: ["inlinedSend:with:with:", "new"],
- referencedClasses: ["IRInlinedIfNilIfNotNil"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:",
- protocol: 'inlining',
- fn: function (anIRInstruction){
- var self=this;
- function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
- function $IRClosure(){return globals.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
- function $IRBlockSequence(){return globals.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$4,$5,$7,$8,$6,$9,$3,$1;
- $2=_st($IRInlinedIfNilIfNotNil())._new();
- $ctx1.sendIdx["new"]=1;
- $4=_st($IRClosure())._new();
- $ctx1.sendIdx["new"]=2;
- _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
- $5=$4;
- $7=_st($IRBlockSequence())._new();
- _st($7)._add_(_st(_st(self._send())._instructions())._first());
- $8=_st($7)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- $6=$8;
- _st($5)._add_($6);
- $ctx1.sendIdx["add:"]=1;
- $9=_st($4)._yourself();
- $3=$9;
- $1=self._inlinedSend_with_with_($2,$3,anIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction"],
- source: "ifNotNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09with: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send instructions first;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)\x0a\x09\x09with: anIRInstruction",
- messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
- referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifNotNil:ifNil:",
- protocol: 'inlining',
- fn: function (anIRInstruction,anotherIRInstruction){
- var self=this;
- function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anotherIRInstruction,anIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifNotNil: anIRInstruction ifNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anotherIRInstruction with: anIRInstruction",
- messageSends: ["inlinedSend:with:with:", "new"],
- referencedClasses: ["IRInlinedIfNilIfNotNil"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifTrue:",
- protocol: 'inlining',
- fn: function (anIRInstruction){
- var self=this;
- function $IRInlinedIfTrue(){return globals.IRInlinedIfTrue||(typeof IRInlinedIfTrue=="undefined"?nil:IRInlinedIfTrue)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._inlinedSend_with_(_st($IRInlinedIfTrue())._new(),anIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction"],
- source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new with: anIRInstruction",
- messageSends: ["inlinedSend:with:", "new"],
- referencedClasses: ["IRInlinedIfTrue"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ifTrue:ifFalse:",
- protocol: 'inlining',
- fn: function (anIRInstruction,anotherIRInstruction){
- var self=this;
- function $IRInlinedIfTrueIfFalse(){return globals.IRInlinedIfTrueIfFalse||(typeof IRInlinedIfTrueIfFalse=="undefined"?nil:IRInlinedIfTrueIfFalse)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._inlinedSend_with_with_(_st($IRInlinedIfTrueIfFalse())._new(),anIRInstruction,anotherIRInstruction);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)})},
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new with: anIRInstruction with: anotherIRInstruction",
- messageSends: ["inlinedSend:with:with:", "new"],
- referencedClasses: ["IRInlinedIfTrueIfFalse"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineClosure:",
- protocol: 'inlining',
- fn: function (anIRClosure){
- var self=this;
- var inlinedClosure,sequence,statements;
- function $IRTempDeclaration(){return globals.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
- function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
- function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
- function $AliasVar(){return globals.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$5,$6,$4,$7,$9,$10,$12,$14,$15,$16,$17,$13,$11,$18,$20,$22,$23,$21,$19,$24,$8,$26,$25,$29,$28,$30,$27,$31,$34,$33,$32,$35;
- inlinedClosure=self._inlinedClosure();
- $1=inlinedClosure;
- $2=_st(anIRClosure)._scope();
- $ctx1.sendIdx["scope"]=1;
- _st($1)._scope_($2);
- $ctx1.sendIdx["scope:"]=1;
- _st(_st(anIRClosure)._tempDeclarations())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(inlinedClosure)._add_(each);
- $ctx2.sendIdx["add:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- sequence=self._inlinedSequence();
- _st(_st(anIRClosure)._arguments())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $3=inlinedClosure;
- $5=_st($IRTempDeclaration())._new();
- $ctx2.sendIdx["new"]=1;
- _st($5)._name_(each);
- $ctx2.sendIdx["name:"]=1;
- $6=_st($5)._yourself();
- $ctx2.sendIdx["yourself"]=1;
- $4=$6;
- _st($3)._add_($4);
- $ctx2.sendIdx["add:"]=2;
- $7=sequence;
- $9=_st($IRAssignment())._new();
- $ctx2.sendIdx["new"]=2;
- $10=$9;
- $12=_st($IRVariable())._new();
- $ctx2.sendIdx["new"]=3;
- $14=_st($AliasVar())._new();
- $ctx2.sendIdx["new"]=4;
- $15=$14;
- $16=_st(inlinedClosure)._scope();
- $ctx2.sendIdx["scope"]=2;
- _st($15)._scope_($16);
- $ctx2.sendIdx["scope:"]=2;
- _st($14)._name_(each);
- $ctx2.sendIdx["name:"]=2;
- $17=_st($14)._yourself();
- $ctx2.sendIdx["yourself"]=2;
- $13=$17;
- $11=_st($12)._variable_($13);
- $ctx2.sendIdx["variable:"]=1;
- _st($10)._add_($11);
- $ctx2.sendIdx["add:"]=4;
- $18=$9;
- $20=_st($IRVariable())._new();
- $ctx2.sendIdx["new"]=5;
- $22=_st($AliasVar())._new();
- _st($22)._scope_(_st(inlinedClosure)._scope());
- _st($22)._name_("$receiver");
- $23=_st($22)._yourself();
- $ctx2.sendIdx["yourself"]=3;
- $21=$23;
- $19=_st($20)._variable_($21);
- _st($18)._add_($19);
- $ctx2.sendIdx["add:"]=5;
- $24=_st($9)._yourself();
- $8=$24;
- return _st($7)._add_($8);
- $ctx2.sendIdx["add:"]=3;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- $ctx1.sendIdx["do:"]=2;
- _st(inlinedClosure)._add_(sequence);
- $ctx1.sendIdx["add:"]=6;
- $26=_st(anIRClosure)._instructions();
- $ctx1.sendIdx["instructions"]=2;
- $25=_st($26)._last();
- $ctx1.sendIdx["last"]=1;
- statements=_st($25)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st(statements)._ifNotEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- _st(_st(statements)._allButLast())._do_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(sequence)._add_(each);
- $ctx3.sendIdx["add:"]=7;
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,4)})}));
- $29=_st(statements)._last();
- $ctx2.sendIdx["last"]=2;
- $28=_st($29)._isReturn();
- $27=_st($28)._and_((function(){
- return smalltalk.withContext(function($ctx3) {
- $30=_st(statements)._last();
- $ctx3.sendIdx["last"]=3;
- return _st($30)._isBlockReturn();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
- if(smalltalk.assert($27)){
- $31=sequence;
- $34=_st(statements)._last();
- $ctx2.sendIdx["last"]=4;
- $33=_st($34)._instructions();
- $32=_st($33)._first();
- return _st($31)._add_($32);
- $ctx2.sendIdx["add:"]=8;
- } else {
- return _st(sequence)._add_(_st(statements)._last());
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $35=inlinedClosure;
- return $35;
- }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},globals.IRSendInliner)})},
- args: ["anIRClosure"],
- source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure sequence statements |\x0a\x0a\x09inlinedClosure := self inlinedClosure.\x0a\x09inlinedClosure scope: anIRClosure scope.\x0a\x0a\x09\x22Add the possible temp declarations\x22\x0a\x09anIRClosure tempDeclarations do: [ :each |\x0a\x09\x09\x09inlinedClosure add: each ].\x0a\x0a\x09\x22Add a block sequence\x22\x0a\x09sequence := self inlinedSequence.\x0a\x0a\x09\x22Map the closure arguments to the receiver of the message send\x22\x0a\x09anIRClosure arguments do: [ :each |\x0a\x09\x09inlinedClosure add: (IRTempDeclaration new name: each; yourself).\x0a\x09\x09sequence add: (IRAssignment new\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: each; yourself));\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: '$receiver'; yourself));\x0a\x09\x09\x09yourself) ].\x0a\x09\x09\x09\x0a\x09\x22To ensure the correct order of the closure instructions: first the temps then the sequence\x22\x0a\x09inlinedClosure add: sequence.\x0a\x0a\x09\x22Get all the statements\x22\x0a\x09statements := anIRClosure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements allButLast do: [ :each | sequence add: each ].\x0a\x0a\x09\x09\x22Inlined closures don't have implicit local returns\x22\x0a\x09\x09(statements last isReturn and: [ statements last isBlockReturn ])\x0a\x09\x09\x09ifTrue: [ sequence add: statements last instructions first ]\x0a\x09\x09\x09ifFalse: [ sequence add: statements last ] ].\x0a\x0a\x09^ inlinedClosure",
- messageSends: ["inlinedClosure", "scope:", "scope", "do:", "tempDeclarations", "add:", "inlinedSequence", "arguments", "name:", "new", "yourself", "variable:", "instructions", "last", "ifNotEmpty:", "allButLast", "ifTrue:ifFalse:", "and:", "isReturn", "isBlockReturn", "first"],
- referencedClasses: ["IRTempDeclaration", "IRAssignment", "IRVariable", "AliasVar"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineSend:",
- protocol: 'inlining',
- fn: function (anIRSend){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- self._send_(anIRSend);
- $3=self._send();
- $ctx1.sendIdx["send"]=1;
- $2=_st($3)._selector();
- $1=self._perform_withArguments_($2,_st(_st(self._send())._instructions())._allButFirst());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},globals.IRSendInliner)})},
- args: ["anIRSend"],
- source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self\x0a\x09\x09perform: self send selector\x0a\x09\x09withArguments: self send instructions allButFirst",
- messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedClosure",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRInlinedClosure(){return globals.IRInlinedClosure||(typeof IRInlinedClosure=="undefined"?nil:IRInlinedClosure)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRInlinedClosure())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},globals.IRSendInliner)})},
- args: [],
- source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedClosure"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedSend:with:",
- protocol: 'inlining',
- fn: function (inlinedSend,anIRInstruction){
- var self=this;
- var inlinedClosure;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$5,$4,$3,$6;
- $1=_st(anIRInstruction)._isClosure();
- if(! smalltalk.assert($1)){
- self._inliningError_("Message argument should be a block");
- $ctx1.sendIdx["inliningError:"]=1;
- };
- $2=_st(_st(_st(anIRInstruction)._arguments())._size()).__eq((0));
- if(! smalltalk.assert($2)){
- self._inliningError_("Inlined block should have zero argument");
- };
- inlinedClosure=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
- $5=self._send();
- $ctx1.sendIdx["send"]=1;
- $4=_st($5)._instructions();
- $3=_st($4)._first();
- _st(inlinedSend)._add_($3);
- $ctx1.sendIdx["add:"]=1;
- $6=_st(inlinedSend)._add_(inlinedClosure);
- _st(self._send())._replaceWith_(inlinedSend);
- return inlinedSend;
- }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},globals.IRSendInliner)})},
- args: ["inlinedSend", "anIRInstruction"],
- source: "inlinedSend: inlinedSend with: anIRInstruction\x0a\x09| inlinedClosure |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anIRInstruction arguments size = 0 ifFalse: [ self inliningError: 'Inlined block should have zero argument' ].\x0a\x0a\x09inlinedClosure := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x0a\x09^ inlinedSend",
- messageSends: ["ifFalse:", "isClosure", "inliningError:", "=", "size", "arguments", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedSend:with:with:",
- protocol: 'inlining',
- fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
- var self=this;
- var inlinedClosure1,inlinedClosure2;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$7,$6,$5,$8;
- $1=_st(anIRInstruction)._isClosure();
- $ctx1.sendIdx["isClosure"]=1;
- if(! smalltalk.assert($1)){
- self._inliningError_("Message argument should be a block");
- $ctx1.sendIdx["inliningError:"]=1;
- };
- $2=_st(anotherIRInstruction)._isClosure();
- if(! smalltalk.assert($2)){
- self._inliningError_("Message argument should be a block");
- };
- $3=self._translator();
- $ctx1.sendIdx["translator"]=1;
- $4=self._inlineClosure_(anIRInstruction);
- $ctx1.sendIdx["inlineClosure:"]=1;
- inlinedClosure1=_st($3)._visit_($4);
- $ctx1.sendIdx["visit:"]=1;
- inlinedClosure2=_st(self._translator())._visit_(self._inlineClosure_(anotherIRInstruction));
- $7=self._send();
- $ctx1.sendIdx["send"]=1;
- $6=_st($7)._instructions();
- $5=_st($6)._first();
- _st(inlinedSend)._add_($5);
- $ctx1.sendIdx["add:"]=1;
- _st(inlinedSend)._add_(inlinedClosure1);
- $ctx1.sendIdx["add:"]=2;
- $8=_st(inlinedSend)._add_(inlinedClosure2);
- _st(self._send())._replaceWith_(inlinedSend);
- return inlinedSend;
- }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},globals.IRSendInliner)})},
- args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
- source: "inlinedSend: inlinedSend with: anIRInstruction with: anotherIRInstruction\x0a\x09| inlinedClosure1 inlinedClosure2 |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anotherIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x0a\x09inlinedClosure1 := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x09inlinedClosure2 := self translator visit: (self inlineClosure: anotherIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure1;\x0a\x09\x09add: inlinedClosure2.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09^ inlinedSend",
- messageSends: ["ifFalse:", "isClosure", "inliningError:", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedSequence",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRInlinedSequence(){return globals.IRInlinedSequence||(typeof IRInlinedSequence=="undefined"?nil:IRInlinedSequence)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRInlinedSequence())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},globals.IRSendInliner)})},
- args: [],
- source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedSequence"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inliningError:",
- protocol: 'error handling',
- fn: function (aString){
- var self=this;
- function $InliningError(){return globals.InliningError||(typeof InliningError=="undefined"?nil:InliningError)}
- return smalltalk.withContext(function($ctx1) {
- _st($InliningError())._signal_(aString);
- return self}, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},globals.IRSendInliner)})},
- args: ["aString"],
- source: "inliningError: aString\x0a\x09InliningError signal: aString",
- messageSends: ["signal:"],
- referencedClasses: ["InliningError"]
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "send",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@send"];
- return $1;
- },
- args: [],
- source: "send\x0a\x09^ send",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "send:",
- protocol: 'accessing',
- fn: function (anIRSend){
- var self=this;
- self["@send"]=anIRSend;
- return self},
- args: ["anIRSend"],
- source: "send: anIRSend\x0a\x09send := anIRSend",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "translator",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@translator"];
- return $1;
- },
- args: [],
- source: "translator\x0a\x09^ translator",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "translator:",
- protocol: 'accessing',
- fn: function (anASTTranslator){
- var self=this;
- self["@translator"]=anASTTranslator;
- return self},
- args: ["anASTTranslator"],
- source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSendInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedSelectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
- return $1;
- },
- args: [],
- source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRSendInliner.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "shouldInline:",
- protocol: 'accessing',
- fn: function (anIRInstruction){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- $1=_st(self._inlinedSelectors())._includes_(_st(anIRInstruction)._selector());
- if(! smalltalk.assert($1)){
- return false;
- };
- _st(_st(_st(anIRInstruction)._instructions())._allButFirst())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(each)._isClosure();
- if(! smalltalk.assert($2)){
- throw $early=[false];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRInstruction:anIRInstruction},globals.IRSendInliner.klass)})},
- args: ["anIRInstruction"],
- source: "shouldInline: anIRInstruction\x0a\x09(self inlinedSelectors includes: anIRInstruction selector) ifFalse: [ ^ false ].\x0a\x09anIRInstruction instructions allButFirst do: [ :each |\x0a\x09\x09each isClosure ifFalse: [ ^ false ]].\x0a\x09^ true",
- messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "do:", "allButFirst", "instructions", "isClosure"],
- referencedClasses: []
- }),
- globals.IRSendInliner.klass);
- smalltalk.addClass('IRAssignmentInliner', globals.IRSendInliner, ['assignment'], 'Compiler-Inlining');
- globals.IRAssignmentInliner.comment="I inline message sends together with assignments by moving them around into the inline closure instructions.\x0a\x0a##Example\x0a\x0a\x09foo\x0a\x09\x09| a |\x0a\x09\x09a := true ifTrue: [ 1 ]\x0a\x0aWill produce:\x0a\x0a\x09if(smalltalk.assert(true) {\x0a\x09\x09a = 1;\x0a\x09};";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assignment",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@assignment"];
- return $1;
- },
- args: [],
- source: "assignment\x0a\x09^ assignment",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRAssignmentInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assignment:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@assignment"]=aNode;
- return self},
- args: ["aNode"],
- source: "assignment: aNode\x0a\x09assignment := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.IRAssignmentInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineAssignment:",
- protocol: 'inlining',
- fn: function (anIRAssignment){
- var self=this;
- var inlinedAssignment;
- function $IRInlinedAssignment(){return globals.IRInlinedAssignment||(typeof IRInlinedAssignment=="undefined"?nil:IRInlinedAssignment)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- self._assignment_(anIRAssignment);
- inlinedAssignment=_st($IRInlinedAssignment())._new();
- $1=_st(anIRAssignment)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st($1)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(inlinedAssignment)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(anIRAssignment)._replaceWith_(inlinedAssignment);
- self._inlineSend_(_st(_st(inlinedAssignment)._instructions())._last());
- $2=inlinedAssignment;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment,inlinedAssignment:inlinedAssignment},globals.IRAssignmentInliner)})},
- args: ["anIRAssignment"],
- source: "inlineAssignment: anIRAssignment\x0a\x09| inlinedAssignment |\x0a\x09self assignment: anIRAssignment.\x0a\x09inlinedAssignment := IRInlinedAssignment new.\x0a\x09anIRAssignment instructions do: [ :each |\x0a\x09\x09inlinedAssignment add: each ].\x0a\x09anIRAssignment replaceWith: inlinedAssignment.\x0a\x09self inlineSend: inlinedAssignment instructions last.\x0a\x09^ inlinedAssignment",
- messageSends: ["assignment:", "new", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
- referencedClasses: ["IRInlinedAssignment"]
- }),
- globals.IRAssignmentInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineClosure:",
- protocol: 'inlining',
- fn: function (anIRClosure){
- var self=this;
- var inlinedClosure,statements;
- function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5,$7,$8,$6,$9;
- inlinedClosure=globals.IRAssignmentInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
- $2=_st(inlinedClosure)._instructions();
- $ctx1.sendIdx["instructions"]=2;
- $1=_st($2)._last();
- $ctx1.sendIdx["last"]=1;
- statements=_st($1)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st(statements)._ifNotEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- $4=_st(statements)._last();
- $ctx2.sendIdx["last"]=2;
- $3=_st($4)._canBeAssigned();
- if(smalltalk.assert($3)){
- $5=_st(statements)._last();
- $ctx2.sendIdx["last"]=3;
- $7=_st($IRAssignment())._new();
- _st($7)._add_(_st(_st(self._assignment())._instructions())._first());
- $ctx2.sendIdx["add:"]=1;
- _st($7)._add_(_st(_st(statements)._last())._copy());
- $8=_st($7)._yourself();
- $6=$8;
- return _st($5)._replaceWith_($6);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $9=inlinedClosure;
- return $9;
- }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,statements:statements},globals.IRAssignmentInliner)})},
- args: ["anIRClosure"],
- source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure statements |\x0a\x0a\x09inlinedClosure := super inlineClosure: anIRClosure.\x0a\x09statements := inlinedClosure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements last canBeAssigned ifTrue: [\x0a\x09\x09\x09statements last replaceWith: (IRAssignment new\x0a\x09\x09\x09\x09add: self assignment instructions first;\x0a\x09\x09\x09\x09add: statements last copy;\x0a\x09\x09\x09\x09yourself) ] ].\x0a\x0a\x09^ inlinedClosure",
- messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifTrue:", "canBeAssigned", "replaceWith:", "add:", "new", "first", "assignment", "copy", "yourself"],
- referencedClasses: ["IRAssignment"]
- }),
- globals.IRAssignmentInliner);
- smalltalk.addClass('IRReturnInliner', globals.IRSendInliner, [], 'Compiler-Inlining');
- globals.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineClosure:",
- protocol: 'inlining',
- fn: function (anIRClosure){
- var self=this;
- var closure,statements;
- function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5,$6,$7;
- closure=globals.IRReturnInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
- $1=_st(_st(closure)._instructions())._last();
- $ctx1.sendIdx["last"]=1;
- statements=_st($1)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st(statements)._ifNotEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- $3=_st(statements)._last();
- $ctx2.sendIdx["last"]=2;
- $2=_st($3)._isReturn();
- if(! smalltalk.assert($2)){
- $4=_st(statements)._last();
- $ctx2.sendIdx["last"]=3;
- $5=_st($IRReturn())._new();
- _st($5)._add_(_st(_st(statements)._last())._copy());
- $6=_st($5)._yourself();
- return _st($4)._replaceWith_($6);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $7=closure;
- return $7;
- }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,statements:statements},globals.IRReturnInliner)})},
- args: ["anIRClosure"],
- source: "inlineClosure: anIRClosure\x0a\x09| closure statements |\x0a\x0a\x09closure := super inlineClosure: anIRClosure.\x0a\x09statements := closure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements last isReturn\x0a\x09\x09\x09ifFalse: [ statements last replaceWith: (IRReturn new\x0a\x09\x09\x09\x09add: statements last copy;\x0a\x09\x09\x09\x09yourself)] ].\x0a\x0a\x09^ closure",
- messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifFalse:", "isReturn", "replaceWith:", "add:", "new", "copy", "yourself"],
- referencedClasses: ["IRReturn"]
- }),
- globals.IRReturnInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlineReturn:",
- protocol: 'inlining',
- fn: function (anIRReturn){
- var self=this;
- var return_;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- return_=self._inlinedReturn();
- $1=_st(anIRReturn)._instructions();
- $ctx1.sendIdx["instructions"]=1;
- _st($1)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(return_)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(anIRReturn)._replaceWith_(return_);
- self._inlineSend_(_st(_st(return_)._instructions())._last());
- $2=return_;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn,return_:return_},globals.IRReturnInliner)})},
- args: ["anIRReturn"],
- source: "inlineReturn: anIRReturn\x0a\x09| return |\x0a\x09return := self inlinedReturn.\x0a\x09anIRReturn instructions do: [ :each |\x0a\x09\x09return add: each ].\x0a\x09anIRReturn replaceWith: return.\x0a\x09self inlineSend: return instructions last.\x0a\x09^ return",
- messageSends: ["inlinedReturn", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
- referencedClasses: []
- }),
- globals.IRReturnInliner);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inlinedReturn",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $IRInlinedReturn(){return globals.IRInlinedReturn||(typeof IRInlinedReturn=="undefined"?nil:IRInlinedReturn)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRInlinedReturn())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inlinedReturn",{},globals.IRReturnInliner)})},
- args: [],
- source: "inlinedReturn\x0a\x09^ IRInlinedReturn new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedReturn"]
- }),
- globals.IRReturnInliner);
- smalltalk.addClass('InliningCodeGenerator', globals.CodeGenerator, [], 'Compiler-Inlining');
- globals.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- var ir,stream;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- _st(self._semanticAnalyzer())._visit_(aNode);
- $ctx1.sendIdx["visit:"]=1;
- ir=_st(self._translator())._visit_(aNode);
- $ctx1.sendIdx["visit:"]=2;
- _st(self._inliner())._visit_(ir);
- $ctx1.sendIdx["visit:"]=3;
- $2=self._irTranslator();
- _st($2)._currentClass_(self._currentClass());
- _st($2)._visit_(ir);
- $3=_st($2)._contents();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},globals.InliningCodeGenerator)})},
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09self inliner visit: ir.\x0a\x0a\x09^ self irTranslator\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
- messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "irTranslator", "currentClass", "contents"],
- referencedClasses: []
- }),
- globals.InliningCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "inliner",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRInliner(){return globals.IRInliner||(typeof IRInliner=="undefined"?nil:IRInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRInliner())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"inliner",{},globals.InliningCodeGenerator)})},
- args: [],
- source: "inliner\x0a\x09^ IRInliner new",
- messageSends: ["new"],
- referencedClasses: ["IRInliner"]
- }),
- globals.InliningCodeGenerator);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "irTranslator",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRInliningJSTranslator(){return globals.IRInliningJSTranslator||(typeof IRInliningJSTranslator=="undefined"?nil:IRInliningJSTranslator)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st($IRInliningJSTranslator())._new();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},globals.InliningCodeGenerator)})},
- args: [],
- source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
- messageSends: ["new"],
- referencedClasses: ["IRInliningJSTranslator"]
- }),
- globals.InliningCodeGenerator);
- });
- define("amber_core/Compiler-Semantic", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-Semantic');
- smalltalk.packages["Compiler-Semantic"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('LexicalScope', globals.Object, ['node', 'instruction', 'temps', 'args', 'outerScope', 'blockIndex'], 'Compiler-Semantic');
- globals.LexicalScope.comment="I represent a lexical scope where variable names are associated with ScopeVars\x0aInstances are used for block scopes. Method scopes are instances of MethodLexicalScope.\x0a\x0aI am attached to a ScopeVar and method/block nodes.\x0aEach context (method/closure) get a fresh scope that inherits from its outer scope.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addArg:",
- protocol: 'adding',
- fn: function (aString){
- var self=this;
- function $ArgVar(){return globals.ArgVar||(typeof ArgVar=="undefined"?nil:ArgVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._args();
- $ctx1.sendIdx["args"]=1;
- _st($1)._at_put_(aString,_st($ArgVar())._on_(aString));
- _st(_st(self._args())._at_(aString))._scope_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"addArg:",{aString:aString},globals.LexicalScope)})},
- args: ["aString"],
- source: "addArg: aString\x0a\x09self args at: aString put: (ArgVar on: aString).\x0a\x09(self args at: aString) scope: self",
- messageSends: ["at:put:", "args", "on:", "scope:", "at:"],
- referencedClasses: ["ArgVar"]
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addTemp:",
- protocol: 'adding',
- fn: function (aString){
- var self=this;
- function $TempVar(){return globals.TempVar||(typeof TempVar=="undefined"?nil:TempVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._temps();
- $ctx1.sendIdx["temps"]=1;
- _st($1)._at_put_(aString,_st($TempVar())._on_(aString));
- _st(_st(self._temps())._at_(aString))._scope_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"addTemp:",{aString:aString},globals.LexicalScope)})},
- args: ["aString"],
- source: "addTemp: aString\x0a\x09self temps at: aString put: (TempVar on: aString).\x0a\x09(self temps at: aString) scope: self",
- messageSends: ["at:put:", "temps", "on:", "scope:", "at:"],
- referencedClasses: ["TempVar"]
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1="$ctx".__comma(_st(self._scopeLevel())._asString());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.LexicalScope)})},
- args: [],
- source: "alias\x0a\x09^ '$ctx', self scopeLevel asString",
- messageSends: [",", "asString", "scopeLevel"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allVariableNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(self._args())._keys();
- $ctx1.sendIdx["keys"]=1;
- $1=_st($2).__comma(_st(self._temps())._keys());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},globals.LexicalScope)})},
- args: [],
- source: "allVariableNames\x0a\x09^ self args keys, self temps keys",
- messageSends: [",", "keys", "args", "temps"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "args",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@args"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@args"]=_st($Dictionary())._new();
- $1=self["@args"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"args",{},globals.LexicalScope)})},
- args: [],
- source: "args\x0a\x09^ args ifNil: [ args := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "bindingFor:",
- protocol: 'accessing',
- fn: function (aStringOrNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$5,$1;
- $2=self._pseudoVars();
- $3=_st(aStringOrNode)._value();
- $ctx1.sendIdx["value"]=1;
- $1=_st($2)._at_ifAbsent_($3,(function(){
- return smalltalk.withContext(function($ctx2) {
- $4=self._args();
- $5=_st(aStringOrNode)._value();
- $ctx2.sendIdx["value"]=2;
- return _st($4)._at_ifAbsent_($5,(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(self._temps())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
- return nil;
- }));
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
- $ctx2.sendIdx["at:ifAbsent:"]=2;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["at:ifAbsent:"]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aStringOrNode:aStringOrNode},globals.LexicalScope)})},
- args: ["aStringOrNode"],
- source: "bindingFor: aStringOrNode\x0a\x09^ self pseudoVars at: aStringOrNode value ifAbsent: [\x0a\x09\x09self args at: aStringOrNode value ifAbsent: [\x0a\x09\x09\x09self temps at: aStringOrNode value ifAbsent: [ nil ]]]",
- messageSends: ["at:ifAbsent:", "pseudoVars", "value", "args", "temps"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "blockIndex",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@blockIndex"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=(0);
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},globals.LexicalScope)})},
- args: [],
- source: "blockIndex\x0a\x09^ blockIndex ifNil: [ 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "blockIndex:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@blockIndex"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "blockIndex: anInteger \x0a\x09blockIndex := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "canInlineNonLocalReturns",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._isInlined())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._outerScope())._canInlineNonLocalReturns();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"canInlineNonLocalReturns",{},globals.LexicalScope)})},
- args: [],
- source: "canInlineNonLocalReturns\x0a\x09^ self isInlined and: [ self outerScope canInlineNonLocalReturns ]",
- messageSends: ["and:", "isInlined", "canInlineNonLocalReturns", "outerScope"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instruction",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@instruction"];
- return $1;
- },
- args: [],
- source: "instruction\x0a\x09^ instruction",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instruction:",
- protocol: 'accessing',
- fn: function (anIRInstruction){
- var self=this;
- self["@instruction"]=anIRInstruction;
- return self},
- args: ["anIRInstruction"],
- source: "instruction: anIRInstruction\x0a\x09instruction := anIRInstruction",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isBlockScope",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._isMethodScope())._not();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isBlockScope",{},globals.LexicalScope)})},
- args: [],
- source: "isBlockScope\x0a\x09^ self isMethodScope not",
- messageSends: ["not", "isMethodScope"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInlined",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- $3=self._instruction();
- $ctx1.sendIdx["instruction"]=1;
- $2=_st($3)._notNil();
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._instruction())._isInlined();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isInlined",{},globals.LexicalScope)})},
- args: [],
- source: "isInlined\x0a\x09^ self instruction notNil and: [\x0a\x09\x09self instruction isInlined ]",
- messageSends: ["and:", "notNil", "instruction", "isInlined"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMethodScope",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isMethodScope\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "lookupVariable:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- var lookup;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- lookup=self._bindingFor_(aNode);
- $1=lookup;
- if(($receiver = $1) == nil || $receiver == null){
- $2=self._outerScope();
- $ctx1.sendIdx["outerScope"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- lookup=$2;
- } else {
- lookup=_st(self._outerScope())._lookupVariable_(aNode);
- };
- lookup;
- } else {
- $1;
- };
- $3=lookup;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"lookupVariable:",{aNode:aNode,lookup:lookup},globals.LexicalScope)})},
- args: ["aNode"],
- source: "lookupVariable: aNode\x0a\x09| lookup |\x0a\x09lookup := (self bindingFor: aNode).\x0a\x09lookup ifNil: [\x0a\x09\x09lookup := self outerScope ifNotNil: [\x0a\x09\x09\x09(self outerScope lookupVariable: aNode) ]].\x0a\x09^ lookup",
- messageSends: ["bindingFor:", "ifNil:", "ifNotNil:", "outerScope", "lookupVariable:"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodScope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._outerScope();
- $ctx1.sendIdx["outerScope"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $1=_st(self._outerScope())._methodScope();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"methodScope",{},globals.LexicalScope)})},
- args: [],
- source: "methodScope\x0a\x09^ self outerScope ifNotNil: [\x0a\x09\x09self outerScope methodScope ]",
- messageSends: ["ifNotNil:", "outerScope", "methodScope"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@node"];
- return $1;
- },
- args: [],
- source: "node\x0a\x09\x22Answer the node in which I am defined\x22\x0a\x09\x0a\x09^ node",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@node"]=aNode;
- return self},
- args: ["aNode"],
- source: "node: aNode\x0a\x09node := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerScope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@outerScope"];
- return $1;
- },
- args: [],
- source: "outerScope\x0a\x09^ outerScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerScope:",
- protocol: 'accessing',
- fn: function (aLexicalScope){
- var self=this;
- self["@outerScope"]=aLexicalScope;
- return self},
- args: ["aLexicalScope"],
- source: "outerScope: aLexicalScope\x0a\x09outerScope := aLexicalScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pseudoVars",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._methodScope())._pseudoVars();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},globals.LexicalScope)})},
- args: [],
- source: "pseudoVars\x0a\x09^ self methodScope pseudoVars",
- messageSends: ["pseudoVars", "methodScope"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scopeLevel",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$5;
- $1=self._outerScope();
- $ctx1.sendIdx["outerScope"]=1;
- if(($receiver = $1) == nil || $receiver == null){
- return (1);
- } else {
- $1;
- };
- $2=self._isInlined();
- if(smalltalk.assert($2)){
- $4=self._outerScope();
- $ctx1.sendIdx["outerScope"]=2;
- $3=_st($4)._scopeLevel();
- $ctx1.sendIdx["scopeLevel"]=1;
- return $3;
- };
- $5=_st(_st(self._outerScope())._scopeLevel()).__plus((1));
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"scopeLevel",{},globals.LexicalScope)})},
- args: [],
- source: "scopeLevel\x0a\x09self outerScope ifNil: [ ^ 1 ].\x0a\x09self isInlined ifTrue: [ ^ self outerScope scopeLevel ].\x0a\x09\x0a\x09^ self outerScope scopeLevel + 1",
- messageSends: ["ifNil:", "outerScope", "ifTrue:", "isInlined", "scopeLevel", "+"],
- referencedClasses: []
- }),
- globals.LexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "temps",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@temps"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@temps"]=_st($Dictionary())._new();
- $1=self["@temps"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.LexicalScope)})},
- args: [],
- source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.LexicalScope);
- smalltalk.addClass('MethodLexicalScope', globals.LexicalScope, ['iVars', 'pseudoVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
- globals.MethodLexicalScope.comment="I represent a method scope.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addIVar:",
- protocol: 'adding',
- fn: function (aString){
- var self=this;
- function $InstanceVar(){return globals.InstanceVar||(typeof InstanceVar=="undefined"?nil:InstanceVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._iVars();
- $ctx1.sendIdx["iVars"]=1;
- _st($1)._at_put_(aString,_st($InstanceVar())._on_(aString));
- _st(_st(self._iVars())._at_(aString))._scope_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"addIVar:",{aString:aString},globals.MethodLexicalScope)})},
- args: ["aString"],
- source: "addIVar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
- messageSends: ["at:put:", "iVars", "on:", "scope:", "at:"],
- referencedClasses: ["InstanceVar"]
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addNonLocalReturn:",
- protocol: 'adding',
- fn: function (aScope){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._nonLocalReturns())._add_(aScope);
- return self}, function($ctx1) {$ctx1.fill(self,"addNonLocalReturn:",{aScope:aScope},globals.MethodLexicalScope)})},
- args: ["aScope"],
- source: "addNonLocalReturn: aScope\x0a\x09self nonLocalReturns add: aScope",
- messageSends: ["add:", "nonLocalReturns"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "allVariableNames",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(globals.MethodLexicalScope.superclass.fn.prototype._allVariableNames.apply(_st(self), [])).__comma(_st(self._iVars())._keys());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},globals.MethodLexicalScope)})},
- args: [],
- source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
- messageSends: [",", "allVariableNames", "keys", "iVars"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "bindingFor:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=globals.MethodLexicalScope.superclass.fn.prototype._bindingFor_.apply(_st(self), [aNode]);
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st(self._iVars())._at_ifAbsent_(_st(aNode)._value(),(function(){
- return nil;
- }));
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aNode:aNode},globals.MethodLexicalScope)})},
- args: ["aNode"],
- source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
- messageSends: ["ifNil:", "bindingFor:", "at:ifAbsent:", "iVars", "value"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "canInlineNonLocalReturns",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "canInlineNonLocalReturns\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hasLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._localReturn();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"hasLocalReturn",{},globals.MethodLexicalScope)})},
- args: [],
- source: "hasLocalReturn\x0a\x09^ self localReturn",
- messageSends: ["localReturn"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hasNonLocalReturn",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._nonLocalReturns())._notEmpty();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"hasNonLocalReturn",{},globals.MethodLexicalScope)})},
- args: [],
- source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturns notEmpty",
- messageSends: ["notEmpty", "nonLocalReturns"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "iVars",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@iVars"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@iVars"]=_st($Dictionary())._new();
- $1=self["@iVars"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"iVars",{},globals.MethodLexicalScope)})},
- args: [],
- source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isMethodScope",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isMethodScope\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localReturn",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@localReturn"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localReturn",{},globals.MethodLexicalScope)})},
- args: [],
- source: "localReturn\x0a\x09^ localReturn ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localReturn:",
- protocol: 'accessing',
- fn: function (aBoolean){
- var self=this;
- self["@localReturn"]=aBoolean;
- return self},
- args: ["aBoolean"],
- source: "localReturn: aBoolean\x0a\x09localReturn := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "methodScope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "methodScope\x0a\x09^ self",
- messageSends: [],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nonLocalReturns",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@nonLocalReturns"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@nonLocalReturns"]=_st($OrderedCollection())._new();
- $1=self["@nonLocalReturns"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nonLocalReturns",{},globals.MethodLexicalScope)})},
- args: [],
- source: "nonLocalReturns\x0a\x09^ nonLocalReturns ifNil: [ nonLocalReturns := OrderedCollection new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pseudoVars",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $PseudoVar(){return globals.PseudoVar||(typeof PseudoVar=="undefined"?nil:PseudoVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- $1=self["@pseudoVars"];
- if(($receiver = $1) == nil || $receiver == null){
- self["@pseudoVars"]=_st($Dictionary())._new();
- self["@pseudoVars"];
- _st(_st($Smalltalk())._pseudoVariableNames())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $2=_st($PseudoVar())._on_(each);
- _st($2)._scope_(self._methodScope());
- $3=_st($2)._yourself();
- return _st(self["@pseudoVars"])._at_put_(each,$3);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- } else {
- $1;
- };
- $4=self["@pseudoVars"];
- return $4;
- }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},globals.MethodLexicalScope)})},
- args: [],
- source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
- messageSends: ["ifNil:", "new", "do:", "pseudoVariableNames", "at:put:", "scope:", "on:", "methodScope", "yourself"],
- referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar"]
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "removeNonLocalReturn:",
- protocol: 'adding',
- fn: function (aScope){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
- }));
- return self}, function($ctx1) {$ctx1.fill(self,"removeNonLocalReturn:",{aScope:aScope},globals.MethodLexicalScope)})},
- args: ["aScope"],
- source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
- messageSends: ["remove:ifAbsent:", "nonLocalReturns"],
- referencedClasses: []
- }),
- globals.MethodLexicalScope);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "unknownVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@unknownVariables"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@unknownVariables"]=_st($OrderedCollection())._new();
- $1=self["@unknownVariables"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{},globals.MethodLexicalScope)})},
- args: [],
- source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.MethodLexicalScope);
- smalltalk.addClass('ScopeVar', globals.Object, ['scope', 'name'], 'Compiler-Semantic');
- globals.ScopeVar.comment="I am an entry in a LexicalScope that gets associated with variable nodes of the same name.\x0aThere are 4 different subclasses of vars: temp vars, local vars, args, and unknown/global vars.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._name())._asVariableName();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.ScopeVar)})},
- args: [],
- source: "alias\x0a\x09^ self name asVariableName",
- messageSends: ["asVariableName", "name"],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isArgVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isArgVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClassRefVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isClassRefVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isImmutable\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInstanceVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isInstanceVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isPseudoVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isPseudoVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isTempVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isTempVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isUnknownVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isUnknownVar\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@name"];
- return $1;
- },
- args: [],
- source: "name\x0a\x09^ name",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "name:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@name"]=aString;
- return self},
- args: ["aString"],
- source: "name: aString\x0a\x09name := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@scope"];
- return $1;
- },
- args: [],
- source: "scope\x0a\x09^ scope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "scope:",
- protocol: 'accessing',
- fn: function (aScope){
- var self=this;
- self["@scope"]=aScope;
- return self},
- args: ["aScope"],
- source: "scope: aScope\x0a\x09scope := aScope",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "validateAssignment",
- protocol: 'testing',
- fn: function (){
- var self=this;
- function $InvalidAssignmentError(){return globals.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st(self._isArgVar())._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._isPseudoVar();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($1)){
- $2=_st($InvalidAssignmentError())._new();
- _st($2)._variableName_(self._name());
- $3=_st($2)._signal();
- $3;
- };
- return self}, function($ctx1) {$ctx1.fill(self,"validateAssignment",{},globals.ScopeVar)})},
- args: [],
- source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
- messageSends: ["ifTrue:", "or:", "isArgVar", "isPseudoVar", "variableName:", "new", "name", "signal"],
- referencedClasses: ["InvalidAssignmentError"]
- }),
- globals.ScopeVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._name_(aString);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{aString:aString},globals.ScopeVar.klass)})},
- args: ["aString"],
- source: "on: aString\x0a\x09^ self new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
- messageSends: ["name:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.ScopeVar.klass);
- smalltalk.addClass('AliasVar', globals.ScopeVar, ['node'], 'Compiler-Semantic');
- globals.AliasVar.comment="I am an internally defined variable by the compiler";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@node"];
- return $1;
- },
- args: [],
- source: "node\x0a\x09^ node",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AliasVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@node"]=aNode;
- return self},
- args: ["aNode"],
- source: "node: aNode\x0a\x09node := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AliasVar);
- smalltalk.addClass('ArgVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.ArgVar.comment="I am an argument of a method or block.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isArgVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isArgVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ArgVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ArgVar);
- smalltalk.addClass('ClassRefVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.ClassRefVar.comment="I am an class reference variable";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("$".__comma(self._name())).__comma("()");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.ClassRefVar)})},
- args: [],
- source: "alias\x0a\x09\x22Fixes issue #190.\x0a\x09A function is created in the method definition, answering the class or nil.\x0a\x09See JSStream >> #nextPutClassRefFunction:\x22\x0a\x09\x0a\x09^ '$', self name, '()'",
- messageSends: [",", "name"],
- referencedClasses: []
- }),
- globals.ClassRefVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isClassRefVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isClassRefVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassRefVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ClassRefVar);
- smalltalk.addClass('InstanceVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.InstanceVar.comment="I am an instance variable of a method or block.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st("self[\x22@".__comma(self._name())).__comma("\x22]");
- $ctx1.sendIdx[","]=1;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.InstanceVar)})},
- args: [],
- source: "alias\x0a\x09^ 'self[\x22@', self name, '\x22]'",
- messageSends: [",", "name"],
- referencedClasses: []
- }),
- globals.InstanceVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isInstanceVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isInstanceVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.InstanceVar);
- smalltalk.addClass('PseudoVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "alias",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._name();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.PseudoVar)})},
- args: [],
- source: "alias\x0a\x09^ self name",
- messageSends: ["name"],
- referencedClasses: []
- }),
- globals.PseudoVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isImmutable",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isImmutable\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PseudoVar);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isPseudoVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isPseudoVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.PseudoVar);
- smalltalk.addClass('TempVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.TempVar.comment="I am an temporary variable of a method or block.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isTempVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isTempVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.TempVar);
- smalltalk.addClass('UnknownVar', globals.ScopeVar, [], 'Compiler-Semantic');
- globals.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isUnknownVar",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isUnknownVar\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.UnknownVar);
- smalltalk.addClass('SemanticAnalyzer', globals.NodeVisitor, ['currentScope', 'blockIndex', 'theClass', 'classReferences', 'messageSends', 'superSends'], 'Compiler-Semantic');
- globals.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "classReferences",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Set(){return globals.Set||(typeof Set=="undefined"?nil:Set)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@classReferences"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@classReferences"]=_st($Set())._new();
- $1=self["@classReferences"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"classReferences",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Set"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "errorShadowingVariable:",
- protocol: 'error handling',
- fn: function (aString){
- var self=this;
- function $ShadowingVariableError(){return globals.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($ShadowingVariableError())._new();
- _st($1)._variableName_(aString);
- $2=_st($1)._signal();
- return self}, function($ctx1) {$ctx1.fill(self,"errorShadowingVariable:",{aString:aString},globals.SemanticAnalyzer)})},
- args: ["aString"],
- source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
- messageSends: ["variableName:", "new", "signal"],
- referencedClasses: ["ShadowingVariableError"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "errorUnknownVariable:",
- protocol: 'error handling',
- fn: function (aNode){
- var self=this;
- var identifier;
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $UnknownVariableError(){return globals.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5;
- identifier=_st(aNode)._value();
- $ctx1.sendIdx["value"]=1;
- $1=_st(_st(_st(_st($Smalltalk())._globalJsVariables())._includes_(identifier))._not())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._isVariableGloballyUndefined_(identifier);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($1)){
- $2=_st($UnknownVariableError())._new();
- $3=$2;
- $4=_st(aNode)._value();
- $ctx1.sendIdx["value"]=2;
- _st($3)._variableName_($4);
- $5=_st($2)._signal();
- $5;
- } else {
- _st(_st(_st(self["@currentScope"])._methodScope())._unknownVariables())._add_(_st(aNode)._value());
- };
- return self}, function($ctx1) {$ctx1.fill(self,"errorUnknownVariable:",{aNode:aNode,identifier:identifier},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "errorUnknownVariable: aNode\x0a\x09\x22Throw an error if the variable is undeclared in the global JS scope (i.e. window).\x0a\x09We allow all variables listed by Smalltalk>>#globalJsVariables.\x0a\x09This list includes: `jQuery`, `window`, `document`, `process` and `global`\x0a\x09for nodejs and browser environments.\x0a\x09\x0a\x09This is only to make sure compilation works on both browser-based and nodejs environments.\x0a\x09The ideal solution would be to use a pragma instead\x22\x0a\x0a\x09| identifier |\x0a\x09identifier := aNode value.\x0a\x09\x0a\x09((Smalltalk globalJsVariables includes: identifier) not\x0a\x09\x09and: [ self isVariableGloballyUndefined: identifier ])\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09UnknownVariableError new\x0a\x09\x09\x09\x09\x09variableName: aNode value;\x0a\x09\x09\x09\x09\x09signal ]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09currentScope methodScope unknownVariables add: aNode value ]",
- messageSends: ["value", "ifTrue:ifFalse:", "and:", "not", "includes:", "globalJsVariables", "isVariableGloballyUndefined:", "variableName:", "new", "signal", "add:", "unknownVariables", "methodScope"],
- referencedClasses: ["Smalltalk", "UnknownVariableError"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariableGloballyUndefined:",
- protocol: 'testing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return eval('typeof ' + aString + ' == "undefined"');
- return self}, function($ctx1) {$ctx1.fill(self,"isVariableGloballyUndefined:",{aString:aString},globals.SemanticAnalyzer)})},
- args: ["aString"],
- source: "isVariableGloballyUndefined: aString\x0a\x09<return eval('typeof ' + aString + ' == \x22undefined\x22')>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@messageSends"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@messageSends"]=_st($Dictionary())._new();
- $1=self["@messageSends"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newBlockScope",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $LexicalScope(){return globals.LexicalScope||(typeof LexicalScope=="undefined"?nil:LexicalScope)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newScopeOfClass_($LexicalScope());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newBlockScope",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
- messageSends: ["newScopeOfClass:"],
- referencedClasses: ["LexicalScope"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newMethodScope",
- protocol: 'factory',
- fn: function (){
- var self=this;
- function $MethodLexicalScope(){return globals.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._newScopeOfClass_($MethodLexicalScope());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newMethodScope",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
- messageSends: ["newScopeOfClass:"],
- referencedClasses: ["MethodLexicalScope"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newScopeOfClass:",
- protocol: 'factory',
- fn: function (aLexicalScopeClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st(aLexicalScopeClass)._new();
- _st($2)._outerScope_(self["@currentScope"]);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newScopeOfClass:",{aLexicalScopeClass:aLexicalScopeClass},globals.SemanticAnalyzer)})},
- args: ["aLexicalScopeClass"],
- source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new\x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
- messageSends: ["outerScope:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextBlockIndex",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@blockIndex"];
- if(($receiver = $1) == nil || $receiver == null){
- self["@blockIndex"]=(0);
- self["@blockIndex"];
- } else {
- $1;
- };
- self["@blockIndex"]=_st(self["@blockIndex"]).__plus((1));
- $2=self["@blockIndex"];
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"nextBlockIndex",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "nextBlockIndex\x0a\x09blockIndex ifNil: [ blockIndex := 0 ].\x0a\x09\x0a\x09blockIndex := blockIndex + 1.\x0a\x09^ blockIndex",
- messageSends: ["ifNil:", "+"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "popScope",
- protocol: 'scope',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@currentScope"];
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- self["@currentScope"]=_st(self["@currentScope"])._outerScope();
- self["@currentScope"];
- };
- return self}, function($ctx1) {$ctx1.fill(self,"popScope",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
- messageSends: ["ifNotNil:", "outerScope"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pushScope:",
- protocol: 'scope',
- fn: function (aScope){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aScope)._outerScope_(self["@currentScope"]);
- self["@currentScope"]=aScope;
- return self}, function($ctx1) {$ctx1.fill(self,"pushScope:",{aScope:aScope},globals.SemanticAnalyzer)})},
- args: ["aScope"],
- source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
- messageSends: ["outerScope:"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "superSends",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@superSends"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@superSends"]=_st($Dictionary())._new();
- $1=self["@superSends"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"superSends",{},globals.SemanticAnalyzer)})},
- args: [],
- source: "superSends\x0a\x09^ superSends ifNil: [ superSends := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@theClass"];
- return $1;
- },
- args: [],
- source: "theClass\x0a\x09^ theClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "theClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@theClass"]=aClass;
- return self},
- args: ["aClass"],
- source: "theClass: aClass\x0a\x09theClass := aClass",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "validateVariableScope:",
- protocol: 'scope',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@currentScope"])._lookupVariable_(aString);
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- self._errorShadowingVariable_(aString);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"validateVariableScope:",{aString:aString},globals.SemanticAnalyzer)})},
- args: ["aString"],
- source: "validateVariableScope: aString\x0a\x09\x22Validate the variable scope in by doing a recursive lookup, up to the method scope\x22\x0a\x0a\x09(currentScope lookupVariable: aString) ifNotNil: [\x0a\x09\x09self errorShadowingVariable: aString ]",
- messageSends: ["ifNotNil:", "lookupVariable:", "errorShadowingVariable:"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAssignmentNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- globals.SemanticAnalyzer.superclass.fn.prototype._visitAssignmentNode_.apply(_st(self), [aNode]);
- _st(_st(aNode)._left())._beAssigned();
- return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
- messageSends: ["visitAssignmentNode:", "beAssigned", "left"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._pushScope_(self._newBlockScope());
- _st(aNode)._scope_(self["@currentScope"]);
- _st(self["@currentScope"])._node_(aNode);
- _st(self["@currentScope"])._blockIndex_(self._nextBlockIndex());
- _st(_st(aNode)._parameters())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- self._validateVariableScope_(each);
- return _st(self["@currentScope"])._addArg_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- globals.SemanticAnalyzer.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
- self._popScope();
- return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09self pushScope: self newBlockScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x09currentScope blockIndex: self nextBlockIndex.\x0a\x0a\x09aNode parameters do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitBlockNode: aNode.\x0a\x09self popScope",
- messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "blockIndex:", "nextBlockIndex", "do:", "parameters", "validateVariableScope:", "addArg:", "visitBlockNode:", "popScope"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitCascadeNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- globals.SemanticAnalyzer.superclass.fn.prototype._visitCascadeNode_.apply(_st(self), [aNode]);
- $3=_st(aNode)._nodes();
- $ctx1.sendIdx["nodes"]=1;
- $2=_st($3)._first();
- $1=_st($2)._superSend();
- if(smalltalk.assert($1)){
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._superSend_(true);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitCascadeNode: aNode\x0a\x09super visitCascadeNode: aNode.\x0a\x09aNode nodes first superSend ifTrue: [\x0a\x09\x09aNode nodes do: [ :each | each superSend: true ] ]",
- messageSends: ["visitCascadeNode:", "ifTrue:", "superSend", "first", "nodes", "do:", "superSend:"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitMethodNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._pushScope_(self._newMethodScope());
- _st(aNode)._scope_(self["@currentScope"]);
- _st(self["@currentScope"])._node_(aNode);
- _st(_st(self._theClass())._allInstanceVariableNames())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@currentScope"])._addIVar_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- _st(_st(aNode)._arguments())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- self._validateVariableScope_(each);
- return _st(self["@currentScope"])._addArg_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- globals.SemanticAnalyzer.superclass.fn.prototype._visitMethodNode_.apply(_st(self), [aNode]);
- _st(aNode)._classReferences_(self._classReferences());
- _st(aNode)._sendIndexes_(self._messageSends());
- $1=_st(aNode)._superSends_(_st(self._superSends())._keys());
- self._popScope();
- return self}, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitMethodNode: aNode\x0a\x09self pushScope: self newMethodScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x0a\x09self theClass allInstanceVariableNames do: [ :each |\x0a\x09\x09currentScope addIVar: each ].\x0a\x09aNode arguments do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitMethodNode: aNode.\x0a\x0a\x09aNode\x0a\x09\x09classReferences: self classReferences;\x0a\x09\x09sendIndexes: self messageSends;\x0a\x09\x09superSends: self superSends keys.\x0a\x09self popScope",
- messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "sendIndexes:", "messageSends", "superSends:", "keys", "superSends", "popScope"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReturnNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aNode)._scope_(self["@currentScope"]);
- $1=_st(self["@currentScope"])._isMethodScope();
- if(smalltalk.assert($1)){
- _st(self["@currentScope"])._localReturn_(true);
- } else {
- _st(_st(self["@currentScope"])._methodScope())._addNonLocalReturn_(self["@currentScope"]);
- };
- globals.SemanticAnalyzer.superclass.fn.prototype._visitReturnNode_.apply(_st(self), [aNode]);
- return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09aNode scope: currentScope.\x0a\x09currentScope isMethodScope\x0a\x09\x09ifTrue: [ currentScope localReturn: true ]\x0a\x09\x09ifFalse: [ currentScope methodScope addNonLocalReturn: currentScope ].\x0a\x09super visitReturnNode: aNode",
- messageSends: ["scope:", "ifTrue:ifFalse:", "isMethodScope", "localReturn:", "addNonLocalReturn:", "methodScope", "visitReturnNode:"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $Set(){return globals.Set||(typeof Set=="undefined"?nil:Set)}
- function $IRSendInliner(){return globals.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4,$5,$6,$8,$9,$7,$11,$12,$10,$13,$14,$15,$17,$18,$16;
- $3=_st(aNode)._receiver();
- $ctx1.sendIdx["receiver"]=1;
- $2=_st($3)._value();
- $1=_st($2).__eq("super");
- if(smalltalk.assert($1)){
- _st(aNode)._superSend_(true);
- $4=_st(aNode)._receiver();
- $ctx1.sendIdx["receiver"]=2;
- _st($4)._value_("self");
- $5=self._superSends();
- $ctx1.sendIdx["superSends"]=1;
- $6=_st(aNode)._selector();
- $ctx1.sendIdx["selector"]=1;
- _st($5)._at_ifAbsentPut_($6,(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st($Set())._new();
- $ctx2.sendIdx["new"]=1;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $ctx1.sendIdx["at:ifAbsentPut:"]=1;
- $8=self._superSends();
- $9=_st(aNode)._selector();
- $ctx1.sendIdx["selector"]=2;
- $7=_st($8)._at_($9);
- $ctx1.sendIdx["at:"]=1;
- _st($7)._add_(aNode);
- $ctx1.sendIdx["add:"]=1;
- } else {
- $11=_st($IRSendInliner())._inlinedSelectors();
- $12=_st(aNode)._selector();
- $ctx1.sendIdx["selector"]=3;
- $10=_st($11)._includes_($12);
- if(smalltalk.assert($10)){
- _st(aNode)._shouldBeInlined_(true);
- $13=_st(aNode)._receiver();
- if(($receiver = $13) == nil || $receiver == null){
- $13;
- } else {
- var receiver;
- receiver=$receiver;
- _st(receiver)._shouldBeAliased_(true);
- };
- };
- };
- $14=self._messageSends();
- $ctx1.sendIdx["messageSends"]=1;
- $15=_st(aNode)._selector();
- $ctx1.sendIdx["selector"]=4;
- _st($14)._at_ifAbsentPut_($15,(function(){
- return smalltalk.withContext(function($ctx2) {
- return _st($Set())._new();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}));
- $17=self._messageSends();
- $ctx1.sendIdx["messageSends"]=2;
- $18=_st(aNode)._selector();
- $ctx1.sendIdx["selector"]=5;
- $16=_st($17)._at_($18);
- $ctx1.sendIdx["at:"]=2;
- _st($16)._add_(aNode);
- _st(aNode)._index_(_st(_st(self._messageSends())._at_(_st(aNode)._selector()))._size());
- globals.SemanticAnalyzer.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
- return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x0a\x09aNode receiver value = 'super'\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09aNode superSend: true.\x0a\x09\x09\x09aNode receiver value: 'self'.\x0a\x09\x09\x09self superSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09\x09\x09(self superSends at: aNode selector) add: aNode ]\x0a\x09\x09\x0a\x09\x09ifFalse: [ (IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true.\x0a\x09\x09\x09aNode receiver ifNotNil: [ :receiver |\x0a\x09\x09\x09\x09receiver shouldBeAliased: true ] ] ].\x0a\x0a\x09self messageSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09(self messageSends at: aNode selector) add: aNode.\x0a\x0a\x09aNode index: (self messageSends at: aNode selector) size.\x0a\x0a\x09super visitSendNode: aNode",
- messageSends: ["ifTrue:ifFalse:", "=", "value", "receiver", "superSend:", "value:", "at:ifAbsentPut:", "superSends", "selector", "new", "add:", "at:", "ifTrue:", "includes:", "inlinedSelectors", "shouldBeInlined:", "ifNotNil:", "shouldBeAliased:", "messageSends", "index:", "size", "visitSendNode:"],
- referencedClasses: ["Set", "IRSendInliner"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(aNode)._temps())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- self._validateVariableScope_(each);
- return _st(self["@currentScope"])._addTemp_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- globals.SemanticAnalyzer.superclass.fn.prototype._visitSequenceNode_.apply(_st(self), [aNode]);
- return self}, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
- messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitVariableNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var binding;
- function $ClassRefVar(){return globals.ClassRefVar||(typeof ClassRefVar=="undefined"?nil:ClassRefVar)}
- function $UnknownVar(){return globals.UnknownVar||(typeof UnknownVar=="undefined"?nil:UnknownVar)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5,$6,$7,$8,$9,$10,$11;
- binding=_st(self["@currentScope"])._lookupVariable_(aNode);
- $1=binding;
- if(($receiver = $1) == nil || $receiver == null){
- $3=_st(aNode)._value();
- $ctx1.sendIdx["value"]=1;
- $2=_st($3)._isCapitalized();
- if(smalltalk.assert($2)){
- $4=_st($ClassRefVar())._new();
- $ctx1.sendIdx["new"]=1;
- $5=$4;
- $6=_st(aNode)._value();
- $ctx1.sendIdx["value"]=2;
- _st($5)._name_($6);
- $ctx1.sendIdx["name:"]=1;
- $7=_st($4)._yourself();
- $ctx1.sendIdx["yourself"]=1;
- binding=$7;
- binding;
- $8=self._classReferences();
- $9=_st(aNode)._value();
- $ctx1.sendIdx["value"]=3;
- _st($8)._add_($9);
- } else {
- self._errorUnknownVariable_(aNode);
- $10=_st($UnknownVar())._new();
- _st($10)._name_(_st(aNode)._value());
- $11=_st($10)._yourself();
- binding=$11;
- binding;
- };
- } else {
- $1;
- };
- _st(aNode)._binding_(binding);
- return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode,binding:binding},globals.SemanticAnalyzer)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09\x22Bind a ScopeVar to aNode by doing a lookup in the current scope.\x0a\x09If no ScopeVar is found, bind a UnknowVar and throw an error.\x22\x0a\x0a\x09| binding |\x0a\x09binding := currentScope lookupVariable: aNode.\x0a\x09\x0a\x09binding ifNil: [\x0a\x09\x09aNode value isCapitalized\x0a\x09\x09\x09ifTrue: [ \x22Capital letter variables might be globals.\x22\x0a\x09\x09\x09\x09binding := ClassRefVar new name: aNode value; yourself.\x0a\x09\x09\x09\x09self classReferences add: aNode value]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09self errorUnknownVariable: aNode.\x0a\x09\x09\x09\x09binding := UnknownVar new name: aNode value; yourself ] ].\x0a\x09\x09\x0a\x09aNode binding: binding.",
- messageSends: ["lookupVariable:", "ifNil:", "ifTrue:ifFalse:", "isCapitalized", "value", "name:", "new", "yourself", "add:", "classReferences", "errorUnknownVariable:", "binding:"],
- referencedClasses: ["ClassRefVar", "UnknownVar"]
- }),
- globals.SemanticAnalyzer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._theClass_(aClass);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"on:",{aClass:aClass},globals.SemanticAnalyzer.klass)})},
- args: ["aClass"],
- source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
- messageSends: ["theClass:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.SemanticAnalyzer.klass);
- });
- define("amber_core/Compiler-Interpreter", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Methods", "amber_core/Kernel-Objects", "amber_core/Compiler-Core", "amber_core/Kernel-Exceptions", "amber_core/Compiler-AST"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('Compiler-Interpreter');
- smalltalk.packages["Compiler-Interpreter"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('AIBlockClosure', globals.BlockClosure, ['node', 'outerContext'], 'Compiler-Interpreter');
- globals.AIBlockClosure.comment="I am a special `BlockClosure` subclass used by an interpreter to interpret a block node.\x0a\x0aWhile I am polymorphic with `BlockClosure`, some methods such as `#new` will raise interpretation errors. Unlike a `BlockClosure`, my instance are not JavaScript functions.\x0a\x0aEvaluating an instance will result in interpreting the `node` instance variable (instance of `BlockNode`).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "applyTo:arguments:",
- protocol: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._interpreterError();
- return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.AIBlockClosure)})},
- args: ["anObject", "aCollection"],
- source: "applyTo: anObject arguments: aCollection\x0a\x09self interpreterError",
- messageSends: ["interpreterError"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compiledSource",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "[ AST Block closure ]";
- },
- args: [],
- source: "compiledSource\x0a\x09\x22Unlike blocks, the receiver doesn't represent a JS function\x22\x0a\x09\x0a\x09^ '[ AST Block closure ]'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currySelf",
- protocol: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._interpreterError();
- return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},globals.AIBlockClosure)})},
- args: [],
- source: "currySelf\x0a\x09self interpreterError",
- messageSends: ["interpreterError"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeWithContext:node:",
- protocol: 'initialization',
- fn: function (aContext,aNode){
- var self=this;
- self["@node"]=aNode;
- self["@outerContext"]=aContext;
- return self},
- args: ["aContext", "aNode"],
- source: "initializeWithContext: aContext node: aNode\x0a\x09node := aNode.\x0a\x09outerContext := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreterError",
- protocol: 'error handling',
- fn: function (){
- var self=this;
- function $ASTInterpreterError(){return globals.ASTInterpreterError||(typeof ASTInterpreterError=="undefined"?nil:ASTInterpreterError)}
- return smalltalk.withContext(function($ctx1) {
- _st($ASTInterpreterError())._signal_("Method cannot be interpreted by the interpreter.");
- return self}, function($ctx1) {$ctx1.fill(self,"interpreterError",{},globals.AIBlockClosure)})},
- args: [],
- source: "interpreterError\x0a\x09ASTInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
- messageSends: ["signal:"],
- referencedClasses: ["ASTInterpreterError"]
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numArgs",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self["@node"])._temps())._size();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"numArgs",{},globals.AIBlockClosure)})},
- args: [],
- source: "numArgs\x0a\x09^ node temps size",
- messageSends: ["size", "temps"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- protocol: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value",{},globals.AIBlockClosure)})},
- args: [],
- source: "value\x0a\x09^ self valueWithPossibleArguments: #()",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- protocol: 'evaluating',
- fn: function (anArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([anArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:",{anArgument:anArgument},globals.AIBlockClosure)})},
- args: ["anArgument"],
- source: "value: anArgument\x0a\x09^ self valueWithPossibleArguments: {anArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([firstArgument,secondArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},globals.AIBlockClosure)})},
- args: ["firstArgument", "secondArgument"],
- source: "value: firstArgument value: secondArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- protocol: 'evaluating',
- fn: function (firstArgument,secondArgument,thirdArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([firstArgument,secondArgument,thirdArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},globals.AIBlockClosure)})},
- args: ["firstArgument", "secondArgument", "thirdArgument"],
- source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument . thirdArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- protocol: 'evaluating',
- fn: function (aCollection){
- var self=this;
- var context,sequenceNode;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$6;
- context=_st(self["@outerContext"])._newBlockContext();
- $1=_st(_st(_st(self["@node"])._nodes())._first())._copy();
- _st($1)._parent_(nil);
- $2=_st($1)._yourself();
- sequenceNode=$2;
- _st(_st(self["@node"])._parameters())._withIndexDo_((function(each,index){
- return smalltalk.withContext(function($ctx2) {
- return _st(context)._localAt_put_(each,_st(aCollection)._at_ifAbsent_(index,(function(){
- return nil;
- })));
- }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
- $3=_st(context)._interpreter();
- $ctx1.sendIdx["interpreter"]=1;
- _st($3)._node_(_st(sequenceNode)._nextChild());
- $4=_st($3)._proceed();
- $5=_st(self["@outerContext"])._interpreter();
- $ctx1.sendIdx["interpreter"]=2;
- _st($5)._setNonLocalReturnFromContext_(context);
- $6=_st(_st(context)._interpreter())._pop();
- return $6;
- }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},globals.AIBlockClosure)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09| context sequenceNode |\x0a\x09context := outerContext newBlockContext.\x0a\x0a\x09\x22Interpret a copy of the sequence node to avoid creating a new AIBlockClosure\x22\x0a\x09sequenceNode := node nodes first copy\x0a\x09\x09parent: nil;\x0a\x09\x09yourself.\x0a\x0a\x09\x22Populate the arguments into the context locals\x22\x09\x0a\x09node parameters withIndexDo: [ :each :index |\x0a\x09\x09context localAt: each put: (aCollection at: index ifAbsent: [ nil ]) ].\x0a\x0a\x09\x22Interpret the first node of the BlockSequenceNode\x22\x0a\x09context interpreter\x0a\x09\x09node: sequenceNode nextChild;\x0a\x09\x09proceed.\x0a\x09\x09\x0a\x09outerContext interpreter\x0a\x09\x09setNonLocalReturnFromContext: context.\x0a\x09\x09\x0a\x09^ context interpreter pop",
- messageSends: ["newBlockContext", "parent:", "copy", "first", "nodes", "yourself", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "nextChild", "proceed", "setNonLocalReturnFromContext:", "pop"],
- referencedClasses: []
- }),
- globals.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "forContext:node:",
- protocol: 'instance creation',
- fn: function (aContext,aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._initializeWithContext_node_(aContext,aNode);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},globals.AIBlockClosure.klass)})},
- args: ["aContext", "aNode"],
- source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
- messageSends: ["initializeWithContext:node:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.AIBlockClosure.klass);
- smalltalk.addClass('AIContext', globals.MethodContext, ['outerContext', 'innerContext', 'pc', 'locals', 'selector', 'index', 'sendIndexes', 'evaluatedSelector', 'ast', 'interpreter'], 'Compiler-Interpreter');
- globals.AIContext.comment="I am like a `MethodContext`, used by the `ASTInterpreter`.\x0aUnlike a `MethodContext`, my instances are not read-only.\x0a\x0aWhen debugging, my instances are created by copying the current `MethodContext` (thisContext)";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._ast())._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._localAt_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.AIContext)})},
- args: [],
- source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
- messageSends: ["collect:", "arguments", "ast", "localAt:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ast",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5;
- $1=self._isBlockContext();
- if(smalltalk.assert($1)){
- $3=self._outerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $2=$3;
- } else {
- var context;
- context=$receiver;
- $2=_st(context)._ast();
- };
- return $2;
- };
- $4=self["@ast"];
- if(($receiver = $4) == nil || $receiver == null){
- self._initializeAST();
- } else {
- $4;
- };
- $5=self["@ast"];
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"ast",{},globals.AIContext)})},
- args: [],
- source: "ast\x0a\x09self isBlockContext ifTrue: [ \x0a\x09\x09^ self outerContext ifNotNil: [ :context | context ast ] ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
- messageSends: ["ifTrue:", "isBlockContext", "ifNotNil:", "outerContext", "ast", "ifNil:", "initializeAST"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluateNode:",
- protocol: 'evaluating',
- fn: function (aNode){
- var self=this;
- function $ASTInterpreter(){return globals.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($ASTInterpreter())._new();
- _st($2)._context_(self);
- _st($2)._node_(_st(aNode)._nextChild());
- _st($2)._proceed();
- $3=_st($2)._result();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"evaluateNode:",{aNode:aNode},globals.AIContext)})},
- args: ["aNode"],
- source: "evaluateNode: aNode\x0a\x09^ ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09node: aNode nextChild;\x0a\x09\x09proceed;\x0a\x09\x09result",
- messageSends: ["context:", "new", "node:", "nextChild", "proceed", "result"],
- referencedClasses: ["ASTInterpreter"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluatedSelector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@evaluatedSelector"];
- return $1;
- },
- args: [],
- source: "evaluatedSelector\x0a\x09^ evaluatedSelector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "evaluatedSelector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@evaluatedSelector"]=aString;
- return self},
- args: ["aString"],
- source: "evaluatedSelector: aString\x0a\x09evaluatedSelector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@index"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=(0);
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"index",{},globals.AIContext)})},
- args: [],
- source: "index\x0a\x09^ index ifNil: [ 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index:",
- protocol: 'accessing',
- fn: function (anInteger){
- var self=this;
- self["@index"]=anInteger;
- return self},
- args: ["anInteger"],
- source: "index: anInteger\x0a\x09index := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeAST",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $SemanticAnalyzer(){return globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._method();
- $ctx1.sendIdx["method"]=1;
- self["@ast"]=_st($1)._ast();
- _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
- return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},globals.AIContext)})},
- args: [],
- source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
- messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
- referencedClasses: ["SemanticAnalyzer"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeFromMethodContext:",
- protocol: 'initialization',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- self._evaluatedSelector_(_st(aMethodContext)._evaluatedSelector());
- self._index_(_st(aMethodContext)._index());
- self._sendIndexes_(_st(aMethodContext)._sendIndexes());
- self._receiver_(_st(aMethodContext)._receiver());
- $1=self._selector_(_st(aMethodContext)._selector());
- $2=_st(aMethodContext)._outerContext();
- $ctx1.sendIdx["outerContext"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $2;
- } else {
- var outer;
- outer=$receiver;
- $3=_st(outer)._methodContext();
- if(($receiver = $3) == nil || $receiver == null){
- $3;
- } else {
- self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
- };
- $4=_st(aMethodContext)._locals();
- $ctx1.sendIdx["locals"]=1;
- _st($4)._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._locals())._at_put_(key,value);
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)})}));
- };
- return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},globals.AIContext)})},
- args: ["aMethodContext"],
- source: "initializeFromMethodContext: aMethodContext\x0a\x0a\x09self\x0a\x09\x09evaluatedSelector: aMethodContext evaluatedSelector;\x0a\x09\x09index: aMethodContext index;\x0a\x09\x09sendIndexes: aMethodContext sendIndexes;\x0a\x09\x09receiver: aMethodContext receiver;\x0a\x09\x09selector: aMethodContext selector.\x0a\x09\x09\x0a\x09aMethodContext outerContext ifNotNil: [ :outer |\x0a\x09\x09\x22If the method context is nil, the block was defined in JS, so ignore it\x22\x0a\x09\x09outer methodContext ifNotNil: [\x0a\x09\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a\x09\x09\x09aMethodContext locals keysAndValuesDo: [ :key :value |\x0a\x09\x09\x09\x09self locals at: key put: value ] ]",
- messageSends: ["evaluatedSelector:", "evaluatedSelector", "index:", "index", "sendIndexes:", "sendIndexes", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeInterpreter",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $ASTInterpreter(){return globals.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st($ASTInterpreter())._new();
- _st($1)._context_(self);
- $2=_st($1)._yourself();
- self["@interpreter"]=$2;
- $3=self._innerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $3;
- } else {
- self._setupInterpreter_(self["@interpreter"]);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},globals.AIContext)})},
- args: [],
- source: "initializeInterpreter\x0a\x09interpreter := ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09yourself.\x0a\x09\x0a\x09self innerContext ifNotNil: [\x0a\x09\x09self setupInterpreter: interpreter ]",
- messageSends: ["context:", "new", "yourself", "ifNotNil:", "innerContext", "setupInterpreter:"],
- referencedClasses: ["ASTInterpreter"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeLocals",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- self["@locals"]=_st($Dictionary())._new();
- _st(self["@locals"])._at_put_("thisContext",self);
- return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},globals.AIContext)})},
- args: [],
- source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
- messageSends: ["new", "at:put:"],
- referencedClasses: ["Dictionary"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "innerContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@innerContext"];
- return $1;
- },
- args: [],
- source: "innerContext\x0a\x09^ innerContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "innerContext:",
- protocol: 'accessing',
- fn: function (anAIContext){
- var self=this;
- self["@innerContext"]=anAIContext;
- return self},
- args: ["anAIContext"],
- source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@interpreter"];
- if(($receiver = $1) == nil || $receiver == null){
- self._initializeInterpreter();
- } else {
- $1;
- };
- $2=self["@interpreter"];
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"interpreter",{},globals.AIContext)})},
- args: [],
- source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
- messageSends: ["ifNil:", "initializeInterpreter"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter:",
- protocol: 'interpreting',
- fn: function (anInterpreter){
- var self=this;
- self["@interpreter"]=anInterpreter;
- return self},
- args: ["anInterpreter"],
- source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._outerContext();
- if(($receiver = $2) == nil || $receiver == null){
- return $2;
- } else {
- var context;
- context=$receiver;
- return _st(context)._localAt_(aString);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},globals.AIContext)})},
- args: ["aString"],
- source: "localAt: aString\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext ifNotNil: [ :context | \x0a\x09\x09\x09context localAt: aString ] ]",
- messageSends: ["at:ifAbsent:", "locals", "ifNotNil:", "outerContext", "localAt:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:ifAbsent:",
- protocol: 'accessing',
- fn: function (aString,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._outerContext();
- if(($receiver = $2) == nil || $receiver == null){
- return _st(aBlock)._value();
- } else {
- var context;
- context=$receiver;
- return _st(context)._localAt_ifAbsent_(aString,aBlock);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localAt:ifAbsent:",{aString:aString,aBlock:aBlock},globals.AIContext)})},
- args: ["aString", "aBlock"],
- source: "localAt: aString ifAbsent: aBlock\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext \x0a\x09\x09\x09ifNotNil: [ :context | context localAt: aString ifAbsent: aBlock ]\x0a\x09\x09\x09ifNil: [ aBlock value ] ]",
- messageSends: ["at:ifAbsent:", "locals", "ifNotNil:ifNil:", "outerContext", "localAt:ifAbsent:", "value"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:put:",
- protocol: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._locals())._at_put_(aString,anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},globals.AIContext)})},
- args: ["aString", "anObject"],
- source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
- messageSends: ["at:put:", "locals"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "locals",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@locals"];
- if(($receiver = $1) == nil || $receiver == null){
- self._initializeLocals();
- } else {
- $1;
- };
- $2=self["@locals"];
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"locals",{},globals.AIContext)})},
- args: [],
- source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
- messageSends: ["ifNil:", "initializeLocals"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$5,$4,$3,$1;
- $2=self._methodContext();
- $ctx1.sendIdx["methodContext"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $5=self._methodContext();
- $ctx1.sendIdx["methodContext"]=2;
- $4=_st($5)._receiver();
- $3=_st($4)._class();
- $1=_st($3)._lookupSelector_(_st(self._methodContext())._selector());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.AIContext)})},
- args: [],
- source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
- messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newBlockContext",
- protocol: 'factory',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st(self._class())._new();
- _st($2)._outerContext_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newBlockContext",{},globals.AIContext)})},
- args: [],
- source: "newBlockContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
- messageSends: ["outerContext:", "new", "class", "yourself"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@outerContext"];
- return $1;
- },
- args: [],
- source: "outerContext\x0a\x09^ outerContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext:",
- protocol: 'accessing',
- fn: function (anAIContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self["@outerContext"]=anAIContext;
- $1=self["@outerContext"];
- if(($receiver = $1) == nil || $receiver == null){
- $1;
- } else {
- var context;
- context=$receiver;
- _st(context)._innerContext_(self);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},globals.AIContext)})},
- args: ["anAIContext"],
- source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext ifNotNil: [ :context | \x0a\x09\x09context innerContext: self ]",
- messageSends: ["ifNotNil:", "innerContext:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._localAt_("self");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.AIContext)})},
- args: [],
- source: "receiver\x0a\x09^ self localAt: 'self'",
- messageSends: ["localAt:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- protocol: 'interpreting',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._localAt_put_("self",anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},globals.AIContext)})},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
- messageSends: ["localAt:put:"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexAt:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._sendIndexes())._at_ifAbsent_(aString,(function(){
- return (0);
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aString:aString},globals.AIContext)})},
- args: ["aString"],
- source: "sendIndexAt: aString\x0a\x09^ self sendIndexes at: aString ifAbsent: [ 0 ]",
- messageSends: ["at:ifAbsent:", "sendIndexes"],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@sendIndexes"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st($Dictionary())._new();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},globals.AIContext)})},
- args: [],
- source: "sendIndexes\x0a\x09^ sendIndexes ifNil: [ Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendIndexes:",
- protocol: 'accessing',
- fn: function (aDictionary){
- var self=this;
- self["@sendIndexes"]=aDictionary;
- return self},
- args: ["aDictionary"],
- source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupInterpreter:",
- protocol: 'interpreting',
- fn: function (anInterpreter){
- var self=this;
- var currentNode;
- function $ASTPCNodeVisitor(){return globals.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$5,$4,$3;
- $1=_st($ASTPCNodeVisitor())._new();
- _st($1)._selector_(self._evaluatedSelector());
- _st($1)._context_(self);
- _st($1)._visit_(self._ast());
- $2=_st($1)._currentNode();
- currentNode=$2;
- _st(anInterpreter)._node_(currentNode);
- $5=self._innerContext();
- $ctx1.sendIdx["innerContext"]=1;
- $4=_st($5)._arguments();
- $3=_st($4)._reversed();
- _st($3)._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(anInterpreter)._push_(each);
- $ctx2.sendIdx["push:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
- return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter,currentNode:currentNode},globals.AIContext)})},
- args: ["anInterpreter"],
- source: "setupInterpreter: anInterpreter\x0a\x09| currentNode |\x0a\x09\x0a\x09\x22Retrieve the current node\x22\x0a\x09currentNode := ASTPCNodeVisitor new\x0a\x09\x09\x09selector: self evaluatedSelector;\x0a\x09\x09\x09context: self;\x0a\x09\x09\x09visit: self ast;\x0a\x09\x09\x09currentNode.\x0a\x09\x0a\x09anInterpreter node: currentNode.\x0a\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
- messageSends: ["selector:", "new", "evaluatedSelector", "context:", "visit:", "ast", "currentNode", "node:", "do:", "reversed", "arguments", "innerContext", "push:", "receiver"],
- referencedClasses: ["ASTPCNodeVisitor"]
- }),
- globals.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromMethodContext:",
- protocol: 'instance creation',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._initializeFromMethodContext_(aMethodContext);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},globals.AIContext.klass)})},
- args: ["aMethodContext"],
- source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
- messageSends: ["initializeFromMethodContext:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.AIContext.klass);
- smalltalk.addClass('ASTDebugger', globals.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
- globals.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from an `AIContext` with `ASTDebugger class >> context:`.\x0aThey hold an `AIContext` instance internally, recursive copy of the `MethodContext`.\x0a\x0a## API\x0a\x0aUse the methods of the `'stepping'` protocol to do stepping.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atEnd",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._interpreter())._atEnd();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atEnd",{},globals.ASTDebugger)})},
- args: [],
- source: "atEnd\x0a\x09^ self interpreter atEnd",
- messageSends: ["atEnd", "interpreter"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@context"];
- return $1;
- },
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- protocol: 'accessing',
- fn: function (aContext){
- var self=this;
- self["@context"]=aContext;
- return self},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._context())._interpreter();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"interpreter",{},globals.ASTDebugger)})},
- args: [],
- source: "interpreter\x0a\x09^ self context interpreter",
- messageSends: ["interpreter", "context"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._context())._method();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},globals.ASTDebugger)})},
- args: [],
- source: "method\x0a\x09^ self context method",
- messageSends: ["method", "context"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextNode",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._interpreter())._nextNode();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nextNode",{},globals.ASTDebugger)})},
- args: [],
- source: "nextNode\x0a\x09^ self interpreter nextNode",
- messageSends: ["nextNode", "interpreter"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "proceed",
- protocol: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldBeImplemented();
- return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},globals.ASTDebugger)})},
- args: [],
- source: "proceed\x0a\x09self shouldBeImplemented",
- messageSends: ["shouldBeImplemented"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "restart",
- protocol: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._interpreter())._restart();
- return self}, function($ctx1) {$ctx1.fill(self,"restart",{},globals.ASTDebugger)})},
- args: [],
- source: "restart\x0a\x09self interpreter restart",
- messageSends: ["restart", "interpreter"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "skip",
- protocol: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._interpreter())._skip();
- return self}, function($ctx1) {$ctx1.fill(self,"skip",{},globals.ASTDebugger)})},
- args: [],
- source: "skip\x0a\x09self interpreter skip",
- messageSends: ["skip", "interpreter"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepInto",
- protocol: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldBeImplemented();
- return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},globals.ASTDebugger)})},
- args: [],
- source: "stepInto\x0a\x09self shouldBeImplemented",
- messageSends: ["shouldBeImplemented"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepOver",
- protocol: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._flushOuterContexts();
- _st(self._interpreter())._stepOver();
- return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},globals.ASTDebugger)})},
- args: [],
- source: "stepOver\x0a\x09self flushOuterContexts.\x0a\x09self interpreter stepOver",
- messageSends: ["flushOuterContexts", "stepOver", "interpreter"],
- referencedClasses: []
- }),
- globals.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- protocol: 'instance creation',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._context_(aContext);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},globals.ASTDebugger.klass)})},
- args: ["aContext"],
- source: "context: aContext\x0a\x09^ self new\x0a\x09\x09context: aContext;\x0a\x09\x09yourself",
- messageSends: ["context:", "new", "yourself"],
- referencedClasses: []
- }),
- globals.ASTDebugger.klass);
- smalltalk.addClass('ASTInterpreter', globals.NodeVisitor, ['node', 'context', 'stack', 'returnValue', 'returned'], 'Compiler-Interpreter');
- globals.ASTInterpreter.comment="I visit an AST, interpreting (evaluating) nodes one after the other, using a small stack machine.\x0a\x0a## API\x0a\x0aWhile my instances should be used from within an `ASTDebugger`, which provides a more high level interface,\x0ayou can use methods from the `interpreting` protocol:\x0a\x0a- `#step` evaluates the current `node` only\x0a- `#stepOver` evaluates the AST from the current `node` up to the next stepping node (most likely the next send node)\x0a- `#proceed` evaluates eagerly the AST\x0a- `#restart` select the first node of the AST\x0a- `#skip` skips the current node, moving to the next one if any";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assign:to:",
- protocol: 'private',
- fn: function (aNode,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4;
- $1=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($1)){
- $3=self._context();
- $ctx1.sendIdx["context"]=1;
- $2=_st($3)._receiver();
- $4=_st(aNode)._value();
- $ctx1.sendIdx["value"]=1;
- _st($2)._instVarAt_put_($4,anObject);
- } else {
- _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},globals.ASTInterpreter)})},
- args: ["aNode", "anObject"],
- source: "assign: aNode to: anObject\x0a\x09aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
- messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atEnd",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._hasReturned())._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._node())._isNil();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atEnd",{},globals.ASTInterpreter)})},
- args: [],
- source: "atEnd\x0a\x09^ self hasReturned or: [ self node isNil ]",
- messageSends: ["or:", "hasReturned", "isNil", "node"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@context"];
- return $1;
- },
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- protocol: 'accessing',
- fn: function (aContext){
- var self=this;
- self["@context"]=aContext;
- return self},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- var source,function_;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4,$5;
- source=_st($String())._streamContents_((function(str){
- return smalltalk.withContext(function($ctx2) {
- _st(str)._nextPutAll_("(function(");
- $ctx2.sendIdx["nextPutAll:"]=1;
- $3=self._context();
- $ctx2.sendIdx["context"]=1;
- $2=_st($3)._locals();
- $ctx2.sendIdx["locals"]=1;
- $1=_st($2)._keys();
- _st($1)._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(str)._nextPutAll_(each);
- $ctx3.sendIdx["nextPutAll:"]=2;
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(str)._nextPutAll_(",");
- $ctx3.sendIdx["nextPutAll:"]=3;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- _st(str)._nextPutAll_("){ return (function() {");
- $ctx2.sendIdx["nextPutAll:"]=4;
- _st(str)._nextPutAll_(aString);
- $ctx2.sendIdx["nextPutAll:"]=5;
- $4=_st(str)._nextPutAll_("})() })");
- return $4;
- }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
- function_=_st(_st($Compiler())._new())._eval_(source);
- $5=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},globals.ASTInterpreter)})},
- args: ["aString"],
- source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an JS function.\x0a\x09aString is not sandboxed.\x22\x0a\x09\x0a\x09| source function |\x0a\x09\x0a\x09source := String streamContents: [ :str |\x0a\x09\x09str nextPutAll: '(function('.\x0a\x09\x09self context locals keys\x0a\x09\x09\x09do: [ :each | str nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ str nextPutAll: ',' ].\x0a\x09\x09str\x0a\x09\x09\x09nextPutAll: '){ return (function() {';\x0a\x09\x09\x09nextPutAll: aString;\x0a\x09\x09\x09nextPutAll: '})() })' ].\x0a\x09\x09\x09\x0a\x09function := Compiler new eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
- messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
- referencedClasses: ["String", "Compiler"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hasReturned",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@returned"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"hasReturned",{},globals.ASTInterpreter)})},
- args: [],
- source: "hasReturned\x0a\x09^ returned ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpret",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._visit_(self._node());
- return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},globals.ASTInterpreter)})},
- args: [],
- source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
- messageSends: ["visit:", "node"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpret:",
- protocol: 'interpreting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(aNode);
- self._interpret();
- return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
- messageSends: ["node:", "interpret"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageFromSendNode:arguments:",
- protocol: 'private',
- fn: function (aSendNode,aCollection){
- var self=this;
- function $Message(){return globals.Message||(typeof Message=="undefined"?nil:Message)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($Message())._new();
- _st($2)._selector_(_st(aSendNode)._selector());
- _st($2)._arguments_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},globals.ASTInterpreter)})},
- args: ["aSendNode", "aCollection"],
- source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
- messageSends: ["selector:", "new", "selector", "arguments:", "yourself"],
- referencedClasses: ["Message"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageNotUnderstood:receiver:",
- protocol: 'private',
- fn: function (aMessage,anObject){
- var self=this;
- function $MessageNotUnderstood(){return globals.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($MessageNotUnderstood())._new();
- _st($1)._meesage_(aMessage);
- _st($1)._receiver_(anObject);
- $2=_st($1)._signal();
- return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},globals.ASTInterpreter)})},
- args: ["aMessage", "anObject"],
- source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
- messageSends: ["meesage:", "new", "receiver:", "signal"],
- referencedClasses: ["MessageNotUnderstood"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(_st(self._node())._nextNode());
- return self}, function($ctx1) {$ctx1.fill(self,"next",{},globals.ASTInterpreter)})},
- args: [],
- source: "next\x0a\x09self node: self node nextNode",
- messageSends: ["node:", "nextNode", "node"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@node"];
- return $1;
- },
- args: [],
- source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node:",
- protocol: 'accessing',
- fn: function (aNode){
- var self=this;
- self["@node"]=aNode;
- return self},
- args: ["aNode"],
- source: "node: aNode\x0a\x09node := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "peek",
- protocol: 'stack',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- $1=self._stack();
- $ctx1.sendIdx["stack"]=1;
- _st($1)._ifEmpty_((function(){
- throw $early=[nil];
- }));
- $2=_st(self._stack())._last();
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"peek",{},globals.ASTInterpreter)})},
- args: [],
- source: "peek\x0a\x09\x22Peek the top object of the context stack\x22\x0a\x09\x0a\x09self stack ifEmpty: [ ^ nil ].\x0a\x09\x0a\x09^ self stack last",
- messageSends: ["ifEmpty:", "stack", "last"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pop",
- protocol: 'stack',
- fn: function (){
- var self=this;
- var peekedValue;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- peekedValue=self._peek();
- _st(self._stack())._removeLast();
- $1=peekedValue;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},globals.ASTInterpreter)})},
- args: [],
- source: "pop\x0a\x09\x22Pop an object from the context stack\x22\x0a\x09\x0a\x09| peekedValue |\x0a\x09\x0a\x09peekedValue := self peek.\x0a\x09self stack removeLast.\x0a\x09^ peekedValue",
- messageSends: ["peek", "removeLast", "stack"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "proceed",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._atEnd();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._step();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},globals.ASTInterpreter)})},
- args: [],
- source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] \x0a\x09\x09whileFalse: [ self step ]",
- messageSends: ["whileFalse:", "atEnd", "step"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "push:",
- protocol: 'stack',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._stack())._add_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},globals.ASTInterpreter)})},
- args: ["anObject"],
- source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
- messageSends: ["add:", "stack"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "restart",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(_st(_st(self._context())._ast())._nextChild());
- return self}, function($ctx1) {$ctx1.fill(self,"restart",{},globals.ASTInterpreter)})},
- args: [],
- source: "restart\x0a\x09self node: self context ast nextChild",
- messageSends: ["node:", "nextChild", "ast", "context"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "result",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._hasReturned();
- if(smalltalk.assert($2)){
- $1=self._returnValue();
- } else {
- $1=_st(self._context())._receiver();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"result",{},globals.ASTInterpreter)})},
- args: [],
- source: "result\x0a\x09^ self hasReturned \x0a\x09\x09ifTrue: [ self returnValue ] \x0a\x09\x09ifFalse: [ self context receiver ]",
- messageSends: ["ifTrue:ifFalse:", "hasReturned", "returnValue", "receiver", "context"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "returnValue",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@returnValue"];
- return $1;
- },
- args: [],
- source: "returnValue\x0a\x09^ returnValue",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "returnValue:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@returnValue"]=anObject;
- return self},
- args: ["anObject"],
- source: "returnValue: anObject\x0a\x09returnValue := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendMessage:to:superSend:",
- protocol: 'private',
- fn: function (aMessage,anObject,aBoolean){
- var self=this;
- var method;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5,$6;
- var $early={};
- try {
- if(! smalltalk.assert(aBoolean)){
- $1=_st(aMessage)._sendTo_(anObject);
- return $1;
- };
- $3=_st(anObject)._class();
- $ctx1.sendIdx["class"]=1;
- $2=_st($3)._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
- $ctx1.sendIdx["messageNotUnderstood:receiver:"]=1;
- return $4;
- } else {
- $2;
- };
- method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
- return smalltalk.withContext(function($ctx2) {
- $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
- throw $early=[$5];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
- return $6;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},globals.ASTInterpreter)})},
- args: ["aMessage", "anObject", "aBoolean"],
- source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method sendTo: anObject arguments: aMessage arguments",
- messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setNonLocalReturnFromContext:",
- protocol: 'interpreting',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(aContext)._interpreter();
- $ctx1.sendIdx["interpreter"]=1;
- $1=_st($2)._hasReturned();
- if(smalltalk.assert($1)){
- self["@returned"]=true;
- self["@returned"];
- self._returnValue_(_st(_st(aContext)._interpreter())._returnValue());
- };
- return self}, function($ctx1) {$ctx1.fill(self,"setNonLocalReturnFromContext:",{aContext:aContext},globals.ASTInterpreter)})},
- args: ["aContext"],
- source: "setNonLocalReturnFromContext: aContext\x0a\x09aContext interpreter hasReturned ifTrue: [\x0a\x09\x09returned := true.\x0a\x09\x09self returnValue: aContext interpreter returnValue ]",
- messageSends: ["ifTrue:", "hasReturned", "interpreter", "returnValue:", "returnValue"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "skip",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._next();
- return self}, function($ctx1) {$ctx1.fill(self,"skip",{},globals.ASTInterpreter)})},
- args: [],
- source: "skip\x0a\x09self next",
- messageSends: ["next"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stack",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@stack"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@stack"]=_st($OrderedCollection())._new();
- $1=self["@stack"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"stack",{},globals.ASTInterpreter)})},
- args: [],
- source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "step",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self._interpret();
- $1=self._next();
- return self}, function($ctx1) {$ctx1.fill(self,"step",{},globals.ASTInterpreter)})},
- args: [],
- source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
- messageSends: ["interpret", "next"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepOver",
- protocol: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._step();
- $ctx1.sendIdx["step"]=1;
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._node())._isSteppingNode();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._step();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},globals.ASTInterpreter)})},
- args: [],
- source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
- messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visit:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._hasReturned();
- if(! smalltalk.assert($1)){
- globals.ASTInterpreter.superclass.fn.prototype._visit_.apply(_st(self), [aNode]);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visit: aNode\x0a\x09self hasReturned ifFalse: [ super visit: aNode ]",
- messageSends: ["ifFalse:", "hasReturned", "visit:"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAssignmentNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var poppedValue;
- return smalltalk.withContext(function($ctx1) {
- poppedValue=self._pop();
- $ctx1.sendIdx["pop"]=1;
- self._pop();
- self._push_(poppedValue);
- self._assign_to_(_st(aNode)._left(),poppedValue);
- return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09| poppedValue |\x0a\x09\x0a\x09poppedValue := self pop.\x0a\x09\x0a\x09\x22Pop the left side of the assignment.\x0a\x09It already has been visited, and we don't need its value.\x22\x0a\x09self pop.\x0a\x09\x0a\x09self push: poppedValue.\x0a\x09self assign: aNode left to: poppedValue",
- messageSends: ["pop", "push:", "assign:to:", "left"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var block;
- function $AIBlockClosure(){return globals.AIBlockClosure||(typeof AIBlockClosure=="undefined"?nil:AIBlockClosure)}
- return smalltalk.withContext(function($ctx1) {
- block=_st($AIBlockClosure())._forContext_node_(self._context(),aNode);
- self._push_(block);
- return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09\x22Do not evaluate the block node.\x0a\x09Instead, put all instructions into a block that we push to the stack for later evaluation\x22\x0a\x09\x0a\x09| block |\x0a\x09\x0a\x09block := AIBlockClosure forContext: self context node: aNode.\x0a\x09\x0a\x09self push: block",
- messageSends: ["forContext:node:", "context", "push:"],
- referencedClasses: ["AIBlockClosure"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicArrayNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var array;
- return smalltalk.withContext(function($ctx1) {
- array=[];
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(array)._addFirst_(self._pop());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- self._push_(array);
- return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
- messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicDictionaryNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var associations,hashedCollection;
- function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- function $HashedCollection(){return globals.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- return smalltalk.withContext(function($ctx1) {
- associations=_st($OrderedCollection())._new();
- $ctx1.sendIdx["new"]=1;
- hashedCollection=_st($HashedCollection())._new();
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(associations)._add_(self._pop());
- $ctx2.sendIdx["add:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["do:"]=1;
- _st(_st(associations)._reversed())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(hashedCollection)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- self._push_(hashedCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,associations:associations,hashedCollection:hashedCollection},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitDynamicDictionaryNode: aNode\x0a\x09| associations hashedCollection |\x0a\x09\x0a\x09associations := OrderedCollection new.\x0a\x09hashedCollection := HashedCollection new.\x0a\x09\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09associations add: self pop ].\x0a\x09\x0a\x09associations reversed do: [ :each |\x0a\x09\x09hashedCollection add: each ].\x0a\x09\x0a\x09self push: hashedCollection",
- messageSends: ["new", "do:", "nodes", "add:", "pop", "reversed", "push:"],
- referencedClasses: ["OrderedCollection", "HashedCollection"]
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@returned"]=true;
- self._returnValue_(self._eval_(_st(aNode)._source()));
- return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: (self eval: aNode source)",
- messageSends: ["returnValue:", "eval:", "source"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return self},
- args: ["aNode"],
- source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReturnNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@returned"]=true;
- self._returnValue_(self._pop());
- return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: self pop",
- messageSends: ["returnValue:", "pop"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var receiver,args,message,result;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- args=_st(_st(aNode)._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._pop();
- $ctx2.sendIdx["pop"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- receiver=self._pop();
- message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
- result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
- $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(aNode)._isLastChild())._not();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- if(smalltalk.assert($1)){
- self._push_(receiver);
- $ctx1.sendIdx["push:"]=1;
- } else {
- self._push_(result);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self pop.\x0a\x09\x0a\x09message := self\x0a\x09\x09messageFromSendNode: aNode\x0a\x09\x09arguments: args reversed.\x0a\x09\x0a\x09result := self sendMessage: message to: receiver superSend: aNode superSend.\x0a\x09\x0a\x09\x22For cascade sends, push the reciever if the send is not the last one\x22\x0a\x09(aNode isCascadeSendNode and: [ aNode isLastChild not ])\x0a\x09\x09ifTrue: [ self push: receiver ]\x0a\x09\x09ifFalse: [ self push: result ]",
- messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitValueNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._push_(_st(aNode)._value());
- return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09self push: aNode value",
- messageSends: ["push:", "value"],
- referencedClasses: []
- }),
- globals.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitVariableNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$5,$6,$4,$3,$8,$10,$9,$11,$12,$13,$15,$14,$16,$17,$7;
- $2=_st(aNode)._binding();
- $ctx1.sendIdx["binding"]=1;
- $1=_st($2)._isUnknownVar();
- if(smalltalk.assert($1)){
- $5=_st($PlatformInterface())._globals();
- $ctx1.sendIdx["globals"]=1;
- $6=_st(aNode)._value();
- $ctx1.sendIdx["value"]=1;
- $4=_st($5)._at_ifAbsent_($6,(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Unknown variable");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- $ctx1.sendIdx["at:ifAbsent:"]=1;
- $3=self._push_($4);
- $ctx1.sendIdx["push:"]=1;
- return $3;
- };
- $8=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($8)){
- $10=self._context();
- $ctx1.sendIdx["context"]=1;
- $9=_st($10)._receiver();
- $11=_st(aNode)._value();
- $ctx1.sendIdx["value"]=2;
- $7=_st($9)._instVarAt_($11);
- } else {
- $12=self._context();
- $13=_st(aNode)._value();
- $ctx1.sendIdx["value"]=3;
- $7=_st($12)._localAt_ifAbsent_($13,(function(){
- return smalltalk.withContext(function($ctx2) {
- $15=_st(aNode)._value();
- $ctx2.sendIdx["value"]=4;
- $14=_st($15)._isCapitalized();
- if(smalltalk.assert($14)){
- $16=_st($Smalltalk())._globals();
- $ctx2.sendIdx["globals"]=2;
- $17=_st(aNode)._value();
- $ctx2.sendIdx["value"]=5;
- return _st($16)._at_ifAbsent_($17,(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(_st($PlatformInterface())._globals())._at_(_st(aNode)._value());
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)})}));
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
- };
- self._push_($7);
- return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},globals.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (PlatformInterface globals at: aNode value ifAbsent: [ self error: 'Unknown variable' ]) ].\x0a\x09\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context \x0a\x09\x09\x09localAt: aNode value\x0a\x09\x09\x09ifAbsent: [\x0a\x09\x09\x09\x09aNode value isCapitalized\x0a\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09Smalltalk globals \x0a\x09\x09\x09\x09\x09\x09\x09at: aNode value \x0a\x09\x09\x09\x09\x09\x09\x09ifAbsent: [ PlatformInterface globals at: aNode value ] ] ] ])",
- messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "globals", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:ifAbsent:", "isCapitalized", "at:"],
- referencedClasses: ["PlatformInterface", "Smalltalk"]
- }),
- globals.ASTInterpreter);
- smalltalk.addClass('ASTInterpreterError', globals.Error, [], 'Compiler-Interpreter');
- globals.ASTInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
- smalltalk.addClass('ASTPCNodeVisitor', globals.NodeVisitor, ['context', 'index', 'selector', 'currentNode'], 'Compiler-Interpreter');
- globals.ASTPCNodeVisitor.comment="I visit an AST until I get to the current node for the `context` and answer it.\x0a\x0a## API\x0a\x0aMy instances must be filled with a context object using `#context:`.\x0a\x0aAfter visiting the AST the current node is answered by `#currentNode`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@context"];
- return $1;
- },
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- protocol: 'accessing',
- fn: function (aContext){
- var self=this;
- self["@context"]=aContext;
- return self},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentNode",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentNode"];
- return $1;
- },
- args: [],
- source: "currentNode\x0a\x09^ currentNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "increaseIndex",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@index"]=_st(self._index()).__plus((1));
- return self}, function($ctx1) {$ctx1.fill(self,"increaseIndex",{},globals.ASTPCNodeVisitor)})},
- args: [],
- source: "increaseIndex\x0a\x09index := self index + 1",
- messageSends: ["+", "index"],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@index"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@index"]=(0);
- $1=self["@index"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"index",{},globals.ASTPCNodeVisitor)})},
- args: [],
- source: "index\x0a\x09^ index ifNil: [ index := 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@selector"];
- return $1;
- },
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@selector"]=aString;
- return self},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- self["@currentNode"]=aNode;
- return self},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09\x22If a JSStatementNode is encountered, it always is the current node.\x0a\x09Stop visiting the AST there\x22\x0a\x09\x0a\x09currentNode := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- var sendIndex;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$4,$3,$6,$5,$7;
- $1=self._context();
- $2=self._selector();
- $ctx1.sendIdx["selector"]=1;
- sendIndex=_st($1)._sendIndexAt_($2);
- globals.ASTPCNodeVisitor.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
- $4=self._selector();
- $ctx1.sendIdx["selector"]=2;
- $3=_st($4).__eq(_st(aNode)._selector());
- if(smalltalk.assert($3)){
- $6=self._index();
- $ctx1.sendIdx["index"]=1;
- $5=_st($6).__lt(sendIndex);
- if(! smalltalk.assert($5)){
- $7=_st(self._index()).__gt(sendIndex);
- if(! smalltalk.assert($7)){
- self["@currentNode"]=aNode;
- self["@currentNode"];
- };
- };
- self._increaseIndex();
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,sendIndex:sendIndex},globals.ASTPCNodeVisitor)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09| sendIndex |\x0a\x09sendIndex := self context sendIndexAt: self selector.\x0a\x09\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self selector = aNode selector ifTrue: [\x0a\x09\x09self index < sendIndex ifFalse: [ \x0a\x09\x09\x09self index > sendIndex ifFalse: [ currentNode := aNode ] ].\x0a\x09\x09self increaseIndex ]",
- messageSends: ["sendIndexAt:", "context", "selector", "visitSendNode:", "ifTrue:", "=", "ifFalse:", "<", "index", ">", "increaseIndex"],
- referencedClasses: []
- }),
- globals.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.DynamicArrayNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.DynamicDictionaryNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.JSStatementNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return false;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- protocol: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return true;
- },
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- globals.SendNode);
- });
- define("amber_vm/parser", ["./globals", "./nil"], function(globals, nil) {
- globals.SmalltalkParser = (function() {
- /*
- * Generated by PEG.js 0.8.0.
- *
- * http://pegjs.majda.cz/
- */
- function peg$subclass(child, parent) {
- function ctor() { this.constructor = child; }
- ctor.prototype = parent.prototype;
- child.prototype = new ctor();
- }
- function SyntaxError(message, expected, found, offset, line, column) {
- this.message = message;
- this.expected = expected;
- this.found = found;
- this.offset = offset;
- this.line = line;
- this.column = column;
- this.name = "SyntaxError";
- }
- peg$subclass(SyntaxError, Error);
- function parse(input) {
- var options = arguments.length > 1 ? arguments[1] : {},
- peg$FAILED = {},
- peg$startRuleFunctions = { start: peg$parsestart },
- peg$startRuleFunction = peg$parsestart,
- peg$c0 = [],
- peg$c1 = peg$FAILED,
- peg$c2 = /^[ \t\x0B\f\xA0\uFEFF\n\r\u2028\u2029]/,
- peg$c3 = { type: "class", value: "[ \\t\\x0B\\f\\xA0\\uFEFF\\n\\r\\u2028\\u2029]", description: "[ \\t\\x0B\\f\\xA0\\uFEFF\\n\\r\\u2028\\u2029]" },
- peg$c4 = /^["]/,
- peg$c5 = { type: "class", value: "[\"]", description: "[\"]" },
- peg$c6 = /^[^"]/,
- peg$c7 = { type: "class", value: "[^\"]", description: "[^\"]" },
- peg$c8 = /^[a-zA-Z]/,
- peg$c9 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" },
- peg$c10 = /^[a-zA-Z0-9]/,
- peg$c11 = { type: "class", value: "[a-zA-Z0-9]", description: "[a-zA-Z0-9]" },
- peg$c12 = function(first, others) {return first + others.join("");},
- peg$c13 = /^[:]/,
- peg$c14 = { type: "class", value: "[:]", description: "[:]" },
- peg$c15 = function(first, last) {return first + last;},
- peg$c16 = /^[a-zA-Z0-9:]/,
- peg$c17 = { type: "class", value: "[a-zA-Z0-9:]", description: "[a-zA-Z0-9:]" },
- peg$c18 = /^[A-Z]/,
- peg$c19 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
- peg$c20 = /^[']/,
- peg$c21 = { type: "class", value: "[']", description: "[']" },
- peg$c22 = "''",
- peg$c23 = { type: "literal", value: "''", description: "\"''\"" },
- peg$c24 = function() {return "'";},
- peg$c25 = /^[^']/,
- peg$c26 = { type: "class", value: "[^']", description: "[^']" },
- peg$c27 = function(val) {
- return globals.ValueNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(val.join("").replace(/\"/ig, '"'));
- },
- peg$c28 = "#",
- peg$c29 = { type: "literal", value: "#", description: "\"#\"" },
- peg$c30 = function(rest) {return rest;},
- peg$c31 = function(node) {return node._value();},
- peg$c32 = function(val) {
- return globals.ValueNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(val);
- },
- peg$c33 = function(n) {
- return globals.ValueNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(n);
- },
- peg$c34 = "e",
- peg$c35 = { type: "literal", value: "e", description: "\"e\"" },
- peg$c36 = function(n) {return parseFloat(n.join(""));},
- peg$c37 = null,
- peg$c38 = /^[\-]/,
- peg$c39 = { type: "class", value: "[\\-]", description: "[\\-]" },
- peg$c40 = "16r",
- peg$c41 = { type: "literal", value: "16r", description: "\"16r\"" },
- peg$c42 = /^[0-9a-fA-F]/,
- peg$c43 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" },
- peg$c44 = function(neg, num) {return parseInt(((neg || '') + num.join("")), 16);},
- peg$c45 = /^[0-9]/,
- peg$c46 = { type: "class", value: "[0-9]", description: "[0-9]" },
- peg$c47 = ".",
- peg$c48 = { type: "literal", value: ".", description: "\".\"" },
- peg$c49 = function(neg, digits, dec) {return parseFloat(((neg || '') + digits.join("") + "." + dec.join("")), 10);},
- peg$c50 = function(neg, digits) {return (parseInt((neg || '') +digits.join(""), 10));},
- peg$c51 = "#(",
- peg$c52 = { type: "literal", value: "#(", description: "\"#(\"" },
- peg$c53 = "(",
- peg$c54 = { type: "literal", value: "(", description: "\"(\"" },
- peg$c55 = function(lit) {return lit._value();},
- peg$c56 = ")",
- peg$c57 = { type: "literal", value: ")", description: "\")\"" },
- peg$c58 = function(lits) {
- return globals.ValueNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(lits);
- },
- peg$c59 = "{",
- peg$c60 = { type: "literal", value: "{", description: "\"{\"" },
- peg$c61 = "}",
- peg$c62 = { type: "literal", value: "}", description: "\"}\"" },
- peg$c63 = function(expressions) {
- return globals.DynamicArrayNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._nodes_(expressions || []);
- },
- peg$c64 = "#{",
- peg$c65 = { type: "literal", value: "#{", description: "\"#{\"" },
- peg$c66 = function(expressions) {
- return globals.DynamicDictionaryNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._nodes_(expressions || []);
- },
- peg$c67 = "true",
- peg$c68 = { type: "literal", value: "true", description: "\"true\"" },
- peg$c69 = function() {return true;},
- peg$c70 = "false",
- peg$c71 = { type: "literal", value: "false", description: "\"false\"" },
- peg$c72 = function() {return false;},
- peg$c73 = "nil",
- peg$c74 = { type: "literal", value: "nil", description: "\"nil\"" },
- peg$c75 = function() {return nil;},
- peg$c76 = function(val) {
- return globals.ValueNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(val);
- },
- peg$c77 = function(identifier) {
- return globals.VariableNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._value_(identifier);
- },
- peg$c78 = function(key, arg) {return {key:key, arg: arg};},
- peg$c79 = /^[\\+*\/=><,@%~|&\-]/,
- peg$c80 = { type: "class", value: "[\\\\+*\\/=><,@%~|&\\-]", description: "[\\\\+*\\/=><,@%~|&\\-]" },
- peg$c81 = function(bin) {return bin.join("");},
- peg$c82 = function(pairs) {
- var keywords = [];
- var params = [];
- var i = 0;
- for(i = 0; i < pairs.length; i++){
- keywords.push(pairs[i].key);
- }
- for(i = 0; i < pairs.length; i++){
- params.push(pairs[i].arg);
- }
- return [keywords.join(""), params];
- },
- peg$c83 = function(selector, arg) {return [selector, [arg]];},
- peg$c84 = function(selector) {return [selector, []];},
- peg$c85 = function(expression) {return expression;},
- peg$c86 = function(first, others) { return [first].concat(others); },
- peg$c87 = ":=",
- peg$c88 = { type: "literal", value: ":=", description: "\":=\"" },
- peg$c89 = function(variable, expression) {
- return globals.AssignmentNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._left_(variable)
- ._right_(expression);
- },
- peg$c90 = "^",
- peg$c91 = { type: "literal", value: "^", description: "\"^\"" },
- peg$c92 = function(expression) {
- return globals.ReturnNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._nodes_([expression]);
- },
- peg$c93 = "|",
- peg$c94 = { type: "literal", value: "|", description: "\"|\"" },
- peg$c95 = function(variable) {return variable;},
- peg$c96 = function(vars) {return vars;},
- peg$c97 = ":",
- peg$c98 = { type: "literal", value: ":", description: "\":\"" },
- peg$c99 = function(param) {return param;},
- peg$c100 = function(params) {return params;},
- peg$c101 = /^[.]/,
- peg$c102 = { type: "class", value: "[.]", description: "[.]" },
- peg$c103 = function(ret) {return [ret];},
- peg$c104 = function(exps, ret) {
- var expressions = exps;
- expressions.push(ret);
- return expressions;
- },
- peg$c105 = function(expressions) {
- return expressions || [];
- },
- peg$c106 = function(temps, statements) {
- return globals.SequenceNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._temps_(temps || [])
- ._nodes_(statements || []);
- },
- peg$c107 = "[",
- peg$c108 = { type: "literal", value: "[", description: "\"[\"" },
- peg$c109 = "]",
- peg$c110 = { type: "literal", value: "]", description: "\"]\"" },
- peg$c111 = function(params, sequence) {
- return globals.BlockNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._parameters_(params || [])
- ._nodes_([sequence._asBlockSequenceNode()]);
- },
- peg$c112 = void 0,
- peg$c113 = function(selector) {
- return globals.SendNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._selector_(selector);
- },
- peg$c114 = function(message, tail) {
- if(tail) {
- return tail._valueForReceiver_(message);
- }
- else {
- return message;
- }
- },
- peg$c115 = function(receiver, tail) {
- if(tail) {
- return tail._valueForReceiver_(receiver);
- }
- else {
- return receiver;
- }
- },
- peg$c116 = function(selector, arg) {
- return globals.SendNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._selector_(selector)
- ._arguments_([arg]);
- },
- peg$c117 = function(message, tail) {
- if(tail) {
- return tail._valueForReceiver_(message);
- }
- else {
- return message;
- }
- },
- peg$c118 = function(pair) {return pair;},
- peg$c119 = function(pairs) {
- var selector = [];
- var args = [];
- for(var i = 0; i < pairs.length; i++) {
- selector.push(pairs[i].key);
- args.push(pairs[i].arg);
- }
- return globals.SendNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._selector_(selector.join(""))
- ._arguments_(args);
- },
- peg$c120 = function(receiver, tail) {
- return tail._valueForReceiver_(receiver);
- },
- peg$c121 = ";",
- peg$c122 = { type: "literal", value: ";", description: "\";\"" },
- peg$c123 = function(mess) {return mess;},
- peg$c124 = function(send, messages) {
- var cascade = [];
- cascade.push(send);
- for(var i = 0; i < messages.length; i++) {
- cascade.push(messages[i]);
- }
- return globals.CascadeNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._receiver_(send._receiver())
- ._nodes_(cascade);
- },
- peg$c125 = "<",
- peg$c126 = { type: "literal", value: "<", description: "\"<\"" },
- peg$c127 = ">>",
- peg$c128 = { type: "literal", value: ">>", description: "\">>\"" },
- peg$c129 = function() {return ">";},
- peg$c130 = /^[^>]/,
- peg$c131 = { type: "class", value: "[^>]", description: "[^>]" },
- peg$c132 = ">",
- peg$c133 = { type: "literal", value: ">", description: "\">\"" },
- peg$c134 = function(val) {
- return globals.JSStatementNode._new()
- ._position_((line()).__at(column()))
- ._source_(val.join(""))
- },
- peg$c135 = function(pattern, sequence) {
- return globals.MethodNode._new()
- ._position_((line()).__at(column()))
- ._source_(text())
- ._selector_(pattern[0])
- ._arguments_(pattern[1])
- ._nodes_([sequence]);
- },
- peg$c136 = function(send) { return send._selector() === "->" },
- peg$c137 = function(send) { return [send._receiver(), send._arguments()[0]]; },
- peg$c138 = function(first, others) { return first.concat.apply(first, others); },
- peg$currPos = 0,
- peg$reportedPos = 0,
- peg$cachedPos = 0,
- peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
- peg$maxFailPos = 0,
- peg$maxFailExpected = [],
- peg$silentFails = 0,
- peg$cache = {},
- peg$result;
- if ("startRule" in options) {
- if (!(options.startRule in peg$startRuleFunctions)) {
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
- }
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
- }
- function text() {
- return input.substring(peg$reportedPos, peg$currPos);
- }
- function offset() {
- return peg$reportedPos;
- }
- function line() {
- return peg$computePosDetails(peg$reportedPos).line;
- }
- function column() {
- return peg$computePosDetails(peg$reportedPos).column;
- }
- function expected(description) {
- throw peg$buildException(
- null,
- [{ type: "other", description: description }],
- peg$reportedPos
- );
- }
- function error(message) {
- throw peg$buildException(message, null, peg$reportedPos);
- }
- function peg$computePosDetails(pos) {
- function advance(details, startPos, endPos) {
- var p, ch;
- for (p = startPos; p < endPos; p++) {
- ch = input.charAt(p);
- if (ch === "\n") {
- if (!details.seenCR) { details.line++; }
- details.column = 1;
- details.seenCR = false;
- } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
- details.line++;
- details.column = 1;
- details.seenCR = true;
- } else {
- details.column++;
- details.seenCR = false;
- }
- }
- }
- if (peg$cachedPos !== pos) {
- if (peg$cachedPos > pos) {
- peg$cachedPos = 0;
- peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
- }
- advance(peg$cachedPosDetails, peg$cachedPos, pos);
- peg$cachedPos = pos;
- }
- return peg$cachedPosDetails;
- }
- function peg$fail(expected) {
- if (peg$currPos < peg$maxFailPos) { return; }
- if (peg$currPos > peg$maxFailPos) {
- peg$maxFailPos = peg$currPos;
- peg$maxFailExpected = [];
- }
- peg$maxFailExpected.push(expected);
- }
- function peg$buildException(message, expected, pos) {
- function cleanupExpected(expected) {
- var i = 1;
- expected.sort(function(a, b) {
- if (a.description < b.description) {
- return -1;
- } else if (a.description > b.description) {
- return 1;
- } else {
- return 0;
- }
- });
- while (i < expected.length) {
- if (expected[i - 1] === expected[i]) {
- expected.splice(i, 1);
- } else {
- i++;
- }
- }
- }
- function buildMessage(expected, found) {
- function stringEscape(s) {
- function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
- return s
- .replace(/\\/g, '\\\\')
- .replace(/"/g, '\\"')
- .replace(/\x08/g, '\\b')
- .replace(/\t/g, '\\t')
- .replace(/\n/g, '\\n')
- .replace(/\f/g, '\\f')
- .replace(/\r/g, '\\r')
- .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
- .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
- .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
- .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
- }
- var expectedDescs = new Array(expected.length),
- expectedDesc, foundDesc, i;
- for (i = 0; i < expected.length; i++) {
- expectedDescs[i] = expected[i].description;
- }
- expectedDesc = expected.length > 1
- ? expectedDescs.slice(0, -1).join(", ")
- + " or "
- + expectedDescs[expected.length - 1]
- : expectedDescs[0];
- foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
- return "Expected " + expectedDesc + " but " + foundDesc + " found.";
- }
- var posDetails = peg$computePosDetails(pos),
- found = pos < input.length ? input.charAt(pos) : null;
- if (expected !== null) {
- cleanupExpected(expected);
- }
- return new SyntaxError(
- message !== null ? message : buildMessage(expected, found),
- expected,
- found,
- pos,
- posDetails.line,
- posDetails.column
- );
- }
- function peg$parsestart() {
- var s0;
- var key = peg$currPos * 59 + 0,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parsemethod();
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseseparator() {
- var s0, s1;
- var key = peg$currPos * 59 + 1,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = [];
- if (peg$c2.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c3); }
- }
- if (s1 !== peg$FAILED) {
- while (s1 !== peg$FAILED) {
- s0.push(s1);
- if (peg$c2.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c3); }
- }
- }
- } else {
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsecomments() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 2,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = [];
- s1 = peg$currPos;
- if (peg$c4.test(input.charAt(peg$currPos))) {
- s2 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c5); }
- }
- if (s2 !== peg$FAILED) {
- s3 = [];
- if (peg$c6.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c7); }
- }
- while (s4 !== peg$FAILED) {
- s3.push(s4);
- if (peg$c6.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c7); }
- }
- }
- if (s3 !== peg$FAILED) {
- if (peg$c4.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c5); }
- }
- if (s4 !== peg$FAILED) {
- s2 = [s2, s3, s4];
- s1 = s2;
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- if (s1 !== peg$FAILED) {
- while (s1 !== peg$FAILED) {
- s0.push(s1);
- s1 = peg$currPos;
- if (peg$c4.test(input.charAt(peg$currPos))) {
- s2 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c5); }
- }
- if (s2 !== peg$FAILED) {
- s3 = [];
- if (peg$c6.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c7); }
- }
- while (s4 !== peg$FAILED) {
- s3.push(s4);
- if (peg$c6.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c7); }
- }
- }
- if (s3 !== peg$FAILED) {
- if (peg$c4.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c5); }
- }
- if (s4 !== peg$FAILED) {
- s2 = [s2, s3, s4];
- s1 = s2;
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- }
- } else {
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsews() {
- var s0, s1;
- var key = peg$currPos * 59 + 3,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = [];
- s1 = peg$parseseparator();
- if (s1 === peg$FAILED) {
- s1 = peg$parsecomments();
- }
- while (s1 !== peg$FAILED) {
- s0.push(s1);
- s1 = peg$parseseparator();
- if (s1 === peg$FAILED) {
- s1 = peg$parsecomments();
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseidentifier() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 4,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c8.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c9); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c10.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c11); }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c10.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c11); }
- }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c12(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsekeyword() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 5,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseidentifier();
- if (s1 !== peg$FAILED) {
- if (peg$c13.test(input.charAt(peg$currPos))) {
- s2 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c14); }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c15(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseselector() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 6,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c8.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c9); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c16.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c17); }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c16.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c17); }
- }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c12(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseclassName() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 7,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c18.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c19); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c10.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c11); }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c10.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c11); }
- }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c12(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsestring() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 8,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c20.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c21); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c22) {
- s4 = peg$c22;
- peg$currPos += 2;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c23); }
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c24();
- }
- s3 = s4;
- if (s3 === peg$FAILED) {
- if (peg$c25.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c26); }
- }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c22) {
- s4 = peg$c22;
- peg$currPos += 2;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c23); }
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c24();
- }
- s3 = s4;
- if (s3 === peg$FAILED) {
- if (peg$c25.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c26); }
- }
- }
- }
- if (s2 !== peg$FAILED) {
- if (peg$c20.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c21); }
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c27(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsesymbol() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 9,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 35) {
- s1 = peg$c28;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c29); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsebareSymbol();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c30(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebareSymbol() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 10,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseselector();
- if (s1 === peg$FAILED) {
- s1 = peg$parsebinarySelector();
- if (s1 === peg$FAILED) {
- s1 = peg$currPos;
- s2 = peg$parsestring();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s1;
- s2 = peg$c31(s2);
- }
- s1 = s2;
- }
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c32(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsenumber() {
- var s0, s1;
- var key = peg$currPos * 59 + 11,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsenumberExp();
- if (s1 === peg$FAILED) {
- s1 = peg$parsehex();
- if (s1 === peg$FAILED) {
- s1 = peg$parsefloat();
- if (s1 === peg$FAILED) {
- s1 = peg$parseinteger();
- }
- }
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c33(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsenumberExp() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 12,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$currPos;
- s2 = peg$parsefloat();
- if (s2 === peg$FAILED) {
- s2 = peg$parseinteger();
- }
- if (s2 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 101) {
- s3 = peg$c34;
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c35); }
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parseinteger();
- if (s4 !== peg$FAILED) {
- s2 = [s2, s3, s4];
- s1 = s2;
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- } else {
- peg$currPos = s1;
- s1 = peg$c1;
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c36(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsehex() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 13,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c38.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c39); }
- }
- if (s1 === peg$FAILED) {
- s1 = peg$c37;
- }
- if (s1 !== peg$FAILED) {
- if (input.substr(peg$currPos, 3) === peg$c40) {
- s2 = peg$c40;
- peg$currPos += 3;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c41); }
- }
- if (s2 !== peg$FAILED) {
- s3 = [];
- if (peg$c42.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c43); }
- }
- if (s4 !== peg$FAILED) {
- while (s4 !== peg$FAILED) {
- s3.push(s4);
- if (peg$c42.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c43); }
- }
- }
- } else {
- s3 = peg$c1;
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c44(s1, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsefloat() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 14,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c38.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c39); }
- }
- if (s1 === peg$FAILED) {
- s1 = peg$c37;
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- if (s3 !== peg$FAILED) {
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- }
- } else {
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 46) {
- s3 = peg$c47;
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
- }
- if (s3 !== peg$FAILED) {
- s4 = [];
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s5 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- if (s5 !== peg$FAILED) {
- while (s5 !== peg$FAILED) {
- s4.push(s5);
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s5 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- }
- } else {
- s4 = peg$c1;
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c49(s1, s2, s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseinteger() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 15,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (peg$c38.test(input.charAt(peg$currPos))) {
- s1 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c39); }
- }
- if (s1 === peg$FAILED) {
- s1 = peg$c37;
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- if (s3 !== peg$FAILED) {
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c45.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
- }
- }
- } else {
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c50(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseliteralArray() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 16,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c51) {
- s1 = peg$c51;
- peg$currPos += 2;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c52); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parseliteralArrayRest();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c30(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebareLiteralArray() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 17,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 40) {
- s1 = peg$c53;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c54); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parseliteralArrayRest();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c30(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseliteralArrayRest() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 18,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$currPos;
- s4 = peg$parseparseTimeLiteral();
- if (s4 === peg$FAILED) {
- s4 = peg$parsebareLiteralArray();
- if (s4 === peg$FAILED) {
- s4 = peg$parsebareSymbol();
- }
- }
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c55(s4);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$currPos;
- s4 = peg$parseparseTimeLiteral();
- if (s4 === peg$FAILED) {
- s4 = peg$parsebareLiteralArray();
- if (s4 === peg$FAILED) {
- s4 = peg$parsebareSymbol();
- }
- }
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c55(s4);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- }
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 41) {
- s4 = peg$c56;
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c57); }
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c58(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsedynamicArray() {
- var s0, s1, s2, s3, s4, s5, s6;
- var key = peg$currPos * 59 + 19,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 123) {
- s1 = peg$c59;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c60); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseexpressions();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 46) {
- s5 = peg$c47;
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
- }
- if (s5 === peg$FAILED) {
- s5 = peg$c37;
- }
- if (s5 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 125) {
- s6 = peg$c61;
- peg$currPos++;
- } else {
- s6 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c62); }
- }
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c63(s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsedynamicDictionary() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 20,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c64) {
- s1 = peg$c64;
- peg$currPos += 2;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c65); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseassociations();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 125) {
- s5 = peg$c61;
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c62); }
- }
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c66(s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsepseudoVariable() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 21,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$currPos;
- if (input.substr(peg$currPos, 4) === peg$c67) {
- s2 = peg$c67;
- peg$currPos += 4;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c68); }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s1;
- s2 = peg$c69();
- }
- s1 = s2;
- if (s1 === peg$FAILED) {
- s1 = peg$currPos;
- if (input.substr(peg$currPos, 5) === peg$c70) {
- s2 = peg$c70;
- peg$currPos += 5;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c71); }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s1;
- s2 = peg$c72();
- }
- s1 = s2;
- if (s1 === peg$FAILED) {
- s1 = peg$currPos;
- if (input.substr(peg$currPos, 3) === peg$c73) {
- s2 = peg$c73;
- peg$currPos += 3;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c74); }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s1;
- s2 = peg$c75();
- }
- s1 = s2;
- }
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c76(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseparseTimeLiteral() {
- var s0;
- var key = peg$currPos * 59 + 22,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parsepseudoVariable();
- if (s0 === peg$FAILED) {
- s0 = peg$parsenumber();
- if (s0 === peg$FAILED) {
- s0 = peg$parseliteralArray();
- if (s0 === peg$FAILED) {
- s0 = peg$parsestring();
- if (s0 === peg$FAILED) {
- s0 = peg$parsesymbol();
- }
- }
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseruntimeLiteral() {
- var s0;
- var key = peg$currPos * 59 + 23,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parsedynamicDictionary();
- if (s0 === peg$FAILED) {
- s0 = peg$parsedynamicArray();
- if (s0 === peg$FAILED) {
- s0 = peg$parseblock();
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseliteral() {
- var s0;
- var key = peg$currPos * 59 + 24,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parseruntimeLiteral();
- if (s0 === peg$FAILED) {
- s0 = peg$parseparseTimeLiteral();
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsevariable() {
- var s0, s1;
- var key = peg$currPos * 59 + 25,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseidentifier();
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c77(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsekeywordPair() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 26,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsekeyword();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parsebinarySend();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c78(s1, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebinarySelector() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 27,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = [];
- if (peg$c79.test(input.charAt(peg$currPos))) {
- s2 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c80); }
- }
- if (s2 !== peg$FAILED) {
- while (s2 !== peg$FAILED) {
- s1.push(s2);
- if (peg$c79.test(input.charAt(peg$currPos))) {
- s2 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c80); }
- }
- }
- } else {
- s1 = peg$c1;
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c81(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsekeywordPattern() {
- var s0, s1, s2, s3, s4, s5, s6;
- var key = peg$currPos * 59 + 28,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = [];
- s2 = peg$currPos;
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsekeyword();
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- s6 = peg$parseidentifier();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s2;
- s3 = peg$c78(s4, s6);
- s2 = s3;
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- while (s2 !== peg$FAILED) {
- s1.push(s2);
- s2 = peg$currPos;
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsekeyword();
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- s6 = peg$parseidentifier();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s2;
- s3 = peg$c78(s4, s6);
- s2 = s3;
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- }
- } else {
- s1 = peg$c1;
- }
- if (s1 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c82(s1);
- }
- s0 = s1;
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebinaryPattern() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 29,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsebinarySelector();
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parseidentifier();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c83(s2, s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseunaryPattern() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 30,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parseidentifier();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c84(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseexpression() {
- var s0;
- var key = peg$currPos * 59 + 31,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parseassignment();
- if (s0 === peg$FAILED) {
- s0 = peg$parsecascade();
- if (s0 === peg$FAILED) {
- s0 = peg$parsekeywordSend();
- if (s0 === peg$FAILED) {
- s0 = peg$parsebinarySend();
- }
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseexpressionList() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 32,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 46) {
- s2 = peg$c47;
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
- }
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parseexpression();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c85(s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseexpressions() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 33,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseexpression();
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$parseexpressionList();
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$parseexpressionList();
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c86(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseassignment() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 34,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsevariable();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- if (input.substr(peg$currPos, 2) === peg$c87) {
- s3 = peg$c87;
- peg$currPos += 2;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c88); }
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- s5 = peg$parseexpression();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c89(s1, s5);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseret() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 35,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 94) {
- s1 = peg$c90;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c91); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseexpression();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 46) {
- s5 = peg$c47;
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
- }
- if (s5 === peg$FAILED) {
- s5 = peg$c37;
- }
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c92(s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsetemps() {
- var s0, s1, s2, s3, s4, s5, s6;
- var key = peg$currPos * 59 + 36,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 124) {
- s1 = peg$c93;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c94); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$currPos;
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- s5 = peg$parseidentifier();
- if (s5 !== peg$FAILED) {
- s6 = peg$parsews();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c95(s5);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$currPos;
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- s5 = peg$parseidentifier();
- if (s5 !== peg$FAILED) {
- s6 = peg$parsews();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c95(s5);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- }
- if (s2 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 124) {
- s3 = peg$c93;
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c94); }
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c96(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseblockParamList() {
- var s0, s1, s2, s3, s4, s5, s6;
- var key = peg$currPos * 59 + 37,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = [];
- s2 = peg$currPos;
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 58) {
- s4 = peg$c97;
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c98); }
- }
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- s6 = peg$parseidentifier();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s2;
- s3 = peg$c99(s6);
- s2 = s3;
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- while (s2 !== peg$FAILED) {
- s1.push(s2);
- s2 = peg$currPos;
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 58) {
- s4 = peg$c97;
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c98); }
- }
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- s6 = peg$parseidentifier();
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s2;
- s3 = peg$c99(s6);
- s2 = s3;
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- } else {
- peg$currPos = s2;
- s2 = peg$c1;
- }
- }
- } else {
- s1 = peg$c1;
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 124) {
- s3 = peg$c93;
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c94); }
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c100(s1);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsesubexpression() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 38,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 40) {
- s1 = peg$c53;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c54); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseexpression();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 41) {
- s5 = peg$c56;
- peg$currPos++;
- } else {
- s5 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c57); }
- }
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c85(s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsestatements() {
- var s0, s1, s2, s3, s4, s5, s6, s7;
- var key = peg$currPos * 59 + 39,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseret();
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c103(s1);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- if (s0 === peg$FAILED) {
- s0 = peg$currPos;
- s1 = peg$parseexpressions();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = [];
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- if (s4 !== peg$FAILED) {
- while (s4 !== peg$FAILED) {
- s3.push(s4);
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- }
- } else {
- s3 = peg$c1;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- s5 = peg$parseret();
- if (s5 !== peg$FAILED) {
- s6 = [];
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s7 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s7 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- while (s7 !== peg$FAILED) {
- s6.push(s7);
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s7 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s7 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- }
- if (s6 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c104(s1, s5);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- if (s0 === peg$FAILED) {
- s0 = peg$currPos;
- s1 = peg$parseexpressions();
- if (s1 === peg$FAILED) {
- s1 = peg$c37;
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- if (peg$c101.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c102); }
- }
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c105(s1);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsesequence() {
- var s0;
- var key = peg$currPos * 59 + 40,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parsejsStatement();
- if (s0 === peg$FAILED) {
- s0 = peg$parsestSequence();
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsestSequence() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 41,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsetemps();
- if (s1 === peg$FAILED) {
- s1 = peg$c37;
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parsestatements();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c106(s1, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseblock() {
- var s0, s1, s2, s3, s4, s5, s6, s7;
- var key = peg$currPos * 59 + 42,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 91) {
- s1 = peg$c107;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c108); }
- }
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseblockParamList();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- s5 = peg$parsesequence();
- if (s5 === peg$FAILED) {
- s5 = peg$c37;
- }
- if (s5 !== peg$FAILED) {
- s6 = peg$parsews();
- if (s6 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 93) {
- s7 = peg$c109;
- peg$currPos++;
- } else {
- s7 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c110); }
- }
- if (s7 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c111(s3, s5);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseoperand() {
- var s0;
- var key = peg$currPos * 59 + 43,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parseliteral();
- if (s0 === peg$FAILED) {
- s0 = peg$parsevariable();
- if (s0 === peg$FAILED) {
- s0 = peg$parsesubexpression();
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseunaryMessage() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 44,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parseidentifier();
- if (s2 !== peg$FAILED) {
- s3 = peg$currPos;
- peg$silentFails++;
- if (peg$c13.test(input.charAt(peg$currPos))) {
- s4 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c14); }
- }
- peg$silentFails--;
- if (s4 === peg$FAILED) {
- s3 = peg$c112;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c113(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseunaryTail() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 45,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseunaryMessage();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseunaryTail();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- s4 = peg$parsews();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c114(s1, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseunarySend() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 46,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseoperand();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsews();
- if (s2 !== peg$FAILED) {
- s3 = peg$parseunaryTail();
- if (s3 === peg$FAILED) {
- s3 = peg$c37;
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c115(s1, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebinaryMessage() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 47,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsebinarySelector();
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parseunarySend();
- if (s4 === peg$FAILED) {
- s4 = peg$parseoperand();
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c116(s2, s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebinaryTail() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 48,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsebinaryMessage();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsebinaryTail();
- if (s2 === peg$FAILED) {
- s2 = peg$c37;
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c117(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsebinarySend() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 49,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseunarySend();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsebinaryTail();
- if (s2 === peg$FAILED) {
- s2 = peg$c37;
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c115(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsekeywordMessage() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 50,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$currPos;
- s4 = peg$parsekeywordPair();
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c118(s4);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- if (s3 !== peg$FAILED) {
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$currPos;
- s4 = peg$parsekeywordPair();
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c118(s4);
- s3 = s4;
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- } else {
- peg$currPos = s3;
- s3 = peg$c1;
- }
- }
- } else {
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c119(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsekeywordSend() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 51,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsebinarySend();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsekeywordMessage();
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c120(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsemessage() {
- var s0;
- var key = peg$currPos * 59 + 52,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$parsebinaryMessage();
- if (s0 === peg$FAILED) {
- s0 = peg$parseunaryMessage();
- if (s0 === peg$FAILED) {
- s0 = peg$parsekeywordMessage();
- }
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsecascade() {
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
- var key = peg$currPos * 59 + 53,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsekeywordSend();
- if (s2 === peg$FAILED) {
- s2 = peg$parsebinarySend();
- }
- if (s2 !== peg$FAILED) {
- s3 = [];
- s4 = peg$currPos;
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 59) {
- s6 = peg$c121;
- peg$currPos++;
- } else {
- s6 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c122); }
- }
- if (s6 !== peg$FAILED) {
- s7 = peg$parsews();
- if (s7 !== peg$FAILED) {
- s8 = peg$parsemessage();
- if (s8 !== peg$FAILED) {
- s9 = peg$parsews();
- if (s9 !== peg$FAILED) {
- peg$reportedPos = s4;
- s5 = peg$c123(s8);
- s4 = s5;
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- if (s4 !== peg$FAILED) {
- while (s4 !== peg$FAILED) {
- s3.push(s4);
- s4 = peg$currPos;
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 59) {
- s6 = peg$c121;
- peg$currPos++;
- } else {
- s6 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c122); }
- }
- if (s6 !== peg$FAILED) {
- s7 = peg$parsews();
- if (s7 !== peg$FAILED) {
- s8 = peg$parsemessage();
- if (s8 !== peg$FAILED) {
- s9 = peg$parsews();
- if (s9 !== peg$FAILED) {
- peg$reportedPos = s4;
- s5 = peg$c123(s8);
- s4 = s5;
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- } else {
- peg$currPos = s4;
- s4 = peg$c1;
- }
- }
- } else {
- s3 = peg$c1;
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c124(s2, s3);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsejsStatement() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 54,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- if (input.charCodeAt(peg$currPos) === 60) {
- s1 = peg$c125;
- peg$currPos++;
- } else {
- s1 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c126); }
- }
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c127) {
- s4 = peg$c127;
- peg$currPos += 2;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c128); }
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c129();
- }
- s3 = s4;
- if (s3 === peg$FAILED) {
- if (peg$c130.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c131); }
- }
- }
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$currPos;
- if (input.substr(peg$currPos, 2) === peg$c127) {
- s4 = peg$c127;
- peg$currPos += 2;
- } else {
- s4 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c128); }
- }
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s3;
- s4 = peg$c129();
- }
- s3 = s4;
- if (s3 === peg$FAILED) {
- if (peg$c130.test(input.charAt(peg$currPos))) {
- s3 = input.charAt(peg$currPos);
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c131); }
- }
- }
- }
- if (s2 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 62) {
- s3 = peg$c132;
- peg$currPos++;
- } else {
- s3 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c133); }
- }
- if (s3 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c134(s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parsemethod() {
- var s0, s1, s2, s3, s4, s5;
- var key = peg$currPos * 59 + 55,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- s2 = peg$parsekeywordPattern();
- if (s2 === peg$FAILED) {
- s2 = peg$parsebinaryPattern();
- if (s2 === peg$FAILED) {
- s2 = peg$parseunaryPattern();
- }
- }
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parsesequence();
- if (s4 === peg$FAILED) {
- s4 = peg$c37;
- }
- if (s4 !== peg$FAILED) {
- s5 = peg$parsews();
- if (s5 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c135(s2, s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseassociationSend() {
- var s0, s1, s2;
- var key = peg$currPos * 59 + 56,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsebinarySend();
- if (s1 !== peg$FAILED) {
- peg$reportedPos = peg$currPos;
- s2 = peg$c136(s1);
- if (s2) {
- s2 = peg$c112;
- } else {
- s2 = peg$c1;
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c137(s1);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseassociationList() {
- var s0, s1, s2, s3, s4;
- var key = peg$currPos * 59 + 57,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parsews();
- if (s1 !== peg$FAILED) {
- if (input.charCodeAt(peg$currPos) === 46) {
- s2 = peg$c47;
- peg$currPos++;
- } else {
- s2 = peg$FAILED;
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
- }
- if (s2 !== peg$FAILED) {
- s3 = peg$parsews();
- if (s3 !== peg$FAILED) {
- s4 = peg$parseassociationSend();
- if (s4 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c85(s4);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- function peg$parseassociations() {
- var s0, s1, s2, s3;
- var key = peg$currPos * 59 + 58,
- cached = peg$cache[key];
- if (cached) {
- peg$currPos = cached.nextPos;
- return cached.result;
- }
- s0 = peg$currPos;
- s1 = peg$parseassociationSend();
- if (s1 !== peg$FAILED) {
- s2 = [];
- s3 = peg$parseassociationList();
- while (s3 !== peg$FAILED) {
- s2.push(s3);
- s3 = peg$parseassociationList();
- }
- if (s2 !== peg$FAILED) {
- peg$reportedPos = s0;
- s1 = peg$c138(s1, s2);
- s0 = s1;
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- } else {
- peg$currPos = s0;
- s0 = peg$c1;
- }
- peg$cache[key] = { nextPos: peg$currPos, result: s0 };
- return s0;
- }
- peg$result = peg$startRuleFunction();
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
- return peg$result;
- } else {
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
- peg$fail({ type: "end", description: "end of input" });
- }
- throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
- }
- }
- return {
- SyntaxError: SyntaxError,
- parse: parse
- };
- })();
- });
- define("amber_cli/AmberCli", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
- smalltalk.addPackage('AmberCli');
- smalltalk.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_cli"};
- smalltalk.addClass('AmberCli', globals.Object, [], 'AmberCli');
- globals.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0d\x0a\x0d\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0d\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0d\x0aUse `help` to get a list of all available options.\x0d\x0aAny further commandline parameters are passed to the specific program.\x0d\x0a\x0d\x0a## Commands\x0d\x0a\x0d\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0d\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0d\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commandLineSwitches",
- protocol: 'commandline',
- fn: function (){
- var self=this;
- var switches;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- switches=_st(_st(self._class())._methodsInProtocol_("commands"))._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._selector();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["collect:"]=1;
- switches=_st(switches)._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._match_("^[^:]*:$");
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- switches=_st(switches)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(_st(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
- $1=switches;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},globals.AmberCli.klass)})},
- args: [],
- source: "commandLineSwitches\x0a\x09\x22Collect all methodnames from the 'commands' protocol of the class\x0a\x09 and select the ones with only one parameter.\x0a\x09 Then remove the ':' at the end of the name.\x0a\x09 Additionally all uppercase letters are made lowercase and preceded by a '-'.\x0a\x09 Example: fallbackPage: becomes --fallback-page.\x0a\x09 Return the Array containing the commandline switches.\x22\x0a\x09| switches |\x0a\x09switches := ((self class methodsInProtocol: 'commands') collect: [ :each | each selector]).\x0a\x09switches := switches select: [ :each | each match: '^[^:]*:$'].\x0a\x09switches :=switches collect: [ :each |\x0a\x09\x09(each allButLast replace: '([A-Z])' with: '-$1') asLowercase].\x0a\x09^switches",
- messageSends: ["collect:", "methodsInProtocol:", "class", "selector", "select:", "match:", "asLowercase", "replace:with:", "allButLast"],
- referencedClasses: []
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleArguments:",
- protocol: 'commandline',
- fn: function (args){
- var self=this;
- var selector;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(args)._first();
- $ctx1.sendIdx["first"]=1;
- selector=self._selectorForCommandLineSwitch_($1);
- _st(args)._remove_(_st(args)._first());
- self._perform_withArguments_(selector,_st($Array())._with_(args));
- return self}, function($ctx1) {$ctx1.fill(self,"handleArguments:",{args:args,selector:selector},globals.AmberCli.klass)})},
- args: ["args"],
- source: "handleArguments: args\x0a\x09| selector |\x0a\x0a\x09selector := self selectorForCommandLineSwitch: (args first).\x0a\x09args remove: args first.\x0a\x09self perform: selector withArguments: (Array with: args)",
- messageSends: ["selectorForCommandLineSwitch:", "first", "remove:", "perform:withArguments:", "with:"],
- referencedClasses: ["Array"]
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "help:",
- protocol: 'commands',
- fn: function (args){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(console)._log_("Available Commands:");
- $ctx1.sendIdx["log:"]=1;
- _st(self._commandLineSwitches())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(console)._log_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"help:",{args:args},globals.AmberCli.klass)})},
- args: ["args"],
- source: "help: args\x0a\x09console log: 'Available Commands:'.\x0a\x09self commandLineSwitches do: [ :each | console log: each ]",
- messageSends: ["log:", "do:", "commandLineSwitches"],
- referencedClasses: []
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "main",
- protocol: 'startup',
- fn: function (){
- var self=this;
- var args,nodeMinorVersion;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4,$5,$6;
- $3=_st(process)._version();
- $ctx1.sendIdx["version"]=1;
- $2=_st($3)._tokenize_(".");
- $1=_st($2)._second();
- nodeMinorVersion=_st($1)._asNumber();
- $4=_st(nodeMinorVersion).__lt((8));
- if(smalltalk.assert($4)){
- _st(console)._log_("You are currently using Node.js ".__comma(_st(process)._version()));
- $ctx1.sendIdx["log:"]=1;
- _st(console)._log_("Required is at least Node.js v0.8.x or greater.");
- return (-1);
- };
- args=_st(process)._argv();
- _st(args)._removeFrom_to_((1),(2));
- $5=_st(args)._isEmpty();
- if(smalltalk.assert($5)){
- self._help_(nil);
- } else {
- $6=self._handleArguments_(args);
- return $6;
- };
- return self}, function($ctx1) {$ctx1.fill(self,"main",{args:args,nodeMinorVersion:nodeMinorVersion},globals.AmberCli.klass)})},
- args: [],
- source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09Parses commandline arguments and starts the according subprogram.\x22\x0a\x09| args nodeMinorVersion |\x0a\x0a\x09nodeMinorVersion := ((process version) tokenize: '.') second asNumber.\x0a\x09nodeMinorVersion < 8 ifTrue: [\x0a\x09\x09console log: 'You are currently using Node.js ', (process version).\x0a\x09\x09console log: 'Required is at least Node.js v0.8.x or greater.'.\x0a\x09\x09^ -1.\x0a\x09].\x0a\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 2.\x0a\x09\x0a\x09(args isEmpty)\x0a\x09\x09ifTrue: [self help: nil]\x0a\x09\x09ifFalse: [^self handleArguments: args]",
- messageSends: ["asNumber", "second", "tokenize:", "version", "ifTrue:", "<", "log:", ",", "argv", "removeFrom:to:", "ifTrue:ifFalse:", "isEmpty", "help:", "handleArguments:"],
- referencedClasses: []
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "repl:",
- protocol: 'commands',
- fn: function (args){
- var self=this;
- function $Repl(){return globals.Repl||(typeof Repl=="undefined"?nil:Repl)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($Repl())._new())._createInterface();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"repl:",{args:args},globals.AmberCli.klass)})},
- args: ["args"],
- source: "repl: args\x0a\x09^Repl new createInterface",
- messageSends: ["createInterface", "new"],
- referencedClasses: ["Repl"]
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selectorForCommandLineSwitch:",
- protocol: 'commandline',
- fn: function (aSwitch){
- var self=this;
- var command,selector;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(self._commandLineSwitches())._includes_(aSwitch);
- if(smalltalk.assert($1)){
- selector=_st(_st(aSwitch)._replace_with_("-[a-z]",(function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._second())._asUppercase();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}))).__comma(":");
- selector;
- } else {
- selector="help:";
- selector;
- };
- $2=selector;
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch,command:command,selector:selector},globals.AmberCli.klass)})},
- args: ["aSwitch"],
- source: "selectorForCommandLineSwitch: aSwitch\x0a\x09\x22Add ':' at the end and replace all occurences of a lowercase letter preceded by a '-' with the Uppercase letter.\x0a\x09 Example: fallback-page becomes fallbackPage:.\x0a\x09 If no correct selector is found return 'help:'\x22\x0a\x09 | command selector |\x0a\x0a\x09 (self commandLineSwitches includes: aSwitch)\x0a\x09 ifTrue: [ selector := (aSwitch replace: '-[a-z]' with: [ :each | each second asUppercase ]), ':']\x0a\x09 ifFalse: [ selector := 'help:' ].\x0a\x09^selector",
- messageSends: ["ifTrue:ifFalse:", "includes:", "commandLineSwitches", ",", "replace:with:", "asUppercase", "second"],
- referencedClasses: []
- }),
- globals.AmberCli.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "serve:",
- protocol: 'commands',
- fn: function (args){
- var self=this;
- function $FileServer(){return globals.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($FileServer())._createServerWithArguments_(args))._start();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"serve:",{args:args},globals.AmberCli.klass)})},
- args: ["args"],
- source: "serve: args\x0a\x09^(FileServer createServerWithArguments: args) start",
- messageSends: ["start", "createServerWithArguments:"],
- referencedClasses: ["FileServer"]
- }),
- globals.AmberCli.klass);
- smalltalk.addClass('FileServer', globals.Object, ['path', 'http', 'fs', 'url', 'host', 'port', 'basePath', 'util', 'username', 'password', 'fallbackPage'], 'AmberCli');
- globals.FileServer.comment="I am the Amber Smalltalk FileServer.\x0d\x0aMy runtime requirement is a functional Node.js executable.\x0d\x0a\x0d\x0aTo start a FileServer instance on port `4000` use the following code:\x0d\x0a\x0d\x0a FileServer new start\x0d\x0a\x0d\x0aA parameterized instance can be created with the following code:\x0d\x0a\x0d\x0a FileServer createServerWithArguments: options\x0d\x0a\x0d\x0aHere, `options` is an array of commandline style strings each followed by a value e.g. `#('--port', '6000', '--host', '0.0.0.0')`.\x0d\x0aA list of all available parameters can be printed to the commandline by passing `--help` as parameter.\x0d\x0aSee the `Options` section for further details on how options are mapped to instance methods.\x0d\x0a\x0d\x0aAfter startup FileServer checks if the directory layout required by Amber is present and logs a warning on absence.\x0d\x0a\x0d\x0a\x0d\x0a## Options\x0d\x0a\x0d\x0aEach option is of the form `--some-option-string` which is transformed into a selector of the format `someOptionString:`.\x0d\x0aThe trailing `--` gets removed, each `-[a-z]` gets transformed into the according uppercase letter, and a `:` is appended to create a selector which takes a single argument.\x0d\x0aAfterwards, the selector gets executed on the `FileServer` instance with the value following in the options array as parameter.\x0d\x0a\x0d\x0a## Adding new commandline parameters\x0d\x0a\x0d\x0aAdding new commandline parameters to `FileServer` is as easy as adding a new single parameter method to the `accessing` protocol.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "base64Decode:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return (new Buffer(aString, 'base64').toString());
- return self}, function($ctx1) {$ctx1.fill(self,"base64Decode:",{aString:aString},globals.FileServer)})},
- args: ["aString"],
- source: "base64Decode: aString\x0a\x09<return (new Buffer(aString, 'base64').toString())>",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basePath",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@basePath"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st(self._class())._defaultBasePath();
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"basePath",{},globals.FileServer)})},
- args: [],
- source: "basePath\x0a\x09^basePath ifNil: [self class defaultBasePath]",
- messageSends: ["ifNil:", "defaultBasePath", "class"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "basePath:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@basePath"]=aString;
- self._validateBasePath();
- return self}, function($ctx1) {$ctx1.fill(self,"basePath:",{aString:aString},globals.FileServer)})},
- args: ["aString"],
- source: "basePath: aString\x0a\x09basePath := aString.\x0a\x09self validateBasePath.",
- messageSends: ["validateBasePath"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "checkDirectoryLayout",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$5,$4,$2,$6;
- $1=_st(self["@fs"])._existsSync_(self._withBasePath_("index.html"));
- $ctx1.sendIdx["existsSync:"]=1;
- if(! smalltalk.assert($1)){
- _st(console)._warn_("Warning: project directory does not contain index.html.");
- $ctx1.sendIdx["warn:"]=1;
- _st(console)._warn_(" You can specify the directory containing index.html with --base-path.");
- $ctx1.sendIdx["warn:"]=2;
- _st(console)._warn_(" You can also specify a page to be served by default,");
- $ctx1.sendIdx["warn:"]=3;
- _st(console)._warn_(" for all paths that do not map to a file, with --fallback-page.");
- $ctx1.sendIdx["warn:"]=4;
- };
- $3=self["@fs"];
- $5=self._basePath();
- $ctx1.sendIdx["basePath"]=1;
- $4=_st($5).__comma("st");
- $ctx1.sendIdx[","]=1;
- $2=_st($3)._existsSync_($4);
- $ctx1.sendIdx["existsSync:"]=2;
- if(! smalltalk.assert($2)){
- _st(console)._warn_("Warning: project directory is missing an \x22st\x22 directory");
- $ctx1.sendIdx["warn:"]=5;
- };
- $6=_st(self["@fs"])._existsSync_(_st(self._basePath()).__comma("js"));
- if(! smalltalk.assert($6)){
- _st(console)._warn_("Warning: project directory is missing a \x22js\x22 directory");
- };
- return self}, function($ctx1) {$ctx1.fill(self,"checkDirectoryLayout",{},globals.FileServer)})},
- args: [],
- source: "checkDirectoryLayout\x0a\x09(fs existsSync:\x09(self withBasePath: 'index.html')) ifFalse: [\x0a\x09\x09console warn: 'Warning: project directory does not contain index.html.'.\x0a\x09\x09console warn: ' You can specify the directory containing index.html with --base-path.'.\x0a\x09\x09console warn: ' You can also specify a page to be served by default,'.\x0a\x09\x09console warn: ' for all paths that do not map to a file, with --fallback-page.'].\x0a\x09(fs existsSync: self basePath, 'st') ifFalse: [\x0a\x09\x09console warn: 'Warning: project directory is missing an \x22st\x22 directory'].\x0a\x09(fs existsSync: self basePath, 'js') ifFalse: [\x0a\x09\x09console warn: 'Warning: project directory is missing a \x22js\x22 directory'].",
- messageSends: ["ifFalse:", "existsSync:", "withBasePath:", "warn:", ",", "basePath"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fallbackPage",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@fallbackPage"];
- return $1;
- },
- args: [],
- source: "fallbackPage\x0a\x09^fallbackPage",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fallbackPage:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@fallbackPage"]=aString;
- return self},
- args: ["aString"],
- source: "fallbackPage: aString\x0a\x09fallbackPage := aString",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleGETRequest:respondTo:",
- protocol: 'request handling',
- fn: function (aRequest,aResponse){
- var self=this;
- var uri,filename;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- uri=_st(self["@url"])._parse_(_st(aRequest)._url());
- filename=_st(self["@path"])._join_with_(self._basePath(),_st(uri)._pathname());
- _st(self["@fs"])._exists_do_(filename,(function(aBoolean){
- return smalltalk.withContext(function($ctx2) {
- if(smalltalk.assert(aBoolean)){
- $1=_st(_st(self["@fs"])._statSync_(filename))._isDirectory();
- if(smalltalk.assert($1)){
- return self._respondDirectoryNamed_from_to_(filename,uri,aResponse);
- } else {
- return self._respondFileNamed_to_(filename,aResponse);
- };
- } else {
- return self._respondNotFoundTo_(aResponse);
- };
- }, function($ctx2) {$ctx2.fillBlock({aBoolean:aBoolean},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"handleGETRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,uri:uri,filename:filename},globals.FileServer)})},
- args: ["aRequest", "aResponse"],
- source: "handleGETRequest: aRequest respondTo: aResponse\x0a\x09| uri filename |\x0a\x09uri := url parse: aRequest url.\x0a\x09filename := path join: self basePath with: uri pathname.\x0a\x09fs exists: filename do: [:aBoolean |\x0a\x09\x09aBoolean\x0a\x09\x09\x09ifFalse: [self respondNotFoundTo: aResponse]\x0a\x09\x09\x09ifTrue: [(fs statSync: filename) isDirectory\x0a\x09\x09\x09\x09ifTrue: [self respondDirectoryNamed: filename from: uri to: aResponse]\x0a\x09\x09\x09\x09ifFalse: [self respondFileNamed: filename to: aResponse]]]",
- messageSends: ["parse:", "url", "join:with:", "basePath", "pathname", "exists:do:", "ifFalse:ifTrue:", "respondNotFoundTo:", "ifTrue:ifFalse:", "isDirectory", "statSync:", "respondDirectoryNamed:from:to:", "respondFileNamed:to:"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleOPTIONSRequest:respondTo:",
- protocol: 'request handling',
- fn: function (aRequest,aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(aResponse)._writeHead_options_((200),globals.HashedCollection._newFromPairs_(["Access-Control-Allow-Origin","*","Access-Control-Allow-Methods","GET, PUT, POST, DELETE, OPTIONS","Access-Control-Allow-Headers","Content-Type, Accept","Content-Length",(0),"Access-Control-Max-Age",(10)]));
- _st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"handleOPTIONSRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},globals.FileServer)})},
- args: ["aRequest", "aResponse"],
- source: "handleOPTIONSRequest: aRequest respondTo: aResponse\x0a\x09aResponse writeHead: 200 options: #{'Access-Control-Allow-Origin' -> '*'.\x0a\x09\x09\x09\x09\x09'Access-Control-Allow-Methods' -> 'GET, PUT, POST, DELETE, OPTIONS'.\x0a\x09\x09\x09\x09\x09'Access-Control-Allow-Headers' -> 'Content-Type, Accept'.\x0a\x09\x09\x09\x09\x09'Content-Length' -> 0.\x0a\x09\x09\x09\x09\x09'Access-Control-Max-Age' -> 10}.\x0a\x09aResponse end",
- messageSends: ["writeHead:options:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handlePUTRequest:respondTo:",
- protocol: 'request handling',
- fn: function (aRequest,aResponse){
- var self=this;
- var file,stream;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- $1=self._isAuthenticated_(aRequest);
- if(! smalltalk.assert($1)){
- self._respondAuthenticationRequiredTo_(aResponse);
- return nil;
- };
- file=".".__comma(_st(aRequest)._url());
- $ctx1.sendIdx[","]=1;
- stream=_st(self["@fs"])._createWriteStream_(file);
- _st(stream)._on_do_("error",(function(error){
- return smalltalk.withContext(function($ctx2) {
- $2=console;
- $3="Error creating WriteStream for file ".__comma(file);
- $ctx2.sendIdx[","]=2;
- _st($2)._warn_($3);
- $ctx2.sendIdx["warn:"]=1;
- _st(console)._warn_(" Did you forget to create the necessary js/ or st/ directory in your project?");
- $ctx2.sendIdx["warn:"]=2;
- _st(console)._warn_(" The exact error is: ".__comma(error));
- return self._respondNotCreatedTo_(aResponse);
- }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
- $ctx1.sendIdx["on:do:"]=1;
- _st(stream)._on_do_("close",(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._respondCreatedTo_(aResponse);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $ctx1.sendIdx["on:do:"]=2;
- _st(aRequest)._setEncoding_("utf8");
- _st(aRequest)._on_do_("data",(function(data){
- return smalltalk.withContext(function($ctx2) {
- return _st(stream)._write_(data);
- }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1,4)})}));
- $ctx1.sendIdx["on:do:"]=3;
- _st(aRequest)._on_do_("end",(function(){
- return smalltalk.withContext(function($ctx2) {
- $4=_st(stream)._writable();
- if(smalltalk.assert($4)){
- return _st(stream)._end();
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"handlePUTRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,file:file,stream:stream},globals.FileServer)})},
- args: ["aRequest", "aResponse"],
- source: "handlePUTRequest: aRequest respondTo: aResponse\x0a\x09| file stream |\x0a\x09(self isAuthenticated: aRequest)\x0a\x09\x09ifFalse: [self respondAuthenticationRequiredTo: aResponse. ^nil].\x0a\x0a\x09file := '.', aRequest url.\x0a\x09stream := fs createWriteStream: file.\x0a\x0a\x09stream on: 'error' do: [:error |\x0a\x09\x09console warn: 'Error creating WriteStream for file ', file.\x0a\x09\x09console warn: ' Did you forget to create the necessary js/ or st/ directory in your project?'.\x0a\x09\x09console warn: ' The exact error is: ', error.\x0a\x09\x09self respondNotCreatedTo: aResponse].\x0a\x0a\x09stream on: 'close' do: [\x0a\x09\x09self respondCreatedTo: aResponse].\x0a\x0a\x09aRequest setEncoding: 'utf8'.\x0a\x09aRequest on: 'data' do: [:data |\x0a\x09\x09stream write: data].\x0a\x0a\x09aRequest on: 'end' do: [\x0a\x09\x09stream writable ifTrue: [stream end]]",
- messageSends: ["ifFalse:", "isAuthenticated:", "respondAuthenticationRequiredTo:", ",", "url", "createWriteStream:", "on:do:", "warn:", "respondNotCreatedTo:", "respondCreatedTo:", "setEncoding:", "write:", "ifTrue:", "writable", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "handleRequest:respondTo:",
- protocol: 'request handling',
- fn: function (aRequest,aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$4,$3,$5;
- $2=_st(aRequest)._method();
- $ctx1.sendIdx["method"]=1;
- $1=_st($2).__eq("PUT");
- $ctx1.sendIdx["="]=1;
- if(smalltalk.assert($1)){
- self._handlePUTRequest_respondTo_(aRequest,aResponse);
- };
- $4=_st(aRequest)._method();
- $ctx1.sendIdx["method"]=2;
- $3=_st($4).__eq("GET");
- $ctx1.sendIdx["="]=2;
- if(smalltalk.assert($3)){
- self._handleGETRequest_respondTo_(aRequest,aResponse);
- };
- $5=_st(_st(aRequest)._method()).__eq("OPTIONS");
- if(smalltalk.assert($5)){
- self._handleOPTIONSRequest_respondTo_(aRequest,aResponse);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"handleRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},globals.FileServer)})},
- args: ["aRequest", "aResponse"],
- source: "handleRequest: aRequest respondTo: aResponse\x0a\x09aRequest method = 'PUT'\x0a\x09\x09ifTrue: [self handlePUTRequest: aRequest respondTo: aResponse].\x0a\x09aRequest method = 'GET'\x0a\x09\x09ifTrue:[self handleGETRequest: aRequest respondTo: aResponse].\x0a\x09aRequest method = 'OPTIONS'\x0a\x09\x09ifTrue:[self handleOPTIONSRequest: aRequest respondTo: aResponse]",
- messageSends: ["ifTrue:", "=", "method", "handlePUTRequest:respondTo:", "handleGETRequest:respondTo:", "handleOPTIONSRequest:respondTo:"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "host",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@host"];
- return $1;
- },
- args: [],
- source: "host\x0a\x09^host",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "host:",
- protocol: 'accessing',
- fn: function (hostname){
- var self=this;
- self["@host"]=hostname;
- return self},
- args: ["hostname"],
- source: "host: hostname\x0a\x09host := hostname",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- globals.FileServer.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@path"]=self._require_("path");
- $ctx1.sendIdx["require:"]=1;
- self["@http"]=self._require_("http");
- $ctx1.sendIdx["require:"]=2;
- self["@fs"]=self._require_("fs");
- $ctx1.sendIdx["require:"]=3;
- self["@util"]=self._require_("util");
- $ctx1.sendIdx["require:"]=4;
- self["@url"]=self._require_("url");
- $1=self._class();
- $ctx1.sendIdx["class"]=1;
- self["@host"]=_st($1)._defaultHost();
- self["@port"]=_st(self._class())._defaultPort();
- self["@username"]=nil;
- self["@password"]=nil;
- self["@fallbackPage"]=nil;
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.FileServer)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09path := self require: 'path'.\x0a\x09http := self require: 'http'.\x0a\x09fs := self require: 'fs'.\x0a\x09util := self require: 'util'.\x0a\x09url := self require: 'url'.\x0a\x09host := self class defaultHost.\x0a\x09port := self class defaultPort.\x0a\x09username := nil.\x0a\x09password := nil.\x0a\x09fallbackPage := nil.",
- messageSends: ["initialize", "require:", "defaultHost", "class", "defaultPort"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isAuthenticated:",
- protocol: 'private',
- fn: function (aRequest){
- var self=this;
- var header,token,auth,parts;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4,$5,$6,$9,$10,$8,$7;
- $2=_st(self["@username"])._isNil();
- $ctx1.sendIdx["isNil"]=1;
- $1=_st($2)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@password"])._isNil();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["and:"]=1;
- if(smalltalk.assert($1)){
- return true;
- };
- $3=_st(_st(aRequest)._headers())._at_("authorization");
- $ctx1.sendIdx["at:"]=1;
- if(($receiver = $3) == nil || $receiver == null){
- header="";
- } else {
- header=$3;
- };
- $4=_st(header)._isEmpty();
- if(smalltalk.assert($4)){
- return false;
- } else {
- $5=_st(header)._tokenize_(" ");
- $ctx1.sendIdx["tokenize:"]=1;
- if(($receiver = $5) == nil || $receiver == null){
- token="";
- } else {
- token=$5;
- };
- token;
- $6=_st(token)._at_((2));
- $ctx1.sendIdx["at:"]=2;
- auth=self._base64Decode_($6);
- auth;
- parts=_st(auth)._tokenize_(":");
- parts;
- $9=self["@username"];
- $10=_st(parts)._at_((1));
- $ctx1.sendIdx["at:"]=3;
- $8=_st($9).__eq($10);
- $ctx1.sendIdx["="]=1;
- $7=_st($8)._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@password"]).__eq(_st(parts)._at_((2)));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})}));
- if(smalltalk.assert($7)){
- return true;
- } else {
- return false;
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"isAuthenticated:",{aRequest:aRequest,header:header,token:token,auth:auth,parts:parts},globals.FileServer)})},
- args: ["aRequest"],
- source: "isAuthenticated: aRequest\x0a\x09\x22Basic HTTP Auth: http://stackoverflow.com/a/5957629/293175\x0a\x09 and https://gist.github.com/1686663\x22\x0a\x09| header token auth parts|\x0a\x0a\x09(username isNil and: [password isNil]) ifTrue: [^true].\x0a\x0a\x09\x22get authentication header\x22\x0a\x09header := (aRequest headers at: 'authorization') ifNil:[''].\x0a\x09(header isEmpty)\x0a\x09ifTrue: [^false]\x0a\x09ifFalse: [\x0a\x09\x09\x22get authentication token\x22\x0a\x09\x09token := (header tokenize: ' ') ifNil:[''].\x0a\x09\x09\x22convert back from base64\x22\x0a\x09\x09auth := self base64Decode: (token at: 2).\x0a\x09\x09\x22split token at colon\x22\x0a\x09\x09parts := auth tokenize: ':'.\x0a\x0a\x09\x09((username = (parts at: 1)) and: [password = (parts at: 2)])\x0a\x09\x09\x09ifTrue: [^true]\x0a\x09\x09\x09ifFalse: [^false]\x0a\x09].",
- messageSends: ["ifTrue:", "and:", "isNil", "ifNil:", "at:", "headers", "ifTrue:ifFalse:", "isEmpty", "tokenize:", "base64Decode:", "="],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "password:",
- protocol: 'accessing',
- fn: function (aPassword){
- var self=this;
- self["@password"]=aPassword;
- return self},
- args: ["aPassword"],
- source: "password: aPassword\x0a\x09password := aPassword.",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "port",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@port"];
- return $1;
- },
- args: [],
- source: "port\x0a\x09^port",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "port:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- self["@port"]=aNumber;
- return self},
- args: ["aNumber"],
- source: "port: aNumber\x0a\x09port := aNumber",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "require:",
- protocol: 'private',
- fn: function (aModuleString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(require)._value_(aModuleString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"require:",{aModuleString:aModuleString},globals.FileServer)})},
- args: ["aModuleString"],
- source: "require: aModuleString\x0a\x09\x22call to the require function\x22\x0a\x09^require value: aModuleString",
- messageSends: ["value:"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondAuthenticationRequiredTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((401),globals.HashedCollection._newFromPairs_(["WWW-Authenticate","Basic realm=\x22Secured Developer Area\x22"]));
- _st(aResponse)._write_("<html><body>Authentication needed</body></html>");
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondAuthenticationRequiredTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondAuthenticationRequiredTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 401 options: #{'WWW-Authenticate' -> 'Basic realm=\x22Secured Developer Area\x22'};\x0a\x09\x09write: '<html><body>Authentication needed</body></html>';\x0a\x09\x09end.",
- messageSends: ["writeHead:options:", "write:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondCreatedTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((201),globals.HashedCollection._newFromPairs_(["Content-Type","text/plain","Access-Control-Allow-Origin","*"]));
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondCreatedTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondCreatedTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 201 options: #{'Content-Type' -> 'text/plain'. 'Access-Control-Allow-Origin' -> '*'};\x0a\x09\x09end.",
- messageSends: ["writeHead:options:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondDirectoryNamed:from:to:",
- protocol: 'request handling',
- fn: function (aDirname,aUrl,aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$5,$7,$6,$4;
- $2=_st(aUrl)._pathname();
- $ctx1.sendIdx["pathname"]=1;
- $1=_st($2)._endsWith_("/");
- if(smalltalk.assert($1)){
- $3=_st(aDirname).__comma("index.html");
- $ctx1.sendIdx[","]=1;
- self._respondFileNamed_to_($3,aResponse);
- } else {
- $5=_st(_st(aUrl)._pathname()).__comma("/");
- $7=_st(aUrl)._search();
- if(($receiver = $7) == nil || $receiver == null){
- $6="";
- } else {
- $6=$7;
- };
- $4=_st($5).__comma($6);
- $ctx1.sendIdx[","]=2;
- self._respondRedirect_to_($4,aResponse);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"respondDirectoryNamed:from:to:",{aDirname:aDirname,aUrl:aUrl,aResponse:aResponse},globals.FileServer)})},
- args: ["aDirname", "aUrl", "aResponse"],
- source: "respondDirectoryNamed: aDirname from: aUrl to: aResponse\x0a\x09(aUrl pathname endsWith: '/')\x0a\x09\x09ifTrue: [self respondFileNamed: aDirname, 'index.html' to: aResponse]\x0a\x09\x09ifFalse: [self respondRedirect: aUrl pathname, '/', (aUrl search ifNil: ['']) to: aResponse]",
- messageSends: ["ifTrue:ifFalse:", "endsWith:", "pathname", "respondFileNamed:to:", ",", "respondRedirect:to:", "ifNil:", "search"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondFileNamed:to:",
- protocol: 'request handling',
- fn: function (aFilename,aResponse){
- var self=this;
- var type,filename;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5;
- filename=aFilename;
- _st(self["@fs"])._readFile_do_(filename,(function(ex,file){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(ex)._notNil();
- if(smalltalk.assert($1)){
- $2=console;
- $3=_st(filename).__comma(" does not exist");
- $ctx2.sendIdx[","]=1;
- _st($2)._log_($3);
- return self._respondNotFoundTo_(aResponse);
- } else {
- type=_st(self._class())._mimeTypeFor_(filename);
- type;
- $4=_st(type).__eq("application/javascript");
- if(smalltalk.assert($4)){
- type=_st(type).__comma(";charset=utf-8");
- type;
- };
- _st(aResponse)._writeHead_options_((200),globals.HashedCollection._newFromPairs_(["Content-Type",type]));
- _st(aResponse)._write_encoding_(file,"binary");
- $5=_st(aResponse)._end();
- return $5;
- };
- }, function($ctx2) {$ctx2.fillBlock({ex:ex,file:file},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"respondFileNamed:to:",{aFilename:aFilename,aResponse:aResponse,type:type,filename:filename},globals.FileServer)})},
- args: ["aFilename", "aResponse"],
- source: "respondFileNamed: aFilename to: aResponse\x0a\x09| type filename |\x0a\x0a\x09filename := aFilename.\x0a\x0a\x09fs readFile: filename do: [:ex :file |\x0a\x09\x09ex notNil \x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09console log: filename, ' does not exist'.\x0a\x09\x09\x09\x09self respondNotFoundTo: aResponse]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09type := self class mimeTypeFor: filename.\x0a\x09\x09\x09\x09type = 'application/javascript'\x0a\x09\x09\x09\x09\x09ifTrue: [ type:=type,';charset=utf-8' ].\x0a\x09\x09\x09\x09aResponse \x0a\x09\x09\x09\x09\x09writeHead: 200 options: #{'Content-Type' -> type};\x0a\x09\x09\x09\x09\x09write: file encoding: 'binary';\x0a\x09\x09\x09\x09\x09end]]",
- messageSends: ["readFile:do:", "ifTrue:ifFalse:", "notNil", "log:", ",", "respondNotFoundTo:", "mimeTypeFor:", "class", "ifTrue:", "=", "writeHead:options:", "write:encoding:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondInternalErrorTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((500),globals.HashedCollection._newFromPairs_(["Content-Type","text/plain"]));
- _st(aResponse)._write_("500 Internal server error");
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondInternalErrorTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondInternalErrorTo: aResponse\x0a\x09aResponse \x0a\x09\x09writeHead: 500 options: #{'Content-Type' -> 'text/plain'};\x0a\x09\x09write: '500 Internal server error';\x0a\x09\x09end",
- messageSends: ["writeHead:options:", "write:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondNotCreatedTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((400),globals.HashedCollection._newFromPairs_(["Content-Type","text/plain"]));
- _st(aResponse)._write_("File could not be created. Did you forget to create the st/js directories on the server?");
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondNotCreatedTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondNotCreatedTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 400 options: #{'Content-Type' -> 'text/plain'};\x0a\x09\x09write: 'File could not be created. Did you forget to create the st/js directories on the server?';\x0a\x09\x09end.",
- messageSends: ["writeHead:options:", "write:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondNotFoundTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1,$3,$4;
- $2=self._fallbackPage();
- $ctx1.sendIdx["fallbackPage"]=1;
- $1=_st($2)._isNil();
- if(! smalltalk.assert($1)){
- $3=self._respondFileNamed_to_(self._fallbackPage(),aResponse);
- return $3;
- };
- _st(aResponse)._writeHead_options_((404),globals.HashedCollection._newFromPairs_(["Content-Type","text/html"]));
- _st(aResponse)._write_("<html><body><p>404 Not found</p>");
- $ctx1.sendIdx["write:"]=1;
- _st(aResponse)._write_("<p>Did you forget to put an index.html file into the directory which is served by \x22bin/amber serve\x22? To solve this you can:<ul>");
- $ctx1.sendIdx["write:"]=2;
- _st(aResponse)._write_("<li>create an index.html in the served directory.</li>");
- $ctx1.sendIdx["write:"]=3;
- _st(aResponse)._write_("<li>can also specify the location of a page to be served whenever path does not resolve to a file with the \x22--fallback-page\x22 option.</li>");
- $ctx1.sendIdx["write:"]=4;
- _st(aResponse)._write_("<li>change the directory to be served with the \x22--base-path\x22 option.</li>");
- $ctx1.sendIdx["write:"]=5;
- _st(aResponse)._write_("</ul></p></body></html>");
- $4=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondNotFoundTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondNotFoundTo: aResponse\x0a\x09self fallbackPage isNil ifFalse: [^self respondFileNamed: self fallbackPage to: aResponse].\x0a\x09aResponse \x0a\x09\x09writeHead: 404 options: #{'Content-Type' -> 'text/html'};\x0a\x09\x09write: '<html><body><p>404 Not found</p>';\x0a\x09\x09write: '<p>Did you forget to put an index.html file into the directory which is served by \x22bin/amber serve\x22? To solve this you can:<ul>';\x0a\x09\x09write: '<li>create an index.html in the served directory.</li>';\x0a\x09\x09write: '<li>can also specify the location of a page to be served whenever path does not resolve to a file with the \x22--fallback-page\x22 option.</li>';\x0a\x09\x09write: '<li>change the directory to be served with the \x22--base-path\x22 option.</li>';\x0a\x09\x09write: '</ul></p></body></html>';\x0a\x09\x09end",
- messageSends: ["ifFalse:", "isNil", "fallbackPage", "respondFileNamed:to:", "writeHead:options:", "write:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondOKTo:",
- protocol: 'request handling',
- fn: function (aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((200),globals.HashedCollection._newFromPairs_(["Content-Type","text/plain","Access-Control-Allow-Origin","*"]));
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondOKTo:",{aResponse:aResponse},globals.FileServer)})},
- args: ["aResponse"],
- source: "respondOKTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 200 options: #{'Content-Type' -> 'text/plain'. 'Access-Control-Allow-Origin' -> '*'};\x0a\x09\x09end.",
- messageSends: ["writeHead:options:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "respondRedirect:to:",
- protocol: 'request handling',
- fn: function (aString,aResponse){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- _st(aResponse)._writeHead_options_((303),globals.HashedCollection._newFromPairs_(["Location",aString]));
- $1=_st(aResponse)._end();
- return self}, function($ctx1) {$ctx1.fill(self,"respondRedirect:to:",{aString:aString,aResponse:aResponse},globals.FileServer)})},
- args: ["aString", "aResponse"],
- source: "respondRedirect: aString to: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 303 options: #{'Location' -> aString};\x0a\x09\x09end.",
- messageSends: ["writeHead:options:", "end"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "start",
- protocol: 'starting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$8,$7,$6,$10,$9,$5,$11;
- self._checkDirectoryLayout();
- $1=_st(self["@http"])._createServer_((function(request,response){
- return smalltalk.withContext(function($ctx2) {
- return self._handleRequest_respondTo_(request,response);
- }, function($ctx2) {$ctx2.fillBlock({request:request,response:response},$ctx1,1)})}));
- _st($1)._on_do_("error",(function(error){
- return smalltalk.withContext(function($ctx2) {
- $2=console;
- $3="Error starting server: ".__comma(error);
- $ctx2.sendIdx[","]=1;
- return _st($2)._log_($3);
- $ctx2.sendIdx["log:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
- $ctx1.sendIdx["on:do:"]=1;
- _st($1)._on_do_("listening",(function(){
- return smalltalk.withContext(function($ctx2) {
- $4=console;
- $8=self._host();
- $ctx2.sendIdx["host"]=1;
- $7="Starting file server on http://".__comma($8);
- $6=_st($7).__comma(":");
- $ctx2.sendIdx[","]=3;
- $10=self._port();
- $ctx2.sendIdx["port"]=1;
- $9=_st($10)._asString();
- $5=_st($6).__comma($9);
- $ctx2.sendIdx[","]=2;
- return _st($4)._log_($5);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $11=_st($1)._listen_host_(self._port(),self._host());
- return self}, function($ctx1) {$ctx1.fill(self,"start",{},globals.FileServer)})},
- args: [],
- source: "start\x0a\x09\x22Checks if required directory layout is present (issue warning if not).\x0a\x09 Afterwards start the server.\x22\x0a\x09self checkDirectoryLayout.\x0a\x09(http createServer: [:request :response |\x0a\x09 self handleRequest: request respondTo: response])\x0a\x09 on: 'error' do: [:error | console log: 'Error starting server: ', error];\x0a\x09 on: 'listening' do: [console log: 'Starting file server on http://', self host, ':', self port asString];\x0a\x09 listen: self port host: self host.",
- messageSends: ["checkDirectoryLayout", "on:do:", "createServer:", "handleRequest:respondTo:", "log:", ",", "host", "asString", "port", "listen:host:"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "startOn:",
- protocol: 'starting',
- fn: function (aPort){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._port_(aPort);
- self._start();
- return self}, function($ctx1) {$ctx1.fill(self,"startOn:",{aPort:aPort},globals.FileServer)})},
- args: ["aPort"],
- source: "startOn: aPort\x0a\x09self port: aPort.\x0a\x09self start",
- messageSends: ["port:", "start"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "username:",
- protocol: 'accessing',
- fn: function (aUsername){
- var self=this;
- self["@username"]=aUsername;
- return self},
- args: ["aUsername"],
- source: "username: aUsername\x0a\x09username := aUsername.",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "validateBasePath",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$7,$6,$5,$8,$9;
- $1=self["@fs"];
- $2=self._basePath();
- $ctx1.sendIdx["basePath"]=1;
- _st($1)._stat_then_($2,(function(err,stat){
- return smalltalk.withContext(function($ctx2) {
- if(($receiver = err) == nil || $receiver == null){
- $3=_st(stat)._isDirectory();
- if(! smalltalk.assert($3)){
- $4=console;
- $7=self._basePath();
- $ctx2.sendIdx["basePath"]=2;
- $6="Warning: --base-path parameter ".__comma($7);
- $ctx2.sendIdx[","]=2;
- $5=_st($6).__comma(" is not a directory.");
- $ctx2.sendIdx[","]=1;
- return _st($4)._warn_($5);
- $ctx2.sendIdx["warn:"]=1;
- };
- } else {
- $8=console;
- $9=_st("Warning: path at --base-path parameter ".__comma(self._basePath())).__comma(" does not exist.");
- $ctx2.sendIdx[","]=3;
- return _st($8)._warn_($9);
- };
- }, function($ctx2) {$ctx2.fillBlock({err:err,stat:stat},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"validateBasePath",{},globals.FileServer)})},
- args: [],
- source: "validateBasePath\x0a\x09\x22The basePath must be an existing directory. \x22\x0a\x09fs stat: self basePath then: [ :err :stat | err\x0a\x09\x09ifNil: [ stat isDirectory ifFalse: [ console warn: 'Warning: --base-path parameter ' , self basePath , ' is not a directory.' ]]\x0a\x09\x09ifNotNil: [ console warn: 'Warning: path at --base-path parameter ' , self basePath , ' does not exist.' ]].",
- messageSends: ["stat:then:", "basePath", "ifNil:ifNotNil:", "ifFalse:", "isDirectory", "warn:", ","],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "withBasePath:",
- protocol: 'private',
- fn: function (aBaseRelativePath){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self["@path"])._join_with_(self._basePath(),aBaseRelativePath);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"withBasePath:",{aBaseRelativePath:aBaseRelativePath},globals.FileServer)})},
- args: ["aBaseRelativePath"],
- source: "withBasePath: aBaseRelativePath\x0a\x09\x22return a file path which is relative to the basePath.\x22\x0a\x09^\x09path join: self basePath with: aBaseRelativePath",
- messageSends: ["join:with:", "basePath"],
- referencedClasses: []
- }),
- globals.FileServer);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "writeData:toFileNamed:",
- protocol: 'private',
- fn: function (data,aFilename){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(console)._log_(aFilename);
- return self}, function($ctx1) {$ctx1.fill(self,"writeData:toFileNamed:",{data:data,aFilename:aFilename},globals.FileServer)})},
- args: ["data", "aFilename"],
- source: "writeData: data toFileNamed: aFilename\x0a\x09console log: aFilename",
- messageSends: ["log:"],
- referencedClasses: []
- }),
- globals.FileServer);
- globals.FileServer.klass.iVarNames = ['mimeTypes'];
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commandLineSwitches",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var switches;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- switches=_st(self._methodsInProtocol_("accessing"))._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._selector();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["collect:"]=1;
- switches=_st(switches)._select_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(each)._match_("^[^:]*:$");
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- switches=_st(switches)._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(_st(_st(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase())._replace_with_("^([a-z])","--$1");
- $ctx2.sendIdx["replace:with:"]=1;
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
- $1=switches;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},globals.FileServer.klass)})},
- args: [],
- source: "commandLineSwitches\x0a\x09\x22Collect all methodnames from the 'accessing' protocol\x0a\x09 and select the ones with only one parameter.\x0a\x09 Then remove the ':' at the end of the name\x0a\x09 and add a '--' at the beginning.\x0a\x09 Additionally all uppercase letters are made lowercase and preceded by a '-'.\x0a\x09 Example: fallbackPage: becomes --fallback-page.\x0a\x09 Return the Array containing the commandline switches.\x22\x0a\x09| switches |\x0a\x09switches := ((self methodsInProtocol: 'accessing') collect: [ :each | each selector]).\x0a\x09switches := switches select: [ :each | each match: '^[^:]*:$'].\x0a\x09switches :=switches collect: [ :each |\x0a\x09\x09(each allButLast replace: '([A-Z])' with: '-$1') asLowercase replace: '^([a-z])' with: '--$1' ].\x0a\x09^switches",
- messageSends: ["collect:", "methodsInProtocol:", "selector", "select:", "match:", "replace:with:", "asLowercase", "allButLast"],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "createServerWithArguments:",
- protocol: 'initialization',
- fn: function (options){
- var self=this;
- var server,popFront,front,optionName,optionValue,switches;
- function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11;
- var $early={};
- try {
- switches=self._commandLineSwitches();
- server=self._new();
- _st(options)._ifEmpty_((function(){
- $1=server;
- throw $early=[$1];
- }));
- $2=_st(_st(options)._size())._even();
- if(! smalltalk.assert($2)){
- _st(console)._log_("Using default parameters.");
- $ctx1.sendIdx["log:"]=1;
- $3=console;
- $4="Wrong commandline options or not enough arguments for: ".__comma(options);
- $ctx1.sendIdx[","]=1;
- _st($3)._log_($4);
- $ctx1.sendIdx["log:"]=2;
- $5=console;
- $6="Use any of the following ones: ".__comma(switches);
- $ctx1.sendIdx[","]=2;
- _st($5)._log_($6);
- $ctx1.sendIdx["log:"]=3;
- $7=server;
- return $7;
- };
- popFront=(function(args){
- return smalltalk.withContext(function($ctx2) {
- front=_st(args)._first();
- front;
- _st(args)._remove_(front);
- return front;
- }, function($ctx2) {$ctx2.fillBlock({args:args},$ctx1,3)})});
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(options)._notEmpty();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}))._whileTrue_((function(){
- return smalltalk.withContext(function($ctx2) {
- optionName=_st(popFront)._value_(options);
- $ctx2.sendIdx["value:"]=1;
- optionName;
- optionValue=_st(popFront)._value_(options);
- optionValue;
- $8=_st(switches)._includes_(optionName);
- if(smalltalk.assert($8)){
- optionName=self._selectorForCommandLineSwitch_(optionName);
- optionName;
- return _st(server)._perform_withArguments_(optionName,_st($Array())._with_(optionValue));
- } else {
- $9=console;
- $10=_st(optionName).__comma(" is not a valid commandline option");
- $ctx2.sendIdx[","]=3;
- _st($9)._log_($10);
- $ctx2.sendIdx["log:"]=4;
- return _st(console)._log_("Use any of the following ones: ".__comma(switches));
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
- $11=server;
- return $11;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"createServerWithArguments:",{options:options,server:server,popFront:popFront,front:front,optionName:optionName,optionValue:optionValue,switches:switches},globals.FileServer.klass)})},
- args: ["options"],
- source: "createServerWithArguments: options\x0a\x09\x22If options are empty return a default FileServer instance.\x0a\x09 If options are given loop through them and set the passed in values\x0a\x09 on the FileServer instance.\x0a\x09 \x0a\x09 Commanline options map directly to methods in the 'accessing' protocol\x0a\x09 taking one parameter.\x0a\x09 Adding a method to this protocol makes it directly settable through\x0a\x09 command line options.\x0a\x09 \x22\x0a\x09| server popFront front optionName optionValue switches |\x0a\x0a\x09switches := self commandLineSwitches.\x0a\x0a\x09server := self new.\x0a\x0a\x09options ifEmpty: [^server].\x0a\x0a\x09(options size even) ifFalse: [\x0a\x09\x09console log: 'Using default parameters.'.\x0a\x09\x09console log: 'Wrong commandline options or not enough arguments for: ' , options.\x0a\x09\x09console log: 'Use any of the following ones: ', switches.\x0a\x09\x09^server].\x0a\x0a\x09popFront := [:args |\x0a\x09\x09front := args first.\x0a\x09\x09args remove: front.\x0a\x09\x09front].\x0a\x0a\x09[options notEmpty] whileTrue: [\x0a\x09\x09optionName := popFront value: options.\x0a\x09\x09optionValue := popFront value: options.\x0a\x0a\x09\x09(switches includes: optionName) ifTrue: [\x0a\x09\x09\x09optionName := self selectorForCommandLineSwitch: optionName.\x0a\x09\x09\x09server perform: optionName withArguments: (Array with: optionValue)]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09console log: optionName, ' is not a valid commandline option'.\x0a\x09\x09\x09\x09console log: 'Use any of the following ones: ', switches ]].\x0a\x09^server.",
- messageSends: ["commandLineSwitches", "new", "ifEmpty:", "ifFalse:", "even", "size", "log:", ",", "first", "remove:", "whileTrue:", "notEmpty", "value:", "ifTrue:ifFalse:", "includes:", "selectorForCommandLineSwitch:", "perform:withArguments:", "with:"],
- referencedClasses: ["Array"]
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultBasePath",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "./";
- },
- args: [],
- source: "defaultBasePath\x0a\x09^ './'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultHost",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "127.0.0.1";
- },
- args: [],
- source: "defaultHost\x0a\x09^'127.0.0.1'",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultMimeTypes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=globals.HashedCollection._newFromPairs_(["%","application/x-trash","323","text/h323","abw","application/x-abiword","ai","application/postscript","aif","audio/x-aiff","aifc","audio/x-aiff","aiff","audio/x-aiff","alc","chemical/x-alchemy","art","image/x-jg","asc","text/plain","asf","video/x-ms-asf","asn","chemical/x-ncbi-asn1-spec","aso","chemical/x-ncbi-asn1-binary","asx","video/x-ms-asf","au","audio/basic","avi","video/x-msvideo","b","chemical/x-molconn-Z","bak","application/x-trash","bat","application/x-msdos-program","bcpio","application/x-bcpio","bib","text/x-bibtex","bin","application/octet-stream","bmp","image/x-ms-bmp","book","application/x-maker","bsd","chemical/x-crossfire","c","text/x-csrc","c++","text/x-c++src","c3d","chemical/x-chem3d","cac","chemical/x-cache","cache","chemical/x-cache","cascii","chemical/x-cactvs-binary","cat","application/vnd.ms-pki.seccat","cbin","chemical/x-cactvs-binary","cc","text/x-c++src","cdf","application/x-cdf","cdr","image/x-coreldraw","cdt","image/x-coreldrawtemplate","cdx","chemical/x-cdx","cdy","application/vnd.cinderella","cef","chemical/x-cxf","cer","chemical/x-cerius","chm","chemical/x-chemdraw","chrt","application/x-kchart","cif","chemical/x-cif","class","application/java-vm","cls","text/x-tex","cmdf","chemical/x-cmdf","cml","chemical/x-cml","cod","application/vnd.rim.cod","com","application/x-msdos-program","cpa","chemical/x-compass","cpio","application/x-cpio","cpp","text/x-c++src","cpt","image/x-corelphotopaint","crl","application/x-pkcs7-crl","crt","application/x-x509-ca-cert","csf","chemical/x-cache-csf","csh","text/x-csh","csm","chemical/x-csml","csml","chemical/x-csml","css","text/css","csv","text/comma-separated-values","ctab","chemical/x-cactvs-binary","ctx","chemical/x-ctx","cu","application/cu-seeme","cub","chemical/x-gaussian-cube","cxf","chemical/x-cxf","cxx","text/x-c++src","dat","chemical/x-mopac-input","dcr","application/x-director","deb","application/x-debian-package","dif","video/dv","diff","text/plain","dir","application/x-director","djv","image/vnd.djvu","djvu","image/vnd.djvu","dl","video/dl","dll","application/x-msdos-program","dmg","application/x-apple-diskimage","dms","application/x-dms","doc","application/msword","dot","application/msword","dv","video/dv","dvi","application/x-dvi","dx","chemical/x-jcamp-dx","dxr","application/x-director","emb","chemical/x-embl-dl-nucleotide","embl","chemical/x-embl-dl-nucleotide","ent","chemical/x-pdb","eps","application/postscript","etx","text/x-setext","exe","application/x-msdos-program","ez","application/andrew-inset","fb","application/x-maker","fbdoc","application/x-maker","fch","chemical/x-gaussian-checkpoint","fchk","chemical/x-gaussian-checkpoint","fig","application/x-xfig","flac","application/x-flac","fli","video/fli","fm","application/x-maker","frame","application/x-maker","frm","application/x-maker","gal","chemical/x-gaussian-log","gam","chemical/x-gamess-input","gamin","chemical/x-gamess-input","gau","chemical/x-gaussian-input","gcd","text/x-pcs-gcd","gcf","application/x-graphing-calculator","gcg","chemical/x-gcg8-sequence","gen","chemical/x-genbank","gf","application/x-tex-gf","gif","image/gif","gjc","chemical/x-gaussian-input","gjf","chemical/x-gaussian-input","gl","video/gl","gnumeric","application/x-gnumeric","gpt","chemical/x-mopac-graph","gsf","application/x-font","gsm","audio/x-gsm","gtar","application/x-gtar","h","text/x-chdr","h++","text/x-c++hdr","hdf","application/x-hdf","hh","text/x-c++hdr","hin","chemical/x-hin","hpp","text/x-c++hdr","hqx","application/mac-binhex40","hs","text/x-haskell","hta","application/hta","htc","text/x-component","htm","text/html","html","text/html","hxx","text/x-c++hdr","ica","application/x-ica","ice","x-conference/x-cooltalk","ico","image/x-icon","ics","text/calendar","icz","text/calendar","ief","image/ief","iges","model/iges","igs","model/iges","iii","application/x-iphone","inp","chemical/x-gamess-input","ins","application/x-internet-signup","iso","application/x-iso9660-image","isp","application/x-internet-signup","ist","chemical/x-isostar","istr","chemical/x-isostar","jad","text/vnd.sun.j2me.app-descriptor","jar","application/java-archive","java","text/x-java","jdx","chemical/x-jcamp-dx","jmz","application/x-jmol","jng","image/x-jng","jnlp","application/x-java-jnlp-file","jpe","image/jpeg","jpeg","image/jpeg","jpg","image/jpeg","js","application/javascript","kar","audio/midi","key","application/pgp-keys","kil","application/x-killustrator","kin","chemical/x-kinemage","kpr","application/x-kpresenter","kpt","application/x-kpresenter","ksp","application/x-kspread","kwd","application/x-kword","kwt","application/x-kword","latex","application/x-latex","lha","application/x-lha","lhs","text/x-literate-haskell","lsf","video/x-la-asf","lsx","video/x-la-asf","ltx","text/x-tex","lzh","application/x-lzh","lzx","application/x-lzx","m3u","audio/x-mpegurl","m4a","audio/mpeg","maker","application/x-maker","man","application/x-troff-man","mcif","chemical/x-mmcif","mcm","chemical/x-macmolecule","mdb","application/msaccess","me","application/x-troff-me","mesh","model/mesh","mid","audio/midi","midi","audio/midi","mif","application/x-mif","mm","application/x-freemind","mmd","chemical/x-macromodel-input","mmf","application/vnd.smaf","mml","text/mathml","mmod","chemical/x-macromodel-input","mng","video/x-mng","moc","text/x-moc","mol","chemical/x-mdl-molfile","mol2","chemical/x-mol2","moo","chemical/x-mopac-out","mop","chemical/x-mopac-input","mopcrt","chemical/x-mopac-input","mov","video/quicktime","movie","video/x-sgi-movie","mp2","audio/mpeg","mp3","audio/mpeg","mp4","video/mp4","mpc","chemical/x-mopac-input","mpe","video/mpeg","mpeg","video/mpeg","mpega","audio/mpeg","mpg","video/mpeg","mpga","audio/mpeg","ms","application/x-troff-ms","msh","model/mesh","msi","application/x-msi","mvb","chemical/x-mopac-vib","mxu","video/vnd.mpegurl","nb","application/mathematica","nc","application/x-netcdf","nwc","application/x-nwc","o","application/x-object","oda","application/oda","odb","application/vnd.oasis.opendocument.database","odc","application/vnd.oasis.opendocument.chart","odf","application/vnd.oasis.opendocument.formula","odg","application/vnd.oasis.opendocument.graphics","odi","application/vnd.oasis.opendocument.image","odm","application/vnd.oasis.opendocument.text-master","odp","application/vnd.oasis.opendocument.presentation","ods","application/vnd.oasis.opendocument.spreadsheet","odt","application/vnd.oasis.opendocument.text","ogg","application/ogg","old","application/x-trash","oth","application/vnd.oasis.opendocument.text-web","oza","application/x-oz-application","p","text/x-pascal","p7r","application/x-pkcs7-certreqresp","pac","application/x-ns-proxy-autoconfig","pas","text/x-pascal","pat","image/x-coreldrawpattern","pbm","image/x-portable-bitmap","pcf","application/x-font","pcf.Z","application/x-font","pcx","image/pcx","pdb","chemical/x-pdb","pdf","application/pdf","pfa","application/x-font","pfb","application/x-font","pgm","image/x-portable-graymap","pgn","application/x-chess-pgn","pgp","application/pgp-signature","pk","application/x-tex-pk","pl","text/x-perl","pls","audio/x-scpls","pm","text/x-perl","png","image/png","pnm","image/x-portable-anymap","pot","text/plain","ppm","image/x-portable-pixmap","pps","application/vnd.ms-powerpoint","ppt","application/vnd.ms-powerpoint","prf","application/pics-rules","prt","chemical/x-ncbi-asn1-ascii","ps","application/postscript","psd","image/x-photoshop","psp","text/x-psp","py","text/x-python","pyc","application/x-python-code","pyo","application/x-python-code","qt","video/quicktime","qtl","application/x-quicktimeplayer","ra","audio/x-realaudio","ram","audio/x-pn-realaudio","rar","application/rar","ras","image/x-cmu-raster","rd","chemical/x-mdl-rdfile","rdf","application/rdf+xml","rgb","image/x-rgb","rm","audio/x-pn-realaudio","roff","application/x-troff","ros","chemical/x-rosdal","rpm","application/x-redhat-package-manager","rss","application/rss+xml","rtf","text/rtf","rtx","text/richtext","rxn","chemical/x-mdl-rxnfile","sct","text/scriptlet","sd","chemical/x-mdl-sdfile","sd2","audio/x-sd2","sda","application/vnd.stardivision.draw","sdc","application/vnd.stardivision.calc","sdd","application/vnd.stardivision.impress","sdf","chemical/x-mdl-sdfile","sdp","application/vnd.stardivision.impress","sdw","application/vnd.stardivision.writer","ser","application/java-serialized-object","sgf","application/x-go-sgf","sgl","application/vnd.stardivision.writer-global","sh","text/x-sh","shar","application/x-shar","shtml","text/html","sid","audio/prs.sid","sik","application/x-trash","silo","model/mesh","sis","application/vnd.symbian.install","sit","application/x-stuffit","skd","application/x-koan","skm","application/x-koan","skp","application/x-koan","skt","application/x-koan","smf","application/vnd.stardivision.math","smi","application/smil","smil","application/smil","snd","audio/basic","spc","chemical/x-galactic-spc","spl","application/x-futuresplash","src","application/x-wais-source","stc","application/vnd.sun.xml.calc.template","std","application/vnd.sun.xml.draw.template","sti","application/vnd.sun.xml.impress.template","stl","application/vnd.ms-pki.stl","stw","application/vnd.sun.xml.writer.template","sty","text/x-tex","sv4cpio","application/x-sv4cpio","sv4crc","application/x-sv4crc","svg","image/svg+xml","svgz","image/svg+xml","sw","chemical/x-swissprot","swf","application/x-shockwave-flash","swfl","application/x-shockwave-flash","sxc","application/vnd.sun.xml.calc","sxd","application/vnd.sun.xml.draw","sxg","application/vnd.sun.xml.writer.global","sxi","application/vnd.sun.xml.impress","sxm","application/vnd.sun.xml.math","sxw","application/vnd.sun.xml.writer","t","application/x-troff","tar","application/x-tar","taz","application/x-gtar","tcl","text/x-tcl","tex","text/x-tex","texi","application/x-texinfo","texinfo","application/x-texinfo","text","text/plain","tgf","chemical/x-mdl-tgf","tgz","application/x-gtar","tif","image/tiff","tiff","image/tiff","tk","text/x-tcl","tm","text/texmacs","torrent","application/x-bittorrent","tr","application/x-troff","ts","text/texmacs","tsp","application/dsptype","tsv","text/tab-separated-values","txt","text/plain","udeb","application/x-debian-package","uls","text/iuls","ustar","application/x-ustar","val","chemical/x-ncbi-asn1-binary","vcd","application/x-cdlink","vcf","text/x-vcard","vcs","text/x-vcalendar","vmd","chemical/x-vmd","vms","chemical/x-vamas-iso14976","vor","application/vnd.stardivision.writer","vrm","x-world/x-vrml","vrml","x-world/x-vrml","vsd","application/vnd.visio","wad","application/x-doom","wav","audio/x-wav","wax","audio/x-ms-wax","wbmp","image/vnd.wap.wbmp","wbxml","application/vnd.wap.wbxml","wk","application/x-123","wm","video/x-ms-wm","wma","audio/x-ms-wma","wmd","application/x-ms-wmd","wml","text/vnd.wap.wml","wmlc","application/vnd.wap.wmlc","wmls","text/vnd.wap.wmlscript","wmlsc","application/vnd.wap.wmlscriptc","wmv","video/x-ms-wmv","wmx","video/x-ms-wmx","wmz","application/x-ms-wmz","wp5","application/wordperfect5.1","wpd","application/wordperfect","wrl","x-world/x-vrml","wsc","text/scriptlet","wvx","video/x-ms-wvx","wz","application/x-wingz","xbm","image/x-xbitmap","xcf","application/x-xcf","xht","application/xhtml+xml","xhtml","application/xhtml+xml","xlb","application/vnd.ms-excel","xls","application/vnd.ms-excel","xlt","application/vnd.ms-excel","xml","application/xml","xpi","application/x-xpinstall","xpm","image/x-xpixmap","xsl","application/xml","xtel","chemical/x-xtel","xul","application/vnd.mozilla.xul+xml","xwd","image/x-xwindowdump","xyz","chemical/x-xyz","zip","application/zip","zmt","chemical/x-mopac-input","~","application/x-trash"]);
- return $1;
- },
- args: [],
- source: "defaultMimeTypes\x0a\x09^ #{\x0a\x09\x09'%' -> 'application/x-trash'.\x0a\x09\x09'323' -> 'text/h323'.\x0a\x09\x09'abw' -> 'application/x-abiword'.\x0a\x09\x09'ai' -> 'application/postscript'.\x0a\x09\x09'aif' -> 'audio/x-aiff'.\x0a\x09\x09'aifc' -> 'audio/x-aiff'.\x0a\x09\x09'aiff' -> 'audio/x-aiff'.\x0a\x09\x09'alc' -> 'chemical/x-alchemy'.\x0a\x09\x09'art' -> 'image/x-jg'.\x0a\x09\x09'asc' -> 'text/plain'.\x0a\x09\x09'asf' -> 'video/x-ms-asf'.\x0a\x09\x09'asn' -> 'chemical/x-ncbi-asn1-spec'.\x0a\x09\x09'aso' -> 'chemical/x-ncbi-asn1-binary'.\x0a\x09\x09'asx' -> 'video/x-ms-asf'.\x0a\x09\x09'au' -> 'audio/basic'.\x0a\x09\x09'avi' -> 'video/x-msvideo'.\x0a\x09\x09'b' -> 'chemical/x-molconn-Z'.\x0a\x09\x09'bak' -> 'application/x-trash'.\x0a\x09\x09'bat' -> 'application/x-msdos-program'.\x0a\x09\x09'bcpio' -> 'application/x-bcpio'.\x0a\x09\x09'bib' -> 'text/x-bibtex'.\x0a\x09\x09'bin' -> 'application/octet-stream'.\x0a\x09\x09'bmp' -> 'image/x-ms-bmp'.\x0a\x09\x09'book' -> 'application/x-maker'.\x0a\x09\x09'bsd' -> 'chemical/x-crossfire'.\x0a\x09\x09'c' -> 'text/x-csrc'.\x0a\x09\x09'c++' -> 'text/x-c++src'.\x0a\x09\x09'c3d' -> 'chemical/x-chem3d'.\x0a\x09\x09'cac' -> 'chemical/x-cache'.\x0a\x09\x09'cache' -> 'chemical/x-cache'.\x0a\x09\x09'cascii' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'cat' -> 'application/vnd.ms-pki.seccat'.\x0a\x09\x09'cbin' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'cc' -> 'text/x-c++src'.\x0a\x09\x09'cdf' -> 'application/x-cdf'.\x0a\x09\x09'cdr' -> 'image/x-coreldraw'.\x0a\x09\x09'cdt' -> 'image/x-coreldrawtemplate'.\x0a\x09\x09'cdx' -> 'chemical/x-cdx'.\x0a\x09\x09'cdy' -> 'application/vnd.cinderella'.\x0a\x09\x09'cef' -> 'chemical/x-cxf'.\x0a\x09\x09'cer' -> 'chemical/x-cerius'.\x0a\x09\x09'chm' -> 'chemical/x-chemdraw'.\x0a\x09\x09'chrt' -> 'application/x-kchart'.\x0a\x09\x09'cif' -> 'chemical/x-cif'.\x0a\x09\x09'class' -> 'application/java-vm'.\x0a\x09\x09'cls' -> 'text/x-tex'.\x0a\x09\x09'cmdf' -> 'chemical/x-cmdf'.\x0a\x09\x09'cml' -> 'chemical/x-cml'.\x0a\x09\x09'cod' -> 'application/vnd.rim.cod'.\x0a\x09\x09'com' -> 'application/x-msdos-program'.\x0a\x09\x09'cpa' -> 'chemical/x-compass'.\x0a\x09\x09'cpio' -> 'application/x-cpio'.\x0a\x09\x09'cpp' -> 'text/x-c++src'.\x0a\x09\x09'cpt' -> 'image/x-corelphotopaint'.\x0a\x09\x09'crl' -> 'application/x-pkcs7-crl'.\x0a\x09\x09'crt' -> 'application/x-x509-ca-cert'.\x0a\x09\x09'csf' -> 'chemical/x-cache-csf'.\x0a\x09\x09'csh' -> 'text/x-csh'.\x0a\x09\x09'csm' -> 'chemical/x-csml'.\x0a\x09\x09'csml' -> 'chemical/x-csml'.\x0a\x09\x09'css' -> 'text/css'.\x0a\x09\x09'csv' -> 'text/comma-separated-values'.\x0a\x09\x09'ctab' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'ctx' -> 'chemical/x-ctx'.\x0a\x09\x09'cu' -> 'application/cu-seeme'.\x0a\x09\x09'cub' -> 'chemical/x-gaussian-cube'.\x0a\x09\x09'cxf' -> 'chemical/x-cxf'.\x0a\x09\x09'cxx' -> 'text/x-c++src'.\x0a\x09\x09'dat' -> 'chemical/x-mopac-input'.\x0a\x09\x09'dcr' -> 'application/x-director'.\x0a\x09\x09'deb' -> 'application/x-debian-package'.\x0a\x09\x09'dif' -> 'video/dv'.\x0a\x09\x09'diff' -> 'text/plain'.\x0a\x09\x09'dir' -> 'application/x-director'.\x0a\x09\x09'djv' -> 'image/vnd.djvu'.\x0a\x09\x09'djvu' -> 'image/vnd.djvu'.\x0a\x09\x09'dl' -> 'video/dl'.\x0a\x09\x09'dll' -> 'application/x-msdos-program'.\x0a\x09\x09'dmg' -> 'application/x-apple-diskimage'.\x0a\x09\x09'dms' -> 'application/x-dms'.\x0a\x09\x09'doc' -> 'application/msword'.\x0a\x09\x09'dot' -> 'application/msword'.\x0a\x09\x09'dv' -> 'video/dv'.\x0a\x09\x09'dvi' -> 'application/x-dvi'.\x0a\x09\x09'dx' -> 'chemical/x-jcamp-dx'.\x0a\x09\x09'dxr' -> 'application/x-director'.\x0a\x09\x09'emb' -> 'chemical/x-embl-dl-nucleotide'.\x0a\x09\x09'embl' -> 'chemical/x-embl-dl-nucleotide'.\x0a\x09\x09'ent' -> 'chemical/x-pdb'.\x0a\x09\x09'eps' -> 'application/postscript'.\x0a\x09\x09'etx' -> 'text/x-setext'.\x0a\x09\x09'exe' -> 'application/x-msdos-program'.\x0a\x09\x09'ez' -> 'application/andrew-inset'.\x0a\x09\x09'fb' -> 'application/x-maker'.\x0a\x09\x09'fbdoc' -> 'application/x-maker'.\x0a\x09\x09'fch' -> 'chemical/x-gaussian-checkpoint'.\x0a\x09\x09'fchk' -> 'chemical/x-gaussian-checkpoint'.\x0a\x09\x09'fig' -> 'application/x-xfig'.\x0a\x09\x09'flac' -> 'application/x-flac'.\x0a\x09\x09'fli' -> 'video/fli'.\x0a\x09\x09'fm' -> 'application/x-maker'.\x0a\x09\x09'frame' -> 'application/x-maker'.\x0a\x09\x09'frm' -> 'application/x-maker'.\x0a\x09\x09'gal' -> 'chemical/x-gaussian-log'.\x0a\x09\x09'gam' -> 'chemical/x-gamess-input'.\x0a\x09\x09'gamin' -> 'chemical/x-gamess-input'.\x0a\x09\x09'gau' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gcd' -> 'text/x-pcs-gcd'.\x0a\x09\x09'gcf' -> 'application/x-graphing-calculator'.\x0a\x09\x09'gcg' -> 'chemical/x-gcg8-sequence'.\x0a\x09\x09'gen' -> 'chemical/x-genbank'.\x0a\x09\x09'gf' -> 'application/x-tex-gf'.\x0a\x09\x09'gif' -> 'image/gif'.\x0a\x09\x09'gjc' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gjf' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gl' -> 'video/gl'.\x0a\x09\x09'gnumeric' -> 'application/x-gnumeric'.\x0a\x09\x09'gpt' -> 'chemical/x-mopac-graph'.\x0a\x09\x09'gsf' -> 'application/x-font'.\x0a\x09\x09'gsm' -> 'audio/x-gsm'.\x0a\x09\x09'gtar' -> 'application/x-gtar'.\x0a\x09\x09'h' -> 'text/x-chdr'.\x0a\x09\x09'h++' -> 'text/x-c++hdr'.\x0a\x09\x09'hdf' -> 'application/x-hdf'.\x0a\x09\x09'hh' -> 'text/x-c++hdr'.\x0a\x09\x09'hin' -> 'chemical/x-hin'.\x0a\x09\x09'hpp' -> 'text/x-c++hdr'.\x0a\x09\x09'hqx' -> 'application/mac-binhex40'.\x0a\x09\x09'hs' -> 'text/x-haskell'.\x0a\x09\x09'hta' -> 'application/hta'.\x0a\x09\x09'htc' -> 'text/x-component'.\x0a\x09\x09'htm' -> 'text/html'.\x0a\x09\x09'html' -> 'text/html'.\x0a\x09\x09'hxx' -> 'text/x-c++hdr'.\x0a\x09\x09'ica' -> 'application/x-ica'.\x0a\x09\x09'ice' -> 'x-conference/x-cooltalk'.\x0a\x09\x09'ico' -> 'image/x-icon'.\x0a\x09\x09'ics' -> 'text/calendar'.\x0a\x09\x09'icz' -> 'text/calendar'.\x0a\x09\x09'ief' -> 'image/ief'.\x0a\x09\x09'iges' -> 'model/iges'.\x0a\x09\x09'igs' -> 'model/iges'.\x0a\x09\x09'iii' -> 'application/x-iphone'.\x0a\x09\x09'inp' -> 'chemical/x-gamess-input'.\x0a\x09\x09'ins' -> 'application/x-internet-signup'.\x0a\x09\x09'iso' -> 'application/x-iso9660-image'.\x0a\x09\x09'isp' -> 'application/x-internet-signup'.\x0a\x09\x09'ist' -> 'chemical/x-isostar'.\x0a\x09\x09'istr' -> 'chemical/x-isostar'.\x0a\x09\x09'jad' -> 'text/vnd.sun.j2me.app-descriptor'.\x0a\x09\x09'jar' -> 'application/java-archive'.\x0a\x09\x09'java' -> 'text/x-java'.\x0a\x09\x09'jdx' -> 'chemical/x-jcamp-dx'.\x0a\x09\x09'jmz' -> 'application/x-jmol'.\x0a\x09\x09'jng' -> 'image/x-jng'.\x0a\x09\x09'jnlp' -> 'application/x-java-jnlp-file'.\x0a\x09\x09'jpe' -> 'image/jpeg'.\x0a\x09\x09'jpeg' -> 'image/jpeg'.\x0a\x09\x09'jpg' -> 'image/jpeg'.\x0a\x09\x09'js' -> 'application/javascript'.\x0a\x09\x09'kar' -> 'audio/midi'.\x0a\x09\x09'key' -> 'application/pgp-keys'.\x0a\x09\x09'kil' -> 'application/x-killustrator'.\x0a\x09\x09'kin' -> 'chemical/x-kinemage'.\x0a\x09\x09'kpr' -> 'application/x-kpresenter'.\x0a\x09\x09'kpt' -> 'application/x-kpresenter'.\x0a\x09\x09'ksp' -> 'application/x-kspread'.\x0a\x09\x09'kwd' -> 'application/x-kword'.\x0a\x09\x09'kwt' -> 'application/x-kword'.\x0a\x09\x09'latex' -> 'application/x-latex'.\x0a\x09\x09'lha' -> 'application/x-lha'.\x0a\x09\x09'lhs' -> 'text/x-literate-haskell'.\x0a\x09\x09'lsf' -> 'video/x-la-asf'.\x0a\x09\x09'lsx' -> 'video/x-la-asf'.\x0a\x09\x09'ltx' -> 'text/x-tex'.\x0a\x09\x09'lzh' -> 'application/x-lzh'.\x0a\x09\x09'lzx' -> 'application/x-lzx'.\x0a\x09\x09'm3u' -> 'audio/x-mpegurl'.\x0a\x09\x09'm4a' -> 'audio/mpeg'.\x0a\x09\x09'maker' -> 'application/x-maker'.\x0a\x09\x09'man' -> 'application/x-troff-man'.\x0a\x09\x09'mcif' -> 'chemical/x-mmcif'.\x0a\x09\x09'mcm' -> 'chemical/x-macmolecule'.\x0a\x09\x09'mdb' -> 'application/msaccess'.\x0a\x09\x09'me' -> 'application/x-troff-me'.\x0a\x09\x09'mesh' -> 'model/mesh'.\x0a\x09\x09'mid' -> 'audio/midi'.\x0a\x09\x09'midi' -> 'audio/midi'.\x0a\x09\x09'mif' -> 'application/x-mif'.\x0a\x09\x09'mm' -> 'application/x-freemind'.\x0a\x09\x09'mmd' -> 'chemical/x-macromodel-input'.\x0a\x09\x09'mmf' -> 'application/vnd.smaf'.\x0a\x09\x09'mml' -> 'text/mathml'.\x0a\x09\x09'mmod' -> 'chemical/x-macromodel-input'.\x0a\x09\x09'mng' -> 'video/x-mng'.\x0a\x09\x09'moc' -> 'text/x-moc'.\x0a\x09\x09'mol' -> 'chemical/x-mdl-molfile'.\x0a\x09\x09'mol2' -> 'chemical/x-mol2'.\x0a\x09\x09'moo' -> 'chemical/x-mopac-out'.\x0a\x09\x09'mop' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mopcrt' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mov' -> 'video/quicktime'.\x0a\x09\x09'movie' -> 'video/x-sgi-movie'.\x0a\x09\x09'mp2' -> 'audio/mpeg'.\x0a\x09\x09'mp3' -> 'audio/mpeg'.\x0a\x09\x09'mp4' -> 'video/mp4'.\x0a\x09\x09'mpc' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mpe' -> 'video/mpeg'.\x0a\x09\x09'mpeg' -> 'video/mpeg'.\x0a\x09\x09'mpega' -> 'audio/mpeg'.\x0a\x09\x09'mpg' -> 'video/mpeg'.\x0a\x09\x09'mpga' -> 'audio/mpeg'.\x0a\x09\x09'ms' -> 'application/x-troff-ms'.\x0a\x09\x09'msh' -> 'model/mesh'.\x0a\x09\x09'msi' -> 'application/x-msi'.\x0a\x09\x09'mvb' -> 'chemical/x-mopac-vib'.\x0a\x09\x09'mxu' -> 'video/vnd.mpegurl'.\x0a\x09\x09'nb' -> 'application/mathematica'.\x0a\x09\x09'nc' -> 'application/x-netcdf'.\x0a\x09\x09'nwc' -> 'application/x-nwc'.\x0a\x09\x09'o' -> 'application/x-object'.\x0a\x09\x09'oda' -> 'application/oda'.\x0a\x09\x09'odb' -> 'application/vnd.oasis.opendocument.database'.\x0a\x09\x09'odc' -> 'application/vnd.oasis.opendocument.chart'.\x0a\x09\x09'odf' -> 'application/vnd.oasis.opendocument.formula'.\x0a\x09\x09'odg' -> 'application/vnd.oasis.opendocument.graphics'.\x0a\x09\x09'odi' -> 'application/vnd.oasis.opendocument.image'.\x0a\x09\x09'odm' -> 'application/vnd.oasis.opendocument.text-master'.\x0a\x09\x09'odp' -> 'application/vnd.oasis.opendocument.presentation'.\x0a\x09\x09'ods' -> 'application/vnd.oasis.opendocument.spreadsheet'.\x0a\x09\x09'odt' -> 'application/vnd.oasis.opendocument.text'.\x0a\x09\x09'ogg' -> 'application/ogg'.\x0a\x09\x09'old' -> 'application/x-trash'.\x0a\x09\x09'oth' -> 'application/vnd.oasis.opendocument.text-web'.\x0a\x09\x09'oza' -> 'application/x-oz-application'.\x0a\x09\x09'p' -> 'text/x-pascal'.\x0a\x09\x09'p7r' -> 'application/x-pkcs7-certreqresp'.\x0a\x09\x09'pac' -> 'application/x-ns-proxy-autoconfig'.\x0a\x09\x09'pas' -> 'text/x-pascal'.\x0a\x09\x09'pat' -> 'image/x-coreldrawpattern'.\x0a\x09\x09'pbm' -> 'image/x-portable-bitmap'.\x0a\x09\x09'pcf' -> 'application/x-font'.\x0a\x09\x09'pcf.Z' -> 'application/x-font'.\x0a\x09\x09'pcx' -> 'image/pcx'.\x0a\x09\x09'pdb' -> 'chemical/x-pdb'.\x0a\x09\x09'pdf' -> 'application/pdf'.\x0a\x09\x09'pfa' -> 'application/x-font'.\x0a\x09\x09'pfb' -> 'application/x-font'.\x0a\x09\x09'pgm' -> 'image/x-portable-graymap'.\x0a\x09\x09'pgn' -> 'application/x-chess-pgn'.\x0a\x09\x09'pgp' -> 'application/pgp-signature'.\x0a\x09\x09'pk' -> 'application/x-tex-pk'.\x0a\x09\x09'pl' -> 'text/x-perl'.\x0a\x09\x09'pls' -> 'audio/x-scpls'.\x0a\x09\x09'pm' -> 'text/x-perl'.\x0a\x09\x09'png' -> 'image/png'.\x0a\x09\x09'pnm' -> 'image/x-portable-anymap'.\x0a\x09\x09'pot' -> 'text/plain'.\x0a\x09\x09'ppm' -> 'image/x-portable-pixmap'.\x0a\x09\x09'pps' -> 'application/vnd.ms-powerpoint'.\x0a\x09\x09'ppt' -> 'application/vnd.ms-powerpoint'.\x0a\x09\x09'prf' -> 'application/pics-rules'.\x0a\x09\x09'prt' -> 'chemical/x-ncbi-asn1-ascii'.\x0a\x09\x09'ps' -> 'application/postscript'.\x0a\x09\x09'psd' -> 'image/x-photoshop'.\x0a\x09\x09'psp' -> 'text/x-psp'.\x0a\x09\x09'py' -> 'text/x-python'.\x0a\x09\x09'pyc' -> 'application/x-python-code'.\x0a\x09\x09'pyo' -> 'application/x-python-code'.\x0a\x09\x09'qt' -> 'video/quicktime'.\x0a\x09\x09'qtl' -> 'application/x-quicktimeplayer'.\x0a\x09\x09'ra' -> 'audio/x-realaudio'.\x0a\x09\x09'ram' -> 'audio/x-pn-realaudio'.\x0a\x09\x09'rar' -> 'application/rar'.\x0a\x09\x09'ras' -> 'image/x-cmu-raster'.\x0a\x09\x09'rd' -> 'chemical/x-mdl-rdfile'.\x0a\x09\x09'rdf' -> 'application/rdf+xml'.\x0a\x09\x09'rgb' -> 'image/x-rgb'.\x0a\x09\x09'rm' -> 'audio/x-pn-realaudio'.\x0a\x09\x09'roff' -> 'application/x-troff'.\x0a\x09\x09'ros' -> 'chemical/x-rosdal'.\x0a\x09\x09'rpm' -> 'application/x-redhat-package-manager'.\x0a\x09\x09'rss' -> 'application/rss+xml'.\x0a\x09\x09'rtf' -> 'text/rtf'.\x0a\x09\x09'rtx' -> 'text/richtext'.\x0a\x09\x09'rxn' -> 'chemical/x-mdl-rxnfile'.\x0a\x09\x09'sct' -> 'text/scriptlet'.\x0a\x09\x09'sd' -> 'chemical/x-mdl-sdfile'.\x0a\x09\x09'sd2' -> 'audio/x-sd2'.\x0a\x09\x09'sda' -> 'application/vnd.stardivision.draw'.\x0a\x09\x09'sdc' -> 'application/vnd.stardivision.calc'.\x0a\x09\x09'sdd' -> 'application/vnd.stardivision.impress'.\x0a\x09\x09'sdf' -> 'chemical/x-mdl-sdfile'.\x0a\x09\x09'sdp' -> 'application/vnd.stardivision.impress'.\x0a\x09\x09'sdw' -> 'application/vnd.stardivision.writer'.\x0a\x09\x09'ser' -> 'application/java-serialized-object'.\x0a\x09\x09'sgf' -> 'application/x-go-sgf'.\x0a\x09\x09'sgl' -> 'application/vnd.stardivision.writer-global'.\x0a\x09\x09'sh' -> 'text/x-sh'.\x0a\x09\x09'shar' -> 'application/x-shar'.\x0a\x09\x09'shtml' -> 'text/html'.\x0a\x09\x09'sid' -> 'audio/prs.sid'.\x0a\x09\x09'sik' -> 'application/x-trash'.\x0a\x09\x09'silo' -> 'model/mesh'.\x0a\x09\x09'sis' -> 'application/vnd.symbian.install'.\x0a\x09\x09'sit' -> 'application/x-stuffit'.\x0a\x09\x09'skd' -> 'application/x-koan'.\x0a\x09\x09'skm' -> 'application/x-koan'.\x0a\x09\x09'skp' -> 'application/x-koan'.\x0a\x09\x09'skt' -> 'application/x-koan'.\x0a\x09\x09'smf' -> 'application/vnd.stardivision.math'.\x0a\x09\x09'smi' -> 'application/smil'.\x0a\x09\x09'smil' -> 'application/smil'.\x0a\x09\x09'snd' -> 'audio/basic'.\x0a\x09\x09'spc' -> 'chemical/x-galactic-spc'.\x0a\x09\x09'spl' -> 'application/x-futuresplash'.\x0a\x09\x09'src' -> 'application/x-wais-source'.\x0a\x09\x09'stc' -> 'application/vnd.sun.xml.calc.template'.\x0a\x09\x09'std' -> 'application/vnd.sun.xml.draw.template'.\x0a\x09\x09'sti' -> 'application/vnd.sun.xml.impress.template'.\x0a\x09\x09'stl' -> 'application/vnd.ms-pki.stl'.\x0a\x09\x09'stw' -> 'application/vnd.sun.xml.writer.template'.\x0a\x09\x09'sty' -> 'text/x-tex'.\x0a\x09\x09'sv4cpio' -> 'application/x-sv4cpio'.\x0a\x09\x09'sv4crc' -> 'application/x-sv4crc'.\x0a\x09\x09'svg' -> 'image/svg+xml'.\x0a\x09\x09'svgz' -> 'image/svg+xml'.\x0a\x09\x09'sw' -> 'chemical/x-swissprot'.\x0a\x09\x09'swf' -> 'application/x-shockwave-flash'.\x0a\x09\x09'swfl' -> 'application/x-shockwave-flash'.\x0a\x09\x09'sxc' -> 'application/vnd.sun.xml.calc'.\x0a\x09\x09'sxd' -> 'application/vnd.sun.xml.draw'.\x0a\x09\x09'sxg' -> 'application/vnd.sun.xml.writer.global'.\x0a\x09\x09'sxi' -> 'application/vnd.sun.xml.impress'.\x0a\x09\x09'sxm' -> 'application/vnd.sun.xml.math'.\x0a\x09\x09'sxw' -> 'application/vnd.sun.xml.writer'.\x0a\x09\x09't' -> 'application/x-troff'.\x0a\x09\x09'tar' -> 'application/x-tar'.\x0a\x09\x09'taz' -> 'application/x-gtar'.\x0a\x09\x09'tcl' -> 'text/x-tcl'.\x0a\x09\x09'tex' -> 'text/x-tex'.\x0a\x09\x09'texi' -> 'application/x-texinfo'.\x0a\x09\x09'texinfo' -> 'application/x-texinfo'.\x0a\x09\x09'text' -> 'text/plain'.\x0a\x09\x09'tgf' -> 'chemical/x-mdl-tgf'.\x0a\x09\x09'tgz' -> 'application/x-gtar'.\x0a\x09\x09'tif' -> 'image/tiff'.\x0a\x09\x09'tiff' -> 'image/tiff'.\x0a\x09\x09'tk' -> 'text/x-tcl'.\x0a\x09\x09'tm' -> 'text/texmacs'.\x0a\x09\x09'torrent' -> 'application/x-bittorrent'.\x0a\x09\x09'tr' -> 'application/x-troff'.\x0a\x09\x09'ts' -> 'text/texmacs'.\x0a\x09\x09'tsp' -> 'application/dsptype'.\x0a\x09\x09'tsv' -> 'text/tab-separated-values'.\x0a\x09\x09'txt' -> 'text/plain'.\x0a\x09\x09'udeb' -> 'application/x-debian-package'.\x0a\x09\x09'uls' -> 'text/iuls'.\x0a\x09\x09'ustar' -> 'application/x-ustar'.\x0a\x09\x09'val' -> 'chemical/x-ncbi-asn1-binary'.\x0a\x09\x09'vcd' -> 'application/x-cdlink'.\x0a\x09\x09'vcf' -> 'text/x-vcard'.\x0a\x09\x09'vcs' -> 'text/x-vcalendar'.\x0a\x09\x09'vmd' -> 'chemical/x-vmd'.\x0a\x09\x09'vms' -> 'chemical/x-vamas-iso14976'.\x0a\x09\x09'vor' -> 'application/vnd.stardivision.writer'.\x0a\x09\x09'vrm' -> 'x-world/x-vrml'.\x0a\x09\x09'vrml' -> 'x-world/x-vrml'.\x0a\x09\x09'vsd' -> 'application/vnd.visio'.\x0a\x09\x09'wad' -> 'application/x-doom'.\x0a\x09\x09'wav' -> 'audio/x-wav'.\x0a\x09\x09'wax' -> 'audio/x-ms-wax'.\x0a\x09\x09'wbmp' -> 'image/vnd.wap.wbmp'.\x0a\x09\x09'wbxml' -> 'application/vnd.wap.wbxml'.\x0a\x09\x09'wk' -> 'application/x-123'.\x0a\x09\x09'wm' -> 'video/x-ms-wm'.\x0a\x09\x09'wma' -> 'audio/x-ms-wma'.\x0a\x09\x09'wmd' -> 'application/x-ms-wmd'.\x0a\x09\x09'wml' -> 'text/vnd.wap.wml'.\x0a\x09\x09'wmlc' -> 'application/vnd.wap.wmlc'.\x0a\x09\x09'wmls' -> 'text/vnd.wap.wmlscript'.\x0a\x09\x09'wmlsc' -> 'application/vnd.wap.wmlscriptc'.\x0a\x09\x09'wmv' -> 'video/x-ms-wmv'.\x0a\x09\x09'wmx' -> 'video/x-ms-wmx'.\x0a\x09\x09'wmz' -> 'application/x-ms-wmz'.\x0a\x09\x09'wp5' -> 'application/wordperfect5.1'.\x0a\x09\x09'wpd' -> 'application/wordperfect'.\x0a\x09\x09'wrl' -> 'x-world/x-vrml'.\x0a\x09\x09'wsc' -> 'text/scriptlet'.\x0a\x09\x09'wvx' -> 'video/x-ms-wvx'.\x0a\x09\x09'wz' -> 'application/x-wingz'.\x0a\x09\x09'xbm' -> 'image/x-xbitmap'.\x0a\x09\x09'xcf' -> 'application/x-xcf'.\x0a\x09\x09'xht' -> 'application/xhtml+xml'.\x0a\x09\x09'xhtml' -> 'application/xhtml+xml'.\x0a\x09\x09'xlb' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xls' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xlt' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xml' -> 'application/xml'.\x0a\x09\x09'xpi' -> 'application/x-xpinstall'.\x0a\x09\x09'xpm' -> 'image/x-xpixmap'.\x0a\x09\x09'xsl' -> 'application/xml'.\x0a\x09\x09'xtel' -> 'chemical/x-xtel'.\x0a\x09\x09'xul' -> 'application/vnd.mozilla.xul+xml'.\x0a\x09\x09'xwd' -> 'image/x-xwindowdump'.\x0a\x09\x09'xyz' -> 'chemical/x-xyz'.\x0a\x09\x09'zip' -> 'application/zip'.\x0a\x09\x09'zmt' -> 'chemical/x-mopac-input'.\x0a\x09\x09'~' -> 'application/x-trash'\x0a\x09}",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultPort",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return (4000);
- },
- args: [],
- source: "defaultPort\x0a\x09^4000",
- messageSends: [],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "main",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- var fileServer,args;
- function $FileServer(){return globals.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- var $early={};
- try {
- args=_st(process)._argv();
- _st(args)._removeFrom_to_((1),(3));
- _st(args)._detect_ifNone_((function(each){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(each).__eq("--help");
- if(smalltalk.assert($1)){
- return _st($FileServer())._printHelp();
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
- return smalltalk.withContext(function($ctx2) {
- fileServer=_st($FileServer())._createServerWithArguments_(args);
- fileServer;
- $2=_st(fileServer)._start();
- throw $early=[$2];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- return self}
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"main",{fileServer:fileServer,args:args},globals.FileServer.klass)})},
- args: [],
- source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09 Creates and starts a FileServer instance.\x22\x0a\x09| fileServer args |\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 3.\x0a\x0a\x09args detect: [ :each |\x0a\x09\x09(each = '--help') ifTrue: [FileServer printHelp]]\x0a\x09ifNone: [\x0a\x09\x09fileServer := FileServer createServerWithArguments: args.\x0a\x09\x09^fileServer start]",
- messageSends: ["argv", "removeFrom:to:", "detect:ifNone:", "ifTrue:", "=", "printHelp", "createServerWithArguments:", "start"],
- referencedClasses: ["FileServer"]
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "mimeTypeFor:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._mimeTypes())._at_ifAbsent_(_st(aString)._replace_with_(".*[\x5c.]",""),(function(){
- return "text/plain";
- }));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"mimeTypeFor:",{aString:aString},globals.FileServer.klass)})},
- args: ["aString"],
- source: "mimeTypeFor: aString\x0a\x09^self mimeTypes at: (aString replace: '.*[\x5c.]' with: '') ifAbsent: ['text/plain']",
- messageSends: ["at:ifAbsent:", "mimeTypes", "replace:with:"],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "mimeTypes",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@mimeTypes"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@mimeTypes"]=self._defaultMimeTypes();
- $1=self["@mimeTypes"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"mimeTypes",{},globals.FileServer.klass)})},
- args: [],
- source: "mimeTypes\x0a\x09^mimeTypes ifNil: [mimeTypes := self defaultMimeTypes]",
- messageSends: ["ifNil:", "defaultMimeTypes"],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printHelp",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(console)._log_("Available commandline options are:");
- $ctx1.sendIdx["log:"]=1;
- _st(console)._log_("--help");
- $ctx1.sendIdx["log:"]=2;
- _st(self._commandLineSwitches())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(console)._log_(_st(each).__comma(" <parameter>"));
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"printHelp",{},globals.FileServer.klass)})},
- args: [],
- source: "printHelp\x0a\x09console log: 'Available commandline options are:'.\x0a\x09console log: '--help'.\x0a\x09self commandLineSwitches do: [ :each |\x0a\x09\x09console log: each, ' <parameter>']",
- messageSends: ["log:", "do:", "commandLineSwitches", ","],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selectorForCommandLineSwitch:",
- protocol: 'accessing',
- fn: function (aSwitch){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st(_st(aSwitch)._replace_with_("^--",""))._replace_with_("-[a-z]",(function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(each)._second())._asUppercase();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- $ctx1.sendIdx["replace:with:"]=1;
- $1=_st($2).__comma(":");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch},globals.FileServer.klass)})},
- args: ["aSwitch"],
- source: "selectorForCommandLineSwitch: aSwitch\x0a\x09\x22Remove the trailing '--', add ':' at the end\x0a\x09 and replace all occurences of a lowercase letter preceded by a '-' with\x0a\x09 the Uppercase letter.\x0a\x09 Example: --fallback-page becomes fallbackPage:\x22\x0a\x09^((aSwitch replace: '^--' with: '')\x0a\x09\x09replace: '-[a-z]' with: [ :each | each second asUppercase ]), ':'",
- messageSends: [",", "replace:with:", "asUppercase", "second"],
- referencedClasses: []
- }),
- globals.FileServer.klass);
- smalltalk.addClass('Repl', globals.Object, ['readline', 'interface', 'util', 'session', 'resultCount', 'commands'], 'AmberCli');
- globals.Repl.comment="I am a class representing a REPL (Read Evaluate Print Loop) and provide a command line interface to Amber Smalltalk.\x0d\x0aOn the prompt you can type Amber statements which will be evaluated after pressing <Enter>.\x0d\x0aThe evaluation is comparable with executing a 'DoIt' in a workspace.\x0d\x0a\x0d\x0aMy runtime requirement is a functional Node.js executable with working Readline support.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "addVariableNamed:to:",
- protocol: 'private',
- fn: function (aString,anObject){
- var self=this;
- var newClass,newObject;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- newClass=self._subclass_withVariable_(_st(anObject)._class(),aString);
- self._encapsulateVariable_withValue_in_(aString,anObject,newClass);
- newObject=_st(newClass)._new();
- self._setPreviousVariablesFor_from_(newObject,anObject);
- $1=newObject;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"addVariableNamed:to:",{aString:aString,anObject:anObject,newClass:newClass,newObject:newObject},globals.Repl)})},
- args: ["aString", "anObject"],
- source: "addVariableNamed: aString to: anObject\x0a\x09| newClass newObject |\x0a\x09newClass := self subclass: anObject class withVariable: aString.\x0a\x09self encapsulateVariable: aString withValue: anObject in: newClass.\x0a\x09newObject := newClass new.\x0a\x09self setPreviousVariablesFor: newObject from: anObject.\x0a\x09^ newObject",
- messageSends: ["subclass:withVariable:", "class", "encapsulateVariable:withValue:in:", "new", "setPreviousVariablesFor:from:"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assignNewVariable:do:",
- protocol: 'private',
- fn: function (buffer,aBlock){
- var self=this;
- function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
- function $ErrorHandler(){return globals.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$4,$2,$1;
- $1=self._parseAssignment_do_(buffer,(function(name,expr){
- var varName,value;
- return smalltalk.withContext(function($ctx2) {
- if(($receiver = name) == nil || $receiver == null){
- varName=self._nextResultName();
- } else {
- varName=name;
- };
- varName;
- self["@session"]=self._addVariableNamed_to_(varName,self["@session"]);
- self["@session"];
- _st((function(){
- return smalltalk.withContext(function($ctx3) {
- $3=_st(varName).__comma(" := ");
- if(($receiver = expr) == nil || $receiver == null){
- $4=buffer;
- } else {
- $4=expr;
- };
- $2=_st($3).__comma($4);
- $ctx3.sendIdx[","]=1;
- value=self._eval_on_($2,self["@session"]);
- return value;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}))._on_do_($Error(),(function(e){
- return smalltalk.withContext(function($ctx3) {
- _st(_st($ErrorHandler())._new())._logError_(e);
- value=nil;
- return value;
- }, function($ctx3) {$ctx3.fillBlock({e:e},$ctx2,5)})}));
- return _st(aBlock)._value_value_(varName,value);
- }, function($ctx2) {$ctx2.fillBlock({name:name,expr:expr,varName:varName,value:value},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"assignNewVariable:do:",{buffer:buffer,aBlock:aBlock},globals.Repl)})},
- args: ["buffer", "aBlock"],
- source: "assignNewVariable: buffer do: aBlock\x0a\x09\x22Assigns a new variable and calls the given block with the variable's name and value\x0a\x09 if buffer contains an assignment expression. If it doesn't the block is called with nil for\x0a\x09 both arguments.\x22\x0a\x09^ self parseAssignment: buffer do: [ :name :expr || varName value |\x0a\x09\x09varName := name ifNil: [self nextResultName].\x0a\x09\x09session := self addVariableNamed: varName to: session.\x0a\x09\x09[ value := self eval: varName, ' := ', (expr ifNil: [buffer]) on: session ]\x0a\x09\x09\x09on: Error\x0a\x09\x09\x09do: [ :e | ErrorHandler new logError: e. value := nil].\x0a\x09\x09aBlock value: varName value: value]",
- messageSends: ["parseAssignment:do:", "ifNil:", "nextResultName", "addVariableNamed:to:", "on:do:", "eval:on:", ",", "logError:", "new", "value:value:"],
- referencedClasses: ["Error", "ErrorHandler"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "clearScreen",
- protocol: 'actions',
- fn: function (){
- var self=this;
- var esc,cls;
- function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- esc=_st($String())._fromCharCode_((27));
- $1=_st(_st(esc).__comma("[2J")).__comma(esc);
- $ctx1.sendIdx[","]=2;
- cls=_st($1).__comma("[0;0f");
- $ctx1.sendIdx[","]=1;
- _st(_st(process)._stdout())._write_(cls);
- _st(self["@interface"])._prompt();
- return self}, function($ctx1) {$ctx1.fill(self,"clearScreen",{esc:esc,cls:cls},globals.Repl)})},
- args: [],
- source: "clearScreen\x0a\x09| esc cls |\x0a\x09esc := String fromCharCode: 27.\x0a\x09cls := esc, '[2J', esc, '[0;0f'.\x0a\x09process stdout write: cls.\x0a\x09interface prompt",
- messageSends: ["fromCharCode:", ",", "write:", "stdout", "prompt"],
- referencedClasses: ["String"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "close",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(process)._stdin())._destroy();
- return self}, function($ctx1) {$ctx1.fill(self,"close",{},globals.Repl)})},
- args: [],
- source: "close\x0a\x09process stdin destroy",
- messageSends: ["destroy", "stdin"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "commands",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@commands"];
- return $1;
- },
- args: [],
- source: "commands\x0a\x09^ commands",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "createInterface",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- self["@interface"]=_st(self["@readline"])._createInterface_stdout_(_st(process)._stdin(),_st(process)._stdout());
- _st(self["@interface"])._on_do_("line",(function(buffer){
- return smalltalk.withContext(function($ctx2) {
- return self._processLine_(buffer);
- }, function($ctx2) {$ctx2.fillBlock({buffer:buffer},$ctx1,1)})}));
- $ctx1.sendIdx["on:do:"]=1;
- _st(self["@interface"])._on_do_("close",(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._close();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- self._printWelcome();
- self._setupHotkeys();
- $1=self._setPrompt();
- _st(self["@interface"])._prompt();
- return self}, function($ctx1) {$ctx1.fill(self,"createInterface",{},globals.Repl)})},
- args: [],
- source: "createInterface\x0a\x09interface := readline createInterface: process stdin stdout: process stdout.\x0a\x09interface on: 'line' do: [:buffer | self processLine: buffer].\x0a\x09interface on: 'close' do: [self close].\x0a\x09self printWelcome; setupHotkeys; setPrompt.\x0a\x09interface prompt",
- messageSends: ["createInterface:stdout:", "stdin", "stdout", "on:do:", "processLine:", "close", "printWelcome", "setupHotkeys", "setPrompt", "prompt"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "encapsulateVariable:withValue:in:",
- protocol: 'private',
- fn: function (aString,anObject,aClass){
- var self=this;
- var compiler;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$4,$3,$2,$5,$6;
- compiler=_st($Compiler())._new();
- $1=compiler;
- $4=_st(aString).__comma(": anObject ^ ");
- $ctx1.sendIdx[","]=3;
- $3=_st($4).__comma(aString);
- $ctx1.sendIdx[","]=2;
- $2=_st($3).__comma(" := anObject");
- $ctx1.sendIdx[","]=1;
- _st($1)._install_forClass_category_($2,aClass,"session");
- $ctx1.sendIdx["install:forClass:category:"]=1;
- $5=compiler;
- $6=_st(_st(aString).__comma(" ^ ")).__comma(aString);
- $ctx1.sendIdx[","]=4;
- _st($5)._install_forClass_category_($6,aClass,"session");
- return self}, function($ctx1) {$ctx1.fill(self,"encapsulateVariable:withValue:in:",{aString:aString,anObject:anObject,aClass:aClass,compiler:compiler},globals.Repl)})},
- args: ["aString", "anObject", "aClass"],
- source: "encapsulateVariable: aString withValue: anObject in: aClass\x0a\x09\x22Add getter and setter for given variable to session.\x22\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09compiler install: aString, ': anObject ^ ', aString, ' := anObject' forClass: aClass category: 'session'.\x0a\x09compiler install: aString, ' ^ ', aString forClass: aClass category: 'session'.",
- messageSends: ["new", "install:forClass:category:", ","],
- referencedClasses: ["Compiler"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:",
- protocol: 'actions',
- fn: function (buffer){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._eval_on_(buffer,_st($DoIt())._new());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"eval:",{buffer:buffer},globals.Repl)})},
- args: ["buffer"],
- source: "eval: buffer\x0a\x09^ self eval: buffer on: DoIt new.",
- messageSends: ["eval:on:", "new"],
- referencedClasses: ["DoIt"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:on:",
- protocol: 'actions',
- fn: function (buffer,anObject){
- var self=this;
- var result;
- function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st(buffer)._isEmpty();
- if(! smalltalk.assert($1)){
- self._try_catch_((function(){
- return smalltalk.withContext(function($ctx2) {
- result=_st(_st($Compiler())._new())._evaluateExpression_on_(buffer,anObject);
- return result;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(e){
- return smalltalk.withContext(function($ctx2) {
- $2=_st(e)._isSmalltalkError();
- if(smalltalk.assert($2)){
- return _st(e)._resignal();
- } else {
- return _st(_st(process)._stdout())._write_(_st(e)._jsStack());
- };
- }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,3)})}));
- };
- $3=result;
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"eval:on:",{buffer:buffer,anObject:anObject,result:result},globals.Repl)})},
- args: ["buffer", "anObject"],
- source: "eval: buffer on: anObject\x0a\x09| result |\x0a\x09buffer isEmpty ifFalse: [\x0a\x09\x09self try: [\x0a\x09\x09\x09result := Compiler new evaluateExpression: buffer on: anObject]\x0a\x09\x09catch: [:e |\x0a\x09\x09\x09e isSmalltalkError\x0a\x09\x09\x09 ifTrue: [ e resignal ]\x0a\x09\x09\x09 ifFalse: [ process stdout write: e jsStack ]]].\x0a\x09^ result",
- messageSends: ["ifFalse:", "isEmpty", "try:catch:", "evaluateExpression:on:", "new", "ifTrue:ifFalse:", "isSmalltalkError", "resignal", "write:", "stdout", "jsStack"],
- referencedClasses: ["Compiler"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "executeCommand:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- _st(self._commands())._keysAndValuesDo_((function(names,cmd){
- return smalltalk.withContext(function($ctx2) {
- $1=_st(names)._includes_(aString);
- if(smalltalk.assert($1)){
- _st(cmd)._value();
- throw $early=[true];
- };
- }, function($ctx2) {$ctx2.fillBlock({names:names,cmd:cmd},$ctx1,1)})}));
- return false;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"executeCommand:",{aString:aString},globals.Repl)})},
- args: ["aString"],
- source: "executeCommand: aString\x0a\x09\x22Tries to process the given string as a command. Returns true if it was a command, false if not.\x22\x0a\x09self commands keysAndValuesDo: [:names :cmd |\x0a\x09\x09(names includes: aString) ifTrue: [\x0a\x09\x09\x09cmd value.\x0a\x09\x09\x09^ true]].\x0a\x09^ false",
- messageSends: ["keysAndValuesDo:", "commands", "ifTrue:", "includes:", "value"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- return smalltalk.withContext(function($ctx1) {
- globals.Repl.superclass.fn.prototype._initialize.apply(_st(self), []);
- self["@session"]=_st($DoIt())._new();
- self["@readline"]=_st(require)._value_("readline");
- $ctx1.sendIdx["value:"]=1;
- self["@util"]=_st(require)._value_("util");
- self._setupCommands();
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Repl)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09session := DoIt new.\x0a\x09readline := require value: 'readline'.\x0a\x09util := require value: 'util'.\x0a\x09self setupCommands",
- messageSends: ["initialize", "new", "value:", "setupCommands"],
- referencedClasses: ["DoIt"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "instanceVariableNamesFor:",
- protocol: 'private',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st(aClass)._superclass();
- $ctx1.sendIdx["superclass"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st(aClass)._instanceVariableNames();
- } else {
- $3=_st(aClass)._instanceVariableNames();
- $ctx1.sendIdx["instanceVariableNames"]=1;
- $1=_st($3)._copyWithAll_(self._instanceVariableNamesFor_(_st(aClass)._superclass()));
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"instanceVariableNamesFor:",{aClass:aClass},globals.Repl)})},
- args: ["aClass"],
- source: "instanceVariableNamesFor: aClass\x0a\x09\x22Yields all instance variable names for the given class, including inherited ones.\x22\x0a\x09^ aClass superclass\x0a\x09\x09ifNotNil: [\x0a\x09\x09\x09aClass instanceVariableNames copyWithAll: (self instanceVariableNamesFor: aClass superclass)]\x0a\x09\x09ifNil: [\x0a\x09\x09\x09aClass instanceVariableNames]",
- messageSends: ["ifNotNil:ifNil:", "superclass", "copyWithAll:", "instanceVariableNames", "instanceVariableNamesFor:"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isIdentifier:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(aString)._match_("^[a-z_]\x5cw*$"._asRegexp());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isIdentifier:",{aString:aString},globals.Repl)})},
- args: ["aString"],
- source: "isIdentifier: aString\x0a\x09^ aString match: '^[a-z_]\x5cw*$' asRegexp",
- messageSends: ["match:", "asRegexp"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isVariableDefined:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._instanceVariableNamesFor_(_st(self["@session"])._class()))._includes_(aString);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"isVariableDefined:",{aString:aString},globals.Repl)})},
- args: ["aString"],
- source: "isVariableDefined: aString\x0a\x09^ (self instanceVariableNamesFor: session class) includes: aString",
- messageSends: ["includes:", "instanceVariableNamesFor:", "class"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextResultName",
- protocol: 'private',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@resultCount"];
- if(($receiver = $1) == nil || $receiver == null){
- self["@resultCount"]=(1);
- } else {
- self["@resultCount"]=_st(self["@resultCount"]).__plus((1));
- };
- $2="res".__comma(_st(self["@resultCount"])._asString());
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"nextResultName",{},globals.Repl)})},
- args: [],
- source: "nextResultName\x0a\x09resultCount := resultCount\x0a \x09ifNotNil: [resultCount + 1]\x0a \x09ifNil: [1].\x0a ^ 'res', resultCount asString",
- messageSends: ["ifNotNil:ifNil:", "+", ",", "asString"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "onKeyPress:",
- protocol: 'private',
- fn: function (key){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(key)._ctrl())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(key)._name()).__eq("l");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($1)){
- self._clearScreen();
- };
- return self}, function($ctx1) {$ctx1.fill(self,"onKeyPress:",{key:key},globals.Repl)})},
- args: ["key"],
- source: "onKeyPress: key\x0a\x09(key ctrl and: [key name = 'l'])\x0a\x09\x09ifTrue: [self clearScreen]",
- messageSends: ["ifTrue:", "and:", "ctrl", "=", "name", "clearScreen"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "parseAssignment:do:",
- protocol: 'private',
- fn: function (aString,aBlock){
- var self=this;
- var assignment;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1;
- assignment=_st(_st(aString)._tokenize_(":="))._collect_((function(s){
- return smalltalk.withContext(function($ctx2) {
- return _st(s)._trimBoth();
- }, function($ctx2) {$ctx2.fillBlock({s:s},$ctx1,1)})}));
- $2=_st(_st(_st(assignment)._size()).__eq((2)))._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- $3=_st(assignment)._first();
- $ctx2.sendIdx["first"]=1;
- return self._isIdentifier_($3);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- if(smalltalk.assert($2)){
- $1=_st(aBlock)._value_value_(_st(assignment)._first(),_st(assignment)._last());
- $ctx1.sendIdx["value:value:"]=1;
- } else {
- $1=_st(aBlock)._value_value_(nil,nil);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"parseAssignment:do:",{aString:aString,aBlock:aBlock,assignment:assignment},globals.Repl)})},
- args: ["aString", "aBlock"],
- source: "parseAssignment: aString do: aBlock\x0a\x09\x22Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.\x0a\x09 If the string is not one no variable will be assigned and the block will be called with nil for both arguments.\x22\x0a\x09| assignment |\x0a\x09assignment := (aString tokenize: ':=') collect: [:s | s trimBoth].\x0a\x09^ (assignment size = 2 and: [self isIdentifier: assignment first])\x0a\x09\x09ifTrue: [ aBlock value: assignment first value: assignment last ]\x0a\x09\x09ifFalse: [ aBlock value: nil value: nil ]",
- messageSends: ["collect:", "tokenize:", "trimBoth", "ifTrue:ifFalse:", "and:", "=", "size", "isIdentifier:", "first", "value:value:", "last"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "presentResultNamed:withValue:",
- protocol: 'private',
- fn: function (varName,value){
- var self=this;
- function $Transcript(){return globals.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4;
- $3=_st(_st(varName).__comma(": ")).__comma(_st(_st(value)._class())._name());
- $ctx1.sendIdx[","]=3;
- $2=_st($3).__comma(" = ");
- $ctx1.sendIdx[","]=2;
- $1=_st($2).__comma(_st(value)._asString());
- $ctx1.sendIdx[","]=1;
- _st($Transcript())._show_($1);
- $4=_st($Transcript())._cr();
- _st(self["@interface"])._prompt();
- return self}, function($ctx1) {$ctx1.fill(self,"presentResultNamed:withValue:",{varName:varName,value:value},globals.Repl)})},
- args: ["varName", "value"],
- source: "presentResultNamed: varName withValue: value\x0a\x09Transcript show: varName, ': ', value class name, ' = ', value asString; cr.\x0a\x09interface prompt",
- messageSends: ["show:", ",", "name", "class", "asString", "cr", "prompt"],
- referencedClasses: ["Transcript"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "printWelcome",
- protocol: 'actions',
- fn: function (){
- var self=this;
- function $Transcript(){return globals.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
- function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$1,$4;
- $3=_st("Welcome to Amber version ".__comma(_st(_st($Smalltalk())._current())._version())).__comma(" (NodeJS ");
- $ctx1.sendIdx[","]=3;
- $2=_st($3).__comma(_st(_st(process)._versions())._node());
- $ctx1.sendIdx[","]=2;
- $1=_st($2).__comma(").");
- $ctx1.sendIdx[","]=1;
- _st($Transcript())._show_($1);
- $ctx1.sendIdx["show:"]=1;
- _st($Transcript())._show_("Type :q to exit.");
- $4=_st($Transcript())._cr();
- return self}, function($ctx1) {$ctx1.fill(self,"printWelcome",{},globals.Repl)})},
- args: [],
- source: "printWelcome\x0a\x09Transcript show: 'Welcome to Amber version ', Smalltalk current version, ' (NodeJS ', process versions node, ').'.\x0a\x09Transcript show: 'Type :q to exit.'; cr.",
- messageSends: ["show:", ",", "version", "current", "node", "versions", "cr"],
- referencedClasses: ["Transcript", "Smalltalk"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "processLine:",
- protocol: 'private',
- fn: function (buffer){
- var self=this;
- var show;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- show=(function(varName,value){
- return smalltalk.withContext(function($ctx2) {
- return self._presentResultNamed_withValue_(varName,value);
- }, function($ctx2) {$ctx2.fillBlock({varName:varName,value:value},$ctx1,1)})});
- $1=self._executeCommand_(buffer);
- if(! smalltalk.assert($1)){
- $2=self._isVariableDefined_(buffer);
- if(smalltalk.assert($2)){
- _st(show)._value_value_(buffer,_st(self["@session"])._perform_(buffer));
- } else {
- self._assignNewVariable_do_(buffer,show);
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"processLine:",{buffer:buffer,show:show},globals.Repl)})},
- args: ["buffer"],
- source: "processLine: buffer\x0a\x09\x22Processes lines entered through the readline interface.\x22\x0a\x09| show |\x0a\x09show := [:varName :value | self presentResultNamed: varName withValue: value].\x0a\x09(self executeCommand: buffer) ifFalse: [\x0a\x09\x09(self isVariableDefined: buffer)\x0a\x09\x09\x09ifTrue: [show value: buffer value: (session perform: buffer)]\x0a\x09\x09\x09ifFalse: [self assignNewVariable: buffer do: show]]",
- messageSends: ["presentResultNamed:withValue:", "ifFalse:", "executeCommand:", "ifTrue:ifFalse:", "isVariableDefined:", "value:value:", "perform:", "assignNewVariable:do:"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "prompt",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "amber >> ";
- },
- args: [],
- source: "prompt\x0a\x09^'amber >> '",
- messageSends: [],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setPreviousVariablesFor:from:",
- protocol: 'private',
- fn: function (newObject,oldObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._instanceVariableNamesFor_(_st(oldObject)._class()))._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(newObject)._perform_withArguments_(_st(each).__comma(":"),[_st(oldObject)._perform_(each)]);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"setPreviousVariablesFor:from:",{newObject:newObject,oldObject:oldObject},globals.Repl)})},
- args: ["newObject", "oldObject"],
- source: "setPreviousVariablesFor: newObject from: oldObject\x0a\x09(self instanceVariableNamesFor: oldObject class) do: [:each |\x0a\x09\x09newObject perform: each, ':' withArguments: {oldObject perform: each}].",
- messageSends: ["do:", "instanceVariableNamesFor:", "class", "perform:withArguments:", ",", "perform:"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setPrompt",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self["@interface"])._setPrompt_(self._prompt());
- return self}, function($ctx1) {$ctx1.fill(self,"setPrompt",{},globals.Repl)})},
- args: [],
- source: "setPrompt\x0a\x09interface setPrompt: self prompt",
- messageSends: ["setPrompt:", "prompt"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupCommands",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=_st([":q"]).__minus_gt((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(process)._exit();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $ctx1.sendIdx["->"]=1;
- $1=[$2,_st([""]).__minus_gt((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self["@interface"])._prompt();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}))];
- self["@commands"]=_st($Dictionary())._from_($1);
- return self}, function($ctx1) {$ctx1.fill(self,"setupCommands",{},globals.Repl)})},
- args: [],
- source: "setupCommands\x0a\x09commands := Dictionary from: {\x0a\x09\x09{':q'} -> [process exit].\x0a\x09\x09{''} -> [interface prompt]}",
- messageSends: ["from:", "->", "exit", "prompt"],
- referencedClasses: ["Dictionary"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupHotkeys",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(process)._stdin())._on_do_("keypress",(function(s,key){
- return smalltalk.withContext(function($ctx2) {
- if(($receiver = key) == nil || $receiver == null){
- return key;
- } else {
- return self._onKeyPress_(key);
- };
- }, function($ctx2) {$ctx2.fillBlock({s:s,key:key},$ctx1,1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"setupHotkeys",{},globals.Repl)})},
- args: [],
- source: "setupHotkeys\x0a\x09process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].",
- messageSends: ["on:do:", "stdin", "ifNotNil:", "onKeyPress:"],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclass:withVariable:",
- protocol: 'private',
- fn: function (aClass,varName){
- var self=this;
- function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st($ClassBuilder())._new())._addSubclassOf_named_instanceVariableNames_package_(aClass,_st(self._subclassNameFor_(aClass))._asSymbol(),[varName],"Compiler-Core");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclass:withVariable:",{aClass:aClass,varName:varName},globals.Repl)})},
- args: ["aClass", "varName"],
- source: "subclass: aClass withVariable: varName\x0a\x09\x22Create subclass with new variable.\x22\x0a\x09^ ClassBuilder new\x0a\x09\x09addSubclassOf: aClass\x0a\x09\x09named: (self subclassNameFor: aClass) asSymbol\x0a\x09\x09instanceVariableNames: {varName}\x0a\x09\x09package: 'Compiler-Core'",
- messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "new", "asSymbol", "subclassNameFor:"],
- referencedClasses: ["ClassBuilder"]
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "subclassNameFor:",
- protocol: 'private',
- fn: function (aClass){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $3,$2,$7,$6,$5,$4,$8,$1;
- $3=_st(aClass)._name();
- $ctx1.sendIdx["name"]=1;
- $2=_st($3)._matchesOf_("\x5cd+$");
- $ctx1.sendIdx["matchesOf:"]=1;
- if(($receiver = $2) == nil || $receiver == null){
- $1=_st(_st(aClass)._name()).__comma("2");
- } else {
- var counter;
- $7=_st(aClass)._name();
- $ctx1.sendIdx["name"]=2;
- $6=_st($7)._matchesOf_("\x5cd+$");
- $5=_st($6)._first();
- $4=_st($5)._asNumber();
- counter=_st($4).__plus((1));
- counter;
- $8=_st(aClass)._name();
- $ctx1.sendIdx["name"]=3;
- $1=_st($8)._replaceRegexp_with_("\x5cd+$"._asRegexp(),_st(counter)._asString());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"subclassNameFor:",{aClass:aClass},globals.Repl)})},
- args: ["aClass"],
- source: "subclassNameFor: aClass\x0a\x09^ (aClass name matchesOf: '\x5cd+$')\x0a\x09\x09ifNotNil: [ | counter |\x0a\x09\x09\x09counter := (aClass name matchesOf: '\x5cd+$') first asNumber + 1.\x0a\x09\x09\x09aClass name replaceRegexp: '\x5cd+$' asRegexp with: counter asString]\x0a\x09\x09ifNil: [\x0a\x09\x09\x09aClass name, '2'].",
- messageSends: ["ifNotNil:ifNil:", "matchesOf:", "name", "+", "asNumber", "first", "replaceRegexp:with:", "asRegexp", "asString", ","],
- referencedClasses: []
- }),
- globals.Repl);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "main",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._new())._createInterface();
- return self}, function($ctx1) {$ctx1.fill(self,"main",{},globals.Repl.klass)})},
- args: [],
- source: "main\x0a\x09self new createInterface",
- messageSends: ["createInterface", "new"],
- referencedClasses: []
- }),
- globals.Repl.klass);
- });
- define("amber_vm/_init", ["amber_vm/smalltalk", "amber_vm/globals", "amber_vm/smalltalk","amber_vm/globals","amber_vm/nil","amber_core/Kernel-Objects","amber_core/Kernel-Classes","amber_core/Kernel-Methods","amber_core/Kernel-Collections","amber_core/Kernel-Infrastructure","amber_core/Kernel-Exceptions","amber_core/Kernel-Transcript","amber_core/Kernel-Announcements","amber_core/Compiler-Exceptions","amber_core/Compiler-Core","amber_core/Compiler-AST","amber_core/Compiler-IR","amber_core/Compiler-Inlining","amber_core/Compiler-Semantic","amber_core/Compiler-Interpreter","amber_vm/parser","amber_cli/AmberCli"], function (smalltalk, globals) {
- smalltalk.initialize();
- globals.AmberCli._main();
- });
- requirejs("amber_vm/_init");
|