Kernel.js 130 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459
  1. smalltalk.addClass('Object', smalltalk.nil, [], 'Kernel');
  2. smalltalk.addMethod(
  3. '__eq',
  4. smalltalk.method({
  5. selector: '=',
  6. category: 'comparing',
  7. fn: function (anObject) {
  8. var self = this;
  9. return function () {return self == anObject;}();
  10. return self;
  11. },
  12. source: unescape('%3D%20anObject%0A%09%5E%7B%27return%20self%20%3D%3D%20anObject%27%7D%0A')}),
  13. smalltalk.Object);
  14. smalltalk.addMethod(
  15. '_~_eq',
  16. smalltalk.method({
  17. selector: '~=',
  18. category: 'comparing',
  19. fn: function (anObject) {
  20. var self = this;
  21. return self.__eq(anObject).__eq_eq(false);
  22. return self;
  23. },
  24. source: unescape('%7E%3D%20anObject%0A%09%5E%28self%20%3D%20anObject%29%20%3D%3D%20false%0A')}),
  25. smalltalk.Object);
  26. smalltalk.addMethod(
  27. '_initialize',
  28. smalltalk.method({
  29. selector: 'initialize',
  30. category: 'initialization',
  31. fn: function () {
  32. var self = this;
  33. return self;
  34. },
  35. source: unescape('initialize%0A')}),
  36. smalltalk.Object);
  37. smalltalk.addMethod(
  38. '_yourself',
  39. smalltalk.method({
  40. selector: 'yourself',
  41. category: 'accessing',
  42. fn: function () {
  43. var self = this;
  44. return self;
  45. return self;
  46. },
  47. source: unescape('yourself%0A%09%5Eself%0A')}),
  48. smalltalk.Object);
  49. smalltalk.addMethod(
  50. '_class',
  51. smalltalk.method({
  52. selector: 'class',
  53. category: 'accessing',
  54. fn: function () {
  55. var self = this;
  56. return function () {return self.klass;}();
  57. return self;
  58. },
  59. source: unescape('class%0A%09%5E%7B%27return%20self.klass%27%7D%0A')}),
  60. smalltalk.Object);
  61. smalltalk.addMethod(
  62. '_size',
  63. smalltalk.method({
  64. selector: 'size',
  65. category: 'accessing',
  66. fn: function () {
  67. var self = this;
  68. self._error_("Object not indexable");
  69. return self;
  70. },
  71. source: unescape('size%0A%09self%20error%3A%20%27Object%20not%20indexable%27%0A')}),
  72. smalltalk.Object);
  73. smalltalk.addMethod(
  74. '_copy',
  75. smalltalk.method({
  76. selector: 'copy',
  77. category: 'copying',
  78. fn: function () {
  79. var self = this;
  80. return self._shallowCopy()._postCopy();
  81. return self;
  82. },
  83. source: unescape('copy%0A%09%5Eself%20shallowCopy%20postCopy%0A')}),
  84. smalltalk.Object);
  85. smalltalk.addMethod(
  86. '_shallowCopy',
  87. smalltalk.method({
  88. selector: 'shallowCopy',
  89. category: 'copying',
  90. fn: function () {
  91. var self = this;
  92. return function () {var copy = self.klass._new();for (var i in self) {if (/^@.+/.test(i)) {copy[i] = self[i];}}return copy;}();
  93. return self;
  94. },
  95. source: unescape('shallowCopy%0A%09%5E%7B%27%0A%09%20%20%20%20var%20copy%20%3D%20self.klass._new%28%29%3B%0A%09%20%20%20%20for%28var%20i%20in%20self%29%20%7B%0A%09%09if%28/%5E@.+/.test%28i%29%29%20%7B%0A%09%09%20%20%20%20copy%5Bi%5D%20%3D%20self%5Bi%5D%3B%0A%09%09%7D%0A%09%20%20%20%20%7D%0A%09%20%20%20%20return%20copy%3B%0A%09%27%7D%0A')}),
  96. smalltalk.Object);
  97. smalltalk.addMethod(
  98. '_deepCopy',
  99. smalltalk.method({
  100. selector: 'deepCopy',
  101. category: 'copying',
  102. fn: function () {
  103. var self = this;
  104. (function () {var copy = self.klass._new();for (var i in self) {if (/^@.+/.test(i)) {copy[i] = self[i]._deepCopy();}}return copy;}());
  105. return self;
  106. },
  107. source: unescape('deepCopy%0A%09%7B%27%09%20%20%20%20%0A%09%20%20%20%20var%20copy%20%3D%20self.klass._new%28%29%3B%0A%09%20%20%20%20for%28var%20i%20in%20self%29%20%7B%0A%09%09if%28/%5E@.+/.test%28i%29%29%20%7B%0A%09%09%20%20%20%20copy%5Bi%5D%20%3D%20self%5Bi%5D._deepCopy%28%29%3B%0A%09%09%7D%0A%09%20%20%20%20%7D%0A%09%20%20%20%20return%20copy%3B%0A%09%27%7D.%0A')}),
  108. smalltalk.Object);
  109. smalltalk.addMethod(
  110. '_postCopy',
  111. smalltalk.method({
  112. selector: 'postCopy',
  113. category: 'copying',
  114. fn: function () {
  115. var self = this;
  116. return self;
  117. },
  118. source: unescape('postCopy%0A')}),
  119. smalltalk.Object);
  120. smalltalk.addMethod(
  121. '__minus_gt',
  122. smalltalk.method({
  123. selector: '->',
  124. category: 'converting',
  125. fn: function (anObject) {
  126. var self = this;
  127. return smalltalk.Association._key_value_(self, anObject);
  128. return self;
  129. },
  130. source: unescape('-%3E%20anObject%0A%09%5EAssociation%20key%3A%20self%20value%3A%20anObject%0A')}),
  131. smalltalk.Object);
  132. smalltalk.addMethod(
  133. '_asString',
  134. smalltalk.method({
  135. selector: 'asString',
  136. category: 'converting',
  137. fn: function () {
  138. var self = this;
  139. return self._printString();
  140. return self;
  141. },
  142. source: unescape('asString%0A%09%5Eself%20printString%0A')}),
  143. smalltalk.Object);
  144. smalltalk.addMethod(
  145. '_asJavascript',
  146. smalltalk.method({
  147. selector: 'asJavascript',
  148. category: 'converting',
  149. fn: function () {
  150. var self = this;
  151. return self._asString();
  152. return self;
  153. },
  154. source: unescape('asJavascript%0A%09%5Eself%20asString%0A')}),
  155. smalltalk.Object);
  156. smalltalk.addMethod(
  157. '_perform_',
  158. smalltalk.method({
  159. selector: 'perform:',
  160. category: 'message handling',
  161. fn: function (aSymbol) {
  162. var self = this;
  163. return self._perform_withArguments_(aSymbol, []);
  164. return self;
  165. },
  166. source: unescape('perform%3A%20aSymbol%0A%09%5Eself%20perform%3A%20aSymbol%20withArguments%3A%20%23%28%29%0A')}),
  167. smalltalk.Object);
  168. smalltalk.addMethod(
  169. '_perform_withArguments_',
  170. smalltalk.method({
  171. selector: 'perform:withArguments:',
  172. category: 'error handling',
  173. fn: function (aSymbol, aCollection) {
  174. var self = this;
  175. return self._basicPerform_withArguments_(aSymbol._asSelector(), aCollection);
  176. return self;
  177. },
  178. source: unescape('perform%3A%20aSymbol%20withArguments%3A%20aCollection%0A%09%5Eself%20basicPerform%3A%20aSymbol%20asSelector%20withArguments%3A%20aCollection%0A')}),
  179. smalltalk.Object);
  180. smalltalk.addMethod(
  181. '_instVarAt_',
  182. smalltalk.method({
  183. selector: 'instVarAt:',
  184. category: 'accessing',
  185. fn: function (aString) {
  186. var self = this;
  187. return function () {var value = self["@" + aString];if (typeof value == "undefined") {return nil;} else {return value;}}();
  188. return self;
  189. },
  190. source: unescape('instVarAt%3A%20aString%0A%09%5E%7B%27%0A%09%20%20%20%20var%20value%20%3D%20self%5B%27%27@%27%27+aString%5D%3B%0A%09%20%20%20%20if%28typeof%28value%29%20%3D%3D%20%27%27undefined%27%27%29%20%7B%0A%09%09return%20nil%3B%0A%09%20%20%20%20%7D%20else%20%7B%0A%09%09return%20value%3B%0A%09%20%20%20%20%7D%0A%09%27%7D%0A')}),
  191. smalltalk.Object);
  192. smalltalk.addMethod(
  193. '_instVarAt_put_',
  194. smalltalk.method({
  195. selector: 'instVarAt:put:',
  196. category: 'accessing',
  197. fn: function (aString, anObject) {
  198. var self = this;
  199. return function () {self["@" + aString] = anObject;}();
  200. return self;
  201. },
  202. source: unescape('instVarAt%3A%20aString%20put%3A%20anObject%0A%09%5E%7B%27self%5B%27%27@%27%27%20+%20aString%5D%20%3D%20anObject%27%7D%0A')}),
  203. smalltalk.Object);
  204. smalltalk.addMethod(
  205. '_basicAt_',
  206. smalltalk.method({
  207. selector: 'basicAt:',
  208. category: 'accessing',
  209. fn: function (aString) {
  210. var self = this;
  211. return function () {var value = self[aString];if (typeof value == "undefined") {return nil;} else {return value;}}();
  212. return self;
  213. },
  214. source: unescape('basicAt%3A%20aString%0A%09%5E%7B%27%0A%09%20%20%20%20var%20value%20%3D%20self%5BaString%5D%3B%0A%09%20%20%20%20if%28typeof%28value%29%20%3D%3D%20%27%27undefined%27%27%29%20%7B%0A%09%09return%20nil%3B%0A%09%20%20%20%20%7D%20else%20%7B%0A%09%09return%20value%3B%0A%09%20%20%20%20%7D%0A%09%27%7D%0A')}),
  215. smalltalk.Object);
  216. smalltalk.addMethod(
  217. '_basicAt_put_',
  218. smalltalk.method({
  219. selector: 'basicAt:put:',
  220. category: 'accessing',
  221. fn: function (aString, anObject) {
  222. var self = this;
  223. return function () {return self[aString] = anObject;}();
  224. return self;
  225. },
  226. source: unescape('basicAt%3A%20aString%20put%3A%20anObject%0A%09%5E%7B%27return%20self%5BaString%5D%20%3D%20anObject%27%7D%0A')}),
  227. smalltalk.Object);
  228. smalltalk.addMethod(
  229. '_error_',
  230. smalltalk.method({
  231. selector: 'error:',
  232. category: 'error handling',
  233. fn: function (aString) {
  234. var self = this;
  235. smalltalk.Error._signal_(aString);
  236. return self;
  237. },
  238. source: unescape('error%3A%20aString%0A%09Error%20signal%3A%20aString%0A')}),
  239. smalltalk.Object);
  240. smalltalk.addMethod(
  241. '_subclassResponsibility',
  242. smalltalk.method({
  243. selector: 'subclassResponsibility',
  244. category: 'error handling',
  245. fn: function () {
  246. var self = this;
  247. self._error_("This method is a responsibility of a subclass");
  248. return self;
  249. },
  250. source: unescape('subclassResponsibility%0A%09self%20error%3A%20%27This%20method%20is%20a%20responsibility%20of%20a%20subclass%27%0A')}),
  251. smalltalk.Object);
  252. smalltalk.addMethod(
  253. '_shouldNotImplement',
  254. smalltalk.method({
  255. selector: 'shouldNotImplement',
  256. category: 'error handling',
  257. fn: function () {
  258. var self = this;
  259. self._error_("This method should not be implemented in ".__comma(self._class()._name()));
  260. return self;
  261. },
  262. source: unescape('shouldNotImplement%0A%09self%20error%3A%20%27This%20method%20should%20not%20be%20implemented%20in%20%27%2C%20self%20class%20name%0A')}),
  263. smalltalk.Object);
  264. smalltalk.addMethod(
  265. '_try_catch_',
  266. smalltalk.method({
  267. selector: 'try:catch:',
  268. category: 'error handling',
  269. fn: function (aBlock, anotherBlock) {
  270. var self = this;
  271. (function () {try {aBlock();} catch (e) {anotherBlock(e);}}());
  272. return self;
  273. },
  274. source: unescape('try%3A%20aBlock%20catch%3A%20anotherBlock%0A%09%7B%27try%7BaBlock%28%29%7D%20catch%28e%29%20%7BanotherBlock%28e%29%7D%27%7D%0A')}),
  275. smalltalk.Object);
  276. smalltalk.addMethod(
  277. '_printString',
  278. smalltalk.method({
  279. selector: 'printString',
  280. category: 'printing',
  281. fn: function () {
  282. var self = this;
  283. return "a ".__comma(self._class()._name());
  284. return self;
  285. },
  286. source: unescape('printString%0A%09%5E%27a%20%27%2C%20self%20class%20name%0A')}),
  287. smalltalk.Object);
  288. smalltalk.addMethod(
  289. '_printNl',
  290. smalltalk.method({
  291. selector: 'printNl',
  292. category: 'printing',
  293. fn: function () {
  294. var self = this;
  295. (function () {console.log(self);}());
  296. return self;
  297. },
  298. source: unescape('printNl%0A%09%7B%27console.log%28self%29%27%7D%0A')}),
  299. smalltalk.Object);
  300. smalltalk.addMethod(
  301. '_isKindOf_',
  302. smalltalk.method({
  303. selector: 'isKindOf:',
  304. category: 'testing',
  305. fn: function (aClass) {
  306. var self = this;
  307. return self._isMemberOf_(aClass)._ifTrue_ifFalse_(function () {return true;}, function () {return self._class()._inheritsFrom_(aClass);});
  308. return self;
  309. },
  310. source: unescape('isKindOf%3A%20aClass%0A%09%5E%28self%20isMemberOf%3A%20aClass%29%0A%09%20%20%20%20ifTrue%3A%20%5Btrue%5D%0A%09%20%20%20%20ifFalse%3A%20%5Bself%20class%20inheritsFrom%3A%20aClass%5D%0A')}),
  311. smalltalk.Object);
  312. smalltalk.addMethod(
  313. '_isMemberOf_',
  314. smalltalk.method({
  315. selector: 'isMemberOf:',
  316. category: 'testing',
  317. fn: function (aClass) {
  318. var self = this;
  319. return self._class().__eq(aClass);
  320. return self;
  321. },
  322. source: unescape('isMemberOf%3A%20aClass%0A%09%5Eself%20class%20%3D%20aClass%0A')}),
  323. smalltalk.Object);
  324. smalltalk.addMethod(
  325. '_ifNil_',
  326. smalltalk.method({
  327. selector: 'ifNil:',
  328. category: 'testing',
  329. fn: function (aBlock) {
  330. var self = this;
  331. return self;
  332. return self;
  333. },
  334. source: unescape('ifNil%3A%20aBlock%0A%09%5Eself%0A')}),
  335. smalltalk.Object);
  336. smalltalk.addMethod(
  337. '_ifNil_ifNotNil_',
  338. smalltalk.method({
  339. selector: 'ifNil:ifNotNil:',
  340. category: 'testing',
  341. fn: function (aBlock, anotherBlock) {
  342. var self = this;
  343. return anotherBlock._value();
  344. return self;
  345. },
  346. source: unescape('ifNil%3A%20aBlock%20ifNotNil%3A%20anotherBlock%0A%09%5EanotherBlock%20value%0A')}),
  347. smalltalk.Object);
  348. smalltalk.addMethod(
  349. '_ifNotNil_',
  350. smalltalk.method({
  351. selector: 'ifNotNil:',
  352. category: 'testing',
  353. fn: function (aBlock) {
  354. var self = this;
  355. return aBlock._value();
  356. return self;
  357. },
  358. source: unescape('ifNotNil%3A%20aBlock%0A%09%5EaBlock%20value%0A')}),
  359. smalltalk.Object);
  360. smalltalk.addMethod(
  361. '_ifNotNil_ifNil_',
  362. smalltalk.method({
  363. selector: 'ifNotNil:ifNil:',
  364. category: 'testing',
  365. fn: function (aBlock, anotherBlock) {
  366. var self = this;
  367. return aBlock._value();
  368. return self;
  369. },
  370. source: unescape('ifNotNil%3A%20aBlock%20ifNil%3A%20anotherBlock%0A%09%5EaBlock%20value%0A')}),
  371. smalltalk.Object);
  372. smalltalk.addMethod(
  373. '_isNil',
  374. smalltalk.method({
  375. selector: 'isNil',
  376. category: 'testing',
  377. fn: function () {
  378. var self = this;
  379. return false;
  380. return self;
  381. },
  382. source: unescape('isNil%0A%09%5Efalse%0A')}),
  383. smalltalk.Object);
  384. smalltalk.addMethod(
  385. '_notNil',
  386. smalltalk.method({
  387. selector: 'notNil',
  388. category: 'testing',
  389. fn: function () {
  390. var self = this;
  391. return self._isNil()._not();
  392. return self;
  393. },
  394. source: unescape('notNil%0A%09%5Eself%20isNil%20not%0A')}),
  395. smalltalk.Object);
  396. smalltalk.addMethod(
  397. '_isClass',
  398. smalltalk.method({
  399. selector: 'isClass',
  400. category: 'testing',
  401. fn: function () {
  402. var self = this;
  403. return false;
  404. return self;
  405. },
  406. source: unescape('isClass%0A%09%5Efalse%0A')}),
  407. smalltalk.Object);
  408. smalltalk.addMethod(
  409. '_isMetaclass',
  410. smalltalk.method({
  411. selector: 'isMetaclass',
  412. category: 'testing',
  413. fn: function () {
  414. var self = this;
  415. return false;
  416. return self;
  417. },
  418. source: unescape('isMetaclass%0A%09%5Efalse%0A')}),
  419. smalltalk.Object);
  420. smalltalk.addMethod(
  421. '_isNumber',
  422. smalltalk.method({
  423. selector: 'isNumber',
  424. category: 'testing',
  425. fn: function () {
  426. var self = this;
  427. return false;
  428. return self;
  429. },
  430. source: unescape('isNumber%0A%09%5Efalse%0A')}),
  431. smalltalk.Object);
  432. smalltalk.addMethod(
  433. '_isString',
  434. smalltalk.method({
  435. selector: 'isString',
  436. category: 'testing',
  437. fn: function () {
  438. var self = this;
  439. return false;
  440. return self;
  441. },
  442. source: unescape('isString%0A%09%5Efalse%0A')}),
  443. smalltalk.Object);
  444. smalltalk.addMethod(
  445. '_isParseFailure',
  446. smalltalk.method({
  447. selector: 'isParseFailure',
  448. category: 'testing',
  449. fn: function () {
  450. var self = this;
  451. return false;
  452. return self;
  453. },
  454. source: unescape('isParseFailure%0A%09%5Efalse%0A')}),
  455. smalltalk.Object);
  456. smalltalk.addMethod(
  457. '_basicPerform_',
  458. smalltalk.method({
  459. selector: 'basicPerform:',
  460. category: 'error handling',
  461. fn: function (aSymbol) {
  462. var self = this;
  463. return self._basicPerform_withArguments_(aSymbol, []);
  464. return self;
  465. },
  466. source: unescape('basicPerform%3A%20aSymbol%20%0A%20%20%20%20%5Eself%20basicPerform%3A%20aSymbol%20withArguments%3A%20%23%28%29%0A')}),
  467. smalltalk.Object);
  468. smalltalk.addMethod(
  469. '_basicPerform_withArguments_',
  470. smalltalk.method({
  471. selector: 'basicPerform:withArguments:',
  472. category: 'error handling',
  473. fn: function (aSymbol, aCollection) {
  474. var self = this;
  475. return function () {return self[aSymbol].apply(self, aCollection);}();
  476. return self;
  477. },
  478. source: unescape('basicPerform%3A%20aSymbol%20withArguments%3A%20aCollection%0A%09%5E%7B%27return%20self%5BaSymbol%5D.apply%28self%2C%20aCollection%29%3B%27%7D%0A')}),
  479. smalltalk.Object);
  480. smalltalk.addMethod(
  481. '_appendToBrush_',
  482. smalltalk.method({
  483. selector: 'appendToBrush:',
  484. category: '*Canvas',
  485. fn: function (aTagBrush) {
  486. var self = this;
  487. aTagBrush._append_(self._asString());
  488. return self;
  489. },
  490. source: unescape('appendToBrush%3A%20aTagBrush%0A%20%20%20%20aTagBrush%20append%3A%20self%20asString%0A')}),
  491. smalltalk.Object);
  492. smalltalk.addMethod(
  493. '_basicDelete_',
  494. smalltalk.method({
  495. selector: 'basicDelete:',
  496. category: 'accessing',
  497. fn: function (aString) {
  498. var self = this;
  499. (function () {delete self[aString];}());
  500. return self;
  501. },
  502. source: unescape('basicDelete%3A%20aString%0A%20%20%20%20%7B%27delete%20self%5BaString%5D%27%7D%0A')}),
  503. smalltalk.Object);
  504. smalltalk.addMethod(
  505. '_inspect',
  506. smalltalk.method({
  507. selector: 'inspect',
  508. category: '*IDE',
  509. fn: function () {
  510. var self = this;
  511. (function ($rec) {$rec._inspect_(self);return $rec._open();}(smalltalk.Inspector._new()));
  512. return self;
  513. },
  514. source: unescape('inspect%0A%09Inspector%20new%20%0A%09%09inspect%3A%20self%3B%0A%09%09open')}),
  515. smalltalk.Object);
  516. smalltalk.addMethod(
  517. '_inspectOn_',
  518. smalltalk.method({
  519. selector: 'inspectOn:',
  520. category: '*IDE',
  521. fn: function (anInspector) {
  522. var self = this;
  523. var variables = nil;
  524. variables = smalltalk.Dictionary._new();
  525. variables._at_put_(unescape("%23self"), self);
  526. self._class()._instanceVariableNames()._do_(function (each) {return variables._at_put_(each, self._instVarAt_(each));});
  527. (function ($rec) {$rec._setLabel_(self._printString());return $rec._setVariables_(variables);}(anInspector));
  528. return self;
  529. },
  530. source: unescape('inspectOn%3A%20anInspector%0A%09%7C%20variables%20%7C%0A%09variables%20%3A%3D%20Dictionary%20new.%0A%09variables%20at%3A%20%27%23self%27%20put%3A%20self.%0A%09self%20class%20instanceVariableNames%20do%3A%20%5B%3Aeach%20%7C%0A%09%09variables%20at%3A%20each%20put%3A%20%28self%20instVarAt%3A%20each%29%5D.%0A%09anInspector%20%0A%09%09setLabel%3A%20self%20printString%3B%0A%09%09setVariables%3A%20variables%0A%09%0A%09')}),
  531. smalltalk.Object);
  532. smalltalk.addClass('Smalltalk', smalltalk.Object, [], 'Kernel');
  533. smalltalk.addMethod(
  534. '_classes',
  535. smalltalk.method({
  536. selector: 'classes',
  537. category: 'accessing',
  538. fn: function () {
  539. var self = this;
  540. return function () {return self.classes();}();
  541. return self;
  542. },
  543. source: unescape('classes%0A%09%5E%7B%27return%20self.classes%28%29%27%7D%0A')}),
  544. smalltalk.Smalltalk);
  545. smalltalk.Smalltalk.klass.iVarNames = ['current'];
  546. smalltalk.addMethod(
  547. '_current',
  548. smalltalk.method({
  549. selector: 'current',
  550. category: 'accessing',
  551. fn: function () {
  552. var self = this;
  553. return function () {return smalltalk;}();
  554. return self;
  555. },
  556. source: unescape('current%0A%09%20%20%20%20%5E%7B%27return%20smalltalk%27%7D%0A')}),
  557. smalltalk.Smalltalk.klass);
  558. smalltalk.addClass('Behavior', smalltalk.Object, [], 'Kernel');
  559. smalltalk.addMethod(
  560. '_new',
  561. smalltalk.method({
  562. selector: 'new',
  563. category: 'instance creation',
  564. fn: function () {
  565. var self = this;
  566. return function ($rec) {$rec._initialize();return $rec._yourself();}(self._basicNew());
  567. return self;
  568. },
  569. source: unescape('new%0A%09%5Eself%20basicNew%20%0A%09%20%20%20%20initialize%3B%0A%09%20%20%20%20yourself%0A')}),
  570. smalltalk.Behavior);
  571. smalltalk.addMethod(
  572. '_basicNew',
  573. smalltalk.method({
  574. selector: 'basicNew',
  575. category: 'instance creation',
  576. fn: function () {
  577. var self = this;
  578. return function () {return new self.fn;}();
  579. return self;
  580. },
  581. source: unescape('basicNew%0A%09%5E%7B%27return%20new%20self.fn%28%29%3B%27%7D%0A')}),
  582. smalltalk.Behavior);
  583. smalltalk.addMethod(
  584. '_name',
  585. smalltalk.method({
  586. selector: 'name',
  587. category: 'accessing',
  588. fn: function () {
  589. var self = this;
  590. return function () {return self.className || nil;}();
  591. return self;
  592. },
  593. source: unescape('name%0A%09%5E%7B%27return%20self.className%20%7C%7C%20nil%27%7D%0A')}),
  594. smalltalk.Behavior);
  595. smalltalk.addMethod(
  596. '_superclass',
  597. smalltalk.method({
  598. selector: 'superclass',
  599. category: 'accessing',
  600. fn: function () {
  601. var self = this;
  602. return function () {return self.superclass || nil;}();
  603. return self;
  604. },
  605. source: unescape('superclass%0A%09%5E%7B%27return%20self.superclass%20%7C%7C%20nil%27%7D%0A')}),
  606. smalltalk.Behavior);
  607. smalltalk.addMethod(
  608. '_subclasses',
  609. smalltalk.method({
  610. selector: 'subclasses',
  611. category: 'accessing',
  612. fn: function () {
  613. var self = this;
  614. return function () {return smalltalk.subclasses(self);}();
  615. return self;
  616. },
  617. source: unescape('subclasses%0A%09%5E%7B%27return%20smalltalk.subclasses%28self%29%27%7D%0A')}),
  618. smalltalk.Behavior);
  619. smalltalk.addMethod(
  620. '_allSubclasses',
  621. smalltalk.method({
  622. selector: 'allSubclasses',
  623. category: 'accessing',
  624. fn: function () {
  625. var self = this;
  626. var result = nil;
  627. result = self._subclasses();
  628. self._subclasses()._do_(function (each) {return result._addAll_(each._allSubclasses());});
  629. return result;
  630. return self;
  631. },
  632. source: unescape('allSubclasses%0A%09%7C%20result%20%7C%0A%09result%20%3A%3D%20self%20subclasses.%0A%09self%20subclasses%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20result%20addAll%3A%20each%20allSubclasses%5D.%0A%09%5Eresult%0A')}),
  633. smalltalk.Behavior);
  634. smalltalk.addMethod(
  635. '_withAllSubclasses',
  636. smalltalk.method({
  637. selector: 'withAllSubclasses',
  638. category: 'accessing',
  639. fn: function () {
  640. var self = this;
  641. return function ($rec) {$rec._addAll_(self._allSubclasses());return $rec._yourself();}(smalltalk.Array._with_(self));
  642. return self;
  643. },
  644. source: unescape('withAllSubclasses%0A%09%5E%28Array%20with%3A%20self%29%20addAll%3A%20self%20allSubclasses%3B%20yourself%0A')}),
  645. smalltalk.Behavior);
  646. smalltalk.addMethod(
  647. '_prototype',
  648. smalltalk.method({
  649. selector: 'prototype',
  650. category: 'accessing',
  651. fn: function () {
  652. var self = this;
  653. return function () {return self.fn.prototype;}();
  654. return self;
  655. },
  656. source: unescape('prototype%0A%09%5E%7B%27return%20self.fn.prototype%27%7D%0A')}),
  657. smalltalk.Behavior);
  658. smalltalk.addMethod(
  659. '_methodDictionary',
  660. smalltalk.method({
  661. selector: 'methodDictionary',
  662. category: 'accessing',
  663. fn: function () {
  664. var self = this;
  665. return function () {var dict = smalltalk.Dictionary._new();var methods = self.fn.prototype.methods;for (var i in methods) {if (methods[i].selector) {dict._at_put_(methods[i].selector, methods[i]);}}return dict;}();
  666. return self;
  667. },
  668. source: unescape('methodDictionary%0A%09%5E%7B%27var%20dict%20%3D%20smalltalk.Dictionary._new%28%29%3B%0A%09var%20methods%20%3D%20self.fn.prototype.methods%3B%0A%09for%28var%20i%20in%20methods%29%20%7B%0A%09%09if%28methods%5Bi%5D.selector%29%20%7B%0A%09%09%09dict._at_put_%28methods%5Bi%5D.selector%2C%20methods%5Bi%5D%29%3B%0A%09%09%7D%0A%09%7D%3B%0A%09return%20dict%27%7D%0A')}),
  669. smalltalk.Behavior);
  670. smalltalk.addMethod(
  671. '_instVarNames',
  672. smalltalk.method({
  673. selector: 'instVarNames',
  674. category: '',
  675. fn: function () {
  676. var self = this;
  677. return function () {return self.iVarNames;}();
  678. return self;
  679. },
  680. source: unescape('')}),
  681. smalltalk.Behavior);
  682. smalltalk.addMethod(
  683. '_methodsFor_',
  684. smalltalk.method({
  685. selector: 'methodsFor:',
  686. category: 'accessing',
  687. fn: function (aString) {
  688. var self = this;
  689. return function ($rec) {$rec._class_category_(self, aString);return $rec._yourself();}(smalltalk.ClassCategoryReader._new());
  690. return self;
  691. },
  692. source: unescape('methodsFor%3A%20aString%0A%09%5EClassCategoryReader%20new%0A%09%20%20%20%20class%3A%20self%20category%3A%20aString%3B%0A%09%20%20%20%20yourself%0A')}),
  693. smalltalk.Behavior);
  694. smalltalk.addMethod(
  695. '_addCompiledMethod_',
  696. smalltalk.method({
  697. selector: 'addCompiledMethod:',
  698. category: 'accessing',
  699. fn: function (aMethod) {
  700. var self = this;
  701. (function () {self.fn.prototype[aMethod.selector._asSelector()] = aMethod.fn;self.fn.prototype.methods[aMethod.selector] = aMethod;}());
  702. return self;
  703. },
  704. source: unescape('addCompiledMethod%3A%20aMethod%0A%09%7B%27self.fn.prototype%5BaMethod.selector._asSelector%28%29%5D%20%3D%20aMethod.fn%3B%0A%09self.fn.prototype.methods%5BaMethod.selector%5D%20%3D%20aMethod%27%7D%0A')}),
  705. smalltalk.Behavior);
  706. smalltalk.addMethod(
  707. '_instanceVariableNames',
  708. smalltalk.method({
  709. selector: 'instanceVariableNames',
  710. category: 'accessing',
  711. fn: function () {
  712. var self = this;
  713. return function () {return self.iVarNames;}();
  714. return self;
  715. },
  716. source: unescape('instanceVariableNames%0A%09%5E%7B%27return%20self.iVarNames%27%7D%0A')}),
  717. smalltalk.Behavior);
  718. smalltalk.addMethod(
  719. '_comment',
  720. smalltalk.method({
  721. selector: 'comment',
  722. category: 'accessing',
  723. fn: function () {
  724. var self = this;
  725. return self._basicAt_("comment")._ifNil_(function () {return "";});
  726. return self;
  727. },
  728. source: unescape('comment%0A%20%20%20%20%5E%28self%20basicAt%3A%20%27comment%27%29%20ifNil%3A%20%5B%27%27%5D%0A')}),
  729. smalltalk.Behavior);
  730. smalltalk.addMethod(
  731. '_comment_',
  732. smalltalk.method({
  733. selector: 'comment:',
  734. category: 'accessing',
  735. fn: function (aString) {
  736. var self = this;
  737. self._basicAt_put_("comment", aString);
  738. return self;
  739. },
  740. source: unescape('comment%3A%20aString%0A%20%20%20%20self%20basicAt%3A%20%27comment%27%20put%3A%20aString%0A')}),
  741. smalltalk.Behavior);
  742. smalltalk.addMethod(
  743. '_commentStamp',
  744. smalltalk.method({
  745. selector: 'commentStamp',
  746. category: 'accessing',
  747. fn: function () {
  748. var self = this;
  749. return function ($rec) {$rec._class_(self);return $rec._yourself();}(smalltalk.ClassCommentReader._new());
  750. return self;
  751. },
  752. source: unescape('commentStamp%0A%20%20%20%20%5EClassCommentReader%20new%0A%09class%3A%20self%3B%0A%09yourself%0A')}),
  753. smalltalk.Behavior);
  754. smalltalk.addMethod(
  755. '_removeCompiledMethod_',
  756. smalltalk.method({
  757. selector: 'removeCompiledMethod:',
  758. category: 'accessing',
  759. fn: function (aMethod) {
  760. var self = this;
  761. (function () {delete self.fn.prototype[aMethod.selector._asSelector()];delete self.fn.prototype.methods[aMethod.selector];}());
  762. return self;
  763. },
  764. source: unescape('removeCompiledMethod%3A%20aMethod%0A%09%7B%27delete%20self.fn.prototype%5BaMethod.selector._asSelector%28%29%5D%3B%0A%09delete%20self.fn.prototype.methods%5BaMethod.selector%5D%27%7D%0A')}),
  765. smalltalk.Behavior);
  766. smalltalk.addClass('Class', smalltalk.Behavior, [], 'Kernel');
  767. smalltalk.addMethod(
  768. '_category',
  769. smalltalk.method({
  770. selector: 'category',
  771. category: 'accessing',
  772. fn: function () {
  773. var self = this;
  774. return function () {return self.category;}();
  775. return self;
  776. },
  777. source: unescape('category%0A%09%5E%7B%27return%20self.category%27%7D%0A')}),
  778. smalltalk.Class);
  779. smalltalk.addMethod(
  780. '_category_',
  781. smalltalk.method({
  782. selector: 'category:',
  783. category: 'accessing',
  784. fn: function (aString) {
  785. var self = this;
  786. (function () {self.category = aString;}());
  787. return self;
  788. },
  789. source: unescape('category%3A%20aString%0A%09%7B%27self.category%20%3D%20aString%27%7D%0A')}),
  790. smalltalk.Class);
  791. smalltalk.addMethod(
  792. '_subclass_instanceVariableNames_',
  793. smalltalk.method({
  794. selector: 'subclass:instanceVariableNames:',
  795. category: 'class creation',
  796. fn: function (aString, anotherString) {
  797. var self = this;
  798. return self._subclass_instanceVariableNames_category_(aString, anotherString, nil);
  799. return self;
  800. },
  801. source: unescape('subclass%3A%20aString%20instanceVariableNames%3A%20anotherString%0A%09%5Eself%20subclass%3A%20aString%20instanceVariableNames%3A%20anotherString%20category%3A%20nil%0A')}),
  802. smalltalk.Class);
  803. smalltalk.addMethod(
  804. '_subclass_instanceVariableNames_category_',
  805. smalltalk.method({
  806. selector: 'subclass:instanceVariableNames:category:',
  807. category: 'class creation',
  808. fn: function (aString, aString2, aString3) {
  809. var self = this;
  810. return smalltalk.ClassBuilder._new()._superclass_subclass_instanceVariableNames_category_(self, aString, aString2, aString3);
  811. return self;
  812. },
  813. source: unescape('subclass%3A%20aString%20instanceVariableNames%3A%20aString2%20category%3A%20aString3%0A%09%5EClassBuilder%20new%0A%09%20%20%20%20superclass%3A%20self%20subclass%3A%20aString%20instanceVariableNames%3A%20aString2%20category%3A%20aString3%0A')}),
  814. smalltalk.Class);
  815. smalltalk.addMethod(
  816. '_isClass',
  817. smalltalk.method({
  818. selector: 'isClass',
  819. category: 'testing',
  820. fn: function () {
  821. var self = this;
  822. return true;
  823. return self;
  824. },
  825. source: unescape('isClass%0A%09%5Etrue%0A')}),
  826. smalltalk.Class);
  827. smalltalk.addMethod(
  828. '_printString',
  829. smalltalk.method({
  830. selector: 'printString',
  831. category: 'printing',
  832. fn: function () {
  833. var self = this;
  834. return self._name();
  835. return self;
  836. },
  837. source: unescape('printString%0A%09%5Eself%20name%0A')}),
  838. smalltalk.Class);
  839. smalltalk.addMethod(
  840. '_rename_',
  841. smalltalk.method({
  842. selector: 'rename:',
  843. category: 'accessing',
  844. fn: function (aString) {
  845. var self = this;
  846. (function () {smalltalk[aString] = self;delete smalltalk[self.className];self.className = aString;}());
  847. return self;
  848. },
  849. source: unescape('rename%3A%20aString%0A%09%7B%27%0A%09%09smalltalk%5BaString%5D%20%3D%20self%3B%0A%09%09delete%20smalltalk%5Bself.className%5D%3B%0A%09%09self.className%20%3D%20aString%3B%0A%09%27%7D')}),
  850. smalltalk.Class);
  851. smalltalk.addClass('Metaclass', smalltalk.Behavior, [], 'Kernel');
  852. smalltalk.addMethod(
  853. '_instanceClass',
  854. smalltalk.method({
  855. selector: 'instanceClass',
  856. category: 'accessing',
  857. fn: function () {
  858. var self = this;
  859. return function () {return self.instanceClass;}();
  860. return self;
  861. },
  862. source: unescape('instanceClass%0A%09%5E%7B%27return%20self.instanceClass%27%7D%0A')}),
  863. smalltalk.Metaclass);
  864. smalltalk.addMethod(
  865. '_instanceVariableNames_',
  866. smalltalk.method({
  867. selector: 'instanceVariableNames:',
  868. category: 'accessing',
  869. fn: function (aCollection) {
  870. var self = this;
  871. smalltalk.ClassBuilder._new()._class_instanceVariableNames_(self, aCollection);
  872. return self;
  873. },
  874. source: unescape('instanceVariableNames%3A%20aCollection%0A%09ClassBuilder%20new%0A%09%20%20%20%20class%3A%20self%20instanceVariableNames%3A%20aCollection%0A')}),
  875. smalltalk.Metaclass);
  876. smalltalk.addMethod(
  877. '_isMetaclass',
  878. smalltalk.method({
  879. selector: 'isMetaclass',
  880. category: 'testing',
  881. fn: function () {
  882. var self = this;
  883. return true;
  884. return self;
  885. },
  886. source: unescape('isMetaclass%0A%09%5Etrue%0A')}),
  887. smalltalk.Metaclass);
  888. smalltalk.addMethod(
  889. '_printString',
  890. smalltalk.method({
  891. selector: 'printString',
  892. category: 'printing',
  893. fn: function () {
  894. var self = this;
  895. return self._instanceClass()._name().__comma(" class");
  896. return self;
  897. },
  898. source: unescape('printString%0A%09%5Eself%20instanceClass%20name%2C%20%27%20class%27%0A')}),
  899. smalltalk.Metaclass);
  900. smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel');
  901. smalltalk.addMethod(
  902. '_source',
  903. smalltalk.method({
  904. selector: 'source',
  905. category: 'accessing',
  906. fn: function () {
  907. var self = this;
  908. return self._basicAt_("source")._ifNil_(function () {return "";});
  909. return self;
  910. },
  911. source: unescape('source%0A%09%5E%28self%20basicAt%3A%20%27source%27%29%20ifNil%3A%20%5B%27%27%5D%0A')}),
  912. smalltalk.CompiledMethod);
  913. smalltalk.addMethod(
  914. '_source_',
  915. smalltalk.method({
  916. selector: 'source:',
  917. category: 'accessing',
  918. fn: function (aString) {
  919. var self = this;
  920. self._basicAt_put_("source", aString);
  921. return self;
  922. },
  923. source: unescape('source%3A%20aString%0A%09self%20basicAt%3A%20%27source%27%20put%3A%20aString%0A')}),
  924. smalltalk.CompiledMethod);
  925. smalltalk.addMethod(
  926. '_category',
  927. smalltalk.method({
  928. selector: 'category',
  929. category: 'accessing',
  930. fn: function () {
  931. var self = this;
  932. return self._basicAt_("category")._ifNil_(function () {return "";});
  933. return self;
  934. },
  935. source: unescape('category%0A%09%5E%28self%20basicAt%3A%20%27category%27%29%20ifNil%3A%20%5B%27%27%5D%0A')}),
  936. smalltalk.CompiledMethod);
  937. smalltalk.addMethod(
  938. '_category_',
  939. smalltalk.method({
  940. selector: 'category:',
  941. category: 'accessing',
  942. fn: function (aString) {
  943. var self = this;
  944. self._basicAt_put_("category", aString);
  945. return self;
  946. },
  947. source: unescape('category%3A%20aString%0A%09self%20basicAt%3A%20%27category%27%20put%3A%20aString%0A')}),
  948. smalltalk.CompiledMethod);
  949. smalltalk.addMethod(
  950. '_selector',
  951. smalltalk.method({
  952. selector: 'selector',
  953. category: 'accessing',
  954. fn: function () {
  955. var self = this;
  956. return self._basicAt_("selector");
  957. return self;
  958. },
  959. source: unescape('selector%0A%09%5Eself%20basicAt%3A%20%27selector%27%0A')}),
  960. smalltalk.CompiledMethod);
  961. smalltalk.addMethod(
  962. '_selector_',
  963. smalltalk.method({
  964. selector: 'selector:',
  965. category: 'accessing',
  966. fn: function (aString) {
  967. var self = this;
  968. self._basicAt_put_("selector", aString);
  969. return self;
  970. },
  971. source: unescape('selector%3A%20aString%0A%09self%20basicAt%3A%20%27selector%27%20put%3A%20aString%0A')}),
  972. smalltalk.CompiledMethod);
  973. smalltalk.addMethod(
  974. '_fn',
  975. smalltalk.method({
  976. selector: 'fn',
  977. category: 'accessing',
  978. fn: function () {
  979. var self = this;
  980. return self._basicAt_("fn");
  981. return self;
  982. },
  983. source: unescape('fn%0A%09%5Eself%20basicAt%3A%20%27fn%27%0A')}),
  984. smalltalk.CompiledMethod);
  985. smalltalk.addMethod(
  986. '_fn_',
  987. smalltalk.method({
  988. selector: 'fn:',
  989. category: 'accessing',
  990. fn: function (aBlock) {
  991. var self = this;
  992. self._basicAt_put_("fn", aBlock);
  993. return self;
  994. },
  995. source: unescape('fn%3A%20aBlock%0A%09self%20basicAt%3A%20%27fn%27%20put%3A%20aBlock%0A')}),
  996. smalltalk.CompiledMethod);
  997. smalltalk.addClass('Number', smalltalk.Object, [], 'Kernel');
  998. smalltalk.addMethod(
  999. '__eq',
  1000. smalltalk.method({
  1001. selector: '=',
  1002. category: 'comparing',
  1003. fn: function (aNumber) {
  1004. var self = this;
  1005. return function () {return Number(self) == aNumber;}();
  1006. return self;
  1007. },
  1008. source: unescape('%3D%20aNumber%0A%09%5E%7B%27return%20Number%28self%29%20%3D%3D%20aNumber%27%7D%0A')}),
  1009. smalltalk.Number);
  1010. smalltalk.addMethod(
  1011. '__gt',
  1012. smalltalk.method({
  1013. selector: '>',
  1014. category: 'comparing',
  1015. fn: function (aNumber) {
  1016. var self = this;
  1017. return function () {return self > aNumber;}();
  1018. return self;
  1019. },
  1020. source: unescape('%3E%20aNumber%0A%09%5E%7B%27return%20self%20%3E%20aNumber%27%7D%0A')}),
  1021. smalltalk.Number);
  1022. smalltalk.addMethod(
  1023. '__lt',
  1024. smalltalk.method({
  1025. selector: '<',
  1026. category: 'comparing',
  1027. fn: function (aNumber) {
  1028. var self = this;
  1029. return function () {return self < aNumber;}();
  1030. return self;
  1031. },
  1032. source: unescape('%3C%20aNumber%0A%09%5E%7B%27return%20self%20%3C%20aNumber%27%7D%0A')}),
  1033. smalltalk.Number);
  1034. smalltalk.addMethod(
  1035. '__gt_eq',
  1036. smalltalk.method({
  1037. selector: '>=',
  1038. category: 'comparing',
  1039. fn: function (aNumber) {
  1040. var self = this;
  1041. return function () {return self >= aNumber;}();
  1042. return self;
  1043. },
  1044. source: unescape('%3E%3D%20aNumber%0A%09%5E%7B%27return%20self%20%3E%3D%20aNumber%27%7D%0A')}),
  1045. smalltalk.Number);
  1046. smalltalk.addMethod(
  1047. '__lt_eq',
  1048. smalltalk.method({
  1049. selector: '<=',
  1050. category: 'comparing',
  1051. fn: function (aNumber) {
  1052. var self = this;
  1053. return function () {return self <= aNumber;}();
  1054. return self;
  1055. },
  1056. source: unescape('%3C%3D%20aNumber%0A%09%5E%7B%27return%20self%20%3C%3D%20aNumber%27%7D%0A')}),
  1057. smalltalk.Number);
  1058. smalltalk.addMethod(
  1059. '__plus',
  1060. smalltalk.method({
  1061. selector: '+',
  1062. category: 'arithmetic',
  1063. fn: function (aNumber) {
  1064. var self = this;
  1065. return function () {return self + aNumber;}();
  1066. return self;
  1067. },
  1068. source: unescape('+%20aNumber%0A%09%5E%7B%27return%20self%20+%20aNumber%27%7D%0A')}),
  1069. smalltalk.Number);
  1070. smalltalk.addMethod(
  1071. '__minus',
  1072. smalltalk.method({
  1073. selector: '-',
  1074. category: 'arithmetic',
  1075. fn: function (aNumber) {
  1076. var self = this;
  1077. return function () {return self - aNumber;}();
  1078. return self;
  1079. },
  1080. source: unescape('-%20aNumber%0A%09%5E%7B%27return%20self%20-%20aNumber%27%7D%0A')}),
  1081. smalltalk.Number);
  1082. smalltalk.addMethod(
  1083. '__star',
  1084. smalltalk.method({
  1085. selector: '*',
  1086. category: 'arithmetic',
  1087. fn: function (aNumber) {
  1088. var self = this;
  1089. return function () {return self * aNumber;}();
  1090. return self;
  1091. },
  1092. source: unescape('*%20aNumber%0A%09%5E%7B%27return%20self%20*%20aNumber%27%7D%0A')}),
  1093. smalltalk.Number);
  1094. smalltalk.addMethod(
  1095. '__slash',
  1096. smalltalk.method({
  1097. selector: '/',
  1098. category: 'arithmetic',
  1099. fn: function (aNumber) {
  1100. var self = this;
  1101. return function () {return self / aNumber;}();
  1102. return self;
  1103. },
  1104. source: unescape('/%20aNumber%0A%09%5E%7B%27return%20self%20/%20aNumber%27%7D%0A')}),
  1105. smalltalk.Number);
  1106. smalltalk.addMethod(
  1107. '_max_',
  1108. smalltalk.method({
  1109. selector: 'max:',
  1110. category: 'arithmetic',
  1111. fn: function (aNumber) {
  1112. var self = this;
  1113. return function () {return Math.max(self, aNumber);}();
  1114. return self;
  1115. },
  1116. source: unescape('max%3A%20aNumber%0A%09%5E%7B%27return%20Math.max%28self%2C%20aNumber%29%3B%27%7D%0A')}),
  1117. smalltalk.Number);
  1118. smalltalk.addMethod(
  1119. '_min_',
  1120. smalltalk.method({
  1121. selector: 'min:',
  1122. category: 'arithmetic',
  1123. fn: function (aNumber) {
  1124. var self = this;
  1125. return function () {return Math.min(self, aNumber);}();
  1126. return self;
  1127. },
  1128. source: unescape('min%3A%20aNumber%0A%09%5E%7B%27return%20Math.min%28self%2C%20aNumber%29%3B%27%7D%0A')}),
  1129. smalltalk.Number);
  1130. smalltalk.addMethod(
  1131. '_rounded',
  1132. smalltalk.method({
  1133. selector: 'rounded',
  1134. category: 'converting',
  1135. fn: function () {
  1136. var self = this;
  1137. return function () {return Math.round(self);}();
  1138. return self;
  1139. },
  1140. source: unescape('rounded%0A%09%5E%7B%27return%20Math.round%28self%29%3B%27%7D%0A')}),
  1141. smalltalk.Number);
  1142. smalltalk.addMethod(
  1143. '_truncated',
  1144. smalltalk.method({
  1145. selector: 'truncated',
  1146. category: 'converting',
  1147. fn: function () {
  1148. var self = this;
  1149. return function () {return Math.floor(self);}();
  1150. return self;
  1151. },
  1152. source: unescape('truncated%0A%09%5E%7B%27return%20Math.floor%28self%29%3B%27%7D%0A')}),
  1153. smalltalk.Number);
  1154. smalltalk.addMethod(
  1155. '_to_',
  1156. smalltalk.method({
  1157. selector: 'to:',
  1158. category: 'converting',
  1159. fn: function (aNumber) {
  1160. var self = this;
  1161. var array = nil;
  1162. var first = nil;
  1163. var last = nil;
  1164. var count = nil;
  1165. first = self._truncated();
  1166. last = aNumber._truncated().__plus(1);
  1167. count = 1;
  1168. first.__lt_eq(last)._ifFalse_(function () {return self._error_("Wrong interval");});
  1169. array = smalltalk.Array._new();
  1170. last.__minus(first)._timesRepeat_(function () {array._at_put_(count, first);count = count.__plus(1);return first = first.__plus(1);});
  1171. return array;
  1172. return self;
  1173. },
  1174. source: unescape('to%3A%20aNumber%0A%09%7C%20array%20first%20last%20count%20%7C%0A%09first%20%3A%3D%20self%20truncated.%0A%09last%20%3A%3D%20aNumber%20truncated%20+%201.%0A%09count%20%3A%3D%201.%0A%09%28first%20%3C%3D%20last%29%20ifFalse%3A%20%5Bself%20error%3A%20%27Wrong%20interval%27%5D.%0A%09array%20%3A%3D%20Array%20new.%0A%09%28last%20-%20first%29%20timesRepeat%3A%20%5B%0A%09%20%20%20%20array%20at%3A%20count%20put%3A%20first.%0A%09%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%09%20%20%20%20first%20%3A%3D%20first%20+%201%5D.%0A%09%5Earray%0A')}),
  1175. smalltalk.Number);
  1176. smalltalk.addMethod(
  1177. '_timesRepeat_',
  1178. smalltalk.method({
  1179. selector: 'timesRepeat:',
  1180. category: 'enumerating',
  1181. fn: function (aBlock) {
  1182. var self = this;
  1183. var integer = nil;
  1184. var count = nil;
  1185. integer = self._truncated();
  1186. count = 1;
  1187. (function () {return count.__gt(self);}._whileFalse_(function () {aBlock._value();return count = count.__plus(1);}));
  1188. return self;
  1189. },
  1190. source: unescape('timesRepeat%3A%20aBlock%0A%09%7C%20integer%20count%20%7C%0A%09integer%20%3A%3D%20self%20truncated.%0A%09count%20%3A%3D%201.%0A%09%5Bcount%20%3E%20self%5D%20whileFalse%3A%20%5B%0A%09%20%20%20%20aBlock%20value.%0A%09%20%20%20%20count%20%3A%3D%20count%20+%201%5D%0A')}),
  1191. smalltalk.Number);
  1192. smalltalk.addMethod(
  1193. '_to_do_',
  1194. smalltalk.method({
  1195. selector: 'to:do:',
  1196. category: 'enumerating',
  1197. fn: function (aNumber, aBlock) {
  1198. var self = this;
  1199. return self._to_(aNumber)._do_(aBlock);
  1200. return self;
  1201. },
  1202. source: unescape('to%3A%20aNumber%20do%3A%20aBlock%0A%09%5E%28self%20to%3A%20aNumber%29%20do%3A%20aBlock%0A')}),
  1203. smalltalk.Number);
  1204. smalltalk.addMethod(
  1205. '_asString',
  1206. smalltalk.method({
  1207. selector: 'asString',
  1208. category: 'converting',
  1209. fn: function () {
  1210. var self = this;
  1211. return self._printString();
  1212. return self;
  1213. },
  1214. source: unescape('asString%0A%09%5Eself%20printString%0A')}),
  1215. smalltalk.Number);
  1216. smalltalk.addMethod(
  1217. '_asJavascript',
  1218. smalltalk.method({
  1219. selector: 'asJavascript',
  1220. category: 'converting',
  1221. fn: function () {
  1222. var self = this;
  1223. return unescape("%28").__comma(self._printString()).__comma(unescape("%29"));
  1224. return self;
  1225. },
  1226. source: unescape('asJavascript%0A%09%5E%27%28%27%2C%20self%20printString%2C%20%27%29%27%0A')}),
  1227. smalltalk.Number);
  1228. smalltalk.addMethod(
  1229. '_printString',
  1230. smalltalk.method({
  1231. selector: 'printString',
  1232. category: 'printing',
  1233. fn: function () {
  1234. var self = this;
  1235. return function () {return String(self);}();
  1236. return self;
  1237. },
  1238. source: unescape('printString%0A%09%5E%7B%27return%20String%28self%29%27%7D%0A')}),
  1239. smalltalk.Number);
  1240. smalltalk.addMethod(
  1241. '_isNumber',
  1242. smalltalk.method({
  1243. selector: 'isNumber',
  1244. category: 'testing',
  1245. fn: function () {
  1246. var self = this;
  1247. return true;
  1248. return self;
  1249. },
  1250. source: unescape('isNumber%0A%09%5Etrue%0A')}),
  1251. smalltalk.Number);
  1252. smalltalk.addMethod(
  1253. '_atRandom',
  1254. smalltalk.method({
  1255. selector: 'atRandom',
  1256. category: 'converting',
  1257. fn: function () {
  1258. var self = this;
  1259. return smalltalk.Random._new()._next().__star(self)._truncated().__plus(1);
  1260. return self;
  1261. },
  1262. source: unescape('atRandom%0A%20%20%20%20%5E%28Random%20new%20next%20*%20self%29%20truncated%20+%201%0A')}),
  1263. smalltalk.Number);
  1264. smalltalk.addMethod(
  1265. '__at',
  1266. smalltalk.method({
  1267. selector: '@',
  1268. category: 'converting',
  1269. fn: function (aNumber) {
  1270. var self = this;
  1271. return smalltalk.Point._x_y_(self, aNumber);
  1272. return self;
  1273. },
  1274. source: unescape('@%20aNumber%0A%09%5EPoint%20x%3A%20self%20y%3A%20aNumber')}),
  1275. smalltalk.Number);
  1276. smalltalk.addMethod(
  1277. '_asPoint',
  1278. smalltalk.method({
  1279. selector: 'asPoint',
  1280. category: 'converting',
  1281. fn: function () {
  1282. var self = this;
  1283. return smalltalk.Point._x_y_(self, self);
  1284. return self;
  1285. },
  1286. source: unescape('asPoint%0A%09%5EPoint%20x%3A%20self%20y%3A%20self')}),
  1287. smalltalk.Number);
  1288. smalltalk.addMethod(
  1289. '_clearInterval',
  1290. smalltalk.method({
  1291. selector: 'clearInterval',
  1292. category: 'intervals',
  1293. fn: function () {
  1294. var self = this;
  1295. (function () {clearInterval(Number(self));}());
  1296. return self;
  1297. },
  1298. source: unescape('clearInterval%0A%09%7B%27clearInterval%28Number%28self%29%29%27%7D')}),
  1299. smalltalk.Number);
  1300. smalltalk.addMethod(
  1301. '_pi',
  1302. smalltalk.method({
  1303. selector: 'pi',
  1304. category: 'instance creation',
  1305. fn: function () {
  1306. var self = this;
  1307. return function () {return Math.PI;}();
  1308. return self;
  1309. },
  1310. source: unescape('pi%0A%09%5E%7B%27return%20Math.PI%27%7D')}),
  1311. smalltalk.Number.klass);
  1312. smalltalk.addClass('BlockClosure', smalltalk.Object, [], 'Kernel');
  1313. smalltalk.addMethod(
  1314. '_compiledSource',
  1315. smalltalk.method({
  1316. selector: 'compiledSource',
  1317. category: 'accessing',
  1318. fn: function () {
  1319. var self = this;
  1320. return function () {return self.toString();}();
  1321. return self;
  1322. },
  1323. source: unescape('compiledSource%0A%09%5E%7B%27return%20self.toString%28%29%27%7D%0A')}),
  1324. smalltalk.BlockClosure);
  1325. smalltalk.addMethod(
  1326. '_whileTrue_',
  1327. smalltalk.method({
  1328. selector: 'whileTrue:',
  1329. category: 'controlling',
  1330. fn: function (aBlock) {
  1331. var self = this;
  1332. (function () {while (self()) {aBlock();}}());
  1333. return self;
  1334. },
  1335. source: unescape('whileTrue%3A%20aBlock%0A%09%7B%27while%28self%28%29%29%20%7BaBlock%28%29%7D%27%7D%0A')}),
  1336. smalltalk.BlockClosure);
  1337. smalltalk.addMethod(
  1338. '_whileFalse_',
  1339. smalltalk.method({
  1340. selector: 'whileFalse:',
  1341. category: 'controlling',
  1342. fn: function (aBlock) {
  1343. var self = this;
  1344. (function () {while (!self()) {aBlock();}}());
  1345. return self;
  1346. },
  1347. source: unescape('whileFalse%3A%20aBlock%0A%09%7B%27while%28%21self%28%29%29%20%7BaBlock%28%29%7D%27%7D%0A')}),
  1348. smalltalk.BlockClosure);
  1349. smalltalk.addMethod(
  1350. '_value',
  1351. smalltalk.method({
  1352. selector: 'value',
  1353. category: 'evaluating',
  1354. fn: function () {
  1355. var self = this;
  1356. return function () {return self();}();
  1357. return self;
  1358. },
  1359. source: unescape('value%0A%09%5E%7B%27return%20self%28%29%3B%27%7D%0A')}),
  1360. smalltalk.BlockClosure);
  1361. smalltalk.addMethod(
  1362. '_value_',
  1363. smalltalk.method({
  1364. selector: 'value:',
  1365. category: 'evaluating',
  1366. fn: function (anArg) {
  1367. var self = this;
  1368. return function () {return self(anArg);}();
  1369. return self;
  1370. },
  1371. source: unescape('value%3A%20anArg%0A%09%5E%7B%27return%20self%28anArg%29%3B%27%7D%0A')}),
  1372. smalltalk.BlockClosure);
  1373. smalltalk.addMethod(
  1374. '_value_value_',
  1375. smalltalk.method({
  1376. selector: 'value:value:',
  1377. category: 'evaluating',
  1378. fn: function (firstArg, secondArg) {
  1379. var self = this;
  1380. return function () {return self(firstArg, secondArg);}();
  1381. return self;
  1382. },
  1383. source: unescape('value%3A%20firstArg%20value%3A%20secondArg%0A%09%5E%7B%27return%20self%28firstArg%2C%20secondArg%29%3B%27%7D%0A')}),
  1384. smalltalk.BlockClosure);
  1385. smalltalk.addMethod(
  1386. '_value_value_value_',
  1387. smalltalk.method({
  1388. selector: 'value:value:value:',
  1389. category: 'evaluating',
  1390. fn: function (firstArg, secondArg, thirdArg) {
  1391. var self = this;
  1392. return function () {return self(firstArg, secondArg, thirdArg);}();
  1393. return self;
  1394. },
  1395. source: unescape('value%3A%20firstArg%20value%3A%20secondArg%20value%3A%20thirdArg%0A%09%5E%7B%27return%20self%28firstArg%2C%20secondArg%2C%20thirdArg%29%3B%27%7D%0A')}),
  1396. smalltalk.BlockClosure);
  1397. smalltalk.addMethod(
  1398. '_valueWithPossibleArguments_',
  1399. smalltalk.method({
  1400. selector: 'valueWithPossibleArguments:',
  1401. category: 'evaluating',
  1402. fn: function (aCollection) {
  1403. var self = this;
  1404. return function () {return self.apply(null, aCollection);}();
  1405. return self;
  1406. },
  1407. source: unescape('valueWithPossibleArguments%3A%20aCollection%0A%09%5E%7B%27return%20self.apply%28null%2C%20aCollection%29%3B%27%7D%0A')}),
  1408. smalltalk.BlockClosure);
  1409. smalltalk.addMethod(
  1410. '_on_do_',
  1411. smalltalk.method({
  1412. selector: 'on:do:',
  1413. category: 'error handling',
  1414. fn: function (anErrorClass, aBlock) {
  1415. var self = this;
  1416. self._try_catch_(self, function (error) {return error._isKindOf_(anErrorClass)._ifTrue_ifFalse_(function () {return aBlock._value();}, function () {return error._signal();});});
  1417. return self;
  1418. },
  1419. source: unescape('on%3A%20anErrorClass%20do%3A%20aBlock%0A%09self%20try%3A%20self%20catch%3A%20%5B%3Aerror%20%7C%0A%09%20%20%20%20%28error%20isKindOf%3A%20anErrorClass%29%20%0A%09%20%20%20%20%20ifTrue%3A%20%5BaBlock%20value%5D%0A%09%20%20%20%20%20ifFalse%3A%20%5Berror%20signal%5D%5D%0A')}),
  1420. smalltalk.BlockClosure);
  1421. smalltalk.addMethod(
  1422. '_appendToJQuery_',
  1423. smalltalk.method({
  1424. selector: 'appendToJQuery:',
  1425. category: '*JQuery',
  1426. fn: function (aJQuery) {
  1427. var self = this;
  1428. var canvas = nil;
  1429. canvas = smalltalk.HTMLCanvas._new();
  1430. self._value_(canvas);
  1431. aJQuery._append_(canvas);
  1432. return self;
  1433. },
  1434. source: unescape('appendToJQuery%3A%20aJQuery%0A%09%7C%20canvas%20%7C%0A%09canvas%20%3A%3D%20HTMLCanvas%20new.%0A%09self%20value%3A%20canvas.%0A%09aJQuery%20append%3A%20canvas%0A')}),
  1435. smalltalk.BlockClosure);
  1436. smalltalk.addMethod(
  1437. '_appendToBrush_',
  1438. smalltalk.method({
  1439. selector: 'appendToBrush:',
  1440. category: '*Canvas',
  1441. fn: function (aTagBrush) {
  1442. var self = this;
  1443. aTagBrush._appendBlock_(self);
  1444. return self;
  1445. },
  1446. source: unescape('appendToBrush%3A%20aTagBrush%0A%20%20%20%20aTagBrush%20appendBlock%3A%20self%0A')}),
  1447. smalltalk.BlockClosure);
  1448. smalltalk.addMethod(
  1449. '_valueWithTimeout_',
  1450. smalltalk.method({
  1451. selector: 'valueWithTimeout:',
  1452. category: 'timeout/interval',
  1453. fn: function (aNumber) {
  1454. var self = this;
  1455. (function () {setTimeout(self, aNumber);}());
  1456. return self;
  1457. },
  1458. source: unescape('valueWithTimeout%3A%20aNumber%0A%09%7B%27setTimeout%28self%2C%20aNumber%29%27%7D')}),
  1459. smalltalk.BlockClosure);
  1460. smalltalk.addMethod(
  1461. '_valueWithInterval_',
  1462. smalltalk.method({
  1463. selector: 'valueWithInterval:',
  1464. category: 'timeout/interval',
  1465. fn: function (aNumber) {
  1466. var self = this;
  1467. return function () {return setInterval(self, aNumber);}();
  1468. return self;
  1469. },
  1470. source: unescape('valueWithInterval%3A%20aNumber%0A%09%5E%7B%27return%20setInterval%28self%2C%20aNumber%29%27%7D')}),
  1471. smalltalk.BlockClosure);
  1472. smalltalk.addMethod(
  1473. '_ensure_',
  1474. smalltalk.method({
  1475. selector: 'ensure:',
  1476. category: 'evaluating',
  1477. fn: function (aBlock) {
  1478. var self = this;
  1479. (function () {var success = true;try {self();} catch (e) {success = false;aBlock();throw e;}if (success) {aBlock();}}());
  1480. return self;
  1481. },
  1482. source: unescape('ensure%3A%20aBlock%0A%09%22Evaluate%20a%20termination%20block%20after%20evaluating%20the%20receiver%2C%20regardless%20of%0A%09%20whether%20the%20receiver%27s%20evaluation%20completes.%22%0A%09%7B%27%0A%09%09var%20success%20%3D%20true%3B%0A%09%09try%7Bself%28%29%7D%20catch%28e%29%20%7B%0A%09%09%09success%20%3D%20false%3B%0A%09%09%09aBlock%28%29%3B%0A%09%09%09throw%28e%29%7D%0A%09%09if%28success%29%7BaBlock%28%29%7D%0A%09%27%7D')}),
  1483. smalltalk.BlockClosure);
  1484. smalltalk.addClass('Boolean', smalltalk.Object, [], 'Kernel');
  1485. smalltalk.addMethod(
  1486. '__eq',
  1487. smalltalk.method({
  1488. selector: '=',
  1489. category: 'comparing',
  1490. fn: function (aBoolean) {
  1491. var self = this;
  1492. return function () {return Boolean(self == true) == aBoolean;}();
  1493. return self;
  1494. },
  1495. source: unescape('%3D%20aBoolean%0A%20%20%20%20%09%5E%7B%27return%20Boolean%28self%20%3D%3D%20true%29%20%3D%3D%20aBoolean%27%7D%0A')}),
  1496. smalltalk.Boolean);
  1497. smalltalk.addMethod(
  1498. '_shallowCopy',
  1499. smalltalk.method({
  1500. selector: 'shallowCopy',
  1501. category: 'copying',
  1502. fn: function () {
  1503. var self = this;
  1504. return self;
  1505. return self;
  1506. },
  1507. source: unescape('shallowCopy%0A%09%5Eself%0A')}),
  1508. smalltalk.Boolean);
  1509. smalltalk.addMethod(
  1510. '_deepCopy',
  1511. smalltalk.method({
  1512. selector: 'deepCopy',
  1513. category: 'copying',
  1514. fn: function () {
  1515. var self = this;
  1516. return self;
  1517. return self;
  1518. },
  1519. source: unescape('deepCopy%0A%09%5Eself%0A')}),
  1520. smalltalk.Boolean);
  1521. smalltalk.addMethod(
  1522. '_ifTrue_',
  1523. smalltalk.method({
  1524. selector: 'ifTrue:',
  1525. category: 'controlling',
  1526. fn: function (aBlock) {
  1527. var self = this;
  1528. return self._ifTrue_ifFalse_(aBlock, function () {return nil;});
  1529. return self;
  1530. },
  1531. source: unescape('ifTrue%3A%20aBlock%0A%09%5Eself%20ifTrue%3A%20aBlock%20ifFalse%3A%20%5B%5D%0A')}),
  1532. smalltalk.Boolean);
  1533. smalltalk.addMethod(
  1534. '_ifFalse_',
  1535. smalltalk.method({
  1536. selector: 'ifFalse:',
  1537. category: 'controlling',
  1538. fn: function (aBlock) {
  1539. var self = this;
  1540. return self._ifTrue_ifFalse_(function () {return nil;}, aBlock);
  1541. return self;
  1542. },
  1543. source: unescape('ifFalse%3A%20aBlock%0A%09%5Eself%20ifTrue%3A%20%5B%5D%20ifFalse%3A%20aBlock%0A')}),
  1544. smalltalk.Boolean);
  1545. smalltalk.addMethod(
  1546. '_ifFalse_ifTrue_',
  1547. smalltalk.method({
  1548. selector: 'ifFalse:ifTrue:',
  1549. category: 'controlling',
  1550. fn: function (aBlock, anotherBlock) {
  1551. var self = this;
  1552. return self._ifTrue_ifFalse_(anotherBlock, aBlock);
  1553. return self;
  1554. },
  1555. source: unescape('ifFalse%3A%20aBlock%20ifTrue%3A%20anotherBlock%0A%09%5Eself%20ifTrue%3A%20anotherBlock%20ifFalse%3A%20aBlock%0A')}),
  1556. smalltalk.Boolean);
  1557. smalltalk.addMethod(
  1558. '_ifTrue_ifFalse_',
  1559. smalltalk.method({
  1560. selector: 'ifTrue:ifFalse:',
  1561. category: 'controlling',
  1562. fn: function (aBlock, anotherBlock) {
  1563. var self = this;
  1564. return function () {if (self == true) {return aBlock();} else {return anotherBlock();}}();
  1565. return self;
  1566. },
  1567. source: unescape('ifTrue%3A%20aBlock%20ifFalse%3A%20anotherBlock%0A%09%5E%7B%27%0A%09%20%20%20%20if%28self%20%3D%3D%20true%29%20%7B%0A%09%09return%20aBlock%28%29%3B%0A%09%20%20%20%20%7D%20else%20%7B%0A%09%09return%20anotherBlock%28%29%3B%0A%09%20%20%20%20%7D%0A%09%27%7D%0A')}),
  1568. smalltalk.Boolean);
  1569. smalltalk.addMethod(
  1570. '_and_',
  1571. smalltalk.method({
  1572. selector: 'and:',
  1573. category: 'controlling',
  1574. fn: function (aBlock) {
  1575. var self = this;
  1576. return self.__eq(true)._ifTrue_ifFalse_(aBlock, function () {return false;});
  1577. return self;
  1578. },
  1579. source: unescape('and%3A%20aBlock%0A%09%5Eself%20%3D%20true%0A%09%20%20%20%20ifTrue%3A%20aBlock%0A%09%20%20%20%20ifFalse%3A%20%5Bfalse%5D%0A')}),
  1580. smalltalk.Boolean);
  1581. smalltalk.addMethod(
  1582. '_or_',
  1583. smalltalk.method({
  1584. selector: 'or:',
  1585. category: 'controlling',
  1586. fn: function (aBlock) {
  1587. var self = this;
  1588. return self.__eq(true)._ifTrue_ifFalse_(function () {return true;}, aBlock);
  1589. return self;
  1590. },
  1591. source: unescape('or%3A%20aBlock%0A%09%5Eself%20%3D%20true%0A%09%20%20%20%20ifTrue%3A%20%5Btrue%5D%0A%09%20%20%20%20ifFalse%3A%20aBlock%0A')}),
  1592. smalltalk.Boolean);
  1593. smalltalk.addMethod(
  1594. '_not',
  1595. smalltalk.method({
  1596. selector: 'not',
  1597. category: 'controlling',
  1598. fn: function () {
  1599. var self = this;
  1600. return self.__eq(false);
  1601. return self;
  1602. },
  1603. source: unescape('not%0A%09%5Eself%20%3D%20false%0A')}),
  1604. smalltalk.Boolean);
  1605. smalltalk.addMethod(
  1606. '_printString',
  1607. smalltalk.method({
  1608. selector: 'printString',
  1609. category: 'printing',
  1610. fn: function () {
  1611. var self = this;
  1612. return function () {return self.toString();}();
  1613. return self;
  1614. },
  1615. source: unescape('printString%0A%09%5E%7B%27return%20self.toString%28%29%27%7D%0A')}),
  1616. smalltalk.Boolean);
  1617. smalltalk.addClass('UndefinedObject', smalltalk.Object, [], 'Kernel');
  1618. smalltalk.addMethod(
  1619. '_subclass_instanceVariableNames_',
  1620. smalltalk.method({
  1621. selector: 'subclass:instanceVariableNames:',
  1622. category: 'class creation',
  1623. fn: function (aString, anotherString) {
  1624. var self = this;
  1625. return self._subclass_instanceVariableNames_category_(aString, anotherString, nil);
  1626. return self;
  1627. },
  1628. source: unescape('subclass%3A%20aString%20instanceVariableNames%3A%20anotherString%0A%09%5Eself%20subclass%3A%20aString%20instanceVariableNames%3A%20anotherString%20category%3A%20nil%0A')}),
  1629. smalltalk.UndefinedObject);
  1630. smalltalk.addMethod(
  1631. '_subclass_instanceVariableNames_category_',
  1632. smalltalk.method({
  1633. selector: 'subclass:instanceVariableNames:category:',
  1634. category: 'class creation',
  1635. fn: function (aString, aString2, aString3) {
  1636. var self = this;
  1637. return smalltalk.ClassBuilder._new()._superclass_subclass_instanceVariableNames_category_(self, aString, aString2, aString3);
  1638. return self;
  1639. },
  1640. source: unescape('subclass%3A%20aString%20instanceVariableNames%3A%20aString2%20category%3A%20aString3%0A%09%5EClassBuilder%20new%0A%09%20%20%20%20superclass%3A%20self%20subclass%3A%20aString%20instanceVariableNames%3A%20aString2%20category%3A%20aString3%0A')}),
  1641. smalltalk.UndefinedObject);
  1642. smalltalk.addMethod(
  1643. '_shallowCopy',
  1644. smalltalk.method({
  1645. selector: 'shallowCopy',
  1646. category: 'copying',
  1647. fn: function () {
  1648. var self = this;
  1649. return self;
  1650. return self;
  1651. },
  1652. source: unescape('shallowCopy%0A%09%5Eself%0A')}),
  1653. smalltalk.UndefinedObject);
  1654. smalltalk.addMethod(
  1655. '_deepCopy',
  1656. smalltalk.method({
  1657. selector: 'deepCopy',
  1658. category: 'copying',
  1659. fn: function () {
  1660. var self = this;
  1661. return self;
  1662. return self;
  1663. },
  1664. source: unescape('deepCopy%0A%09%5Eself%0A')}),
  1665. smalltalk.UndefinedObject);
  1666. smalltalk.addMethod(
  1667. '_ifNil_',
  1668. smalltalk.method({
  1669. selector: 'ifNil:',
  1670. category: 'testing',
  1671. fn: function (aBlock) {
  1672. var self = this;
  1673. return self._ifNil_ifNotNil_(aBlock, function () {return nil;});
  1674. return self;
  1675. },
  1676. source: unescape('ifNil%3A%20aBlock%0A%09%5Eself%20ifNil%3A%20aBlock%20ifNotNil%3A%20%5B%5D%0A')}),
  1677. smalltalk.UndefinedObject);
  1678. smalltalk.addMethod(
  1679. '_ifNotNil_',
  1680. smalltalk.method({
  1681. selector: 'ifNotNil:',
  1682. category: 'testing',
  1683. fn: function (aBlock) {
  1684. var self = this;
  1685. return self;
  1686. return self;
  1687. },
  1688. source: unescape('ifNotNil%3A%20aBlock%0A%09%5Eself%0A')}),
  1689. smalltalk.UndefinedObject);
  1690. smalltalk.addMethod(
  1691. '_ifNil_ifNotNil_',
  1692. smalltalk.method({
  1693. selector: 'ifNil:ifNotNil:',
  1694. category: 'testing',
  1695. fn: function (aBlock, anotherBlock) {
  1696. var self = this;
  1697. return aBlock._value();
  1698. return self;
  1699. },
  1700. source: unescape('ifNil%3A%20aBlock%20ifNotNil%3A%20anotherBlock%0A%09%5EaBlock%20value%0A')}),
  1701. smalltalk.UndefinedObject);
  1702. smalltalk.addMethod(
  1703. '_ifNotNil_ifNil_',
  1704. smalltalk.method({
  1705. selector: 'ifNotNil:ifNil:',
  1706. category: 'testing',
  1707. fn: function (aBlock, anotherBlock) {
  1708. var self = this;
  1709. return anotherBlock._value();
  1710. return self;
  1711. },
  1712. source: unescape('ifNotNil%3A%20aBlock%20ifNil%3A%20anotherBlock%0A%09%5EanotherBlock%20value%0A')}),
  1713. smalltalk.UndefinedObject);
  1714. smalltalk.addMethod(
  1715. '_isNil',
  1716. smalltalk.method({
  1717. selector: 'isNil',
  1718. category: 'testing',
  1719. fn: function () {
  1720. var self = this;
  1721. return true;
  1722. return self;
  1723. },
  1724. source: unescape('isNil%0A%09%5Etrue%0A')}),
  1725. smalltalk.UndefinedObject);
  1726. smalltalk.addMethod(
  1727. '_notNil',
  1728. smalltalk.method({
  1729. selector: 'notNil',
  1730. category: 'testing',
  1731. fn: function () {
  1732. var self = this;
  1733. return false;
  1734. return self;
  1735. },
  1736. source: unescape('notNil%0A%09%5Efalse%0A')}),
  1737. smalltalk.UndefinedObject);
  1738. smalltalk.addMethod(
  1739. '_printString',
  1740. smalltalk.method({
  1741. selector: 'printString',
  1742. category: 'printing',
  1743. fn: function () {
  1744. var self = this;
  1745. return "nil";
  1746. return self;
  1747. },
  1748. source: unescape('printString%0A%20%20%20%20%5E%27nil%27%0A')}),
  1749. smalltalk.UndefinedObject);
  1750. smalltalk.addMethod(
  1751. '_new',
  1752. smalltalk.method({
  1753. selector: 'new',
  1754. category: 'instance creation',
  1755. fn: function () {
  1756. var self = this;
  1757. self._error_("You cannot create new instances of UndefinedObject. Use nil");
  1758. return self;
  1759. },
  1760. source: unescape('new%0A%09%20%20%20%20self%20error%3A%20%27You%20cannot%20create%20new%20instances%20of%20UndefinedObject.%20Use%20nil%27%0A')}),
  1761. smalltalk.UndefinedObject.klass);
  1762. smalltalk.addClass('Collection', smalltalk.Object, [], 'Kernel');
  1763. smalltalk.addMethod(
  1764. '_size',
  1765. smalltalk.method({
  1766. selector: 'size',
  1767. category: 'accessing',
  1768. fn: function () {
  1769. var self = this;
  1770. self._subclassResponsibility();
  1771. return self;
  1772. },
  1773. source: unescape('size%0A%09self%20subclassResponsibility%0A')}),
  1774. smalltalk.Collection);
  1775. smalltalk.addMethod(
  1776. '_at_',
  1777. smalltalk.method({
  1778. selector: 'at:',
  1779. category: 'accessing',
  1780. fn: function (anIndex) {
  1781. var self = this;
  1782. return self._at_ifAbsent_(anIndex, function () {return self._errorNotFound();});
  1783. return self;
  1784. },
  1785. source: unescape('at%3A%20anIndex%0A%09%5Eself%20at%3A%20anIndex%20ifAbsent%3A%20%5B%0A%09%20%20%20%20self%20errorNotFound%5D%0A')}),
  1786. smalltalk.Collection);
  1787. smalltalk.addMethod(
  1788. '_at_put_',
  1789. smalltalk.method({
  1790. selector: 'at:put:',
  1791. category: 'accessing',
  1792. fn: function (anIndex, anObject) {
  1793. var self = this;
  1794. self._subclassResponsibility();
  1795. return self;
  1796. },
  1797. source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%09self%20subclassResponsibility%0A')}),
  1798. smalltalk.Collection);
  1799. smalltalk.addMethod(
  1800. '_at_ifAbsent_',
  1801. smalltalk.method({
  1802. selector: 'at:ifAbsent:',
  1803. category: 'accessing',
  1804. fn: function (anIndex, aBlock) {
  1805. var self = this;
  1806. self._subclassResponsibility();
  1807. return self;
  1808. },
  1809. source: unescape('at%3A%20anIndex%20ifAbsent%3A%20aBlock%0A%09self%20subclassResponsibility%0A')}),
  1810. smalltalk.Collection);
  1811. smalltalk.addMethod(
  1812. '_first',
  1813. smalltalk.method({
  1814. selector: 'first',
  1815. category: 'accessing',
  1816. fn: function () {
  1817. var self = this;
  1818. return self._at_(1);
  1819. return self;
  1820. },
  1821. source: unescape('first%0A%09%5Eself%20at%3A%201%0A')}),
  1822. smalltalk.Collection);
  1823. smalltalk.addMethod(
  1824. '_second',
  1825. smalltalk.method({
  1826. selector: 'second',
  1827. category: 'accessing',
  1828. fn: function () {
  1829. var self = this;
  1830. return self._at_(2);
  1831. return self;
  1832. },
  1833. source: unescape('second%0A%09%5Eself%20at%3A%202%0A')}),
  1834. smalltalk.Collection);
  1835. smalltalk.addMethod(
  1836. '_third',
  1837. smalltalk.method({
  1838. selector: 'third',
  1839. category: 'accessing',
  1840. fn: function () {
  1841. var self = this;
  1842. return self._at_(3);
  1843. return self;
  1844. },
  1845. source: unescape('third%0A%09%5Eself%20at%3A%203%0A')}),
  1846. smalltalk.Collection);
  1847. smalltalk.addMethod(
  1848. '_fourth',
  1849. smalltalk.method({
  1850. selector: 'fourth',
  1851. category: 'accessing',
  1852. fn: function () {
  1853. var self = this;
  1854. return self._at_(4);
  1855. return self;
  1856. },
  1857. source: unescape('fourth%0A%09%5Eself%20at%3A%204%0A')}),
  1858. smalltalk.Collection);
  1859. smalltalk.addMethod(
  1860. '_last',
  1861. smalltalk.method({
  1862. selector: 'last',
  1863. category: 'accessing',
  1864. fn: function () {
  1865. var self = this;
  1866. return self._at_(self._size());
  1867. return self;
  1868. },
  1869. source: unescape('last%0A%09%5Eself%20at%3A%20self%20size%0A')}),
  1870. smalltalk.Collection);
  1871. smalltalk.addMethod(
  1872. '_readStream',
  1873. smalltalk.method({
  1874. selector: 'readStream',
  1875. category: 'accessing',
  1876. fn: function () {
  1877. var self = this;
  1878. return self._stream();
  1879. return self;
  1880. },
  1881. source: unescape('readStream%0A%09%5Eself%20stream%0A')}),
  1882. smalltalk.Collection);
  1883. smalltalk.addMethod(
  1884. '_writeStream',
  1885. smalltalk.method({
  1886. selector: 'writeStream',
  1887. category: 'accessing',
  1888. fn: function () {
  1889. var self = this;
  1890. return self._stream();
  1891. return self;
  1892. },
  1893. source: unescape('writeStream%0A%09%5Eself%20stream%0A')}),
  1894. smalltalk.Collection);
  1895. smalltalk.addMethod(
  1896. '_stream',
  1897. smalltalk.method({
  1898. selector: 'stream',
  1899. category: 'accessing',
  1900. fn: function () {
  1901. var self = this;
  1902. return self._streamClass()._on_(self);
  1903. return self;
  1904. },
  1905. source: unescape('stream%0A%09%5Eself%20streamClass%20on%3A%20self%0A')}),
  1906. smalltalk.Collection);
  1907. smalltalk.addMethod(
  1908. '_streamClass',
  1909. smalltalk.method({
  1910. selector: 'streamClass',
  1911. category: 'accessing',
  1912. fn: function () {
  1913. var self = this;
  1914. return self._class()._streamClass();
  1915. return self;
  1916. },
  1917. source: unescape('streamClass%0A%09%5Eself%20class%20streamClass%0A')}),
  1918. smalltalk.Collection);
  1919. smalltalk.addMethod(
  1920. '_add_',
  1921. smalltalk.method({
  1922. selector: 'add:',
  1923. category: 'adding/removing',
  1924. fn: function (anObject) {
  1925. var self = this;
  1926. self._subclassResponsibility();
  1927. return self;
  1928. },
  1929. source: unescape('add%3A%20anObject%0A%09self%20subclassResponsibility%0A')}),
  1930. smalltalk.Collection);
  1931. smalltalk.addMethod(
  1932. '_addAll_',
  1933. smalltalk.method({
  1934. selector: 'addAll:',
  1935. category: 'adding/removing',
  1936. fn: function (aCollection) {
  1937. var self = this;
  1938. aCollection._do_(function (each) {return self._add_(each);});
  1939. return aCollection;
  1940. return self;
  1941. },
  1942. source: unescape('addAll%3A%20aCollection%0A%09aCollection%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20self%20add%3A%20each%5D.%0A%09%5EaCollection%0A')}),
  1943. smalltalk.Collection);
  1944. smalltalk.addMethod(
  1945. '__comma',
  1946. smalltalk.method({
  1947. selector: ',',
  1948. category: 'copying',
  1949. fn: function (aCollection) {
  1950. var self = this;
  1951. return function ($rec) {$rec._addAll_(aCollection);return $rec._yourself();}(self._copy());
  1952. return self;
  1953. },
  1954. source: unescape('%2C%20aCollection%0A%09%5Eself%20copy%20%0A%09%20%20%20%20addAll%3A%20aCollection%3B%20%0A%09%20%20%20%20yourself%0A')}),
  1955. smalltalk.Collection);
  1956. smalltalk.addMethod(
  1957. '_copyFrom_to_',
  1958. smalltalk.method({
  1959. selector: 'copyFrom:to:',
  1960. category: 'copying',
  1961. fn: function (anIndex, anotherIndex) {
  1962. var self = this;
  1963. self._subclassResponsibility();
  1964. return self;
  1965. },
  1966. source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%09self%20subclassResponsibility%0A')}),
  1967. smalltalk.Collection);
  1968. smalltalk.addMethod(
  1969. '_copyWith_',
  1970. smalltalk.method({
  1971. selector: 'copyWith:',
  1972. category: 'copying',
  1973. fn: function (anObject) {
  1974. var self = this;
  1975. return function ($rec) {$rec._add_(anObject);return $rec._yourself();}(self._copy());
  1976. return self;
  1977. },
  1978. source: unescape('copyWith%3A%20anObject%0A%09%5Eself%20copy%20add%3A%20anObject%3B%20yourself%0A')}),
  1979. smalltalk.Collection);
  1980. smalltalk.addMethod(
  1981. '_copyWithAll_',
  1982. smalltalk.method({
  1983. selector: 'copyWithAll:',
  1984. category: 'copying',
  1985. fn: function (aCollection) {
  1986. var self = this;
  1987. return function ($rec) {$rec._addAll_(aCollection);return $rec._yourself();}(self._copy());
  1988. return self;
  1989. },
  1990. source: unescape('copyWithAll%3A%20aCollection%0A%09%5Eself%20copy%20addAll%3A%20aCollection%3B%20yourself%0A')}),
  1991. smalltalk.Collection);
  1992. smalltalk.addMethod(
  1993. '_asArray',
  1994. smalltalk.method({
  1995. selector: 'asArray',
  1996. category: 'converting',
  1997. fn: function () {
  1998. var self = this;
  1999. var array = nil;
  2000. var index = nil;
  2001. array = smalltalk.Array._new();
  2002. index = 0;
  2003. self._do_(function (each) {index = index.__plus(1);return array._at_put_(index, each);});
  2004. return array;
  2005. return self;
  2006. },
  2007. source: unescape('asArray%0A%09%7C%20array%20index%20%7C%0A%09array%20%3A%3D%20Array%20new.%0A%09index%20%3A%3D%200.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20index%20%3A%3D%20index%20+%201.%0A%09%20%20%20%20array%20at%3A%20index%20put%3A%20each%5D.%0A%09%5Earray%0A')}),
  2008. smalltalk.Collection);
  2009. smalltalk.addMethod(
  2010. '_do_',
  2011. smalltalk.method({
  2012. selector: 'do:',
  2013. category: 'enumerating',
  2014. fn: function (aBlock) {
  2015. var self = this;
  2016. (function () {for (var i = 0; i < self.length; i++) {aBlock(self[i]);}}());
  2017. return self;
  2018. },
  2019. source: unescape('do%3A%20aBlock%0A%09%7B%27for%28var%20i%3D0%3Bi%3Cself.length%3Bi++%29%7BaBlock%28self%5Bi%5D%29%3B%7D%27%7D%0A')}),
  2020. smalltalk.Collection);
  2021. smalltalk.addMethod(
  2022. '_collect_',
  2023. smalltalk.method({
  2024. selector: 'collect:',
  2025. category: 'enumerating',
  2026. fn: function (aBlock) {
  2027. var self = this;
  2028. var stream = nil;
  2029. stream = self._class()._new()._writeStream();
  2030. self._do_(function (each) {return stream._nextPut_(aBlock._value_(each));});
  2031. return stream._contents();
  2032. return self;
  2033. },
  2034. source: unescape('collect%3A%20aBlock%0A%09%7C%20stream%20%7C%0A%09stream%20%3A%3D%20self%20class%20new%20writeStream.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20stream%20nextPut%3A%20%28aBlock%20value%3A%20each%29%5D.%0A%09%5Estream%20contents%0A')}),
  2035. smalltalk.Collection);
  2036. smalltalk.addMethod(
  2037. '_detect_',
  2038. smalltalk.method({
  2039. selector: 'detect:',
  2040. category: 'enumerating',
  2041. fn: function (aBlock) {
  2042. var self = this;
  2043. return self._detect_ifNone_(aBlock, function () {return self._errorNotFound();});
  2044. return self;
  2045. },
  2046. source: unescape('detect%3A%20aBlock%0A%09%5Eself%20detect%3A%20aBlock%20ifNone%3A%20%5Bself%20errorNotFound%5D%0A')}),
  2047. smalltalk.Collection);
  2048. smalltalk.addMethod(
  2049. '_detect_ifNone_',
  2050. smalltalk.method({
  2051. selector: 'detect:ifNone:',
  2052. category: 'enumerating',
  2053. fn: function (aBlock, anotherBlock) {
  2054. var self = this;
  2055. return function () {for (var i = 0; i < self.length; i++) {if (aBlock(self[i])) {return self[i];}}return anotherBlock();}();
  2056. return self;
  2057. },
  2058. source: unescape('detect%3A%20aBlock%20ifNone%3A%20anotherBlock%0A%09%5E%7B%27%0A%09for%28var%20i%20%3D%200%3B%20i%20%3C%20self.length%3B%20i++%29%0A%09%09if%28aBlock%28self%5Bi%5D%29%29%0A%09%09%09return%20self%5Bi%5D%3B%0A%09return%20anotherBlock%28%29%3B%0A%09%27%7D%0A')}),
  2059. smalltalk.Collection);
  2060. smalltalk.addMethod(
  2061. '_do_separatedBy_',
  2062. smalltalk.method({
  2063. selector: 'do:separatedBy:',
  2064. category: 'enumerating',
  2065. fn: function (aBlock, anotherBlock) {
  2066. var self = this;
  2067. var first = nil;
  2068. first = true;
  2069. self._do_(function (each) {first._ifTrue_ifFalse_(function () {return first = false;}, function () {return anotherBlock._value();});return aBlock._value_(each);});
  2070. return self;
  2071. },
  2072. source: unescape('do%3A%20aBlock%20separatedBy%3A%20anotherBlock%0A%20%20%20%20%09%7C%20first%20%7C%0A%20%20%20%20%09first%20%3A%3D%20true.%0A%20%20%20%20%09self%20do%3A%20%5B%3Aeach%20%7C%0A%20%20%20%20%09%20%20%20%20first%0A%20%20%20%20%09%09ifTrue%3A%20%5Bfirst%20%3A%3D%20false%5D%0A%20%20%20%20%09%09ifFalse%3A%20%5BanotherBlock%20value%5D.%0A%20%20%20%20%09%20%20%20%20aBlock%20value%3A%20each%5D%0A')}),
  2073. smalltalk.Collection);
  2074. smalltalk.addMethod(
  2075. '_inject_into_',
  2076. smalltalk.method({
  2077. selector: 'inject:into:',
  2078. category: 'enumerating',
  2079. fn: function (anObject, aBlock) {
  2080. var self = this;
  2081. var result = nil;
  2082. result = anObject;
  2083. self._do_(function (each) {return result = aBlock._value_value_(result, each);});
  2084. return result;
  2085. return self;
  2086. },
  2087. source: unescape('inject%3A%20anObject%20into%3A%20aBlock%0A%09%7C%20result%20%7C%0A%09result%20%3A%3D%20anObject.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%20%0A%09%20%20%20%20result%20%3A%3D%20aBlock%20value%3A%20result%20value%3A%20each%5D.%0A%09%5Eresult%0A')}),
  2088. smalltalk.Collection);
  2089. smalltalk.addMethod(
  2090. '_reject_',
  2091. smalltalk.method({
  2092. selector: 'reject:',
  2093. category: 'enumerating',
  2094. fn: function (aBlock) {
  2095. var self = this;
  2096. return self._select_(function (each) {return aBlock._value_(each).__eq(false);});
  2097. return self;
  2098. },
  2099. source: unescape('reject%3A%20aBlock%0A%09%5Eself%20select%3A%20%5B%3Aeach%20%7C%20%28aBlock%20value%3A%20each%29%20%3D%20false%5D%0A')}),
  2100. smalltalk.Collection);
  2101. smalltalk.addMethod(
  2102. '_select_',
  2103. smalltalk.method({
  2104. selector: 'select:',
  2105. category: 'enumerating',
  2106. fn: function (aBlock) {
  2107. var self = this;
  2108. var stream = nil;
  2109. stream = self._class()._new()._writeStream();
  2110. self._do_(function (each) {return aBlock._value_(each)._ifTrue_(function () {return stream._nextPut_(each);});});
  2111. return stream._contents();
  2112. return self;
  2113. },
  2114. source: unescape('select%3A%20aBlock%0A%09%7C%20stream%20%7C%0A%09stream%20%3A%3D%20self%20class%20new%20writeStream.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20%28aBlock%20value%3A%20each%29%20ifTrue%3A%20%5B%0A%09%09stream%20nextPut%3A%20each%5D%5D.%0A%09%5Estream%20contents%0A')}),
  2115. smalltalk.Collection);
  2116. smalltalk.addMethod(
  2117. '_errorNotFound',
  2118. smalltalk.method({
  2119. selector: 'errorNotFound',
  2120. category: 'error handling',
  2121. fn: function () {
  2122. var self = this;
  2123. self._error_("Object is not in the collection");
  2124. return self;
  2125. },
  2126. source: unescape('errorNotFound%0A%09self%20error%3A%20%27Object%20is%20not%20in%20the%20collection%27%0A')}),
  2127. smalltalk.Collection);
  2128. smalltalk.addMethod(
  2129. '_includes_',
  2130. smalltalk.method({
  2131. selector: 'includes:',
  2132. category: 'testing',
  2133. fn: function (anObject) {
  2134. var self = this;
  2135. return function () {var i = self.length;while (i--) {if (self[i].__eq(anObject)) {return true;}}return false;}();
  2136. return self;
  2137. },
  2138. source: unescape('includes%3A%20anObject%0A%09%5E%7B%27%0A%09%09var%20i%20%3D%20self.length%3B%0A%09%09while%20%28i--%29%20%7B%0A%09%09%09if%20%28self%5Bi%5D.__eq%28anObject%29%29%20%7B%0A%09%09%09%09return%20true%3B%0A%09%09%09%7D%09%0A%09%09%7D%0A%09%09return%20false%3B%0A%0A%09%27%7D%0A')}),
  2139. smalltalk.Collection);
  2140. smalltalk.addMethod(
  2141. '_notEmpty',
  2142. smalltalk.method({
  2143. selector: 'notEmpty',
  2144. category: 'testing',
  2145. fn: function () {
  2146. var self = this;
  2147. return self._isEmpty()._not();
  2148. return self;
  2149. },
  2150. source: unescape('notEmpty%0A%09%5Eself%20isEmpty%20not%0A')}),
  2151. smalltalk.Collection);
  2152. smalltalk.addMethod(
  2153. '_isEmpty',
  2154. smalltalk.method({
  2155. selector: 'isEmpty',
  2156. category: 'testing',
  2157. fn: function () {
  2158. var self = this;
  2159. return self._size().__eq(0);
  2160. return self;
  2161. },
  2162. source: unescape('isEmpty%0A%09%5Eself%20size%20%3D%200%0A')}),
  2163. smalltalk.Collection);
  2164. smalltalk.addMethod(
  2165. '_remove_',
  2166. smalltalk.method({
  2167. selector: 'remove:',
  2168. category: 'adding/removing',
  2169. fn: function (anObject) {
  2170. var self = this;
  2171. self._subclassResponsibility();
  2172. return self;
  2173. },
  2174. source: unescape('remove%3A%20anObject%0A%20%20%20%20self%20subclassResponsibility%0A')}),
  2175. smalltalk.Collection);
  2176. smalltalk.addMethod(
  2177. '_streamClass',
  2178. smalltalk.method({
  2179. selector: 'streamClass',
  2180. category: 'accessing',
  2181. fn: function () {
  2182. var self = this;
  2183. return smalltalk.Stream;
  2184. return self;
  2185. },
  2186. source: unescape('streamClass%0A%09%20%20%20%20%5EStream%0A')}),
  2187. smalltalk.Collection.klass);
  2188. smalltalk.addMethod(
  2189. '_with_',
  2190. smalltalk.method({
  2191. selector: 'with:',
  2192. category: 'instance creation',
  2193. fn: function (anObject) {
  2194. var self = this;
  2195. return function ($rec) {$rec._add_(anObject);return $rec._yourself();}(self._new());
  2196. return self;
  2197. },
  2198. source: unescape('with%3A%20anObject%0A%09%20%20%20%20%5Eself%20new%0A%09%09add%3A%20anObject%3B%0A%09%09yourself%0A')}),
  2199. smalltalk.Collection.klass);
  2200. smalltalk.addMethod(
  2201. '_with_with_',
  2202. smalltalk.method({
  2203. selector: 'with:with:',
  2204. category: 'instance creation',
  2205. fn: function (anObject, anotherObject) {
  2206. var self = this;
  2207. return function ($rec) {$rec._add_(anObject);$rec._add_(anotherObject);return $rec._yourself();}(self._new());
  2208. return self;
  2209. },
  2210. source: unescape('with%3A%20anObject%20with%3A%20anotherObject%0A%09%20%20%20%20%5Eself%20new%0A%09%09add%3A%20anObject%3B%0A%09%09add%3A%20anotherObject%3B%0A%09%09yourself%0A')}),
  2211. smalltalk.Collection.klass);
  2212. smalltalk.addMethod(
  2213. '_with_with_with_',
  2214. smalltalk.method({
  2215. selector: 'with:with:with:',
  2216. category: 'instance creation',
  2217. fn: function (firstObject, secondObject, thirdObject) {
  2218. var self = this;
  2219. return function ($rec) {$rec._add_(firstObject);$rec._add_(secondObject);$rec._add_(thirdObject);return $rec._yourself();}(self._new());
  2220. return self;
  2221. },
  2222. source: unescape('with%3A%20firstObject%20with%3A%20secondObject%20with%3A%20thirdObject%0A%09%20%20%20%20%5Eself%20new%0A%09%09add%3A%20firstObject%3B%0A%09%09add%3A%20secondObject%3B%0A%09%09add%3A%20thirdObject%3B%0A%09%09yourself%0A')}),
  2223. smalltalk.Collection.klass);
  2224. smalltalk.addMethod(
  2225. '_withAll_',
  2226. smalltalk.method({
  2227. selector: 'withAll:',
  2228. category: 'instance creation',
  2229. fn: function (aCollection) {
  2230. var self = this;
  2231. return function ($rec) {$rec._addAll_(aCollection);return $rec._yourself();}(self._new());
  2232. return self;
  2233. },
  2234. source: unescape('withAll%3A%20aCollection%0A%09%20%20%20%20%5Eself%20new%0A%09%09addAll%3A%20aCollection%3B%0A%09%09yourself%0A')}),
  2235. smalltalk.Collection.klass);
  2236. smalltalk.addClass('String', smalltalk.Collection, [], 'Kernel');
  2237. smalltalk.addMethod(
  2238. '__eq',
  2239. smalltalk.method({
  2240. selector: '=',
  2241. category: 'comparing',
  2242. fn: function (aString) {
  2243. var self = this;
  2244. return function () {return String(self) == aString;}();
  2245. return self;
  2246. },
  2247. source: unescape('%3D%20aString%0A%09%5E%7B%27return%20String%28self%29%20%3D%3D%20aString%27%7D%0A')}),
  2248. smalltalk.String);
  2249. smalltalk.addMethod(
  2250. '_size',
  2251. smalltalk.method({
  2252. selector: 'size',
  2253. category: 'accessing',
  2254. fn: function () {
  2255. var self = this;
  2256. return function () {return self.length;}();
  2257. return self;
  2258. },
  2259. source: unescape('size%0A%09%5E%7B%27return%20self.length%27%7D%0A')}),
  2260. smalltalk.String);
  2261. smalltalk.addMethod(
  2262. '_at_',
  2263. smalltalk.method({
  2264. selector: 'at:',
  2265. category: 'accessing',
  2266. fn: function (anIndex) {
  2267. var self = this;
  2268. return function () {return self[anIndex - 1] || nil;}();
  2269. return self;
  2270. },
  2271. source: unescape('at%3A%20anIndex%0A%20%20%20%20%09%5E%7B%27return%20self%5BanIndex%20-%201%5D%20%7C%7C%20nil%3B%27%7D%0A')}),
  2272. smalltalk.String);
  2273. smalltalk.addMethod(
  2274. '_at_put_',
  2275. smalltalk.method({
  2276. selector: 'at:put:',
  2277. category: 'accessing',
  2278. fn: function (anIndex, anObject) {
  2279. var self = this;
  2280. self._errorReadOnly();
  2281. return self;
  2282. },
  2283. source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%20%20%20%20%09self%20errorReadOnly%0A')}),
  2284. smalltalk.String);
  2285. smalltalk.addMethod(
  2286. '_at_ifAbsent_',
  2287. smalltalk.method({
  2288. selector: 'at:ifAbsent:',
  2289. category: 'accessing',
  2290. fn: function (anIndex, aBlock) {
  2291. var self = this;
  2292. self._at_(anIndex)._ifNil_(function () {return aBlock;});
  2293. return self;
  2294. },
  2295. source: unescape('at%3A%20anIndex%20ifAbsent%3A%20aBlock%0A%20%20%20%20%09%28self%20at%3A%20anIndex%29%20ifNil%3A%20%5BaBlock%5D%0A')}),
  2296. smalltalk.String);
  2297. smalltalk.addMethod(
  2298. '_escaped',
  2299. smalltalk.method({
  2300. selector: 'escaped',
  2301. category: 'accessing',
  2302. fn: function () {
  2303. var self = this;
  2304. return function () {return escape(self);}();
  2305. return self;
  2306. },
  2307. source: unescape('escaped%0A%09%5E%7B%27return%20escape%28self%29%27%7D%0A')}),
  2308. smalltalk.String);
  2309. smalltalk.addMethod(
  2310. '_unescaped',
  2311. smalltalk.method({
  2312. selector: 'unescaped',
  2313. category: 'accessing',
  2314. fn: function () {
  2315. var self = this;
  2316. return function () {return unescape(self);}();
  2317. return self;
  2318. },
  2319. source: unescape('unescaped%0A%09%5E%7B%27return%20unescape%28self%29%27%7D%0A')}),
  2320. smalltalk.String);
  2321. smalltalk.addMethod(
  2322. '_add_',
  2323. smalltalk.method({
  2324. selector: 'add:',
  2325. category: 'adding',
  2326. fn: function (anObject) {
  2327. var self = this;
  2328. self._errorReadOnly();
  2329. return self;
  2330. },
  2331. source: unescape('add%3A%20anObject%0A%20%20%20%20%09self%20errorReadOnly%0A')}),
  2332. smalltalk.String);
  2333. smalltalk.addMethod(
  2334. '__comma',
  2335. smalltalk.method({
  2336. selector: ',',
  2337. category: 'copying',
  2338. fn: function (aString) {
  2339. var self = this;
  2340. return function () {return self + aString;}();
  2341. return self;
  2342. },
  2343. source: unescape('%2C%20aString%0A%20%20%20%20%09%5E%7B%27return%20self%20+%20aString%27%7D%0A')}),
  2344. smalltalk.String);
  2345. smalltalk.addMethod(
  2346. '_copyFrom_to_',
  2347. smalltalk.method({
  2348. selector: 'copyFrom:to:',
  2349. category: 'copying',
  2350. fn: function (anIndex, anotherIndex) {
  2351. var self = this;
  2352. return function () {return self.substring(anIndex - 1, anotherIndex);}();
  2353. return self;
  2354. },
  2355. source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%20%20%20%20%09%5E%7B%27return%20self.substring%28anIndex%20-%201%2C%20anotherIndex%29%3B%27%7D%0A')}),
  2356. smalltalk.String);
  2357. smalltalk.addMethod(
  2358. '_shallowCopy',
  2359. smalltalk.method({
  2360. selector: 'shallowCopy',
  2361. category: 'copying',
  2362. fn: function () {
  2363. var self = this;
  2364. return self._class()._fromString_(self);
  2365. return self;
  2366. },
  2367. source: unescape('shallowCopy%0A%20%20%20%20%09%5Eself%20class%20fromString%3A%20self%0A')}),
  2368. smalltalk.String);
  2369. smalltalk.addMethod(
  2370. '_deepCopy',
  2371. smalltalk.method({
  2372. selector: 'deepCopy',
  2373. category: 'copying',
  2374. fn: function () {
  2375. var self = this;
  2376. return self._shallowCopy();
  2377. return self;
  2378. },
  2379. source: unescape('deepCopy%0A%20%20%20%20%09%5Eself%20shallowCopy%0A')}),
  2380. smalltalk.String);
  2381. smalltalk.addMethod(
  2382. '_asSelector',
  2383. smalltalk.method({
  2384. selector: 'asSelector',
  2385. category: 'converting',
  2386. fn: function () {
  2387. var self = this;
  2388. var selector = nil;
  2389. selector = "_".__comma(self);
  2390. selector = selector._replace_with_(":", "_");
  2391. selector = selector._replace_with_(unescape("%5B+%5D"), "_plus");
  2392. selector = selector._replace_with_(unescape("-"), "_minus");
  2393. selector = selector._replace_with_(unescape("%5B*%5D"), "_star");
  2394. selector = selector._replace_with_(unescape("%5B/%5D"), "_slash");
  2395. selector = selector._replace_with_(unescape("%3E"), "_gt");
  2396. selector = selector._replace_with_(unescape("%3C"), "_lt");
  2397. selector = selector._replace_with_(unescape("%3D"), "_eq");
  2398. selector = selector._replace_with_(unescape("%2C"), "_comma");
  2399. selector = selector._replace_with_(unescape("%5B@%5D"), "_at");
  2400. return selector;
  2401. return self;
  2402. },
  2403. source: unescape('asSelector%0A%09%7C%20selector%20%7C%0A%09selector%20%3A%3D%20%27_%27%2C%20self.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%3A%27%20with%3A%20%27_%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%5B+%5D%27%20with%3A%20%27_plus%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27-%27%20with%3A%20%27_minus%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%5B*%5D%27%20with%3A%20%27_star%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%5B/%5D%27%20with%3A%20%27_slash%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%3E%27%20with%3A%20%27_gt%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%3C%27%20with%3A%20%27_lt%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%3D%27%20with%3A%20%27_eq%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%2C%27%20with%3A%20%27_comma%27.%0A%20%20%20%20%09selector%20%3A%3D%20selector%20replace%3A%20%27%5B@%5D%27%20with%3A%20%27_at%27.%0A%09%5Eselector%0A')}),
  2404. smalltalk.String);
  2405. smalltalk.addMethod(
  2406. '_asJavascript',
  2407. smalltalk.method({
  2408. selector: 'asJavascript',
  2409. category: 'converting',
  2410. fn: function () {
  2411. var self = this;
  2412. return function () {if (self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1) {return "unescape(\"" + escape(self) + "\")";} else {return "\"" + self + "\"";}}();
  2413. return self;
  2414. },
  2415. source: unescape('asJavascript%0A%09%5E%7B%27%0A%09if%28self.search%28/%5E%5Ba-zA-Z0-9_%3A.%24%20%5D*%24/%29%20%3D%3D%20-1%29%0A%09%09return%20%22unescape%28%5C%22%22%20+%20escape%28self%29%20+%20%22%5C%22%29%22%3B%0A%09else%0A%09%09return%20%22%5C%22%22%20+%20self%20+%20%22%5C%22%22%3B%0A%09%27%7D%0A')}),
  2416. smalltalk.String);
  2417. smalltalk.addMethod(
  2418. '_replace_with_',
  2419. smalltalk.method({
  2420. selector: 'replace:with:',
  2421. category: 'regular expressions',
  2422. fn: function (aString, anotherString) {
  2423. var self = this;
  2424. return self._replaceRegexp_with_(smalltalk.RegularExpression._fromString_flag_(aString, "g"), anotherString);
  2425. return self;
  2426. },
  2427. source: unescape('replace%3A%20aString%20with%3A%20anotherString%0A%20%20%20%20%09%5Eself%20replaceRegexp%3A%20%28RegularExpression%20fromString%3A%20aString%20flag%3A%20%27g%27%29%20with%3A%20anotherString%0A')}),
  2428. smalltalk.String);
  2429. smalltalk.addMethod(
  2430. '_replaceRegexp_with_',
  2431. smalltalk.method({
  2432. selector: 'replaceRegexp:with:',
  2433. category: 'regular expressions',
  2434. fn: function (aRegexp, aString) {
  2435. var self = this;
  2436. return function () {return self.replace(aRegexp, aString);}();
  2437. return self;
  2438. },
  2439. source: unescape('replaceRegexp%3A%20aRegexp%20with%3A%20aString%0A%20%20%20%20%09%5E%7B%27return%20self.replace%28aRegexp%2C%20aString%29%3B%27%7D%0A')}),
  2440. smalltalk.String);
  2441. smalltalk.addMethod(
  2442. '_tokenize_',
  2443. smalltalk.method({
  2444. selector: 'tokenize:',
  2445. category: 'converting',
  2446. fn: function (aString) {
  2447. var self = this;
  2448. return function () {return self.split(aString);}();
  2449. return self;
  2450. },
  2451. source: unescape('tokenize%3A%20aString%0A%09%5E%7B%27return%20self.split%28aString%29%27%7D%0A')}),
  2452. smalltalk.String);
  2453. smalltalk.addMethod(
  2454. '_match_',
  2455. smalltalk.method({
  2456. selector: 'match:',
  2457. category: 'regular expressions',
  2458. fn: function (aRegexp) {
  2459. var self = this;
  2460. return function () {return self.search(aRegexp) != -1;}();
  2461. return self;
  2462. },
  2463. source: unescape('match%3A%20aRegexp%0A%20%20%20%20%09%5E%7B%27return%20self.search%28aRegexp%29%20%21%3D%20-1%27%7D%0A')}),
  2464. smalltalk.String);
  2465. smalltalk.addMethod(
  2466. '_asString',
  2467. smalltalk.method({
  2468. selector: 'asString',
  2469. category: 'converting',
  2470. fn: function () {
  2471. var self = this;
  2472. return self;
  2473. return self;
  2474. },
  2475. source: unescape('asString%0A%20%20%20%20%09%5Eself%0A')}),
  2476. smalltalk.String);
  2477. smalltalk.addMethod(
  2478. '_asNumber',
  2479. smalltalk.method({
  2480. selector: 'asNumber',
  2481. category: 'converting',
  2482. fn: function () {
  2483. var self = this;
  2484. return function () {return Number(self);}();
  2485. return self;
  2486. },
  2487. source: unescape('asNumber%0A%09%5E%7B%27return%20Number%28self%29%3B%27%7D%0A')}),
  2488. smalltalk.String);
  2489. smalltalk.addMethod(
  2490. '_asParser',
  2491. smalltalk.method({
  2492. selector: 'asParser',
  2493. category: 'converting',
  2494. fn: function () {
  2495. var self = this;
  2496. return smalltalk.PPStringParser._new()._string_(self);
  2497. return self;
  2498. },
  2499. source: unescape('asParser%0A%20%20%20%20%09%5EPPStringParser%20new%20string%3A%20self%0A')}),
  2500. smalltalk.String);
  2501. smalltalk.addMethod(
  2502. '_asChoiceParser',
  2503. smalltalk.method({
  2504. selector: 'asChoiceParser',
  2505. category: 'converting',
  2506. fn: function () {
  2507. var self = this;
  2508. return smalltalk.PPChoiceParser._withAll_(self._asArray()._collect_(function (each) {return each._asParser();}));
  2509. return self;
  2510. },
  2511. source: unescape('asChoiceParser%0A%20%20%20%20%09%5EPPChoiceParser%20withAll%3A%20%28self%20asArray%20collect%3A%20%5B%3Aeach%20%7C%20each%20asParser%5D%29%0A')}),
  2512. smalltalk.String);
  2513. smalltalk.addMethod(
  2514. '_asCharacterParser',
  2515. smalltalk.method({
  2516. selector: 'asCharacterParser',
  2517. category: 'converting',
  2518. fn: function () {
  2519. var self = this;
  2520. return smalltalk.PPCharacterParser._new()._string_(self);
  2521. return self;
  2522. },
  2523. source: unescape('asCharacterParser%0A%20%20%20%20%09%5EPPCharacterParser%20new%20string%3A%20self%0A')}),
  2524. smalltalk.String);
  2525. smalltalk.addMethod(
  2526. '_errorReadOnly',
  2527. smalltalk.method({
  2528. selector: 'errorReadOnly',
  2529. category: 'error handling',
  2530. fn: function () {
  2531. var self = this;
  2532. self._error_(unescape("Object%20is%20read-only"));
  2533. return self;
  2534. },
  2535. source: unescape('errorReadOnly%0A%20%20%20%20%09self%20error%3A%20%27Object%20is%20read-only%27%0A')}),
  2536. smalltalk.String);
  2537. smalltalk.addMethod(
  2538. '_printString',
  2539. smalltalk.method({
  2540. selector: 'printString',
  2541. category: 'printing',
  2542. fn: function () {
  2543. var self = this;
  2544. return unescape("%27").__comma(self).__comma(unescape("%27"));
  2545. return self;
  2546. },
  2547. source: unescape('printString%0A%20%20%20%20%09%5E%27%27%27%27%2C%20self%2C%20%27%27%27%27%0A')}),
  2548. smalltalk.String);
  2549. smalltalk.addMethod(
  2550. '_printNl',
  2551. smalltalk.method({
  2552. selector: 'printNl',
  2553. category: 'printing',
  2554. fn: function () {
  2555. var self = this;
  2556. (function () {console.log(self);}());
  2557. return self;
  2558. },
  2559. source: unescape('printNl%0A%09%7B%27console.log%28self%29%27%7D%0A')}),
  2560. smalltalk.String);
  2561. smalltalk.addMethod(
  2562. '_isString',
  2563. smalltalk.method({
  2564. selector: 'isString',
  2565. category: 'testing',
  2566. fn: function () {
  2567. var self = this;
  2568. return true;
  2569. return self;
  2570. },
  2571. source: unescape('isString%0A%20%20%20%20%09%5Etrue%0A')}),
  2572. smalltalk.String);
  2573. smalltalk.addMethod(
  2574. '_asJQuery',
  2575. smalltalk.method({
  2576. selector: 'asJQuery',
  2577. category: '*JQuery',
  2578. fn: function () {
  2579. var self = this;
  2580. return smalltalk.JQuery._fromString_(self);
  2581. return self;
  2582. },
  2583. source: unescape('asJQuery%0A%20%20%20%20%5EJQuery%20fromString%3A%20self%0A')}),
  2584. smalltalk.String);
  2585. smalltalk.addMethod(
  2586. '_appendToJQuery_',
  2587. smalltalk.method({
  2588. selector: 'appendToJQuery:',
  2589. category: '*JQuery',
  2590. fn: function (aJQuery) {
  2591. var self = this;
  2592. (function () {aJQuery._appendElement_(String(self));}());
  2593. return self;
  2594. },
  2595. source: unescape('appendToJQuery%3A%20aJQuery%0A%20%20%20%20%7B%27aJQuery._appendElement_%28String%28self%29%29%27%7D%0A')}),
  2596. smalltalk.String);
  2597. smalltalk.addMethod(
  2598. '_appendToBrush_',
  2599. smalltalk.method({
  2600. selector: 'appendToBrush:',
  2601. category: '*Canvas',
  2602. fn: function (aTagBrush) {
  2603. var self = this;
  2604. aTagBrush._appendString_(self);
  2605. return self;
  2606. },
  2607. source: unescape('appendToBrush%3A%20aTagBrush%0A%20%20%20%20aTagBrush%20appendString%3A%20self%0A')}),
  2608. smalltalk.String);
  2609. smalltalk.addMethod(
  2610. '__gt',
  2611. smalltalk.method({
  2612. selector: '>',
  2613. category: 'comparing',
  2614. fn: function (aString) {
  2615. var self = this;
  2616. return function () {return String(self) > aString;}();
  2617. return self;
  2618. },
  2619. source: unescape('%3E%20aString%0A%09%5E%7B%27return%20String%28self%29%20%3E%20aString%27%7D%0A')}),
  2620. smalltalk.String);
  2621. smalltalk.addMethod(
  2622. '__lt',
  2623. smalltalk.method({
  2624. selector: '<',
  2625. category: 'comparing',
  2626. fn: function (aString) {
  2627. var self = this;
  2628. return function () {return String(self) < aString;}();
  2629. return self;
  2630. },
  2631. source: unescape('%3C%20aString%0A%09%5E%7B%27return%20String%28self%29%20%3C%20aString%27%7D%0A')}),
  2632. smalltalk.String);
  2633. smalltalk.addMethod(
  2634. '__gt_eq',
  2635. smalltalk.method({
  2636. selector: '>=',
  2637. category: 'comparing',
  2638. fn: function (aString) {
  2639. var self = this;
  2640. return function () {return String(self) >= aString;}();
  2641. return self;
  2642. },
  2643. source: unescape('%3E%3D%20aString%0A%09%5E%7B%27return%20String%28self%29%20%3E%3D%20aString%27%7D%0A')}),
  2644. smalltalk.String);
  2645. smalltalk.addMethod(
  2646. '__lt_eq',
  2647. smalltalk.method({
  2648. selector: '<=',
  2649. category: 'comparing',
  2650. fn: function (aString) {
  2651. var self = this;
  2652. return function () {return String(self) <= aString;}();
  2653. return self;
  2654. },
  2655. source: unescape('%3C%3D%20aString%0A%09%5E%7B%27return%20String%28self%29%20%3C%3D%20aString%27%7D%0A')}),
  2656. smalltalk.String);
  2657. smalltalk.addMethod(
  2658. '_remove_',
  2659. smalltalk.method({
  2660. selector: 'remove:',
  2661. category: 'adding',
  2662. fn: function (anObject) {
  2663. var self = this;
  2664. self._errorReadOnly();
  2665. return self;
  2666. },
  2667. source: unescape('remove%3A%20anObject%0A%20%20%20%20self%20errorReadOnly%0A')}),
  2668. smalltalk.String);
  2669. smalltalk.addMethod(
  2670. '_streamClass',
  2671. smalltalk.method({
  2672. selector: 'streamClass',
  2673. category: 'accessing',
  2674. fn: function () {
  2675. var self = this;
  2676. return smalltalk.StringStream;
  2677. return self;
  2678. },
  2679. source: unescape('streamClass%0A%09%20%20%20%20%5EStringStream%0A')}),
  2680. smalltalk.String.klass);
  2681. smalltalk.addMethod(
  2682. '_fromString_',
  2683. smalltalk.method({
  2684. selector: 'fromString:',
  2685. category: 'instance creation',
  2686. fn: function (aString) {
  2687. var self = this;
  2688. return function () {return new self.fn(aString);}();
  2689. return self;
  2690. },
  2691. source: unescape('fromString%3A%20aString%0A%09%20%20%20%20%5E%7B%27return%20new%20self.fn%28aString%29%3B%27%7D%0A')}),
  2692. smalltalk.String.klass);
  2693. smalltalk.addMethod(
  2694. '_cr',
  2695. smalltalk.method({
  2696. selector: 'cr',
  2697. category: 'accessing',
  2698. fn: function () {
  2699. var self = this;
  2700. return function () {return "\n";}();
  2701. return self;
  2702. },
  2703. source: unescape('cr%0A%09%20%20%20%20%5E%7B%27%7Breturn%20%27%27%5Cn%27%27%7D%3B%27%7D%0A')}),
  2704. smalltalk.String.klass);
  2705. smalltalk.addMethod(
  2706. '_lf',
  2707. smalltalk.method({
  2708. selector: 'lf',
  2709. category: 'accessing',
  2710. fn: function () {
  2711. var self = this;
  2712. return function () {return "\r";}();
  2713. return self;
  2714. },
  2715. source: unescape('lf%0A%09%20%20%20%20%5E%7B%27return%20%27%27%5Cr%27%27%3B%27%7D%0A')}),
  2716. smalltalk.String.klass);
  2717. smalltalk.addMethod(
  2718. '_space',
  2719. smalltalk.method({
  2720. selector: 'space',
  2721. category: 'accessing',
  2722. fn: function () {
  2723. var self = this;
  2724. return function () {return " ";}();
  2725. return self;
  2726. },
  2727. source: unescape('space%0A%09%20%20%20%20%5E%7B%27return%20%27%27%20%27%27%3B%27%7D%0A')}),
  2728. smalltalk.String.klass);
  2729. smalltalk.addMethod(
  2730. '_tab',
  2731. smalltalk.method({
  2732. selector: 'tab',
  2733. category: 'accessing',
  2734. fn: function () {
  2735. var self = this;
  2736. return function () {return "\t";}();
  2737. return self;
  2738. },
  2739. source: unescape('tab%0A%09%20%20%20%20%5E%7B%27return%20%27%27%5Ct%27%27%3B%27%7D%0A')}),
  2740. smalltalk.String.klass);
  2741. smalltalk.addClass('RegularExpression', smalltalk.Object, [], 'Kernel');
  2742. smalltalk.addMethod(
  2743. '_compile_',
  2744. smalltalk.method({
  2745. selector: 'compile:',
  2746. category: 'evaluating',
  2747. fn: function (aString) {
  2748. var self = this;
  2749. return function () {return self.compile(aString);}();
  2750. return self;
  2751. },
  2752. source: unescape('compile%3A%20aString%0A%09%5E%7B%27return%20self.compile%28aString%29%3B%27%7D%0A')}),
  2753. smalltalk.RegularExpression);
  2754. smalltalk.addMethod(
  2755. '_exec_',
  2756. smalltalk.method({
  2757. selector: 'exec:',
  2758. category: 'evaluating',
  2759. fn: function (aString) {
  2760. var self = this;
  2761. return function () {return self.exec(aString);}();
  2762. return self;
  2763. },
  2764. source: unescape('exec%3A%20aString%0A%09%5E%7B%27return%20self.exec%28aString%29%3B%27%7D%0A')}),
  2765. smalltalk.RegularExpression);
  2766. smalltalk.addMethod(
  2767. '_test_',
  2768. smalltalk.method({
  2769. selector: 'test:',
  2770. category: 'evaluating',
  2771. fn: function (aString) {
  2772. var self = this;
  2773. return function () {return self.test(aString);}();
  2774. return self;
  2775. },
  2776. source: unescape('test%3A%20aString%0A%09%5E%7B%27return%20self.test%28aString%29%3B%27%7D%0A')}),
  2777. smalltalk.RegularExpression);
  2778. smalltalk.addMethod(
  2779. '_fromString_flag_',
  2780. smalltalk.method({
  2781. selector: 'fromString:flag:',
  2782. category: 'instance creation',
  2783. fn: function (aString, anotherString) {
  2784. var self = this;
  2785. return function () {return new RegExp(aString, anotherString);}();
  2786. return self;
  2787. },
  2788. source: unescape('fromString%3A%20aString%20flag%3A%20anotherString%0A%09%20%20%20%20%5E%7B%27return%20new%20RegExp%28aString%2C%20anotherString%29%3B%27%7D%0A')}),
  2789. smalltalk.RegularExpression.klass);
  2790. smalltalk.addMethod(
  2791. '_fromString_',
  2792. smalltalk.method({
  2793. selector: 'fromString:',
  2794. category: 'instance creation',
  2795. fn: function (aString) {
  2796. var self = this;
  2797. return self._fromString_flag_(aString, "");
  2798. return self;
  2799. },
  2800. source: unescape('fromString%3A%20aString%0A%09%20%20%20%20%5Eself%20fromString%3A%20aString%20flag%3A%20%27%27%0A')}),
  2801. smalltalk.RegularExpression.klass);
  2802. smalltalk.addClass('Array', smalltalk.Collection, [], 'Kernel');
  2803. smalltalk.addMethod(
  2804. '_size',
  2805. smalltalk.method({
  2806. selector: 'size',
  2807. category: 'accessing',
  2808. fn: function () {
  2809. var self = this;
  2810. return function () {return self.length;}();
  2811. return self;
  2812. },
  2813. source: unescape('size%0A%09%5E%7B%27return%20self.length%27%7D%0A')}),
  2814. smalltalk.Array);
  2815. smalltalk.addMethod(
  2816. '_at_put_',
  2817. smalltalk.method({
  2818. selector: 'at:put:',
  2819. category: 'accessing',
  2820. fn: function (anIndex, anObject) {
  2821. var self = this;
  2822. return function () {return self[anIndex - 1] = anObject;}();
  2823. return self;
  2824. },
  2825. source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%09%5E%7B%27return%20self%5BanIndex%20-%201%5D%20%3D%20anObject%27%7D%0A')}),
  2826. smalltalk.Array);
  2827. smalltalk.addMethod(
  2828. '_at_ifAbsent_',
  2829. smalltalk.method({
  2830. selector: 'at:ifAbsent:',
  2831. category: 'accessing',
  2832. fn: function (anIndex, aBlock) {
  2833. var self = this;
  2834. return function () {var value = self[anIndex - 1];if (value === undefined) {return aBlock();} else {return value;}}();
  2835. return self;
  2836. },
  2837. source: unescape('at%3A%20anIndex%20ifAbsent%3A%20aBlock%0A%09%5E%7B%27%0A%09%20%20%20%20var%20value%20%3D%20self%5BanIndex%20-%201%5D%3B%0A%09%20%20%20%20if%28value%20%3D%3D%3D%20undefined%29%20%7B%0A%09%09return%20aBlock%28%29%3B%0A%09%20%20%20%20%7D%20else%20%7B%0A%09%09return%20value%3B%0A%09%20%20%20%20%7D%0A%09%27%7D%0A')}),
  2838. smalltalk.Array);
  2839. smalltalk.addMethod(
  2840. '_add_',
  2841. smalltalk.method({
  2842. selector: 'add:',
  2843. category: 'adding',
  2844. fn: function (anObject) {
  2845. var self = this;
  2846. return function () {self.push(anObject);return anObject;}();
  2847. return self;
  2848. },
  2849. source: unescape('add%3A%20anObject%0A%09%5E%7B%27self.push%28anObject%29%3B%20return%20anObject%3B%27%7D%0A')}),
  2850. smalltalk.Array);
  2851. smalltalk.addMethod(
  2852. '_addLast_',
  2853. smalltalk.method({
  2854. selector: 'addLast:',
  2855. category: 'adding',
  2856. fn: function (anObject) {
  2857. var self = this;
  2858. return self._add_(anObject);
  2859. return self;
  2860. },
  2861. source: unescape('addLast%3A%20anObject%0A%09%5Eself%20add%3A%20anObject%0A')}),
  2862. smalltalk.Array);
  2863. smalltalk.addMethod(
  2864. '_shallowCopy',
  2865. smalltalk.method({
  2866. selector: 'shallowCopy',
  2867. category: 'copying',
  2868. fn: function () {
  2869. var self = this;
  2870. var newCollection = nil;
  2871. newCollection = self._class()._new();
  2872. self._do_(function (each) {return newCollection._add_(each);});
  2873. return newCollection;
  2874. return self;
  2875. },
  2876. source: unescape('shallowCopy%0A%09%7C%20newCollection%20%7C%0A%09newCollection%20%3A%3D%20self%20class%20new.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%20newCollection%20add%3A%20each%5D.%0A%09%5EnewCollection%0A')}),
  2877. smalltalk.Array);
  2878. smalltalk.addMethod(
  2879. '_deepCopy',
  2880. smalltalk.method({
  2881. selector: 'deepCopy',
  2882. category: 'copying',
  2883. fn: function () {
  2884. var self = this;
  2885. var newCollection = nil;
  2886. newCollection = self._class()._new();
  2887. self._do_(function (each) {return newCollection._add_(each._deepCopy());});
  2888. return newCollection;
  2889. return self;
  2890. },
  2891. source: unescape('deepCopy%0A%09%7C%20newCollection%20%7C%0A%09newCollection%20%3A%3D%20self%20class%20new.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%20newCollection%20add%3A%20each%20deepCopy%5D.%0A%09%5EnewCollection%0A')}),
  2892. smalltalk.Array);
  2893. smalltalk.addMethod(
  2894. '_copyFrom_to_',
  2895. smalltalk.method({
  2896. selector: 'copyFrom:to:',
  2897. category: 'copying',
  2898. fn: function (anIndex, anotherIndex) {
  2899. var self = this;
  2900. var array = nil;
  2901. array = self._class()._new();
  2902. anIndex._to_do_(anotherIndex, function (each) {return array._add_(self._at_(each));});
  2903. return array;
  2904. return self;
  2905. },
  2906. source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%09%7C%20array%20%7C%0A%09array%20%3A%3D%20self%20class%20new.%0A%09anIndex%20to%3A%20anotherIndex%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20array%20add%3A%20%28self%20at%3A%20each%29%5D.%0A%09%5Earray%0A')}),
  2907. smalltalk.Array);
  2908. smalltalk.addMethod(
  2909. '_join_',
  2910. smalltalk.method({
  2911. selector: 'join:',
  2912. category: 'enumerating',
  2913. fn: function (aString) {
  2914. var self = this;
  2915. return function () {return self.join(aString);}();
  2916. return self;
  2917. },
  2918. source: unescape('join%3A%20aString%0A%09%5E%7B%27return%20self.join%28aString%29%3B%27%7D%0A')}),
  2919. smalltalk.Array);
  2920. smalltalk.addMethod(
  2921. '_asJavascript',
  2922. smalltalk.method({
  2923. selector: 'asJavascript',
  2924. category: 'converting',
  2925. fn: function () {
  2926. var self = this;
  2927. return unescape("%5B").__comma(self._collect_(function (each) {return each._asJavascript();})._join_(unescape("%2C%20"))).__comma(unescape("%5D"));
  2928. return self;
  2929. },
  2930. source: unescape('asJavascript%0A%09%5E%27%5B%27%2C%20%28%28self%20collect%3A%20%5B%3Aeach%20%7C%20each%20asJavascript%5D%29%20join%3A%20%27%2C%20%27%29%2C%20%20%27%5D%27%0A')}),
  2931. smalltalk.Array);
  2932. smalltalk.addMethod(
  2933. '_sort',
  2934. smalltalk.method({
  2935. selector: 'sort',
  2936. category: 'enumerating',
  2937. fn: function () {
  2938. var self = this;
  2939. return self._copy()._basicPerform_("sort");
  2940. return self;
  2941. },
  2942. source: unescape('sort%0A%20%20%20%20%5Eself%20copy%20basicPerform%3A%20%27sort%27%0A')}),
  2943. smalltalk.Array);
  2944. smalltalk.addMethod(
  2945. '_sort_',
  2946. smalltalk.method({
  2947. selector: 'sort:',
  2948. category: 'enumerating',
  2949. fn: function (aBlock) {
  2950. var self = this;
  2951. return self._copy()._basicPerform_withArguments_("sort", smalltalk.Array._with_(aBlock));
  2952. return self;
  2953. },
  2954. source: unescape('sort%3A%20aBlock%0A%20%20%20%20%5Eself%20copy%20basicPerform%3A%20%27sort%27%20withArguments%3A%20%28Array%20with%3A%20aBlock%29%0A')}),
  2955. smalltalk.Array);
  2956. smalltalk.addMethod(
  2957. '_remove_',
  2958. smalltalk.method({
  2959. selector: 'remove:',
  2960. category: 'adding',
  2961. fn: function (anObject) {
  2962. var self = this;
  2963. (function () {for (var i = 0; i < self.length; i++) {if (self[i] == anObject) {self.splice(i, 1);break;}}}());
  2964. return self;
  2965. },
  2966. source: unescape('remove%3A%20anObject%0A%20%20%20%20%7B%27for%28var%20i%3D0%3Bi%3Cself.length%3Bi++%29%20%7B%0A%09if%28self%5Bi%5D%20%3D%3D%20anObject%29%20%7B%0A%09%09self.splice%28i%2C1%29%3B%0A%09%09break%3B%0A%09%7D%0A%20%20%20%20%7D%27%7D%0A')}),
  2967. smalltalk.Array);
  2968. smalltalk.addClass('Error', smalltalk.Object, ['messageText'], 'Kernel');
  2969. smalltalk.addMethod(
  2970. '_messageText',
  2971. smalltalk.method({
  2972. selector: 'messageText',
  2973. category: 'accessing',
  2974. fn: function () {
  2975. var self = this;
  2976. return self['@messageText'];
  2977. return self;
  2978. },
  2979. source: unescape('messageText%0A%09%5EmessageText%0A')}),
  2980. smalltalk.Error);
  2981. smalltalk.addMethod(
  2982. '_messageText_',
  2983. smalltalk.method({
  2984. selector: 'messageText:',
  2985. category: 'accessing',
  2986. fn: function (aString) {
  2987. var self = this;
  2988. self['@messageText'] = aString;
  2989. return self;
  2990. },
  2991. source: unescape('messageText%3A%20aString%0A%09messageText%20%3A%3D%20aString%0A')}),
  2992. smalltalk.Error);
  2993. smalltalk.addMethod(
  2994. '_signal',
  2995. smalltalk.method({
  2996. selector: 'signal',
  2997. category: 'signaling',
  2998. fn: function () {
  2999. var self = this;
  3000. return function () {throw {smalltalkError: self};}();
  3001. return self;
  3002. },
  3003. source: unescape('signal%0A%09%5E%7B%27throw%28%7BsmalltalkError%3A%20self%7D%29%27%7D%0A')}),
  3004. smalltalk.Error);
  3005. smalltalk.addMethod(
  3006. '_signal_',
  3007. smalltalk.method({
  3008. selector: 'signal:',
  3009. category: 'instance creation',
  3010. fn: function (aString) {
  3011. var self = this;
  3012. return function ($rec) {$rec._messageText_(aString);return $rec._signal();}(self._new());
  3013. return self;
  3014. },
  3015. source: unescape('signal%3A%20aString%0A%09%20%20%20%20%5Eself%20new%0A%09%09messageText%3A%20aString%3B%0A%09%09signal%0A')}),
  3016. smalltalk.Error.klass);
  3017. smalltalk.addClass('Association', smalltalk.Object, ['key', 'value'], 'Kernel');
  3018. smalltalk.addMethod(
  3019. '__eq',
  3020. smalltalk.method({
  3021. selector: '=',
  3022. category: 'comparing',
  3023. fn: function (anAssociation) {
  3024. var self = this;
  3025. return self._class().__eq(anAssociation._class())._and_(function () {return self._key().__eq(anAssociation._key())._and_(function () {return self._value().__eq(anAssociation._value());});});
  3026. return self;
  3027. },
  3028. source: unescape('%3D%20anAssociation%0A%09%5Eself%20class%20%3D%20anAssociation%20class%20and%3A%20%5B%0A%09%20%20%20%20self%20key%20%3D%20anAssociation%20key%20and%3A%20%5B%0A%09%09self%20value%20%3D%20anAssociation%20value%5D%5D%0A')}),
  3029. smalltalk.Association);
  3030. smalltalk.addMethod(
  3031. '_key_',
  3032. smalltalk.method({
  3033. selector: 'key:',
  3034. category: 'accessing',
  3035. fn: function (aKey) {
  3036. var self = this;
  3037. self['@key'] = aKey;
  3038. return self;
  3039. },
  3040. source: unescape('key%3A%20aKey%0A%09key%20%3A%3D%20aKey%0A')}),
  3041. smalltalk.Association);
  3042. smalltalk.addMethod(
  3043. '_key',
  3044. smalltalk.method({
  3045. selector: 'key',
  3046. category: 'accessing',
  3047. fn: function () {
  3048. var self = this;
  3049. return self['@key'];
  3050. return self;
  3051. },
  3052. source: unescape('key%0A%09%5Ekey%0A')}),
  3053. smalltalk.Association);
  3054. smalltalk.addMethod(
  3055. '_value_',
  3056. smalltalk.method({
  3057. selector: 'value:',
  3058. category: 'accessing',
  3059. fn: function (aValue) {
  3060. var self = this;
  3061. self['@value'] = aValue;
  3062. return self;
  3063. },
  3064. source: unescape('value%3A%20aValue%0A%09value%20%3A%3D%20aValue%0A')}),
  3065. smalltalk.Association);
  3066. smalltalk.addMethod(
  3067. '_value',
  3068. smalltalk.method({
  3069. selector: 'value',
  3070. category: 'accessing',
  3071. fn: function () {
  3072. var self = this;
  3073. return self['@value'];
  3074. return self;
  3075. },
  3076. source: unescape('value%0A%09%5Evalue%0A')}),
  3077. smalltalk.Association);
  3078. smalltalk.addMethod(
  3079. '_key_value_',
  3080. smalltalk.method({
  3081. selector: 'key:value:',
  3082. category: 'instance creation',
  3083. fn: function (aKey, aValue) {
  3084. var self = this;
  3085. return function ($rec) {$rec._key_(aKey);$rec._value_(aValue);return $rec._yourself();}(self._new());
  3086. return self;
  3087. },
  3088. source: unescape('key%3A%20aKey%20value%3A%20aValue%0A%09%20%20%20%20%5Eself%20new%0A%09%09key%3A%20aKey%3B%0A%09%09value%3A%20aValue%3B%0A%09%09yourself%0A')}),
  3089. smalltalk.Association.klass);
  3090. smalltalk.addClass('Dictionary', smalltalk.Collection, ['keys'], 'Kernel');
  3091. smalltalk.addMethod(
  3092. '__eq',
  3093. smalltalk.method({
  3094. selector: '=',
  3095. category: 'comparing',
  3096. fn: function (aDictionary) {
  3097. var self = this;
  3098. try {
  3099. self._class().__eq(aDictionary._class())._ifFalse_(function () {return function () {throw {name: "stReturn", selector: "__eq", fn: function () {return false;}};}();});
  3100. self._associationsDo_(function (assoc) {return aDictionary._at_ifAbsent_(assoc._key(), function () {return function () {throw {name: "stReturn", selector: "__eq", fn: function () {return false;}};}();}).__eq(assoc._value())._ifFalse_(function () {return function () {throw {name: "stReturn", selector: "__eq", fn: function () {return false;}};}();});});
  3101. (function () {throw {name: "stReturn", selector: "__eq", fn: function () {return true;}};}());
  3102. return self;
  3103. } catch (e) {
  3104. if (e.name === "stReturn" && e.selector === "__eq") {
  3105. return e.fn();
  3106. }
  3107. throw e;
  3108. }
  3109. },
  3110. source: unescape('%3D%20aDictionary%0A%09self%20class%20%3D%20aDictionary%20class%20ifFalse%3A%20%5B%5Efalse%5D.%0A%09self%20associationsDo%3A%20%5B%3Aassoc%20%7C%0A%09%20%20%20%20%28aDictionary%20at%3A%20assoc%20key%20ifAbsent%3A%20%5B%5Efalse%5D%29%20%3D%20assoc%20value%20%0A%09%09ifFalse%3A%20%5B%5Efalse%5D%5D.%0A%09%5Etrue%0A')}),
  3111. smalltalk.Dictionary);
  3112. smalltalk.addMethod(
  3113. '_shallowCopy',
  3114. smalltalk.method({
  3115. selector: 'shallowCopy',
  3116. category: 'copying',
  3117. fn: function () {
  3118. var self = this;
  3119. var copy = nil;
  3120. copy = self._class()._new();
  3121. self._associationsDo_(function (each) {return copy._at_put_(each._key(), each._value());});
  3122. return copy;
  3123. return self;
  3124. },
  3125. source: unescape('shallowCopy%0A%09%7C%20copy%20%7C%0A%09copy%20%3A%3D%20self%20class%20new.%0A%09self%20associationsDo%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20copy%20at%3A%20each%20key%20%20put%3A%20each%20value%5D.%0A%09%5Ecopy%0A')}),
  3126. smalltalk.Dictionary);
  3127. smalltalk.addMethod(
  3128. '_initialize',
  3129. smalltalk.method({
  3130. selector: 'initialize',
  3131. category: 'initialization',
  3132. fn: function () {
  3133. var self = this;
  3134. self.klass.superclass.fn.prototype._initialize.apply(self, []);
  3135. self['@keys'] = [];
  3136. return self;
  3137. },
  3138. source: unescape('initialize%0A%20%20%20%20%09super%20initialize.%0A%20%20%20%20%09keys%20%3A%3D%20%23%28%29%0A')}),
  3139. smalltalk.Dictionary);
  3140. smalltalk.addMethod(
  3141. '_size',
  3142. smalltalk.method({
  3143. selector: 'size',
  3144. category: 'accessing',
  3145. fn: function () {
  3146. var self = this;
  3147. return self['@keys']._size();
  3148. return self;
  3149. },
  3150. source: unescape('size%0A%09%5Ekeys%20size%0A')}),
  3151. smalltalk.Dictionary);
  3152. smalltalk.addMethod(
  3153. '_associations',
  3154. smalltalk.method({
  3155. selector: 'associations',
  3156. category: 'accessing',
  3157. fn: function () {
  3158. var self = this;
  3159. var associations = nil;
  3160. associations = [];
  3161. self['@keys']._do_(function (each) {return associations._add_(smalltalk.Association._key_value_(each, self._at_(each)));});
  3162. return associations;
  3163. return self;
  3164. },
  3165. source: unescape('associations%0A%09%7C%20associations%20%7C%0A%09associations%20%3A%3D%20%23%28%29.%0A%09keys%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20associations%20add%3A%20%28Association%20key%3A%20each%20value%3A%20%28self%20at%3A%20each%29%29%5D.%0A%09%5Eassociations%0A')}),
  3166. smalltalk.Dictionary);
  3167. smalltalk.addMethod(
  3168. '_keys',
  3169. smalltalk.method({
  3170. selector: 'keys',
  3171. category: 'accessing',
  3172. fn: function () {
  3173. var self = this;
  3174. return self['@keys']._copy();
  3175. return self;
  3176. },
  3177. source: unescape('keys%0A%09%5Ekeys%20copy%0A')}),
  3178. smalltalk.Dictionary);
  3179. smalltalk.addMethod(
  3180. '_values',
  3181. smalltalk.method({
  3182. selector: 'values',
  3183. category: 'accessing',
  3184. fn: function () {
  3185. var self = this;
  3186. return self['@keys']._collect_(function (each) {return self._at_(each);});
  3187. return self;
  3188. },
  3189. source: unescape('values%0A%20%20%20%20%09%5Ekeys%20collect%3A%20%5B%3Aeach%20%7C%20self%20at%3A%20each%5D%0A')}),
  3190. smalltalk.Dictionary);
  3191. smalltalk.addMethod(
  3192. '_at_put_',
  3193. smalltalk.method({
  3194. selector: 'at:put:',
  3195. category: 'accessing',
  3196. fn: function (aKey, aValue) {
  3197. var self = this;
  3198. self['@keys']._includes_(aKey)._ifFalse_(function () {return self['@keys']._add_(aKey);});
  3199. return self._basicAt_put_(aKey, aValue);
  3200. return self;
  3201. },
  3202. source: unescape('at%3A%20aKey%20put%3A%20aValue%0A%09%28keys%20includes%3A%20aKey%29%20ifFalse%3A%20%5Bkeys%20add%3A%20aKey%5D.%0A%09%5Eself%20basicAt%3A%20aKey%20put%3A%20aValue%0A')}),
  3203. smalltalk.Dictionary);
  3204. smalltalk.addMethod(
  3205. '_at_ifAbsent_',
  3206. smalltalk.method({
  3207. selector: 'at:ifAbsent:',
  3208. category: 'accessing',
  3209. fn: function (aKey, aBlock) {
  3210. var self = this;
  3211. return self._basicAt_(aKey)._ifNil_(aBlock);
  3212. return self;
  3213. },
  3214. source: unescape('at%3A%20aKey%20ifAbsent%3A%20aBlock%0A%09%5E%28self%20basicAt%3A%20aKey%29%20ifNil%3A%20aBlock%0A')}),
  3215. smalltalk.Dictionary);
  3216. smalltalk.addMethod(
  3217. '_at_ifAbsentPut_',
  3218. smalltalk.method({
  3219. selector: 'at:ifAbsentPut:',
  3220. category: 'accessing',
  3221. fn: function (aKey, aBlock) {
  3222. var self = this;
  3223. return self._at_ifAbsent_(aKey, function () {return self._at_put_(aKey, aBlock._value());});
  3224. return self;
  3225. },
  3226. source: unescape('at%3A%20aKey%20ifAbsentPut%3A%20aBlock%0A%20%20%20%20%09%5Eself%20at%3A%20aKey%20ifAbsent%3A%20%5B%0A%20%20%20%20%09%20%20%20%20self%20at%3A%20aKey%20put%3A%20aBlock%20value%5D%0A')}),
  3227. smalltalk.Dictionary);
  3228. smalltalk.addMethod(
  3229. '_at_ifPresent_',
  3230. smalltalk.method({
  3231. selector: 'at:ifPresent:',
  3232. category: 'accessing',
  3233. fn: function (aKey, aBlock) {
  3234. var self = this;
  3235. return self._basicAt_(aKey)._ifNotNil_(function () {return aBlock._value_(self._at_(aKey));});
  3236. return self;
  3237. },
  3238. source: unescape('at%3A%20aKey%20ifPresent%3A%20aBlock%0A%09%5E%28self%20basicAt%3A%20aKey%29%20ifNotNil%3A%20%5BaBlock%20value%3A%20%28self%20at%3A%20aKey%29%5D%0A')}),
  3239. smalltalk.Dictionary);
  3240. smalltalk.addMethod(
  3241. '_at_ifPresent_ifAbsent_',
  3242. smalltalk.method({
  3243. selector: 'at:ifPresent:ifAbsent:',
  3244. category: 'accessing',
  3245. fn: function (aKey, aBlock, anotherBlock) {
  3246. var self = this;
  3247. return self._basicAt_(aKey)._ifNil_ifNotNil_(anotherBlock, function () {return aBlock._value_(self._at_(aKey));});
  3248. return self;
  3249. },
  3250. source: unescape('at%3A%20aKey%20ifPresent%3A%20aBlock%20ifAbsent%3A%20anotherBlock%0A%09%5E%28self%20basicAt%3A%20aKey%29%0A%09%20%20%20%20ifNil%3A%20anotherBlock%0A%09%20%20%20%20ifNotNil%3A%20%5BaBlock%20value%3A%20%28self%20at%3A%20aKey%29%5D%0A')}),
  3251. smalltalk.Dictionary);
  3252. smalltalk.addMethod(
  3253. '_add_',
  3254. smalltalk.method({
  3255. selector: 'add:',
  3256. category: 'adding/removing',
  3257. fn: function (anAssociation) {
  3258. var self = this;
  3259. self._at_put_(anAssociation._key(), anAssociation._value());
  3260. return self;
  3261. },
  3262. source: unescape('add%3A%20anAssociation%0A%20%20%20%20%09self%20at%3A%20anAssociation%20key%20put%3A%20anAssociation%20value%0A')}),
  3263. smalltalk.Dictionary);
  3264. smalltalk.addMethod(
  3265. '_addAll_',
  3266. smalltalk.method({
  3267. selector: 'addAll:',
  3268. category: 'adding/removing',
  3269. fn: function (aDictionary) {
  3270. var self = this;
  3271. self.klass.superclass.fn.prototype._addAll_.apply(self, [aDictionary._associations()]);
  3272. return aDictionary;
  3273. return self;
  3274. },
  3275. source: unescape('addAll%3A%20aDictionary%0A%20%20%20%20%09super%20addAll%3A%20aDictionary%20associations.%0A%20%20%20%20%09%5EaDictionary%0A')}),
  3276. smalltalk.Dictionary);
  3277. smalltalk.addMethod(
  3278. '__comma',
  3279. smalltalk.method({
  3280. selector: ',',
  3281. category: 'copying',
  3282. fn: function (aCollection) {
  3283. var self = this;
  3284. self._shouldNotImplement();
  3285. return self;
  3286. },
  3287. source: unescape('%2C%20aCollection%0A%09self%20shouldNotImplement%0A')}),
  3288. smalltalk.Dictionary);
  3289. smalltalk.addMethod(
  3290. '_copyFrom_to_',
  3291. smalltalk.method({
  3292. selector: 'copyFrom:to:',
  3293. category: 'copying',
  3294. fn: function (anIndex, anotherIndex) {
  3295. var self = this;
  3296. self._shouldNotImplement();
  3297. return self;
  3298. },
  3299. source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%09self%20shouldNotImplement%0A')}),
  3300. smalltalk.Dictionary);
  3301. smalltalk.addMethod(
  3302. '_associationsDo_',
  3303. smalltalk.method({
  3304. selector: 'associationsDo:',
  3305. category: 'enumerating',
  3306. fn: function (aBlock) {
  3307. var self = this;
  3308. self._associations()._do_(aBlock);
  3309. return self;
  3310. },
  3311. source: unescape('associationsDo%3A%20aBlock%0A%20%20%20%20%09self%20associations%20do%3A%20aBlock%0A')}),
  3312. smalltalk.Dictionary);
  3313. smalltalk.addMethod(
  3314. '_keysAndValuesDo_',
  3315. smalltalk.method({
  3316. selector: 'keysAndValuesDo:',
  3317. category: 'enumerating',
  3318. fn: function (aBlock) {
  3319. var self = this;
  3320. self._associationsDo_(function (each) {return aBlock._value_value_(each._key(), each._value());});
  3321. return self;
  3322. },
  3323. source: unescape('keysAndValuesDo%3A%20aBlock%0A%20%20%20%20%09self%20associationsDo%3A%20%5B%3Aeach%20%7C%0A%20%20%20%20%09%20%20%20%20aBlock%20value%3A%20each%20key%20value%3A%20each%20value%5D%0A')}),
  3324. smalltalk.Dictionary);
  3325. smalltalk.addMethod(
  3326. '_do_',
  3327. smalltalk.method({
  3328. selector: 'do:',
  3329. category: 'enumerating',
  3330. fn: function (aBlock) {
  3331. var self = this;
  3332. self._values()._do_(aBlock);
  3333. return self;
  3334. },
  3335. source: unescape('do%3A%20aBlock%0A%20%20%20%20%09self%20values%20do%3A%20aBlock%0A')}),
  3336. smalltalk.Dictionary);
  3337. smalltalk.addMethod(
  3338. '_select_',
  3339. smalltalk.method({
  3340. selector: 'select:',
  3341. category: 'enumerating',
  3342. fn: function (aBlock) {
  3343. var self = this;
  3344. var newDict = nil;
  3345. newDict = self._class()._new();
  3346. self._keysAndValuesDo_(function (key, value) {return aBlock._value_(value)._ifTrue_(function () {return newDict._at_put_(key, value);});});
  3347. return newDict;
  3348. return self;
  3349. },
  3350. source: unescape('select%3A%20aBlock%0A%20%20%20%20%09%7C%20newDict%20%7C%0A%20%20%20%20%09newDict%20%3A%3D%20self%20class%20new.%0A%20%20%20%20%09self%20keysAndValuesDo%3A%20%5B%3Akey%20%3Avalue%20%7C%0A%20%20%20%20%09%20%20%20%20%28aBlock%20value%3A%20value%29%20ifTrue%3A%20%5BnewDict%20at%3A%20key%20put%3A%20value%5D%5D.%0A%20%20%20%20%09%5EnewDict%0A')}),
  3351. smalltalk.Dictionary);
  3352. smalltalk.addMethod(
  3353. '_collect_',
  3354. smalltalk.method({
  3355. selector: 'collect:',
  3356. category: 'enumerating',
  3357. fn: function (aBlock) {
  3358. var self = this;
  3359. var newDict = nil;
  3360. newDict = self._class()._new();
  3361. self._keysAndValuesDo_(function (key, value) {return aBlock._value_(value)._ifTrue_(function () {return newDict._at_put_(key, value);});});
  3362. return newDict;
  3363. return self;
  3364. },
  3365. source: unescape('collect%3A%20aBlock%0A%20%20%20%20%09%7C%20newDict%20%7C%0A%20%20%20%20%09newDict%20%3A%3D%20self%20class%20new.%0A%20%20%20%20%09self%20keysAndValuesDo%3A%20%5B%3Akey%20%3Avalue%20%7C%0A%20%20%20%20%09%20%20%20%20%28aBlock%20value%3A%20value%29%20ifTrue%3A%20%5BnewDict%20at%3A%20key%20put%3A%20value%5D%5D.%0A%20%20%20%20%09%5EnewDict%0A')}),
  3366. smalltalk.Dictionary);
  3367. smalltalk.addMethod(
  3368. '_detect_ifNone_',
  3369. smalltalk.method({
  3370. selector: 'detect:ifNone:',
  3371. category: 'enumerating',
  3372. fn: function (aBlock, anotherBlock) {
  3373. var self = this;
  3374. return self._values()._detect_ifNone_(aBlock, anotherBlock);
  3375. return self;
  3376. },
  3377. source: unescape('detect%3A%20aBlock%20ifNone%3A%20anotherBlock%0A%09%5Eself%20values%20detect%3A%20aBlock%20ifNone%3A%20anotherBlock%0A')}),
  3378. smalltalk.Dictionary);
  3379. smalltalk.addMethod(
  3380. '_includes_',
  3381. smalltalk.method({
  3382. selector: 'includes:',
  3383. category: 'enumerating',
  3384. fn: function (anObject) {
  3385. var self = this;
  3386. return self._values()._includes_(anObject);
  3387. return self;
  3388. },
  3389. source: unescape('includes%3A%20anObject%0A%09%5Eself%20values%20includes%3A%20anObject%0A')}),
  3390. smalltalk.Dictionary);
  3391. smalltalk.addMethod(
  3392. '_remove_',
  3393. smalltalk.method({
  3394. selector: 'remove:',
  3395. category: 'adding/removing',
  3396. fn: function (aKey) {
  3397. var self = this;
  3398. self._removeKey_(aKey);
  3399. return self;
  3400. },
  3401. source: unescape('remove%3A%20aKey%0A%20%20%20%20self%20removeKey%3A%20aKey%0A')}),
  3402. smalltalk.Dictionary);
  3403. smalltalk.addMethod(
  3404. '_removeKey_',
  3405. smalltalk.method({
  3406. selector: 'removeKey:',
  3407. category: 'adding/removing',
  3408. fn: function (aKey) {
  3409. var self = this;
  3410. self['@keys']._remove_(aKey);
  3411. return self;
  3412. },
  3413. source: unescape('removeKey%3A%20aKey%0A%20%20%20%20keys%20remove%3A%20aKey%0A')}),
  3414. smalltalk.Dictionary);
  3415. smalltalk.addClass('ClassBuilder', smalltalk.Object, [], 'Kernel');
  3416. smalltalk.addMethod(
  3417. '_superclass_subclass_',
  3418. smalltalk.method({
  3419. selector: 'superclass:subclass:',
  3420. category: 'class creation',
  3421. fn: function (aClass, aString) {
  3422. var self = this;
  3423. self._superclass_subclass_instanceVariableNames_category_(aClass, aString, "", nil);
  3424. return self;
  3425. },
  3426. source: unescape('superclass%3A%20aClass%20subclass%3A%20aString%0A%09self%20superclass%3A%20aClass%20subclass%3A%20aString%20instanceVariableNames%3A%20%27%27%20category%3A%20nil%0A')}),
  3427. smalltalk.ClassBuilder);
  3428. smalltalk.addMethod(
  3429. '_superclass_subclass_instanceVariableNames_category_',
  3430. smalltalk.method({
  3431. selector: 'superclass:subclass:instanceVariableNames:category:',
  3432. category: 'class creation',
  3433. fn: function (aClass, aString, aString2, aString3) {
  3434. var self = this;
  3435. var newClass = nil;
  3436. newClass = self._addSubclassOf_named_instanceVariableNames_(aClass, aString, self._instanceVariableNamesFor_(aString2));
  3437. self._setupClass_(newClass);
  3438. newClass._category_(aString3._ifNil_(function () {return "unclassified";}));
  3439. return self;
  3440. },
  3441. source: unescape('superclass%3A%20aClass%20subclass%3A%20aString%20instanceVariableNames%3A%20aString2%20category%3A%20aString3%0A%09%7C%20newClass%20%7C%0A%09newClass%20%3A%3D%20self%20addSubclassOf%3A%20aClass%20named%3A%20aString%20instanceVariableNames%3A%20%28self%20instanceVariableNamesFor%3A%20aString2%29.%0A%09self%20setupClass%3A%20newClass.%0A%09newClass%20category%3A%20%28aString3%20ifNil%3A%20%5B%27unclassified%27%5D%29%0A')}),
  3442. smalltalk.ClassBuilder);
  3443. smalltalk.addMethod(
  3444. '_class_instanceVariableNames_',
  3445. smalltalk.method({
  3446. selector: 'class:instanceVariableNames:',
  3447. category: 'class creation',
  3448. fn: function (aClass, aString) {
  3449. var self = this;
  3450. aClass._isMetaclass()._ifFalse_(function () {return self._error_(aClass._name().__comma(" is not a metaclass"));});
  3451. aClass._basicAt_put_("iVarNames", self._instanceVariableNamesFor_(aString));
  3452. self._setupClass_(aClass);
  3453. return self;
  3454. },
  3455. source: unescape('class%3A%20aClass%20instanceVariableNames%3A%20aString%0A%09aClass%20isMetaclass%20ifFalse%3A%20%5Bself%20error%3A%20aClass%20name%2C%20%27%20is%20not%20a%20metaclass%27%5D.%0A%09aClass%20basicAt%3A%20%27iVarNames%27%20put%3A%20%28self%20instanceVariableNamesFor%3A%20aString%29.%0A%09self%20setupClass%3A%20aClass%0A')}),
  3456. smalltalk.ClassBuilder);
  3457. smalltalk.addMethod(
  3458. '_instanceVariableNamesFor_',
  3459. smalltalk.method({
  3460. selector: 'instanceVariableNamesFor:',
  3461. category: 'private',
  3462. fn: function (aString) {
  3463. var self = this;
  3464. return aString._tokenize_(" ")._reject_(function (each) {return each._isEmpty();});
  3465. return self;
  3466. },
  3467. source: unescape('instanceVariableNamesFor%3A%20aString%0A%09%5E%28aString%20tokenize%3A%20%27%20%27%29%20reject%3A%20%5B%3Aeach%20%7C%20each%20isEmpty%5D%0A')}),
  3468. smalltalk.ClassBuilder);
  3469. smalltalk.addMethod(
  3470. '_addSubclassOf_named_instanceVariableNames_',
  3471. smalltalk.method({
  3472. selector: 'addSubclassOf:named:instanceVariableNames:',
  3473. category: 'private',
  3474. fn: function (aClass, aString, aCollection) {
  3475. var self = this;
  3476. return function () {smalltalk.addClass(aString, aClass, aCollection);return smalltalk[aString];}();
  3477. return self;
  3478. },
  3479. source: unescape('addSubclassOf%3A%20aClass%20named%3A%20aString%20instanceVariableNames%3A%20aCollection%0A%09%5E%7B%27smalltalk.addClass%28aString%2C%20aClass%2C%20aCollection%29%3B%0A%09%20%20%20%20return%20smalltalk%5BaString%5D%27%7D%0A')}),
  3480. smalltalk.ClassBuilder);
  3481. smalltalk.addMethod(
  3482. '_setupClass_',
  3483. smalltalk.method({
  3484. selector: 'setupClass:',
  3485. category: 'private',
  3486. fn: function (aClass) {
  3487. var self = this;
  3488. (function () {smalltalk.init(aClass);}());
  3489. return self;
  3490. },
  3491. source: unescape('setupClass%3A%20aClass%0A%09%7B%27smalltalk.init%28aClass%29%3B%27%7D%0A')}),
  3492. smalltalk.ClassBuilder);
  3493. smalltalk.addClass('ClassCategoryReader', smalltalk.Object, ['class', 'category', 'chunkParser'], 'Kernel');
  3494. smalltalk.addMethod(
  3495. '_initialize',
  3496. smalltalk.method({
  3497. selector: 'initialize',
  3498. category: 'initialization',
  3499. fn: function () {
  3500. var self = this;
  3501. self.klass.superclass.fn.prototype._initialize.apply(self, []);
  3502. self['@chunkParser'] = smalltalk.ChunkParser._new();
  3503. return self;
  3504. },
  3505. source: unescape('initialize%0A%09super%20initialize.%0A%09chunkParser%20%3A%3D%20ChunkParser%20new.%0A')}),
  3506. smalltalk.ClassCategoryReader);
  3507. smalltalk.addMethod(
  3508. '_class_category_',
  3509. smalltalk.method({
  3510. selector: 'class:category:',
  3511. category: 'accessing',
  3512. fn: function (aClass, aString) {
  3513. var self = this;
  3514. self['@class'] = aClass;
  3515. self['@category'] = aString;
  3516. return self;
  3517. },
  3518. source: unescape('class%3A%20aClass%20category%3A%20aString%0A%09class%20%3A%3D%20aClass.%0A%09category%20%3A%3D%20aString%0A')}),
  3519. smalltalk.ClassCategoryReader);
  3520. smalltalk.addMethod(
  3521. '_scanFrom_',
  3522. smalltalk.method({
  3523. selector: 'scanFrom:',
  3524. category: 'fileIn',
  3525. fn: function (aStream) {
  3526. var self = this;
  3527. var nextChunk = nil;
  3528. nextChunk = self['@chunkParser']._emptyChunk().__slash(self['@chunkParser']._chunk())._parse_(aStream);
  3529. nextChunk._isEmptyChunk()._ifFalse_(function () {self._compileMethod_(nextChunk._contents());return self._scanFrom_(aStream);});
  3530. return self;
  3531. },
  3532. source: unescape('scanFrom%3A%20aStream%0A%09%7C%20nextChunk%20%7C%0A%09nextChunk%20%3A%3D%20%28chunkParser%20emptyChunk%20/%20chunkParser%20chunk%29%20parse%3A%20aStream.%0A%09nextChunk%20isEmptyChunk%20ifFalse%3A%20%5B%0A%09%20%20%20%20self%20compileMethod%3A%20nextChunk%20contents.%0A%09%20%20%20%20self%20scanFrom%3A%20aStream%5D.%0A')}),
  3533. smalltalk.ClassCategoryReader);
  3534. smalltalk.addMethod(
  3535. '_compileMethod_',
  3536. smalltalk.method({
  3537. selector: 'compileMethod:',
  3538. category: 'private',
  3539. fn: function (aString) {
  3540. var self = this;
  3541. var method = nil;
  3542. method = smalltalk.Compiler._new()._load_forClass_(aString, self['@class']);
  3543. method._category_(self['@category']);
  3544. self['@class']._addCompiledMethod_(method);
  3545. return self;
  3546. },
  3547. source: unescape('compileMethod%3A%20aString%0A%09%7C%20method%20%7C%0A%09method%20%3A%3D%20Compiler%20new%20load%3A%20aString%20forClass%3A%20class.%0A%09method%20category%3A%20category.%0A%09class%20addCompiledMethod%3A%20method%0A')}),
  3548. smalltalk.ClassCategoryReader);
  3549. smalltalk.addClass('Stream', smalltalk.Object, ['collection', 'position', 'streamSize'], 'Kernel');
  3550. smalltalk.addMethod(
  3551. '_collection',
  3552. smalltalk.method({
  3553. selector: 'collection',
  3554. category: 'accessing',
  3555. fn: function () {
  3556. var self = this;
  3557. return self['@collection'];
  3558. return self;
  3559. },
  3560. source: unescape('collection%0A%09%5Ecollection%0A')}),
  3561. smalltalk.Stream);
  3562. smalltalk.addMethod(
  3563. '_setCollection_',
  3564. smalltalk.method({
  3565. selector: 'setCollection:',
  3566. category: 'accessing',
  3567. fn: function (aCollection) {
  3568. var self = this;
  3569. self['@collection'] = aCollection;
  3570. return self;
  3571. },
  3572. source: unescape('setCollection%3A%20aCollection%0A%09collection%20%3A%3D%20aCollection%0A')}),
  3573. smalltalk.Stream);
  3574. smalltalk.addMethod(
  3575. '_position',
  3576. smalltalk.method({
  3577. selector: 'position',
  3578. category: 'accessing',
  3579. fn: function () {
  3580. var self = this;
  3581. return self['@position']._ifNil_(function () {return self['@position'] = 0;});
  3582. return self;
  3583. },
  3584. source: unescape('position%0A%09%5Eposition%20ifNil%3A%20%5Bposition%20%3A%3D%200%5D%0A')}),
  3585. smalltalk.Stream);
  3586. smalltalk.addMethod(
  3587. '_position_',
  3588. smalltalk.method({
  3589. selector: 'position:',
  3590. category: 'accessing',
  3591. fn: function (anInteger) {
  3592. var self = this;
  3593. self['@position'] = anInteger;
  3594. return self;
  3595. },
  3596. source: unescape('position%3A%20anInteger%0A%09position%20%3A%3D%20anInteger%0A')}),
  3597. smalltalk.Stream);
  3598. smalltalk.addMethod(
  3599. '_streamSize',
  3600. smalltalk.method({
  3601. selector: 'streamSize',
  3602. category: 'accessing',
  3603. fn: function () {
  3604. var self = this;
  3605. return self['@streamSize'];
  3606. return self;
  3607. },
  3608. source: unescape('streamSize%0A%09%5EstreamSize%0A')}),
  3609. smalltalk.Stream);
  3610. smalltalk.addMethod(
  3611. '_setStreamSize_',
  3612. smalltalk.method({
  3613. selector: 'setStreamSize:',
  3614. category: 'accessing',
  3615. fn: function (anInteger) {
  3616. var self = this;
  3617. self['@streamSize'] = anInteger;
  3618. return self;
  3619. },
  3620. source: unescape('setStreamSize%3A%20anInteger%0A%09streamSize%20%3A%3D%20anInteger%0A')}),
  3621. smalltalk.Stream);
  3622. smalltalk.addMethod(
  3623. '_contents',
  3624. smalltalk.method({
  3625. selector: 'contents',
  3626. category: 'accessing',
  3627. fn: function () {
  3628. var self = this;
  3629. return self._collection()._copyFrom_to_(1, self._streamSize());
  3630. return self;
  3631. },
  3632. source: unescape('contents%0A%09%5Eself%20collection%0A%09%20%20%20%20copyFrom%3A%201%20%0A%09%20%20%20%20to%3A%20self%20streamSize%0A')}),
  3633. smalltalk.Stream);
  3634. smalltalk.addMethod(
  3635. '_size',
  3636. smalltalk.method({
  3637. selector: 'size',
  3638. category: 'accessing',
  3639. fn: function () {
  3640. var self = this;
  3641. return self._streamSize();
  3642. return self;
  3643. },
  3644. source: unescape('size%0A%09%5Eself%20streamSize%0A')}),
  3645. smalltalk.Stream);
  3646. smalltalk.addMethod(
  3647. '_reset',
  3648. smalltalk.method({
  3649. selector: 'reset',
  3650. category: 'actions',
  3651. fn: function () {
  3652. var self = this;
  3653. self._position_(0);
  3654. return self;
  3655. },
  3656. source: unescape('reset%0A%09self%20position%3A%200%0A')}),
  3657. smalltalk.Stream);
  3658. smalltalk.addMethod(
  3659. '_close',
  3660. smalltalk.method({
  3661. selector: 'close',
  3662. category: 'actions',
  3663. fn: function () {
  3664. var self = this;
  3665. return self;
  3666. },
  3667. source: unescape('close%0A')}),
  3668. smalltalk.Stream);
  3669. smalltalk.addMethod(
  3670. '_flush',
  3671. smalltalk.method({
  3672. selector: 'flush',
  3673. category: 'actions',
  3674. fn: function () {
  3675. var self = this;
  3676. return self;
  3677. },
  3678. source: unescape('flush%0A')}),
  3679. smalltalk.Stream);
  3680. smalltalk.addMethod(
  3681. '_resetContents',
  3682. smalltalk.method({
  3683. selector: 'resetContents',
  3684. category: 'actions',
  3685. fn: function () {
  3686. var self = this;
  3687. self._reset();
  3688. self._setStreamSize_(0);
  3689. return self;
  3690. },
  3691. source: unescape('resetContents%0A%09self%20reset.%0A%09self%20setStreamSize%3A%200%0A')}),
  3692. smalltalk.Stream);
  3693. smalltalk.addMethod(
  3694. '_do_',
  3695. smalltalk.method({
  3696. selector: 'do:',
  3697. category: 'enumerating',
  3698. fn: function (aBlock) {
  3699. var self = this;
  3700. (function () {return self._atEnd();}._whileFalse_(function () {return aBlock._value_(self._next());}));
  3701. return self;
  3702. },
  3703. source: unescape('do%3A%20aBlock%0A%09%5Bself%20atEnd%5D%20whileFalse%3A%20%5BaBlock%20value%3A%20self%20next%5D%0A')}),
  3704. smalltalk.Stream);
  3705. smalltalk.addMethod(
  3706. '_setToEnd',
  3707. smalltalk.method({
  3708. selector: 'setToEnd',
  3709. category: 'positioning',
  3710. fn: function () {
  3711. var self = this;
  3712. self._position_(self._size());
  3713. return self;
  3714. },
  3715. source: unescape('setToEnd%0A%09self%20position%3A%20self%20size%0A')}),
  3716. smalltalk.Stream);
  3717. smalltalk.addMethod(
  3718. '_skip_',
  3719. smalltalk.method({
  3720. selector: 'skip:',
  3721. category: 'positioning',
  3722. fn: function (anInteger) {
  3723. var self = this;
  3724. self._position_(self._position().__plus(anInteger)._min_max_(self._size(), 0));
  3725. return self;
  3726. },
  3727. source: unescape('skip%3A%20anInteger%0A%09self%20position%3A%20%28%28self%20position%20+%20anInteger%29%20min%3A%20self%20size%20max%3A%200%29%0A')}),
  3728. smalltalk.Stream);
  3729. smalltalk.addMethod(
  3730. '_next',
  3731. smalltalk.method({
  3732. selector: 'next',
  3733. category: 'reading',
  3734. fn: function () {
  3735. var self = this;
  3736. self._position_(self._position().__plus(1));
  3737. return self['@collection']._at_(self._position());
  3738. return self;
  3739. },
  3740. source: unescape('next%0A%09self%20position%3A%20self%20position%20+%201.%20%0A%09%5Ecollection%20at%3A%20self%20position%0A')}),
  3741. smalltalk.Stream);
  3742. smalltalk.addMethod(
  3743. '_next_',
  3744. smalltalk.method({
  3745. selector: 'next:',
  3746. category: 'reading',
  3747. fn: function (anInteger) {
  3748. var self = this;
  3749. var tempCollection = nil;
  3750. tempCollection = self._collection()._class()._new();
  3751. anInteger._timesRepeat_(function () {return self._atEnd()._ifFalse_(function () {return tempCollection._add_(self._next());});});
  3752. return tempCollection;
  3753. return self;
  3754. },
  3755. source: unescape('next%3A%20anInteger%0A%09%7C%20tempCollection%20%7C%0A%09tempCollection%20%3A%3D%20self%20collection%20class%20new.%0A%09anInteger%20timesRepeat%3A%20%5B%0A%09%20%20%20%20self%20atEnd%20ifFalse%3A%20%5B%0A%09%09tempCollection%20add%3A%20self%20next%5D%5D.%0A%09%5EtempCollection%0A')}),
  3756. smalltalk.Stream);
  3757. smalltalk.addMethod(
  3758. '_nextPut_',
  3759. smalltalk.method({
  3760. selector: 'nextPut:',
  3761. category: 'writing',
  3762. fn: function (anObject) {
  3763. var self = this;
  3764. self._position_(self._position().__plus(1));
  3765. self._collection()._at_put_(self._position(), anObject);
  3766. self._setStreamSize_(self._streamSize()._max_(self._position()));
  3767. return self;
  3768. },
  3769. source: unescape('nextPut%3A%20anObject%0A%09self%20position%3A%20self%20position%20+%201.%0A%09self%20collection%20at%3A%20self%20position%20put%3A%20anObject.%0A%09self%20setStreamSize%3A%20%28self%20streamSize%20max%3A%20self%20position%29%0A')}),
  3770. smalltalk.Stream);
  3771. smalltalk.addMethod(
  3772. '_nextPutAll_',
  3773. smalltalk.method({
  3774. selector: 'nextPutAll:',
  3775. category: 'writing',
  3776. fn: function (aCollection) {
  3777. var self = this;
  3778. aCollection._do_(function (each) {return self._nextPut_(each);});
  3779. return self;
  3780. },
  3781. source: unescape('nextPutAll%3A%20aCollection%0A%09aCollection%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20self%20nextPut%3A%20each%5D%0A')}),
  3782. smalltalk.Stream);
  3783. smalltalk.addMethod(
  3784. '_peek',
  3785. smalltalk.method({
  3786. selector: 'peek',
  3787. category: 'reading',
  3788. fn: function () {
  3789. var self = this;
  3790. return self._atEnd()._ifFalse_(function () {return self._collection()._at_(self._position().__plus(1));});
  3791. return self;
  3792. },
  3793. source: unescape('peek%0A%09%5Eself%20atEnd%20ifFalse%3A%20%5B%0A%09%20%20%20%20self%20collection%20at%3A%20self%20position%20+%201%5D%0A')}),
  3794. smalltalk.Stream);
  3795. smalltalk.addMethod(
  3796. '_atEnd',
  3797. smalltalk.method({
  3798. selector: 'atEnd',
  3799. category: 'testing',
  3800. fn: function () {
  3801. var self = this;
  3802. return self._position().__eq(self._size());
  3803. return self;
  3804. },
  3805. source: unescape('atEnd%0A%09%5Eself%20position%20%3D%20self%20size%0A')}),
  3806. smalltalk.Stream);
  3807. smalltalk.addMethod(
  3808. '_atStart',
  3809. smalltalk.method({
  3810. selector: 'atStart',
  3811. category: 'testing',
  3812. fn: function () {
  3813. var self = this;
  3814. return self._position().__eq(0);
  3815. return self;
  3816. },
  3817. source: unescape('atStart%0A%09%5Eself%20position%20%3D%200%0A')}),
  3818. smalltalk.Stream);
  3819. smalltalk.addMethod(
  3820. '_isEmpty',
  3821. smalltalk.method({
  3822. selector: 'isEmpty',
  3823. category: 'testing',
  3824. fn: function () {
  3825. var self = this;
  3826. return self._size().__eq(0);
  3827. return self;
  3828. },
  3829. source: unescape('isEmpty%0A%09%5Eself%20size%20%3D%200%0A')}),
  3830. smalltalk.Stream);
  3831. smalltalk.addMethod(
  3832. '_on_',
  3833. smalltalk.method({
  3834. selector: 'on:',
  3835. category: 'instance creation',
  3836. fn: function (aCollection) {
  3837. var self = this;
  3838. return function ($rec) {$rec._setCollection_(aCollection);$rec._setStreamSize_(aCollection._size());return $rec._yourself();}(self._new());
  3839. return self;
  3840. },
  3841. source: unescape('on%3A%20aCollection%0A%09%20%20%20%20%5Eself%20new%20%0A%09%09setCollection%3A%20aCollection%3B%0A%09%09setStreamSize%3A%20aCollection%20size%3B%0A%09%09yourself%0A')}),
  3842. smalltalk.Stream.klass);
  3843. smalltalk.addClass('StringStream', smalltalk.Stream, [], 'Kernel');
  3844. smalltalk.addMethod(
  3845. '_next_',
  3846. smalltalk.method({
  3847. selector: 'next:',
  3848. category: 'reading',
  3849. fn: function (anInteger) {
  3850. var self = this;
  3851. var tempCollection = nil;
  3852. tempCollection = self._collection()._class()._new();
  3853. anInteger._timesRepeat_(function () {return self._atEnd()._ifFalse_(function () {return tempCollection = tempCollection.__comma(self._next());});});
  3854. return tempCollection;
  3855. return self;
  3856. },
  3857. source: unescape('next%3A%20anInteger%0A%09%7C%20tempCollection%20%7C%0A%09tempCollection%20%3A%3D%20self%20collection%20class%20new.%0A%09anInteger%20timesRepeat%3A%20%5B%0A%09%20%20%20%20self%20atEnd%20ifFalse%3A%20%5B%0A%09%09tempCollection%20%3A%3D%20tempCollection%2C%20self%20next%5D%5D.%0A%09%5EtempCollection%0A')}),
  3858. smalltalk.StringStream);
  3859. smalltalk.addMethod(
  3860. '_nextPut_',
  3861. smalltalk.method({
  3862. selector: 'nextPut:',
  3863. category: 'writing',
  3864. fn: function (aString) {
  3865. var self = this;
  3866. self._nextPutAll_(aString);
  3867. return self;
  3868. },
  3869. source: unescape('nextPut%3A%20aString%0A%09self%20nextPutAll%3A%20aString%0A')}),
  3870. smalltalk.StringStream);
  3871. smalltalk.addMethod(
  3872. '_nextPutAll_',
  3873. smalltalk.method({
  3874. selector: 'nextPutAll:',
  3875. category: 'writing',
  3876. fn: function (aString) {
  3877. var self = this;
  3878. self._setCollection_(self._collection()._copyFrom_to_(1, self._position()).__comma(aString).__comma(self._collection()._copyFrom_to_(self._position().__plus(1).__plus(aString._size()), self._collection()._size())));
  3879. self._position_(self._position().__plus(aString._size()));
  3880. self._setStreamSize_(self._streamSize()._max_(self._position()));
  3881. return self;
  3882. },
  3883. source: unescape('nextPutAll%3A%20aString%0A%09self%20setCollection%3A%20%0A%09%20%20%20%20%28self%20collection%20copyFrom%3A%201%20to%3A%20self%20position%29%2C%0A%09%20%20%20%20aString%2C%0A%09%20%20%20%20%28self%20collection%20copyFrom%3A%20%28self%20position%20+%201%20+%20aString%20size%29%20to%3A%20self%20collection%20size%29.%0A%09self%20position%3A%20self%20position%20+%20aString%20size.%0A%09self%20setStreamSize%3A%20%28self%20streamSize%20max%3A%20self%20position%29%0A')}),
  3884. smalltalk.StringStream);
  3885. smalltalk.addClass('ClassCommentReader', smalltalk.Object, ['class', 'chunkParser'], 'Kernel');
  3886. smalltalk.addMethod(
  3887. '_class_',
  3888. smalltalk.method({
  3889. selector: 'class:',
  3890. category: 'accessing',
  3891. fn: function (aClass) {
  3892. var self = this;
  3893. self['@class'] = aClass;
  3894. return self;
  3895. },
  3896. source: unescape('class%3A%20aClass%0A%09class%20%3A%3D%20aClass%0A')}),
  3897. smalltalk.ClassCommentReader);
  3898. smalltalk.addMethod(
  3899. '_scanFrom_',
  3900. smalltalk.method({
  3901. selector: 'scanFrom:',
  3902. category: 'fileIn',
  3903. fn: function (aStream) {
  3904. var self = this;
  3905. var nextChunk = nil;
  3906. nextChunk = self['@chunkParser']._emptyChunk().__slash(self['@chunkParser']._chunk())._parse_(aStream);
  3907. nextChunk._isEmptyChunk()._ifFalse_(function () {return self._setComment_(nextChunk._contents());});
  3908. return self;
  3909. },
  3910. source: unescape('scanFrom%3A%20aStream%0A%09%7C%20nextChunk%20%7C%0A%09nextChunk%20%3A%3D%20%28chunkParser%20emptyChunk%20/%20chunkParser%20chunk%29%20parse%3A%20aStream.%0A%09nextChunk%20isEmptyChunk%20ifFalse%3A%20%5B%0A%09%20%20%20%20self%20setComment%3A%20nextChunk%20contents%5D.%0A')}),
  3911. smalltalk.ClassCommentReader);
  3912. smalltalk.addMethod(
  3913. '_initialize',
  3914. smalltalk.method({
  3915. selector: 'initialize',
  3916. category: 'initialization',
  3917. fn: function () {
  3918. var self = this;
  3919. self.klass.superclass.fn.prototype._initialize.apply(self, []);
  3920. self['@chunkParser'] = smalltalk.ChunkParser._new();
  3921. return self;
  3922. },
  3923. source: unescape('initialize%0A%09super%20initialize.%0A%09chunkParser%20%3A%3D%20ChunkParser%20new.%0A')}),
  3924. smalltalk.ClassCommentReader);
  3925. smalltalk.addMethod(
  3926. '_setComment_',
  3927. smalltalk.method({
  3928. selector: 'setComment:',
  3929. category: 'private',
  3930. fn: function (aString) {
  3931. var self = this;
  3932. self['@class']._comment_(aString);
  3933. return self;
  3934. },
  3935. source: unescape('setComment%3A%20aString%0A%20%20%20%20class%20comment%3A%20aString%0A')}),
  3936. smalltalk.ClassCommentReader);
  3937. smalltalk.addClass('Random', smalltalk.Object, [], 'Kernel');
  3938. smalltalk.addMethod(
  3939. '_next',
  3940. smalltalk.method({
  3941. selector: 'next',
  3942. category: 'accessing',
  3943. fn: function () {
  3944. var self = this;
  3945. return function () {return Math.random();}();
  3946. return self;
  3947. },
  3948. source: unescape('next%0A%20%20%20%20%5E%7B%27return%20Math.random%28%29%27%7D%0A')}),
  3949. smalltalk.Random);
  3950. smalltalk.addMethod(
  3951. '_next_',
  3952. smalltalk.method({
  3953. selector: 'next:',
  3954. category: 'accessing',
  3955. fn: function (anInteger) {
  3956. var self = this;
  3957. return (1)._to_collect_(anInteger, function (each) {return self._next();});
  3958. return self;
  3959. },
  3960. source: unescape('next%3A%20anInteger%0A%20%20%20%20%5E1%20to%3A%20anInteger%20collect%3A%20%5B%3Aeach%20%7C%20self%20next%5D%0A')}),
  3961. smalltalk.Random);
  3962. smalltalk.addClass('Point', smalltalk.Object, ['x', 'y'], 'Kernel');
  3963. smalltalk.addMethod(
  3964. '_x',
  3965. smalltalk.method({
  3966. selector: 'x',
  3967. category: 'accessing',
  3968. fn: function () {
  3969. var self = this;
  3970. return self['@x'];
  3971. return self;
  3972. },
  3973. source: unescape('x%0A%09%5Ex')}),
  3974. smalltalk.Point);
  3975. smalltalk.addMethod(
  3976. '_y',
  3977. smalltalk.method({
  3978. selector: 'y',
  3979. category: 'accessing',
  3980. fn: function () {
  3981. var self = this;
  3982. return self['@y'];
  3983. return self;
  3984. },
  3985. source: unescape('y%0A%09%5Ey')}),
  3986. smalltalk.Point);
  3987. smalltalk.addMethod(
  3988. '_y_',
  3989. smalltalk.method({
  3990. selector: 'y:',
  3991. category: 'accessing',
  3992. fn: function (aNumber) {
  3993. var self = this;
  3994. self['@y'] = aNumber;
  3995. return self;
  3996. },
  3997. source: unescape('y%3A%20aNumber%0A%09y%20%3A%3D%20aNumber')}),
  3998. smalltalk.Point);
  3999. smalltalk.addMethod(
  4000. '_x_',
  4001. smalltalk.method({
  4002. selector: 'x:',
  4003. category: 'accessing',
  4004. fn: function (aNumber) {
  4005. var self = this;
  4006. self['@x'] = aNumber;
  4007. return self;
  4008. },
  4009. source: unescape('x%3A%20aNumber%0A%09x%20%3A%3D%20aNumber')}),
  4010. smalltalk.Point);
  4011. smalltalk.addMethod(
  4012. '__star',
  4013. smalltalk.method({
  4014. selector: '*',
  4015. category: 'arithmetic',
  4016. fn: function (aPoint) {
  4017. var self = this;
  4018. return smalltalk.Point._x_y_(self._x().__star(aPoint._asPoint()._x()), self._y().__star(aPoint._asPoint()._y()));
  4019. return self;
  4020. },
  4021. source: unescape('*%20aPoint%0A%09%5EPoint%20x%3A%20self%20x%20*%20aPoint%20asPoint%20x%20y%3A%20self%20y%20*%20aPoint%20asPoint%20y')}),
  4022. smalltalk.Point);
  4023. smalltalk.addMethod(
  4024. '__plus',
  4025. smalltalk.method({
  4026. selector: '+',
  4027. category: 'arithmetic',
  4028. fn: function (aPoint) {
  4029. var self = this;
  4030. return smalltalk.Point._x_y_(self._x().__plus(aPoint._asPoint()._x()), self._y().__plus(aPoint._asPoint()._y()));
  4031. return self;
  4032. },
  4033. source: unescape('+%20aPoint%0A%09%5EPoint%20x%3A%20self%20x%20+%20aPoint%20asPoint%20x%20y%3A%20self%20y%20+%20aPoint%20asPoint%20y')}),
  4034. smalltalk.Point);
  4035. smalltalk.addMethod(
  4036. '__minus',
  4037. smalltalk.method({
  4038. selector: '-',
  4039. category: 'arithmetic',
  4040. fn: function (aPoint) {
  4041. var self = this;
  4042. return smalltalk.Point._x_y_(self._x().__minus(aPoint._asPoint()._x()), self._y().__minus(aPoint._asPoint()._y()));
  4043. return self;
  4044. },
  4045. source: unescape('-%20aPoint%0A%09%5EPoint%20x%3A%20self%20x%20-%20aPoint%20asPoint%20x%20y%3A%20self%20y%20-%20aPoint%20asPoint%20y')}),
  4046. smalltalk.Point);
  4047. smalltalk.addMethod(
  4048. '__slash',
  4049. smalltalk.method({
  4050. selector: '/',
  4051. category: 'arithmetic',
  4052. fn: function (aPoint) {
  4053. var self = this;
  4054. return smalltalk.Point._x_y_(self._x().__slash(aPoint._asPoint()._x()), self._y().__slash(aPoint._asPoint()._y()));
  4055. return self;
  4056. },
  4057. source: unescape('/%20aPoint%0A%09%5EPoint%20x%3A%20self%20x%20/%20aPoint%20asPoint%20x%20y%3A%20self%20y%20/%20aPoint%20asPoint%20y')}),
  4058. smalltalk.Point);
  4059. smalltalk.addMethod(
  4060. '_asPoint',
  4061. smalltalk.method({
  4062. selector: 'asPoint',
  4063. category: 'converting',
  4064. fn: function () {
  4065. var self = this;
  4066. return self;
  4067. return self;
  4068. },
  4069. source: unescape('asPoint%0A%09%5Eself')}),
  4070. smalltalk.Point);
  4071. smalltalk.addMethod(
  4072. '_x_y_',
  4073. smalltalk.method({
  4074. selector: 'x:y:',
  4075. category: 'instance creation',
  4076. fn: function (aNumber, anotherNumber) {
  4077. var self = this;
  4078. return function ($rec) {$rec._x_(aNumber);$rec._y_(anotherNumber);return $rec._yourself();}(self._new());
  4079. return self;
  4080. },
  4081. source: unescape('x%3A%20aNumber%20y%3A%20anotherNumber%0A%09%5Eself%20new%0A%09%09x%3A%20aNumber%3B%0A%09%09y%3A%20anotherNumber%3B%0A%09%09yourself')}),
  4082. smalltalk.Point.klass);