2
0

Kernel-Collections.js 194 KB

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