1
0

Kernel-Collections.js 189 KB

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