Kernel-Collections.js 184 KB

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