Kernel-Collections.js 183 KB

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