2
0

Kernel-Collections.js 226 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871
  1. define("amber_core/Kernel-Collections", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Kernel-Collections');
  3. smalltalk.packages["Kernel-Collections"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('Association', smalltalk.Object, ['key', 'value'], 'Kernel-Collections');
  5. smalltalk.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:`";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "=",
  9. protocol: 'comparing',
  10. fn: function (anAssociation){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $3,$2,$5,$4,$6,$1;
  14. $3=self._class();
  15. $ctx1.sendIdx["class"]=1;
  16. $2=_st($3).__eq(_st(anAssociation)._class());
  17. $ctx1.sendIdx["="]=1;
  18. $1=_st($2)._and_((function(){
  19. return smalltalk.withContext(function($ctx2) {
  20. $5=self._key();
  21. $ctx2.sendIdx["key"]=1;
  22. $4=_st($5).__eq(_st(anAssociation)._key());
  23. $ctx2.sendIdx["="]=2;
  24. return _st($4)._and_((function(){
  25. return smalltalk.withContext(function($ctx3) {
  26. $6=self._value();
  27. $ctx3.sendIdx["value"]=1;
  28. return _st($6).__eq(_st(anAssociation)._value());
  29. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  30. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  31. $ctx1.sendIdx["and:"]=1;
  32. return $1;
  33. }, function($ctx1) {$ctx1.fill(self,"=",{anAssociation:anAssociation},smalltalk.Association)})},
  34. args: ["anAssociation"],
  35. source: "= anAssociation\x0a\x09^ self class = anAssociation class and: [\x0a\x09\x09self key = anAssociation key and: [\x0a\x09\x09self value = anAssociation value ]]",
  36. messageSends: ["and:", "=", "class", "key", "value"],
  37. referencedClasses: []
  38. }),
  39. smalltalk.Association);
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "key",
  43. protocol: 'accessing',
  44. fn: function (){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx1) {
  47. var $1;
  48. $1=self["@key"];
  49. return $1;
  50. }, function($ctx1) {$ctx1.fill(self,"key",{},smalltalk.Association)})},
  51. args: [],
  52. source: "key\x0a\x09^ key",
  53. messageSends: [],
  54. referencedClasses: []
  55. }),
  56. smalltalk.Association);
  57. smalltalk.addMethod(
  58. smalltalk.method({
  59. selector: "key:",
  60. protocol: 'accessing',
  61. fn: function (aKey){
  62. var self=this;
  63. return smalltalk.withContext(function($ctx1) {
  64. self["@key"]=aKey;
  65. return self}, function($ctx1) {$ctx1.fill(self,"key:",{aKey:aKey},smalltalk.Association)})},
  66. args: ["aKey"],
  67. source: "key: aKey\x0a\x09key := aKey",
  68. messageSends: [],
  69. referencedClasses: []
  70. }),
  71. smalltalk.Association);
  72. smalltalk.addMethod(
  73. smalltalk.method({
  74. selector: "printOn:",
  75. protocol: 'printing',
  76. fn: function (aStream){
  77. var self=this;
  78. return smalltalk.withContext(function($ctx1) {
  79. _st(self._key())._printOn_(aStream);
  80. $ctx1.sendIdx["printOn:"]=1;
  81. _st(aStream)._nextPutAll_(" -> ");
  82. _st(self._value())._printOn_(aStream);
  83. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.Association)})},
  84. args: ["aStream"],
  85. source: "printOn: aStream\x0a\x09self key printOn: aStream.\x0a\x09aStream nextPutAll: ' -> '.\x0a\x09self value printOn: aStream",
  86. messageSends: ["printOn:", "key", "nextPutAll:", "value"],
  87. referencedClasses: []
  88. }),
  89. smalltalk.Association);
  90. smalltalk.addMethod(
  91. smalltalk.method({
  92. selector: "value",
  93. protocol: 'accessing',
  94. fn: function (){
  95. var self=this;
  96. return smalltalk.withContext(function($ctx1) {
  97. var $1;
  98. $1=self["@value"];
  99. return $1;
  100. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.Association)})},
  101. args: [],
  102. source: "value\x0a\x09^ value",
  103. messageSends: [],
  104. referencedClasses: []
  105. }),
  106. smalltalk.Association);
  107. smalltalk.addMethod(
  108. smalltalk.method({
  109. selector: "value:",
  110. protocol: 'accessing',
  111. fn: function (aValue){
  112. var self=this;
  113. return smalltalk.withContext(function($ctx1) {
  114. self["@value"]=aValue;
  115. return self}, function($ctx1) {$ctx1.fill(self,"value:",{aValue:aValue},smalltalk.Association)})},
  116. args: ["aValue"],
  117. source: "value: aValue\x0a\x09value := aValue",
  118. messageSends: [],
  119. referencedClasses: []
  120. }),
  121. smalltalk.Association);
  122. smalltalk.addMethod(
  123. smalltalk.method({
  124. selector: "key:value:",
  125. protocol: 'instance creation',
  126. fn: function (aKey,aValue){
  127. var self=this;
  128. return smalltalk.withContext(function($ctx1) {
  129. var $2,$3,$1;
  130. $2=self._new();
  131. _st($2)._key_(aKey);
  132. _st($2)._value_(aValue);
  133. $3=_st($2)._yourself();
  134. $1=$3;
  135. return $1;
  136. }, function($ctx1) {$ctx1.fill(self,"key:value:",{aKey:aKey,aValue:aValue},smalltalk.Association.klass)})},
  137. args: ["aKey", "aValue"],
  138. source: "key: aKey value: aValue\x0a\x09\x09^ self new\x0a\x09\x09key: aKey;\x0a\x09\x09value: aValue;\x0a\x09\x09yourself",
  139. messageSends: ["key:", "new", "value:", "yourself"],
  140. referencedClasses: []
  141. }),
  142. smalltalk.Association.klass);
  143. smalltalk.addClass('BucketStore', smalltalk.Object, ['buckets', 'hashBlock'], 'Kernel-Collections');
  144. smalltalk.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`.";
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "bucketOfElement:",
  148. protocol: 'accessing',
  149. fn: function (anObject){
  150. var self=this;
  151. return smalltalk.withContext(function($ctx1) {
  152. var hash = self['@hashBlock'](anObject);
  153. if (!hash) return null;
  154. var buckets = self['@buckets'],
  155. bucket = buckets[hash];
  156. if (!bucket) { bucket = buckets[hash] = self._newBucket(); }
  157. return bucket;
  158. ;
  159. return self}, function($ctx1) {$ctx1.fill(self,"bucketOfElement:",{anObject:anObject},smalltalk.BucketStore)})},
  160. args: ["anObject"],
  161. 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>",
  162. messageSends: [],
  163. referencedClasses: []
  164. }),
  165. smalltalk.BucketStore);
  166. smalltalk.addMethod(
  167. smalltalk.method({
  168. selector: "do:",
  169. protocol: 'enumerating',
  170. fn: function (aBlock){
  171. var self=this;
  172. return smalltalk.withContext(function($ctx1) {
  173. var buckets = self['@buckets'];
  174. var keys = Object.keys(buckets);
  175. for (var i = 0; i < keys.length; ++i) { buckets[keys[i]]._do_(aBlock); }
  176. ;
  177. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.BucketStore)})},
  178. args: ["aBlock"],
  179. 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>",
  180. messageSends: [],
  181. referencedClasses: []
  182. }),
  183. smalltalk.BucketStore);
  184. smalltalk.addMethod(
  185. smalltalk.method({
  186. selector: "hashBlock:",
  187. protocol: 'accessing',
  188. fn: function (aBlock){
  189. var self=this;
  190. return smalltalk.withContext(function($ctx1) {
  191. self["@hashBlock"]=aBlock;
  192. return self}, function($ctx1) {$ctx1.fill(self,"hashBlock:",{aBlock:aBlock},smalltalk.BucketStore)})},
  193. args: ["aBlock"],
  194. source: "hashBlock: aBlock\x0a\x09hashBlock := aBlock",
  195. messageSends: [],
  196. referencedClasses: []
  197. }),
  198. smalltalk.BucketStore);
  199. smalltalk.addMethod(
  200. smalltalk.method({
  201. selector: "initialize",
  202. protocol: 'initialization',
  203. fn: function (){
  204. var self=this;
  205. return smalltalk.withContext(function($ctx1) {
  206. smalltalk.BucketStore.superclass.fn.prototype._initialize.apply(_st(self), []);
  207. self._removeAll();
  208. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.BucketStore)})},
  209. args: [],
  210. source: "initialize\x0a\x09super initialize.\x0a\x09self removeAll",
  211. messageSends: ["initialize", "removeAll"],
  212. referencedClasses: []
  213. }),
  214. smalltalk.BucketStore);
  215. smalltalk.addMethod(
  216. smalltalk.method({
  217. selector: "newBucket",
  218. protocol: 'private',
  219. fn: function (){
  220. var self=this;
  221. return smalltalk.withContext(function($ctx1) {
  222. self._subclassResponsibility();
  223. return self}, function($ctx1) {$ctx1.fill(self,"newBucket",{},smalltalk.BucketStore)})},
  224. args: [],
  225. source: "newBucket\x0a\x09self subclassResponsibility",
  226. messageSends: ["subclassResponsibility"],
  227. referencedClasses: []
  228. }),
  229. smalltalk.BucketStore);
  230. smalltalk.addMethod(
  231. smalltalk.method({
  232. selector: "removeAll",
  233. protocol: 'adding/removing',
  234. fn: function (){
  235. var self=this;
  236. return smalltalk.withContext(function($ctx1) {
  237. self['@buckets'] = Object.create(null);;
  238. return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.BucketStore)})},
  239. args: [],
  240. source: "removeAll\x0a\x09<self['@buckets'] = Object.create(null);>",
  241. messageSends: [],
  242. referencedClasses: []
  243. }),
  244. smalltalk.BucketStore);
  245. smalltalk.addMethod(
  246. smalltalk.method({
  247. selector: "hashBlock:",
  248. protocol: 'instance creation',
  249. fn: function (aBlock){
  250. var self=this;
  251. return smalltalk.withContext(function($ctx1) {
  252. var $2,$3,$1;
  253. $2=self._new();
  254. _st($2)._hashBlock_(aBlock);
  255. $3=_st($2)._yourself();
  256. $1=$3;
  257. return $1;
  258. }, function($ctx1) {$ctx1.fill(self,"hashBlock:",{aBlock:aBlock},smalltalk.BucketStore.klass)})},
  259. args: ["aBlock"],
  260. source: "hashBlock: aBlock\x0a\x09^ self new\x0a\x09\x09hashBlock: aBlock;\x0a\x09\x09yourself",
  261. messageSends: ["hashBlock:", "new", "yourself"],
  262. referencedClasses: []
  263. }),
  264. smalltalk.BucketStore.klass);
  265. smalltalk.addClass('ArrayBucketStore', smalltalk.BucketStore, [], 'Kernel-Collections');
  266. smalltalk.ArrayBucketStore.comment="I am a concrete `BucketStore` with buckets being instance of `Array`.";
  267. smalltalk.addMethod(
  268. smalltalk.method({
  269. selector: "newBucket",
  270. protocol: 'private',
  271. fn: function (){
  272. var self=this;
  273. return smalltalk.withContext(function($ctx1) {
  274. var $1;
  275. $1=[];
  276. return $1;
  277. }, function($ctx1) {$ctx1.fill(self,"newBucket",{},smalltalk.ArrayBucketStore)})},
  278. args: [],
  279. source: "newBucket\x0a\x09^ #()",
  280. messageSends: [],
  281. referencedClasses: []
  282. }),
  283. smalltalk.ArrayBucketStore);
  284. smalltalk.addClass('Collection', smalltalk.Object, [], 'Kernel-Collections');
  285. smalltalk.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.";
  286. smalltalk.addMethod(
  287. smalltalk.method({
  288. selector: ",",
  289. protocol: 'copying',
  290. fn: function (aCollection){
  291. var self=this;
  292. return smalltalk.withContext(function($ctx1) {
  293. var $2,$3,$1;
  294. $2=self._copy();
  295. _st($2)._addAll_(aCollection);
  296. $3=_st($2)._yourself();
  297. $1=$3;
  298. return $1;
  299. }, function($ctx1) {$ctx1.fill(self,",",{aCollection:aCollection},smalltalk.Collection)})},
  300. args: ["aCollection"],
  301. source: ", aCollection\x0a\x09^ self copy\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself",
  302. messageSends: ["addAll:", "copy", "yourself"],
  303. referencedClasses: []
  304. }),
  305. smalltalk.Collection);
  306. smalltalk.addMethod(
  307. smalltalk.method({
  308. selector: "add:",
  309. protocol: 'adding/removing',
  310. fn: function (anObject){
  311. var self=this;
  312. return smalltalk.withContext(function($ctx1) {
  313. self._subclassResponsibility();
  314. return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},smalltalk.Collection)})},
  315. args: ["anObject"],
  316. source: "add: anObject\x0a\x09self subclassResponsibility",
  317. messageSends: ["subclassResponsibility"],
  318. referencedClasses: []
  319. }),
  320. smalltalk.Collection);
  321. smalltalk.addMethod(
  322. smalltalk.method({
  323. selector: "addAll:",
  324. protocol: 'adding/removing',
  325. fn: function (aCollection){
  326. var self=this;
  327. return smalltalk.withContext(function($ctx1) {
  328. _st(aCollection)._do_((function(each){
  329. return smalltalk.withContext(function($ctx2) {
  330. return self._add_(each);
  331. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  332. return aCollection;
  333. }, function($ctx1) {$ctx1.fill(self,"addAll:",{aCollection:aCollection},smalltalk.Collection)})},
  334. args: ["aCollection"],
  335. source: "addAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self add: each ].\x0a\x09^ aCollection",
  336. messageSends: ["do:", "add:"],
  337. referencedClasses: []
  338. }),
  339. smalltalk.Collection);
  340. smalltalk.addMethod(
  341. smalltalk.method({
  342. selector: "allSatisfy:",
  343. protocol: 'enumerating',
  344. fn: function (aBlock){
  345. var self=this;
  346. return smalltalk.withContext(function($ctx1) {
  347. var $1;
  348. var $early={};
  349. try {
  350. self._do_((function(each){
  351. return smalltalk.withContext(function($ctx2) {
  352. $1=_st(aBlock)._value_(each);
  353. if(! smalltalk.assert($1)){
  354. throw $early=[false];
  355. };
  356. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  357. return true;
  358. }
  359. catch(e) {if(e===$early)return e[0]; throw e}
  360. }, function($ctx1) {$ctx1.fill(self,"allSatisfy:",{aBlock:aBlock},smalltalk.Collection)})},
  361. args: ["aBlock"],
  362. 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",
  363. messageSends: ["do:", "ifFalse:", "value:"],
  364. referencedClasses: []
  365. }),
  366. smalltalk.Collection);
  367. smalltalk.addMethod(
  368. smalltalk.method({
  369. selector: "anyOne",
  370. protocol: 'adding/removing',
  371. fn: function (){
  372. var self=this;
  373. return smalltalk.withContext(function($ctx1) {
  374. var $early={};
  375. try {
  376. self._ifEmpty_((function(){
  377. return smalltalk.withContext(function($ctx2) {
  378. return self._error_("Collection is empty");
  379. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  380. self._do_((function(each){
  381. return smalltalk.withContext(function($ctx2) {
  382. throw $early=[each];
  383. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  384. return self}
  385. catch(e) {if(e===$early)return e[0]; throw e}
  386. }, function($ctx1) {$ctx1.fill(self,"anyOne",{},smalltalk.Collection)})},
  387. args: [],
  388. 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 ]",
  389. messageSends: ["ifEmpty:", "error:", "do:"],
  390. referencedClasses: []
  391. }),
  392. smalltalk.Collection);
  393. smalltalk.addMethod(
  394. smalltalk.method({
  395. selector: "anySatisfy:",
  396. protocol: 'enumerating',
  397. fn: function (aBlock){
  398. var self=this;
  399. return smalltalk.withContext(function($ctx1) {
  400. var $1;
  401. var $early={};
  402. try {
  403. self._do_((function(each){
  404. return smalltalk.withContext(function($ctx2) {
  405. $1=_st(aBlock)._value_(each);
  406. if(smalltalk.assert($1)){
  407. throw $early=[true];
  408. };
  409. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  410. return false;
  411. }
  412. catch(e) {if(e===$early)return e[0]; throw e}
  413. }, function($ctx1) {$ctx1.fill(self,"anySatisfy:",{aBlock:aBlock},smalltalk.Collection)})},
  414. args: ["aBlock"],
  415. 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",
  416. messageSends: ["do:", "ifTrue:", "value:"],
  417. referencedClasses: []
  418. }),
  419. smalltalk.Collection);
  420. smalltalk.addMethod(
  421. smalltalk.method({
  422. selector: "asArray",
  423. protocol: 'converting',
  424. fn: function (){
  425. var self=this;
  426. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  427. return smalltalk.withContext(function($ctx1) {
  428. var $1;
  429. $1=_st($Array())._withAll_(self);
  430. return $1;
  431. }, function($ctx1) {$ctx1.fill(self,"asArray",{},smalltalk.Collection)})},
  432. args: [],
  433. source: "asArray\x0a\x09^ Array withAll: self",
  434. messageSends: ["withAll:"],
  435. referencedClasses: ["Array"]
  436. }),
  437. smalltalk.Collection);
  438. smalltalk.addMethod(
  439. smalltalk.method({
  440. selector: "asJSON",
  441. protocol: 'converting',
  442. fn: function (){
  443. var self=this;
  444. return smalltalk.withContext(function($ctx1) {
  445. var $1;
  446. $1=_st(self._asArray())._collect_((function(each){
  447. return smalltalk.withContext(function($ctx2) {
  448. return _st(each)._asJSON();
  449. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  450. return $1;
  451. }, function($ctx1) {$ctx1.fill(self,"asJSON",{},smalltalk.Collection)})},
  452. args: [],
  453. source: "asJSON\x0a\x09^ self asArray collect: [ :each | each asJSON ]",
  454. messageSends: ["collect:", "asArray", "asJSON"],
  455. referencedClasses: []
  456. }),
  457. smalltalk.Collection);
  458. smalltalk.addMethod(
  459. smalltalk.method({
  460. selector: "asOrderedCollection",
  461. protocol: 'converting',
  462. fn: function (){
  463. var self=this;
  464. return smalltalk.withContext(function($ctx1) {
  465. var $1;
  466. $1=self._asArray();
  467. return $1;
  468. }, function($ctx1) {$ctx1.fill(self,"asOrderedCollection",{},smalltalk.Collection)})},
  469. args: [],
  470. source: "asOrderedCollection\x0a\x09^ self asArray",
  471. messageSends: ["asArray"],
  472. referencedClasses: []
  473. }),
  474. smalltalk.Collection);
  475. smalltalk.addMethod(
  476. smalltalk.method({
  477. selector: "asSet",
  478. protocol: 'converting',
  479. fn: function (){
  480. var self=this;
  481. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  482. return smalltalk.withContext(function($ctx1) {
  483. var $1;
  484. $1=_st($Set())._withAll_(self);
  485. return $1;
  486. }, function($ctx1) {$ctx1.fill(self,"asSet",{},smalltalk.Collection)})},
  487. args: [],
  488. source: "asSet\x0a\x09^ Set withAll: self",
  489. messageSends: ["withAll:"],
  490. referencedClasses: ["Set"]
  491. }),
  492. smalltalk.Collection);
  493. smalltalk.addMethod(
  494. smalltalk.method({
  495. selector: "collect:",
  496. protocol: 'enumerating',
  497. fn: function (aBlock){
  498. var self=this;
  499. var stream;
  500. return smalltalk.withContext(function($ctx1) {
  501. var $1;
  502. stream=_st(_st(self._class())._new())._writeStream();
  503. self._do_((function(each){
  504. return smalltalk.withContext(function($ctx2) {
  505. return _st(stream)._nextPut_(_st(aBlock)._value_(each));
  506. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  507. $1=_st(stream)._contents();
  508. return $1;
  509. }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,stream:stream},smalltalk.Collection)})},
  510. args: ["aBlock"],
  511. 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",
  512. messageSends: ["writeStream", "new", "class", "do:", "nextPut:", "value:", "contents"],
  513. referencedClasses: []
  514. }),
  515. smalltalk.Collection);
  516. smalltalk.addMethod(
  517. smalltalk.method({
  518. selector: "contains:",
  519. protocol: 'testing',
  520. fn: function (aBlock){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. var $1;
  524. self._deprecatedAPI();
  525. $1=self._anySatisfy_(aBlock);
  526. return $1;
  527. }, function($ctx1) {$ctx1.fill(self,"contains:",{aBlock:aBlock},smalltalk.Collection)})},
  528. args: ["aBlock"],
  529. source: "contains: aBlock\x0a\x09self deprecatedAPI.\x0a\x0a\x09^ self anySatisfy: aBlock",
  530. messageSends: ["deprecatedAPI", "anySatisfy:"],
  531. referencedClasses: []
  532. }),
  533. smalltalk.Collection);
  534. smalltalk.addMethod(
  535. smalltalk.method({
  536. selector: "copyWith:",
  537. protocol: 'copying',
  538. fn: function (anObject){
  539. var self=this;
  540. return smalltalk.withContext(function($ctx1) {
  541. var $2,$3,$1;
  542. $2=self._copy();
  543. _st($2)._add_(anObject);
  544. $3=_st($2)._yourself();
  545. $1=$3;
  546. return $1;
  547. }, function($ctx1) {$ctx1.fill(self,"copyWith:",{anObject:anObject},smalltalk.Collection)})},
  548. args: ["anObject"],
  549. source: "copyWith: anObject\x0a\x09^ self copy add: anObject; yourself",
  550. messageSends: ["add:", "copy", "yourself"],
  551. referencedClasses: []
  552. }),
  553. smalltalk.Collection);
  554. smalltalk.addMethod(
  555. smalltalk.method({
  556. selector: "copyWithAll:",
  557. protocol: 'copying',
  558. fn: function (aCollection){
  559. var self=this;
  560. return smalltalk.withContext(function($ctx1) {
  561. var $2,$3,$1;
  562. $2=self._copy();
  563. _st($2)._addAll_(aCollection);
  564. $3=_st($2)._yourself();
  565. $1=$3;
  566. return $1;
  567. }, function($ctx1) {$ctx1.fill(self,"copyWithAll:",{aCollection:aCollection},smalltalk.Collection)})},
  568. args: ["aCollection"],
  569. source: "copyWithAll: aCollection\x0a\x09^ self copy addAll: aCollection; yourself",
  570. messageSends: ["addAll:", "copy", "yourself"],
  571. referencedClasses: []
  572. }),
  573. smalltalk.Collection);
  574. smalltalk.addMethod(
  575. smalltalk.method({
  576. selector: "copyWithoutAll:",
  577. protocol: 'copying',
  578. fn: function (aCollection){
  579. var self=this;
  580. return smalltalk.withContext(function($ctx1) {
  581. var $1;
  582. $1=self._reject_((function(each){
  583. return smalltalk.withContext(function($ctx2) {
  584. return _st(aCollection)._includes_(each);
  585. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  586. return $1;
  587. }, function($ctx1) {$ctx1.fill(self,"copyWithoutAll:",{aCollection:aCollection},smalltalk.Collection)})},
  588. args: ["aCollection"],
  589. 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 ]",
  590. messageSends: ["reject:", "includes:"],
  591. referencedClasses: []
  592. }),
  593. smalltalk.Collection);
  594. smalltalk.addMethod(
  595. smalltalk.method({
  596. selector: "detect:",
  597. protocol: 'enumerating',
  598. fn: function (aBlock){
  599. var self=this;
  600. return smalltalk.withContext(function($ctx1) {
  601. var $1;
  602. $1=self._detect_ifNone_(aBlock,(function(){
  603. return smalltalk.withContext(function($ctx2) {
  604. return self._errorNotFound();
  605. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  606. return $1;
  607. }, function($ctx1) {$ctx1.fill(self,"detect:",{aBlock:aBlock},smalltalk.Collection)})},
  608. args: ["aBlock"],
  609. source: "detect: aBlock\x0a\x09^ self detect: aBlock ifNone: [ self errorNotFound ]",
  610. messageSends: ["detect:ifNone:", "errorNotFound"],
  611. referencedClasses: []
  612. }),
  613. smalltalk.Collection);
  614. smalltalk.addMethod(
  615. smalltalk.method({
  616. selector: "detect:ifNone:",
  617. protocol: 'enumerating',
  618. fn: function (aBlock,anotherBlock){
  619. var self=this;
  620. return smalltalk.withContext(function($ctx1) {
  621. self._subclassResponsibility();
  622. return self}, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.Collection)})},
  623. args: ["aBlock", "anotherBlock"],
  624. source: "detect: aBlock ifNone: anotherBlock\x0a\x09self subclassResponsibility",
  625. messageSends: ["subclassResponsibility"],
  626. referencedClasses: []
  627. }),
  628. smalltalk.Collection);
  629. smalltalk.addMethod(
  630. smalltalk.method({
  631. selector: "do:",
  632. protocol: 'enumerating',
  633. fn: function (aBlock){
  634. var self=this;
  635. return smalltalk.withContext(function($ctx1) {
  636. self._subclassResponsibility();
  637. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.Collection)})},
  638. args: ["aBlock"],
  639. source: "do: aBlock\x0a\x09self subclassResponsibility",
  640. messageSends: ["subclassResponsibility"],
  641. referencedClasses: []
  642. }),
  643. smalltalk.Collection);
  644. smalltalk.addMethod(
  645. smalltalk.method({
  646. selector: "do:separatedBy:",
  647. protocol: 'enumerating',
  648. fn: function (aBlock,anotherBlock){
  649. var self=this;
  650. var actionBeforeElement;
  651. return smalltalk.withContext(function($ctx1) {
  652. actionBeforeElement=(function(){
  653. return smalltalk.withContext(function($ctx2) {
  654. actionBeforeElement=anotherBlock;
  655. return actionBeforeElement;
  656. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  657. self._do_((function(each){
  658. return smalltalk.withContext(function($ctx2) {
  659. _st(actionBeforeElement)._value();
  660. return _st(aBlock)._value_(each);
  661. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  662. return self}, function($ctx1) {$ctx1.fill(self,"do:separatedBy:",{aBlock:aBlock,anotherBlock:anotherBlock,actionBeforeElement:actionBeforeElement},smalltalk.Collection)})},
  663. args: ["aBlock", "anotherBlock"],
  664. 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 ]",
  665. messageSends: ["do:", "value", "value:"],
  666. referencedClasses: []
  667. }),
  668. smalltalk.Collection);
  669. smalltalk.addMethod(
  670. smalltalk.method({
  671. selector: "errorNotFound",
  672. protocol: 'error handling',
  673. fn: function (){
  674. var self=this;
  675. return smalltalk.withContext(function($ctx1) {
  676. self._error_("Object is not in the collection");
  677. return self}, function($ctx1) {$ctx1.fill(self,"errorNotFound",{},smalltalk.Collection)})},
  678. args: [],
  679. source: "errorNotFound\x0a\x09self error: 'Object is not in the collection'",
  680. messageSends: ["error:"],
  681. referencedClasses: []
  682. }),
  683. smalltalk.Collection);
  684. smalltalk.addMethod(
  685. smalltalk.method({
  686. selector: "ifEmpty:",
  687. protocol: 'testing',
  688. fn: function (aBlock){
  689. var self=this;
  690. return smalltalk.withContext(function($ctx1) {
  691. var $2,$1;
  692. $2=self._isEmpty();
  693. $1=_st($2)._ifTrue_ifFalse_(aBlock,(function(){
  694. return smalltalk.withContext(function($ctx2) {
  695. return self;
  696. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  697. return $1;
  698. }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock},smalltalk.Collection)})},
  699. args: ["aBlock"],
  700. 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 ]",
  701. messageSends: ["ifTrue:ifFalse:", "isEmpty"],
  702. referencedClasses: []
  703. }),
  704. smalltalk.Collection);
  705. smalltalk.addMethod(
  706. smalltalk.method({
  707. selector: "ifEmpty:ifNotEmpty:",
  708. protocol: 'testing',
  709. fn: function (aBlock,anotherBlock){
  710. var self=this;
  711. return smalltalk.withContext(function($ctx1) {
  712. var $2,$1;
  713. $2=self._isEmpty();
  714. $1=_st($2)._ifTrue_ifFalse_(aBlock,anotherBlock);
  715. return $1;
  716. }, function($ctx1) {$ctx1.fill(self,"ifEmpty:ifNotEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.Collection)})},
  717. args: ["aBlock", "anotherBlock"],
  718. source: "ifEmpty: aBlock ifNotEmpty: anotherBlock\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: anotherBlock",
  719. messageSends: ["ifTrue:ifFalse:", "isEmpty"],
  720. referencedClasses: []
  721. }),
  722. smalltalk.Collection);
  723. smalltalk.addMethod(
  724. smalltalk.method({
  725. selector: "ifNotEmpty:",
  726. protocol: 'testing',
  727. fn: function (aBlock){
  728. var self=this;
  729. return smalltalk.withContext(function($ctx1) {
  730. var $2,$1;
  731. $2=self._notEmpty();
  732. $1=_st($2)._ifTrue_ifFalse_(aBlock,(function(){
  733. return smalltalk.withContext(function($ctx2) {
  734. return self;
  735. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  736. return $1;
  737. }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:",{aBlock:aBlock},smalltalk.Collection)})},
  738. args: ["aBlock"],
  739. source: "ifNotEmpty: aBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ self ]",
  740. messageSends: ["ifTrue:ifFalse:", "notEmpty"],
  741. referencedClasses: []
  742. }),
  743. smalltalk.Collection);
  744. smalltalk.addMethod(
  745. smalltalk.method({
  746. selector: "ifNotEmpty:ifEmpty:",
  747. protocol: 'testing',
  748. fn: function (aBlock,anotherBlock){
  749. var self=this;
  750. return smalltalk.withContext(function($ctx1) {
  751. var $2,$1;
  752. $2=self._notEmpty();
  753. $1=_st($2)._ifTrue_ifFalse_(aBlock,anotherBlock);
  754. return $1;
  755. }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:ifEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.Collection)})},
  756. args: ["aBlock", "anotherBlock"],
  757. source: "ifNotEmpty: aBlock ifEmpty: anotherBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: anotherBlock",
  758. messageSends: ["ifTrue:ifFalse:", "notEmpty"],
  759. referencedClasses: []
  760. }),
  761. smalltalk.Collection);
  762. smalltalk.addMethod(
  763. smalltalk.method({
  764. selector: "includes:",
  765. protocol: 'testing',
  766. fn: function (anObject){
  767. var self=this;
  768. return smalltalk.withContext(function($ctx1) {
  769. var $1;
  770. $1=self._anySatisfy_((function(each){
  771. return smalltalk.withContext(function($ctx2) {
  772. return _st(each).__eq(anObject);
  773. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  774. return $1;
  775. }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},smalltalk.Collection)})},
  776. args: ["anObject"],
  777. source: "includes: anObject\x0a\x09^ self anySatisfy: [ :each | each = anObject ]",
  778. messageSends: ["anySatisfy:", "="],
  779. referencedClasses: []
  780. }),
  781. smalltalk.Collection);
  782. smalltalk.addMethod(
  783. smalltalk.method({
  784. selector: "inject:into:",
  785. protocol: 'enumerating',
  786. fn: function (anObject,aBlock){
  787. var self=this;
  788. var result;
  789. return smalltalk.withContext(function($ctx1) {
  790. var $1;
  791. result=anObject;
  792. self._do_((function(each){
  793. return smalltalk.withContext(function($ctx2) {
  794. result=_st(aBlock)._value_value_(result,each);
  795. return result;
  796. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  797. $1=result;
  798. return $1;
  799. }, function($ctx1) {$ctx1.fill(self,"inject:into:",{anObject:anObject,aBlock:aBlock,result:result},smalltalk.Collection)})},
  800. args: ["anObject", "aBlock"],
  801. 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",
  802. messageSends: ["do:", "value:value:"],
  803. referencedClasses: []
  804. }),
  805. smalltalk.Collection);
  806. smalltalk.addMethod(
  807. smalltalk.method({
  808. selector: "intersection:",
  809. protocol: 'enumerating',
  810. fn: function (aCollection){
  811. var self=this;
  812. var set,outputSet;
  813. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  814. return smalltalk.withContext(function($ctx1) {
  815. var $2,$1,$3;
  816. set=self._asSet();
  817. outputSet=_st($Set())._new();
  818. _st(aCollection)._do_((function(each){
  819. return smalltalk.withContext(function($ctx2) {
  820. $2=_st(set)._includes_(each);
  821. $ctx2.sendIdx["includes:"]=1;
  822. $1=_st($2)._and_((function(){
  823. return smalltalk.withContext(function($ctx3) {
  824. return _st(_st(outputSet)._includes_(each))._not();
  825. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  826. if(smalltalk.assert($1)){
  827. return _st(outputSet)._add_(each);
  828. };
  829. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  830. $3=_st(self._class())._withAll_(_st(outputSet)._asArray());
  831. return $3;
  832. }, function($ctx1) {$ctx1.fill(self,"intersection:",{aCollection:aCollection,set:set,outputSet:outputSet},smalltalk.Collection)})},
  833. args: ["aCollection"],
  834. 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",
  835. messageSends: ["asSet", "new", "do:", "ifTrue:", "and:", "includes:", "not", "add:", "withAll:", "class", "asArray"],
  836. referencedClasses: ["Set"]
  837. }),
  838. smalltalk.Collection);
  839. smalltalk.addMethod(
  840. smalltalk.method({
  841. selector: "isEmpty",
  842. protocol: 'testing',
  843. fn: function (){
  844. var self=this;
  845. return smalltalk.withContext(function($ctx1) {
  846. var $1;
  847. $1=_st(self._size()).__eq((0));
  848. return $1;
  849. }, function($ctx1) {$ctx1.fill(self,"isEmpty",{},smalltalk.Collection)})},
  850. args: [],
  851. source: "isEmpty\x0a\x09^ self size = 0",
  852. messageSends: ["=", "size"],
  853. referencedClasses: []
  854. }),
  855. smalltalk.Collection);
  856. smalltalk.addMethod(
  857. smalltalk.method({
  858. selector: "noneSatisfy:",
  859. protocol: 'enumerating',
  860. fn: function (aBlock){
  861. var self=this;
  862. return smalltalk.withContext(function($ctx1) {
  863. var $1;
  864. var $early={};
  865. try {
  866. self._do_((function(item){
  867. return smalltalk.withContext(function($ctx2) {
  868. $1=_st(aBlock)._value_(item);
  869. if(smalltalk.assert($1)){
  870. throw $early=[false];
  871. };
  872. }, function($ctx2) {$ctx2.fillBlock({item:item},$ctx1,1)})}));
  873. return true;
  874. }
  875. catch(e) {if(e===$early)return e[0]; throw e}
  876. }, function($ctx1) {$ctx1.fill(self,"noneSatisfy:",{aBlock:aBlock},smalltalk.Collection)})},
  877. args: ["aBlock"],
  878. 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",
  879. messageSends: ["do:", "ifTrue:", "value:"],
  880. referencedClasses: []
  881. }),
  882. smalltalk.Collection);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "notEmpty",
  886. protocol: 'testing',
  887. fn: function (){
  888. var self=this;
  889. return smalltalk.withContext(function($ctx1) {
  890. var $1;
  891. $1=_st(self._isEmpty())._not();
  892. return $1;
  893. }, function($ctx1) {$ctx1.fill(self,"notEmpty",{},smalltalk.Collection)})},
  894. args: [],
  895. source: "notEmpty\x0a\x09^ self isEmpty not",
  896. messageSends: ["not", "isEmpty"],
  897. referencedClasses: []
  898. }),
  899. smalltalk.Collection);
  900. smalltalk.addMethod(
  901. smalltalk.method({
  902. selector: "occurrencesOf:",
  903. protocol: 'accessing',
  904. fn: function (anObject){
  905. var self=this;
  906. var tally;
  907. return smalltalk.withContext(function($ctx1) {
  908. var $1,$2;
  909. tally=(0);
  910. self._do_((function(each){
  911. return smalltalk.withContext(function($ctx2) {
  912. $1=_st(anObject).__eq(each);
  913. if(smalltalk.assert($1)){
  914. tally=_st(tally).__plus((1));
  915. return tally;
  916. };
  917. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  918. $2=tally;
  919. return $2;
  920. }, function($ctx1) {$ctx1.fill(self,"occurrencesOf:",{anObject:anObject,tally:tally},smalltalk.Collection)})},
  921. args: ["anObject"],
  922. 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",
  923. messageSends: ["do:", "ifTrue:", "=", "+"],
  924. referencedClasses: []
  925. }),
  926. smalltalk.Collection);
  927. smalltalk.addMethod(
  928. smalltalk.method({
  929. selector: "putOn:",
  930. protocol: 'streaming',
  931. fn: function (aStream){
  932. var self=this;
  933. return smalltalk.withContext(function($ctx1) {
  934. self._do_((function(each){
  935. return smalltalk.withContext(function($ctx2) {
  936. return _st(each)._putOn_(aStream);
  937. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  938. return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},smalltalk.Collection)})},
  939. args: ["aStream"],
  940. source: "putOn: aStream\x0a\x09self do: [ :each | each putOn: aStream ]",
  941. messageSends: ["do:", "putOn:"],
  942. referencedClasses: []
  943. }),
  944. smalltalk.Collection);
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "reject:",
  948. protocol: 'enumerating',
  949. fn: function (aBlock){
  950. var self=this;
  951. return smalltalk.withContext(function($ctx1) {
  952. var $1;
  953. $1=self._select_((function(each){
  954. return smalltalk.withContext(function($ctx2) {
  955. return _st(_st(aBlock)._value_(each)).__eq(false);
  956. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  957. return $1;
  958. }, function($ctx1) {$ctx1.fill(self,"reject:",{aBlock:aBlock},smalltalk.Collection)})},
  959. args: ["aBlock"],
  960. source: "reject: aBlock\x0a\x09^ self select: [ :each | (aBlock value: each) = false ]",
  961. messageSends: ["select:", "=", "value:"],
  962. referencedClasses: []
  963. }),
  964. smalltalk.Collection);
  965. smalltalk.addMethod(
  966. smalltalk.method({
  967. selector: "remove:",
  968. protocol: 'adding/removing',
  969. fn: function (anObject){
  970. var self=this;
  971. return smalltalk.withContext(function($ctx1) {
  972. var $1;
  973. $1=self._remove_ifAbsent_(anObject,(function(){
  974. return smalltalk.withContext(function($ctx2) {
  975. return self._errorNotFound();
  976. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  977. return $1;
  978. }, function($ctx1) {$ctx1.fill(self,"remove:",{anObject:anObject},smalltalk.Collection)})},
  979. args: ["anObject"],
  980. source: "remove: anObject\x0a\x09^ self remove: anObject ifAbsent: [ self errorNotFound ]",
  981. messageSends: ["remove:ifAbsent:", "errorNotFound"],
  982. referencedClasses: []
  983. }),
  984. smalltalk.Collection);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "remove:ifAbsent:",
  988. protocol: 'adding/removing',
  989. fn: function (anObject,aBlock){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. self._subclassResponsibility();
  993. return self}, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock},smalltalk.Collection)})},
  994. args: ["anObject", "aBlock"],
  995. source: "remove: anObject ifAbsent: aBlock\x0a\x09self subclassResponsibility",
  996. messageSends: ["subclassResponsibility"],
  997. referencedClasses: []
  998. }),
  999. smalltalk.Collection);
  1000. smalltalk.addMethod(
  1001. smalltalk.method({
  1002. selector: "removeAll",
  1003. protocol: 'adding/removing',
  1004. fn: function (){
  1005. var self=this;
  1006. return smalltalk.withContext(function($ctx1) {
  1007. self._subclassResponsibility();
  1008. return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.Collection)})},
  1009. args: [],
  1010. source: "removeAll\x0a\x09self subclassResponsibility",
  1011. messageSends: ["subclassResponsibility"],
  1012. referencedClasses: []
  1013. }),
  1014. smalltalk.Collection);
  1015. smalltalk.addMethod(
  1016. smalltalk.method({
  1017. selector: "select:",
  1018. protocol: 'enumerating',
  1019. fn: function (aBlock){
  1020. var self=this;
  1021. var stream;
  1022. return smalltalk.withContext(function($ctx1) {
  1023. var $1,$2;
  1024. stream=_st(_st(self._class())._new())._writeStream();
  1025. self._do_((function(each){
  1026. return smalltalk.withContext(function($ctx2) {
  1027. $1=_st(aBlock)._value_(each);
  1028. if(smalltalk.assert($1)){
  1029. return _st(stream)._nextPut_(each);
  1030. };
  1031. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1032. $2=_st(stream)._contents();
  1033. return $2;
  1034. }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,stream:stream},smalltalk.Collection)})},
  1035. args: ["aBlock"],
  1036. 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",
  1037. messageSends: ["writeStream", "new", "class", "do:", "ifTrue:", "value:", "nextPut:", "contents"],
  1038. referencedClasses: []
  1039. }),
  1040. smalltalk.Collection);
  1041. smalltalk.addMethod(
  1042. smalltalk.method({
  1043. selector: "select:thenCollect:",
  1044. protocol: 'enumerating',
  1045. fn: function (selectBlock,collectBlock){
  1046. var self=this;
  1047. var stream;
  1048. return smalltalk.withContext(function($ctx1) {
  1049. var $1,$2;
  1050. stream=_st(_st(self._class())._new())._writeStream();
  1051. self._do_((function(each){
  1052. return smalltalk.withContext(function($ctx2) {
  1053. $1=_st(selectBlock)._value_(each);
  1054. $ctx2.sendIdx["value:"]=1;
  1055. if(smalltalk.assert($1)){
  1056. return _st(stream)._nextPut_(_st(collectBlock)._value_(each));
  1057. };
  1058. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1059. $2=_st(stream)._contents();
  1060. return $2;
  1061. }, function($ctx1) {$ctx1.fill(self,"select:thenCollect:",{selectBlock:selectBlock,collectBlock:collectBlock,stream:stream},smalltalk.Collection)})},
  1062. args: ["selectBlock", "collectBlock"],
  1063. 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",
  1064. messageSends: ["writeStream", "new", "class", "do:", "ifTrue:", "value:", "nextPut:", "contents"],
  1065. referencedClasses: []
  1066. }),
  1067. smalltalk.Collection);
  1068. smalltalk.addMethod(
  1069. smalltalk.method({
  1070. selector: "size",
  1071. protocol: 'accessing',
  1072. fn: function (){
  1073. var self=this;
  1074. return smalltalk.withContext(function($ctx1) {
  1075. self._subclassResponsibility();
  1076. return self}, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.Collection)})},
  1077. args: [],
  1078. source: "size\x0a\x09self subclassResponsibility",
  1079. messageSends: ["subclassResponsibility"],
  1080. referencedClasses: []
  1081. }),
  1082. smalltalk.Collection);
  1083. smalltalk.addMethod(
  1084. smalltalk.method({
  1085. selector: "heliosClass",
  1086. protocol: 'helios',
  1087. fn: function (){
  1088. var self=this;
  1089. return smalltalk.withContext(function($ctx1) {
  1090. return "collection";
  1091. }, function($ctx1) {$ctx1.fill(self,"heliosClass",{},smalltalk.Collection.klass)})},
  1092. args: [],
  1093. source: "heliosClass\x0a\x09^ 'collection'",
  1094. messageSends: [],
  1095. referencedClasses: []
  1096. }),
  1097. smalltalk.Collection.klass);
  1098. smalltalk.addMethod(
  1099. smalltalk.method({
  1100. selector: "new:",
  1101. protocol: 'instance creation',
  1102. fn: function (anInteger){
  1103. var self=this;
  1104. return smalltalk.withContext(function($ctx1) {
  1105. var $1;
  1106. $1=self._new();
  1107. return $1;
  1108. }, function($ctx1) {$ctx1.fill(self,"new:",{anInteger:anInteger},smalltalk.Collection.klass)})},
  1109. args: ["anInteger"],
  1110. source: "new: anInteger\x0a\x09^ self new",
  1111. messageSends: ["new"],
  1112. referencedClasses: []
  1113. }),
  1114. smalltalk.Collection.klass);
  1115. smalltalk.addMethod(
  1116. smalltalk.method({
  1117. selector: "with:",
  1118. protocol: 'instance creation',
  1119. fn: function (anObject){
  1120. var self=this;
  1121. return smalltalk.withContext(function($ctx1) {
  1122. var $2,$3,$1;
  1123. $2=self._new();
  1124. _st($2)._add_(anObject);
  1125. $3=_st($2)._yourself();
  1126. $1=$3;
  1127. return $1;
  1128. }, function($ctx1) {$ctx1.fill(self,"with:",{anObject:anObject},smalltalk.Collection.klass)})},
  1129. args: ["anObject"],
  1130. source: "with: anObject\x0a\x09\x09^ self new\x0a\x09\x09add: anObject;\x0a\x09\x09yourself",
  1131. messageSends: ["add:", "new", "yourself"],
  1132. referencedClasses: []
  1133. }),
  1134. smalltalk.Collection.klass);
  1135. smalltalk.addMethod(
  1136. smalltalk.method({
  1137. selector: "with:with:",
  1138. protocol: 'instance creation',
  1139. fn: function (anObject,anotherObject){
  1140. var self=this;
  1141. return smalltalk.withContext(function($ctx1) {
  1142. var $2,$3,$1;
  1143. $2=self._new();
  1144. _st($2)._add_(anObject);
  1145. $ctx1.sendIdx["add:"]=1;
  1146. _st($2)._add_(anotherObject);
  1147. $3=_st($2)._yourself();
  1148. $1=$3;
  1149. return $1;
  1150. }, function($ctx1) {$ctx1.fill(self,"with:with:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Collection.klass)})},
  1151. args: ["anObject", "anotherObject"],
  1152. source: "with: anObject with: anotherObject\x0a\x09\x09^ self new\x0a\x09\x09add: anObject;\x0a\x09\x09add: anotherObject;\x0a\x09\x09yourself",
  1153. messageSends: ["add:", "new", "yourself"],
  1154. referencedClasses: []
  1155. }),
  1156. smalltalk.Collection.klass);
  1157. smalltalk.addMethod(
  1158. smalltalk.method({
  1159. selector: "with:with:with:",
  1160. protocol: 'instance creation',
  1161. fn: function (firstObject,secondObject,thirdObject){
  1162. var self=this;
  1163. return smalltalk.withContext(function($ctx1) {
  1164. var $2,$3,$1;
  1165. $2=self._new();
  1166. _st($2)._add_(firstObject);
  1167. $ctx1.sendIdx["add:"]=1;
  1168. _st($2)._add_(secondObject);
  1169. $ctx1.sendIdx["add:"]=2;
  1170. _st($2)._add_(thirdObject);
  1171. $3=_st($2)._yourself();
  1172. $1=$3;
  1173. return $1;
  1174. }, function($ctx1) {$ctx1.fill(self,"with:with:with:",{firstObject:firstObject,secondObject:secondObject,thirdObject:thirdObject},smalltalk.Collection.klass)})},
  1175. args: ["firstObject", "secondObject", "thirdObject"],
  1176. 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",
  1177. messageSends: ["add:", "new", "yourself"],
  1178. referencedClasses: []
  1179. }),
  1180. smalltalk.Collection.klass);
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "withAll:",
  1184. protocol: 'instance creation',
  1185. fn: function (aCollection){
  1186. var self=this;
  1187. return smalltalk.withContext(function($ctx1) {
  1188. var $2,$3,$1;
  1189. $2=self._new();
  1190. _st($2)._addAll_(aCollection);
  1191. $3=_st($2)._yourself();
  1192. $1=$3;
  1193. return $1;
  1194. }, function($ctx1) {$ctx1.fill(self,"withAll:",{aCollection:aCollection},smalltalk.Collection.klass)})},
  1195. args: ["aCollection"],
  1196. source: "withAll: aCollection\x0a\x09\x09^ self new\x0a\x09\x09addAll: aCollection;\x0a\x09\x09yourself",
  1197. messageSends: ["addAll:", "new", "yourself"],
  1198. referencedClasses: []
  1199. }),
  1200. smalltalk.Collection.klass);
  1201. smalltalk.addClass('IndexableCollection', smalltalk.Collection, [], 'Kernel-Collections');
  1202. smalltalk.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.";
  1203. smalltalk.addMethod(
  1204. smalltalk.method({
  1205. selector: "at:",
  1206. protocol: 'accessing',
  1207. fn: function (anIndex){
  1208. var self=this;
  1209. return smalltalk.withContext(function($ctx1) {
  1210. var $1;
  1211. $1=self._at_ifAbsent_(anIndex,(function(){
  1212. return smalltalk.withContext(function($ctx2) {
  1213. return self._errorNotFound();
  1214. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1215. return $1;
  1216. }, function($ctx1) {$ctx1.fill(self,"at:",{anIndex:anIndex},smalltalk.IndexableCollection)})},
  1217. args: ["anIndex"],
  1218. 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 ]",
  1219. messageSends: ["at:ifAbsent:", "errorNotFound"],
  1220. referencedClasses: []
  1221. }),
  1222. smalltalk.IndexableCollection);
  1223. smalltalk.addMethod(
  1224. smalltalk.method({
  1225. selector: "at:ifAbsent:",
  1226. protocol: 'accessing',
  1227. fn: function (anIndex,aBlock){
  1228. var self=this;
  1229. return smalltalk.withContext(function($ctx1) {
  1230. self._subclassResponsibility();
  1231. return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},smalltalk.IndexableCollection)})},
  1232. args: ["anIndex", "aBlock"],
  1233. 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",
  1234. messageSends: ["subclassResponsibility"],
  1235. referencedClasses: []
  1236. }),
  1237. smalltalk.IndexableCollection);
  1238. smalltalk.addMethod(
  1239. smalltalk.method({
  1240. selector: "at:ifAbsentPut:",
  1241. protocol: 'accessing',
  1242. fn: function (aKey,aBlock){
  1243. var self=this;
  1244. return smalltalk.withContext(function($ctx1) {
  1245. var $1;
  1246. $1=self._at_ifAbsent_(aKey,(function(){
  1247. return smalltalk.withContext(function($ctx2) {
  1248. return self._at_put_(aKey,_st(aBlock)._value());
  1249. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1250. return $1;
  1251. }, function($ctx1) {$ctx1.fill(self,"at:ifAbsentPut:",{aKey:aKey,aBlock:aBlock},smalltalk.IndexableCollection)})},
  1252. args: ["aKey", "aBlock"],
  1253. source: "at: aKey ifAbsentPut: aBlock\x0a\x09^ self at: aKey ifAbsent: [\x0a\x09\x09self at: aKey put: aBlock value ]",
  1254. messageSends: ["at:ifAbsent:", "at:put:", "value"],
  1255. referencedClasses: []
  1256. }),
  1257. smalltalk.IndexableCollection);
  1258. smalltalk.addMethod(
  1259. smalltalk.method({
  1260. selector: "at:ifPresent:",
  1261. protocol: 'accessing',
  1262. fn: function (anIndex,aBlock){
  1263. var self=this;
  1264. return smalltalk.withContext(function($ctx1) {
  1265. var $1;
  1266. $1=self._at_ifPresent_ifAbsent_(anIndex,aBlock,(function(){
  1267. return smalltalk.withContext(function($ctx2) {
  1268. return nil;
  1269. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1270. return $1;
  1271. }, function($ctx1) {$ctx1.fill(self,"at:ifPresent:",{anIndex:anIndex,aBlock:aBlock},smalltalk.IndexableCollection)})},
  1272. args: ["anIndex", "aBlock"],
  1273. 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 ]",
  1274. messageSends: ["at:ifPresent:ifAbsent:"],
  1275. referencedClasses: []
  1276. }),
  1277. smalltalk.IndexableCollection);
  1278. smalltalk.addMethod(
  1279. smalltalk.method({
  1280. selector: "at:ifPresent:ifAbsent:",
  1281. protocol: 'accessing',
  1282. fn: function (anIndex,aBlock,anotherBlock){
  1283. var self=this;
  1284. return smalltalk.withContext(function($ctx1) {
  1285. self._subclassResponsibility();
  1286. return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.IndexableCollection)})},
  1287. args: ["anIndex", "aBlock", "anotherBlock"],
  1288. 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",
  1289. messageSends: ["subclassResponsibility"],
  1290. referencedClasses: []
  1291. }),
  1292. smalltalk.IndexableCollection);
  1293. smalltalk.addMethod(
  1294. smalltalk.method({
  1295. selector: "at:put:",
  1296. protocol: 'accessing',
  1297. fn: function (anIndex,anObject){
  1298. var self=this;
  1299. return smalltalk.withContext(function($ctx1) {
  1300. self._subclassResponsibility();
  1301. return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},smalltalk.IndexableCollection)})},
  1302. args: ["anIndex", "anObject"],
  1303. source: "at: anIndex put: anObject\x0a\x09\x22Store anObject under the given index in the receiver.\x22\x0a\x0a\x09self subclassResponsibility",
  1304. messageSends: ["subclassResponsibility"],
  1305. referencedClasses: []
  1306. }),
  1307. smalltalk.IndexableCollection);
  1308. smalltalk.addMethod(
  1309. smalltalk.method({
  1310. selector: "indexOf:",
  1311. protocol: 'accessing',
  1312. fn: function (anObject){
  1313. var self=this;
  1314. return smalltalk.withContext(function($ctx1) {
  1315. var $1;
  1316. $1=self._indexOf_ifAbsent_(anObject,(function(){
  1317. return smalltalk.withContext(function($ctx2) {
  1318. return self._errorNotFound();
  1319. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1320. return $1;
  1321. }, function($ctx1) {$ctx1.fill(self,"indexOf:",{anObject:anObject},smalltalk.IndexableCollection)})},
  1322. args: ["anObject"],
  1323. 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 ]",
  1324. messageSends: ["indexOf:ifAbsent:", "errorNotFound"],
  1325. referencedClasses: []
  1326. }),
  1327. smalltalk.IndexableCollection);
  1328. smalltalk.addMethod(
  1329. smalltalk.method({
  1330. selector: "indexOf:ifAbsent:",
  1331. protocol: 'accessing',
  1332. fn: function (anObject,aBlock){
  1333. var self=this;
  1334. return smalltalk.withContext(function($ctx1) {
  1335. self._subclassResponsibility();
  1336. return self}, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},smalltalk.IndexableCollection)})},
  1337. args: ["anObject", "aBlock"],
  1338. 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",
  1339. messageSends: ["subclassResponsibility"],
  1340. referencedClasses: []
  1341. }),
  1342. smalltalk.IndexableCollection);
  1343. smalltalk.addMethod(
  1344. smalltalk.method({
  1345. selector: "with:do:",
  1346. protocol: 'enumarating',
  1347. fn: function (anotherCollection,aBlock){
  1348. var self=this;
  1349. return smalltalk.withContext(function($ctx1) {
  1350. self._withIndexDo_((function(each,index){
  1351. return smalltalk.withContext(function($ctx2) {
  1352. return _st(aBlock)._value_value_(each,_st(anotherCollection)._at_(index));
  1353. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  1354. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anotherCollection:anotherCollection,aBlock:aBlock},smalltalk.IndexableCollection)})},
  1355. args: ["anotherCollection", "aBlock"],
  1356. 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) ]",
  1357. messageSends: ["withIndexDo:", "value:value:", "at:"],
  1358. referencedClasses: []
  1359. }),
  1360. smalltalk.IndexableCollection);
  1361. smalltalk.addMethod(
  1362. smalltalk.method({
  1363. selector: "withIndexDo:",
  1364. protocol: 'enumarating',
  1365. fn: function (aBlock){
  1366. var self=this;
  1367. return smalltalk.withContext(function($ctx1) {
  1368. self._subclassResponsibility();
  1369. return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},smalltalk.IndexableCollection)})},
  1370. args: ["aBlock"],
  1371. 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",
  1372. messageSends: ["subclassResponsibility"],
  1373. referencedClasses: []
  1374. }),
  1375. smalltalk.IndexableCollection);
  1376. smalltalk.addClass('AssociativeCollection', smalltalk.IndexableCollection, [], 'Kernel-Collections');
  1377. smalltalk.AssociativeCollection.comment="I am a base class for object-indexed collections (Dictionary et.al.).";
  1378. smalltalk.addMethod(
  1379. smalltalk.method({
  1380. selector: "=",
  1381. protocol: 'comparing',
  1382. fn: function (anAssocitativeCollection){
  1383. var self=this;
  1384. return smalltalk.withContext(function($ctx1) {
  1385. var $2,$1,$4,$3,$6,$5;
  1386. $2=self._class();
  1387. $ctx1.sendIdx["class"]=1;
  1388. $1=_st($2).__eq(_st(anAssocitativeCollection)._class());
  1389. $ctx1.sendIdx["="]=1;
  1390. if(! smalltalk.assert($1)){
  1391. return false;
  1392. };
  1393. $4=self._size();
  1394. $ctx1.sendIdx["size"]=1;
  1395. $3=_st($4).__eq(_st(anAssocitativeCollection)._size());
  1396. $ctx1.sendIdx["="]=2;
  1397. if(! smalltalk.assert($3)){
  1398. return false;
  1399. };
  1400. $6=self._associations();
  1401. $ctx1.sendIdx["associations"]=1;
  1402. $5=_st($6).__eq(_st(anAssocitativeCollection)._associations());
  1403. return $5;
  1404. }, function($ctx1) {$ctx1.fill(self,"=",{anAssocitativeCollection:anAssocitativeCollection},smalltalk.AssociativeCollection)})},
  1405. args: ["anAssocitativeCollection"],
  1406. source: "= anAssocitativeCollection\x0a\x09self class = anAssocitativeCollection class ifFalse: [ ^ false ].\x0a\x09self size = anAssocitativeCollection size ifFalse: [ ^ false ].\x0a\x09^ self associations = anAssocitativeCollection associations",
  1407. messageSends: ["ifFalse:", "=", "class", "size", "associations"],
  1408. referencedClasses: []
  1409. }),
  1410. smalltalk.AssociativeCollection);
  1411. smalltalk.addMethod(
  1412. smalltalk.method({
  1413. selector: "add:",
  1414. protocol: 'adding/removing',
  1415. fn: function (anAssociation){
  1416. var self=this;
  1417. return smalltalk.withContext(function($ctx1) {
  1418. self._at_put_(_st(anAssociation)._key(),_st(anAssociation)._value());
  1419. return self}, function($ctx1) {$ctx1.fill(self,"add:",{anAssociation:anAssociation},smalltalk.AssociativeCollection)})},
  1420. args: ["anAssociation"],
  1421. source: "add: anAssociation\x0a\x09self at: anAssociation key put: anAssociation value",
  1422. messageSends: ["at:put:", "key", "value"],
  1423. referencedClasses: []
  1424. }),
  1425. smalltalk.AssociativeCollection);
  1426. smalltalk.addMethod(
  1427. smalltalk.method({
  1428. selector: "addAll:",
  1429. protocol: 'adding/removing',
  1430. fn: function (anAssociativeCollection){
  1431. var self=this;
  1432. return smalltalk.withContext(function($ctx1) {
  1433. smalltalk.AssociativeCollection.superclass.fn.prototype._addAll_.apply(_st(self), [_st(anAssociativeCollection)._associations()]);
  1434. return anAssociativeCollection;
  1435. }, function($ctx1) {$ctx1.fill(self,"addAll:",{anAssociativeCollection:anAssociativeCollection},smalltalk.AssociativeCollection)})},
  1436. args: ["anAssociativeCollection"],
  1437. source: "addAll: anAssociativeCollection\x0a\x09super addAll: anAssociativeCollection associations.\x0a\x09^ anAssociativeCollection",
  1438. messageSends: ["addAll:", "associations"],
  1439. referencedClasses: []
  1440. }),
  1441. smalltalk.AssociativeCollection);
  1442. smalltalk.addMethod(
  1443. smalltalk.method({
  1444. selector: "asDictionary",
  1445. protocol: 'converting',
  1446. fn: function (){
  1447. var self=this;
  1448. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1449. return smalltalk.withContext(function($ctx1) {
  1450. var $1;
  1451. $1=_st($Dictionary())._from_(self._associations());
  1452. return $1;
  1453. }, function($ctx1) {$ctx1.fill(self,"asDictionary",{},smalltalk.AssociativeCollection)})},
  1454. args: [],
  1455. source: "asDictionary\x0a\x09^ Dictionary from: self associations",
  1456. messageSends: ["from:", "associations"],
  1457. referencedClasses: ["Dictionary"]
  1458. }),
  1459. smalltalk.AssociativeCollection);
  1460. smalltalk.addMethod(
  1461. smalltalk.method({
  1462. selector: "asHashedCollection",
  1463. protocol: 'converting',
  1464. fn: function (){
  1465. var self=this;
  1466. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1467. return smalltalk.withContext(function($ctx1) {
  1468. var $1;
  1469. $1=_st($HashedCollection())._from_(self._associations());
  1470. return $1;
  1471. }, function($ctx1) {$ctx1.fill(self,"asHashedCollection",{},smalltalk.AssociativeCollection)})},
  1472. args: [],
  1473. source: "asHashedCollection\x0a\x09^ HashedCollection from: self associations",
  1474. messageSends: ["from:", "associations"],
  1475. referencedClasses: ["HashedCollection"]
  1476. }),
  1477. smalltalk.AssociativeCollection);
  1478. smalltalk.addMethod(
  1479. smalltalk.method({
  1480. selector: "asJSON",
  1481. protocol: 'converting',
  1482. fn: function (){
  1483. var self=this;
  1484. var hash;
  1485. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1486. return smalltalk.withContext(function($ctx1) {
  1487. var $1;
  1488. hash=_st($HashedCollection())._new();
  1489. self._keysAndValuesDo_((function(key,value){
  1490. return smalltalk.withContext(function($ctx2) {
  1491. return _st(hash)._at_put_(key,_st(value)._asJSON());
  1492. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1493. $1=hash;
  1494. return $1;
  1495. }, function($ctx1) {$ctx1.fill(self,"asJSON",{hash:hash},smalltalk.AssociativeCollection)})},
  1496. args: [],
  1497. 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",
  1498. messageSends: ["new", "keysAndValuesDo:", "at:put:", "asJSON"],
  1499. referencedClasses: ["HashedCollection"]
  1500. }),
  1501. smalltalk.AssociativeCollection);
  1502. smalltalk.addMethod(
  1503. smalltalk.method({
  1504. selector: "associations",
  1505. protocol: 'accessing',
  1506. fn: function (){
  1507. var self=this;
  1508. var associations;
  1509. return smalltalk.withContext(function($ctx1) {
  1510. var $1;
  1511. associations=[];
  1512. self._associationsDo_((function(each){
  1513. return smalltalk.withContext(function($ctx2) {
  1514. return _st(associations)._add_(each);
  1515. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1516. $1=associations;
  1517. return $1;
  1518. }, function($ctx1) {$ctx1.fill(self,"associations",{associations:associations},smalltalk.AssociativeCollection)})},
  1519. args: [],
  1520. source: "associations\x0a\x09| associations |\x0a\x09associations := #().\x0a\x09self associationsDo: [ :each | associations add: each ].\x0a\x09^ associations",
  1521. messageSends: ["associationsDo:", "add:"],
  1522. referencedClasses: []
  1523. }),
  1524. smalltalk.AssociativeCollection);
  1525. smalltalk.addMethod(
  1526. smalltalk.method({
  1527. selector: "associationsDo:",
  1528. protocol: 'enumerating',
  1529. fn: function (aBlock){
  1530. var self=this;
  1531. function $Association(){return smalltalk.Association||(typeof Association=="undefined"?nil:Association)}
  1532. return smalltalk.withContext(function($ctx1) {
  1533. self._keysAndValuesDo_((function(key,value){
  1534. return smalltalk.withContext(function($ctx2) {
  1535. return _st(aBlock)._value_(_st($Association())._key_value_(key,value));
  1536. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1537. return self}, function($ctx1) {$ctx1.fill(self,"associationsDo:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1538. args: ["aBlock"],
  1539. source: "associationsDo: aBlock\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09aBlock value: (Association key: key value: value) ]",
  1540. messageSends: ["keysAndValuesDo:", "value:", "key:value:"],
  1541. referencedClasses: ["Association"]
  1542. }),
  1543. smalltalk.AssociativeCollection);
  1544. smalltalk.addMethod(
  1545. smalltalk.method({
  1546. selector: "at:ifPresent:ifAbsent:",
  1547. protocol: 'accessing',
  1548. fn: function (aKey,aBlock,anotherBlock){
  1549. var self=this;
  1550. return smalltalk.withContext(function($ctx1) {
  1551. var $2,$1;
  1552. $2=self._includesKey_(aKey);
  1553. if(smalltalk.assert($2)){
  1554. $1=_st(aBlock)._value_(self._at_(aKey));
  1555. } else {
  1556. $1=_st(anotherBlock)._value();
  1557. };
  1558. return $1;
  1559. }, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{aKey:aKey,aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.AssociativeCollection)})},
  1560. args: ["aKey", "aBlock", "anotherBlock"],
  1561. 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 ]",
  1562. messageSends: ["ifTrue:ifFalse:", "includesKey:", "value:", "at:", "value"],
  1563. referencedClasses: []
  1564. }),
  1565. smalltalk.AssociativeCollection);
  1566. smalltalk.addMethod(
  1567. smalltalk.method({
  1568. selector: "collect:",
  1569. protocol: 'enumerating',
  1570. fn: function (aBlock){
  1571. var self=this;
  1572. var newDict;
  1573. return smalltalk.withContext(function($ctx1) {
  1574. var $1;
  1575. newDict=_st(self._class())._new();
  1576. self._keysAndValuesDo_((function(key,value){
  1577. return smalltalk.withContext(function($ctx2) {
  1578. return _st(newDict)._at_put_(key,_st(aBlock)._value_(value));
  1579. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1580. $1=newDict;
  1581. return $1;
  1582. }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,newDict:newDict},smalltalk.AssociativeCollection)})},
  1583. args: ["aBlock"],
  1584. 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",
  1585. messageSends: ["new", "class", "keysAndValuesDo:", "at:put:", "value:"],
  1586. referencedClasses: []
  1587. }),
  1588. smalltalk.AssociativeCollection);
  1589. smalltalk.addMethod(
  1590. smalltalk.method({
  1591. selector: "deepCopy",
  1592. protocol: 'copying',
  1593. fn: function (){
  1594. var self=this;
  1595. var copy;
  1596. return smalltalk.withContext(function($ctx1) {
  1597. var $1;
  1598. copy=_st(self._class())._new();
  1599. self._keysAndValuesDo_((function(key,value){
  1600. return smalltalk.withContext(function($ctx2) {
  1601. return _st(copy)._at_put_(key,_st(value)._deepCopy());
  1602. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1603. $1=copy;
  1604. return $1;
  1605. }, function($ctx1) {$ctx1.fill(self,"deepCopy",{copy:copy},smalltalk.AssociativeCollection)})},
  1606. args: [],
  1607. 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",
  1608. messageSends: ["new", "class", "keysAndValuesDo:", "at:put:", "deepCopy"],
  1609. referencedClasses: []
  1610. }),
  1611. smalltalk.AssociativeCollection);
  1612. smalltalk.addMethod(
  1613. smalltalk.method({
  1614. selector: "detect:ifNone:",
  1615. protocol: 'enumerating',
  1616. fn: function (aBlock,anotherBlock){
  1617. var self=this;
  1618. return smalltalk.withContext(function($ctx1) {
  1619. var $1;
  1620. $1=_st(self._values())._detect_ifNone_(aBlock,anotherBlock);
  1621. return $1;
  1622. }, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.AssociativeCollection)})},
  1623. args: ["aBlock", "anotherBlock"],
  1624. source: "detect: aBlock ifNone: anotherBlock\x0a\x09^ self values detect: aBlock ifNone: anotherBlock",
  1625. messageSends: ["detect:ifNone:", "values"],
  1626. referencedClasses: []
  1627. }),
  1628. smalltalk.AssociativeCollection);
  1629. smalltalk.addMethod(
  1630. smalltalk.method({
  1631. selector: "do:",
  1632. protocol: 'enumerating',
  1633. fn: function (aBlock){
  1634. var self=this;
  1635. return smalltalk.withContext(function($ctx1) {
  1636. self._valuesDo_(aBlock);
  1637. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1638. args: ["aBlock"],
  1639. source: "do: aBlock\x0a\x09self valuesDo: aBlock",
  1640. messageSends: ["valuesDo:"],
  1641. referencedClasses: []
  1642. }),
  1643. smalltalk.AssociativeCollection);
  1644. smalltalk.addMethod(
  1645. smalltalk.method({
  1646. selector: "includes:",
  1647. protocol: 'enumerating',
  1648. fn: function (anObject){
  1649. var self=this;
  1650. return smalltalk.withContext(function($ctx1) {
  1651. var $1;
  1652. $1=_st(self._values())._includes_(anObject);
  1653. return $1;
  1654. }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},smalltalk.AssociativeCollection)})},
  1655. args: ["anObject"],
  1656. source: "includes: anObject\x0a\x09^ self values includes: anObject",
  1657. messageSends: ["includes:", "values"],
  1658. referencedClasses: []
  1659. }),
  1660. smalltalk.AssociativeCollection);
  1661. smalltalk.addMethod(
  1662. smalltalk.method({
  1663. selector: "includesKey:",
  1664. protocol: 'testing',
  1665. fn: function (aKey){
  1666. var self=this;
  1667. return smalltalk.withContext(function($ctx1) {
  1668. self._subclassResponsibility();
  1669. return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},smalltalk.AssociativeCollection)})},
  1670. args: ["aKey"],
  1671. source: "includesKey: aKey\x0a\x09self subclassResponsibility",
  1672. messageSends: ["subclassResponsibility"],
  1673. referencedClasses: []
  1674. }),
  1675. smalltalk.AssociativeCollection);
  1676. smalltalk.addMethod(
  1677. smalltalk.method({
  1678. selector: "indexOf:ifAbsent:",
  1679. protocol: 'accessing',
  1680. fn: function (anObject,aBlock){
  1681. var self=this;
  1682. return smalltalk.withContext(function($ctx1) {
  1683. var $1;
  1684. $1=_st(self._keys())._detect_ifNone_((function(each){
  1685. return smalltalk.withContext(function($ctx2) {
  1686. return _st(self._at_(each)).__eq(anObject);
  1687. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),aBlock);
  1688. return $1;
  1689. }, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1690. args: ["anObject", "aBlock"],
  1691. source: "indexOf: anObject ifAbsent: aBlock\x0a\x09^ self keys \x0a\x09\x09detect: [ :each | (self at: each) = anObject ] \x0a\x09\x09ifNone: aBlock",
  1692. messageSends: ["detect:ifNone:", "keys", "=", "at:"],
  1693. referencedClasses: []
  1694. }),
  1695. smalltalk.AssociativeCollection);
  1696. smalltalk.addMethod(
  1697. smalltalk.method({
  1698. selector: "keyAtValue:",
  1699. protocol: 'accessing',
  1700. fn: function (anObject){
  1701. var self=this;
  1702. return smalltalk.withContext(function($ctx1) {
  1703. var $1;
  1704. $1=self._keyAtValue_ifAbsent_(anObject,(function(){
  1705. return smalltalk.withContext(function($ctx2) {
  1706. return self._errorNotFound();
  1707. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1708. return $1;
  1709. }, function($ctx1) {$ctx1.fill(self,"keyAtValue:",{anObject:anObject},smalltalk.AssociativeCollection)})},
  1710. args: ["anObject"],
  1711. source: "keyAtValue: anObject\x0a\x09^ self keyAtValue: anObject ifAbsent: [ self errorNotFound ]",
  1712. messageSends: ["keyAtValue:ifAbsent:", "errorNotFound"],
  1713. referencedClasses: []
  1714. }),
  1715. smalltalk.AssociativeCollection);
  1716. smalltalk.addMethod(
  1717. smalltalk.method({
  1718. selector: "keyAtValue:ifAbsent:",
  1719. protocol: 'accessing',
  1720. fn: function (anObject,aBlock){
  1721. var self=this;
  1722. return smalltalk.withContext(function($ctx1) {
  1723. var $1;
  1724. $1=self._indexOf_ifAbsent_(anObject,aBlock);
  1725. return $1;
  1726. }, function($ctx1) {$ctx1.fill(self,"keyAtValue:ifAbsent:",{anObject:anObject,aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1727. args: ["anObject", "aBlock"],
  1728. source: "keyAtValue: anObject ifAbsent: aBlock\x0a\x09^ self indexOf: anObject ifAbsent: aBlock",
  1729. messageSends: ["indexOf:ifAbsent:"],
  1730. referencedClasses: []
  1731. }),
  1732. smalltalk.AssociativeCollection);
  1733. smalltalk.addMethod(
  1734. smalltalk.method({
  1735. selector: "keys",
  1736. protocol: 'accessing',
  1737. fn: function (){
  1738. var self=this;
  1739. return smalltalk.withContext(function($ctx1) {
  1740. self._subclassResponsibility();
  1741. return self}, function($ctx1) {$ctx1.fill(self,"keys",{},smalltalk.AssociativeCollection)})},
  1742. args: [],
  1743. source: "keys\x0a\x09self subclassResponsibility",
  1744. messageSends: ["subclassResponsibility"],
  1745. referencedClasses: []
  1746. }),
  1747. smalltalk.AssociativeCollection);
  1748. smalltalk.addMethod(
  1749. smalltalk.method({
  1750. selector: "keysAndValuesDo:",
  1751. protocol: 'enumerating',
  1752. fn: function (aBlock){
  1753. var self=this;
  1754. return smalltalk.withContext(function($ctx1) {
  1755. self._keysDo_((function(each){
  1756. return smalltalk.withContext(function($ctx2) {
  1757. return _st(aBlock)._value_value_(each,self._at_(each));
  1758. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1759. return self}, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1760. args: ["aBlock"],
  1761. source: "keysAndValuesDo: aBlock\x0a\x09self keysDo: [ :each |\x0a\x09\x09aBlock value: each value: (self at: each) ]",
  1762. messageSends: ["keysDo:", "value:value:", "at:"],
  1763. referencedClasses: []
  1764. }),
  1765. smalltalk.AssociativeCollection);
  1766. smalltalk.addMethod(
  1767. smalltalk.method({
  1768. selector: "keysDo:",
  1769. protocol: 'enumerating',
  1770. fn: function (aBlock){
  1771. var self=this;
  1772. return smalltalk.withContext(function($ctx1) {
  1773. self._subclassResponsibility();
  1774. return self}, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1775. args: ["aBlock"],
  1776. source: "keysDo: aBlock\x0a\x09self subclassResponsibility",
  1777. messageSends: ["subclassResponsibility"],
  1778. referencedClasses: []
  1779. }),
  1780. smalltalk.AssociativeCollection);
  1781. smalltalk.addMethod(
  1782. smalltalk.method({
  1783. selector: "printOn:",
  1784. protocol: 'printing',
  1785. fn: function (aStream){
  1786. var self=this;
  1787. return smalltalk.withContext(function($ctx1) {
  1788. smalltalk.AssociativeCollection.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1789. $ctx1.sendIdx["printOn:"]=1;
  1790. _st(aStream)._nextPutAll_(" (");
  1791. $ctx1.sendIdx["nextPutAll:"]=1;
  1792. _st(self._associations())._do_separatedBy_((function(each){
  1793. return smalltalk.withContext(function($ctx2) {
  1794. return _st(each)._printOn_(aStream);
  1795. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  1796. return smalltalk.withContext(function($ctx2) {
  1797. return _st(aStream)._nextPutAll_(" , ");
  1798. $ctx2.sendIdx["nextPutAll:"]=2;
  1799. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1800. _st(aStream)._nextPutAll_(")");
  1801. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.AssociativeCollection)})},
  1802. args: ["aStream"],
  1803. 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: ')'",
  1804. messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:", "associations"],
  1805. referencedClasses: []
  1806. }),
  1807. smalltalk.AssociativeCollection);
  1808. smalltalk.addMethod(
  1809. smalltalk.method({
  1810. selector: "remove:ifAbsent:",
  1811. protocol: 'adding/removing',
  1812. fn: function (aKey,aBlock){
  1813. var self=this;
  1814. return smalltalk.withContext(function($ctx1) {
  1815. var $1;
  1816. $1=self._removeKey_ifAbsent_(aKey,aBlock);
  1817. return $1;
  1818. }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1819. args: ["aKey", "aBlock"],
  1820. source: "remove: aKey ifAbsent: aBlock\x0a\x09^ self removeKey: aKey ifAbsent: aBlock",
  1821. messageSends: ["removeKey:ifAbsent:"],
  1822. referencedClasses: []
  1823. }),
  1824. smalltalk.AssociativeCollection);
  1825. smalltalk.addMethod(
  1826. smalltalk.method({
  1827. selector: "removeAll",
  1828. protocol: 'adding/removing',
  1829. fn: function (){
  1830. var self=this;
  1831. return smalltalk.withContext(function($ctx1) {
  1832. var $1;
  1833. $1=_st(self._keys())._do_((function(each){
  1834. return smalltalk.withContext(function($ctx2) {
  1835. return self._removeKey_(each);
  1836. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1837. return $1;
  1838. }, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.AssociativeCollection)})},
  1839. args: [],
  1840. source: "removeAll\x0a\x09^ self keys do: [ :each | self removeKey: each ]",
  1841. messageSends: ["do:", "keys", "removeKey:"],
  1842. referencedClasses: []
  1843. }),
  1844. smalltalk.AssociativeCollection);
  1845. smalltalk.addMethod(
  1846. smalltalk.method({
  1847. selector: "removeKey:",
  1848. protocol: 'adding/removing',
  1849. fn: function (aKey){
  1850. var self=this;
  1851. return smalltalk.withContext(function($ctx1) {
  1852. var $1;
  1853. $1=self._remove_(aKey);
  1854. return $1;
  1855. }, function($ctx1) {$ctx1.fill(self,"removeKey:",{aKey:aKey},smalltalk.AssociativeCollection)})},
  1856. args: ["aKey"],
  1857. source: "removeKey: aKey\x0a\x09^ self remove: aKey",
  1858. messageSends: ["remove:"],
  1859. referencedClasses: []
  1860. }),
  1861. smalltalk.AssociativeCollection);
  1862. smalltalk.addMethod(
  1863. smalltalk.method({
  1864. selector: "removeKey:ifAbsent:",
  1865. protocol: 'adding/removing',
  1866. fn: function (aKey,aBlock){
  1867. var self=this;
  1868. return smalltalk.withContext(function($ctx1) {
  1869. self._subclassResponsibility();
  1870. return self}, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1871. args: ["aKey", "aBlock"],
  1872. source: "removeKey: aKey ifAbsent: aBlock\x0a\x09self subclassResponsibility",
  1873. messageSends: ["subclassResponsibility"],
  1874. referencedClasses: []
  1875. }),
  1876. smalltalk.AssociativeCollection);
  1877. smalltalk.addMethod(
  1878. smalltalk.method({
  1879. selector: "select:",
  1880. protocol: 'enumerating',
  1881. fn: function (aBlock){
  1882. var self=this;
  1883. var newDict;
  1884. return smalltalk.withContext(function($ctx1) {
  1885. var $1,$2;
  1886. newDict=_st(self._class())._new();
  1887. self._keysAndValuesDo_((function(key,value){
  1888. return smalltalk.withContext(function($ctx2) {
  1889. $1=_st(aBlock)._value_(value);
  1890. if(smalltalk.assert($1)){
  1891. return _st(newDict)._at_put_(key,value);
  1892. };
  1893. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1894. $2=newDict;
  1895. return $2;
  1896. }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,newDict:newDict},smalltalk.AssociativeCollection)})},
  1897. args: ["aBlock"],
  1898. 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",
  1899. messageSends: ["new", "class", "keysAndValuesDo:", "ifTrue:", "value:", "at:put:"],
  1900. referencedClasses: []
  1901. }),
  1902. smalltalk.AssociativeCollection);
  1903. smalltalk.addMethod(
  1904. smalltalk.method({
  1905. selector: "shallowCopy",
  1906. protocol: 'copying',
  1907. fn: function (){
  1908. var self=this;
  1909. var copy;
  1910. return smalltalk.withContext(function($ctx1) {
  1911. var $1;
  1912. copy=_st(self._class())._new();
  1913. self._keysAndValuesDo_((function(key,value){
  1914. return smalltalk.withContext(function($ctx2) {
  1915. return _st(copy)._at_put_(key,value);
  1916. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1917. $1=copy;
  1918. return $1;
  1919. }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{copy:copy},smalltalk.AssociativeCollection)})},
  1920. args: [],
  1921. 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",
  1922. messageSends: ["new", "class", "keysAndValuesDo:", "at:put:"],
  1923. referencedClasses: []
  1924. }),
  1925. smalltalk.AssociativeCollection);
  1926. smalltalk.addMethod(
  1927. smalltalk.method({
  1928. selector: "size",
  1929. protocol: 'accessing',
  1930. fn: function (){
  1931. var self=this;
  1932. return smalltalk.withContext(function($ctx1) {
  1933. var $1;
  1934. $1=_st(self._keys())._size();
  1935. return $1;
  1936. }, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.AssociativeCollection)})},
  1937. args: [],
  1938. source: "size\x0a\x09^ self keys size",
  1939. messageSends: ["size", "keys"],
  1940. referencedClasses: []
  1941. }),
  1942. smalltalk.AssociativeCollection);
  1943. smalltalk.addMethod(
  1944. smalltalk.method({
  1945. selector: "values",
  1946. protocol: 'accessing',
  1947. fn: function (){
  1948. var self=this;
  1949. return smalltalk.withContext(function($ctx1) {
  1950. self._subclassResponsibility();
  1951. return self}, function($ctx1) {$ctx1.fill(self,"values",{},smalltalk.AssociativeCollection)})},
  1952. args: [],
  1953. source: "values\x0a\x09self subclassResponsibility",
  1954. messageSends: ["subclassResponsibility"],
  1955. referencedClasses: []
  1956. }),
  1957. smalltalk.AssociativeCollection);
  1958. smalltalk.addMethod(
  1959. smalltalk.method({
  1960. selector: "valuesDo:",
  1961. protocol: 'enumerating',
  1962. fn: function (aBlock){
  1963. var self=this;
  1964. return smalltalk.withContext(function($ctx1) {
  1965. self._subclassResponsibility();
  1966. return self}, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1967. args: ["aBlock"],
  1968. source: "valuesDo: aBlock\x0a\x09self subclassResponsibility",
  1969. messageSends: ["subclassResponsibility"],
  1970. referencedClasses: []
  1971. }),
  1972. smalltalk.AssociativeCollection);
  1973. smalltalk.addMethod(
  1974. smalltalk.method({
  1975. selector: "withIndexDo:",
  1976. protocol: 'enumerating',
  1977. fn: function (aBlock){
  1978. var self=this;
  1979. return smalltalk.withContext(function($ctx1) {
  1980. self._keysAndValuesDo_((function(key,value){
  1981. return smalltalk.withContext(function($ctx2) {
  1982. return _st(aBlock)._value_value_(value,key);
  1983. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  1984. return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},smalltalk.AssociativeCollection)})},
  1985. args: ["aBlock"],
  1986. source: "withIndexDo: aBlock\x0a\x09self keysAndValuesDo: [ :key :value | aBlock value: value value: key ]",
  1987. messageSends: ["keysAndValuesDo:", "value:value:"],
  1988. referencedClasses: []
  1989. }),
  1990. smalltalk.AssociativeCollection);
  1991. smalltalk.addMethod(
  1992. smalltalk.method({
  1993. selector: "from:",
  1994. protocol: 'instance creation',
  1995. fn: function (aCollection){
  1996. var self=this;
  1997. var newCollection;
  1998. return smalltalk.withContext(function($ctx1) {
  1999. var $1;
  2000. newCollection=self._new();
  2001. _st(aCollection)._do_((function(each){
  2002. return smalltalk.withContext(function($ctx2) {
  2003. return _st(newCollection)._add_(each);
  2004. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  2005. $1=newCollection;
  2006. return $1;
  2007. }, function($ctx1) {$ctx1.fill(self,"from:",{aCollection:aCollection,newCollection:newCollection},smalltalk.AssociativeCollection.klass)})},
  2008. args: ["aCollection"],
  2009. source: "from: aCollection\x0a\x09| newCollection |\x0a\x09newCollection := self new.\x0a\x09aCollection do: [ :each | newCollection add: each ].\x0a\x09^ newCollection",
  2010. messageSends: ["new", "do:", "add:"],
  2011. referencedClasses: []
  2012. }),
  2013. smalltalk.AssociativeCollection.klass);
  2014. smalltalk.addMethod(
  2015. smalltalk.method({
  2016. selector: "fromPairs:",
  2017. protocol: 'instance creation',
  2018. fn: function (aCollection){
  2019. var self=this;
  2020. return smalltalk.withContext(function($ctx1) {
  2021. var $1;
  2022. $1=self._from_(aCollection);
  2023. return $1;
  2024. }, function($ctx1) {$ctx1.fill(self,"fromPairs:",{aCollection:aCollection},smalltalk.AssociativeCollection.klass)})},
  2025. args: ["aCollection"],
  2026. source: "fromPairs: aCollection\x0a\x09\x22This message is poorly named and has been replaced by #from:\x22\x0a\x09^ self from: aCollection",
  2027. messageSends: ["from:"],
  2028. referencedClasses: []
  2029. }),
  2030. smalltalk.AssociativeCollection.klass);
  2031. smalltalk.addMethod(
  2032. smalltalk.method({
  2033. selector: "newFromPairs:",
  2034. protocol: 'instance creation',
  2035. fn: function (aCollection){
  2036. var self=this;
  2037. var newCollection;
  2038. return smalltalk.withContext(function($ctx1) {
  2039. var $2,$1,$3,$4,$5;
  2040. $2=_st(aCollection)._size();
  2041. $ctx1.sendIdx["size"]=1;
  2042. $1=_st($2)._even();
  2043. if(! smalltalk.assert($1)){
  2044. self._error_("#newFromPairs only accepts arrays of an even length");
  2045. };
  2046. newCollection=self._new();
  2047. _st((1)._to_by_(_st(aCollection)._size(),(2)))._do_((function(each){
  2048. return smalltalk.withContext(function($ctx2) {
  2049. $3=newCollection;
  2050. $4=_st(aCollection)._at_(each);
  2051. $ctx2.sendIdx["at:"]=1;
  2052. return _st($3)._at_put_($4,_st(aCollection)._at_(_st(each).__plus((1))));
  2053. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  2054. $5=newCollection;
  2055. return $5;
  2056. }, function($ctx1) {$ctx1.fill(self,"newFromPairs:",{aCollection:aCollection,newCollection:newCollection},smalltalk.AssociativeCollection.klass)})},
  2057. args: ["aCollection"],
  2058. 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",
  2059. messageSends: ["ifFalse:", "even", "size", "error:", "new", "do:", "to:by:", "at:put:", "at:", "+"],
  2060. referencedClasses: []
  2061. }),
  2062. smalltalk.AssociativeCollection.klass);
  2063. smalltalk.addClass('Dictionary', smalltalk.AssociativeCollection, ['keys', 'values'], 'Kernel-Collections');
  2064. smalltalk.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.";
  2065. smalltalk.addMethod(
  2066. smalltalk.method({
  2067. selector: "at:ifAbsent:",
  2068. protocol: 'accessing',
  2069. fn: function (aKey,aBlock){
  2070. var self=this;
  2071. return smalltalk.withContext(function($ctx1) {
  2072. var index = self._positionOfKey_(aKey);
  2073. return index >=0 ? self['@values'][index] : aBlock._value();
  2074. ;
  2075. return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.Dictionary)})},
  2076. args: ["aKey", "aBlock"],
  2077. 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>",
  2078. messageSends: [],
  2079. referencedClasses: []
  2080. }),
  2081. smalltalk.Dictionary);
  2082. smalltalk.addMethod(
  2083. smalltalk.method({
  2084. selector: "at:put:",
  2085. protocol: 'accessing',
  2086. fn: function (aKey,aValue){
  2087. var self=this;
  2088. return smalltalk.withContext(function($ctx1) {
  2089. var index = self._positionOfKey_(aKey);
  2090. if(index === -1) {
  2091. var keys = self['@keys'];
  2092. index = keys.length;
  2093. keys.push(aKey);
  2094. }
  2095. return self['@values'][index] = aValue;
  2096. ;
  2097. return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aKey:aKey,aValue:aValue},smalltalk.Dictionary)})},
  2098. args: ["aKey", "aValue"],
  2099. 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>",
  2100. messageSends: [],
  2101. referencedClasses: []
  2102. }),
  2103. smalltalk.Dictionary);
  2104. smalltalk.addMethod(
  2105. smalltalk.method({
  2106. selector: "includesKey:",
  2107. protocol: 'testing',
  2108. fn: function (aKey){
  2109. var self=this;
  2110. return smalltalk.withContext(function($ctx1) {
  2111. return self._positionOfKey_(aKey) >= 0; ;
  2112. return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},smalltalk.Dictionary)})},
  2113. args: ["aKey"],
  2114. source: "includesKey: aKey\x0a\x09< return self._positionOfKey_(aKey) >>= 0; >",
  2115. messageSends: [],
  2116. referencedClasses: []
  2117. }),
  2118. smalltalk.Dictionary);
  2119. smalltalk.addMethod(
  2120. smalltalk.method({
  2121. selector: "indexOf:ifAbsent:",
  2122. protocol: 'accessing',
  2123. fn: function (anObject,aBlock){
  2124. var self=this;
  2125. var index;
  2126. return smalltalk.withContext(function($ctx1) {
  2127. var $2,$1;
  2128. index=_st(self["@values"])._indexOf_ifAbsent_(anObject,(function(){
  2129. return smalltalk.withContext(function($ctx2) {
  2130. return (0);
  2131. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2132. $2=_st(index).__eq((0));
  2133. if(smalltalk.assert($2)){
  2134. $1=_st(aBlock)._value();
  2135. } else {
  2136. $1=_st(self["@keys"])._at_(index);
  2137. };
  2138. return $1;
  2139. }, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock,index:index},smalltalk.Dictionary)})},
  2140. args: ["anObject", "aBlock"],
  2141. 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 ]",
  2142. messageSends: ["indexOf:ifAbsent:", "ifTrue:ifFalse:", "=", "value", "at:"],
  2143. referencedClasses: []
  2144. }),
  2145. smalltalk.Dictionary);
  2146. smalltalk.addMethod(
  2147. smalltalk.method({
  2148. selector: "initialize",
  2149. protocol: 'initialization',
  2150. fn: function (){
  2151. var self=this;
  2152. return smalltalk.withContext(function($ctx1) {
  2153. smalltalk.Dictionary.superclass.fn.prototype._initialize.apply(_st(self), []);
  2154. self["@keys"]=[];
  2155. self["@values"]=[];
  2156. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Dictionary)})},
  2157. args: [],
  2158. source: "initialize\x0a\x09super initialize.\x0a\x09keys := #().\x0a\x09values := #()",
  2159. messageSends: ["initialize"],
  2160. referencedClasses: []
  2161. }),
  2162. smalltalk.Dictionary);
  2163. smalltalk.addMethod(
  2164. smalltalk.method({
  2165. selector: "keys",
  2166. protocol: 'accessing',
  2167. fn: function (){
  2168. var self=this;
  2169. return smalltalk.withContext(function($ctx1) {
  2170. var $1;
  2171. $1=_st(self["@keys"])._copy();
  2172. return $1;
  2173. }, function($ctx1) {$ctx1.fill(self,"keys",{},smalltalk.Dictionary)})},
  2174. args: [],
  2175. source: "keys\x0a\x09^ keys copy",
  2176. messageSends: ["copy"],
  2177. referencedClasses: []
  2178. }),
  2179. smalltalk.Dictionary);
  2180. smalltalk.addMethod(
  2181. smalltalk.method({
  2182. selector: "keysAndValuesDo:",
  2183. protocol: 'enumerating',
  2184. fn: function (aBlock){
  2185. var self=this;
  2186. return smalltalk.withContext(function($ctx1) {
  2187. var $1;
  2188. $1=_st(self["@keys"])._with_do_(self["@values"],aBlock);
  2189. return $1;
  2190. }, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},smalltalk.Dictionary)})},
  2191. args: ["aBlock"],
  2192. source: "keysAndValuesDo: aBlock\x0a\x09^ keys with: values do: aBlock",
  2193. messageSends: ["with:do:"],
  2194. referencedClasses: []
  2195. }),
  2196. smalltalk.Dictionary);
  2197. smalltalk.addMethod(
  2198. smalltalk.method({
  2199. selector: "keysDo:",
  2200. protocol: 'enumerating',
  2201. fn: function (aBlock){
  2202. var self=this;
  2203. return smalltalk.withContext(function($ctx1) {
  2204. var $1;
  2205. $1=_st(self["@keys"])._do_(aBlock);
  2206. return $1;
  2207. }, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},smalltalk.Dictionary)})},
  2208. args: ["aBlock"],
  2209. source: "keysDo: aBlock\x0a\x09^ keys do: aBlock",
  2210. messageSends: ["do:"],
  2211. referencedClasses: []
  2212. }),
  2213. smalltalk.Dictionary);
  2214. smalltalk.addMethod(
  2215. smalltalk.method({
  2216. selector: "positionOfKey:",
  2217. protocol: 'private',
  2218. fn: function (anObject){
  2219. var self=this;
  2220. return smalltalk.withContext(function($ctx1) {
  2221. var keys = self['@keys'];
  2222. for(var i=0;i<keys.length;i++){
  2223. if(keys[i].__eq(anObject)) { return i;}
  2224. }
  2225. return -1;
  2226. ;
  2227. return self}, function($ctx1) {$ctx1.fill(self,"positionOfKey:",{anObject:anObject},smalltalk.Dictionary)})},
  2228. args: ["anObject"],
  2229. 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>",
  2230. messageSends: [],
  2231. referencedClasses: []
  2232. }),
  2233. smalltalk.Dictionary);
  2234. smalltalk.addMethod(
  2235. smalltalk.method({
  2236. selector: "removeAll",
  2237. protocol: 'adding/removing',
  2238. fn: function (){
  2239. var self=this;
  2240. return smalltalk.withContext(function($ctx1) {
  2241. _st(self["@keys"])._removeAll();
  2242. $ctx1.sendIdx["removeAll"]=1;
  2243. _st(self["@values"])._removeAll();
  2244. return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.Dictionary)})},
  2245. args: [],
  2246. source: "removeAll\x0a\x09keys removeAll.\x0a\x09values removeAll",
  2247. messageSends: ["removeAll"],
  2248. referencedClasses: []
  2249. }),
  2250. smalltalk.Dictionary);
  2251. smalltalk.addMethod(
  2252. smalltalk.method({
  2253. selector: "removeKey:ifAbsent:",
  2254. protocol: 'adding/removing',
  2255. fn: function (aKey,aBlock){
  2256. var self=this;
  2257. return smalltalk.withContext(function($ctx1) {
  2258. var index = self._positionOfKey_(aKey);
  2259. if(index === -1) {
  2260. return aBlock._value()
  2261. } else {
  2262. var keys = self['@keys'], values = self['@values'];
  2263. var value = values[index], l = keys.length;
  2264. keys[index] = keys[l-1];
  2265. keys.pop();
  2266. values[index] = values[l-1];
  2267. values.pop();
  2268. return value;
  2269. }
  2270. ;
  2271. return self}, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.Dictionary)})},
  2272. args: ["aKey", "aBlock"],
  2273. 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>",
  2274. messageSends: [],
  2275. referencedClasses: []
  2276. }),
  2277. smalltalk.Dictionary);
  2278. smalltalk.addMethod(
  2279. smalltalk.method({
  2280. selector: "values",
  2281. protocol: 'accessing',
  2282. fn: function (){
  2283. var self=this;
  2284. return smalltalk.withContext(function($ctx1) {
  2285. var $1;
  2286. $1=self["@values"];
  2287. return $1;
  2288. }, function($ctx1) {$ctx1.fill(self,"values",{},smalltalk.Dictionary)})},
  2289. args: [],
  2290. source: "values\x0a\x09^ values",
  2291. messageSends: [],
  2292. referencedClasses: []
  2293. }),
  2294. smalltalk.Dictionary);
  2295. smalltalk.addMethod(
  2296. smalltalk.method({
  2297. selector: "valuesDo:",
  2298. protocol: 'enumerating',
  2299. fn: function (aBlock){
  2300. var self=this;
  2301. return smalltalk.withContext(function($ctx1) {
  2302. var $1;
  2303. $1=_st(self["@values"])._do_(aBlock);
  2304. return $1;
  2305. }, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},smalltalk.Dictionary)})},
  2306. args: ["aBlock"],
  2307. source: "valuesDo: aBlock\x0a\x09^ values do: aBlock",
  2308. messageSends: ["do:"],
  2309. referencedClasses: []
  2310. }),
  2311. smalltalk.Dictionary);
  2312. smalltalk.addClass('HashedCollection', smalltalk.AssociativeCollection, [], 'Kernel-Collections');
  2313. smalltalk.HashedCollection.comment="I am a traditional JavaScript object, or a Smalltalk `Dictionary`.\x0a\x0aUnlike a `Dictionary`, I can only have strings as keys.";
  2314. smalltalk.addMethod(
  2315. smalltalk.method({
  2316. selector: "at:ifAbsent:",
  2317. protocol: 'accessing',
  2318. fn: function (aKey,aBlock){
  2319. var self=this;
  2320. return smalltalk.withContext(function($ctx1) {
  2321. var $2,$1;
  2322. $2=self._includesKey_(aKey);
  2323. if(smalltalk.assert($2)){
  2324. $1=self._basicAt_(aKey);
  2325. } else {
  2326. $1=_st(aBlock)._value();
  2327. };
  2328. return $1;
  2329. }, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.HashedCollection)})},
  2330. args: ["aKey", "aBlock"],
  2331. source: "at: aKey ifAbsent: aBlock\x0a\x09^ (self includesKey: aKey)\x0a\x09\x09ifTrue: [ self basicAt: aKey ]\x0a\x09\x09ifFalse: [ aBlock value ]",
  2332. messageSends: ["ifTrue:ifFalse:", "includesKey:", "basicAt:", "value"],
  2333. referencedClasses: []
  2334. }),
  2335. smalltalk.HashedCollection);
  2336. smalltalk.addMethod(
  2337. smalltalk.method({
  2338. selector: "at:put:",
  2339. protocol: 'accessing',
  2340. fn: function (aKey,aValue){
  2341. var self=this;
  2342. return smalltalk.withContext(function($ctx1) {
  2343. var $1;
  2344. $1=self._basicAt_put_(aKey,aValue);
  2345. return $1;
  2346. }, function($ctx1) {$ctx1.fill(self,"at:put:",{aKey:aKey,aValue:aValue},smalltalk.HashedCollection)})},
  2347. args: ["aKey", "aValue"],
  2348. source: "at: aKey put: aValue\x0a\x09^ self basicAt: aKey put: aValue",
  2349. messageSends: ["basicAt:put:"],
  2350. referencedClasses: []
  2351. }),
  2352. smalltalk.HashedCollection);
  2353. smalltalk.addMethod(
  2354. smalltalk.method({
  2355. selector: "includesKey:",
  2356. protocol: 'testing',
  2357. fn: function (aKey){
  2358. var self=this;
  2359. return smalltalk.withContext(function($ctx1) {
  2360. return self.hasOwnProperty(aKey);
  2361. return self}, function($ctx1) {$ctx1.fill(self,"includesKey:",{aKey:aKey},smalltalk.HashedCollection)})},
  2362. args: ["aKey"],
  2363. source: "includesKey: aKey\x0a\x09<return self.hasOwnProperty(aKey)>",
  2364. messageSends: [],
  2365. referencedClasses: []
  2366. }),
  2367. smalltalk.HashedCollection);
  2368. smalltalk.addMethod(
  2369. smalltalk.method({
  2370. selector: "keys",
  2371. protocol: 'accessing',
  2372. fn: function (){
  2373. var self=this;
  2374. return smalltalk.withContext(function($ctx1) {
  2375. return Object.keys(self);
  2376. return self}, function($ctx1) {$ctx1.fill(self,"keys",{},smalltalk.HashedCollection)})},
  2377. args: [],
  2378. source: "keys\x0a\x09<return Object.keys(self)>",
  2379. messageSends: [],
  2380. referencedClasses: []
  2381. }),
  2382. smalltalk.HashedCollection);
  2383. smalltalk.addMethod(
  2384. smalltalk.method({
  2385. selector: "keysDo:",
  2386. protocol: 'enumerating',
  2387. fn: function (aBlock){
  2388. var self=this;
  2389. return smalltalk.withContext(function($ctx1) {
  2390. _st(self._keys())._do_(aBlock);
  2391. return self}, function($ctx1) {$ctx1.fill(self,"keysDo:",{aBlock:aBlock},smalltalk.HashedCollection)})},
  2392. args: ["aBlock"],
  2393. source: "keysDo: aBlock\x0a\x09self keys do: aBlock",
  2394. messageSends: ["do:", "keys"],
  2395. referencedClasses: []
  2396. }),
  2397. smalltalk.HashedCollection);
  2398. smalltalk.addMethod(
  2399. smalltalk.method({
  2400. selector: "removeKey:ifAbsent:",
  2401. protocol: 'adding/removing',
  2402. fn: function (aKey,aBlock){
  2403. var self=this;
  2404. return smalltalk.withContext(function($ctx1) {
  2405. var $1;
  2406. $1=self._at_ifPresent_ifAbsent_(aKey,(function(removed){
  2407. return smalltalk.withContext(function($ctx2) {
  2408. self._basicDelete_(aKey);
  2409. return removed;
  2410. }, function($ctx2) {$ctx2.fillBlock({removed:removed},$ctx1,1)})}),(function(){
  2411. return smalltalk.withContext(function($ctx2) {
  2412. return _st(aBlock)._value();
  2413. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  2414. return $1;
  2415. }, function($ctx1) {$ctx1.fill(self,"removeKey:ifAbsent:",{aKey:aKey,aBlock:aBlock},smalltalk.HashedCollection)})},
  2416. args: ["aKey", "aBlock"],
  2417. 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 ]",
  2418. messageSends: ["at:ifPresent:ifAbsent:", "basicDelete:", "value"],
  2419. referencedClasses: []
  2420. }),
  2421. smalltalk.HashedCollection);
  2422. smalltalk.addMethod(
  2423. smalltalk.method({
  2424. selector: "values",
  2425. protocol: 'accessing',
  2426. fn: function (){
  2427. var self=this;
  2428. return smalltalk.withContext(function($ctx1) {
  2429. return self._keys().map(function(key){
  2430. return self._at_(key);
  2431. });
  2432. ;
  2433. return self}, function($ctx1) {$ctx1.fill(self,"values",{},smalltalk.HashedCollection)})},
  2434. args: [],
  2435. source: "values\x0a\x09<\x0a\x09\x09return self._keys().map(function(key){\x0a\x09\x09\x09return self._at_(key);\x0a\x09\x09});\x0a\x09>",
  2436. messageSends: [],
  2437. referencedClasses: []
  2438. }),
  2439. smalltalk.HashedCollection);
  2440. smalltalk.addMethod(
  2441. smalltalk.method({
  2442. selector: "valuesDo:",
  2443. protocol: 'enumerating',
  2444. fn: function (aBlock){
  2445. var self=this;
  2446. return smalltalk.withContext(function($ctx1) {
  2447. _st(self._values())._do_(aBlock);
  2448. return self}, function($ctx1) {$ctx1.fill(self,"valuesDo:",{aBlock:aBlock},smalltalk.HashedCollection)})},
  2449. args: ["aBlock"],
  2450. source: "valuesDo: aBlock\x0a\x09self values do: aBlock",
  2451. messageSends: ["do:", "values"],
  2452. referencedClasses: []
  2453. }),
  2454. smalltalk.HashedCollection);
  2455. smalltalk.addClass('SequenceableCollection', smalltalk.IndexableCollection, [], 'Kernel-Collections');
  2456. smalltalk.SequenceableCollection.comment="I am an IndexableCollection\x0awith numeric indexes starting with 1.";
  2457. smalltalk.addMethod(
  2458. smalltalk.method({
  2459. selector: "=",
  2460. protocol: 'comparing',
  2461. fn: function (aCollection){
  2462. var self=this;
  2463. return smalltalk.withContext(function($ctx1) {
  2464. var $3,$2,$4,$1,$5;
  2465. var $early={};
  2466. try {
  2467. $3=self._class();
  2468. $ctx1.sendIdx["class"]=1;
  2469. $2=_st($3).__eq(_st(aCollection)._class());
  2470. $ctx1.sendIdx["="]=1;
  2471. $1=_st($2)._and_((function(){
  2472. return smalltalk.withContext(function($ctx2) {
  2473. $4=self._size();
  2474. $ctx2.sendIdx["size"]=1;
  2475. return _st($4).__eq(_st(aCollection)._size());
  2476. $ctx2.sendIdx["="]=2;
  2477. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2478. if(! smalltalk.assert($1)){
  2479. return false;
  2480. };
  2481. self._withIndexDo_((function(each,i){
  2482. return smalltalk.withContext(function($ctx2) {
  2483. $5=_st(_st(aCollection)._at_(i)).__eq(each);
  2484. if(! smalltalk.assert($5)){
  2485. throw $early=[false];
  2486. };
  2487. }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,3)})}));
  2488. return true;
  2489. }
  2490. catch(e) {if(e===$early)return e[0]; throw e}
  2491. }, function($ctx1) {$ctx1.fill(self,"=",{aCollection:aCollection},smalltalk.SequenceableCollection)})},
  2492. args: ["aCollection"],
  2493. 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",
  2494. messageSends: ["ifFalse:", "and:", "=", "class", "size", "withIndexDo:", "at:"],
  2495. referencedClasses: []
  2496. }),
  2497. smalltalk.SequenceableCollection);
  2498. smalltalk.addMethod(
  2499. smalltalk.method({
  2500. selector: "addLast:",
  2501. protocol: 'adding/removing',
  2502. fn: function (anObject){
  2503. var self=this;
  2504. return smalltalk.withContext(function($ctx1) {
  2505. self._add_(anObject);
  2506. return self}, function($ctx1) {$ctx1.fill(self,"addLast:",{anObject:anObject},smalltalk.SequenceableCollection)})},
  2507. args: ["anObject"],
  2508. source: "addLast: anObject\x0a\x09self add: anObject",
  2509. messageSends: ["add:"],
  2510. referencedClasses: []
  2511. }),
  2512. smalltalk.SequenceableCollection);
  2513. smalltalk.addMethod(
  2514. smalltalk.method({
  2515. selector: "allButFirst",
  2516. protocol: 'accessing',
  2517. fn: function (){
  2518. var self=this;
  2519. return smalltalk.withContext(function($ctx1) {
  2520. var $1;
  2521. $1=self._copyFrom_to_((2),self._size());
  2522. return $1;
  2523. }, function($ctx1) {$ctx1.fill(self,"allButFirst",{},smalltalk.SequenceableCollection)})},
  2524. args: [],
  2525. source: "allButFirst\x0a\x09^ self copyFrom: 2 to: self size",
  2526. messageSends: ["copyFrom:to:", "size"],
  2527. referencedClasses: []
  2528. }),
  2529. smalltalk.SequenceableCollection);
  2530. smalltalk.addMethod(
  2531. smalltalk.method({
  2532. selector: "allButLast",
  2533. protocol: 'accessing',
  2534. fn: function (){
  2535. var self=this;
  2536. return smalltalk.withContext(function($ctx1) {
  2537. var $1;
  2538. $1=self._copyFrom_to_((1),_st(self._size()).__minus((1)));
  2539. return $1;
  2540. }, function($ctx1) {$ctx1.fill(self,"allButLast",{},smalltalk.SequenceableCollection)})},
  2541. args: [],
  2542. source: "allButLast\x0a\x09^ self copyFrom: 1 to: self size - 1",
  2543. messageSends: ["copyFrom:to:", "-", "size"],
  2544. referencedClasses: []
  2545. }),
  2546. smalltalk.SequenceableCollection);
  2547. smalltalk.addMethod(
  2548. smalltalk.method({
  2549. selector: "atRandom",
  2550. protocol: 'accessing',
  2551. fn: function (){
  2552. var self=this;
  2553. return smalltalk.withContext(function($ctx1) {
  2554. var $1;
  2555. $1=self._at_(_st(self._size())._atRandom());
  2556. return $1;
  2557. }, function($ctx1) {$ctx1.fill(self,"atRandom",{},smalltalk.SequenceableCollection)})},
  2558. args: [],
  2559. source: "atRandom\x0a\x09^ self at: self size atRandom",
  2560. messageSends: ["at:", "atRandom", "size"],
  2561. referencedClasses: []
  2562. }),
  2563. smalltalk.SequenceableCollection);
  2564. smalltalk.addMethod(
  2565. smalltalk.method({
  2566. selector: "beginsWith:",
  2567. protocol: 'testing',
  2568. fn: function (prefix){
  2569. var self=this;
  2570. return smalltalk.withContext(function($ctx1) {
  2571. var $2,$3,$1,$4;
  2572. $2=self._size();
  2573. $ctx1.sendIdx["size"]=1;
  2574. $3=_st(prefix)._size();
  2575. $ctx1.sendIdx["size"]=2;
  2576. $1=_st($2).__lt($3);
  2577. if(smalltalk.assert($1)){
  2578. return false;
  2579. };
  2580. $4=_st(self._first_(_st(prefix)._size())).__eq(prefix);
  2581. return $4;
  2582. }, function($ctx1) {$ctx1.fill(self,"beginsWith:",{prefix:prefix},smalltalk.SequenceableCollection)})},
  2583. args: ["prefix"],
  2584. source: "beginsWith: prefix\x0a\x09self size < prefix size ifTrue: [ ^ false ].\x0a\x09^ (self first: prefix size) = prefix",
  2585. messageSends: ["ifTrue:", "<", "size", "=", "first:"],
  2586. referencedClasses: []
  2587. }),
  2588. smalltalk.SequenceableCollection);
  2589. smalltalk.addMethod(
  2590. smalltalk.method({
  2591. selector: "copyFrom:to:",
  2592. protocol: 'copying',
  2593. fn: function (anIndex,anotherIndex){
  2594. var self=this;
  2595. var range,newCollection;
  2596. return smalltalk.withContext(function($ctx1) {
  2597. var $1;
  2598. range=_st(anIndex)._to_(anotherIndex);
  2599. newCollection=_st(self._class())._new_(_st(range)._size());
  2600. _st(range)._withIndexDo_((function(each,i){
  2601. return smalltalk.withContext(function($ctx2) {
  2602. return _st(newCollection)._at_put_(i,self._at_(each));
  2603. }, function($ctx2) {$ctx2.fillBlock({each:each,i:i},$ctx1,1)})}));
  2604. $1=newCollection;
  2605. return $1;
  2606. }, function($ctx1) {$ctx1.fill(self,"copyFrom:to:",{anIndex:anIndex,anotherIndex:anotherIndex,range:range,newCollection:newCollection},smalltalk.SequenceableCollection)})},
  2607. args: ["anIndex", "anotherIndex"],
  2608. 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",
  2609. messageSends: ["to:", "new:", "class", "size", "withIndexDo:", "at:put:", "at:"],
  2610. referencedClasses: []
  2611. }),
  2612. smalltalk.SequenceableCollection);
  2613. smalltalk.addMethod(
  2614. smalltalk.method({
  2615. selector: "deepCopy",
  2616. protocol: 'copying',
  2617. fn: function (){
  2618. var self=this;
  2619. var newCollection;
  2620. return smalltalk.withContext(function($ctx1) {
  2621. var $1;
  2622. newCollection=_st(self._class())._new_(self._size());
  2623. self._withIndexDo_((function(each,index){
  2624. return smalltalk.withContext(function($ctx2) {
  2625. return _st(newCollection)._at_put_(index,_st(each)._deepCopy());
  2626. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  2627. $1=newCollection;
  2628. return $1;
  2629. }, function($ctx1) {$ctx1.fill(self,"deepCopy",{newCollection:newCollection},smalltalk.SequenceableCollection)})},
  2630. args: [],
  2631. 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",
  2632. messageSends: ["new:", "class", "size", "withIndexDo:", "at:put:", "deepCopy"],
  2633. referencedClasses: []
  2634. }),
  2635. smalltalk.SequenceableCollection);
  2636. smalltalk.addMethod(
  2637. smalltalk.method({
  2638. selector: "detect:ifNone:",
  2639. protocol: 'enumerating',
  2640. fn: function (aBlock,anotherBlock){
  2641. var self=this;
  2642. return smalltalk.withContext(function($ctx1) {
  2643. self = self._numericallyIndexable();
  2644. for(var i = 0; i < self.length; i++)
  2645. if(aBlock._value_(self[i]))
  2646. return self[i];
  2647. return anotherBlock._value();
  2648. ;
  2649. return self}, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.SequenceableCollection)})},
  2650. args: ["aBlock", "anotherBlock"],
  2651. 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>",
  2652. messageSends: [],
  2653. referencedClasses: []
  2654. }),
  2655. smalltalk.SequenceableCollection);
  2656. smalltalk.addMethod(
  2657. smalltalk.method({
  2658. selector: "do:",
  2659. protocol: 'enumerating',
  2660. fn: function (aBlock){
  2661. var self=this;
  2662. return smalltalk.withContext(function($ctx1) {
  2663. self = self._numericallyIndexable();
  2664. for(var i=0; i < self.length; i++) {
  2665. aBlock._value_(self[i]);
  2666. }
  2667. ;
  2668. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.SequenceableCollection)})},
  2669. args: ["aBlock"],
  2670. 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>",
  2671. messageSends: [],
  2672. referencedClasses: []
  2673. }),
  2674. smalltalk.SequenceableCollection);
  2675. smalltalk.addMethod(
  2676. smalltalk.method({
  2677. selector: "endsWith:",
  2678. protocol: 'testing',
  2679. fn: function (suffix){
  2680. var self=this;
  2681. return smalltalk.withContext(function($ctx1) {
  2682. var $2,$3,$1,$4;
  2683. $2=self._size();
  2684. $ctx1.sendIdx["size"]=1;
  2685. $3=_st(suffix)._size();
  2686. $ctx1.sendIdx["size"]=2;
  2687. $1=_st($2).__lt($3);
  2688. if(smalltalk.assert($1)){
  2689. return false;
  2690. };
  2691. $4=_st(self._last_(_st(suffix)._size())).__eq(suffix);
  2692. return $4;
  2693. }, function($ctx1) {$ctx1.fill(self,"endsWith:",{suffix:suffix},smalltalk.SequenceableCollection)})},
  2694. args: ["suffix"],
  2695. source: "endsWith: suffix\x0a\x09self size < suffix size ifTrue: [ ^ false ].\x0a\x09^ (self last: suffix size) = suffix",
  2696. messageSends: ["ifTrue:", "<", "size", "=", "last:"],
  2697. referencedClasses: []
  2698. }),
  2699. smalltalk.SequenceableCollection);
  2700. smalltalk.addMethod(
  2701. smalltalk.method({
  2702. selector: "first",
  2703. protocol: 'accessing',
  2704. fn: function (){
  2705. var self=this;
  2706. return smalltalk.withContext(function($ctx1) {
  2707. var $1;
  2708. $1=self._at_((1));
  2709. return $1;
  2710. }, function($ctx1) {$ctx1.fill(self,"first",{},smalltalk.SequenceableCollection)})},
  2711. args: [],
  2712. source: "first\x0a\x09^ self at: 1",
  2713. messageSends: ["at:"],
  2714. referencedClasses: []
  2715. }),
  2716. smalltalk.SequenceableCollection);
  2717. smalltalk.addMethod(
  2718. smalltalk.method({
  2719. selector: "first:",
  2720. protocol: 'accessing',
  2721. fn: function (aNumber){
  2722. var self=this;
  2723. return smalltalk.withContext(function($ctx1) {
  2724. var $1,$2;
  2725. $1=_st(self._size()).__lt(aNumber);
  2726. if(smalltalk.assert($1)){
  2727. self._error_("Invalid number of elements");
  2728. };
  2729. $2=self._copyFrom_to_((1),aNumber);
  2730. return $2;
  2731. }, function($ctx1) {$ctx1.fill(self,"first:",{aNumber:aNumber},smalltalk.SequenceableCollection)})},
  2732. args: ["aNumber"],
  2733. 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",
  2734. messageSends: ["ifTrue:", "<", "size", "error:", "copyFrom:to:"],
  2735. referencedClasses: []
  2736. }),
  2737. smalltalk.SequenceableCollection);
  2738. smalltalk.addMethod(
  2739. smalltalk.method({
  2740. selector: "fourth",
  2741. protocol: 'accessing',
  2742. fn: function (){
  2743. var self=this;
  2744. return smalltalk.withContext(function($ctx1) {
  2745. var $1;
  2746. $1=self._at_((4));
  2747. return $1;
  2748. }, function($ctx1) {$ctx1.fill(self,"fourth",{},smalltalk.SequenceableCollection)})},
  2749. args: [],
  2750. source: "fourth\x0a\x09^ self at: 4",
  2751. messageSends: ["at:"],
  2752. referencedClasses: []
  2753. }),
  2754. smalltalk.SequenceableCollection);
  2755. smalltalk.addMethod(
  2756. smalltalk.method({
  2757. selector: "includes:",
  2758. protocol: 'testing',
  2759. fn: function (anObject){
  2760. var self=this;
  2761. return smalltalk.withContext(function($ctx1) {
  2762. var $1;
  2763. $1=_st(self._indexOf_ifAbsent_(anObject,(function(){
  2764. return smalltalk.withContext(function($ctx2) {
  2765. return nil;
  2766. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._notNil();
  2767. return $1;
  2768. }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject},smalltalk.SequenceableCollection)})},
  2769. args: ["anObject"],
  2770. source: "includes: anObject\x0a\x09^ (self indexOf: anObject ifAbsent: [ nil ]) notNil",
  2771. messageSends: ["notNil", "indexOf:ifAbsent:"],
  2772. referencedClasses: []
  2773. }),
  2774. smalltalk.SequenceableCollection);
  2775. smalltalk.addMethod(
  2776. smalltalk.method({
  2777. selector: "indexOf:ifAbsent:",
  2778. protocol: 'accessing',
  2779. fn: function (anObject,aBlock){
  2780. var self=this;
  2781. return smalltalk.withContext(function($ctx1) {
  2782. self = self._numericallyIndexable();
  2783. for(var i=0; i < self.length; i++) {
  2784. if(_st(self[i]).__eq(anObject)) {return i+1}
  2785. };
  2786. return aBlock._value();
  2787. ;
  2788. return self}, function($ctx1) {$ctx1.fill(self,"indexOf:ifAbsent:",{anObject:anObject,aBlock:aBlock},smalltalk.SequenceableCollection)})},
  2789. args: ["anObject", "aBlock"],
  2790. 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>",
  2791. messageSends: [],
  2792. referencedClasses: []
  2793. }),
  2794. smalltalk.SequenceableCollection);
  2795. smalltalk.addMethod(
  2796. smalltalk.method({
  2797. selector: "indexOf:startingAt:",
  2798. protocol: 'accessing',
  2799. fn: function (anObject,start){
  2800. var self=this;
  2801. return smalltalk.withContext(function($ctx1) {
  2802. var $1;
  2803. $1=self._indexOf_startingAt_ifAbsent_(anObject,start,(function(){
  2804. return smalltalk.withContext(function($ctx2) {
  2805. return (0);
  2806. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2807. return $1;
  2808. }, function($ctx1) {$ctx1.fill(self,"indexOf:startingAt:",{anObject:anObject,start:start},smalltalk.SequenceableCollection)})},
  2809. args: ["anObject", "start"],
  2810. 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 ]",
  2811. messageSends: ["indexOf:startingAt:ifAbsent:"],
  2812. referencedClasses: []
  2813. }),
  2814. smalltalk.SequenceableCollection);
  2815. smalltalk.addMethod(
  2816. smalltalk.method({
  2817. selector: "indexOf:startingAt:ifAbsent:",
  2818. protocol: 'accessing',
  2819. fn: function (anObject,start,aBlock){
  2820. var self=this;
  2821. return smalltalk.withContext(function($ctx1) {
  2822. self = self._numericallyIndexable();
  2823. for(var i=start - 1; i < self.length; i++){
  2824. if(_st(self[i]).__eq(anObject)) {return i+1}
  2825. }
  2826. return aBlock._value();
  2827. ;
  2828. return self}, function($ctx1) {$ctx1.fill(self,"indexOf:startingAt:ifAbsent:",{anObject:anObject,start:start,aBlock:aBlock},smalltalk.SequenceableCollection)})},
  2829. args: ["anObject", "start", "aBlock"],
  2830. 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>",
  2831. messageSends: [],
  2832. referencedClasses: []
  2833. }),
  2834. smalltalk.SequenceableCollection);
  2835. smalltalk.addMethod(
  2836. smalltalk.method({
  2837. selector: "last",
  2838. protocol: 'accessing',
  2839. fn: function (){
  2840. var self=this;
  2841. return smalltalk.withContext(function($ctx1) {
  2842. var $1;
  2843. $1=self._at_(self._size());
  2844. return $1;
  2845. }, function($ctx1) {$ctx1.fill(self,"last",{},smalltalk.SequenceableCollection)})},
  2846. args: [],
  2847. source: "last\x0a\x09^ self at: self size",
  2848. messageSends: ["at:", "size"],
  2849. referencedClasses: []
  2850. }),
  2851. smalltalk.SequenceableCollection);
  2852. smalltalk.addMethod(
  2853. smalltalk.method({
  2854. selector: "last:",
  2855. protocol: 'accessing',
  2856. fn: function (aNumber){
  2857. var self=this;
  2858. return smalltalk.withContext(function($ctx1) {
  2859. var $2,$1,$6,$5,$4,$3;
  2860. $2=self._size();
  2861. $ctx1.sendIdx["size"]=1;
  2862. $1=_st($2).__lt(aNumber);
  2863. if(smalltalk.assert($1)){
  2864. self._error_("Invalid number of elements");
  2865. };
  2866. $6=self._size();
  2867. $ctx1.sendIdx["size"]=2;
  2868. $5=_st($6).__minus(aNumber);
  2869. $4=_st($5).__plus((1));
  2870. $3=self._copyFrom_to_($4,self._size());
  2871. return $3;
  2872. }, function($ctx1) {$ctx1.fill(self,"last:",{aNumber:aNumber},smalltalk.SequenceableCollection)})},
  2873. args: ["aNumber"],
  2874. 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",
  2875. messageSends: ["ifTrue:", "<", "size", "error:", "copyFrom:to:", "+", "-"],
  2876. referencedClasses: []
  2877. }),
  2878. smalltalk.SequenceableCollection);
  2879. smalltalk.addMethod(
  2880. smalltalk.method({
  2881. selector: "newStream",
  2882. protocol: 'streaming',
  2883. fn: function (){
  2884. var self=this;
  2885. return smalltalk.withContext(function($ctx1) {
  2886. var $1;
  2887. $1=_st(self._streamClass())._on_(self);
  2888. return $1;
  2889. }, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.SequenceableCollection)})},
  2890. args: [],
  2891. source: "newStream\x0a\x09^ self streamClass on: self",
  2892. messageSends: ["on:", "streamClass"],
  2893. referencedClasses: []
  2894. }),
  2895. smalltalk.SequenceableCollection);
  2896. smalltalk.addMethod(
  2897. smalltalk.method({
  2898. selector: "numericallyIndexable",
  2899. protocol: 'private',
  2900. fn: function (){
  2901. var self=this;
  2902. return smalltalk.withContext(function($ctx1) {
  2903. self._subclassResponsibility();
  2904. return self}, function($ctx1) {$ctx1.fill(self,"numericallyIndexable",{},smalltalk.SequenceableCollection)})},
  2905. args: [],
  2906. 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",
  2907. messageSends: ["subclassResponsibility"],
  2908. referencedClasses: []
  2909. }),
  2910. smalltalk.SequenceableCollection);
  2911. smalltalk.addMethod(
  2912. smalltalk.method({
  2913. selector: "readStream",
  2914. protocol: 'streaming',
  2915. fn: function (){
  2916. var self=this;
  2917. return smalltalk.withContext(function($ctx1) {
  2918. var $1;
  2919. $1=self._stream();
  2920. return $1;
  2921. }, function($ctx1) {$ctx1.fill(self,"readStream",{},smalltalk.SequenceableCollection)})},
  2922. args: [],
  2923. source: "readStream\x0a\x09\x22For Pharo compatibility\x22\x0a\x09\x0a\x09^ self stream",
  2924. messageSends: ["stream"],
  2925. referencedClasses: []
  2926. }),
  2927. smalltalk.SequenceableCollection);
  2928. smalltalk.addMethod(
  2929. smalltalk.method({
  2930. selector: "removeLast",
  2931. protocol: 'adding/removing',
  2932. fn: function (){
  2933. var self=this;
  2934. return smalltalk.withContext(function($ctx1) {
  2935. var $1;
  2936. $1=self._remove_(self._last());
  2937. return $1;
  2938. }, function($ctx1) {$ctx1.fill(self,"removeLast",{},smalltalk.SequenceableCollection)})},
  2939. args: [],
  2940. source: "removeLast\x0a\x09^ self remove: self last",
  2941. messageSends: ["remove:", "last"],
  2942. referencedClasses: []
  2943. }),
  2944. smalltalk.SequenceableCollection);
  2945. smalltalk.addMethod(
  2946. smalltalk.method({
  2947. selector: "reversed",
  2948. protocol: 'converting',
  2949. fn: function (){
  2950. var self=this;
  2951. return smalltalk.withContext(function($ctx1) {
  2952. self._subclassResponsibility();
  2953. return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},smalltalk.SequenceableCollection)})},
  2954. args: [],
  2955. source: "reversed\x0a\x09self subclassResponsibility",
  2956. messageSends: ["subclassResponsibility"],
  2957. referencedClasses: []
  2958. }),
  2959. smalltalk.SequenceableCollection);
  2960. smalltalk.addMethod(
  2961. smalltalk.method({
  2962. selector: "second",
  2963. protocol: 'accessing',
  2964. fn: function (){
  2965. var self=this;
  2966. return smalltalk.withContext(function($ctx1) {
  2967. var $1;
  2968. $1=self._at_((2));
  2969. return $1;
  2970. }, function($ctx1) {$ctx1.fill(self,"second",{},smalltalk.SequenceableCollection)})},
  2971. args: [],
  2972. source: "second\x0a\x09^ self at: 2",
  2973. messageSends: ["at:"],
  2974. referencedClasses: []
  2975. }),
  2976. smalltalk.SequenceableCollection);
  2977. smalltalk.addMethod(
  2978. smalltalk.method({
  2979. selector: "shallowCopy",
  2980. protocol: 'copying',
  2981. fn: function (){
  2982. var self=this;
  2983. var newCollection;
  2984. return smalltalk.withContext(function($ctx1) {
  2985. var $1;
  2986. newCollection=_st(self._class())._new_(self._size());
  2987. self._withIndexDo_((function(each,index){
  2988. return smalltalk.withContext(function($ctx2) {
  2989. return _st(newCollection)._at_put_(index,each);
  2990. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  2991. $1=newCollection;
  2992. return $1;
  2993. }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{newCollection:newCollection},smalltalk.SequenceableCollection)})},
  2994. args: [],
  2995. 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",
  2996. messageSends: ["new:", "class", "size", "withIndexDo:", "at:put:"],
  2997. referencedClasses: []
  2998. }),
  2999. smalltalk.SequenceableCollection);
  3000. smalltalk.addMethod(
  3001. smalltalk.method({
  3002. selector: "stream",
  3003. protocol: 'streaming',
  3004. fn: function (){
  3005. var self=this;
  3006. return smalltalk.withContext(function($ctx1) {
  3007. var $1;
  3008. $1=self._newStream();
  3009. return $1;
  3010. }, function($ctx1) {$ctx1.fill(self,"stream",{},smalltalk.SequenceableCollection)})},
  3011. args: [],
  3012. source: "stream\x0a\x09^ self newStream",
  3013. messageSends: ["newStream"],
  3014. referencedClasses: []
  3015. }),
  3016. smalltalk.SequenceableCollection);
  3017. smalltalk.addMethod(
  3018. smalltalk.method({
  3019. selector: "streamClass",
  3020. protocol: 'streaming',
  3021. fn: function (){
  3022. var self=this;
  3023. return smalltalk.withContext(function($ctx1) {
  3024. var $1;
  3025. $1=_st(self._class())._streamClass();
  3026. return $1;
  3027. }, function($ctx1) {$ctx1.fill(self,"streamClass",{},smalltalk.SequenceableCollection)})},
  3028. args: [],
  3029. source: "streamClass\x0a\x09^ self class streamClass",
  3030. messageSends: ["streamClass", "class"],
  3031. referencedClasses: []
  3032. }),
  3033. smalltalk.SequenceableCollection);
  3034. smalltalk.addMethod(
  3035. smalltalk.method({
  3036. selector: "third",
  3037. protocol: 'accessing',
  3038. fn: function (){
  3039. var self=this;
  3040. return smalltalk.withContext(function($ctx1) {
  3041. var $1;
  3042. $1=self._at_((3));
  3043. return $1;
  3044. }, function($ctx1) {$ctx1.fill(self,"third",{},smalltalk.SequenceableCollection)})},
  3045. args: [],
  3046. source: "third\x0a\x09^ self at: 3",
  3047. messageSends: ["at:"],
  3048. referencedClasses: []
  3049. }),
  3050. smalltalk.SequenceableCollection);
  3051. smalltalk.addMethod(
  3052. smalltalk.method({
  3053. selector: "with:do:",
  3054. protocol: 'enumerating',
  3055. fn: function (anotherCollection,aBlock){
  3056. var self=this;
  3057. return smalltalk.withContext(function($ctx1) {
  3058. self = self._numericallyIndexable();
  3059. anotherCollection = anotherCollection._numericallyIndexable();
  3060. for(var i=0; i<self.length; i++) {
  3061. aBlock._value_value_(self[i], anotherCollection[i]);
  3062. }
  3063. ;
  3064. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anotherCollection:anotherCollection,aBlock:aBlock},smalltalk.SequenceableCollection)})},
  3065. args: ["anotherCollection", "aBlock"],
  3066. 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>",
  3067. messageSends: [],
  3068. referencedClasses: []
  3069. }),
  3070. smalltalk.SequenceableCollection);
  3071. smalltalk.addMethod(
  3072. smalltalk.method({
  3073. selector: "withIndexDo:",
  3074. protocol: 'enumerating',
  3075. fn: function (aBlock){
  3076. var self=this;
  3077. return smalltalk.withContext(function($ctx1) {
  3078. self = self._numericallyIndexable();
  3079. for(var i=0; i < self.length; i++) {
  3080. aBlock._value_value_(self[i], i+1);
  3081. }
  3082. ;
  3083. return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},smalltalk.SequenceableCollection)})},
  3084. args: ["aBlock"],
  3085. 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>",
  3086. messageSends: [],
  3087. referencedClasses: []
  3088. }),
  3089. smalltalk.SequenceableCollection);
  3090. smalltalk.addMethod(
  3091. smalltalk.method({
  3092. selector: "writeStream",
  3093. protocol: 'streaming',
  3094. fn: function (){
  3095. var self=this;
  3096. return smalltalk.withContext(function($ctx1) {
  3097. var $1;
  3098. $1=self._stream();
  3099. return $1;
  3100. }, function($ctx1) {$ctx1.fill(self,"writeStream",{},smalltalk.SequenceableCollection)})},
  3101. args: [],
  3102. source: "writeStream\x0a\x09\x22For Pharo compatibility\x22\x0a\x09\x0a\x09^ self stream",
  3103. messageSends: ["stream"],
  3104. referencedClasses: []
  3105. }),
  3106. smalltalk.SequenceableCollection);
  3107. smalltalk.addMethod(
  3108. smalltalk.method({
  3109. selector: "streamClass",
  3110. protocol: 'accessing',
  3111. fn: function (){
  3112. var self=this;
  3113. function $Stream(){return smalltalk.Stream||(typeof Stream=="undefined"?nil:Stream)}
  3114. return smalltalk.withContext(function($ctx1) {
  3115. return $Stream();
  3116. }, function($ctx1) {$ctx1.fill(self,"streamClass",{},smalltalk.SequenceableCollection.klass)})},
  3117. args: [],
  3118. source: "streamClass\x0a\x09\x09^ Stream",
  3119. messageSends: [],
  3120. referencedClasses: ["Stream"]
  3121. }),
  3122. smalltalk.SequenceableCollection.klass);
  3123. smalltalk.addMethod(
  3124. smalltalk.method({
  3125. selector: "streamContents:",
  3126. protocol: 'streaming',
  3127. fn: function (aBlock){
  3128. var self=this;
  3129. var stream;
  3130. return smalltalk.withContext(function($ctx1) {
  3131. var $1;
  3132. stream=_st(self._streamClass())._on_(self._new());
  3133. _st(aBlock)._value_(stream);
  3134. $1=_st(stream)._contents();
  3135. return $1;
  3136. }, function($ctx1) {$ctx1.fill(self,"streamContents:",{aBlock:aBlock,stream:stream},smalltalk.SequenceableCollection.klass)})},
  3137. args: ["aBlock"],
  3138. source: "streamContents: aBlock\x0a\x09| stream |\x0a\x09stream := (self streamClass on: self new).\x0a\x09aBlock value: stream.\x0a\x09^ stream contents",
  3139. messageSends: ["on:", "streamClass", "new", "value:", "contents"],
  3140. referencedClasses: []
  3141. }),
  3142. smalltalk.SequenceableCollection.klass);
  3143. smalltalk.addClass('Array', smalltalk.SequenceableCollection, [], 'Kernel-Collections');
  3144. smalltalk.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`.";
  3145. smalltalk.addMethod(
  3146. smalltalk.method({
  3147. selector: "add:",
  3148. protocol: 'adding/removing',
  3149. fn: function (anObject){
  3150. var self=this;
  3151. return smalltalk.withContext(function($ctx1) {
  3152. self.push(anObject); return anObject;;
  3153. return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},smalltalk.Array)})},
  3154. args: ["anObject"],
  3155. source: "add: anObject\x0a\x09<self.push(anObject); return anObject;>",
  3156. messageSends: [],
  3157. referencedClasses: []
  3158. }),
  3159. smalltalk.Array);
  3160. smalltalk.addMethod(
  3161. smalltalk.method({
  3162. selector: "addFirst:",
  3163. protocol: 'adding/removing',
  3164. fn: function (anObject){
  3165. var self=this;
  3166. return smalltalk.withContext(function($ctx1) {
  3167. self.unshift(anObject); return anObject;;
  3168. return self}, function($ctx1) {$ctx1.fill(self,"addFirst:",{anObject:anObject},smalltalk.Array)})},
  3169. args: ["anObject"],
  3170. source: "addFirst: anObject\x0a\x09<self.unshift(anObject); return anObject;>",
  3171. messageSends: [],
  3172. referencedClasses: []
  3173. }),
  3174. smalltalk.Array);
  3175. smalltalk.addMethod(
  3176. smalltalk.method({
  3177. selector: "asJavascript",
  3178. protocol: 'converting',
  3179. fn: function (){
  3180. var self=this;
  3181. return smalltalk.withContext(function($ctx1) {
  3182. var $1;
  3183. $1=_st("[".__comma(_st(self._collect_((function(each){
  3184. return smalltalk.withContext(function($ctx2) {
  3185. return _st(each)._asJavascript();
  3186. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._join_(", "))).__comma("]");
  3187. $ctx1.sendIdx[","]=1;
  3188. return $1;
  3189. }, function($ctx1) {$ctx1.fill(self,"asJavascript",{},smalltalk.Array)})},
  3190. args: [],
  3191. source: "asJavascript\x0a\x09^ '[', ((self collect: [:each | each asJavascript ]) join: ', '), ']'",
  3192. messageSends: [",", "join:", "collect:", "asJavascript"],
  3193. referencedClasses: []
  3194. }),
  3195. smalltalk.Array);
  3196. smalltalk.addMethod(
  3197. smalltalk.method({
  3198. selector: "at:ifAbsent:",
  3199. protocol: 'accessing',
  3200. fn: function (anIndex,aBlock){
  3201. var self=this;
  3202. return smalltalk.withContext(function($ctx1) {
  3203. return anIndex >= 1 && anIndex <= self.length
  3204. ? self[anIndex - 1]
  3205. : aBlock._value()
  3206. ;
  3207. return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},smalltalk.Array)})},
  3208. args: ["anIndex", "aBlock"],
  3209. 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>",
  3210. messageSends: [],
  3211. referencedClasses: []
  3212. }),
  3213. smalltalk.Array);
  3214. smalltalk.addMethod(
  3215. smalltalk.method({
  3216. selector: "at:ifPresent:ifAbsent:",
  3217. protocol: 'accessing',
  3218. fn: function (anIndex,aBlock,anotherBlock){
  3219. var self=this;
  3220. return smalltalk.withContext(function($ctx1) {
  3221. return anIndex >= 1 && anIndex <= self.length
  3222. ? aBlock._value_(self[anIndex - 1])
  3223. : anotherBlock._value()
  3224. ;
  3225. return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.Array)})},
  3226. args: ["anIndex", "aBlock", "anotherBlock"],
  3227. 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>",
  3228. messageSends: [],
  3229. referencedClasses: []
  3230. }),
  3231. smalltalk.Array);
  3232. smalltalk.addMethod(
  3233. smalltalk.method({
  3234. selector: "at:put:",
  3235. protocol: 'accessing',
  3236. fn: function (anIndex,anObject){
  3237. var self=this;
  3238. return smalltalk.withContext(function($ctx1) {
  3239. return self[anIndex - 1] = anObject;
  3240. return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},smalltalk.Array)})},
  3241. args: ["anIndex", "anObject"],
  3242. source: "at: anIndex put: anObject\x0a\x09<return self[anIndex - 1] = anObject>",
  3243. messageSends: [],
  3244. referencedClasses: []
  3245. }),
  3246. smalltalk.Array);
  3247. smalltalk.addMethod(
  3248. smalltalk.method({
  3249. selector: "collect:",
  3250. protocol: 'enumerating',
  3251. fn: function (aBlock){
  3252. var self=this;
  3253. return smalltalk.withContext(function($ctx1) {
  3254. return self.map(function(each) {return aBlock._value_(each)});
  3255. return self}, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock},smalltalk.Array)})},
  3256. args: ["aBlock"],
  3257. source: "collect: aBlock\x0a\x09\x22Optimized version\x22\x0a\x09\x0a\x09<return self.map(function(each) {return aBlock._value_(each)})>",
  3258. messageSends: [],
  3259. referencedClasses: []
  3260. }),
  3261. smalltalk.Array);
  3262. smalltalk.addMethod(
  3263. smalltalk.method({
  3264. selector: "join:",
  3265. protocol: 'enumerating',
  3266. fn: function (aString){
  3267. var self=this;
  3268. return smalltalk.withContext(function($ctx1) {
  3269. return self.join(aString);
  3270. return self}, function($ctx1) {$ctx1.fill(self,"join:",{aString:aString},smalltalk.Array)})},
  3271. args: ["aString"],
  3272. source: "join: aString\x0a\x09<return self.join(aString)>",
  3273. messageSends: [],
  3274. referencedClasses: []
  3275. }),
  3276. smalltalk.Array);
  3277. smalltalk.addMethod(
  3278. smalltalk.method({
  3279. selector: "numericallyIndexable",
  3280. protocol: 'private',
  3281. fn: function (){
  3282. var self=this;
  3283. return smalltalk.withContext(function($ctx1) {
  3284. return self;
  3285. }, function($ctx1) {$ctx1.fill(self,"numericallyIndexable",{},smalltalk.Array)})},
  3286. args: [],
  3287. source: "numericallyIndexable\x0a\x09^ self",
  3288. messageSends: [],
  3289. referencedClasses: []
  3290. }),
  3291. smalltalk.Array);
  3292. smalltalk.addMethod(
  3293. smalltalk.method({
  3294. selector: "printOn:",
  3295. protocol: 'printing',
  3296. fn: function (aStream){
  3297. var self=this;
  3298. return smalltalk.withContext(function($ctx1) {
  3299. smalltalk.Array.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  3300. $ctx1.sendIdx["printOn:"]=1;
  3301. _st(aStream)._nextPutAll_(" (");
  3302. $ctx1.sendIdx["nextPutAll:"]=1;
  3303. self._do_separatedBy_((function(each){
  3304. return smalltalk.withContext(function($ctx2) {
  3305. return _st(each)._printOn_(aStream);
  3306. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  3307. return smalltalk.withContext(function($ctx2) {
  3308. return _st(aStream)._nextPutAll_(" ");
  3309. $ctx2.sendIdx["nextPutAll:"]=2;
  3310. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  3311. _st(aStream)._nextPutAll_(")");
  3312. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.Array)})},
  3313. args: ["aStream"],
  3314. 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: ')'",
  3315. messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:"],
  3316. referencedClasses: []
  3317. }),
  3318. smalltalk.Array);
  3319. smalltalk.addMethod(
  3320. smalltalk.method({
  3321. selector: "remove:ifAbsent:",
  3322. protocol: 'adding/removing',
  3323. fn: function (anObject,aBlock){
  3324. var self=this;
  3325. var index;
  3326. return smalltalk.withContext(function($ctx1) {
  3327. var $2,$1;
  3328. index=self._indexOf_ifAbsent_(anObject,(function(){
  3329. return smalltalk.withContext(function($ctx2) {
  3330. return (0);
  3331. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  3332. $2=_st(index).__eq((0));
  3333. if(smalltalk.assert($2)){
  3334. $1=_st(aBlock)._value();
  3335. } else {
  3336. self._removeIndex_(index);
  3337. $1=anObject;
  3338. };
  3339. return $1;
  3340. }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock,index:index},smalltalk.Array)})},
  3341. args: ["anObject", "aBlock"],
  3342. 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 ]",
  3343. messageSends: ["indexOf:ifAbsent:", "ifFalse:ifTrue:", "=", "removeIndex:", "value"],
  3344. referencedClasses: []
  3345. }),
  3346. smalltalk.Array);
  3347. smalltalk.addMethod(
  3348. smalltalk.method({
  3349. selector: "removeAll",
  3350. protocol: 'adding/removing',
  3351. fn: function (){
  3352. var self=this;
  3353. return smalltalk.withContext(function($ctx1) {
  3354. self.length = 0;
  3355. return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.Array)})},
  3356. args: [],
  3357. source: "removeAll\x0a\x09<self.length = 0>",
  3358. messageSends: [],
  3359. referencedClasses: []
  3360. }),
  3361. smalltalk.Array);
  3362. smalltalk.addMethod(
  3363. smalltalk.method({
  3364. selector: "removeFrom:to:",
  3365. protocol: 'adding/removing',
  3366. fn: function (aNumber,anotherNumber){
  3367. var self=this;
  3368. return smalltalk.withContext(function($ctx1) {
  3369. self.splice(aNumber -1, anotherNumber - aNumber + 1);
  3370. return self}, function($ctx1) {$ctx1.fill(self,"removeFrom:to:",{aNumber:aNumber,anotherNumber:anotherNumber},smalltalk.Array)})},
  3371. args: ["aNumber", "anotherNumber"],
  3372. source: "removeFrom: aNumber to: anotherNumber\x0a\x09<self.splice(aNumber -1, anotherNumber - aNumber + 1)>",
  3373. messageSends: [],
  3374. referencedClasses: []
  3375. }),
  3376. smalltalk.Array);
  3377. smalltalk.addMethod(
  3378. smalltalk.method({
  3379. selector: "removeIndex:",
  3380. protocol: 'adding/removing',
  3381. fn: function (anInteger){
  3382. var self=this;
  3383. return smalltalk.withContext(function($ctx1) {
  3384. self.splice(anInteger - 1, 1);
  3385. return self}, function($ctx1) {$ctx1.fill(self,"removeIndex:",{anInteger:anInteger},smalltalk.Array)})},
  3386. args: ["anInteger"],
  3387. source: "removeIndex: anInteger\x0a\x09<self.splice(anInteger - 1, 1)>",
  3388. messageSends: [],
  3389. referencedClasses: []
  3390. }),
  3391. smalltalk.Array);
  3392. smalltalk.addMethod(
  3393. smalltalk.method({
  3394. selector: "removeLast",
  3395. protocol: 'adding/removing',
  3396. fn: function (){
  3397. var self=this;
  3398. return smalltalk.withContext(function($ctx1) {
  3399. return self.pop();;
  3400. return self}, function($ctx1) {$ctx1.fill(self,"removeLast",{},smalltalk.Array)})},
  3401. args: [],
  3402. source: "removeLast\x0a\x09<return self.pop();>",
  3403. messageSends: [],
  3404. referencedClasses: []
  3405. }),
  3406. smalltalk.Array);
  3407. smalltalk.addMethod(
  3408. smalltalk.method({
  3409. selector: "reversed",
  3410. protocol: 'converting',
  3411. fn: function (){
  3412. var self=this;
  3413. return smalltalk.withContext(function($ctx1) {
  3414. return self._copy().reverse();
  3415. return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},smalltalk.Array)})},
  3416. args: [],
  3417. source: "reversed\x0a\x09<return self._copy().reverse()>",
  3418. messageSends: [],
  3419. referencedClasses: []
  3420. }),
  3421. smalltalk.Array);
  3422. smalltalk.addMethod(
  3423. smalltalk.method({
  3424. selector: "select:",
  3425. protocol: 'enumerating',
  3426. fn: function (aBlock){
  3427. var self=this;
  3428. return smalltalk.withContext(function($ctx1) {
  3429. var result = self.klass._new();
  3430. for(var i=0; i<self.length; i++) {
  3431. if(aBlock._value_(self[i])) {
  3432. result.push(self[i]);
  3433. }
  3434. }
  3435. return result;
  3436. ;
  3437. return self}, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock},smalltalk.Array)})},
  3438. args: ["aBlock"],
  3439. 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>",
  3440. messageSends: [],
  3441. referencedClasses: []
  3442. }),
  3443. smalltalk.Array);
  3444. smalltalk.addMethod(
  3445. smalltalk.method({
  3446. selector: "size",
  3447. protocol: 'accessing',
  3448. fn: function (){
  3449. var self=this;
  3450. return smalltalk.withContext(function($ctx1) {
  3451. return self.length;
  3452. return self}, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.Array)})},
  3453. args: [],
  3454. source: "size\x0a\x09<return self.length>",
  3455. messageSends: [],
  3456. referencedClasses: []
  3457. }),
  3458. smalltalk.Array);
  3459. smalltalk.addMethod(
  3460. smalltalk.method({
  3461. selector: "sort",
  3462. protocol: 'enumerating',
  3463. fn: function (){
  3464. var self=this;
  3465. return smalltalk.withContext(function($ctx1) {
  3466. var $1;
  3467. $1=self._basicPerform_("sort");
  3468. return $1;
  3469. }, function($ctx1) {$ctx1.fill(self,"sort",{},smalltalk.Array)})},
  3470. args: [],
  3471. source: "sort\x0a\x09^ self basicPerform: 'sort'",
  3472. messageSends: ["basicPerform:"],
  3473. referencedClasses: []
  3474. }),
  3475. smalltalk.Array);
  3476. smalltalk.addMethod(
  3477. smalltalk.method({
  3478. selector: "sort:",
  3479. protocol: 'enumerating',
  3480. fn: function (aBlock){
  3481. var self=this;
  3482. return smalltalk.withContext(function($ctx1) {
  3483. return self.sort(function(a, b) {
  3484. if(aBlock._value_value_(a,b)) {return -1} else {return 1}
  3485. })
  3486. ;
  3487. return self}, function($ctx1) {$ctx1.fill(self,"sort:",{aBlock:aBlock},smalltalk.Array)})},
  3488. args: ["aBlock"],
  3489. 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>",
  3490. messageSends: [],
  3491. referencedClasses: []
  3492. }),
  3493. smalltalk.Array);
  3494. smalltalk.addMethod(
  3495. smalltalk.method({
  3496. selector: "sorted",
  3497. protocol: 'enumerating',
  3498. fn: function (){
  3499. var self=this;
  3500. return smalltalk.withContext(function($ctx1) {
  3501. var $1;
  3502. $1=_st(self._copy())._sort();
  3503. return $1;
  3504. }, function($ctx1) {$ctx1.fill(self,"sorted",{},smalltalk.Array)})},
  3505. args: [],
  3506. source: "sorted\x0a\x09^ self copy sort",
  3507. messageSends: ["sort", "copy"],
  3508. referencedClasses: []
  3509. }),
  3510. smalltalk.Array);
  3511. smalltalk.addMethod(
  3512. smalltalk.method({
  3513. selector: "sorted:",
  3514. protocol: 'enumerating',
  3515. fn: function (aBlock){
  3516. var self=this;
  3517. return smalltalk.withContext(function($ctx1) {
  3518. var $1;
  3519. $1=_st(self._copy())._sort_(aBlock);
  3520. return $1;
  3521. }, function($ctx1) {$ctx1.fill(self,"sorted:",{aBlock:aBlock},smalltalk.Array)})},
  3522. args: ["aBlock"],
  3523. source: "sorted: aBlock\x0a\x09^ self copy sort: aBlock",
  3524. messageSends: ["sort:", "copy"],
  3525. referencedClasses: []
  3526. }),
  3527. smalltalk.Array);
  3528. smalltalk.addMethod(
  3529. smalltalk.method({
  3530. selector: "new:",
  3531. protocol: 'instance creation',
  3532. fn: function (anInteger){
  3533. var self=this;
  3534. return smalltalk.withContext(function($ctx1) {
  3535. return new Array(anInteger);
  3536. return self}, function($ctx1) {$ctx1.fill(self,"new:",{anInteger:anInteger},smalltalk.Array.klass)})},
  3537. args: ["anInteger"],
  3538. source: "new: anInteger\x0a\x09<return new Array(anInteger)>",
  3539. messageSends: [],
  3540. referencedClasses: []
  3541. }),
  3542. smalltalk.Array.klass);
  3543. smalltalk.addMethod(
  3544. smalltalk.method({
  3545. selector: "with:",
  3546. protocol: 'instance creation',
  3547. fn: function (anObject){
  3548. var self=this;
  3549. return smalltalk.withContext(function($ctx1) {
  3550. var $2,$3,$1;
  3551. $2=self._new_((1));
  3552. _st($2)._at_put_((1),anObject);
  3553. $3=_st($2)._yourself();
  3554. $1=$3;
  3555. return $1;
  3556. }, function($ctx1) {$ctx1.fill(self,"with:",{anObject:anObject},smalltalk.Array.klass)})},
  3557. args: ["anObject"],
  3558. source: "with: anObject\x0a\x09\x09^ (self new: 1)\x0a\x09\x09at: 1 put: anObject;\x0a\x09\x09yourself",
  3559. messageSends: ["at:put:", "new:", "yourself"],
  3560. referencedClasses: []
  3561. }),
  3562. smalltalk.Array.klass);
  3563. smalltalk.addMethod(
  3564. smalltalk.method({
  3565. selector: "with:with:",
  3566. protocol: 'instance creation',
  3567. fn: function (anObject,anObject2){
  3568. var self=this;
  3569. return smalltalk.withContext(function($ctx1) {
  3570. var $2,$3,$1;
  3571. $2=self._new_((2));
  3572. _st($2)._at_put_((1),anObject);
  3573. $ctx1.sendIdx["at:put:"]=1;
  3574. _st($2)._at_put_((2),anObject2);
  3575. $3=_st($2)._yourself();
  3576. $1=$3;
  3577. return $1;
  3578. }, function($ctx1) {$ctx1.fill(self,"with:with:",{anObject:anObject,anObject2:anObject2},smalltalk.Array.klass)})},
  3579. args: ["anObject", "anObject2"],
  3580. 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",
  3581. messageSends: ["at:put:", "new:", "yourself"],
  3582. referencedClasses: []
  3583. }),
  3584. smalltalk.Array.klass);
  3585. smalltalk.addMethod(
  3586. smalltalk.method({
  3587. selector: "with:with:with:",
  3588. protocol: 'instance creation',
  3589. fn: function (anObject,anObject2,anObject3){
  3590. var self=this;
  3591. return smalltalk.withContext(function($ctx1) {
  3592. var $2,$3,$1;
  3593. $2=self._new_((3));
  3594. _st($2)._at_put_((1),anObject);
  3595. $ctx1.sendIdx["at:put:"]=1;
  3596. _st($2)._at_put_((2),anObject2);
  3597. $ctx1.sendIdx["at:put:"]=2;
  3598. _st($2)._at_put_((3),anObject3);
  3599. $3=_st($2)._yourself();
  3600. $1=$3;
  3601. return $1;
  3602. }, function($ctx1) {$ctx1.fill(self,"with:with:with:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},smalltalk.Array.klass)})},
  3603. args: ["anObject", "anObject2", "anObject3"],
  3604. 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",
  3605. messageSends: ["at:put:", "new:", "yourself"],
  3606. referencedClasses: []
  3607. }),
  3608. smalltalk.Array.klass);
  3609. smalltalk.addMethod(
  3610. smalltalk.method({
  3611. selector: "withAll:",
  3612. protocol: 'instance creation',
  3613. fn: function (aCollection){
  3614. var self=this;
  3615. var instance,index;
  3616. return smalltalk.withContext(function($ctx1) {
  3617. var $1;
  3618. index=(1);
  3619. instance=self._new_(_st(aCollection)._size());
  3620. _st(aCollection)._do_((function(each){
  3621. return smalltalk.withContext(function($ctx2) {
  3622. _st(instance)._at_put_(index,each);
  3623. index=_st(index).__plus((1));
  3624. return index;
  3625. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  3626. $1=instance;
  3627. return $1;
  3628. }, function($ctx1) {$ctx1.fill(self,"withAll:",{aCollection:aCollection,instance:instance,index:index},smalltalk.Array.klass)})},
  3629. args: ["aCollection"],
  3630. 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",
  3631. messageSends: ["new:", "size", "do:", "at:put:", "+"],
  3632. referencedClasses: []
  3633. }),
  3634. smalltalk.Array.klass);
  3635. smalltalk.addClass('CharacterArray', smalltalk.SequenceableCollection, [], 'Kernel-Collections');
  3636. smalltalk.CharacterArray.comment="I am the abstract superclass of string-like collections.";
  3637. smalltalk.addMethod(
  3638. smalltalk.method({
  3639. selector: ",",
  3640. protocol: 'copying',
  3641. fn: function (aString){
  3642. var self=this;
  3643. return smalltalk.withContext(function($ctx1) {
  3644. var $2,$1;
  3645. $2=self._asString();
  3646. $ctx1.sendIdx["asString"]=1;
  3647. $1=_st($2).__comma(_st(aString)._asString());
  3648. return $1;
  3649. }, function($ctx1) {$ctx1.fill(self,",",{aString:aString},smalltalk.CharacterArray)})},
  3650. args: ["aString"],
  3651. source: ", aString\x0a\x09^ self asString, aString asString",
  3652. messageSends: [",", "asString"],
  3653. referencedClasses: []
  3654. }),
  3655. smalltalk.CharacterArray);
  3656. smalltalk.addMethod(
  3657. smalltalk.method({
  3658. selector: "add:",
  3659. protocol: 'adding/removing',
  3660. fn: function (anObject){
  3661. var self=this;
  3662. return smalltalk.withContext(function($ctx1) {
  3663. self._errorReadOnly();
  3664. return self}, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject},smalltalk.CharacterArray)})},
  3665. args: ["anObject"],
  3666. source: "add: anObject\x0a\x09self errorReadOnly",
  3667. messageSends: ["errorReadOnly"],
  3668. referencedClasses: []
  3669. }),
  3670. smalltalk.CharacterArray);
  3671. smalltalk.addMethod(
  3672. smalltalk.method({
  3673. selector: "asLowercase",
  3674. protocol: 'converting',
  3675. fn: function (){
  3676. var self=this;
  3677. return smalltalk.withContext(function($ctx1) {
  3678. var $1;
  3679. $1=_st(self._class())._fromString_(_st(self._asString())._asLowercase());
  3680. return $1;
  3681. }, function($ctx1) {$ctx1.fill(self,"asLowercase",{},smalltalk.CharacterArray)})},
  3682. args: [],
  3683. source: "asLowercase\x0a\x09^ self class fromString: self asString asLowercase",
  3684. messageSends: ["fromString:", "class", "asLowercase", "asString"],
  3685. referencedClasses: []
  3686. }),
  3687. smalltalk.CharacterArray);
  3688. smalltalk.addMethod(
  3689. smalltalk.method({
  3690. selector: "asNumber",
  3691. protocol: 'converting',
  3692. fn: function (){
  3693. var self=this;
  3694. return smalltalk.withContext(function($ctx1) {
  3695. var $1;
  3696. $1=_st(self._asString())._asNumber();
  3697. return $1;
  3698. }, function($ctx1) {$ctx1.fill(self,"asNumber",{},smalltalk.CharacterArray)})},
  3699. args: [],
  3700. source: "asNumber\x0a\x09^ self asString asNumber",
  3701. messageSends: ["asNumber", "asString"],
  3702. referencedClasses: []
  3703. }),
  3704. smalltalk.CharacterArray);
  3705. smalltalk.addMethod(
  3706. smalltalk.method({
  3707. selector: "asString",
  3708. protocol: 'converting',
  3709. fn: function (){
  3710. var self=this;
  3711. return smalltalk.withContext(function($ctx1) {
  3712. var $1;
  3713. $1=self._subclassResponsibility();
  3714. return $1;
  3715. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.CharacterArray)})},
  3716. args: [],
  3717. source: "asString\x0a\x09^ self subclassResponsibility",
  3718. messageSends: ["subclassResponsibility"],
  3719. referencedClasses: []
  3720. }),
  3721. smalltalk.CharacterArray);
  3722. smalltalk.addMethod(
  3723. smalltalk.method({
  3724. selector: "asSymbol",
  3725. protocol: 'converting',
  3726. fn: function (){
  3727. var self=this;
  3728. return smalltalk.withContext(function($ctx1) {
  3729. var $1;
  3730. $1=self._asString();
  3731. return $1;
  3732. }, function($ctx1) {$ctx1.fill(self,"asSymbol",{},smalltalk.CharacterArray)})},
  3733. args: [],
  3734. source: "asSymbol\x0a\x09^ self asString",
  3735. messageSends: ["asString"],
  3736. referencedClasses: []
  3737. }),
  3738. smalltalk.CharacterArray);
  3739. smalltalk.addMethod(
  3740. smalltalk.method({
  3741. selector: "asUppercase",
  3742. protocol: 'converting',
  3743. fn: function (){
  3744. var self=this;
  3745. return smalltalk.withContext(function($ctx1) {
  3746. var $1;
  3747. $1=_st(self._class())._fromString_(_st(self._asString())._asUppercase());
  3748. return $1;
  3749. }, function($ctx1) {$ctx1.fill(self,"asUppercase",{},smalltalk.CharacterArray)})},
  3750. args: [],
  3751. source: "asUppercase\x0a\x09^ self class fromString: self asString asUppercase",
  3752. messageSends: ["fromString:", "class", "asUppercase", "asString"],
  3753. referencedClasses: []
  3754. }),
  3755. smalltalk.CharacterArray);
  3756. smalltalk.addMethod(
  3757. smalltalk.method({
  3758. selector: "at:put:",
  3759. protocol: 'accessing',
  3760. fn: function (anIndex,anObject){
  3761. var self=this;
  3762. return smalltalk.withContext(function($ctx1) {
  3763. self._errorReadOnly();
  3764. return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{anIndex:anIndex,anObject:anObject},smalltalk.CharacterArray)})},
  3765. args: ["anIndex", "anObject"],
  3766. source: "at: anIndex put: anObject\x0a\x09self errorReadOnly",
  3767. messageSends: ["errorReadOnly"],
  3768. referencedClasses: []
  3769. }),
  3770. smalltalk.CharacterArray);
  3771. smalltalk.addMethod(
  3772. smalltalk.method({
  3773. selector: "errorReadOnly",
  3774. protocol: 'error handling',
  3775. fn: function (){
  3776. var self=this;
  3777. return smalltalk.withContext(function($ctx1) {
  3778. self._error_("Object is read-only");
  3779. return self}, function($ctx1) {$ctx1.fill(self,"errorReadOnly",{},smalltalk.CharacterArray)})},
  3780. args: [],
  3781. source: "errorReadOnly\x0a\x09self error: 'Object is read-only'",
  3782. messageSends: ["error:"],
  3783. referencedClasses: []
  3784. }),
  3785. smalltalk.CharacterArray);
  3786. smalltalk.addMethod(
  3787. smalltalk.method({
  3788. selector: "printOn:",
  3789. protocol: 'printing',
  3790. fn: function (aStream){
  3791. var self=this;
  3792. return smalltalk.withContext(function($ctx1) {
  3793. _st(self._asString())._printOn_(aStream);
  3794. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.CharacterArray)})},
  3795. args: ["aStream"],
  3796. source: "printOn: aStream\x0a\x09self asString printOn: aStream",
  3797. messageSends: ["printOn:", "asString"],
  3798. referencedClasses: []
  3799. }),
  3800. smalltalk.CharacterArray);
  3801. smalltalk.addMethod(
  3802. smalltalk.method({
  3803. selector: "putOn:",
  3804. protocol: 'streaming',
  3805. fn: function (aStream){
  3806. var self=this;
  3807. return smalltalk.withContext(function($ctx1) {
  3808. _st(aStream)._nextPutString_(self);
  3809. return self}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},smalltalk.CharacterArray)})},
  3810. args: ["aStream"],
  3811. source: "putOn: aStream\x0a\x09aStream nextPutString: self",
  3812. messageSends: ["nextPutString:"],
  3813. referencedClasses: []
  3814. }),
  3815. smalltalk.CharacterArray);
  3816. smalltalk.addMethod(
  3817. smalltalk.method({
  3818. selector: "remove:",
  3819. protocol: 'adding/removing',
  3820. fn: function (anObject){
  3821. var self=this;
  3822. return smalltalk.withContext(function($ctx1) {
  3823. self._errorReadOnly();
  3824. return self}, function($ctx1) {$ctx1.fill(self,"remove:",{anObject:anObject},smalltalk.CharacterArray)})},
  3825. args: ["anObject"],
  3826. source: "remove: anObject\x0a\x09self errorReadOnly",
  3827. messageSends: ["errorReadOnly"],
  3828. referencedClasses: []
  3829. }),
  3830. smalltalk.CharacterArray);
  3831. smalltalk.addMethod(
  3832. smalltalk.method({
  3833. selector: "fromString:",
  3834. protocol: 'instance creation',
  3835. fn: function (aString){
  3836. var self=this;
  3837. return smalltalk.withContext(function($ctx1) {
  3838. self._subclassResponsibility();
  3839. return self}, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},smalltalk.CharacterArray.klass)})},
  3840. args: ["aString"],
  3841. source: "fromString: aString\x0a\x09self subclassResponsibility",
  3842. messageSends: ["subclassResponsibility"],
  3843. referencedClasses: []
  3844. }),
  3845. smalltalk.CharacterArray.klass);
  3846. smalltalk.addClass('String', smalltalk.CharacterArray, [], 'Kernel-Collections');
  3847. smalltalk.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 >> #,`";
  3848. smalltalk.addMethod(
  3849. smalltalk.method({
  3850. selector: ",",
  3851. protocol: 'copying',
  3852. fn: function (aString){
  3853. var self=this;
  3854. return smalltalk.withContext(function($ctx1) {
  3855. return String(self) + aString;
  3856. return self}, function($ctx1) {$ctx1.fill(self,",",{aString:aString},smalltalk.String)})},
  3857. args: ["aString"],
  3858. source: ", aString\x0a\x09<return String(self) + aString>",
  3859. messageSends: [],
  3860. referencedClasses: []
  3861. }),
  3862. smalltalk.String);
  3863. smalltalk.addMethod(
  3864. smalltalk.method({
  3865. selector: "<",
  3866. protocol: 'comparing',
  3867. fn: function (aString){
  3868. var self=this;
  3869. return smalltalk.withContext(function($ctx1) {
  3870. return String(self) < aString._asString();
  3871. return self}, function($ctx1) {$ctx1.fill(self,"<",{aString:aString},smalltalk.String)})},
  3872. args: ["aString"],
  3873. source: "< aString\x0a\x09<return String(self) < aString._asString()>",
  3874. messageSends: [],
  3875. referencedClasses: []
  3876. }),
  3877. smalltalk.String);
  3878. smalltalk.addMethod(
  3879. smalltalk.method({
  3880. selector: "<=",
  3881. protocol: 'comparing',
  3882. fn: function (aString){
  3883. var self=this;
  3884. return smalltalk.withContext(function($ctx1) {
  3885. return String(self) <= aString._asString();
  3886. return self}, function($ctx1) {$ctx1.fill(self,"<=",{aString:aString},smalltalk.String)})},
  3887. args: ["aString"],
  3888. source: "<= aString\x0a\x09<return String(self) <= aString._asString()>",
  3889. messageSends: [],
  3890. referencedClasses: []
  3891. }),
  3892. smalltalk.String);
  3893. smalltalk.addMethod(
  3894. smalltalk.method({
  3895. selector: "=",
  3896. protocol: 'comparing',
  3897. fn: function (aString){
  3898. var self=this;
  3899. return smalltalk.withContext(function($ctx1) {
  3900. return aString != null &&
  3901. typeof aString._isString === "function" &&
  3902. aString._isString() &&
  3903. String(self) === String(aString)
  3904. ;
  3905. return self}, function($ctx1) {$ctx1.fill(self,"=",{aString:aString},smalltalk.String)})},
  3906. args: ["aString"],
  3907. 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>",
  3908. messageSends: [],
  3909. referencedClasses: []
  3910. }),
  3911. smalltalk.String);
  3912. smalltalk.addMethod(
  3913. smalltalk.method({
  3914. selector: "==",
  3915. protocol: 'comparing',
  3916. fn: function (aString){
  3917. var self=this;
  3918. return smalltalk.withContext(function($ctx1) {
  3919. var $1;
  3920. $1=self.__eq(aString);
  3921. return $1;
  3922. }, function($ctx1) {$ctx1.fill(self,"==",{aString:aString},smalltalk.String)})},
  3923. args: ["aString"],
  3924. source: "== aString\x0a\x09^ self = aString",
  3925. messageSends: ["="],
  3926. referencedClasses: []
  3927. }),
  3928. smalltalk.String);
  3929. smalltalk.addMethod(
  3930. smalltalk.method({
  3931. selector: ">",
  3932. protocol: 'comparing',
  3933. fn: function (aString){
  3934. var self=this;
  3935. return smalltalk.withContext(function($ctx1) {
  3936. return String(self) > aString._asString();
  3937. return self}, function($ctx1) {$ctx1.fill(self,">",{aString:aString},smalltalk.String)})},
  3938. args: ["aString"],
  3939. source: "> aString\x0a\x09<return String(self) >> aString._asString()>",
  3940. messageSends: [],
  3941. referencedClasses: []
  3942. }),
  3943. smalltalk.String);
  3944. smalltalk.addMethod(
  3945. smalltalk.method({
  3946. selector: ">=",
  3947. protocol: 'comparing',
  3948. fn: function (aString){
  3949. var self=this;
  3950. return smalltalk.withContext(function($ctx1) {
  3951. return String(self) >= aString._asString();
  3952. return self}, function($ctx1) {$ctx1.fill(self,">=",{aString:aString},smalltalk.String)})},
  3953. args: ["aString"],
  3954. source: ">= aString\x0a\x09<return String(self) >>= aString._asString()>",
  3955. messageSends: [],
  3956. referencedClasses: []
  3957. }),
  3958. smalltalk.String);
  3959. smalltalk.addMethod(
  3960. smalltalk.method({
  3961. selector: "asJSON",
  3962. protocol: 'converting',
  3963. fn: function (){
  3964. var self=this;
  3965. return smalltalk.withContext(function($ctx1) {
  3966. return self;
  3967. }, function($ctx1) {$ctx1.fill(self,"asJSON",{},smalltalk.String)})},
  3968. args: [],
  3969. source: "asJSON\x0a\x09^ self",
  3970. messageSends: [],
  3971. referencedClasses: []
  3972. }),
  3973. smalltalk.String);
  3974. smalltalk.addMethod(
  3975. smalltalk.method({
  3976. selector: "asJavascript",
  3977. protocol: 'converting',
  3978. fn: function (){
  3979. var self=this;
  3980. return smalltalk.withContext(function($ctx1) {
  3981. if(self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1)
  3982. return "\"" + self.replace(/[\x00-\x1f"\\\x7f-\x9f]/g, function(ch){var c=ch.charCodeAt(0);return "\\x"+("0"+c.toString(16)).slice(-2)}) + "\"";
  3983. else
  3984. return "\"" + self + "\"";
  3985. ;
  3986. return self}, function($ctx1) {$ctx1.fill(self,"asJavascript",{},smalltalk.String)})},
  3987. args: [],
  3988. 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>",
  3989. messageSends: [],
  3990. referencedClasses: []
  3991. }),
  3992. smalltalk.String);
  3993. smalltalk.addMethod(
  3994. smalltalk.method({
  3995. selector: "asLowercase",
  3996. protocol: 'converting',
  3997. fn: function (){
  3998. var self=this;
  3999. return smalltalk.withContext(function($ctx1) {
  4000. return self.toLowerCase();
  4001. return self}, function($ctx1) {$ctx1.fill(self,"asLowercase",{},smalltalk.String)})},
  4002. args: [],
  4003. source: "asLowercase\x0a\x09<return self.toLowerCase()>",
  4004. messageSends: [],
  4005. referencedClasses: []
  4006. }),
  4007. smalltalk.String);
  4008. smalltalk.addMethod(
  4009. smalltalk.method({
  4010. selector: "asMutator",
  4011. protocol: 'converting',
  4012. fn: function (){
  4013. var self=this;
  4014. return smalltalk.withContext(function($ctx1) {
  4015. var $1,$2;
  4016. $1=_st(self._last()).__eq(":");
  4017. if(! smalltalk.assert($1)){
  4018. $2=self.__comma(":");
  4019. return $2;
  4020. };
  4021. return self;
  4022. }, function($ctx1) {$ctx1.fill(self,"asMutator",{},smalltalk.String)})},
  4023. args: [],
  4024. 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",
  4025. messageSends: ["ifFalse:", "=", "last", ","],
  4026. referencedClasses: []
  4027. }),
  4028. smalltalk.String);
  4029. smalltalk.addMethod(
  4030. smalltalk.method({
  4031. selector: "asNumber",
  4032. protocol: 'converting',
  4033. fn: function (){
  4034. var self=this;
  4035. return smalltalk.withContext(function($ctx1) {
  4036. return Number(self);
  4037. return self}, function($ctx1) {$ctx1.fill(self,"asNumber",{},smalltalk.String)})},
  4038. args: [],
  4039. source: "asNumber\x0a\x09<return Number(self)>",
  4040. messageSends: [],
  4041. referencedClasses: []
  4042. }),
  4043. smalltalk.String);
  4044. smalltalk.addMethod(
  4045. smalltalk.method({
  4046. selector: "asRegexp",
  4047. protocol: 'converting',
  4048. fn: function (){
  4049. var self=this;
  4050. function $RegularExpression(){return smalltalk.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
  4051. return smalltalk.withContext(function($ctx1) {
  4052. var $1;
  4053. $1=_st($RegularExpression())._fromString_(self);
  4054. return $1;
  4055. }, function($ctx1) {$ctx1.fill(self,"asRegexp",{},smalltalk.String)})},
  4056. args: [],
  4057. source: "asRegexp\x0a\x09^ RegularExpression fromString: self",
  4058. messageSends: ["fromString:"],
  4059. referencedClasses: ["RegularExpression"]
  4060. }),
  4061. smalltalk.String);
  4062. smalltalk.addMethod(
  4063. smalltalk.method({
  4064. selector: "asSelector",
  4065. protocol: 'converting',
  4066. fn: function (){
  4067. var self=this;
  4068. return smalltalk.withContext(function($ctx1) {
  4069. return smalltalk.selector(self);
  4070. return self}, function($ctx1) {$ctx1.fill(self,"asSelector",{},smalltalk.String)})},
  4071. args: [],
  4072. source: "asSelector\x0a\x09<return smalltalk.selector(self)>",
  4073. messageSends: [],
  4074. referencedClasses: []
  4075. }),
  4076. smalltalk.String);
  4077. smalltalk.addMethod(
  4078. smalltalk.method({
  4079. selector: "asString",
  4080. protocol: 'converting',
  4081. fn: function (){
  4082. var self=this;
  4083. return smalltalk.withContext(function($ctx1) {
  4084. return self;
  4085. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.String)})},
  4086. args: [],
  4087. source: "asString\x0a\x09^ self",
  4088. messageSends: [],
  4089. referencedClasses: []
  4090. }),
  4091. smalltalk.String);
  4092. smalltalk.addMethod(
  4093. smalltalk.method({
  4094. selector: "asSymbol",
  4095. protocol: 'converting',
  4096. fn: function (){
  4097. var self=this;
  4098. return smalltalk.withContext(function($ctx1) {
  4099. return self;
  4100. }, function($ctx1) {$ctx1.fill(self,"asSymbol",{},smalltalk.String)})},
  4101. args: [],
  4102. source: "asSymbol\x0a\x09^ self",
  4103. messageSends: [],
  4104. referencedClasses: []
  4105. }),
  4106. smalltalk.String);
  4107. smalltalk.addMethod(
  4108. smalltalk.method({
  4109. selector: "asUppercase",
  4110. protocol: 'converting',
  4111. fn: function (){
  4112. var self=this;
  4113. return smalltalk.withContext(function($ctx1) {
  4114. return self.toUpperCase();
  4115. return self}, function($ctx1) {$ctx1.fill(self,"asUppercase",{},smalltalk.String)})},
  4116. args: [],
  4117. source: "asUppercase\x0a\x09<return self.toUpperCase()>",
  4118. messageSends: [],
  4119. referencedClasses: []
  4120. }),
  4121. smalltalk.String);
  4122. smalltalk.addMethod(
  4123. smalltalk.method({
  4124. selector: "asciiValue",
  4125. protocol: 'accessing',
  4126. fn: function (){
  4127. var self=this;
  4128. return smalltalk.withContext(function($ctx1) {
  4129. return self.charCodeAt(0);;
  4130. return self}, function($ctx1) {$ctx1.fill(self,"asciiValue",{},smalltalk.String)})},
  4131. args: [],
  4132. source: "asciiValue\x0a\x09<return self.charCodeAt(0);>",
  4133. messageSends: [],
  4134. referencedClasses: []
  4135. }),
  4136. smalltalk.String);
  4137. smalltalk.addMethod(
  4138. smalltalk.method({
  4139. selector: "at:ifAbsent:",
  4140. protocol: 'accessing',
  4141. fn: function (anIndex,aBlock){
  4142. var self=this;
  4143. return smalltalk.withContext(function($ctx1) {
  4144. return String(self)[anIndex - 1] || aBlock._value();
  4145. return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{anIndex:anIndex,aBlock:aBlock},smalltalk.String)})},
  4146. args: ["anIndex", "aBlock"],
  4147. source: "at: anIndex ifAbsent: aBlock\x0a\x09<return String(self)[anIndex - 1] || aBlock._value()>",
  4148. messageSends: [],
  4149. referencedClasses: []
  4150. }),
  4151. smalltalk.String);
  4152. smalltalk.addMethod(
  4153. smalltalk.method({
  4154. selector: "at:ifPresent:ifAbsent:",
  4155. protocol: 'accessing',
  4156. fn: function (anIndex,aBlock,anotherBlock){
  4157. var self=this;
  4158. return smalltalk.withContext(function($ctx1) {
  4159. var result = String(self)[anIndex - 1];
  4160. return result ? aBlock._value_(result) : anotherBlock._value();
  4161. ;
  4162. return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{anIndex:anIndex,aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.String)})},
  4163. args: ["anIndex", "aBlock", "anotherBlock"],
  4164. 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>",
  4165. messageSends: [],
  4166. referencedClasses: []
  4167. }),
  4168. smalltalk.String);
  4169. smalltalk.addMethod(
  4170. smalltalk.method({
  4171. selector: "capitalized",
  4172. protocol: 'converting',
  4173. fn: function (){
  4174. var self=this;
  4175. return smalltalk.withContext(function($ctx1) {
  4176. var $2,$1;
  4177. $2=self._isEmpty();
  4178. if(smalltalk.assert($2)){
  4179. $1=self;
  4180. } else {
  4181. $1=_st(_st(self._first())._asUppercase()).__comma(self._allButFirst());
  4182. };
  4183. return $1;
  4184. }, function($ctx1) {$ctx1.fill(self,"capitalized",{},smalltalk.String)})},
  4185. args: [],
  4186. source: "capitalized\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self first asUppercase, self allButFirst ]",
  4187. messageSends: ["ifTrue:ifFalse:", "isEmpty", ",", "asUppercase", "first", "allButFirst"],
  4188. referencedClasses: []
  4189. }),
  4190. smalltalk.String);
  4191. smalltalk.addMethod(
  4192. smalltalk.method({
  4193. selector: "charCodeAt:",
  4194. protocol: 'accessing',
  4195. fn: function (anInteger){
  4196. var self=this;
  4197. return smalltalk.withContext(function($ctx1) {
  4198. return self.charCodeAt(anInteger - 1);
  4199. return self}, function($ctx1) {$ctx1.fill(self,"charCodeAt:",{anInteger:anInteger},smalltalk.String)})},
  4200. args: ["anInteger"],
  4201. source: "charCodeAt: anInteger\x0a\x09<return self.charCodeAt(anInteger - 1)>",
  4202. messageSends: [],
  4203. referencedClasses: []
  4204. }),
  4205. smalltalk.String);
  4206. smalltalk.addMethod(
  4207. smalltalk.method({
  4208. selector: "copyFrom:to:",
  4209. protocol: 'copying',
  4210. fn: function (anIndex,anotherIndex){
  4211. var self=this;
  4212. return smalltalk.withContext(function($ctx1) {
  4213. return self.substring(anIndex - 1, anotherIndex);
  4214. return self}, function($ctx1) {$ctx1.fill(self,"copyFrom:to:",{anIndex:anIndex,anotherIndex:anotherIndex},smalltalk.String)})},
  4215. args: ["anIndex", "anotherIndex"],
  4216. source: "copyFrom: anIndex to: anotherIndex\x0a\x09<return self.substring(anIndex - 1, anotherIndex)>",
  4217. messageSends: [],
  4218. referencedClasses: []
  4219. }),
  4220. smalltalk.String);
  4221. smalltalk.addMethod(
  4222. smalltalk.method({
  4223. selector: "crlfSanitized",
  4224. protocol: 'converting',
  4225. fn: function (){
  4226. var self=this;
  4227. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  4228. return smalltalk.withContext(function($ctx1) {
  4229. var $1;
  4230. $1=_st(self._lines())._join_(_st($String())._lf());
  4231. return $1;
  4232. }, function($ctx1) {$ctx1.fill(self,"crlfSanitized",{},smalltalk.String)})},
  4233. args: [],
  4234. source: "crlfSanitized\x0a\x09^ self lines join: String lf",
  4235. messageSends: ["join:", "lines", "lf"],
  4236. referencedClasses: ["String"]
  4237. }),
  4238. smalltalk.String);
  4239. smalltalk.addMethod(
  4240. smalltalk.method({
  4241. selector: "deepCopy",
  4242. protocol: 'copying',
  4243. fn: function (){
  4244. var self=this;
  4245. return smalltalk.withContext(function($ctx1) {
  4246. var $1;
  4247. $1=self._shallowCopy();
  4248. return $1;
  4249. }, function($ctx1) {$ctx1.fill(self,"deepCopy",{},smalltalk.String)})},
  4250. args: [],
  4251. source: "deepCopy\x0a\x09^ self shallowCopy",
  4252. messageSends: ["shallowCopy"],
  4253. referencedClasses: []
  4254. }),
  4255. smalltalk.String);
  4256. smalltalk.addMethod(
  4257. smalltalk.method({
  4258. selector: "escaped",
  4259. protocol: 'converting',
  4260. fn: function (){
  4261. var self=this;
  4262. return smalltalk.withContext(function($ctx1) {
  4263. return escape(self);
  4264. return self}, function($ctx1) {$ctx1.fill(self,"escaped",{},smalltalk.String)})},
  4265. args: [],
  4266. source: "escaped\x0a\x09<return escape(self)>",
  4267. messageSends: [],
  4268. referencedClasses: []
  4269. }),
  4270. smalltalk.String);
  4271. smalltalk.addMethod(
  4272. smalltalk.method({
  4273. selector: "identityHash",
  4274. protocol: 'accessing',
  4275. fn: function (){
  4276. var self=this;
  4277. return smalltalk.withContext(function($ctx1) {
  4278. var $1;
  4279. $1=self.__comma("s");
  4280. return $1;
  4281. }, function($ctx1) {$ctx1.fill(self,"identityHash",{},smalltalk.String)})},
  4282. args: [],
  4283. source: "identityHash\x0a\x09^ self, 's'",
  4284. messageSends: [","],
  4285. referencedClasses: []
  4286. }),
  4287. smalltalk.String);
  4288. smalltalk.addMethod(
  4289. smalltalk.method({
  4290. selector: "includesSubString:",
  4291. protocol: 'testing',
  4292. fn: function (subString){
  4293. var self=this;
  4294. return smalltalk.withContext(function($ctx1) {
  4295. return self.indexOf(subString) != -1;
  4296. return self}, function($ctx1) {$ctx1.fill(self,"includesSubString:",{subString:subString},smalltalk.String)})},
  4297. args: ["subString"],
  4298. source: "includesSubString: subString\x0a\x09<return self.indexOf(subString) != -1>",
  4299. messageSends: [],
  4300. referencedClasses: []
  4301. }),
  4302. smalltalk.String);
  4303. smalltalk.addMethod(
  4304. smalltalk.method({
  4305. selector: "isCapitalized",
  4306. protocol: 'testing',
  4307. fn: function (){
  4308. var self=this;
  4309. return smalltalk.withContext(function($ctx1) {
  4310. var $3,$2,$1;
  4311. $3=self._first();
  4312. $ctx1.sendIdx["first"]=1;
  4313. $2=_st($3)._asUppercase();
  4314. $1=_st($2).__eq_eq(self._first());
  4315. return $1;
  4316. }, function($ctx1) {$ctx1.fill(self,"isCapitalized",{},smalltalk.String)})},
  4317. args: [],
  4318. source: "isCapitalized\x0a\x09^ self first asUppercase == self first",
  4319. messageSends: ["==", "asUppercase", "first"],
  4320. referencedClasses: []
  4321. }),
  4322. smalltalk.String);
  4323. smalltalk.addMethod(
  4324. smalltalk.method({
  4325. selector: "isImmutable",
  4326. protocol: 'testing',
  4327. fn: function (){
  4328. var self=this;
  4329. return smalltalk.withContext(function($ctx1) {
  4330. return true;
  4331. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},smalltalk.String)})},
  4332. args: [],
  4333. source: "isImmutable\x0a\x09^ true",
  4334. messageSends: [],
  4335. referencedClasses: []
  4336. }),
  4337. smalltalk.String);
  4338. smalltalk.addMethod(
  4339. smalltalk.method({
  4340. selector: "isString",
  4341. protocol: 'testing',
  4342. fn: function (){
  4343. var self=this;
  4344. return smalltalk.withContext(function($ctx1) {
  4345. return true;
  4346. }, function($ctx1) {$ctx1.fill(self,"isString",{},smalltalk.String)})},
  4347. args: [],
  4348. source: "isString\x0a\x09^ true",
  4349. messageSends: [],
  4350. referencedClasses: []
  4351. }),
  4352. smalltalk.String);
  4353. smalltalk.addMethod(
  4354. smalltalk.method({
  4355. selector: "isVowel",
  4356. protocol: 'testing',
  4357. fn: function (){
  4358. var self=this;
  4359. return smalltalk.withContext(function($ctx1) {
  4360. var $1;
  4361. $1=_st(_st(self._size()).__eq((1)))._and_((function(){
  4362. return smalltalk.withContext(function($ctx2) {
  4363. return "aeiou"._includes_(self._asLowercase());
  4364. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  4365. return $1;
  4366. }, function($ctx1) {$ctx1.fill(self,"isVowel",{},smalltalk.String)})},
  4367. args: [],
  4368. 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 ]",
  4369. messageSends: ["and:", "=", "size", "includes:", "asLowercase"],
  4370. referencedClasses: []
  4371. }),
  4372. smalltalk.String);
  4373. smalltalk.addMethod(
  4374. smalltalk.method({
  4375. selector: "join:",
  4376. protocol: 'split join',
  4377. fn: function (aCollection){
  4378. var self=this;
  4379. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  4380. return smalltalk.withContext(function($ctx1) {
  4381. var $1;
  4382. $1=_st($String())._streamContents_((function(stream){
  4383. return smalltalk.withContext(function($ctx2) {
  4384. return _st(aCollection)._do_separatedBy_((function(each){
  4385. return smalltalk.withContext(function($ctx3) {
  4386. return _st(stream)._nextPutAll_(_st(each)._asString());
  4387. $ctx3.sendIdx["nextPutAll:"]=1;
  4388. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
  4389. return smalltalk.withContext(function($ctx3) {
  4390. return _st(stream)._nextPutAll_(self);
  4391. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  4392. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
  4393. return $1;
  4394. }, function($ctx1) {$ctx1.fill(self,"join:",{aCollection:aCollection},smalltalk.String)})},
  4395. args: ["aCollection"],
  4396. 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 ]]",
  4397. messageSends: ["streamContents:", "do:separatedBy:", "nextPutAll:", "asString"],
  4398. referencedClasses: ["String"]
  4399. }),
  4400. smalltalk.String);
  4401. smalltalk.addMethod(
  4402. smalltalk.method({
  4403. selector: "lineIndicesDo:",
  4404. protocol: 'split join',
  4405. fn: function (aBlock){
  4406. var self=this;
  4407. var cr,lf,start,sz,nextLF,nextCR;
  4408. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  4409. return smalltalk.withContext(function($ctx1) {
  4410. var $2,$1,$4,$5,$3,$6,$7,$9,$8,$10,$11;
  4411. var $early={};
  4412. try {
  4413. start=(1);
  4414. sz=self._size();
  4415. cr=_st($String())._cr();
  4416. nextCR=self._indexOf_startingAt_(cr,(1));
  4417. $ctx1.sendIdx["indexOf:startingAt:"]=1;
  4418. lf=_st($String())._lf();
  4419. nextLF=self._indexOf_startingAt_(lf,(1));
  4420. $ctx1.sendIdx["indexOf:startingAt:"]=2;
  4421. _st((function(){
  4422. return smalltalk.withContext(function($ctx2) {
  4423. return _st(start).__lt_eq(sz);
  4424. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue_((function(){
  4425. return smalltalk.withContext(function($ctx2) {
  4426. $2=_st(nextLF).__eq((0));
  4427. $ctx2.sendIdx["="]=1;
  4428. $1=_st($2)._and_((function(){
  4429. return smalltalk.withContext(function($ctx3) {
  4430. return _st(nextCR).__eq((0));
  4431. $ctx3.sendIdx["="]=2;
  4432. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  4433. $ctx2.sendIdx["and:"]=1;
  4434. if(smalltalk.assert($1)){
  4435. _st(aBlock)._value_value_value_(start,sz,sz);
  4436. $ctx2.sendIdx["value:value:value:"]=1;
  4437. throw $early=[self];
  4438. };
  4439. $4=_st(nextCR).__eq((0));
  4440. $ctx2.sendIdx["="]=3;
  4441. $3=_st($4)._or_((function(){
  4442. return smalltalk.withContext(function($ctx3) {
  4443. $5=(0).__lt(nextLF);
  4444. $ctx3.sendIdx["<"]=1;
  4445. return _st($5)._and_((function(){
  4446. return smalltalk.withContext(function($ctx4) {
  4447. return _st(nextLF).__lt(nextCR);
  4448. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)})}));
  4449. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
  4450. if(smalltalk.assert($3)){
  4451. $6=start;
  4452. $7=_st(nextLF).__minus((1));
  4453. $ctx2.sendIdx["-"]=1;
  4454. _st(aBlock)._value_value_value_($6,$7,nextLF);
  4455. $ctx2.sendIdx["value:value:value:"]=2;
  4456. start=(1).__plus(nextLF);
  4457. $ctx2.sendIdx["+"]=1;
  4458. start;
  4459. nextLF=self._indexOf_startingAt_(lf,start);
  4460. $ctx2.sendIdx["indexOf:startingAt:"]=3;
  4461. return nextLF;
  4462. } else {
  4463. $9=(1).__plus(nextCR);
  4464. $ctx2.sendIdx["+"]=2;
  4465. $8=_st($9).__eq(nextLF);
  4466. if(smalltalk.assert($8)){
  4467. $10=start;
  4468. $11=_st(nextCR).__minus((1));
  4469. $ctx2.sendIdx["-"]=2;
  4470. _st(aBlock)._value_value_value_($10,$11,nextLF);
  4471. $ctx2.sendIdx["value:value:value:"]=3;
  4472. start=(1).__plus(nextLF);
  4473. $ctx2.sendIdx["+"]=3;
  4474. start;
  4475. nextCR=self._indexOf_startingAt_(cr,start);
  4476. $ctx2.sendIdx["indexOf:startingAt:"]=4;
  4477. nextCR;
  4478. nextLF=self._indexOf_startingAt_(lf,start);
  4479. $ctx2.sendIdx["indexOf:startingAt:"]=5;
  4480. return nextLF;
  4481. } else {
  4482. _st(aBlock)._value_value_value_(start,_st(nextCR).__minus((1)),nextCR);
  4483. start=(1).__plus(nextCR);
  4484. start;
  4485. nextCR=self._indexOf_startingAt_(cr,start);
  4486. return nextCR;
  4487. };
  4488. };
  4489. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  4490. return self}
  4491. catch(e) {if(e===$early)return e[0]; throw e}
  4492. }, function($ctx1) {$ctx1.fill(self,"lineIndicesDo:",{aBlock:aBlock,cr:cr,lf:lf,start:start,sz:sz,nextLF:nextLF,nextCR:nextCR},smalltalk.String)})},
  4493. args: ["aBlock"],
  4494. 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 ] ]]",
  4495. messageSends: ["size", "cr", "indexOf:startingAt:", "lf", "whileTrue:", "<=", "ifTrue:", "and:", "=", "value:value:value:", "ifTrue:ifFalse:", "or:", "<", "-", "+"],
  4496. referencedClasses: ["String"]
  4497. }),
  4498. smalltalk.String);
  4499. smalltalk.addMethod(
  4500. smalltalk.method({
  4501. selector: "lineNumber:",
  4502. protocol: 'split join',
  4503. fn: function (anIndex){
  4504. var self=this;
  4505. var lineCount;
  4506. return smalltalk.withContext(function($ctx1) {
  4507. var $2,$1,$3;
  4508. var $early={};
  4509. try {
  4510. lineCount=(0);
  4511. self._lineIndicesDo_((function(start,endWithoutDelimiters,end){
  4512. return smalltalk.withContext(function($ctx2) {
  4513. lineCount=_st(lineCount).__plus((1));
  4514. $2=lineCount;
  4515. $1=_st($2).__eq(anIndex);
  4516. if(smalltalk.assert($1)){
  4517. $3=self._copyFrom_to_(start,endWithoutDelimiters);
  4518. throw $early=[$3];
  4519. };
  4520. }, function($ctx2) {$ctx2.fillBlock({start:start,endWithoutDelimiters:endWithoutDelimiters,end:end},$ctx1,1)})}));
  4521. return nil;
  4522. }
  4523. catch(e) {if(e===$early)return e[0]; throw e}
  4524. }, function($ctx1) {$ctx1.fill(self,"lineNumber:",{anIndex:anIndex,lineCount:lineCount},smalltalk.String)})},
  4525. args: ["anIndex"],
  4526. 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",
  4527. messageSends: ["lineIndicesDo:", "ifTrue:", "=", "+", "copyFrom:to:"],
  4528. referencedClasses: []
  4529. }),
  4530. smalltalk.String);
  4531. smalltalk.addMethod(
  4532. smalltalk.method({
  4533. selector: "lines",
  4534. protocol: 'split join',
  4535. fn: function (){
  4536. var self=this;
  4537. var lines;
  4538. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  4539. return smalltalk.withContext(function($ctx1) {
  4540. var $1;
  4541. lines=_st($Array())._new();
  4542. self._linesDo_((function(aLine){
  4543. return smalltalk.withContext(function($ctx2) {
  4544. return _st(lines)._add_(aLine);
  4545. }, function($ctx2) {$ctx2.fillBlock({aLine:aLine},$ctx1,1)})}));
  4546. $1=lines;
  4547. return $1;
  4548. }, function($ctx1) {$ctx1.fill(self,"lines",{lines:lines},smalltalk.String)})},
  4549. args: [],
  4550. 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",
  4551. messageSends: ["new", "linesDo:", "add:"],
  4552. referencedClasses: ["Array"]
  4553. }),
  4554. smalltalk.String);
  4555. smalltalk.addMethod(
  4556. smalltalk.method({
  4557. selector: "linesDo:",
  4558. protocol: 'split join',
  4559. fn: function (aBlock){
  4560. var self=this;
  4561. return smalltalk.withContext(function($ctx1) {
  4562. self._lineIndicesDo_((function(start,endWithoutDelimiters,end){
  4563. return smalltalk.withContext(function($ctx2) {
  4564. return _st(aBlock)._value_(self._copyFrom_to_(start,endWithoutDelimiters));
  4565. }, function($ctx2) {$ctx2.fillBlock({start:start,endWithoutDelimiters:endWithoutDelimiters,end:end},$ctx1,1)})}));
  4566. return self}, function($ctx1) {$ctx1.fill(self,"linesDo:",{aBlock:aBlock},smalltalk.String)})},
  4567. args: ["aBlock"],
  4568. 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) ]",
  4569. messageSends: ["lineIndicesDo:", "value:", "copyFrom:to:"],
  4570. referencedClasses: []
  4571. }),
  4572. smalltalk.String);
  4573. smalltalk.addMethod(
  4574. smalltalk.method({
  4575. selector: "match:",
  4576. protocol: 'regular expressions',
  4577. fn: function (aRegexp){
  4578. var self=this;
  4579. return smalltalk.withContext(function($ctx1) {
  4580. return self.search(aRegexp) != -1;
  4581. return self}, function($ctx1) {$ctx1.fill(self,"match:",{aRegexp:aRegexp},smalltalk.String)})},
  4582. args: ["aRegexp"],
  4583. source: "match: aRegexp\x0a\x09<return self.search(aRegexp) != -1>",
  4584. messageSends: [],
  4585. referencedClasses: []
  4586. }),
  4587. smalltalk.String);
  4588. smalltalk.addMethod(
  4589. smalltalk.method({
  4590. selector: "matchesOf:",
  4591. protocol: 'regular expressions',
  4592. fn: function (aRegularExpression){
  4593. var self=this;
  4594. return smalltalk.withContext(function($ctx1) {
  4595. return self.match(aRegularExpression);
  4596. return self}, function($ctx1) {$ctx1.fill(self,"matchesOf:",{aRegularExpression:aRegularExpression},smalltalk.String)})},
  4597. args: ["aRegularExpression"],
  4598. source: "matchesOf: aRegularExpression\x0a\x09<return self.match(aRegularExpression)>",
  4599. messageSends: [],
  4600. referencedClasses: []
  4601. }),
  4602. smalltalk.String);
  4603. smalltalk.addMethod(
  4604. smalltalk.method({
  4605. selector: "numericallyIndexable",
  4606. protocol: 'private',
  4607. fn: function (){
  4608. var self=this;
  4609. return smalltalk.withContext(function($ctx1) {
  4610. return String(self);
  4611. return self}, function($ctx1) {$ctx1.fill(self,"numericallyIndexable",{},smalltalk.String)})},
  4612. args: [],
  4613. source: "numericallyIndexable\x0a\x09<return String(self)>",
  4614. messageSends: [],
  4615. referencedClasses: []
  4616. }),
  4617. smalltalk.String);
  4618. smalltalk.addMethod(
  4619. smalltalk.method({
  4620. selector: "printNl",
  4621. protocol: 'printing',
  4622. fn: function (){
  4623. var self=this;
  4624. return smalltalk.withContext(function($ctx1) {
  4625. console.log(self);
  4626. return self}, function($ctx1) {$ctx1.fill(self,"printNl",{},smalltalk.String)})},
  4627. args: [],
  4628. source: "printNl\x0a\x09<console.log(self)>",
  4629. messageSends: [],
  4630. referencedClasses: []
  4631. }),
  4632. smalltalk.String);
  4633. smalltalk.addMethod(
  4634. smalltalk.method({
  4635. selector: "printOn:",
  4636. protocol: 'printing',
  4637. fn: function (aStream){
  4638. var self=this;
  4639. return smalltalk.withContext(function($ctx1) {
  4640. var $1;
  4641. _st(aStream)._nextPutAll_("'");
  4642. $ctx1.sendIdx["nextPutAll:"]=1;
  4643. _st(aStream)._nextPutAll_(self);
  4644. $ctx1.sendIdx["nextPutAll:"]=2;
  4645. $1=_st(aStream)._nextPutAll_("'");
  4646. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.String)})},
  4647. args: ["aStream"],
  4648. source: "printOn: aStream\x0a\x09aStream \x0a\x09\x09nextPutAll: '''';\x0a\x09\x09nextPutAll: self;\x0a\x09\x09nextPutAll: ''''",
  4649. messageSends: ["nextPutAll:"],
  4650. referencedClasses: []
  4651. }),
  4652. smalltalk.String);
  4653. smalltalk.addMethod(
  4654. smalltalk.method({
  4655. selector: "replace:with:",
  4656. protocol: 'regular expressions',
  4657. fn: function (aString,anotherString){
  4658. var self=this;
  4659. function $RegularExpression(){return smalltalk.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
  4660. return smalltalk.withContext(function($ctx1) {
  4661. var $1;
  4662. $1=self._replaceRegexp_with_(_st($RegularExpression())._fromString_flag_(aString,"g"),anotherString);
  4663. return $1;
  4664. }, function($ctx1) {$ctx1.fill(self,"replace:with:",{aString:aString,anotherString:anotherString},smalltalk.String)})},
  4665. args: ["aString", "anotherString"],
  4666. source: "replace: aString with: anotherString\x0a\x09^ self replaceRegexp: (RegularExpression fromString: aString flag: 'g') with: anotherString",
  4667. messageSends: ["replaceRegexp:with:", "fromString:flag:"],
  4668. referencedClasses: ["RegularExpression"]
  4669. }),
  4670. smalltalk.String);
  4671. smalltalk.addMethod(
  4672. smalltalk.method({
  4673. selector: "replaceRegexp:with:",
  4674. protocol: 'regular expressions',
  4675. fn: function (aRegexp,aString){
  4676. var self=this;
  4677. return smalltalk.withContext(function($ctx1) {
  4678. return self.replace(aRegexp, aString);
  4679. return self}, function($ctx1) {$ctx1.fill(self,"replaceRegexp:with:",{aRegexp:aRegexp,aString:aString},smalltalk.String)})},
  4680. args: ["aRegexp", "aString"],
  4681. source: "replaceRegexp: aRegexp with: aString\x0a\x09<return self.replace(aRegexp, aString)>",
  4682. messageSends: [],
  4683. referencedClasses: []
  4684. }),
  4685. smalltalk.String);
  4686. smalltalk.addMethod(
  4687. smalltalk.method({
  4688. selector: "reversed",
  4689. protocol: 'converting',
  4690. fn: function (){
  4691. var self=this;
  4692. return smalltalk.withContext(function($ctx1) {
  4693. return self.split("").reverse().join("");
  4694. return self}, function($ctx1) {$ctx1.fill(self,"reversed",{},smalltalk.String)})},
  4695. args: [],
  4696. source: "reversed\x0a\x09<return self.split(\x22\x22).reverse().join(\x22\x22)>",
  4697. messageSends: [],
  4698. referencedClasses: []
  4699. }),
  4700. smalltalk.String);
  4701. smalltalk.addMethod(
  4702. smalltalk.method({
  4703. selector: "shallowCopy",
  4704. protocol: 'copying',
  4705. fn: function (){
  4706. var self=this;
  4707. return smalltalk.withContext(function($ctx1) {
  4708. var $1;
  4709. $1=_st(self._class())._fromString_(self);
  4710. return $1;
  4711. }, function($ctx1) {$ctx1.fill(self,"shallowCopy",{},smalltalk.String)})},
  4712. args: [],
  4713. source: "shallowCopy\x0a\x09^ self class fromString: self",
  4714. messageSends: ["fromString:", "class"],
  4715. referencedClasses: []
  4716. }),
  4717. smalltalk.String);
  4718. smalltalk.addMethod(
  4719. smalltalk.method({
  4720. selector: "size",
  4721. protocol: 'accessing',
  4722. fn: function (){
  4723. var self=this;
  4724. return smalltalk.withContext(function($ctx1) {
  4725. return self.length;
  4726. return self}, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.String)})},
  4727. args: [],
  4728. source: "size\x0a\x09<return self.length>",
  4729. messageSends: [],
  4730. referencedClasses: []
  4731. }),
  4732. smalltalk.String);
  4733. smalltalk.addMethod(
  4734. smalltalk.method({
  4735. selector: "subStrings:",
  4736. protocol: 'split join',
  4737. fn: function (aString){
  4738. var self=this;
  4739. return smalltalk.withContext(function($ctx1) {
  4740. var $1;
  4741. $1=self._tokenize_(aString);
  4742. return $1;
  4743. }, function($ctx1) {$ctx1.fill(self,"subStrings:",{aString:aString},smalltalk.String)})},
  4744. args: ["aString"],
  4745. source: "subStrings: aString\x0a\x09^ self tokenize: aString",
  4746. messageSends: ["tokenize:"],
  4747. referencedClasses: []
  4748. }),
  4749. smalltalk.String);
  4750. smalltalk.addMethod(
  4751. smalltalk.method({
  4752. selector: "tokenize:",
  4753. protocol: 'split join',
  4754. fn: function (aString){
  4755. var self=this;
  4756. return smalltalk.withContext(function($ctx1) {
  4757. return self.split(aString);
  4758. return self}, function($ctx1) {$ctx1.fill(self,"tokenize:",{aString:aString},smalltalk.String)})},
  4759. args: ["aString"],
  4760. source: "tokenize: aString\x0a\x09<return self.split(aString)>",
  4761. messageSends: [],
  4762. referencedClasses: []
  4763. }),
  4764. smalltalk.String);
  4765. smalltalk.addMethod(
  4766. smalltalk.method({
  4767. selector: "trimBoth",
  4768. protocol: 'regular expressions',
  4769. fn: function (){
  4770. var self=this;
  4771. return smalltalk.withContext(function($ctx1) {
  4772. var $1;
  4773. $1=self._trimBoth_("\x5cs");
  4774. return $1;
  4775. }, function($ctx1) {$ctx1.fill(self,"trimBoth",{},smalltalk.String)})},
  4776. args: [],
  4777. source: "trimBoth\x0a\x09^ self trimBoth: '\x5cs'",
  4778. messageSends: ["trimBoth:"],
  4779. referencedClasses: []
  4780. }),
  4781. smalltalk.String);
  4782. smalltalk.addMethod(
  4783. smalltalk.method({
  4784. selector: "trimBoth:",
  4785. protocol: 'regular expressions',
  4786. fn: function (separators){
  4787. var self=this;
  4788. return smalltalk.withContext(function($ctx1) {
  4789. var $1;
  4790. $1=_st(self._trimLeft_(separators))._trimRight_(separators);
  4791. return $1;
  4792. }, function($ctx1) {$ctx1.fill(self,"trimBoth:",{separators:separators},smalltalk.String)})},
  4793. args: ["separators"],
  4794. source: "trimBoth: separators\x0a\x09^ (self trimLeft: separators) trimRight: separators",
  4795. messageSends: ["trimRight:", "trimLeft:"],
  4796. referencedClasses: []
  4797. }),
  4798. smalltalk.String);
  4799. smalltalk.addMethod(
  4800. smalltalk.method({
  4801. selector: "trimLeft",
  4802. protocol: 'regular expressions',
  4803. fn: function (){
  4804. var self=this;
  4805. return smalltalk.withContext(function($ctx1) {
  4806. var $1;
  4807. $1=self._trimLeft_("\x5cs");
  4808. return $1;
  4809. }, function($ctx1) {$ctx1.fill(self,"trimLeft",{},smalltalk.String)})},
  4810. args: [],
  4811. source: "trimLeft\x0a\x09^ self trimLeft: '\x5cs'",
  4812. messageSends: ["trimLeft:"],
  4813. referencedClasses: []
  4814. }),
  4815. smalltalk.String);
  4816. smalltalk.addMethod(
  4817. smalltalk.method({
  4818. selector: "trimLeft:",
  4819. protocol: 'regular expressions',
  4820. fn: function (separators){
  4821. var self=this;
  4822. function $RegularExpression(){return smalltalk.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
  4823. return smalltalk.withContext(function($ctx1) {
  4824. var $3,$2,$1;
  4825. $3=_st("^[".__comma(separators)).__comma("]+");
  4826. $ctx1.sendIdx[","]=1;
  4827. $2=_st($RegularExpression())._fromString_flag_($3,"g");
  4828. $1=self._replaceRegexp_with_($2,"");
  4829. return $1;
  4830. }, function($ctx1) {$ctx1.fill(self,"trimLeft:",{separators:separators},smalltalk.String)})},
  4831. args: ["separators"],
  4832. source: "trimLeft: separators\x0a\x09^ self replaceRegexp: (RegularExpression fromString: '^[', separators, ']+' flag: 'g') with: ''",
  4833. messageSends: ["replaceRegexp:with:", "fromString:flag:", ","],
  4834. referencedClasses: ["RegularExpression"]
  4835. }),
  4836. smalltalk.String);
  4837. smalltalk.addMethod(
  4838. smalltalk.method({
  4839. selector: "trimRight",
  4840. protocol: 'regular expressions',
  4841. fn: function (){
  4842. var self=this;
  4843. return smalltalk.withContext(function($ctx1) {
  4844. var $1;
  4845. $1=self._trimRight_("\x5cs");
  4846. return $1;
  4847. }, function($ctx1) {$ctx1.fill(self,"trimRight",{},smalltalk.String)})},
  4848. args: [],
  4849. source: "trimRight\x0a\x09^ self trimRight: '\x5cs'",
  4850. messageSends: ["trimRight:"],
  4851. referencedClasses: []
  4852. }),
  4853. smalltalk.String);
  4854. smalltalk.addMethod(
  4855. smalltalk.method({
  4856. selector: "trimRight:",
  4857. protocol: 'regular expressions',
  4858. fn: function (separators){
  4859. var self=this;
  4860. function $RegularExpression(){return smalltalk.RegularExpression||(typeof RegularExpression=="undefined"?nil:RegularExpression)}
  4861. return smalltalk.withContext(function($ctx1) {
  4862. var $3,$2,$1;
  4863. $3=_st("[".__comma(separators)).__comma("]+$");
  4864. $ctx1.sendIdx[","]=1;
  4865. $2=_st($RegularExpression())._fromString_flag_($3,"g");
  4866. $1=self._replaceRegexp_with_($2,"");
  4867. return $1;
  4868. }, function($ctx1) {$ctx1.fill(self,"trimRight:",{separators:separators},smalltalk.String)})},
  4869. args: ["separators"],
  4870. source: "trimRight: separators\x0a\x09^ self replaceRegexp: (RegularExpression fromString: '[', separators, ']+$' flag: 'g') with: ''",
  4871. messageSends: ["replaceRegexp:with:", "fromString:flag:", ","],
  4872. referencedClasses: ["RegularExpression"]
  4873. }),
  4874. smalltalk.String);
  4875. smalltalk.addMethod(
  4876. smalltalk.method({
  4877. selector: "unescaped",
  4878. protocol: 'converting',
  4879. fn: function (){
  4880. var self=this;
  4881. return smalltalk.withContext(function($ctx1) {
  4882. return unescape(self);
  4883. return self}, function($ctx1) {$ctx1.fill(self,"unescaped",{},smalltalk.String)})},
  4884. args: [],
  4885. source: "unescaped\x0a\x09<return unescape(self)>",
  4886. messageSends: [],
  4887. referencedClasses: []
  4888. }),
  4889. smalltalk.String);
  4890. smalltalk.addMethod(
  4891. smalltalk.method({
  4892. selector: "uriComponentDecoded",
  4893. protocol: 'converting',
  4894. fn: function (){
  4895. var self=this;
  4896. return smalltalk.withContext(function($ctx1) {
  4897. return decodeURIComponent(self);
  4898. return self}, function($ctx1) {$ctx1.fill(self,"uriComponentDecoded",{},smalltalk.String)})},
  4899. args: [],
  4900. source: "uriComponentDecoded\x0a\x09<return decodeURIComponent(self)>",
  4901. messageSends: [],
  4902. referencedClasses: []
  4903. }),
  4904. smalltalk.String);
  4905. smalltalk.addMethod(
  4906. smalltalk.method({
  4907. selector: "uriComponentEncoded",
  4908. protocol: 'converting',
  4909. fn: function (){
  4910. var self=this;
  4911. return smalltalk.withContext(function($ctx1) {
  4912. return encodeURIComponent(self);
  4913. return self}, function($ctx1) {$ctx1.fill(self,"uriComponentEncoded",{},smalltalk.String)})},
  4914. args: [],
  4915. source: "uriComponentEncoded\x0a\x09<return encodeURIComponent(self)>",
  4916. messageSends: [],
  4917. referencedClasses: []
  4918. }),
  4919. smalltalk.String);
  4920. smalltalk.addMethod(
  4921. smalltalk.method({
  4922. selector: "uriDecoded",
  4923. protocol: 'converting',
  4924. fn: function (){
  4925. var self=this;
  4926. return smalltalk.withContext(function($ctx1) {
  4927. return decodeURI(self);
  4928. return self}, function($ctx1) {$ctx1.fill(self,"uriDecoded",{},smalltalk.String)})},
  4929. args: [],
  4930. source: "uriDecoded\x0a\x09<return decodeURI(self)>",
  4931. messageSends: [],
  4932. referencedClasses: []
  4933. }),
  4934. smalltalk.String);
  4935. smalltalk.addMethod(
  4936. smalltalk.method({
  4937. selector: "uriEncoded",
  4938. protocol: 'converting',
  4939. fn: function (){
  4940. var self=this;
  4941. return smalltalk.withContext(function($ctx1) {
  4942. return encodeURI(self);
  4943. return self}, function($ctx1) {$ctx1.fill(self,"uriEncoded",{},smalltalk.String)})},
  4944. args: [],
  4945. source: "uriEncoded\x0a\x09<return encodeURI(self)>",
  4946. messageSends: [],
  4947. referencedClasses: []
  4948. }),
  4949. smalltalk.String);
  4950. smalltalk.addMethod(
  4951. smalltalk.method({
  4952. selector: "cr",
  4953. protocol: 'accessing',
  4954. fn: function (){
  4955. var self=this;
  4956. return smalltalk.withContext(function($ctx1) {
  4957. return '\r';
  4958. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.String.klass)})},
  4959. args: [],
  4960. source: "cr\x0a\x09<return '\x5cr'>",
  4961. messageSends: [],
  4962. referencedClasses: []
  4963. }),
  4964. smalltalk.String.klass);
  4965. smalltalk.addMethod(
  4966. smalltalk.method({
  4967. selector: "crlf",
  4968. protocol: 'accessing',
  4969. fn: function (){
  4970. var self=this;
  4971. return smalltalk.withContext(function($ctx1) {
  4972. return '\r\n';
  4973. return self}, function($ctx1) {$ctx1.fill(self,"crlf",{},smalltalk.String.klass)})},
  4974. args: [],
  4975. source: "crlf\x0a\x09<return '\x5cr\x5cn'>",
  4976. messageSends: [],
  4977. referencedClasses: []
  4978. }),
  4979. smalltalk.String.klass);
  4980. smalltalk.addMethod(
  4981. smalltalk.method({
  4982. selector: "esc",
  4983. protocol: 'accessing',
  4984. fn: function (){
  4985. var self=this;
  4986. return smalltalk.withContext(function($ctx1) {
  4987. var $1;
  4988. $1=self._fromCharCode_((27));
  4989. return $1;
  4990. }, function($ctx1) {$ctx1.fill(self,"esc",{},smalltalk.String.klass)})},
  4991. args: [],
  4992. source: "esc\x0a\x09^ self fromCharCode: 27",
  4993. messageSends: ["fromCharCode:"],
  4994. referencedClasses: []
  4995. }),
  4996. smalltalk.String.klass);
  4997. smalltalk.addMethod(
  4998. smalltalk.method({
  4999. selector: "fromCharCode:",
  5000. protocol: 'instance creation',
  5001. fn: function (anInteger){
  5002. var self=this;
  5003. return smalltalk.withContext(function($ctx1) {
  5004. return String.fromCharCode(anInteger);
  5005. return self}, function($ctx1) {$ctx1.fill(self,"fromCharCode:",{anInteger:anInteger},smalltalk.String.klass)})},
  5006. args: ["anInteger"],
  5007. source: "fromCharCode: anInteger\x0a\x09<return String.fromCharCode(anInteger)>",
  5008. messageSends: [],
  5009. referencedClasses: []
  5010. }),
  5011. smalltalk.String.klass);
  5012. smalltalk.addMethod(
  5013. smalltalk.method({
  5014. selector: "fromString:",
  5015. protocol: 'instance creation',
  5016. fn: function (aString){
  5017. var self=this;
  5018. return smalltalk.withContext(function($ctx1) {
  5019. return String(aString);
  5020. return self}, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},smalltalk.String.klass)})},
  5021. args: ["aString"],
  5022. source: "fromString: aString\x0a\x09\x09<return String(aString)>",
  5023. messageSends: [],
  5024. referencedClasses: []
  5025. }),
  5026. smalltalk.String.klass);
  5027. smalltalk.addMethod(
  5028. smalltalk.method({
  5029. selector: "lf",
  5030. protocol: 'accessing',
  5031. fn: function (){
  5032. var self=this;
  5033. return smalltalk.withContext(function($ctx1) {
  5034. return '\n';
  5035. return self}, function($ctx1) {$ctx1.fill(self,"lf",{},smalltalk.String.klass)})},
  5036. args: [],
  5037. source: "lf\x0a\x09<return '\x5cn'>",
  5038. messageSends: [],
  5039. referencedClasses: []
  5040. }),
  5041. smalltalk.String.klass);
  5042. smalltalk.addMethod(
  5043. smalltalk.method({
  5044. selector: "random",
  5045. protocol: 'random',
  5046. fn: function (){
  5047. var self=this;
  5048. return smalltalk.withContext(function($ctx1) {
  5049. return (Math.random()*(22/32)+(10/32)).toString(32).slice(2);;
  5050. return self}, function($ctx1) {$ctx1.fill(self,"random",{},smalltalk.String.klass)})},
  5051. args: [],
  5052. 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);>",
  5053. messageSends: [],
  5054. referencedClasses: []
  5055. }),
  5056. smalltalk.String.klass);
  5057. smalltalk.addMethod(
  5058. smalltalk.method({
  5059. selector: "randomNotIn:",
  5060. protocol: 'random',
  5061. fn: function (aString){
  5062. var self=this;
  5063. var result;
  5064. return smalltalk.withContext(function($ctx1) {
  5065. var $1;
  5066. _st((function(){
  5067. return smalltalk.withContext(function($ctx2) {
  5068. result=self._random();
  5069. result;
  5070. return _st(aString)._includesSubString_(result);
  5071. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue();
  5072. $1=result;
  5073. return $1;
  5074. }, function($ctx1) {$ctx1.fill(self,"randomNotIn:",{aString:aString,result:result},smalltalk.String.klass)})},
  5075. args: ["aString"],
  5076. source: "randomNotIn: aString\x0a\x09| result |\x0a\x09[ result := self random. aString includesSubString: result ] whileTrue.\x0a\x09^ result",
  5077. messageSends: ["whileTrue", "random", "includesSubString:"],
  5078. referencedClasses: []
  5079. }),
  5080. smalltalk.String.klass);
  5081. smalltalk.addMethod(
  5082. smalltalk.method({
  5083. selector: "space",
  5084. protocol: 'accessing',
  5085. fn: function (){
  5086. var self=this;
  5087. return smalltalk.withContext(function($ctx1) {
  5088. return ' ';
  5089. return self}, function($ctx1) {$ctx1.fill(self,"space",{},smalltalk.String.klass)})},
  5090. args: [],
  5091. source: "space\x0a\x09<return ' '>",
  5092. messageSends: [],
  5093. referencedClasses: []
  5094. }),
  5095. smalltalk.String.klass);
  5096. smalltalk.addMethod(
  5097. smalltalk.method({
  5098. selector: "streamClass",
  5099. protocol: 'accessing',
  5100. fn: function (){
  5101. var self=this;
  5102. function $StringStream(){return smalltalk.StringStream||(typeof StringStream=="undefined"?nil:StringStream)}
  5103. return smalltalk.withContext(function($ctx1) {
  5104. return $StringStream();
  5105. }, function($ctx1) {$ctx1.fill(self,"streamClass",{},smalltalk.String.klass)})},
  5106. args: [],
  5107. source: "streamClass\x0a\x09\x09^ StringStream",
  5108. messageSends: [],
  5109. referencedClasses: ["StringStream"]
  5110. }),
  5111. smalltalk.String.klass);
  5112. smalltalk.addMethod(
  5113. smalltalk.method({
  5114. selector: "tab",
  5115. protocol: 'accessing',
  5116. fn: function (){
  5117. var self=this;
  5118. return smalltalk.withContext(function($ctx1) {
  5119. return '\t';
  5120. return self}, function($ctx1) {$ctx1.fill(self,"tab",{},smalltalk.String.klass)})},
  5121. args: [],
  5122. source: "tab\x0a\x09<return '\x5ct'>",
  5123. messageSends: [],
  5124. referencedClasses: []
  5125. }),
  5126. smalltalk.String.klass);
  5127. smalltalk.addMethod(
  5128. smalltalk.method({
  5129. selector: "value:",
  5130. protocol: 'instance creation',
  5131. fn: function (aUTFCharCode){
  5132. var self=this;
  5133. return smalltalk.withContext(function($ctx1) {
  5134. return String.fromCharCode(aUTFCharCode);;
  5135. return self}, function($ctx1) {$ctx1.fill(self,"value:",{aUTFCharCode:aUTFCharCode},smalltalk.String.klass)})},
  5136. args: ["aUTFCharCode"],
  5137. source: "value: aUTFCharCode\x0a\x0a\x09<return String.fromCharCode(aUTFCharCode);>",
  5138. messageSends: [],
  5139. referencedClasses: []
  5140. }),
  5141. smalltalk.String.klass);
  5142. smalltalk.addClass('Set', smalltalk.Collection, ['defaultBucket', 'slowBucketStores', 'fastBuckets', 'size'], 'Kernel-Collections');
  5143. smalltalk.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";
  5144. smalltalk.addMethod(
  5145. smalltalk.method({
  5146. selector: "=",
  5147. protocol: 'comparing',
  5148. fn: function (aCollection){
  5149. var self=this;
  5150. return smalltalk.withContext(function($ctx1) {
  5151. var $2,$1,$4,$3,$5;
  5152. var $early={};
  5153. try {
  5154. $2=self._class();
  5155. $ctx1.sendIdx["class"]=1;
  5156. $1=_st($2).__eq(_st(aCollection)._class());
  5157. $ctx1.sendIdx["="]=1;
  5158. if(! smalltalk.assert($1)){
  5159. return false;
  5160. };
  5161. $4=self._size();
  5162. $ctx1.sendIdx["size"]=1;
  5163. $3=_st($4).__eq(_st(aCollection)._size());
  5164. if(! smalltalk.assert($3)){
  5165. return false;
  5166. };
  5167. self._do_((function(each){
  5168. return smalltalk.withContext(function($ctx2) {
  5169. $5=_st(aCollection)._includes_(each);
  5170. if(! smalltalk.assert($5)){
  5171. throw $early=[false];
  5172. };
  5173. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})}));
  5174. return true;
  5175. }
  5176. catch(e) {if(e===$early)return e[0]; throw e}
  5177. }, function($ctx1) {$ctx1.fill(self,"=",{aCollection:aCollection},smalltalk.Set)})},
  5178. args: ["aCollection"],
  5179. 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",
  5180. messageSends: ["ifFalse:", "=", "class", "size", "do:", "includes:"],
  5181. referencedClasses: []
  5182. }),
  5183. smalltalk.Set);
  5184. smalltalk.addMethod(
  5185. smalltalk.method({
  5186. selector: "add:",
  5187. protocol: 'adding/removing',
  5188. fn: function (anObject){
  5189. var self=this;
  5190. var bucket;
  5191. return smalltalk.withContext(function($ctx1) {
  5192. var $2,$1;
  5193. bucket=self._bucketsOfElement_(anObject);
  5194. $2=_st(bucket)._second();
  5195. if(($receiver = $2) == nil || $receiver == null){
  5196. var object,slowBucket;
  5197. object=_st(bucket)._first();
  5198. $ctx1.sendIdx["first"]=1;
  5199. object;
  5200. slowBucket=_st(bucket)._third();
  5201. slowBucket;
  5202. _st(slowBucket)._indexOf_ifAbsent_(object,(function(){
  5203. return smalltalk.withContext(function($ctx2) {
  5204. _st(slowBucket)._add_(object);
  5205. self["@size"]=_st(self["@size"]).__plus((1));
  5206. return self["@size"];
  5207. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  5208. $1=object;
  5209. } else {
  5210. var primitiveBucket;
  5211. primitiveBucket=$receiver;
  5212. $1=self._add_in_(_st(bucket)._first(),primitiveBucket);
  5213. };
  5214. return $1;
  5215. }, function($ctx1) {$ctx1.fill(self,"add:",{anObject:anObject,bucket:bucket},smalltalk.Set)})},
  5216. args: ["anObject"],
  5217. 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 ]",
  5218. messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "first", "third", "indexOf:ifAbsent:", "add:", "+", "add:in:"],
  5219. referencedClasses: []
  5220. }),
  5221. smalltalk.Set);
  5222. smalltalk.addMethod(
  5223. smalltalk.method({
  5224. selector: "add:in:",
  5225. protocol: 'private',
  5226. fn: function (anObject,anotherObject){
  5227. var self=this;
  5228. return smalltalk.withContext(function($ctx1) {
  5229. if (anObject in anotherObject.store) { return false; }
  5230. self['@size']++;
  5231. return anotherObject.store[anObject] = true;
  5232. ;
  5233. return self}, function($ctx1) {$ctx1.fill(self,"add:in:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Set)})},
  5234. args: ["anObject", "anotherObject"],
  5235. 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>",
  5236. messageSends: [],
  5237. referencedClasses: []
  5238. }),
  5239. smalltalk.Set);
  5240. smalltalk.addMethod(
  5241. smalltalk.method({
  5242. selector: "bucketsOfElement:",
  5243. protocol: 'private',
  5244. fn: function (anObject){
  5245. var self=this;
  5246. return smalltalk.withContext(function($ctx1) {
  5247. var type, bucket, prim = anObject == null ? (anObject = nil) : anObject.valueOf();
  5248. if ((type = typeof prim) === "object") {
  5249. if (anObject !== nil) {
  5250. bucket = null;
  5251. self['@slowBucketStores'].some(function (store) {
  5252. return bucket = store._bucketOfElement_(anObject);
  5253. });
  5254. return [ anObject, null, bucket || self['@defaultBucket'] ];
  5255. }
  5256. // include nil to well-known objects under 'boolean' fastBucket
  5257. prim = null;
  5258. type = 'boolean';
  5259. }
  5260. return [ prim, self['@fastBuckets'][type] ];
  5261. ;
  5262. return self}, function($ctx1) {$ctx1.fill(self,"bucketsOfElement:",{anObject:anObject},smalltalk.Set)})},
  5263. args: ["anObject"],
  5264. 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>",
  5265. messageSends: [],
  5266. referencedClasses: []
  5267. }),
  5268. smalltalk.Set);
  5269. smalltalk.addMethod(
  5270. smalltalk.method({
  5271. selector: "classNameOf:",
  5272. protocol: 'private',
  5273. fn: function (anObject){
  5274. var self=this;
  5275. return smalltalk.withContext(function($ctx1) {
  5276. return anObject.klass && anObject.klass.className;
  5277. return self}, function($ctx1) {$ctx1.fill(self,"classNameOf:",{anObject:anObject},smalltalk.Set)})},
  5278. args: ["anObject"],
  5279. 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>",
  5280. messageSends: [],
  5281. referencedClasses: []
  5282. }),
  5283. smalltalk.Set);
  5284. smalltalk.addMethod(
  5285. smalltalk.method({
  5286. selector: "collect:",
  5287. protocol: 'enumerating',
  5288. fn: function (aBlock){
  5289. var self=this;
  5290. var collection;
  5291. return smalltalk.withContext(function($ctx1) {
  5292. var $1;
  5293. collection=_st(self._class())._new();
  5294. self._do_((function(each){
  5295. return smalltalk.withContext(function($ctx2) {
  5296. return _st(collection)._add_(_st(aBlock)._value_(each));
  5297. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5298. $1=collection;
  5299. return $1;
  5300. }, function($ctx1) {$ctx1.fill(self,"collect:",{aBlock:aBlock,collection:collection},smalltalk.Set)})},
  5301. args: ["aBlock"],
  5302. source: "collect: aBlock\x0a\x09| collection |\x0a\x09collection := self class new.\x0a\x09self do: [ :each | collection add: (aBlock value: each) ].\x0a\x09^ collection",
  5303. messageSends: ["new", "class", "do:", "add:", "value:"],
  5304. referencedClasses: []
  5305. }),
  5306. smalltalk.Set);
  5307. smalltalk.addMethod(
  5308. smalltalk.method({
  5309. selector: "detect:ifNone:",
  5310. protocol: 'enumerating',
  5311. fn: function (aBlock,anotherBlock){
  5312. var self=this;
  5313. return smalltalk.withContext(function($ctx1) {
  5314. var $1,$2;
  5315. var $early={};
  5316. try {
  5317. self._do_((function(each){
  5318. return smalltalk.withContext(function($ctx2) {
  5319. $1=_st(aBlock)._value_(each);
  5320. if(smalltalk.assert($1)){
  5321. throw $early=[each];
  5322. };
  5323. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5324. $2=_st(anotherBlock)._value();
  5325. return $2;
  5326. }
  5327. catch(e) {if(e===$early)return e[0]; throw e}
  5328. }, function($ctx1) {$ctx1.fill(self,"detect:ifNone:",{aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.Set)})},
  5329. args: ["aBlock", "anotherBlock"],
  5330. source: "detect: aBlock ifNone: anotherBlock\x0a\x09self do: [ :each | (aBlock value: each) ifTrue: [ ^each ] ].\x0a\x09^ anotherBlock value",
  5331. messageSends: ["do:", "ifTrue:", "value:", "value"],
  5332. referencedClasses: []
  5333. }),
  5334. smalltalk.Set);
  5335. smalltalk.addMethod(
  5336. smalltalk.method({
  5337. selector: "do:",
  5338. protocol: 'enumerating',
  5339. fn: function (aBlock){
  5340. var self=this;
  5341. return smalltalk.withContext(function($ctx1) {
  5342. var el, keys, i;
  5343. el = self['@fastBuckets'];
  5344. keys = Object.keys(el);
  5345. for (i = 0; i < keys.length; ++i) {
  5346. var fastBucket = el[keys[i]], fn = fastBucket.fn, store = Object.keys(fastBucket.store);
  5347. if (fn) { for (var j = 0; j < store.length; ++j) { aBlock._value_(fn(store[j])); } }
  5348. else { store._do_(aBlock); }
  5349. }
  5350. el = self['@slowBucketStores'];
  5351. for (i = 0; i < el.length; ++i) { el[i]._do_(aBlock); }
  5352. self['@defaultBucket']._do_(aBlock);
  5353. ;
  5354. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.Set)})},
  5355. args: ["aBlock"],
  5356. 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>",
  5357. messageSends: [],
  5358. referencedClasses: []
  5359. }),
  5360. smalltalk.Set);
  5361. smalltalk.addMethod(
  5362. smalltalk.method({
  5363. selector: "includes:",
  5364. protocol: 'testing',
  5365. fn: function (anObject){
  5366. var self=this;
  5367. var bucket;
  5368. return smalltalk.withContext(function($ctx1) {
  5369. var $2,$3,$4,$1;
  5370. bucket=self._bucketsOfElement_(anObject);
  5371. $2=_st(bucket)._second();
  5372. if(($receiver = $2) == nil || $receiver == null){
  5373. $3=_st(bucket)._third();
  5374. $4=_st(bucket)._first();
  5375. $ctx1.sendIdx["first"]=1;
  5376. $1=_st($3)._includes_($4);
  5377. } else {
  5378. var primitiveBucket;
  5379. primitiveBucket=$receiver;
  5380. $1=self._includes_in_(_st(bucket)._first(),primitiveBucket);
  5381. };
  5382. return $1;
  5383. }, function($ctx1) {$ctx1.fill(self,"includes:",{anObject:anObject,bucket:bucket},smalltalk.Set)})},
  5384. args: ["anObject"],
  5385. 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 ]",
  5386. messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "includes:", "third", "first", "includes:in:"],
  5387. referencedClasses: []
  5388. }),
  5389. smalltalk.Set);
  5390. smalltalk.addMethod(
  5391. smalltalk.method({
  5392. selector: "includes:in:",
  5393. protocol: 'private',
  5394. fn: function (anObject,anotherObject){
  5395. var self=this;
  5396. return smalltalk.withContext(function($ctx1) {
  5397. return anObject in anotherObject.store;
  5398. return self}, function($ctx1) {$ctx1.fill(self,"includes:in:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Set)})},
  5399. args: ["anObject", "anotherObject"],
  5400. source: "includes: anObject in: anotherObject\x0a\x09<return anObject in anotherObject.store>",
  5401. messageSends: [],
  5402. referencedClasses: []
  5403. }),
  5404. smalltalk.Set);
  5405. smalltalk.addMethod(
  5406. smalltalk.method({
  5407. selector: "initialize",
  5408. protocol: 'initialization',
  5409. fn: function (){
  5410. var self=this;
  5411. return smalltalk.withContext(function($ctx1) {
  5412. var $1;
  5413. smalltalk.Set.superclass.fn.prototype._initialize.apply(_st(self), []);
  5414. self["@defaultBucket"]=[];
  5415. self._initializeSlowBucketStores();
  5416. $1=self._removeAll();
  5417. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Set)})},
  5418. args: [],
  5419. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09defaultBucket := #().\x0a\x09self\x0a\x09\x09initializeSlowBucketStores;\x0a\x09\x09removeAll",
  5420. messageSends: ["initialize", "initializeSlowBucketStores", "removeAll"],
  5421. referencedClasses: []
  5422. }),
  5423. smalltalk.Set);
  5424. smalltalk.addMethod(
  5425. smalltalk.method({
  5426. selector: "initializeSlowBucketStores",
  5427. protocol: 'initialization',
  5428. fn: function (){
  5429. var self=this;
  5430. function $ArrayBucketStore(){return smalltalk.ArrayBucketStore||(typeof ArrayBucketStore=="undefined"?nil:ArrayBucketStore)}
  5431. return smalltalk.withContext(function($ctx1) {
  5432. var $1;
  5433. $1=_st($ArrayBucketStore())._hashBlock_((function(x){
  5434. return smalltalk.withContext(function($ctx2) {
  5435. return self._classNameOf_(x);
  5436. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})}));
  5437. $ctx1.sendIdx["hashBlock:"]=1;
  5438. self["@slowBucketStores"]=[$1,_st($ArrayBucketStore())._hashBlock_((function(x){
  5439. return smalltalk.withContext(function($ctx2) {
  5440. return self._jsConstructorNameOf_(x);
  5441. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,2)})}))];
  5442. return self}, function($ctx1) {$ctx1.fill(self,"initializeSlowBucketStores",{},smalltalk.Set)})},
  5443. args: [],
  5444. source: "initializeSlowBucketStores\x0a\x09slowBucketStores := {\x0a\x09\x09ArrayBucketStore hashBlock: [ :x | self classNameOf: x ].\x0a\x09\x09ArrayBucketStore hashBlock: [ :x | self jsConstructorNameOf: x ]\x0a\x09}",
  5445. messageSends: ["hashBlock:", "classNameOf:", "jsConstructorNameOf:"],
  5446. referencedClasses: ["ArrayBucketStore"]
  5447. }),
  5448. smalltalk.Set);
  5449. smalltalk.addMethod(
  5450. smalltalk.method({
  5451. selector: "jsConstructorNameOf:",
  5452. protocol: 'private',
  5453. fn: function (anObject){
  5454. var self=this;
  5455. return smalltalk.withContext(function($ctx1) {
  5456. return anObject.constructor && anObject.constructor.name;
  5457. return self}, function($ctx1) {$ctx1.fill(self,"jsConstructorNameOf:",{anObject:anObject},smalltalk.Set)})},
  5458. args: ["anObject"],
  5459. source: "jsConstructorNameOf: anObject\x0a\x09<return anObject.constructor && anObject.constructor.name>",
  5460. messageSends: [],
  5461. referencedClasses: []
  5462. }),
  5463. smalltalk.Set);
  5464. smalltalk.addMethod(
  5465. smalltalk.method({
  5466. selector: "printOn:",
  5467. protocol: 'printing',
  5468. fn: function (aStream){
  5469. var self=this;
  5470. return smalltalk.withContext(function($ctx1) {
  5471. smalltalk.Set.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  5472. $ctx1.sendIdx["printOn:"]=1;
  5473. _st(aStream)._nextPutAll_(" (");
  5474. $ctx1.sendIdx["nextPutAll:"]=1;
  5475. self._do_separatedBy_((function(each){
  5476. return smalltalk.withContext(function($ctx2) {
  5477. return _st(each)._printOn_(aStream);
  5478. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  5479. return smalltalk.withContext(function($ctx2) {
  5480. return _st(aStream)._nextPutAll_(" ");
  5481. $ctx2.sendIdx["nextPutAll:"]=2;
  5482. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  5483. _st(aStream)._nextPutAll_(")");
  5484. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.Set)})},
  5485. args: ["aStream"],
  5486. 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: ')'",
  5487. messageSends: ["printOn:", "nextPutAll:", "do:separatedBy:"],
  5488. referencedClasses: []
  5489. }),
  5490. smalltalk.Set);
  5491. smalltalk.addMethod(
  5492. smalltalk.method({
  5493. selector: "remove:ifAbsent:",
  5494. protocol: 'adding/removing',
  5495. fn: function (anObject,aBlock){
  5496. var self=this;
  5497. var bucket;
  5498. return smalltalk.withContext(function($ctx1) {
  5499. var $2,$3,$4,$5,$1;
  5500. var $early={};
  5501. try {
  5502. bucket=self._bucketsOfElement_(anObject);
  5503. $2=_st(bucket)._second();
  5504. if(($receiver = $2) == nil || $receiver == null){
  5505. $3=_st(bucket)._third();
  5506. $4=_st(bucket)._first();
  5507. $ctx1.sendIdx["first"]=1;
  5508. _st($3)._remove_ifAbsent_($4,(function(){
  5509. return smalltalk.withContext(function($ctx2) {
  5510. $5=_st(aBlock)._value();
  5511. throw $early=[$5];
  5512. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  5513. self["@size"]=_st(self["@size"]).__minus((1));
  5514. $1=self["@size"];
  5515. } else {
  5516. var primitiveBucket;
  5517. primitiveBucket=$receiver;
  5518. $1=self._remove_in_(_st(bucket)._first(),primitiveBucket);
  5519. };
  5520. return $1;
  5521. }
  5522. catch(e) {if(e===$early)return e[0]; throw e}
  5523. }, function($ctx1) {$ctx1.fill(self,"remove:ifAbsent:",{anObject:anObject,aBlock:aBlock,bucket:bucket},smalltalk.Set)})},
  5524. args: ["anObject", "aBlock"],
  5525. 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 ]",
  5526. messageSends: ["bucketsOfElement:", "ifNil:ifNotNil:", "second", "remove:ifAbsent:", "third", "first", "value", "-", "remove:in:"],
  5527. referencedClasses: []
  5528. }),
  5529. smalltalk.Set);
  5530. smalltalk.addMethod(
  5531. smalltalk.method({
  5532. selector: "remove:in:",
  5533. protocol: 'private',
  5534. fn: function (anObject,anotherObject){
  5535. var self=this;
  5536. return smalltalk.withContext(function($ctx1) {
  5537. if (delete anotherObject.store[anObject]) self['@size']--;
  5538. return self}, function($ctx1) {$ctx1.fill(self,"remove:in:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Set)})},
  5539. args: ["anObject", "anotherObject"],
  5540. source: "remove: anObject in: anotherObject\x0a\x09<if (delete anotherObject.store[anObject]) self['@size']-->",
  5541. messageSends: [],
  5542. referencedClasses: []
  5543. }),
  5544. smalltalk.Set);
  5545. smalltalk.addMethod(
  5546. smalltalk.method({
  5547. selector: "removeAll",
  5548. protocol: 'adding/removing',
  5549. fn: function (){
  5550. var self=this;
  5551. return smalltalk.withContext(function($ctx1) {
  5552. self['@fastBuckets'] = {
  5553. 'boolean': { store: Object.create(null), fn: function (x) { return {'true': true, 'false': false, 'null': null}[x]; } },
  5554. 'number': { store: Object.create(null), fn: Number },
  5555. 'string': { store: Object.create(null) }
  5556. };
  5557. self['@slowBucketStores'].forEach(function (x) { x._removeAll(); });
  5558. self['@defaultBucket']._removeAll();
  5559. self['@size'] = 0;
  5560. ;
  5561. return self}, function($ctx1) {$ctx1.fill(self,"removeAll",{},smalltalk.Set)})},
  5562. args: [],
  5563. 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>",
  5564. messageSends: [],
  5565. referencedClasses: []
  5566. }),
  5567. smalltalk.Set);
  5568. smalltalk.addMethod(
  5569. smalltalk.method({
  5570. selector: "select:",
  5571. protocol: 'enumerating',
  5572. fn: function (aBlock){
  5573. var self=this;
  5574. var collection;
  5575. return smalltalk.withContext(function($ctx1) {
  5576. var $1,$2;
  5577. collection=_st(self._class())._new();
  5578. self._do_((function(each){
  5579. return smalltalk.withContext(function($ctx2) {
  5580. $1=_st(aBlock)._value_(each);
  5581. if(smalltalk.assert($1)){
  5582. return _st(collection)._add_(each);
  5583. };
  5584. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5585. $2=collection;
  5586. return $2;
  5587. }, function($ctx1) {$ctx1.fill(self,"select:",{aBlock:aBlock,collection:collection},smalltalk.Set)})},
  5588. args: ["aBlock"],
  5589. 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",
  5590. messageSends: ["new", "class", "do:", "ifTrue:", "value:", "add:"],
  5591. referencedClasses: []
  5592. }),
  5593. smalltalk.Set);
  5594. smalltalk.addMethod(
  5595. smalltalk.method({
  5596. selector: "size",
  5597. protocol: 'accessing',
  5598. fn: function (){
  5599. var self=this;
  5600. return smalltalk.withContext(function($ctx1) {
  5601. var $1;
  5602. $1=self["@size"];
  5603. return $1;
  5604. }, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.Set)})},
  5605. args: [],
  5606. source: "size\x0a\x09^ size",
  5607. messageSends: [],
  5608. referencedClasses: []
  5609. }),
  5610. smalltalk.Set);
  5611. smalltalk.addClass('Queue', smalltalk.Object, ['read', 'readIndex', 'write'], 'Kernel-Collections');
  5612. smalltalk.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.";
  5613. smalltalk.addMethod(
  5614. smalltalk.method({
  5615. selector: "initialize",
  5616. protocol: 'initialization',
  5617. fn: function (){
  5618. var self=this;
  5619. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  5620. return smalltalk.withContext(function($ctx1) {
  5621. smalltalk.Queue.superclass.fn.prototype._initialize.apply(_st(self), []);
  5622. self["@read"]=_st($OrderedCollection())._new();
  5623. $ctx1.sendIdx["new"]=1;
  5624. self["@write"]=_st($OrderedCollection())._new();
  5625. self["@readIndex"]=(1);
  5626. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Queue)})},
  5627. args: [],
  5628. source: "initialize\x0a\x09super initialize.\x0a\x09read := OrderedCollection new.\x0a\x09write := OrderedCollection new.\x0a\x09readIndex := 1",
  5629. messageSends: ["initialize", "new"],
  5630. referencedClasses: ["OrderedCollection"]
  5631. }),
  5632. smalltalk.Queue);
  5633. smalltalk.addMethod(
  5634. smalltalk.method({
  5635. selector: "next",
  5636. protocol: 'accessing',
  5637. fn: function (){
  5638. var self=this;
  5639. return smalltalk.withContext(function($ctx1) {
  5640. var $1;
  5641. $1=self._nextIfAbsent_((function(){
  5642. return smalltalk.withContext(function($ctx2) {
  5643. return self._error_("Cannot read from empty Queue.");
  5644. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  5645. return $1;
  5646. }, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.Queue)})},
  5647. args: [],
  5648. source: "next\x0a\x09^ self nextIfAbsent: [ self error: 'Cannot read from empty Queue.' ]",
  5649. messageSends: ["nextIfAbsent:", "error:"],
  5650. referencedClasses: []
  5651. }),
  5652. smalltalk.Queue);
  5653. smalltalk.addMethod(
  5654. smalltalk.method({
  5655. selector: "nextIfAbsent:",
  5656. protocol: 'accessing',
  5657. fn: function (aBlock){
  5658. var self=this;
  5659. var result;
  5660. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  5661. return smalltalk.withContext(function($ctx1) {
  5662. var $1,$2,$3,$4;
  5663. var $early={};
  5664. try {
  5665. result=_st(self["@read"])._at_ifAbsent_(self["@readIndex"],(function(){
  5666. return smalltalk.withContext(function($ctx2) {
  5667. $1=_st(self["@write"])._isEmpty();
  5668. if(smalltalk.assert($1)){
  5669. $2=_st(self["@readIndex"]).__gt((1));
  5670. if(smalltalk.assert($2)){
  5671. self["@read"]=[];
  5672. self["@read"];
  5673. self["@readIndex"]=(1);
  5674. self["@readIndex"];
  5675. };
  5676. $3=_st(aBlock)._value();
  5677. throw $early=[$3];
  5678. };
  5679. self["@read"]=self["@write"];
  5680. self["@read"];
  5681. self["@readIndex"]=(1);
  5682. self["@readIndex"];
  5683. self["@write"]=_st($OrderedCollection())._new();
  5684. self["@write"];
  5685. return _st(self["@read"])._first();
  5686. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  5687. _st(self["@read"])._at_put_(self["@readIndex"],nil);
  5688. self["@readIndex"]=_st(self["@readIndex"]).__plus((1));
  5689. $4=result;
  5690. return $4;
  5691. }
  5692. catch(e) {if(e===$early)return e[0]; throw e}
  5693. }, function($ctx1) {$ctx1.fill(self,"nextIfAbsent:",{aBlock:aBlock,result:result},smalltalk.Queue)})},
  5694. args: ["aBlock"],
  5695. 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",
  5696. messageSends: ["at:ifAbsent:", "ifTrue:", "isEmpty", ">", "value", "new", "first", "at:put:", "+"],
  5697. referencedClasses: ["OrderedCollection"]
  5698. }),
  5699. smalltalk.Queue);
  5700. smalltalk.addMethod(
  5701. smalltalk.method({
  5702. selector: "nextPut:",
  5703. protocol: 'accessing',
  5704. fn: function (anObject){
  5705. var self=this;
  5706. return smalltalk.withContext(function($ctx1) {
  5707. _st(self["@write"])._add_(anObject);
  5708. return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{anObject:anObject},smalltalk.Queue)})},
  5709. args: ["anObject"],
  5710. source: "nextPut: anObject\x0a\x09write add: anObject",
  5711. messageSends: ["add:"],
  5712. referencedClasses: []
  5713. }),
  5714. smalltalk.Queue);
  5715. smalltalk.addClass('RegularExpression', smalltalk.Object, [], 'Kernel-Collections');
  5716. smalltalk.RegularExpression.comment="I represent a regular expression object. My instances are JavaScript `RegExp` object.";
  5717. smalltalk.addMethod(
  5718. smalltalk.method({
  5719. selector: "compile:",
  5720. protocol: 'evaluating',
  5721. fn: function (aString){
  5722. var self=this;
  5723. return smalltalk.withContext(function($ctx1) {
  5724. return self.compile(aString);
  5725. return self}, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},smalltalk.RegularExpression)})},
  5726. args: ["aString"],
  5727. source: "compile: aString\x0a\x09<return self.compile(aString)>",
  5728. messageSends: [],
  5729. referencedClasses: []
  5730. }),
  5731. smalltalk.RegularExpression);
  5732. smalltalk.addMethod(
  5733. smalltalk.method({
  5734. selector: "exec:",
  5735. protocol: 'evaluating',
  5736. fn: function (aString){
  5737. var self=this;
  5738. return smalltalk.withContext(function($ctx1) {
  5739. return self.exec(aString) || nil;
  5740. return self}, function($ctx1) {$ctx1.fill(self,"exec:",{aString:aString},smalltalk.RegularExpression)})},
  5741. args: ["aString"],
  5742. source: "exec: aString\x0a\x09<return self.exec(aString) || nil>",
  5743. messageSends: [],
  5744. referencedClasses: []
  5745. }),
  5746. smalltalk.RegularExpression);
  5747. smalltalk.addMethod(
  5748. smalltalk.method({
  5749. selector: "test:",
  5750. protocol: 'evaluating',
  5751. fn: function (aString){
  5752. var self=this;
  5753. return smalltalk.withContext(function($ctx1) {
  5754. return self.test(aString);
  5755. return self}, function($ctx1) {$ctx1.fill(self,"test:",{aString:aString},smalltalk.RegularExpression)})},
  5756. args: ["aString"],
  5757. source: "test: aString\x0a\x09<return self.test(aString)>",
  5758. messageSends: [],
  5759. referencedClasses: []
  5760. }),
  5761. smalltalk.RegularExpression);
  5762. smalltalk.addMethod(
  5763. smalltalk.method({
  5764. selector: "fromString:",
  5765. protocol: 'instance creation',
  5766. fn: function (aString){
  5767. var self=this;
  5768. return smalltalk.withContext(function($ctx1) {
  5769. var $1;
  5770. $1=self._fromString_flag_(aString,"");
  5771. return $1;
  5772. }, function($ctx1) {$ctx1.fill(self,"fromString:",{aString:aString},smalltalk.RegularExpression.klass)})},
  5773. args: ["aString"],
  5774. source: "fromString: aString\x0a\x09\x09^ self fromString: aString flag: ''",
  5775. messageSends: ["fromString:flag:"],
  5776. referencedClasses: []
  5777. }),
  5778. smalltalk.RegularExpression.klass);
  5779. smalltalk.addMethod(
  5780. smalltalk.method({
  5781. selector: "fromString:flag:",
  5782. protocol: 'instance creation',
  5783. fn: function (aString,anotherString){
  5784. var self=this;
  5785. return smalltalk.withContext(function($ctx1) {
  5786. return new RegExp(aString, anotherString);
  5787. return self}, function($ctx1) {$ctx1.fill(self,"fromString:flag:",{aString:aString,anotherString:anotherString},smalltalk.RegularExpression.klass)})},
  5788. args: ["aString", "anotherString"],
  5789. source: "fromString: aString flag: anotherString\x0a\x09<return new RegExp(aString, anotherString)>",
  5790. messageSends: [],
  5791. referencedClasses: []
  5792. }),
  5793. smalltalk.RegularExpression.klass);
  5794. smalltalk.addClass('Stream', smalltalk.Object, ['collection', 'position', 'streamSize'], 'Kernel-Collections');
  5795. smalltalk.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.";
  5796. smalltalk.addMethod(
  5797. smalltalk.method({
  5798. selector: "<<",
  5799. protocol: 'writing',
  5800. fn: function (anObject){
  5801. var self=this;
  5802. return smalltalk.withContext(function($ctx1) {
  5803. self._write_(anObject);
  5804. return self}, function($ctx1) {$ctx1.fill(self,"<<",{anObject:anObject},smalltalk.Stream)})},
  5805. args: ["anObject"],
  5806. source: "<< anObject\x0a\x09self write: anObject",
  5807. messageSends: ["write:"],
  5808. referencedClasses: []
  5809. }),
  5810. smalltalk.Stream);
  5811. smalltalk.addMethod(
  5812. smalltalk.method({
  5813. selector: "atEnd",
  5814. protocol: 'testing',
  5815. fn: function (){
  5816. var self=this;
  5817. return smalltalk.withContext(function($ctx1) {
  5818. var $1;
  5819. $1=_st(self._position()).__eq(self._size());
  5820. return $1;
  5821. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.Stream)})},
  5822. args: [],
  5823. source: "atEnd\x0a\x09^ self position = self size",
  5824. messageSends: ["=", "position", "size"],
  5825. referencedClasses: []
  5826. }),
  5827. smalltalk.Stream);
  5828. smalltalk.addMethod(
  5829. smalltalk.method({
  5830. selector: "atStart",
  5831. protocol: 'testing',
  5832. fn: function (){
  5833. var self=this;
  5834. return smalltalk.withContext(function($ctx1) {
  5835. var $1;
  5836. $1=_st(self._position()).__eq((0));
  5837. return $1;
  5838. }, function($ctx1) {$ctx1.fill(self,"atStart",{},smalltalk.Stream)})},
  5839. args: [],
  5840. source: "atStart\x0a\x09^ self position = 0",
  5841. messageSends: ["=", "position"],
  5842. referencedClasses: []
  5843. }),
  5844. smalltalk.Stream);
  5845. smalltalk.addMethod(
  5846. smalltalk.method({
  5847. selector: "close",
  5848. protocol: 'actions',
  5849. fn: function (){
  5850. var self=this;
  5851. return smalltalk.withContext(function($ctx1) {
  5852. return self}, function($ctx1) {$ctx1.fill(self,"close",{},smalltalk.Stream)})},
  5853. args: [],
  5854. source: "close",
  5855. messageSends: [],
  5856. referencedClasses: []
  5857. }),
  5858. smalltalk.Stream);
  5859. smalltalk.addMethod(
  5860. smalltalk.method({
  5861. selector: "collection",
  5862. protocol: 'accessing',
  5863. fn: function (){
  5864. var self=this;
  5865. return smalltalk.withContext(function($ctx1) {
  5866. var $1;
  5867. $1=self["@collection"];
  5868. return $1;
  5869. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.Stream)})},
  5870. args: [],
  5871. source: "collection\x0a\x09^ collection",
  5872. messageSends: [],
  5873. referencedClasses: []
  5874. }),
  5875. smalltalk.Stream);
  5876. smalltalk.addMethod(
  5877. smalltalk.method({
  5878. selector: "contents",
  5879. protocol: 'accessing',
  5880. fn: function (){
  5881. var self=this;
  5882. return smalltalk.withContext(function($ctx1) {
  5883. var $1;
  5884. $1=_st(self._collection())._copyFrom_to_((1),self._streamSize());
  5885. return $1;
  5886. }, function($ctx1) {$ctx1.fill(self,"contents",{},smalltalk.Stream)})},
  5887. args: [],
  5888. source: "contents\x0a\x09^ self collection\x0a\x09\x09copyFrom: 1\x0a\x09\x09to: self streamSize",
  5889. messageSends: ["copyFrom:to:", "collection", "streamSize"],
  5890. referencedClasses: []
  5891. }),
  5892. smalltalk.Stream);
  5893. smalltalk.addMethod(
  5894. smalltalk.method({
  5895. selector: "do:",
  5896. protocol: 'enumerating',
  5897. fn: function (aBlock){
  5898. var self=this;
  5899. return smalltalk.withContext(function($ctx1) {
  5900. _st((function(){
  5901. return smalltalk.withContext(function($ctx2) {
  5902. return self._atEnd();
  5903. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  5904. return smalltalk.withContext(function($ctx2) {
  5905. return _st(aBlock)._value_(self._next());
  5906. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  5907. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.Stream)})},
  5908. args: ["aBlock"],
  5909. source: "do: aBlock\x0a\x09[ self atEnd ] whileFalse: [ aBlock value: self next ]",
  5910. messageSends: ["whileFalse:", "atEnd", "value:", "next"],
  5911. referencedClasses: []
  5912. }),
  5913. smalltalk.Stream);
  5914. smalltalk.addMethod(
  5915. smalltalk.method({
  5916. selector: "flush",
  5917. protocol: 'actions',
  5918. fn: function (){
  5919. var self=this;
  5920. return smalltalk.withContext(function($ctx1) {
  5921. return self}, function($ctx1) {$ctx1.fill(self,"flush",{},smalltalk.Stream)})},
  5922. args: [],
  5923. source: "flush",
  5924. messageSends: [],
  5925. referencedClasses: []
  5926. }),
  5927. smalltalk.Stream);
  5928. smalltalk.addMethod(
  5929. smalltalk.method({
  5930. selector: "isEmpty",
  5931. protocol: 'testing',
  5932. fn: function (){
  5933. var self=this;
  5934. return smalltalk.withContext(function($ctx1) {
  5935. var $1;
  5936. $1=_st(self._size()).__eq((0));
  5937. return $1;
  5938. }, function($ctx1) {$ctx1.fill(self,"isEmpty",{},smalltalk.Stream)})},
  5939. args: [],
  5940. source: "isEmpty\x0a\x09^ self size = 0",
  5941. messageSends: ["=", "size"],
  5942. referencedClasses: []
  5943. }),
  5944. smalltalk.Stream);
  5945. smalltalk.addMethod(
  5946. smalltalk.method({
  5947. selector: "next",
  5948. protocol: 'reading',
  5949. fn: function (){
  5950. var self=this;
  5951. return smalltalk.withContext(function($ctx1) {
  5952. var $2,$4,$3,$1;
  5953. $2=self._atEnd();
  5954. if(smalltalk.assert($2)){
  5955. $1=nil;
  5956. } else {
  5957. $4=self._position();
  5958. $ctx1.sendIdx["position"]=1;
  5959. $3=_st($4).__plus((1));
  5960. self._position_($3);
  5961. $1=_st(self["@collection"])._at_(self._position());
  5962. };
  5963. return $1;
  5964. }, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.Stream)})},
  5965. args: [],
  5966. 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 ]",
  5967. messageSends: ["ifTrue:ifFalse:", "atEnd", "position:", "+", "position", "at:"],
  5968. referencedClasses: []
  5969. }),
  5970. smalltalk.Stream);
  5971. smalltalk.addMethod(
  5972. smalltalk.method({
  5973. selector: "next:",
  5974. protocol: 'reading',
  5975. fn: function (anInteger){
  5976. var self=this;
  5977. var tempCollection;
  5978. return smalltalk.withContext(function($ctx1) {
  5979. var $1,$2;
  5980. tempCollection=_st(_st(self._collection())._class())._new();
  5981. _st(anInteger)._timesRepeat_((function(){
  5982. return smalltalk.withContext(function($ctx2) {
  5983. $1=self._atEnd();
  5984. if(! smalltalk.assert($1)){
  5985. return _st(tempCollection)._add_(self._next());
  5986. };
  5987. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  5988. $2=tempCollection;
  5989. return $2;
  5990. }, function($ctx1) {$ctx1.fill(self,"next:",{anInteger:anInteger,tempCollection:tempCollection},smalltalk.Stream)})},
  5991. args: ["anInteger"],
  5992. 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",
  5993. messageSends: ["new", "class", "collection", "timesRepeat:", "ifFalse:", "atEnd", "add:", "next"],
  5994. referencedClasses: []
  5995. }),
  5996. smalltalk.Stream);
  5997. smalltalk.addMethod(
  5998. smalltalk.method({
  5999. selector: "nextPut:",
  6000. protocol: 'writing',
  6001. fn: function (anObject){
  6002. var self=this;
  6003. return smalltalk.withContext(function($ctx1) {
  6004. var $2,$1,$3,$4;
  6005. $2=self._position();
  6006. $ctx1.sendIdx["position"]=1;
  6007. $1=_st($2).__plus((1));
  6008. self._position_($1);
  6009. $3=self._collection();
  6010. $4=self._position();
  6011. $ctx1.sendIdx["position"]=2;
  6012. _st($3)._at_put_($4,anObject);
  6013. self._setStreamSize_(_st(self._streamSize())._max_(self._position()));
  6014. return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{anObject:anObject},smalltalk.Stream)})},
  6015. args: ["anObject"],
  6016. 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)",
  6017. messageSends: ["position:", "+", "position", "at:put:", "collection", "setStreamSize:", "max:", "streamSize"],
  6018. referencedClasses: []
  6019. }),
  6020. smalltalk.Stream);
  6021. smalltalk.addMethod(
  6022. smalltalk.method({
  6023. selector: "nextPutAll:",
  6024. protocol: 'writing',
  6025. fn: function (aCollection){
  6026. var self=this;
  6027. return smalltalk.withContext(function($ctx1) {
  6028. _st(aCollection)._do_((function(each){
  6029. return smalltalk.withContext(function($ctx2) {
  6030. return self._nextPut_(each);
  6031. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  6032. return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aCollection:aCollection},smalltalk.Stream)})},
  6033. args: ["aCollection"],
  6034. source: "nextPutAll: aCollection\x0a\x09aCollection do: [ :each |\x0a\x09\x09self nextPut: each ]",
  6035. messageSends: ["do:", "nextPut:"],
  6036. referencedClasses: []
  6037. }),
  6038. smalltalk.Stream);
  6039. smalltalk.addMethod(
  6040. smalltalk.method({
  6041. selector: "nextPutString:",
  6042. protocol: 'writing',
  6043. fn: function (aString){
  6044. var self=this;
  6045. return smalltalk.withContext(function($ctx1) {
  6046. self._nextPut_(aString);
  6047. return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.Stream)})},
  6048. args: ["aString"],
  6049. source: "nextPutString: aString\x0a\x09self nextPut: aString",
  6050. messageSends: ["nextPut:"],
  6051. referencedClasses: []
  6052. }),
  6053. smalltalk.Stream);
  6054. smalltalk.addMethod(
  6055. smalltalk.method({
  6056. selector: "peek",
  6057. protocol: 'reading',
  6058. fn: function (){
  6059. var self=this;
  6060. return smalltalk.withContext(function($ctx1) {
  6061. var $2,$1;
  6062. $2=self._atEnd();
  6063. if(! smalltalk.assert($2)){
  6064. $1=_st(self._collection())._at_(_st(self._position()).__plus((1)));
  6065. };
  6066. return $1;
  6067. }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.Stream)})},
  6068. args: [],
  6069. source: "peek\x0a\x09^ self atEnd ifFalse: [\x0a\x09\x09self collection at: self position + 1 ]",
  6070. messageSends: ["ifFalse:", "atEnd", "at:", "collection", "+", "position"],
  6071. referencedClasses: []
  6072. }),
  6073. smalltalk.Stream);
  6074. smalltalk.addMethod(
  6075. smalltalk.method({
  6076. selector: "position",
  6077. protocol: 'accessing',
  6078. fn: function (){
  6079. var self=this;
  6080. return smalltalk.withContext(function($ctx1) {
  6081. var $2,$1;
  6082. $2=self["@position"];
  6083. if(($receiver = $2) == nil || $receiver == null){
  6084. self["@position"]=(0);
  6085. $1=self["@position"];
  6086. } else {
  6087. $1=$2;
  6088. };
  6089. return $1;
  6090. }, function($ctx1) {$ctx1.fill(self,"position",{},smalltalk.Stream)})},
  6091. args: [],
  6092. source: "position\x0a\x09^ position ifNil: [ position := 0 ]",
  6093. messageSends: ["ifNil:"],
  6094. referencedClasses: []
  6095. }),
  6096. smalltalk.Stream);
  6097. smalltalk.addMethod(
  6098. smalltalk.method({
  6099. selector: "position:",
  6100. protocol: 'accessing',
  6101. fn: function (anInteger){
  6102. var self=this;
  6103. return smalltalk.withContext(function($ctx1) {
  6104. self["@position"]=anInteger;
  6105. return self}, function($ctx1) {$ctx1.fill(self,"position:",{anInteger:anInteger},smalltalk.Stream)})},
  6106. args: ["anInteger"],
  6107. source: "position: anInteger\x0a\x09position := anInteger",
  6108. messageSends: [],
  6109. referencedClasses: []
  6110. }),
  6111. smalltalk.Stream);
  6112. smalltalk.addMethod(
  6113. smalltalk.method({
  6114. selector: "reset",
  6115. protocol: 'actions',
  6116. fn: function (){
  6117. var self=this;
  6118. return smalltalk.withContext(function($ctx1) {
  6119. self._position_((0));
  6120. return self}, function($ctx1) {$ctx1.fill(self,"reset",{},smalltalk.Stream)})},
  6121. args: [],
  6122. source: "reset\x0a\x09self position: 0",
  6123. messageSends: ["position:"],
  6124. referencedClasses: []
  6125. }),
  6126. smalltalk.Stream);
  6127. smalltalk.addMethod(
  6128. smalltalk.method({
  6129. selector: "resetContents",
  6130. protocol: 'actions',
  6131. fn: function (){
  6132. var self=this;
  6133. return smalltalk.withContext(function($ctx1) {
  6134. self._reset();
  6135. self._setStreamSize_((0));
  6136. return self}, function($ctx1) {$ctx1.fill(self,"resetContents",{},smalltalk.Stream)})},
  6137. args: [],
  6138. source: "resetContents\x0a\x09self reset.\x0a\x09self setStreamSize: 0",
  6139. messageSends: ["reset", "setStreamSize:"],
  6140. referencedClasses: []
  6141. }),
  6142. smalltalk.Stream);
  6143. smalltalk.addMethod(
  6144. smalltalk.method({
  6145. selector: "setCollection:",
  6146. protocol: 'accessing',
  6147. fn: function (aCollection){
  6148. var self=this;
  6149. return smalltalk.withContext(function($ctx1) {
  6150. self["@collection"]=aCollection;
  6151. return self}, function($ctx1) {$ctx1.fill(self,"setCollection:",{aCollection:aCollection},smalltalk.Stream)})},
  6152. args: ["aCollection"],
  6153. source: "setCollection: aCollection\x0a\x09collection := aCollection",
  6154. messageSends: [],
  6155. referencedClasses: []
  6156. }),
  6157. smalltalk.Stream);
  6158. smalltalk.addMethod(
  6159. smalltalk.method({
  6160. selector: "setStreamSize:",
  6161. protocol: 'accessing',
  6162. fn: function (anInteger){
  6163. var self=this;
  6164. return smalltalk.withContext(function($ctx1) {
  6165. self["@streamSize"]=anInteger;
  6166. return self}, function($ctx1) {$ctx1.fill(self,"setStreamSize:",{anInteger:anInteger},smalltalk.Stream)})},
  6167. args: ["anInteger"],
  6168. source: "setStreamSize: anInteger\x0a\x09streamSize := anInteger",
  6169. messageSends: [],
  6170. referencedClasses: []
  6171. }),
  6172. smalltalk.Stream);
  6173. smalltalk.addMethod(
  6174. smalltalk.method({
  6175. selector: "setToEnd",
  6176. protocol: 'positioning',
  6177. fn: function (){
  6178. var self=this;
  6179. return smalltalk.withContext(function($ctx1) {
  6180. self._position_(self._size());
  6181. return self}, function($ctx1) {$ctx1.fill(self,"setToEnd",{},smalltalk.Stream)})},
  6182. args: [],
  6183. source: "setToEnd\x0a\x09self position: self size",
  6184. messageSends: ["position:", "size"],
  6185. referencedClasses: []
  6186. }),
  6187. smalltalk.Stream);
  6188. smalltalk.addMethod(
  6189. smalltalk.method({
  6190. selector: "size",
  6191. protocol: 'accessing',
  6192. fn: function (){
  6193. var self=this;
  6194. return smalltalk.withContext(function($ctx1) {
  6195. var $1;
  6196. $1=self._streamSize();
  6197. return $1;
  6198. }, function($ctx1) {$ctx1.fill(self,"size",{},smalltalk.Stream)})},
  6199. args: [],
  6200. source: "size\x0a\x09^ self streamSize",
  6201. messageSends: ["streamSize"],
  6202. referencedClasses: []
  6203. }),
  6204. smalltalk.Stream);
  6205. smalltalk.addMethod(
  6206. smalltalk.method({
  6207. selector: "skip:",
  6208. protocol: 'positioning',
  6209. fn: function (anInteger){
  6210. var self=this;
  6211. return smalltalk.withContext(function($ctx1) {
  6212. self._position_(_st(_st(self._position()).__plus(anInteger))._min_max_(self._size(),(0)));
  6213. return self}, function($ctx1) {$ctx1.fill(self,"skip:",{anInteger:anInteger},smalltalk.Stream)})},
  6214. args: ["anInteger"],
  6215. source: "skip: anInteger\x0a\x09self position: ((self position + anInteger) min: self size max: 0)",
  6216. messageSends: ["position:", "min:max:", "+", "position", "size"],
  6217. referencedClasses: []
  6218. }),
  6219. smalltalk.Stream);
  6220. smalltalk.addMethod(
  6221. smalltalk.method({
  6222. selector: "streamSize",
  6223. protocol: 'accessing',
  6224. fn: function (){
  6225. var self=this;
  6226. return smalltalk.withContext(function($ctx1) {
  6227. var $1;
  6228. $1=self["@streamSize"];
  6229. return $1;
  6230. }, function($ctx1) {$ctx1.fill(self,"streamSize",{},smalltalk.Stream)})},
  6231. args: [],
  6232. source: "streamSize\x0a\x09^ streamSize",
  6233. messageSends: [],
  6234. referencedClasses: []
  6235. }),
  6236. smalltalk.Stream);
  6237. smalltalk.addMethod(
  6238. smalltalk.method({
  6239. selector: "write:",
  6240. protocol: 'writing',
  6241. fn: function (anObject){
  6242. var self=this;
  6243. return smalltalk.withContext(function($ctx1) {
  6244. _st(anObject)._putOn_(self);
  6245. return self}, function($ctx1) {$ctx1.fill(self,"write:",{anObject:anObject},smalltalk.Stream)})},
  6246. args: ["anObject"],
  6247. source: "write: anObject\x0a\x09anObject putOn: self",
  6248. messageSends: ["putOn:"],
  6249. referencedClasses: []
  6250. }),
  6251. smalltalk.Stream);
  6252. smalltalk.addMethod(
  6253. smalltalk.method({
  6254. selector: "on:",
  6255. protocol: 'instance creation',
  6256. fn: function (aCollection){
  6257. var self=this;
  6258. return smalltalk.withContext(function($ctx1) {
  6259. var $2,$3,$1;
  6260. $2=self._new();
  6261. _st($2)._setCollection_(aCollection);
  6262. _st($2)._setStreamSize_(_st(aCollection)._size());
  6263. $3=_st($2)._yourself();
  6264. $1=$3;
  6265. return $1;
  6266. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},smalltalk.Stream.klass)})},
  6267. args: ["aCollection"],
  6268. source: "on: aCollection\x0a\x09\x09^ self new\x0a\x09\x09setCollection: aCollection;\x0a\x09\x09setStreamSize: aCollection size;\x0a\x09\x09yourself",
  6269. messageSends: ["setCollection:", "new", "setStreamSize:", "size", "yourself"],
  6270. referencedClasses: []
  6271. }),
  6272. smalltalk.Stream.klass);
  6273. smalltalk.addClass('StringStream', smalltalk.Stream, [], 'Kernel-Collections');
  6274. smalltalk.StringStream.comment="I am a Stream specific to `String` objects.";
  6275. smalltalk.addMethod(
  6276. smalltalk.method({
  6277. selector: "cr",
  6278. protocol: 'writing',
  6279. fn: function (){
  6280. var self=this;
  6281. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  6282. return smalltalk.withContext(function($ctx1) {
  6283. var $1;
  6284. $1=self._nextPutAll_(_st($String())._cr());
  6285. return $1;
  6286. }, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.StringStream)})},
  6287. args: [],
  6288. source: "cr\x0a\x09^ self nextPutAll: String cr",
  6289. messageSends: ["nextPutAll:", "cr"],
  6290. referencedClasses: ["String"]
  6291. }),
  6292. smalltalk.StringStream);
  6293. smalltalk.addMethod(
  6294. smalltalk.method({
  6295. selector: "crlf",
  6296. protocol: 'writing',
  6297. fn: function (){
  6298. var self=this;
  6299. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  6300. return smalltalk.withContext(function($ctx1) {
  6301. var $1;
  6302. $1=self._nextPutAll_(_st($String())._crlf());
  6303. return $1;
  6304. }, function($ctx1) {$ctx1.fill(self,"crlf",{},smalltalk.StringStream)})},
  6305. args: [],
  6306. source: "crlf\x0a\x09^ self nextPutAll: String crlf",
  6307. messageSends: ["nextPutAll:", "crlf"],
  6308. referencedClasses: ["String"]
  6309. }),
  6310. smalltalk.StringStream);
  6311. smalltalk.addMethod(
  6312. smalltalk.method({
  6313. selector: "lf",
  6314. protocol: 'writing',
  6315. fn: function (){
  6316. var self=this;
  6317. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  6318. return smalltalk.withContext(function($ctx1) {
  6319. var $1;
  6320. $1=self._nextPutAll_(_st($String())._lf());
  6321. return $1;
  6322. }, function($ctx1) {$ctx1.fill(self,"lf",{},smalltalk.StringStream)})},
  6323. args: [],
  6324. source: "lf\x0a\x09^ self nextPutAll: String lf",
  6325. messageSends: ["nextPutAll:", "lf"],
  6326. referencedClasses: ["String"]
  6327. }),
  6328. smalltalk.StringStream);
  6329. smalltalk.addMethod(
  6330. smalltalk.method({
  6331. selector: "next:",
  6332. protocol: 'reading',
  6333. fn: function (anInteger){
  6334. var self=this;
  6335. var tempCollection;
  6336. return smalltalk.withContext(function($ctx1) {
  6337. var $1,$2;
  6338. tempCollection=_st(_st(self._collection())._class())._new();
  6339. _st(anInteger)._timesRepeat_((function(){
  6340. return smalltalk.withContext(function($ctx2) {
  6341. $1=self._atEnd();
  6342. if(! smalltalk.assert($1)){
  6343. tempCollection=_st(tempCollection).__comma(self._next());
  6344. return tempCollection;
  6345. };
  6346. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  6347. $2=tempCollection;
  6348. return $2;
  6349. }, function($ctx1) {$ctx1.fill(self,"next:",{anInteger:anInteger,tempCollection:tempCollection},smalltalk.StringStream)})},
  6350. args: ["anInteger"],
  6351. 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",
  6352. messageSends: ["new", "class", "collection", "timesRepeat:", "ifFalse:", "atEnd", ",", "next"],
  6353. referencedClasses: []
  6354. }),
  6355. smalltalk.StringStream);
  6356. smalltalk.addMethod(
  6357. smalltalk.method({
  6358. selector: "nextPut:",
  6359. protocol: 'writing',
  6360. fn: function (aString){
  6361. var self=this;
  6362. return smalltalk.withContext(function($ctx1) {
  6363. self._nextPutAll_(aString);
  6364. return self}, function($ctx1) {$ctx1.fill(self,"nextPut:",{aString:aString},smalltalk.StringStream)})},
  6365. args: ["aString"],
  6366. source: "nextPut: aString\x0a\x09self nextPutAll: aString",
  6367. messageSends: ["nextPutAll:"],
  6368. referencedClasses: []
  6369. }),
  6370. smalltalk.StringStream);
  6371. smalltalk.addMethod(
  6372. smalltalk.method({
  6373. selector: "nextPutAll:",
  6374. protocol: 'writing',
  6375. fn: function (aString){
  6376. var self=this;
  6377. var pre,post;
  6378. return smalltalk.withContext(function($ctx1) {
  6379. var $1,$3,$2,$4,$5,$6,$9,$8,$10,$7,$11,$12,$14,$13;
  6380. $1=self._atEnd();
  6381. if(smalltalk.assert($1)){
  6382. $3=self._collection();
  6383. $ctx1.sendIdx["collection"]=1;
  6384. $2=_st($3).__comma(aString);
  6385. $ctx1.sendIdx[","]=1;
  6386. self._setCollection_($2);
  6387. $ctx1.sendIdx["setCollection:"]=1;
  6388. } else {
  6389. $4=self._collection();
  6390. $ctx1.sendIdx["collection"]=2;
  6391. $5=self._position();
  6392. $ctx1.sendIdx["position"]=1;
  6393. pre=_st($4)._copyFrom_to_((1),$5);
  6394. $ctx1.sendIdx["copyFrom:to:"]=1;
  6395. pre;
  6396. $6=self._collection();
  6397. $ctx1.sendIdx["collection"]=3;
  6398. $9=self._position();
  6399. $ctx1.sendIdx["position"]=2;
  6400. $8=_st($9).__plus((1));
  6401. $ctx1.sendIdx["+"]=2;
  6402. $10=_st(aString)._size();
  6403. $ctx1.sendIdx["size"]=1;
  6404. $7=_st($8).__plus($10);
  6405. $ctx1.sendIdx["+"]=1;
  6406. $11=_st(self._collection())._size();
  6407. $ctx1.sendIdx["size"]=2;
  6408. post=_st($6)._copyFrom_to_($7,$11);
  6409. post;
  6410. $12=_st(_st(pre).__comma(aString)).__comma(post);
  6411. $ctx1.sendIdx[","]=2;
  6412. self._setCollection_($12);
  6413. };
  6414. $14=self._position();
  6415. $ctx1.sendIdx["position"]=3;
  6416. $13=_st($14).__plus(_st(aString)._size());
  6417. self._position_($13);
  6418. self._setStreamSize_(_st(self._streamSize())._max_(self._position()));
  6419. return self}, function($ctx1) {$ctx1.fill(self,"nextPutAll:",{aString:aString,pre:pre,post:post},smalltalk.StringStream)})},
  6420. args: ["aString"],
  6421. 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)",
  6422. messageSends: ["ifTrue:ifFalse:", "atEnd", "setCollection:", ",", "collection", "copyFrom:to:", "position", "+", "size", "position:", "setStreamSize:", "max:", "streamSize"],
  6423. referencedClasses: []
  6424. }),
  6425. smalltalk.StringStream);
  6426. smalltalk.addMethod(
  6427. smalltalk.method({
  6428. selector: "nextPutString:",
  6429. protocol: 'writing',
  6430. fn: function (aString){
  6431. var self=this;
  6432. return smalltalk.withContext(function($ctx1) {
  6433. self._nextPutAll_(aString);
  6434. return self}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},smalltalk.StringStream)})},
  6435. args: ["aString"],
  6436. source: "nextPutString: aString\x0a\x09self nextPutAll: aString",
  6437. messageSends: ["nextPutAll:"],
  6438. referencedClasses: []
  6439. }),
  6440. smalltalk.StringStream);
  6441. smalltalk.addMethod(
  6442. smalltalk.method({
  6443. selector: "space",
  6444. protocol: 'writing',
  6445. fn: function (){
  6446. var self=this;
  6447. return smalltalk.withContext(function($ctx1) {
  6448. self._nextPut_(" ");
  6449. return self}, function($ctx1) {$ctx1.fill(self,"space",{},smalltalk.StringStream)})},
  6450. args: [],
  6451. source: "space\x0a\x09self nextPut: ' '",
  6452. messageSends: ["nextPut:"],
  6453. referencedClasses: []
  6454. }),
  6455. smalltalk.StringStream);
  6456. smalltalk.addMethod(
  6457. smalltalk.method({
  6458. selector: "tab",
  6459. protocol: 'writing',
  6460. fn: function (){
  6461. var self=this;
  6462. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  6463. return smalltalk.withContext(function($ctx1) {
  6464. var $1;
  6465. $1=self._nextPutAll_(_st($String())._tab());
  6466. return $1;
  6467. }, function($ctx1) {$ctx1.fill(self,"tab",{},smalltalk.StringStream)})},
  6468. args: [],
  6469. source: "tab\x0a\x09^ self nextPutAll: String tab",
  6470. messageSends: ["nextPutAll:", "tab"],
  6471. referencedClasses: ["String"]
  6472. }),
  6473. smalltalk.StringStream);
  6474. });