1
0

Kernel-Objects.js 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482
  1. smalltalk.addPackage('Kernel-Objects', {});
  2. smalltalk.addClass('Object', smalltalk.nil, [], 'Kernel-Objects');
  3. smalltalk.Object.comment="*Object is the root of the Smalltalk class system*. All classes in the system are subclasses of Object.\x0a\x0aObject provides default behavior common to all normal objects, such as: \x0a\x0a- access\x0a- copying\x0a- comparison\x0a- error handling\x0a- message sending\x0a- reflection\x0a\x0aAlso utility messages that all objects should respond to are defined here.\x0a\x0aObject has no instance variable.\x0a\x0a##Access\x0a\x0aInstance variables can be accessed with `#instVarAt:` and `#instVarAt:put:`. `Object >> instanceVariableNames` answers a collection of all instance variable names.\x0aAccessing JavaScript properties of an object is done through `#basicAt:`, `#basicAt:put:` and `basicDelete:`.\x0a\x0a##Copying\x0a\x0aCopying an object is handled by `#copy` and `#deepCopy`. The first one performs a shallow copy of the receiver, while the second one performs a deep copy.\x0aThe hook method `#postCopy` can be overriden in subclasses to copy fields as necessary to complete the full copy. It will be sent by the copy of the receiver.\x0a\x0a##Comparison\x0a\x0aObjects understand equality `#=` and identity `#==` comparison.\x0a\x0a##Error handling\x0a\x0a- `#halt` is the typical message to use for inserting breakpoints during debugging.\x0a- `#error:` throws a generic error exception\x0a- `#doesNotUnderstand:` handles the fact that there was an attempt to send the given message to the receiver but the receiver does not understand this message.\x0a Overriding this message can be useful to implement proxies for example."
  4. smalltalk.addMethod(
  5. "__minus_gt",
  6. smalltalk.method({
  7. selector: "->",
  8. category: 'converting',
  9. fn: function (anObject) {
  10. var self = this;
  11. var $1;
  12. $1 = smalltalk.send(smalltalk.Association || Association, "_key_value_", [self, anObject]);
  13. return $1;
  14. },
  15. args: ["anObject"],
  16. source: "-> anObject\x0a\x09^Association key: self value: anObject",
  17. messageSends: ["key:value:"],
  18. referencedClasses: ["Association"]
  19. }),
  20. smalltalk.Object);
  21. smalltalk.addMethod(
  22. "__eq",
  23. smalltalk.method({
  24. selector: "=",
  25. category: 'comparing',
  26. fn: function (anObject) {
  27. var self = this;
  28. var $1;
  29. $1 = smalltalk.send(self, "__eq_eq", [anObject]);
  30. return $1;
  31. },
  32. args: ["anObject"],
  33. source: "= anObject\x0a\x09^self == anObject",
  34. messageSends: ["=="],
  35. referencedClasses: []
  36. }),
  37. smalltalk.Object);
  38. smalltalk.addMethod(
  39. "__eq_eq",
  40. smalltalk.method({
  41. selector: "==",
  42. category: 'comparing',
  43. fn: function (anObject) {
  44. var self = this;
  45. var $1;
  46. $1 = smalltalk.send(smalltalk.send(self, "_identityHash", []), "__eq", [smalltalk.send(anObject, "_identityHash", [])]);
  47. return $1;
  48. },
  49. args: ["anObject"],
  50. source: "== anObject\x0a\x09^self identityHash = anObject identityHash",
  51. messageSends: ["=", "identityHash"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.Object);
  55. smalltalk.addMethod(
  56. "_asJSON",
  57. smalltalk.method({
  58. selector: "asJSON",
  59. category: 'converting',
  60. fn: function () {
  61. var self = this;
  62. var variables;
  63. variables = smalltalk.send(smalltalk.HashedCollection || HashedCollection, "_new", []);
  64. smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_allInstanceVariableNames", []), "_do_", [function (each) {return smalltalk.send(variables, "_at_put_", [each, smalltalk.send(smalltalk.send(self, "_instVarAt_", [each]), "_asJSON", [])]);}]);
  65. return variables;
  66. },
  67. args: [],
  68. source: "asJSON\x0a\x09| variables |\x0a\x09variables := HashedCollection new.\x0a\x09self class allInstanceVariableNames do: [:each |\x0a\x09\x09variables at: each put: (self instVarAt: each) asJSON].\x0a\x09^variables",
  69. messageSends: ["new", "do:", "at:put:", "asJSON", "instVarAt:", "allInstanceVariableNames", "class"],
  70. referencedClasses: ["HashedCollection"]
  71. }),
  72. smalltalk.Object);
  73. smalltalk.addMethod(
  74. "_asJSONString",
  75. smalltalk.method({
  76. selector: "asJSONString",
  77. category: 'converting',
  78. fn: function () {
  79. var self = this;
  80. var $1;
  81. $1 = smalltalk.send(smalltalk.JSON || JSON, "_stringify_", [smalltalk.send(self, "_asJSON", [])]);
  82. return $1;
  83. },
  84. args: [],
  85. source: "asJSONString\x0a\x09^JSON stringify: self asJSON",
  86. messageSends: ["stringify:", "asJSON"],
  87. referencedClasses: ["JSON"]
  88. }),
  89. smalltalk.Object);
  90. smalltalk.addMethod(
  91. "_asJavascript",
  92. smalltalk.method({
  93. selector: "asJavascript",
  94. category: 'converting',
  95. fn: function () {
  96. var self = this;
  97. var $1;
  98. $1 = smalltalk.send(self, "_asString", []);
  99. return $1;
  100. },
  101. args: [],
  102. source: "asJavascript\x0a\x09^self asString",
  103. messageSends: ["asString"],
  104. referencedClasses: []
  105. }),
  106. smalltalk.Object);
  107. smalltalk.addMethod(
  108. "_asString",
  109. smalltalk.method({
  110. selector: "asString",
  111. category: 'converting',
  112. fn: function () {
  113. var self = this;
  114. var $1;
  115. $1 = smalltalk.send(self, "_printString", []);
  116. return $1;
  117. },
  118. args: [],
  119. source: "asString\x0a\x09^self printString",
  120. messageSends: ["printString"],
  121. referencedClasses: []
  122. }),
  123. smalltalk.Object);
  124. smalltalk.addMethod(
  125. "_basicAt_",
  126. smalltalk.method({
  127. selector: "basicAt:",
  128. category: 'accessing',
  129. fn: function (aString) {
  130. var self = this;
  131. return self[aString];
  132. return self;
  133. },
  134. args: ["aString"],
  135. source: "basicAt: aString\x0a\x09<return self[aString]>",
  136. messageSends: [],
  137. referencedClasses: []
  138. }),
  139. smalltalk.Object);
  140. smalltalk.addMethod(
  141. "_basicAt_put_",
  142. smalltalk.method({
  143. selector: "basicAt:put:",
  144. category: 'accessing',
  145. fn: function (aString, anObject) {
  146. var self = this;
  147. return self[aString] = anObject;
  148. return self;
  149. },
  150. args: ["aString", "anObject"],
  151. source: "basicAt: aString put: anObject\x0a\x09<return self[aString] = anObject>",
  152. messageSends: [],
  153. referencedClasses: []
  154. }),
  155. smalltalk.Object);
  156. smalltalk.addMethod(
  157. "_basicDelete_",
  158. smalltalk.method({
  159. selector: "basicDelete:",
  160. category: 'accessing',
  161. fn: function (aString) {
  162. var self = this;
  163. delete self[aString];
  164. return aString;
  165. return self;
  166. },
  167. args: ["aString"],
  168. source: "basicDelete: aString\x0a <delete self[aString]; return aString>",
  169. messageSends: [],
  170. referencedClasses: []
  171. }),
  172. smalltalk.Object);
  173. smalltalk.addMethod(
  174. "_basicPerform_",
  175. smalltalk.method({
  176. selector: "basicPerform:",
  177. category: 'message handling',
  178. fn: function (aSymbol) {
  179. var self = this;
  180. var $1;
  181. $1 = smalltalk.send(self, "_basicPerform_withArguments_", [aSymbol, []]);
  182. return $1;
  183. },
  184. args: ["aSymbol"],
  185. source: "basicPerform: aSymbol \x0a\x09^self basicPerform: aSymbol withArguments: #()",
  186. messageSends: ["basicPerform:withArguments:"],
  187. referencedClasses: []
  188. }),
  189. smalltalk.Object);
  190. smalltalk.addMethod(
  191. "_basicPerform_withArguments_",
  192. smalltalk.method({
  193. selector: "basicPerform:withArguments:",
  194. category: 'message handling',
  195. fn: function (aSymbol, aCollection) {
  196. var self = this;
  197. return self[aSymbol].apply(self, aCollection);
  198. return self;
  199. },
  200. args: ["aSymbol", "aCollection"],
  201. source: "basicPerform: aSymbol withArguments: aCollection\x0a\x09<return self[aSymbol].apply(self, aCollection);>",
  202. messageSends: [],
  203. referencedClasses: []
  204. }),
  205. smalltalk.Object);
  206. smalltalk.addMethod(
  207. "_class",
  208. smalltalk.method({
  209. selector: "class",
  210. category: 'accessing',
  211. fn: function () {
  212. var self = this;
  213. return self.klass;
  214. return self;
  215. },
  216. args: [],
  217. source: "class\x0a\x09<return self.klass>",
  218. messageSends: [],
  219. referencedClasses: []
  220. }),
  221. smalltalk.Object);
  222. smalltalk.addMethod(
  223. "_copy",
  224. smalltalk.method({
  225. selector: "copy",
  226. category: 'copying',
  227. fn: function () {
  228. var self = this;
  229. var $1;
  230. $1 = smalltalk.send(smalltalk.send(self, "_shallowCopy", []), "_postCopy", []);
  231. return $1;
  232. },
  233. args: [],
  234. source: "copy\x0a\x09^self shallowCopy postCopy",
  235. messageSends: ["postCopy", "shallowCopy"],
  236. referencedClasses: []
  237. }),
  238. smalltalk.Object);
  239. smalltalk.addMethod(
  240. "_deepCopy",
  241. smalltalk.method({
  242. selector: "deepCopy",
  243. category: 'copying',
  244. fn: function () {
  245. var self = this;
  246. var copy = self.klass._new();
  247. for (var i in self) {
  248. if (/^@.+/.test(i)) {
  249. copy[i] = self[i]._deepCopy();
  250. }
  251. }
  252. return copy;
  253. return self;
  254. },
  255. args: [],
  256. source: "deepCopy\x0a\x09< \x0a\x09 var copy = self.klass._new();\x0a\x09 for(var i in self) {\x0a\x09\x09if(/^@.+/.test(i)) {\x0a\x09\x09 copy[i] = self[i]._deepCopy();\x0a\x09\x09}\x0a\x09 }\x0a\x09 return copy;\x0a\x09>",
  257. messageSends: [],
  258. referencedClasses: []
  259. }),
  260. smalltalk.Object);
  261. smalltalk.addMethod(
  262. "_deprecatedAPI",
  263. smalltalk.method({
  264. selector: "deprecatedAPI",
  265. category: 'error handling',
  266. fn: function () {
  267. var self = this;
  268. smalltalk.send(console, "_warn_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(thisContext, "_home", []), "_asString", []), "__comma", [" is deprecated! (in "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(thisContext, "_home", []), "_home", []), "_asString", [])]), "__comma", [")"])]);
  269. return self;
  270. },
  271. args: [],
  272. source: "deprecatedAPI\x0a\x09\x22Just a simple way to deprecate methods.\x0a\x09#deprecatedAPI is in the 'error handling' protocol even if it doesn't throw an error,\x0a\x09but it could in the future.\x22\x0a\x09console warn: thisContext home asString, ' is deprecated! (in ', thisContext home home asString, ')'",
  273. messageSends: ["warn:", ",", "asString", "home"],
  274. referencedClasses: []
  275. }),
  276. smalltalk.Object);
  277. smalltalk.addMethod(
  278. "_doesNotUnderstand_",
  279. smalltalk.method({
  280. selector: "doesNotUnderstand:",
  281. category: 'error handling',
  282. fn: function (aMessage) {
  283. var self = this;
  284. var $1, $2;
  285. $1 = smalltalk.send(smalltalk.MessageNotUnderstood || MessageNotUnderstood, "_new", []);
  286. smalltalk.send($1, "_receiver_", [self]);
  287. smalltalk.send($1, "_message_", [aMessage]);
  288. $2 = smalltalk.send($1, "_signal", []);
  289. return self;
  290. },
  291. args: ["aMessage"],
  292. source: "doesNotUnderstand: aMessage\x0a\x09MessageNotUnderstood new\x0a\x09\x09receiver: self;\x0a\x09\x09message: aMessage;\x0a\x09\x09signal",
  293. messageSends: ["receiver:", "new", "message:", "signal"],
  294. referencedClasses: ["MessageNotUnderstood"]
  295. }),
  296. smalltalk.Object);
  297. smalltalk.addMethod(
  298. "_error_",
  299. smalltalk.method({
  300. selector: "error:",
  301. category: 'error handling',
  302. fn: function (aString) {
  303. var self = this;
  304. smalltalk.send(smalltalk.Error || Error, "_signal_", [aString]);
  305. return self;
  306. },
  307. args: ["aString"],
  308. source: "error: aString\x0a\x09Error signal: aString",
  309. messageSends: ["signal:"],
  310. referencedClasses: ["Error"]
  311. }),
  312. smalltalk.Object);
  313. smalltalk.addMethod(
  314. "_halt",
  315. smalltalk.method({
  316. selector: "halt",
  317. category: 'error handling',
  318. fn: function () {
  319. var self = this;
  320. smalltalk.send(self, "_error_", ["Halt encountered"]);
  321. return self;
  322. },
  323. args: [],
  324. source: "halt\x0a\x09self error: 'Halt encountered'",
  325. messageSends: ["error:"],
  326. referencedClasses: []
  327. }),
  328. smalltalk.Object);
  329. smalltalk.addMethod(
  330. "_identityHash",
  331. smalltalk.method({
  332. selector: "identityHash",
  333. category: 'accessing',
  334. fn: function () {
  335. var self = this;
  336. var hash = self.identityHash;
  337. if (hash) {
  338. return hash;
  339. }
  340. hash = smalltalk.nextId();
  341. Object.defineProperty(self, "identityHash", {value: hash});
  342. return hash;
  343. return self;
  344. },
  345. args: [],
  346. source: "identityHash\x0a\x09<\x0a\x09var hash=self.identityHash;\x0a\x09if (hash) return hash;\x0a\x09hash=smalltalk.nextId();\x0a\x09Object.defineProperty(self, 'identityHash', {value:hash});\x0a\x09return hash;\x0a\x09>",
  347. messageSends: [],
  348. referencedClasses: []
  349. }),
  350. smalltalk.Object);
  351. smalltalk.addMethod(
  352. "_ifNil_",
  353. smalltalk.method({
  354. selector: "ifNil:",
  355. category: 'testing',
  356. fn: function (aBlock) {
  357. var self = this;
  358. return self;
  359. },
  360. args: ["aBlock"],
  361. source: "ifNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self",
  362. messageSends: [],
  363. referencedClasses: []
  364. }),
  365. smalltalk.Object);
  366. smalltalk.addMethod(
  367. "_ifNil_ifNotNil_",
  368. smalltalk.method({
  369. selector: "ifNil:ifNotNil:",
  370. category: 'testing',
  371. fn: function (aBlock, anotherBlock) {
  372. var self = this;
  373. var $1;
  374. $1 = smalltalk.send(anotherBlock, "_value", []);
  375. return $1;
  376. },
  377. args: ["aBlock", "anotherBlock"],
  378. source: "ifNil: aBlock ifNotNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^anotherBlock value",
  379. messageSends: ["value"],
  380. referencedClasses: []
  381. }),
  382. smalltalk.Object);
  383. smalltalk.addMethod(
  384. "_ifNotNil_",
  385. smalltalk.method({
  386. selector: "ifNotNil:",
  387. category: 'testing',
  388. fn: function (aBlock) {
  389. var self = this;
  390. var $1;
  391. $1 = smalltalk.send(aBlock, "_value", []);
  392. return $1;
  393. },
  394. args: ["aBlock"],
  395. source: "ifNotNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^aBlock value",
  396. messageSends: ["value"],
  397. referencedClasses: []
  398. }),
  399. smalltalk.Object);
  400. smalltalk.addMethod(
  401. "_ifNotNil_ifNil_",
  402. smalltalk.method({
  403. selector: "ifNotNil:ifNil:",
  404. category: 'testing',
  405. fn: function (aBlock, anotherBlock) {
  406. var self = this;
  407. var $1;
  408. $1 = smalltalk.send(aBlock, "_value", []);
  409. return $1;
  410. },
  411. args: ["aBlock", "anotherBlock"],
  412. source: "ifNotNil: aBlock ifNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^aBlock value",
  413. messageSends: ["value"],
  414. referencedClasses: []
  415. }),
  416. smalltalk.Object);
  417. smalltalk.addMethod(
  418. "_initialize",
  419. smalltalk.method({
  420. selector: "initialize",
  421. category: 'initialization',
  422. fn: function () {
  423. var self = this;
  424. return self;
  425. },
  426. args: [],
  427. source: "initialize",
  428. messageSends: [],
  429. referencedClasses: []
  430. }),
  431. smalltalk.Object);
  432. smalltalk.addMethod(
  433. "_instVarAt_",
  434. smalltalk.method({
  435. selector: "instVarAt:",
  436. category: 'accessing',
  437. fn: function (aSymbol) {
  438. var self = this;
  439. var varname;
  440. varname = smalltalk.send(aSymbol, "_asString", []);
  441. return self["@" + varname];
  442. return self;
  443. },
  444. args: ["aSymbol"],
  445. source: "instVarAt: aSymbol\x0a\x09| varname |\x0a\x09varname := aSymbol asString.\x0a\x09<return self['@'+varname]>",
  446. messageSends: ["asString"],
  447. referencedClasses: []
  448. }),
  449. smalltalk.Object);
  450. smalltalk.addMethod(
  451. "_instVarAt_put_",
  452. smalltalk.method({
  453. selector: "instVarAt:put:",
  454. category: 'accessing',
  455. fn: function (aSymbol, anObject) {
  456. var self = this;
  457. var varname;
  458. varname = smalltalk.send(aSymbol, "_asString", []);
  459. self["@" + varname] = anObject;
  460. return self;
  461. },
  462. args: ["aSymbol", "anObject"],
  463. source: "instVarAt: aSymbol put: anObject\x0a\x09| varname |\x0a\x09varname := aSymbol asString.\x0a\x09<self['@' + varname] = anObject>",
  464. messageSends: ["asString"],
  465. referencedClasses: []
  466. }),
  467. smalltalk.Object);
  468. smalltalk.addMethod(
  469. "_isClass",
  470. smalltalk.method({
  471. selector: "isClass",
  472. category: 'testing',
  473. fn: function () {
  474. var self = this;
  475. return false;
  476. },
  477. args: [],
  478. source: "isClass\x0a\x09^false",
  479. messageSends: [],
  480. referencedClasses: []
  481. }),
  482. smalltalk.Object);
  483. smalltalk.addMethod(
  484. "_isKindOf_",
  485. smalltalk.method({
  486. selector: "isKindOf:",
  487. category: 'testing',
  488. fn: function (aClass) {
  489. var self = this;
  490. var $2, $1;
  491. $2 = smalltalk.send(self, "_isMemberOf_", [aClass]);
  492. if (smalltalk.assert($2)) {
  493. $1 = true;
  494. } else {
  495. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "_inheritsFrom_", [aClass]);
  496. }
  497. return $1;
  498. },
  499. args: ["aClass"],
  500. source: "isKindOf: aClass\x0a\x09^(self isMemberOf: aClass)\x0a\x09 ifTrue: [true]\x0a\x09 ifFalse: [self class inheritsFrom: aClass]",
  501. messageSends: ["ifTrue:ifFalse:", "inheritsFrom:", "class", "isMemberOf:"],
  502. referencedClasses: []
  503. }),
  504. smalltalk.Object);
  505. smalltalk.addMethod(
  506. "_isMemberOf_",
  507. smalltalk.method({
  508. selector: "isMemberOf:",
  509. category: 'testing',
  510. fn: function (aClass) {
  511. var self = this;
  512. var $1;
  513. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "__eq", [aClass]);
  514. return $1;
  515. },
  516. args: ["aClass"],
  517. source: "isMemberOf: aClass\x0a\x09^self class = aClass",
  518. messageSends: ["=", "class"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.Object);
  522. smalltalk.addMethod(
  523. "_isMetaclass",
  524. smalltalk.method({
  525. selector: "isMetaclass",
  526. category: 'testing',
  527. fn: function () {
  528. var self = this;
  529. return false;
  530. },
  531. args: [],
  532. source: "isMetaclass\x0a\x09^false",
  533. messageSends: [],
  534. referencedClasses: []
  535. }),
  536. smalltalk.Object);
  537. smalltalk.addMethod(
  538. "_isNil",
  539. smalltalk.method({
  540. selector: "isNil",
  541. category: 'testing',
  542. fn: function () {
  543. var self = this;
  544. return false;
  545. },
  546. args: [],
  547. source: "isNil\x0a\x09^false",
  548. messageSends: [],
  549. referencedClasses: []
  550. }),
  551. smalltalk.Object);
  552. smalltalk.addMethod(
  553. "_isNumber",
  554. smalltalk.method({
  555. selector: "isNumber",
  556. category: 'testing',
  557. fn: function () {
  558. var self = this;
  559. return false;
  560. },
  561. args: [],
  562. source: "isNumber\x0a\x09^false",
  563. messageSends: [],
  564. referencedClasses: []
  565. }),
  566. smalltalk.Object);
  567. smalltalk.addMethod(
  568. "_isParseFailure",
  569. smalltalk.method({
  570. selector: "isParseFailure",
  571. category: 'testing',
  572. fn: function () {
  573. var self = this;
  574. return false;
  575. },
  576. args: [],
  577. source: "isParseFailure\x0a\x09^false",
  578. messageSends: [],
  579. referencedClasses: []
  580. }),
  581. smalltalk.Object);
  582. smalltalk.addMethod(
  583. "_isString",
  584. smalltalk.method({
  585. selector: "isString",
  586. category: 'testing',
  587. fn: function () {
  588. var self = this;
  589. return false;
  590. },
  591. args: [],
  592. source: "isString\x0a\x09^false",
  593. messageSends: [],
  594. referencedClasses: []
  595. }),
  596. smalltalk.Object);
  597. smalltalk.addMethod(
  598. "_isSymbol",
  599. smalltalk.method({
  600. selector: "isSymbol",
  601. category: 'testing',
  602. fn: function () {
  603. var self = this;
  604. return false;
  605. },
  606. args: [],
  607. source: "isSymbol\x0a\x09^false",
  608. messageSends: [],
  609. referencedClasses: []
  610. }),
  611. smalltalk.Object);
  612. smalltalk.addMethod(
  613. "_log_block_",
  614. smalltalk.method({
  615. selector: "log:block:",
  616. category: 'printing',
  617. fn: function (aString, aBlock) {
  618. var self = this;
  619. var result;
  620. smalltalk.send(console, "_log_", [smalltalk.send(smalltalk.send(aString, "__comma", [" time: "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.Date || Date, "_millisecondsToRun_", [function () {result = smalltalk.send(aBlock, "_value", []);return result;}]), "_printString", [])])]);
  621. return result;
  622. },
  623. args: ["aString", "aBlock"],
  624. source: "log: aString block: aBlock\x0a\x0a\x09| result |\x0a\x09console log: aString, ' time: ', (Date millisecondsToRun: [result := aBlock value]) printString.\x0a\x09^result",
  625. messageSends: ["log:", ",", "printString", "millisecondsToRun:", "value"],
  626. referencedClasses: ["Date"]
  627. }),
  628. smalltalk.Object);
  629. smalltalk.addMethod(
  630. "_notNil",
  631. smalltalk.method({
  632. selector: "notNil",
  633. category: 'testing',
  634. fn: function () {
  635. var self = this;
  636. var $1;
  637. $1 = smalltalk.send(smalltalk.send(self, "_isNil", []), "_not", []);
  638. return $1;
  639. },
  640. args: [],
  641. source: "notNil\x0a\x09^self isNil not",
  642. messageSends: ["not", "isNil"],
  643. referencedClasses: []
  644. }),
  645. smalltalk.Object);
  646. smalltalk.addMethod(
  647. "_perform_",
  648. smalltalk.method({
  649. selector: "perform:",
  650. category: 'message handling',
  651. fn: function (aSymbol) {
  652. var self = this;
  653. var $1;
  654. $1 = smalltalk.send(self, "_perform_withArguments_", [aSymbol, []]);
  655. return $1;
  656. },
  657. args: ["aSymbol"],
  658. source: "perform: aSymbol\x0a\x09^self perform: aSymbol withArguments: #()",
  659. messageSends: ["perform:withArguments:"],
  660. referencedClasses: []
  661. }),
  662. smalltalk.Object);
  663. smalltalk.addMethod(
  664. "_perform_withArguments_",
  665. smalltalk.method({
  666. selector: "perform:withArguments:",
  667. category: 'message handling',
  668. fn: function (aSymbol, aCollection) {
  669. var self = this;
  670. var selector;
  671. selector = smalltalk.send(aSymbol, "_asSelector", []);
  672. return smalltalk.send(self, selector, aCollection);
  673. return self;
  674. },
  675. args: ["aSymbol", "aCollection"],
  676. source: "perform: aSymbol withArguments: aCollection\x0a\x09| selector |\x0a\x09selector := aSymbol asSelector.\x0a\x09<return smalltalk.send(self, selector, aCollection)>",
  677. messageSends: ["asSelector"],
  678. referencedClasses: []
  679. }),
  680. smalltalk.Object);
  681. smalltalk.addMethod(
  682. "_postCopy",
  683. smalltalk.method({
  684. selector: "postCopy",
  685. category: 'copying',
  686. fn: function () {
  687. var self = this;
  688. return self;
  689. },
  690. args: [],
  691. source: "postCopy",
  692. messageSends: [],
  693. referencedClasses: []
  694. }),
  695. smalltalk.Object);
  696. smalltalk.addMethod(
  697. "_printNl",
  698. smalltalk.method({
  699. selector: "printNl",
  700. category: 'printing',
  701. fn: function () {
  702. var self = this;
  703. console.log(self);
  704. return self;
  705. },
  706. args: [],
  707. source: "printNl\x0a\x09<console.log(self)>",
  708. messageSends: [],
  709. referencedClasses: []
  710. }),
  711. smalltalk.Object);
  712. smalltalk.addMethod(
  713. "_printString",
  714. smalltalk.method({
  715. selector: "printString",
  716. category: 'printing',
  717. fn: function () {
  718. var self = this;
  719. var $1;
  720. $1 = smalltalk.send("a ", "__comma", [smalltalk.send(smalltalk.send(self, "_class", []), "_name", [])]);
  721. return $1;
  722. },
  723. args: [],
  724. source: "printString\x0a\x09^'a ', self class name",
  725. messageSends: [",", "name", "class"],
  726. referencedClasses: []
  727. }),
  728. smalltalk.Object);
  729. smalltalk.addMethod(
  730. "_respondsTo_",
  731. smalltalk.method({
  732. selector: "respondsTo:",
  733. category: 'testing',
  734. fn: function (aSelector) {
  735. var self = this;
  736. var $1;
  737. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "_canUnderstand_", [aSelector]);
  738. return $1;
  739. },
  740. args: ["aSelector"],
  741. source: "respondsTo: aSelector\x0a\x09^self class canUnderstand: aSelector",
  742. messageSends: ["canUnderstand:", "class"],
  743. referencedClasses: []
  744. }),
  745. smalltalk.Object);
  746. smalltalk.addMethod(
  747. "_shallowCopy",
  748. smalltalk.method({
  749. selector: "shallowCopy",
  750. category: 'copying',
  751. fn: function () {
  752. var self = this;
  753. var copy = self.klass._new();
  754. for (var i in self) {
  755. if (/^@.+/.test(i)) {
  756. copy[i] = self[i];
  757. }
  758. }
  759. return copy;
  760. return self;
  761. },
  762. args: [],
  763. source: "shallowCopy\x0a\x09<\x0a\x09 var copy = self.klass._new();\x0a\x09 for(var i in self) {\x0a\x09\x09if(/^@.+/.test(i)) {\x0a\x09\x09 copy[i] = self[i];\x0a\x09\x09}\x0a\x09 }\x0a\x09 return copy;\x0a\x09>",
  764. messageSends: [],
  765. referencedClasses: []
  766. }),
  767. smalltalk.Object);
  768. smalltalk.addMethod(
  769. "_shouldNotImplement",
  770. smalltalk.method({
  771. selector: "shouldNotImplement",
  772. category: 'error handling',
  773. fn: function () {
  774. var self = this;
  775. smalltalk.send(self, "_error_", [smalltalk.send("This method should not be implemented in ", "__comma", [smalltalk.send(smalltalk.send(self, "_class", []), "_name", [])])]);
  776. return self;
  777. },
  778. args: [],
  779. source: "shouldNotImplement\x0a\x09self error: 'This method should not be implemented in ', self class name",
  780. messageSends: ["error:", ",", "name", "class"],
  781. referencedClasses: []
  782. }),
  783. smalltalk.Object);
  784. smalltalk.addMethod(
  785. "_size",
  786. smalltalk.method({
  787. selector: "size",
  788. category: 'accessing',
  789. fn: function () {
  790. var self = this;
  791. smalltalk.send(self, "_error_", ["Object not indexable"]);
  792. return self;
  793. },
  794. args: [],
  795. source: "size\x0a\x09self error: 'Object not indexable'",
  796. messageSends: ["error:"],
  797. referencedClasses: []
  798. }),
  799. smalltalk.Object);
  800. smalltalk.addMethod(
  801. "_storeOn_",
  802. smalltalk.method({
  803. selector: "storeOn:",
  804. category: 'printing',
  805. fn: function (aStream) {
  806. var self = this;
  807. smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(self, "_printString", [])]);
  808. return self;
  809. },
  810. args: ["aStream"],
  811. source: "storeOn: aStream\x0a\x09aStream nextPutAll: self printString",
  812. messageSends: ["nextPutAll:", "printString"],
  813. referencedClasses: []
  814. }),
  815. smalltalk.Object);
  816. smalltalk.addMethod(
  817. "_storeString",
  818. smalltalk.method({
  819. selector: "storeString",
  820. category: 'printing',
  821. fn: function () {
  822. var self = this;
  823. var $1;
  824. $1 = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (s) {return smalltalk.send(self, "_storeOn_", [s]);}]);
  825. return $1;
  826. },
  827. args: [],
  828. source: "storeString\x0a\x09\x22Answer a String representation of the receiver from which the receiver \x0a\x09can be reconstructed.\x22\x0a\x0a\x09^ String streamContents: [:s | self storeOn: s]",
  829. messageSends: ["streamContents:", "storeOn:"],
  830. referencedClasses: ["String"]
  831. }),
  832. smalltalk.Object);
  833. smalltalk.addMethod(
  834. "_subclassResponsibility",
  835. smalltalk.method({
  836. selector: "subclassResponsibility",
  837. category: 'error handling',
  838. fn: function () {
  839. var self = this;
  840. smalltalk.send(self, "_error_", ["This method is a responsibility of a subclass"]);
  841. return self;
  842. },
  843. args: [],
  844. source: "subclassResponsibility\x0a\x09self error: 'This method is a responsibility of a subclass'",
  845. messageSends: ["error:"],
  846. referencedClasses: []
  847. }),
  848. smalltalk.Object);
  849. smalltalk.addMethod(
  850. "_throw_",
  851. smalltalk.method({
  852. selector: "throw:",
  853. category: 'error handling',
  854. fn: function (anObject) {
  855. var self = this;
  856. throw anObject;
  857. return self;
  858. },
  859. args: ["anObject"],
  860. source: "throw: anObject\x0a\x09< throw anObject >",
  861. messageSends: [],
  862. referencedClasses: []
  863. }),
  864. smalltalk.Object);
  865. smalltalk.addMethod(
  866. "_try_catch_",
  867. smalltalk.method({
  868. selector: "try:catch:",
  869. category: 'error handling',
  870. fn: function (aBlock, anotherBlock) {
  871. var self = this;
  872. try {
  873. result = aBlock();
  874. } catch (e) {
  875. result = anotherBlock(e);
  876. }
  877. return result;
  878. return self;
  879. },
  880. args: ["aBlock", "anotherBlock"],
  881. source: "try: aBlock catch: anotherBlock\x0a\x09<try{result = aBlock()} catch(e) {result = anotherBlock(e)};\x0a\x09return result;>",
  882. messageSends: [],
  883. referencedClasses: []
  884. }),
  885. smalltalk.Object);
  886. smalltalk.addMethod(
  887. "_value",
  888. smalltalk.method({
  889. selector: "value",
  890. category: 'accessing',
  891. fn: function () {
  892. var self = this;
  893. return self;
  894. },
  895. args: [],
  896. source: "value\x0a\x09^ self",
  897. messageSends: [],
  898. referencedClasses: []
  899. }),
  900. smalltalk.Object);
  901. smalltalk.addMethod(
  902. "_yourself",
  903. smalltalk.method({
  904. selector: "yourself",
  905. category: 'accessing',
  906. fn: function () {
  907. var self = this;
  908. return self;
  909. },
  910. args: [],
  911. source: "yourself\x0a\x09^self",
  912. messageSends: [],
  913. referencedClasses: []
  914. }),
  915. smalltalk.Object);
  916. smalltalk.addMethod(
  917. "_~_eq",
  918. smalltalk.method({
  919. selector: "~=",
  920. category: 'comparing',
  921. fn: function (anObject) {
  922. var self = this;
  923. var $1;
  924. $1 = smalltalk.send(smalltalk.send(self, "__eq", [anObject]), "__eq", [false]);
  925. return $1;
  926. },
  927. args: ["anObject"],
  928. source: "~= anObject\x0a\x09^(self = anObject) = false",
  929. messageSends: ["="],
  930. referencedClasses: []
  931. }),
  932. smalltalk.Object);
  933. smalltalk.addMethod(
  934. "_~~",
  935. smalltalk.method({
  936. selector: "~~",
  937. category: 'comparing',
  938. fn: function (anObject) {
  939. var self = this;
  940. var $1;
  941. $1 = smalltalk.send(smalltalk.send(self, "__eq_eq", [anObject]), "__eq", [false]);
  942. return $1;
  943. },
  944. args: ["anObject"],
  945. source: "~~ anObject\x0a\x09^(self == anObject) = false",
  946. messageSends: ["=", "=="],
  947. referencedClasses: []
  948. }),
  949. smalltalk.Object);
  950. smalltalk.addMethod(
  951. "_initialize",
  952. smalltalk.method({
  953. selector: "initialize",
  954. category: 'initialization',
  955. fn: function () {
  956. var self = this;
  957. return self;
  958. },
  959. args: [],
  960. source: "initialize\x0a\x09\x22no op\x22",
  961. messageSends: [],
  962. referencedClasses: []
  963. }),
  964. smalltalk.Object.klass);
  965. smalltalk.addClass('Boolean', smalltalk.Object, [], 'Kernel-Objects');
  966. smalltalk.Boolean.comment="Boolean wraps the JavaScript `Boolean()` constructor. The `true` and `false` objects are the JavaScript boolean objects.\x0a\x0aBoolean defines the protocol for logic testing operations and conditional control structures for the logical values.\x0aBoolean instances are weither `true` or `false`."
  967. smalltalk.addMethod(
  968. "_&",
  969. smalltalk.method({
  970. selector: "&",
  971. category: 'controlling',
  972. fn: function (aBoolean) {
  973. var self = this;
  974. if (self == true) {
  975. return aBoolean;
  976. } else {
  977. return false;
  978. }
  979. return self;
  980. },
  981. args: ["aBoolean"],
  982. source: "& aBoolean\x0a\x09<\x0a\x09 if(self == true) {\x0a\x09\x09return aBoolean;\x0a\x09 } else {\x0a\x09\x09return false;\x0a\x09 }\x0a\x09>",
  983. messageSends: [],
  984. referencedClasses: []
  985. }),
  986. smalltalk.Boolean);
  987. smalltalk.addMethod(
  988. "__eq",
  989. smalltalk.method({
  990. selector: "=",
  991. category: 'comparing',
  992. fn: function (aBoolean) {
  993. var self = this;
  994. var $1;
  995. $1 = smalltalk.send(smalltalk.send(aBoolean, "_class", []), "__eq", [smalltalk.send(self, "_class", [])]);
  996. if (!smalltalk.assert($1)) {
  997. return false;
  998. }
  999. return Boolean(self == true) == aBoolean;
  1000. return self;
  1001. },
  1002. args: ["aBoolean"],
  1003. source: "= aBoolean\x0a\x09aBoolean class = self class ifFalse: [^false].\x0a\x09<return Boolean(self == true) == aBoolean>",
  1004. messageSends: ["ifFalse:", "=", "class"],
  1005. referencedClasses: []
  1006. }),
  1007. smalltalk.Boolean);
  1008. smalltalk.addMethod(
  1009. "__eq_eq",
  1010. smalltalk.method({
  1011. selector: "==",
  1012. category: 'comparing',
  1013. fn: function (aBoolean) {
  1014. var self = this;
  1015. var $1;
  1016. $1 = smalltalk.send(self, "__eq", [aBoolean]);
  1017. return $1;
  1018. },
  1019. args: ["aBoolean"],
  1020. source: "== aBoolean\x0a\x09^self = aBoolean",
  1021. messageSends: ["="],
  1022. referencedClasses: []
  1023. }),
  1024. smalltalk.Boolean);
  1025. smalltalk.addMethod(
  1026. "_and_",
  1027. smalltalk.method({
  1028. selector: "and:",
  1029. category: 'controlling',
  1030. fn: function (aBlock) {
  1031. var self = this;
  1032. var $2, $1;
  1033. $2 = smalltalk.send(self, "__eq", [true]);
  1034. $1 = smalltalk.send($2, "_ifTrue_ifFalse_", [aBlock, function () {return false;}]);
  1035. return $1;
  1036. },
  1037. args: ["aBlock"],
  1038. source: "and: aBlock\x0a\x09^self = true\x0a\x09 ifTrue: aBlock\x0a\x09 ifFalse: [false]",
  1039. messageSends: ["ifTrue:ifFalse:", "="],
  1040. referencedClasses: []
  1041. }),
  1042. smalltalk.Boolean);
  1043. smalltalk.addMethod(
  1044. "_asJSON",
  1045. smalltalk.method({
  1046. selector: "asJSON",
  1047. category: 'converting',
  1048. fn: function () {
  1049. var self = this;
  1050. return self;
  1051. },
  1052. args: [],
  1053. source: "asJSON\x0a\x09^self",
  1054. messageSends: [],
  1055. referencedClasses: []
  1056. }),
  1057. smalltalk.Boolean);
  1058. smalltalk.addMethod(
  1059. "_deepCopy",
  1060. smalltalk.method({
  1061. selector: "deepCopy",
  1062. category: 'copying',
  1063. fn: function () {
  1064. var self = this;
  1065. return self;
  1066. },
  1067. args: [],
  1068. source: "deepCopy\x0a\x09^self",
  1069. messageSends: [],
  1070. referencedClasses: []
  1071. }),
  1072. smalltalk.Boolean);
  1073. smalltalk.addMethod(
  1074. "_ifFalse_",
  1075. smalltalk.method({
  1076. selector: "ifFalse:",
  1077. category: 'controlling',
  1078. fn: function (aBlock) {
  1079. var self = this;
  1080. var $1;
  1081. $1 = smalltalk.send(self, "_ifTrue_ifFalse_", [function () {}, aBlock]);
  1082. return $1;
  1083. },
  1084. args: ["aBlock"],
  1085. source: "ifFalse: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self ifTrue: [] ifFalse: aBlock",
  1086. messageSends: ["ifTrue:ifFalse:"],
  1087. referencedClasses: []
  1088. }),
  1089. smalltalk.Boolean);
  1090. smalltalk.addMethod(
  1091. "_ifFalse_ifTrue_",
  1092. smalltalk.method({
  1093. selector: "ifFalse:ifTrue:",
  1094. category: 'controlling',
  1095. fn: function (aBlock, anotherBlock) {
  1096. var self = this;
  1097. var $1;
  1098. $1 = smalltalk.send(self, "_ifTrue_ifFalse_", [anotherBlock, aBlock]);
  1099. return $1;
  1100. },
  1101. args: ["aBlock", "anotherBlock"],
  1102. source: "ifFalse: aBlock ifTrue: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self ifTrue: anotherBlock ifFalse: aBlock",
  1103. messageSends: ["ifTrue:ifFalse:"],
  1104. referencedClasses: []
  1105. }),
  1106. smalltalk.Boolean);
  1107. smalltalk.addMethod(
  1108. "_ifTrue_",
  1109. smalltalk.method({
  1110. selector: "ifTrue:",
  1111. category: 'controlling',
  1112. fn: function (aBlock) {
  1113. var self = this;
  1114. var $1;
  1115. $1 = smalltalk.send(self, "_ifTrue_ifFalse_", [aBlock, function () {}]);
  1116. return $1;
  1117. },
  1118. args: ["aBlock"],
  1119. source: "ifTrue: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self ifTrue: aBlock ifFalse: []",
  1120. messageSends: ["ifTrue:ifFalse:"],
  1121. referencedClasses: []
  1122. }),
  1123. smalltalk.Boolean);
  1124. smalltalk.addMethod(
  1125. "_ifTrue_ifFalse_",
  1126. smalltalk.method({
  1127. selector: "ifTrue:ifFalse:",
  1128. category: 'controlling',
  1129. fn: function (aBlock, anotherBlock) {
  1130. var self = this;
  1131. if (self == true) {
  1132. return aBlock();
  1133. } else {
  1134. return anotherBlock();
  1135. }
  1136. return self;
  1137. },
  1138. args: ["aBlock", "anotherBlock"],
  1139. source: "ifTrue: aBlock ifFalse: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<\x0a\x09 if(self == true) {\x0a\x09\x09return aBlock();\x0a\x09 } else {\x0a\x09\x09return anotherBlock();\x0a\x09 }\x0a\x09>",
  1140. messageSends: [],
  1141. referencedClasses: []
  1142. }),
  1143. smalltalk.Boolean);
  1144. smalltalk.addMethod(
  1145. "_not",
  1146. smalltalk.method({
  1147. selector: "not",
  1148. category: 'controlling',
  1149. fn: function () {
  1150. var self = this;
  1151. var $1;
  1152. $1 = smalltalk.send(self, "__eq", [false]);
  1153. return $1;
  1154. },
  1155. args: [],
  1156. source: "not\x0a\x09^self = false",
  1157. messageSends: ["="],
  1158. referencedClasses: []
  1159. }),
  1160. smalltalk.Boolean);
  1161. smalltalk.addMethod(
  1162. "_or_",
  1163. smalltalk.method({
  1164. selector: "or:",
  1165. category: 'controlling',
  1166. fn: function (aBlock) {
  1167. var self = this;
  1168. var $2, $1;
  1169. $2 = smalltalk.send(self, "__eq", [true]);
  1170. $1 = smalltalk.send($2, "_ifTrue_ifFalse_", [function () {return true;}, aBlock]);
  1171. return $1;
  1172. },
  1173. args: ["aBlock"],
  1174. source: "or: aBlock\x0a\x09^self = true\x0a\x09 ifTrue: [true]\x0a\x09 ifFalse: aBlock",
  1175. messageSends: ["ifTrue:ifFalse:", "="],
  1176. referencedClasses: []
  1177. }),
  1178. smalltalk.Boolean);
  1179. smalltalk.addMethod(
  1180. "_printString",
  1181. smalltalk.method({
  1182. selector: "printString",
  1183. category: 'printing',
  1184. fn: function () {
  1185. var self = this;
  1186. return self.toString();
  1187. return self;
  1188. },
  1189. args: [],
  1190. source: "printString\x0a\x09<return self.toString()>",
  1191. messageSends: [],
  1192. referencedClasses: []
  1193. }),
  1194. smalltalk.Boolean);
  1195. smalltalk.addMethod(
  1196. "_shallowCopy",
  1197. smalltalk.method({
  1198. selector: "shallowCopy",
  1199. category: 'copying',
  1200. fn: function () {
  1201. var self = this;
  1202. return self;
  1203. },
  1204. args: [],
  1205. source: "shallowCopy\x0a\x09^self",
  1206. messageSends: [],
  1207. referencedClasses: []
  1208. }),
  1209. smalltalk.Boolean);
  1210. smalltalk.addMethod(
  1211. "_|",
  1212. smalltalk.method({
  1213. selector: "|",
  1214. category: 'controlling',
  1215. fn: function (aBoolean) {
  1216. var self = this;
  1217. if (self == true) {
  1218. return true;
  1219. } else {
  1220. return aBoolean;
  1221. }
  1222. return self;
  1223. },
  1224. args: ["aBoolean"],
  1225. source: "| aBoolean\x0a\x09<\x0a\x09 if(self == true) {\x0a\x09\x09return true;\x0a\x09 } else {\x0a\x09\x09return aBoolean;\x0a\x09 }\x0a\x09>",
  1226. messageSends: [],
  1227. referencedClasses: []
  1228. }),
  1229. smalltalk.Boolean);
  1230. smalltalk.addClass('Date', smalltalk.Object, [], 'Kernel-Objects');
  1231. smalltalk.Date.comment="The Date class is used to work with dates and times. Therefore `Date today` and `Date now` are both valid in\x0aAmber and answer the same date object.\x0a\x0aDate wraps the `Date()` JavaScript constructor, and Smalltalk date objects are JavaScript date objects."
  1232. smalltalk.addMethod(
  1233. "__plus",
  1234. smalltalk.method({
  1235. selector: "+",
  1236. category: 'arithmetic',
  1237. fn: function (aDate) {
  1238. var self = this;
  1239. return self + aDate;
  1240. return self;
  1241. },
  1242. args: ["aDate"],
  1243. source: "+ aDate\x0a\x09<return self + aDate>",
  1244. messageSends: [],
  1245. referencedClasses: []
  1246. }),
  1247. smalltalk.Date);
  1248. smalltalk.addMethod(
  1249. "__minus",
  1250. smalltalk.method({
  1251. selector: "-",
  1252. category: 'arithmetic',
  1253. fn: function (aDate) {
  1254. var self = this;
  1255. return self - aDate;
  1256. return self;
  1257. },
  1258. args: ["aDate"],
  1259. source: "- aDate\x0a\x09<return self - aDate>",
  1260. messageSends: [],
  1261. referencedClasses: []
  1262. }),
  1263. smalltalk.Date);
  1264. smalltalk.addMethod(
  1265. "__lt",
  1266. smalltalk.method({
  1267. selector: "<",
  1268. category: 'comparing',
  1269. fn: function (aDate) {
  1270. var self = this;
  1271. return self < aDate;
  1272. return self;
  1273. },
  1274. args: ["aDate"],
  1275. source: "< aDate\x0a\x09<return self < aDate>",
  1276. messageSends: [],
  1277. referencedClasses: []
  1278. }),
  1279. smalltalk.Date);
  1280. smalltalk.addMethod(
  1281. "__lt_eq",
  1282. smalltalk.method({
  1283. selector: "<=",
  1284. category: 'comparing',
  1285. fn: function (aDate) {
  1286. var self = this;
  1287. return self <= aDate;
  1288. return self;
  1289. },
  1290. args: ["aDate"],
  1291. source: "<= aDate\x0a\x09<return self <= aDate>",
  1292. messageSends: [],
  1293. referencedClasses: []
  1294. }),
  1295. smalltalk.Date);
  1296. smalltalk.addMethod(
  1297. "__gt",
  1298. smalltalk.method({
  1299. selector: ">",
  1300. category: 'comparing',
  1301. fn: function (aDate) {
  1302. var self = this;
  1303. return self > aDate;
  1304. return self;
  1305. },
  1306. args: ["aDate"],
  1307. source: "> aDate\x0a\x09<return self >> aDate>",
  1308. messageSends: [],
  1309. referencedClasses: []
  1310. }),
  1311. smalltalk.Date);
  1312. smalltalk.addMethod(
  1313. "__gt_eq",
  1314. smalltalk.method({
  1315. selector: ">=",
  1316. category: 'comparing',
  1317. fn: function (aDate) {
  1318. var self = this;
  1319. return self >= aDate;
  1320. return self;
  1321. },
  1322. args: ["aDate"],
  1323. source: ">= aDate\x0a\x09<return self >>= aDate>",
  1324. messageSends: [],
  1325. referencedClasses: []
  1326. }),
  1327. smalltalk.Date);
  1328. smalltalk.addMethod(
  1329. "_asDateString",
  1330. smalltalk.method({
  1331. selector: "asDateString",
  1332. category: 'converting',
  1333. fn: function () {
  1334. var self = this;
  1335. return self.toDateString();
  1336. return self;
  1337. },
  1338. args: [],
  1339. source: "asDateString\x0a\x09<return self.toDateString()>",
  1340. messageSends: [],
  1341. referencedClasses: []
  1342. }),
  1343. smalltalk.Date);
  1344. smalltalk.addMethod(
  1345. "_asLocaleString",
  1346. smalltalk.method({
  1347. selector: "asLocaleString",
  1348. category: 'converting',
  1349. fn: function () {
  1350. var self = this;
  1351. return self.toLocaleString();
  1352. return self;
  1353. },
  1354. args: [],
  1355. source: "asLocaleString\x0a\x09<return self.toLocaleString()>",
  1356. messageSends: [],
  1357. referencedClasses: []
  1358. }),
  1359. smalltalk.Date);
  1360. smalltalk.addMethod(
  1361. "_asMilliseconds",
  1362. smalltalk.method({
  1363. selector: "asMilliseconds",
  1364. category: 'converting',
  1365. fn: function () {
  1366. var self = this;
  1367. var $1;
  1368. $1 = smalltalk.send(self, "_time", []);
  1369. return $1;
  1370. },
  1371. args: [],
  1372. source: "asMilliseconds\x0a\x09^self time",
  1373. messageSends: ["time"],
  1374. referencedClasses: []
  1375. }),
  1376. smalltalk.Date);
  1377. smalltalk.addMethod(
  1378. "_asNumber",
  1379. smalltalk.method({
  1380. selector: "asNumber",
  1381. category: 'converting',
  1382. fn: function () {
  1383. var self = this;
  1384. var $1;
  1385. $1 = smalltalk.send(self, "_asMilliseconds", []);
  1386. return $1;
  1387. },
  1388. args: [],
  1389. source: "asNumber\x0a\x09^self asMilliseconds",
  1390. messageSends: ["asMilliseconds"],
  1391. referencedClasses: []
  1392. }),
  1393. smalltalk.Date);
  1394. smalltalk.addMethod(
  1395. "_asString",
  1396. smalltalk.method({
  1397. selector: "asString",
  1398. category: 'converting',
  1399. fn: function () {
  1400. var self = this;
  1401. return self.toString();
  1402. return self;
  1403. },
  1404. args: [],
  1405. source: "asString\x0a\x09<return self.toString()>",
  1406. messageSends: [],
  1407. referencedClasses: []
  1408. }),
  1409. smalltalk.Date);
  1410. smalltalk.addMethod(
  1411. "_asTimeString",
  1412. smalltalk.method({
  1413. selector: "asTimeString",
  1414. category: 'converting',
  1415. fn: function () {
  1416. var self = this;
  1417. return self.toTimeString();
  1418. return self;
  1419. },
  1420. args: [],
  1421. source: "asTimeString\x0a\x09<return self.toTimeString()>",
  1422. messageSends: [],
  1423. referencedClasses: []
  1424. }),
  1425. smalltalk.Date);
  1426. smalltalk.addMethod(
  1427. "_day",
  1428. smalltalk.method({
  1429. selector: "day",
  1430. category: 'accessing',
  1431. fn: function () {
  1432. var self = this;
  1433. var $1;
  1434. $1 = smalltalk.send(self, "_dayOfWeek", []);
  1435. return $1;
  1436. },
  1437. args: [],
  1438. source: "day\x0a\x09^self dayOfWeek",
  1439. messageSends: ["dayOfWeek"],
  1440. referencedClasses: []
  1441. }),
  1442. smalltalk.Date);
  1443. smalltalk.addMethod(
  1444. "_day_",
  1445. smalltalk.method({
  1446. selector: "day:",
  1447. category: 'accessing',
  1448. fn: function (aNumber) {
  1449. var self = this;
  1450. smalltalk.send(self, "_dayOfWeek_", [aNumber]);
  1451. return self;
  1452. },
  1453. args: ["aNumber"],
  1454. source: "day: aNumber\x0a\x09self dayOfWeek: aNumber",
  1455. messageSends: ["dayOfWeek:"],
  1456. referencedClasses: []
  1457. }),
  1458. smalltalk.Date);
  1459. smalltalk.addMethod(
  1460. "_dayOfMonth",
  1461. smalltalk.method({
  1462. selector: "dayOfMonth",
  1463. category: 'accessing',
  1464. fn: function () {
  1465. var self = this;
  1466. return self.getDate();
  1467. return self;
  1468. },
  1469. args: [],
  1470. source: "dayOfMonth\x0a\x09<return self.getDate()>",
  1471. messageSends: [],
  1472. referencedClasses: []
  1473. }),
  1474. smalltalk.Date);
  1475. smalltalk.addMethod(
  1476. "_dayOfMonth_",
  1477. smalltalk.method({
  1478. selector: "dayOfMonth:",
  1479. category: 'accessing',
  1480. fn: function (aNumber) {
  1481. var self = this;
  1482. self.setDate(aNumber);
  1483. return self;
  1484. },
  1485. args: ["aNumber"],
  1486. source: "dayOfMonth: aNumber\x0a\x09<self.setDate(aNumber)>",
  1487. messageSends: [],
  1488. referencedClasses: []
  1489. }),
  1490. smalltalk.Date);
  1491. smalltalk.addMethod(
  1492. "_dayOfWeek",
  1493. smalltalk.method({
  1494. selector: "dayOfWeek",
  1495. category: 'accessing',
  1496. fn: function () {
  1497. var self = this;
  1498. return self.getDay() + 1;
  1499. return self;
  1500. },
  1501. args: [],
  1502. source: "dayOfWeek\x0a\x09<return self.getDay() + 1>",
  1503. messageSends: [],
  1504. referencedClasses: []
  1505. }),
  1506. smalltalk.Date);
  1507. smalltalk.addMethod(
  1508. "_dayOfWeek_",
  1509. smalltalk.method({
  1510. selector: "dayOfWeek:",
  1511. category: 'accessing',
  1512. fn: function (aNumber) {
  1513. var self = this;
  1514. return self.setDay(aNumber - 1);
  1515. return self;
  1516. },
  1517. args: ["aNumber"],
  1518. source: "dayOfWeek: aNumber\x0a\x09<return self.setDay(aNumber - 1)>",
  1519. messageSends: [],
  1520. referencedClasses: []
  1521. }),
  1522. smalltalk.Date);
  1523. smalltalk.addMethod(
  1524. "_hours",
  1525. smalltalk.method({
  1526. selector: "hours",
  1527. category: 'accessing',
  1528. fn: function () {
  1529. var self = this;
  1530. return self.getHours();
  1531. return self;
  1532. },
  1533. args: [],
  1534. source: "hours\x0a\x09<return self.getHours()>",
  1535. messageSends: [],
  1536. referencedClasses: []
  1537. }),
  1538. smalltalk.Date);
  1539. smalltalk.addMethod(
  1540. "_hours_",
  1541. smalltalk.method({
  1542. selector: "hours:",
  1543. category: 'accessing',
  1544. fn: function (aNumber) {
  1545. var self = this;
  1546. self.setHours(aNumber);
  1547. return self;
  1548. },
  1549. args: ["aNumber"],
  1550. source: "hours: aNumber\x0a\x09<self.setHours(aNumber)>",
  1551. messageSends: [],
  1552. referencedClasses: []
  1553. }),
  1554. smalltalk.Date);
  1555. smalltalk.addMethod(
  1556. "_milliseconds",
  1557. smalltalk.method({
  1558. selector: "milliseconds",
  1559. category: 'accessing',
  1560. fn: function () {
  1561. var self = this;
  1562. return self.getMilliseconds();
  1563. return self;
  1564. },
  1565. args: [],
  1566. source: "milliseconds\x0a\x09<return self.getMilliseconds()>",
  1567. messageSends: [],
  1568. referencedClasses: []
  1569. }),
  1570. smalltalk.Date);
  1571. smalltalk.addMethod(
  1572. "_milliseconds_",
  1573. smalltalk.method({
  1574. selector: "milliseconds:",
  1575. category: 'accessing',
  1576. fn: function (aNumber) {
  1577. var self = this;
  1578. self.setMilliseconds(aNumber);
  1579. return self;
  1580. },
  1581. args: ["aNumber"],
  1582. source: "milliseconds: aNumber\x0a\x09<self.setMilliseconds(aNumber)>",
  1583. messageSends: [],
  1584. referencedClasses: []
  1585. }),
  1586. smalltalk.Date);
  1587. smalltalk.addMethod(
  1588. "_minutes",
  1589. smalltalk.method({
  1590. selector: "minutes",
  1591. category: 'accessing',
  1592. fn: function () {
  1593. var self = this;
  1594. return self.getMinutes();
  1595. return self;
  1596. },
  1597. args: [],
  1598. source: "minutes\x0a\x09<return self.getMinutes()>",
  1599. messageSends: [],
  1600. referencedClasses: []
  1601. }),
  1602. smalltalk.Date);
  1603. smalltalk.addMethod(
  1604. "_minutes_",
  1605. smalltalk.method({
  1606. selector: "minutes:",
  1607. category: 'accessing',
  1608. fn: function (aNumber) {
  1609. var self = this;
  1610. self.setMinutes(aNumber);
  1611. return self;
  1612. },
  1613. args: ["aNumber"],
  1614. source: "minutes: aNumber\x0a\x09<self.setMinutes(aNumber)>",
  1615. messageSends: [],
  1616. referencedClasses: []
  1617. }),
  1618. smalltalk.Date);
  1619. smalltalk.addMethod(
  1620. "_month",
  1621. smalltalk.method({
  1622. selector: "month",
  1623. category: 'accessing',
  1624. fn: function () {
  1625. var self = this;
  1626. return self.getMonth() + 1;
  1627. return self;
  1628. },
  1629. args: [],
  1630. source: "month\x0a\x09<return self.getMonth() + 1>",
  1631. messageSends: [],
  1632. referencedClasses: []
  1633. }),
  1634. smalltalk.Date);
  1635. smalltalk.addMethod(
  1636. "_month_",
  1637. smalltalk.method({
  1638. selector: "month:",
  1639. category: 'accessing',
  1640. fn: function (aNumber) {
  1641. var self = this;
  1642. self.setMonth(aNumber - 1);
  1643. return self;
  1644. },
  1645. args: ["aNumber"],
  1646. source: "month: aNumber\x0a\x09<self.setMonth(aNumber - 1)>",
  1647. messageSends: [],
  1648. referencedClasses: []
  1649. }),
  1650. smalltalk.Date);
  1651. smalltalk.addMethod(
  1652. "_printString",
  1653. smalltalk.method({
  1654. selector: "printString",
  1655. category: 'printing',
  1656. fn: function () {
  1657. var self = this;
  1658. var $1;
  1659. $1 = smalltalk.send(self, "_asString", []);
  1660. return $1;
  1661. },
  1662. args: [],
  1663. source: "printString\x0a\x09^self asString",
  1664. messageSends: ["asString"],
  1665. referencedClasses: []
  1666. }),
  1667. smalltalk.Date);
  1668. smalltalk.addMethod(
  1669. "_seconds",
  1670. smalltalk.method({
  1671. selector: "seconds",
  1672. category: 'accessing',
  1673. fn: function () {
  1674. var self = this;
  1675. return self.getSeconds();
  1676. return self;
  1677. },
  1678. args: [],
  1679. source: "seconds\x0a\x09<return self.getSeconds()>",
  1680. messageSends: [],
  1681. referencedClasses: []
  1682. }),
  1683. smalltalk.Date);
  1684. smalltalk.addMethod(
  1685. "_seconds_",
  1686. smalltalk.method({
  1687. selector: "seconds:",
  1688. category: 'accessing',
  1689. fn: function (aNumber) {
  1690. var self = this;
  1691. self.setSeconds(aNumber);
  1692. return self;
  1693. },
  1694. args: ["aNumber"],
  1695. source: "seconds: aNumber\x0a\x09<self.setSeconds(aNumber)>",
  1696. messageSends: [],
  1697. referencedClasses: []
  1698. }),
  1699. smalltalk.Date);
  1700. smalltalk.addMethod(
  1701. "_time",
  1702. smalltalk.method({
  1703. selector: "time",
  1704. category: 'accessing',
  1705. fn: function () {
  1706. var self = this;
  1707. return self.getTime();
  1708. return self;
  1709. },
  1710. args: [],
  1711. source: "time\x0a\x09<return self.getTime()>",
  1712. messageSends: [],
  1713. referencedClasses: []
  1714. }),
  1715. smalltalk.Date);
  1716. smalltalk.addMethod(
  1717. "_time_",
  1718. smalltalk.method({
  1719. selector: "time:",
  1720. category: 'accessing',
  1721. fn: function (aNumber) {
  1722. var self = this;
  1723. self.setTime(aNumber);
  1724. return self;
  1725. },
  1726. args: ["aNumber"],
  1727. source: "time: aNumber\x0a\x09<self.setTime(aNumber)>",
  1728. messageSends: [],
  1729. referencedClasses: []
  1730. }),
  1731. smalltalk.Date);
  1732. smalltalk.addMethod(
  1733. "_year",
  1734. smalltalk.method({
  1735. selector: "year",
  1736. category: 'accessing',
  1737. fn: function () {
  1738. var self = this;
  1739. return self.getFullYear();
  1740. return self;
  1741. },
  1742. args: [],
  1743. source: "year\x0a\x09<return self.getFullYear()>",
  1744. messageSends: [],
  1745. referencedClasses: []
  1746. }),
  1747. smalltalk.Date);
  1748. smalltalk.addMethod(
  1749. "_year_",
  1750. smalltalk.method({
  1751. selector: "year:",
  1752. category: 'accessing',
  1753. fn: function (aNumber) {
  1754. var self = this;
  1755. self.setFullYear(aNumber);
  1756. return self;
  1757. },
  1758. args: ["aNumber"],
  1759. source: "year: aNumber\x0a\x09<self.setFullYear(aNumber)>",
  1760. messageSends: [],
  1761. referencedClasses: []
  1762. }),
  1763. smalltalk.Date);
  1764. smalltalk.addMethod(
  1765. "_fromMilliseconds_",
  1766. smalltalk.method({
  1767. selector: "fromMilliseconds:",
  1768. category: 'instance creation',
  1769. fn: function (aNumber) {
  1770. var self = this;
  1771. var $1;
  1772. $1 = smalltalk.send(self, "_new_", [aNumber]);
  1773. return $1;
  1774. },
  1775. args: ["aNumber"],
  1776. source: "fromMilliseconds: aNumber\x0a\x09^self new: aNumber",
  1777. messageSends: ["new:"],
  1778. referencedClasses: []
  1779. }),
  1780. smalltalk.Date.klass);
  1781. smalltalk.addMethod(
  1782. "_fromSeconds_",
  1783. smalltalk.method({
  1784. selector: "fromSeconds:",
  1785. category: 'instance creation',
  1786. fn: function (aNumber) {
  1787. var self = this;
  1788. var $1;
  1789. $1 = smalltalk.send(self, "_fromMilliseconds_", [smalltalk.send(aNumber, "__star", [1000])]);
  1790. return $1;
  1791. },
  1792. args: ["aNumber"],
  1793. source: "fromSeconds: aNumber\x0a\x09^self fromMilliseconds: aNumber * 1000",
  1794. messageSends: ["fromMilliseconds:", "*"],
  1795. referencedClasses: []
  1796. }),
  1797. smalltalk.Date.klass);
  1798. smalltalk.addMethod(
  1799. "_fromString_",
  1800. smalltalk.method({
  1801. selector: "fromString:",
  1802. category: 'instance creation',
  1803. fn: function (aString) {
  1804. var self = this;
  1805. var $1;
  1806. $1 = smalltalk.send(self, "_new_", [aString]);
  1807. return $1;
  1808. },
  1809. args: ["aString"],
  1810. source: "fromString: aString\x0a\x09\x22Example: Date fromString('2011/04/15 00:00:00')\x22\x0a\x09^self new: aString",
  1811. messageSends: ["new:"],
  1812. referencedClasses: []
  1813. }),
  1814. smalltalk.Date.klass);
  1815. smalltalk.addMethod(
  1816. "_millisecondsToRun_",
  1817. smalltalk.method({
  1818. selector: "millisecondsToRun:",
  1819. category: 'instance creation',
  1820. fn: function (aBlock) {
  1821. var self = this;
  1822. var $1;
  1823. var t;
  1824. t = smalltalk.send(smalltalk.Date || Date, "_now", []);
  1825. smalltalk.send(aBlock, "_value", []);
  1826. $1 = smalltalk.send(smalltalk.send(smalltalk.Date || Date, "_now", []), "__minus", [t]);
  1827. return $1;
  1828. },
  1829. args: ["aBlock"],
  1830. source: "millisecondsToRun: aBlock\x0a\x09| t |\x0a\x09t := Date now.\x0a\x09aBlock value.\x0a\x09^Date now - t",
  1831. messageSends: ["now", "value", "-"],
  1832. referencedClasses: ["Date"]
  1833. }),
  1834. smalltalk.Date.klass);
  1835. smalltalk.addMethod(
  1836. "_new_",
  1837. smalltalk.method({
  1838. selector: "new:",
  1839. category: 'instance creation',
  1840. fn: function (anObject) {
  1841. var self = this;
  1842. return new Date(anObject);
  1843. return self;
  1844. },
  1845. args: ["anObject"],
  1846. source: "new: anObject\x0a\x09<return new Date(anObject)>",
  1847. messageSends: [],
  1848. referencedClasses: []
  1849. }),
  1850. smalltalk.Date.klass);
  1851. smalltalk.addMethod(
  1852. "_now",
  1853. smalltalk.method({
  1854. selector: "now",
  1855. category: 'instance creation',
  1856. fn: function () {
  1857. var self = this;
  1858. var $1;
  1859. $1 = smalltalk.send(self, "_today", []);
  1860. return $1;
  1861. },
  1862. args: [],
  1863. source: "now\x0a\x09^self today",
  1864. messageSends: ["today"],
  1865. referencedClasses: []
  1866. }),
  1867. smalltalk.Date.klass);
  1868. smalltalk.addMethod(
  1869. "_today",
  1870. smalltalk.method({
  1871. selector: "today",
  1872. category: 'instance creation',
  1873. fn: function () {
  1874. var self = this;
  1875. var $1;
  1876. $1 = smalltalk.send(self, "_new", []);
  1877. return $1;
  1878. },
  1879. args: [],
  1880. source: "today\x0a\x09^self new",
  1881. messageSends: ["new"],
  1882. referencedClasses: []
  1883. }),
  1884. smalltalk.Date.klass);
  1885. smalltalk.addClass('JSObjectProxy', smalltalk.Object, ['jsObject'], 'Kernel-Objects');
  1886. smalltalk.JSObjectProxy.comment="JSObjectProxy handles sending messages to JavaScript object, therefore accessing JavaScript objects from Amber is transparent.\x0aJSOjbectProxy makes intensive use of `#doesNotUnderstand:`.\x0a\x0a## Examples\x0a\x0aJSObjectProxy objects are instanciated by Amber when a Smalltalk message is sent to a JavaScript object.\x0a\x0a window alert: 'hello world'.\x0a window inspect.\x0a (window jQuery: 'body') append: 'hello world'\x0a\x0aSmalltalk messages sends are converted to JavaScript function calls or object property access _(in this order)_. If n one of them match, a `MessageNotUnderstood` error will be thrown. \x0a\x0a## Message conversion rules\x0a\x0a- `someUser name` becomes `someUser.name`\x0a- `someUser name: 'John'` becomes `someUser name = \x22John\x22`\x0a- `console log: 'hello world'` becomes `console.log('hello world')`\x0a- `(window jQuery: 'foo') css: 'background' color: 'red'` becomes `window.jQuery('foo').css('background', 'red')`\x0a\x0a__Note:__ For keyword-based messages, only the first keyword is kept: `window foo: 1 bar: 2` is equivalent to `window foo: 1 baz: 2`."
  1887. smalltalk.addMethod(
  1888. "_at_",
  1889. smalltalk.method({
  1890. selector: "at:",
  1891. category: 'accessing',
  1892. fn: function (aSymbol) {
  1893. var self = this;
  1894. var attr;
  1895. attr = smalltalk.send(aSymbol, "_asString", []);
  1896. return self['@jsObject'][attr];
  1897. return self;
  1898. },
  1899. args: ["aSymbol"],
  1900. source: "at: aSymbol\x0a\x09| attr |\x0a\x09attr := aSymbol asString.\x0a\x09<return self['@jsObject'][attr]>",
  1901. messageSends: ["asString"],
  1902. referencedClasses: []
  1903. }),
  1904. smalltalk.JSObjectProxy);
  1905. smalltalk.addMethod(
  1906. "_at_put_",
  1907. smalltalk.method({
  1908. selector: "at:put:",
  1909. category: 'accessing',
  1910. fn: function (aSymbol, anObject) {
  1911. var self = this;
  1912. var attr;
  1913. attr = smalltalk.send(aSymbol, "_asString", []);
  1914. self['@jsObject'][attr] = anObject;
  1915. return self;
  1916. },
  1917. args: ["aSymbol", "anObject"],
  1918. source: "at: aSymbol put: anObject\x0a\x09| attr |\x0a\x09attr := aSymbol asString.\x0a\x09<self['@jsObject'][attr] = anObject>",
  1919. messageSends: ["asString"],
  1920. referencedClasses: []
  1921. }),
  1922. smalltalk.JSObjectProxy);
  1923. smalltalk.addMethod(
  1924. "_doesNotUnderstand_",
  1925. smalltalk.method({
  1926. selector: "doesNotUnderstand:",
  1927. category: 'proxy',
  1928. fn: function (aMessage) {
  1929. var self = this;
  1930. var obj;
  1931. var selector;
  1932. var jsSelector;
  1933. var arguments;
  1934. obj = smalltalk.send(self, "_jsObject", []);
  1935. selector = smalltalk.send(aMessage, "_selector", []);
  1936. jsSelector = smalltalk.send(selector, "_asJavaScriptSelector", []);
  1937. arguments = smalltalk.send(aMessage, "_arguments", []);
  1938. if (obj[jsSelector] != undefined) {
  1939. return smalltalk.send(obj, jsSelector, arguments);
  1940. }
  1941. smalltalk.send(self, "_doesNotUnderstand_", [aMessage], smalltalk.Object);
  1942. return self;
  1943. },
  1944. args: ["aMessage"],
  1945. source: "doesNotUnderstand: aMessage\x0a\x09| obj selector jsSelector arguments |\x0a\x09obj := self jsObject.\x0a\x09selector := aMessage selector.\x0a\x09jsSelector := selector asJavaScriptSelector.\x0a\x09arguments := aMessage arguments.\x0a\x09<if(obj[jsSelector] != undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.\x0a\x09super doesNotUnderstand: aMessage",
  1946. messageSends: ["jsObject", "selector", "asJavaScriptSelector", "arguments", "doesNotUnderstand:"],
  1947. referencedClasses: []
  1948. }),
  1949. smalltalk.JSObjectProxy);
  1950. smalltalk.addMethod(
  1951. "_inspectOn_",
  1952. smalltalk.method({
  1953. selector: "inspectOn:",
  1954. category: 'proxy',
  1955. fn: function (anInspector) {
  1956. var self = this;
  1957. var variables;
  1958. variables = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  1959. smalltalk.send(variables, "_at_put_", ["#self", smalltalk.send(self, "_jsObject", [])]);
  1960. smalltalk.send(anInspector, "_setLabel_", [smalltalk.send(self, "_printString", [])]);
  1961. for (var i in self['@jsObject']) {
  1962. variables._at_put_(i, self['@jsObject'][i]);
  1963. }
  1964. smalltalk.send(anInspector, "_setVariables_", [variables]);
  1965. return self;
  1966. },
  1967. args: ["anInspector"],
  1968. source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self jsObject.\x0a\x09anInspector setLabel: self printString.\x0a\x09<for(var i in self['@jsObject']) {\x0a\x09\x09variables._at_put_(i, self['@jsObject'][i]);\x0a\x09}>.\x0a\x09anInspector setVariables: variables",
  1969. messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "setVariables:"],
  1970. referencedClasses: ["Dictionary"]
  1971. }),
  1972. smalltalk.JSObjectProxy);
  1973. smalltalk.addMethod(
  1974. "_jsObject",
  1975. smalltalk.method({
  1976. selector: "jsObject",
  1977. category: 'accessing',
  1978. fn: function () {
  1979. var self = this;
  1980. return self['@jsObject'];
  1981. },
  1982. args: [],
  1983. source: "jsObject\x0a\x09^jsObject",
  1984. messageSends: [],
  1985. referencedClasses: []
  1986. }),
  1987. smalltalk.JSObjectProxy);
  1988. smalltalk.addMethod(
  1989. "_jsObject_",
  1990. smalltalk.method({
  1991. selector: "jsObject:",
  1992. category: 'accessing',
  1993. fn: function (aJSObject) {
  1994. var self = this;
  1995. self['@jsObject'] = aJSObject;
  1996. return self;
  1997. },
  1998. args: ["aJSObject"],
  1999. source: "jsObject: aJSObject\x0a\x09jsObject := aJSObject",
  2000. messageSends: [],
  2001. referencedClasses: []
  2002. }),
  2003. smalltalk.JSObjectProxy);
  2004. smalltalk.addMethod(
  2005. "_printString",
  2006. smalltalk.method({
  2007. selector: "printString",
  2008. category: 'proxy',
  2009. fn: function () {
  2010. var self = this;
  2011. var $1;
  2012. $1 = smalltalk.send(smalltalk.send(self, "_jsObject", []), "_toString", []);
  2013. return $1;
  2014. },
  2015. args: [],
  2016. source: "printString\x0a\x09^self jsObject toString",
  2017. messageSends: ["toString", "jsObject"],
  2018. referencedClasses: []
  2019. }),
  2020. smalltalk.JSObjectProxy);
  2021. smalltalk.addMethod(
  2022. "_on_",
  2023. smalltalk.method({
  2024. selector: "on:",
  2025. category: 'instance creation',
  2026. fn: function (aJSObject) {
  2027. var self = this;
  2028. var $2, $3, $1;
  2029. $2 = smalltalk.send(self, "_new", []);
  2030. smalltalk.send($2, "_jsObject_", [aJSObject]);
  2031. $3 = smalltalk.send($2, "_yourself", []);
  2032. $1 = $3;
  2033. return $1;
  2034. },
  2035. args: ["aJSObject"],
  2036. source: "on: aJSObject\x0a\x09^self new\x0a\x09\x09jsObject: aJSObject;\x0a\x09\x09yourself",
  2037. messageSends: ["jsObject:", "new", "yourself"],
  2038. referencedClasses: []
  2039. }),
  2040. smalltalk.JSObjectProxy.klass);
  2041. smalltalk.addClass('Number', smalltalk.Object, [], 'Kernel-Objects');
  2042. smalltalk.Number.comment="Number holds the most general methods for dealing with numbers. \x0aNumber is directly mapped to JavaScript Number.\x0a\x0aMost arithmetic methods like `#+` `#/` `#-` `#max:` are directly inlined into javascript. \x0a\x0a##Enumerating\x0aA Number can be used to evaluate a Block a fixed number of times:\x0a\x0a\x095 timesRepeat: [Transcript show: 'This will be printed 5 times'; cr].\x0a\x09\x0a\x091 to: 5 do: [:aNumber| Transcript show: aNumber asString; cr].\x0a\x09\x0a\x091 to: 10 by: 2 do: [:aNumber| Transcript show: aNumber asString; cr]."
  2043. smalltalk.addMethod(
  2044. "_&",
  2045. smalltalk.method({
  2046. selector: "&",
  2047. category: 'converting',
  2048. fn: function (aNumber) {
  2049. var self = this;
  2050. return self & aNumber;
  2051. return self;
  2052. },
  2053. args: ["aNumber"],
  2054. source: "& aNumber\x0a\x09<return self & aNumber>",
  2055. messageSends: [],
  2056. referencedClasses: []
  2057. }),
  2058. smalltalk.Number);
  2059. smalltalk.addMethod(
  2060. "__star",
  2061. smalltalk.method({
  2062. selector: "*",
  2063. category: 'arithmetic',
  2064. fn: function (aNumber) {
  2065. var self = this;
  2066. return self * aNumber;
  2067. return self;
  2068. },
  2069. args: ["aNumber"],
  2070. source: "* aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self * aNumber>",
  2071. messageSends: [],
  2072. referencedClasses: []
  2073. }),
  2074. smalltalk.Number);
  2075. smalltalk.addMethod(
  2076. "__plus",
  2077. smalltalk.method({
  2078. selector: "+",
  2079. category: 'arithmetic',
  2080. fn: function (aNumber) {
  2081. var self = this;
  2082. return self + aNumber;
  2083. return self;
  2084. },
  2085. args: ["aNumber"],
  2086. source: "+ aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self + aNumber>",
  2087. messageSends: [],
  2088. referencedClasses: []
  2089. }),
  2090. smalltalk.Number);
  2091. smalltalk.addMethod(
  2092. "__minus",
  2093. smalltalk.method({
  2094. selector: "-",
  2095. category: 'arithmetic',
  2096. fn: function (aNumber) {
  2097. var self = this;
  2098. return self - aNumber;
  2099. return self;
  2100. },
  2101. args: ["aNumber"],
  2102. source: "- aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self - aNumber>",
  2103. messageSends: [],
  2104. referencedClasses: []
  2105. }),
  2106. smalltalk.Number);
  2107. smalltalk.addMethod(
  2108. "__slash",
  2109. smalltalk.method({
  2110. selector: "/",
  2111. category: 'arithmetic',
  2112. fn: function (aNumber) {
  2113. var self = this;
  2114. return self / aNumber;
  2115. return self;
  2116. },
  2117. args: ["aNumber"],
  2118. source: "/ aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self / aNumber>",
  2119. messageSends: [],
  2120. referencedClasses: []
  2121. }),
  2122. smalltalk.Number);
  2123. smalltalk.addMethod(
  2124. "__lt",
  2125. smalltalk.method({
  2126. selector: "<",
  2127. category: 'comparing',
  2128. fn: function (aNumber) {
  2129. var self = this;
  2130. return self < aNumber;
  2131. return self;
  2132. },
  2133. args: ["aNumber"],
  2134. source: "< aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self < aNumber>",
  2135. messageSends: [],
  2136. referencedClasses: []
  2137. }),
  2138. smalltalk.Number);
  2139. smalltalk.addMethod(
  2140. "__lt_eq",
  2141. smalltalk.method({
  2142. selector: "<=",
  2143. category: 'comparing',
  2144. fn: function (aNumber) {
  2145. var self = this;
  2146. return self <= aNumber;
  2147. return self;
  2148. },
  2149. args: ["aNumber"],
  2150. source: "<= aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self <= aNumber>",
  2151. messageSends: [],
  2152. referencedClasses: []
  2153. }),
  2154. smalltalk.Number);
  2155. smalltalk.addMethod(
  2156. "__eq",
  2157. smalltalk.method({
  2158. selector: "=",
  2159. category: 'comparing',
  2160. fn: function (aNumber) {
  2161. var self = this;
  2162. var $1;
  2163. $1 = smalltalk.send(aNumber, "_isNumber", []);
  2164. if (!smalltalk.assert($1)) {
  2165. return false;
  2166. }
  2167. return Number(self) == aNumber;
  2168. return self;
  2169. },
  2170. args: ["aNumber"],
  2171. source: "= aNumber\x0a\x09aNumber isNumber ifFalse: [^false]. \x0a\x09<return Number(self) == aNumber>",
  2172. messageSends: ["ifFalse:", "isNumber"],
  2173. referencedClasses: []
  2174. }),
  2175. smalltalk.Number);
  2176. smalltalk.addMethod(
  2177. "__gt",
  2178. smalltalk.method({
  2179. selector: ">",
  2180. category: 'comparing',
  2181. fn: function (aNumber) {
  2182. var self = this;
  2183. return self > aNumber;
  2184. return self;
  2185. },
  2186. args: ["aNumber"],
  2187. source: "> aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self >> aNumber>",
  2188. messageSends: [],
  2189. referencedClasses: []
  2190. }),
  2191. smalltalk.Number);
  2192. smalltalk.addMethod(
  2193. "__gt_eq",
  2194. smalltalk.method({
  2195. selector: ">=",
  2196. category: 'comparing',
  2197. fn: function (aNumber) {
  2198. var self = this;
  2199. return self >= aNumber;
  2200. return self;
  2201. },
  2202. args: ["aNumber"],
  2203. source: ">= aNumber\x0a\x09\x22Inlined in the Compiler\x22\x0a\x09<return self >>= aNumber>",
  2204. messageSends: [],
  2205. referencedClasses: []
  2206. }),
  2207. smalltalk.Number);
  2208. smalltalk.addMethod(
  2209. "__at",
  2210. smalltalk.method({
  2211. selector: "@",
  2212. category: 'converting',
  2213. fn: function (aNumber) {
  2214. var self = this;
  2215. var $1;
  2216. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [self, aNumber]);
  2217. return $1;
  2218. },
  2219. args: ["aNumber"],
  2220. source: "@ aNumber\x0a\x09^Point x: self y: aNumber",
  2221. messageSends: ["x:y:"],
  2222. referencedClasses: ["Point"]
  2223. }),
  2224. smalltalk.Number);
  2225. smalltalk.addMethod(
  2226. "_\x5c\x5c",
  2227. smalltalk.method({
  2228. selector: "\x5c\x5c",
  2229. category: 'arithmetic',
  2230. fn: function (aNumber) {
  2231. var self = this;
  2232. return self % aNumber;
  2233. return self;
  2234. },
  2235. args: ["aNumber"],
  2236. source: "\x5c\x5c aNumber\x0a\x09<return self % aNumber>",
  2237. messageSends: [],
  2238. referencedClasses: []
  2239. }),
  2240. smalltalk.Number);
  2241. smalltalk.addMethod(
  2242. "_abs",
  2243. smalltalk.method({
  2244. selector: "abs",
  2245. category: 'arithmetic',
  2246. fn: function () {
  2247. var self = this;
  2248. var $1;
  2249. $1 = Math.abs(self);
  2250. return $1;
  2251. },
  2252. args: [],
  2253. source: "abs\x0a\x09^ <Math.abs(self);>",
  2254. messageSends: [],
  2255. referencedClasses: []
  2256. }),
  2257. smalltalk.Number);
  2258. smalltalk.addMethod(
  2259. "_asJSON",
  2260. smalltalk.method({
  2261. selector: "asJSON",
  2262. category: 'converting',
  2263. fn: function () {
  2264. var self = this;
  2265. return self;
  2266. },
  2267. args: [],
  2268. source: "asJSON\x0a\x09^self",
  2269. messageSends: [],
  2270. referencedClasses: []
  2271. }),
  2272. smalltalk.Number);
  2273. smalltalk.addMethod(
  2274. "_asJavascript",
  2275. smalltalk.method({
  2276. selector: "asJavascript",
  2277. category: 'converting',
  2278. fn: function () {
  2279. var self = this;
  2280. var $1;
  2281. $1 = smalltalk.send(smalltalk.send("(", "__comma", [smalltalk.send(self, "_printString", [])]), "__comma", [")"]);
  2282. return $1;
  2283. },
  2284. args: [],
  2285. source: "asJavascript\x0a\x09^'(', self printString, ')'",
  2286. messageSends: [",", "printString"],
  2287. referencedClasses: []
  2288. }),
  2289. smalltalk.Number);
  2290. smalltalk.addMethod(
  2291. "_asPoint",
  2292. smalltalk.method({
  2293. selector: "asPoint",
  2294. category: 'converting',
  2295. fn: function () {
  2296. var self = this;
  2297. var $1;
  2298. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [self, self]);
  2299. return $1;
  2300. },
  2301. args: [],
  2302. source: "asPoint\x0a\x09^Point x: self y: self",
  2303. messageSends: ["x:y:"],
  2304. referencedClasses: ["Point"]
  2305. }),
  2306. smalltalk.Number);
  2307. smalltalk.addMethod(
  2308. "_asString",
  2309. smalltalk.method({
  2310. selector: "asString",
  2311. category: 'converting',
  2312. fn: function () {
  2313. var self = this;
  2314. var $1;
  2315. $1 = smalltalk.send(self, "_printString", []);
  2316. return $1;
  2317. },
  2318. args: [],
  2319. source: "asString\x0a\x09^self printString",
  2320. messageSends: ["printString"],
  2321. referencedClasses: []
  2322. }),
  2323. smalltalk.Number);
  2324. smalltalk.addMethod(
  2325. "_atRandom",
  2326. smalltalk.method({
  2327. selector: "atRandom",
  2328. category: 'converting',
  2329. fn: function () {
  2330. var self = this;
  2331. var $1;
  2332. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Random || Random, "_new", []), "_next", []), "__star", [self]), "_truncated", []), "__plus", [1]);
  2333. return $1;
  2334. },
  2335. args: [],
  2336. source: "atRandom\x0a ^(Random new next * self) truncated + 1",
  2337. messageSends: ["+", "truncated", "*", "next", "new"],
  2338. referencedClasses: ["Random"]
  2339. }),
  2340. smalltalk.Number);
  2341. smalltalk.addMethod(
  2342. "_clearInterval",
  2343. smalltalk.method({
  2344. selector: "clearInterval",
  2345. category: 'timeouts/intervals',
  2346. fn: function () {
  2347. var self = this;
  2348. clearInterval(Number(self));
  2349. return self;
  2350. },
  2351. args: [],
  2352. source: "clearInterval\x0a\x09<clearInterval(Number(self))>",
  2353. messageSends: [],
  2354. referencedClasses: []
  2355. }),
  2356. smalltalk.Number);
  2357. smalltalk.addMethod(
  2358. "_clearTimeout",
  2359. smalltalk.method({
  2360. selector: "clearTimeout",
  2361. category: 'timeouts/intervals',
  2362. fn: function () {
  2363. var self = this;
  2364. clearTimeout(Number(self));
  2365. return self;
  2366. },
  2367. args: [],
  2368. source: "clearTimeout\x0a\x09<clearTimeout(Number(self))>",
  2369. messageSends: [],
  2370. referencedClasses: []
  2371. }),
  2372. smalltalk.Number);
  2373. smalltalk.addMethod(
  2374. "_copy",
  2375. smalltalk.method({
  2376. selector: "copy",
  2377. category: 'copying',
  2378. fn: function () {
  2379. var self = this;
  2380. return self;
  2381. },
  2382. args: [],
  2383. source: "copy\x0a\x09^self",
  2384. messageSends: [],
  2385. referencedClasses: []
  2386. }),
  2387. smalltalk.Number);
  2388. smalltalk.addMethod(
  2389. "_deepCopy",
  2390. smalltalk.method({
  2391. selector: "deepCopy",
  2392. category: 'copying',
  2393. fn: function () {
  2394. var self = this;
  2395. var $1;
  2396. $1 = smalltalk.send(self, "_copy", []);
  2397. return $1;
  2398. },
  2399. args: [],
  2400. source: "deepCopy\x0a\x09^self copy",
  2401. messageSends: ["copy"],
  2402. referencedClasses: []
  2403. }),
  2404. smalltalk.Number);
  2405. smalltalk.addMethod(
  2406. "_even",
  2407. smalltalk.method({
  2408. selector: "even",
  2409. category: 'testing',
  2410. fn: function () {
  2411. var self = this;
  2412. var $1;
  2413. $1 = smalltalk.send(0, "__eq", [smalltalk.send(self, "_\\\\", [2])]);
  2414. return $1;
  2415. },
  2416. args: [],
  2417. source: "even\x0a\x09^ 0 = (self \x5c\x5c 2)",
  2418. messageSends: ["=", "\x5c\x5c\x5c\x5c"],
  2419. referencedClasses: []
  2420. }),
  2421. smalltalk.Number);
  2422. smalltalk.addMethod(
  2423. "_identityHash",
  2424. smalltalk.method({
  2425. selector: "identityHash",
  2426. category: 'accessing',
  2427. fn: function () {
  2428. var self = this;
  2429. var $1;
  2430. $1 = smalltalk.send(smalltalk.send(self, "_asString", []), "__comma", ["n"]);
  2431. return $1;
  2432. },
  2433. args: [],
  2434. source: "identityHash\x0a\x09^self asString, 'n'",
  2435. messageSends: [",", "asString"],
  2436. referencedClasses: []
  2437. }),
  2438. smalltalk.Number);
  2439. smalltalk.addMethod(
  2440. "_isNumber",
  2441. smalltalk.method({
  2442. selector: "isNumber",
  2443. category: 'testing',
  2444. fn: function () {
  2445. var self = this;
  2446. return true;
  2447. },
  2448. args: [],
  2449. source: "isNumber\x0a\x09^true",
  2450. messageSends: [],
  2451. referencedClasses: []
  2452. }),
  2453. smalltalk.Number);
  2454. smalltalk.addMethod(
  2455. "_isZero",
  2456. smalltalk.method({
  2457. selector: "isZero",
  2458. category: 'testing',
  2459. fn: function () {
  2460. var self = this;
  2461. var $1;
  2462. $1 = smalltalk.send(self, "__eq", [0]);
  2463. return $1;
  2464. },
  2465. args: [],
  2466. source: "isZero\x0a\x09^self = 0",
  2467. messageSends: ["="],
  2468. referencedClasses: []
  2469. }),
  2470. smalltalk.Number);
  2471. smalltalk.addMethod(
  2472. "_max_",
  2473. smalltalk.method({
  2474. selector: "max:",
  2475. category: 'arithmetic',
  2476. fn: function (aNumber) {
  2477. var self = this;
  2478. return Math.max(self, aNumber);
  2479. return self;
  2480. },
  2481. args: ["aNumber"],
  2482. source: "max: aNumber\x0a\x09<return Math.max(self, aNumber);>",
  2483. messageSends: [],
  2484. referencedClasses: []
  2485. }),
  2486. smalltalk.Number);
  2487. smalltalk.addMethod(
  2488. "_min_",
  2489. smalltalk.method({
  2490. selector: "min:",
  2491. category: 'arithmetic',
  2492. fn: function (aNumber) {
  2493. var self = this;
  2494. return Math.min(self, aNumber);
  2495. return self;
  2496. },
  2497. args: ["aNumber"],
  2498. source: "min: aNumber\x0a\x09<return Math.min(self, aNumber);>",
  2499. messageSends: [],
  2500. referencedClasses: []
  2501. }),
  2502. smalltalk.Number);
  2503. smalltalk.addMethod(
  2504. "_negated",
  2505. smalltalk.method({
  2506. selector: "negated",
  2507. category: 'arithmetic',
  2508. fn: function () {
  2509. var self = this;
  2510. var $1;
  2511. $1 = smalltalk.send(0, "__minus", [self]);
  2512. return $1;
  2513. },
  2514. args: [],
  2515. source: "negated\x0a\x09^0 - self",
  2516. messageSends: ["-"],
  2517. referencedClasses: []
  2518. }),
  2519. smalltalk.Number);
  2520. smalltalk.addMethod(
  2521. "_negative",
  2522. smalltalk.method({
  2523. selector: "negative",
  2524. category: 'testing',
  2525. fn: function () {
  2526. var self = this;
  2527. var $1;
  2528. $1 = smalltalk.send(self, "__lt", [0]);
  2529. return $1;
  2530. },
  2531. args: [],
  2532. source: "negative\x0a\x09\x22Answer whether the receiver is mathematically negative.\x22\x0a\x0a\x09^ self < 0",
  2533. messageSends: ["<"],
  2534. referencedClasses: []
  2535. }),
  2536. smalltalk.Number);
  2537. smalltalk.addMethod(
  2538. "_odd",
  2539. smalltalk.method({
  2540. selector: "odd",
  2541. category: 'testing',
  2542. fn: function () {
  2543. var self = this;
  2544. var $1;
  2545. $1 = smalltalk.send(smalltalk.send(self, "_even", []), "_not", []);
  2546. return $1;
  2547. },
  2548. args: [],
  2549. source: "odd\x0a\x09^ self even not",
  2550. messageSends: ["not", "even"],
  2551. referencedClasses: []
  2552. }),
  2553. smalltalk.Number);
  2554. smalltalk.addMethod(
  2555. "_positive",
  2556. smalltalk.method({
  2557. selector: "positive",
  2558. category: 'testing',
  2559. fn: function () {
  2560. var self = this;
  2561. var $1;
  2562. $1 = smalltalk.send(self, "__gt_eq", [0]);
  2563. return $1;
  2564. },
  2565. args: [],
  2566. source: "positive\x0a\x09\x22Answer whether the receiver is positive or equal to 0. (ST-80 protocol).\x22\x0a\x0a\x09^ self >= 0",
  2567. messageSends: [">="],
  2568. referencedClasses: []
  2569. }),
  2570. smalltalk.Number);
  2571. smalltalk.addMethod(
  2572. "_printShowingDecimalPlaces_",
  2573. smalltalk.method({
  2574. selector: "printShowingDecimalPlaces:",
  2575. category: 'printing',
  2576. fn: function (placesDesired) {
  2577. var self = this;
  2578. return self.toFixed(placesDesired);
  2579. return self;
  2580. },
  2581. args: ["placesDesired"],
  2582. source: "printShowingDecimalPlaces: placesDesired\x0a\x09<return self.toFixed(placesDesired)>",
  2583. messageSends: [],
  2584. referencedClasses: []
  2585. }),
  2586. smalltalk.Number);
  2587. smalltalk.addMethod(
  2588. "_printString",
  2589. smalltalk.method({
  2590. selector: "printString",
  2591. category: 'printing',
  2592. fn: function () {
  2593. var self = this;
  2594. return String(self);
  2595. return self;
  2596. },
  2597. args: [],
  2598. source: "printString\x0a\x09<return String(self)>",
  2599. messageSends: [],
  2600. referencedClasses: []
  2601. }),
  2602. smalltalk.Number);
  2603. smalltalk.addMethod(
  2604. "_rounded",
  2605. smalltalk.method({
  2606. selector: "rounded",
  2607. category: 'converting',
  2608. fn: function () {
  2609. var self = this;
  2610. return Math.round(self);
  2611. return self;
  2612. },
  2613. args: [],
  2614. source: "rounded\x0a\x09<return Math.round(self);>",
  2615. messageSends: [],
  2616. referencedClasses: []
  2617. }),
  2618. smalltalk.Number);
  2619. smalltalk.addMethod(
  2620. "_sqrt",
  2621. smalltalk.method({
  2622. selector: "sqrt",
  2623. category: 'arithmetic',
  2624. fn: function () {
  2625. var self = this;
  2626. return Math.sqrt(self);
  2627. return self;
  2628. },
  2629. args: [],
  2630. source: "sqrt\x0a\x09<return Math.sqrt(self)>",
  2631. messageSends: [],
  2632. referencedClasses: []
  2633. }),
  2634. smalltalk.Number);
  2635. smalltalk.addMethod(
  2636. "_squared",
  2637. smalltalk.method({
  2638. selector: "squared",
  2639. category: 'arithmetic',
  2640. fn: function () {
  2641. var self = this;
  2642. var $1;
  2643. $1 = smalltalk.send(self, "__star", [self]);
  2644. return $1;
  2645. },
  2646. args: [],
  2647. source: "squared\x0a\x09^self * self",
  2648. messageSends: ["*"],
  2649. referencedClasses: []
  2650. }),
  2651. smalltalk.Number);
  2652. smalltalk.addMethod(
  2653. "_timesRepeat_",
  2654. smalltalk.method({
  2655. selector: "timesRepeat:",
  2656. category: 'enumerating',
  2657. fn: function (aBlock) {
  2658. var self = this;
  2659. var integer;
  2660. var count;
  2661. integer = smalltalk.send(self, "_truncated", []);
  2662. count = 1;
  2663. smalltalk.send(function () {return smalltalk.send(count, "__gt", [self]);}, "_whileFalse_", [function () {smalltalk.send(aBlock, "_value", []);count = smalltalk.send(count, "__plus", [1]);return count;}]);
  2664. return self;
  2665. },
  2666. args: ["aBlock"],
  2667. source: "timesRepeat: aBlock\x0a\x09| integer count |\x0a\x09integer := self truncated.\x0a\x09count := 1.\x0a\x09[count > self] whileFalse: [\x0a\x09 aBlock value.\x0a\x09 count := count + 1]",
  2668. messageSends: ["truncated", "whileFalse:", "value", "+", ">"],
  2669. referencedClasses: []
  2670. }),
  2671. smalltalk.Number);
  2672. smalltalk.addMethod(
  2673. "_to_",
  2674. smalltalk.method({
  2675. selector: "to:",
  2676. category: 'converting',
  2677. fn: function (aNumber) {
  2678. var self = this;
  2679. var array;
  2680. var first;
  2681. var last;
  2682. var count;
  2683. first = smalltalk.send(self, "_truncated", []);
  2684. last = smalltalk.send(smalltalk.send(aNumber, "_truncated", []), "__plus", [1]);
  2685. count = 1;
  2686. array = smalltalk.send(smalltalk.Array || Array, "_new", []);
  2687. smalltalk.send(smalltalk.send(last, "__minus", [first]), "_timesRepeat_", [function () {smalltalk.send(array, "_at_put_", [count, first]);count = smalltalk.send(count, "__plus", [1]);count;first = smalltalk.send(first, "__plus", [1]);return first;}]);
  2688. return array;
  2689. },
  2690. args: ["aNumber"],
  2691. source: "to: aNumber\x0a\x09| array first last count |\x0a\x09first := self truncated.\x0a\x09last := aNumber truncated + 1.\x0a\x09count := 1.\x0a\x09array := Array new.\x0a\x09(last - first) timesRepeat: [\x0a\x09 array at: count put: first.\x0a\x09 count := count + 1.\x0a\x09 first := first + 1].\x0a\x09^array",
  2692. messageSends: ["truncated", "+", "new", "timesRepeat:", "at:put:", "-"],
  2693. referencedClasses: ["Array"]
  2694. }),
  2695. smalltalk.Number);
  2696. smalltalk.addMethod(
  2697. "_to_by_",
  2698. smalltalk.method({
  2699. selector: "to:by:",
  2700. category: 'converting',
  2701. fn: function (stop, step) {
  2702. var self = this;
  2703. var $1, $2;
  2704. var array;
  2705. var value;
  2706. var pos;
  2707. value = self;
  2708. array = smalltalk.send(smalltalk.Array || Array, "_new", []);
  2709. pos = 1;
  2710. $1 = smalltalk.send(step, "__eq", [0]);
  2711. if (smalltalk.assert($1)) {
  2712. smalltalk.send(self, "_error_", ["step must be non-zero"]);
  2713. }
  2714. $2 = smalltalk.send(step, "__lt", [0]);
  2715. if (smalltalk.assert($2)) {
  2716. smalltalk.send(function () {return smalltalk.send(value, "__gt_eq", [stop]);}, "_whileTrue_", [function () {smalltalk.send(array, "_at_put_", [pos, value]);pos = smalltalk.send(pos, "__plus", [1]);pos;value = smalltalk.send(value, "__plus", [step]);return value;}]);
  2717. } else {
  2718. smalltalk.send(function () {return smalltalk.send(value, "__lt_eq", [stop]);}, "_whileTrue_", [function () {smalltalk.send(array, "_at_put_", [pos, value]);pos = smalltalk.send(pos, "__plus", [1]);pos;value = smalltalk.send(value, "__plus", [step]);return value;}]);
  2719. }
  2720. return array;
  2721. },
  2722. args: ["stop", "step"],
  2723. source: "to: stop by: step\x0a\x09| array value pos |\x0a\x09value := self.\x0a\x09array := Array new.\x0a\x09pos := 1.\x0a\x09step = 0 ifTrue: [self error: 'step must be non-zero'].\x0a\x09step < 0\x0a\x09\x09ifTrue: [[ value >= stop ] whileTrue: [\x0a\x09 \x09\x09\x09array at: pos put: value.\x0a\x09 \x09\x09\x09pos := pos + 1.\x0a\x09 \x09\x09\x09value := value + step]]\x0a\x09\x09ifFalse: [[ value <= stop ] whileTrue: [\x0a\x09 \x09\x09\x09array at: pos put: value.\x0a\x09 \x09\x09\x09pos := pos + 1.\x0a\x09 \x09\x09\x09value := value + step]].\x0a\x09^array",
  2724. messageSends: ["new", "ifTrue:", "error:", "=", "ifTrue:ifFalse:", "whileTrue:", "at:put:", "+", ">=", "<=", "<"],
  2725. referencedClasses: ["Array"]
  2726. }),
  2727. smalltalk.Number);
  2728. smalltalk.addMethod(
  2729. "_to_by_do_",
  2730. smalltalk.method({
  2731. selector: "to:by:do:",
  2732. category: 'enumerating',
  2733. fn: function (stop, step, aBlock) {
  2734. var self = this;
  2735. var $1, $2;
  2736. var value;
  2737. value = self;
  2738. $1 = smalltalk.send(step, "__eq", [0]);
  2739. if (smalltalk.assert($1)) {
  2740. smalltalk.send(self, "_error_", ["step must be non-zero"]);
  2741. }
  2742. $2 = smalltalk.send(step, "__lt", [0]);
  2743. if (smalltalk.assert($2)) {
  2744. smalltalk.send(function () {return smalltalk.send(value, "__gt_eq", [stop]);}, "_whileTrue_", [function () {smalltalk.send(aBlock, "_value_", [value]);value = smalltalk.send(value, "__plus", [step]);return value;}]);
  2745. } else {
  2746. smalltalk.send(function () {return smalltalk.send(value, "__lt_eq", [stop]);}, "_whileTrue_", [function () {smalltalk.send(aBlock, "_value_", [value]);value = smalltalk.send(value, "__plus", [step]);return value;}]);
  2747. }
  2748. return self;
  2749. },
  2750. args: ["stop", "step", "aBlock"],
  2751. source: "to: stop by: step do: aBlock\x0a\x09| value |\x0a\x09value := self.\x0a\x09step = 0 ifTrue: [self error: 'step must be non-zero'].\x0a\x09step < 0\x0a\x09\x09ifTrue: [[ value >= stop ] whileTrue: [\x0a\x09 \x09\x09\x09aBlock value: value.\x0a\x09 \x09\x09\x09value := value + step]]\x0a\x09\x09ifFalse: [[ value <= stop ] whileTrue: [\x0a\x09 \x09\x09\x09aBlock value: value.\x0a\x09 \x09\x09\x09value := value + step]]",
  2752. messageSends: ["ifTrue:", "error:", "=", "ifTrue:ifFalse:", "whileTrue:", "value:", "+", ">=", "<=", "<"],
  2753. referencedClasses: []
  2754. }),
  2755. smalltalk.Number);
  2756. smalltalk.addMethod(
  2757. "_to_do_",
  2758. smalltalk.method({
  2759. selector: "to:do:",
  2760. category: 'enumerating',
  2761. fn: function (stop, aBlock) {
  2762. var self = this;
  2763. var nextValue;
  2764. nextValue = self;
  2765. smalltalk.send(function () {return smalltalk.send(nextValue, "__lt_eq", [stop]);}, "_whileTrue_", [function () {smalltalk.send(aBlock, "_value_", [nextValue]);nextValue = smalltalk.send(nextValue, "__plus", [1]);return nextValue;}]);
  2766. return self;
  2767. },
  2768. args: ["stop", "aBlock"],
  2769. source: "to: stop do: aBlock\x0a\x09\x22Evaluate aBlock for each number from self to aNumber.\x22\x0a\x09| nextValue |\x0a\x09nextValue := self.\x0a\x09[nextValue <= stop]\x0a\x09\x09whileTrue: \x0a\x09\x09\x09[aBlock value: nextValue.\x0a\x09\x09\x09nextValue := nextValue + 1]",
  2770. messageSends: ["whileTrue:", "value:", "+", "<="],
  2771. referencedClasses: []
  2772. }),
  2773. smalltalk.Number);
  2774. smalltalk.addMethod(
  2775. "_truncated",
  2776. smalltalk.method({
  2777. selector: "truncated",
  2778. category: 'converting',
  2779. fn: function () {
  2780. var self = this;
  2781. var $1;
  2782. var result;
  2783. $1 = smalltalk.send(self, "__gt_eq", [0]);
  2784. if (smalltalk.assert($1)) {
  2785. result = Math.floor(self);
  2786. } else {
  2787. result = Math.floor(self * -1) * -1;
  2788. }
  2789. return result;
  2790. },
  2791. args: [],
  2792. source: "truncated\x0a|result|\x0a\x0a self >= 0 \x0a ifTrue: [<result = Math.floor(self);>]\x0a ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].\x0a\x0a ^ result",
  2793. messageSends: ["ifTrue:ifFalse:", ">="],
  2794. referencedClasses: []
  2795. }),
  2796. smalltalk.Number);
  2797. smalltalk.addMethod(
  2798. "_|",
  2799. smalltalk.method({
  2800. selector: "|",
  2801. category: 'converting',
  2802. fn: function (aNumber) {
  2803. var self = this;
  2804. return self | aNumber;
  2805. return self;
  2806. },
  2807. args: ["aNumber"],
  2808. source: "| aNumber\x0a\x09<return self | aNumber>",
  2809. messageSends: [],
  2810. referencedClasses: []
  2811. }),
  2812. smalltalk.Number);
  2813. smalltalk.addMethod(
  2814. "_pi",
  2815. smalltalk.method({
  2816. selector: "pi",
  2817. category: 'instance creation',
  2818. fn: function () {
  2819. var self = this;
  2820. return Math.PI;
  2821. return self;
  2822. },
  2823. args: [],
  2824. source: "pi\x0a\x09<return Math.PI>",
  2825. messageSends: [],
  2826. referencedClasses: []
  2827. }),
  2828. smalltalk.Number.klass);
  2829. smalltalk.addClass('Package', smalltalk.Object, ['commitPathJs', 'commitPathSt'], 'Kernel-Objects');
  2830. smalltalk.Package.comment="A Package is similar to a \x22class category\x22 typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.\x0a\x0aA Package has a name, an Array of \x22requires\x22, a comment and a Dictionary with other optional key value attributes. A Package can also be queried for its classes, but it will then resort to a reverse scan of all classes to find them.\x0aPackages are manipulated through \x22Smalltalk current\x22, like for example finding one based on a name:\x0a\x0a\x09Smalltalk current packageAt: 'Kernel'\x0a\x0a...but you can also use:\x0a\x0a\x09Package named: 'Kernel'\x0a\x0aA Package differs slightly from a Monticello package which can span multiple class categories using a naming convention based on hyphenation. But just as in Monticello a Package supports \x22class extensions\x22 so a Package\x0acan define behaviors in foreign classes using a naming convention for method categories where the category starts with an asterisk and then the name of the owning package follows. This can easily be seen in for example class\x0aString where the method category \x22*IDE\x22 defines #inspectOn: which thus is a method belonging to the IDE package.\x0a\x0aYou can fetch a package from the server:\x0a\x0a\x09Package fetch: 'Additional-Examples'"
  2831. smalltalk.addMethod(
  2832. "_classes",
  2833. smalltalk.method({
  2834. selector: "classes",
  2835. category: 'classes',
  2836. fn: function () {
  2837. var self = this;
  2838. var $1;
  2839. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_classes", []), "_select_", [function (c) {return smalltalk.send(smalltalk.send(c, "_package", []), "__eq_eq", [self]);}]);
  2840. return $1;
  2841. },
  2842. args: [],
  2843. source: "classes\x0a\x09\x22We need to do a reverse scan.\x22\x0a\x09^Smalltalk current classes select: [:c | c package == self]",
  2844. messageSends: ["select:", "==", "package", "classes", "current"],
  2845. referencedClasses: ["Smalltalk"]
  2846. }),
  2847. smalltalk.Package);
  2848. smalltalk.addMethod(
  2849. "_commitPathJs",
  2850. smalltalk.method({
  2851. selector: "commitPathJs",
  2852. category: 'accessing',
  2853. fn: function () {
  2854. var self = this;
  2855. var $1;
  2856. if (($receiver = self['@commitPathJs']) == nil ||
  2857. $receiver == undefined) {
  2858. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathJs", []);
  2859. } else {
  2860. $1 = self['@commitPathJs'];
  2861. }
  2862. return $1;
  2863. },
  2864. args: [],
  2865. source: "commitPathJs\x0a\x09^ commitPathJs ifNil: [self class defaultCommitPathJs]",
  2866. messageSends: ["ifNil:", "defaultCommitPathJs", "class"],
  2867. referencedClasses: []
  2868. }),
  2869. smalltalk.Package);
  2870. smalltalk.addMethod(
  2871. "_commitPathJs_",
  2872. smalltalk.method({
  2873. selector: "commitPathJs:",
  2874. category: 'accessing',
  2875. fn: function (aString) {
  2876. var self = this;
  2877. self['@commitPathJs'] = aString;
  2878. return self;
  2879. },
  2880. args: ["aString"],
  2881. source: "commitPathJs: aString\x0a\x09commitPathJs := aString",
  2882. messageSends: [],
  2883. referencedClasses: []
  2884. }),
  2885. smalltalk.Package);
  2886. smalltalk.addMethod(
  2887. "_commitPathSt",
  2888. smalltalk.method({
  2889. selector: "commitPathSt",
  2890. category: 'accessing',
  2891. fn: function () {
  2892. var self = this;
  2893. var $1;
  2894. if (($receiver = self['@commitPathSt']) == nil ||
  2895. $receiver == undefined) {
  2896. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathSt", []);
  2897. } else {
  2898. $1 = self['@commitPathSt'];
  2899. }
  2900. return $1;
  2901. },
  2902. args: [],
  2903. source: "commitPathSt\x0a\x09^ commitPathSt ifNil: [self class defaultCommitPathSt]",
  2904. messageSends: ["ifNil:", "defaultCommitPathSt", "class"],
  2905. referencedClasses: []
  2906. }),
  2907. smalltalk.Package);
  2908. smalltalk.addMethod(
  2909. "_commitPathSt_",
  2910. smalltalk.method({
  2911. selector: "commitPathSt:",
  2912. category: 'accessing',
  2913. fn: function (aString) {
  2914. var self = this;
  2915. self['@commitPathSt'] = aString;
  2916. return self;
  2917. },
  2918. args: ["aString"],
  2919. source: "commitPathSt: aString\x0a\x09commitPathSt := aString",
  2920. messageSends: [],
  2921. referencedClasses: []
  2922. }),
  2923. smalltalk.Package);
  2924. smalltalk.addMethod(
  2925. "_dependencies",
  2926. smalltalk.method({
  2927. selector: "dependencies",
  2928. category: 'accessing',
  2929. fn: function () {
  2930. var self = this;
  2931. var $1;
  2932. $1 = smalltalk.send(self, "_propertyAt_ifAbsent_", ["dependencies", function () {return [];}]);
  2933. return $1;
  2934. },
  2935. args: [],
  2936. source: "dependencies\x0a\x09^self propertyAt: 'dependencies' ifAbsent: [#()]",
  2937. messageSends: ["propertyAt:ifAbsent:"],
  2938. referencedClasses: []
  2939. }),
  2940. smalltalk.Package);
  2941. smalltalk.addMethod(
  2942. "_dependencies_",
  2943. smalltalk.method({
  2944. selector: "dependencies:",
  2945. category: 'accessing',
  2946. fn: function (anArray) {
  2947. var self = this;
  2948. var $1;
  2949. $1 = smalltalk.send(self, "_propertyAt_put_", ["dependencies", anArray]);
  2950. return $1;
  2951. },
  2952. args: ["anArray"],
  2953. source: "dependencies: anArray\x0a\x09^self propertyAt: 'dependencies' put: anArray",
  2954. messageSends: ["propertyAt:put:"],
  2955. referencedClasses: []
  2956. }),
  2957. smalltalk.Package);
  2958. smalltalk.addMethod(
  2959. "_jsProperties",
  2960. smalltalk.method({
  2961. selector: "jsProperties",
  2962. category: 'private',
  2963. fn: function () {
  2964. var self = this;
  2965. return self.properties;
  2966. return self;
  2967. },
  2968. args: [],
  2969. source: "jsProperties\x0a\x09<return self.properties>",
  2970. messageSends: [],
  2971. referencedClasses: []
  2972. }),
  2973. smalltalk.Package);
  2974. smalltalk.addMethod(
  2975. "_jsProperties_",
  2976. smalltalk.method({
  2977. selector: "jsProperties:",
  2978. category: 'private',
  2979. fn: function (aJSObject) {
  2980. var self = this;
  2981. return self.properties = aJSObject;
  2982. return self;
  2983. },
  2984. args: ["aJSObject"],
  2985. source: "jsProperties: aJSObject\x0a\x09<return self.properties = aJSObject>",
  2986. messageSends: [],
  2987. referencedClasses: []
  2988. }),
  2989. smalltalk.Package);
  2990. smalltalk.addMethod(
  2991. "_name",
  2992. smalltalk.method({
  2993. selector: "name",
  2994. category: 'accessing',
  2995. fn: function () {
  2996. var self = this;
  2997. return self.pkgName;
  2998. return self;
  2999. },
  3000. args: [],
  3001. source: "name\x0a\x09<return self.pkgName>",
  3002. messageSends: [],
  3003. referencedClasses: []
  3004. }),
  3005. smalltalk.Package);
  3006. smalltalk.addMethod(
  3007. "_name_",
  3008. smalltalk.method({
  3009. selector: "name:",
  3010. category: 'accessing',
  3011. fn: function (aString) {
  3012. var self = this;
  3013. self.pkgName = aString;
  3014. return self;
  3015. },
  3016. args: ["aString"],
  3017. source: "name: aString\x0a\x09<self.pkgName = aString>",
  3018. messageSends: [],
  3019. referencedClasses: []
  3020. }),
  3021. smalltalk.Package);
  3022. smalltalk.addMethod(
  3023. "_printString",
  3024. smalltalk.method({
  3025. selector: "printString",
  3026. category: 'printing',
  3027. fn: function () {
  3028. var self = this;
  3029. var $1;
  3030. $1 = smalltalk.send(self, "_name", []);
  3031. return $1;
  3032. },
  3033. args: [],
  3034. source: "printString\x0a\x09^self name",
  3035. messageSends: ["name"],
  3036. referencedClasses: []
  3037. }),
  3038. smalltalk.Package);
  3039. smalltalk.addMethod(
  3040. "_properties",
  3041. smalltalk.method({
  3042. selector: "properties",
  3043. category: 'accessing',
  3044. fn: function () {
  3045. var self = this;
  3046. var $1;
  3047. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_readJSObject_", [smalltalk.send(self, "_basicAt_", ["properties"])]);
  3048. return $1;
  3049. },
  3050. args: [],
  3051. source: "properties\x0a\x09^Smalltalk current readJSObject: (self basicAt: 'properties')",
  3052. messageSends: ["readJSObject:", "basicAt:", "current"],
  3053. referencedClasses: ["Smalltalk"]
  3054. }),
  3055. smalltalk.Package);
  3056. smalltalk.addMethod(
  3057. "_properties_",
  3058. smalltalk.method({
  3059. selector: "properties:",
  3060. category: 'accessing',
  3061. fn: function (aDict) {
  3062. var self = this;
  3063. var object;
  3064. object = {};
  3065. smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
  3066. return self.properties = object;
  3067. return self;
  3068. },
  3069. args: ["aDict"],
  3070. source: "properties: aDict\x0a\x09\x22We store it as a javascript object.\x22\x0a\x09\x0a\x09| object |\x0a\x09<object = {};>.\x0a\x09aDict keysAndValuesDo: [:key :value |\x0a\x09\x09<object[key] = value>.\x0a\x09].\x0a\x09<return self.properties = object>",
  3071. messageSends: ["keysAndValuesDo:"],
  3072. referencedClasses: []
  3073. }),
  3074. smalltalk.Package);
  3075. smalltalk.addMethod(
  3076. "_propertiesAsJSON",
  3077. smalltalk.method({
  3078. selector: "propertiesAsJSON",
  3079. category: 'private',
  3080. fn: function () {
  3081. var self = this;
  3082. return JSON.stringify(self.properties);
  3083. return self;
  3084. },
  3085. args: [],
  3086. source: "propertiesAsJSON\x0a\x09<return JSON.stringify(self.properties)>",
  3087. messageSends: [],
  3088. referencedClasses: []
  3089. }),
  3090. smalltalk.Package);
  3091. smalltalk.addMethod(
  3092. "_propertyAt_",
  3093. smalltalk.method({
  3094. selector: "propertyAt:",
  3095. category: 'properties',
  3096. fn: function (key) {
  3097. var self = this;
  3098. return self.properties[key];
  3099. return self;
  3100. },
  3101. args: ["key"],
  3102. source: "propertyAt: key\x0a\x0a\x09<return self.properties[key]>",
  3103. messageSends: [],
  3104. referencedClasses: []
  3105. }),
  3106. smalltalk.Package);
  3107. smalltalk.addMethod(
  3108. "_propertyAt_ifAbsent_",
  3109. smalltalk.method({
  3110. selector: "propertyAt:ifAbsent:",
  3111. category: 'properties',
  3112. fn: function (key, block) {
  3113. var self = this;
  3114. var $2, $1;
  3115. $2 = smalltalk.send(self, "_propertyAt_", [key]);
  3116. if (($receiver = $2) == nil || $receiver == undefined) {
  3117. $1 = smalltalk.send(block, "_value", []);
  3118. } else {
  3119. $1 = $2;
  3120. }
  3121. return $1;
  3122. },
  3123. args: ["key", "block"],
  3124. source: "propertyAt: key ifAbsent: block\x0a\x0a\x09^(self propertyAt: key) ifNil: [block value]",
  3125. messageSends: ["ifNil:", "value", "propertyAt:"],
  3126. referencedClasses: []
  3127. }),
  3128. smalltalk.Package);
  3129. smalltalk.addMethod(
  3130. "_propertyAt_put_",
  3131. smalltalk.method({
  3132. selector: "propertyAt:put:",
  3133. category: 'properties',
  3134. fn: function (key, value) {
  3135. var self = this;
  3136. return self.properties[key] = value;
  3137. return self;
  3138. },
  3139. args: ["key", "value"],
  3140. source: "propertyAt: key put: value\x0a\x0a\x09<return self.properties[key] = value>",
  3141. messageSends: [],
  3142. referencedClasses: []
  3143. }),
  3144. smalltalk.Package);
  3145. smalltalk.addMethod(
  3146. "_sortedClasses",
  3147. smalltalk.method({
  3148. selector: "sortedClasses",
  3149. category: 'classes',
  3150. fn: function () {
  3151. var self = this;
  3152. var $1;
  3153. $1 = smalltalk.send(smalltalk.send(self, "_class", []), "_sortedClasses_", [smalltalk.send(self, "_classes", [])]);
  3154. return $1;
  3155. },
  3156. args: [],
  3157. source: "sortedClasses\x0a\x09\x22Answer all classes in the receiver, sorted by superclass/subclasses and by class name for common subclasses (Issue #143).\x22\x0a\x0a\x09^self class sortedClasses: self classes",
  3158. messageSends: ["sortedClasses:", "classes", "class"],
  3159. referencedClasses: []
  3160. }),
  3161. smalltalk.Package);
  3162. smalltalk.Package.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
  3163. smalltalk.addMethod(
  3164. "_commitToLocalStorage_",
  3165. smalltalk.method({
  3166. selector: "commitToLocalStorage:",
  3167. category: 'loading-storing',
  3168. fn: function (aPackageName) {
  3169. var self = this;
  3170. var key;
  3171. var sourceCode;
  3172. key = smalltalk.send("smalltalk.packages.", "__comma", [aPackageName]);
  3173. sourceCode = smalltalk.send(smalltalk.send(smalltalk.Exporter || Exporter, "_new", []), "_exportPackage_", [aPackageName]);
  3174. localStorage[key] = escape(sourceCode);
  3175. return self;
  3176. },
  3177. args: ["aPackageName"],
  3178. source: "commitToLocalStorage: aPackageName\x0a\x09| key sourceCode |\x0a\x09key := 'smalltalk.packages.' , aPackageName.\x0a\x09sourceCode := Exporter new exportPackage: aPackageName.\x0a\x09<localStorage[key] = escape(sourceCode)>",
  3179. messageSends: [",", "exportPackage:", "new"],
  3180. referencedClasses: ["Exporter"]
  3181. }),
  3182. smalltalk.Package.klass);
  3183. smalltalk.addMethod(
  3184. "_defaultCommitPathJs",
  3185. smalltalk.method({
  3186. selector: "defaultCommitPathJs",
  3187. category: 'commit paths',
  3188. fn: function () {
  3189. var self = this;
  3190. var $1;
  3191. if (($receiver = self['@defaultCommitPathJs']) == nil ||
  3192. $receiver == undefined) {
  3193. self['@defaultCommitPathJs'] = "js";
  3194. $1 = self['@defaultCommitPathJs'];
  3195. } else {
  3196. $1 = self['@defaultCommitPathJs'];
  3197. }
  3198. return $1;
  3199. },
  3200. args: [],
  3201. source: "defaultCommitPathJs\x0a\x09^ defaultCommitPathJs ifNil: [ defaultCommitPathJs := 'js']",
  3202. messageSends: ["ifNil:"],
  3203. referencedClasses: []
  3204. }),
  3205. smalltalk.Package.klass);
  3206. smalltalk.addMethod(
  3207. "_defaultCommitPathJs_",
  3208. smalltalk.method({
  3209. selector: "defaultCommitPathJs:",
  3210. category: 'commit paths',
  3211. fn: function (aString) {
  3212. var self = this;
  3213. self['@defaultCommitPathJs'] = aString;
  3214. return self;
  3215. },
  3216. args: ["aString"],
  3217. source: "defaultCommitPathJs: aString\x0a\x09defaultCommitPathJs := aString",
  3218. messageSends: [],
  3219. referencedClasses: []
  3220. }),
  3221. smalltalk.Package.klass);
  3222. smalltalk.addMethod(
  3223. "_defaultCommitPathSt",
  3224. smalltalk.method({
  3225. selector: "defaultCommitPathSt",
  3226. category: 'commit paths',
  3227. fn: function () {
  3228. var self = this;
  3229. var $1;
  3230. if (($receiver = self['@defaultCommitPathSt']) == nil ||
  3231. $receiver == undefined) {
  3232. self['@defaultCommitPathSt'] = "st";
  3233. $1 = self['@defaultCommitPathSt'];
  3234. } else {
  3235. $1 = self['@defaultCommitPathSt'];
  3236. }
  3237. return $1;
  3238. },
  3239. args: [],
  3240. source: "defaultCommitPathSt\x0a\x09^ defaultCommitPathSt ifNil: [ defaultCommitPathSt := 'st']",
  3241. messageSends: ["ifNil:"],
  3242. referencedClasses: []
  3243. }),
  3244. smalltalk.Package.klass);
  3245. smalltalk.addMethod(
  3246. "_defaultCommitPathSt_",
  3247. smalltalk.method({
  3248. selector: "defaultCommitPathSt:",
  3249. category: 'commit paths',
  3250. fn: function (aString) {
  3251. var self = this;
  3252. self['@defaultCommitPathSt'] = aString;
  3253. return self;
  3254. },
  3255. args: ["aString"],
  3256. source: "defaultCommitPathSt: aString\x0a\x09defaultCommitPathSt := aString",
  3257. messageSends: [],
  3258. referencedClasses: []
  3259. }),
  3260. smalltalk.Package.klass);
  3261. smalltalk.addMethod(
  3262. "_fetch_",
  3263. smalltalk.method({
  3264. selector: "fetch:",
  3265. category: 'loading-storing',
  3266. fn: function (aPackageName) {
  3267. var self = this;
  3268. smalltalk.send(self, "_fetch_prefix_", [aPackageName, smalltalk.send(smalltalk.send(self, "_defaultCommitPathJs", []), "__comma", ["/"])]);
  3269. return self;
  3270. },
  3271. args: ["aPackageName"],
  3272. source: "fetch: aPackageName\x0a\x09self fetch: aPackageName prefix: self defaultCommitPathJs, '/'",
  3273. messageSends: ["fetch:prefix:", ",", "defaultCommitPathJs"],
  3274. referencedClasses: []
  3275. }),
  3276. smalltalk.Package.klass);
  3277. smalltalk.addMethod(
  3278. "_fetch_prefix_",
  3279. smalltalk.method({
  3280. selector: "fetch:prefix:",
  3281. category: 'loading-storing',
  3282. fn: function (aPackageName, aPrefix) {
  3283. var self = this;
  3284. smalltalk.send(jQuery, "_getScript_onSuccess_", [smalltalk.send(smalltalk.send(aPrefix, "__comma", [aPackageName]), "__comma", [".js"]), function () {return smalltalk.send(smalltalk.Package || Package, "_init_", [aPackageName]);}]);
  3285. return self;
  3286. },
  3287. args: ["aPackageName", "aPrefix"],
  3288. source: "fetch: aPackageName prefix: aPrefix\x0a\x09jQuery getScript: (aPrefix , aPackageName , '.js') onSuccess: [ Package init: aPackageName ]",
  3289. messageSends: ["getScript:onSuccess:", ",", "init:"],
  3290. referencedClasses: ["Package"]
  3291. }),
  3292. smalltalk.Package.klass);
  3293. smalltalk.addMethod(
  3294. "_init_",
  3295. smalltalk.method({
  3296. selector: "init:",
  3297. category: 'loading-storing',
  3298. fn: function (aPackageName) {
  3299. var self = this;
  3300. var $1, $2;
  3301. $1 = smalltalk.send(smalltalk.send(smalltalk, "_classes", []), "_select_", [function (each) {return each.pkg.pkgName == aPackageName;}]);
  3302. smalltalk.send($1, "_do_", [function (each) {return smalltalk.init(each);}]);
  3303. $2 = smalltalk.send($1, "_do_", [function (each) {return smalltalk.send(each, "_initialize", []);}]);
  3304. return self;
  3305. },
  3306. args: ["aPackageName"],
  3307. source: "init: aPackageName\x0a\x09(smalltalk classes select: [ :each | <each.pkg.pkgName == aPackageName> ])\x0a\x09\x09do: [ :each | <smalltalk.init(each)> ];\x0a\x09\x09do: [ :each | each initialize ]",
  3308. messageSends: ["do:", "select:", "classes", "initialize"],
  3309. referencedClasses: []
  3310. }),
  3311. smalltalk.Package.klass);
  3312. smalltalk.addMethod(
  3313. "_named_",
  3314. smalltalk.method({
  3315. selector: "named:",
  3316. category: 'not yet classified',
  3317. fn: function (aPackageName) {
  3318. var self = this;
  3319. var $1;
  3320. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_packageAt_", [aPackageName]);
  3321. return $1;
  3322. },
  3323. args: ["aPackageName"],
  3324. source: "named: aPackageName\x0a\x0a\x09^Smalltalk current packageAt: aPackageName",
  3325. messageSends: ["packageAt:", "current"],
  3326. referencedClasses: ["Smalltalk"]
  3327. }),
  3328. smalltalk.Package.klass);
  3329. smalltalk.addMethod(
  3330. "_named_ifAbsent_",
  3331. smalltalk.method({
  3332. selector: "named:ifAbsent:",
  3333. category: 'not yet classified',
  3334. fn: function (aPackageName, aBlock) {
  3335. var self = this;
  3336. var $1;
  3337. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_packageAt_ifAbsent_", [aPackageName, aBlock]);
  3338. return $1;
  3339. },
  3340. args: ["aPackageName", "aBlock"],
  3341. source: "named: aPackageName ifAbsent: aBlock\x0a\x0a\x09^Smalltalk current packageAt: aPackageName ifAbsent: aBlock",
  3342. messageSends: ["packageAt:ifAbsent:", "current"],
  3343. referencedClasses: ["Smalltalk"]
  3344. }),
  3345. smalltalk.Package.klass);
  3346. smalltalk.addMethod(
  3347. "_resetCommitPaths",
  3348. smalltalk.method({
  3349. selector: "resetCommitPaths",
  3350. category: 'commit paths',
  3351. fn: function () {
  3352. var self = this;
  3353. self['@defaultCommitPathJs'] = nil;
  3354. self['@defaultCommitPathSt'] = nil;
  3355. return self;
  3356. },
  3357. args: [],
  3358. source: "resetCommitPaths\x0a defaultCommitPathJs := nil.\x0a defaultCommitPathSt := nil.",
  3359. messageSends: [],
  3360. referencedClasses: []
  3361. }),
  3362. smalltalk.Package.klass);
  3363. smalltalk.addMethod(
  3364. "_sortedClasses_",
  3365. smalltalk.method({
  3366. selector: "sortedClasses:",
  3367. category: 'sorting',
  3368. fn: function (classes) {
  3369. var self = this;
  3370. var $1;
  3371. var children;
  3372. var others;
  3373. var nodes;
  3374. var expandedClasses;
  3375. children = [];
  3376. others = [];
  3377. smalltalk.send(classes, "_do_", [function (each) {$1 = smalltalk.send(classes, "_includes_", [smalltalk.send(each, "_superclass", [])]);if (smalltalk.assert($1)) {return smalltalk.send(others, "_add_", [each]);} else {return smalltalk.send(children, "_add_", [each]);}}]);
  3378. nodes = smalltalk.send(children, "_collect_", [function (each) {return smalltalk.send(smalltalk.ClassSorterNode || ClassSorterNode, "_on_classes_level_", [each, others, 0]);}]);
  3379. nodes = smalltalk.send(nodes, "_sorted_", [function (a, b) {return smalltalk.send(smalltalk.send(smalltalk.send(a, "_theClass", []), "_name", []), "__lt_eq", [smalltalk.send(smalltalk.send(b, "_theClass", []), "_name", [])]);}]);
  3380. expandedClasses = smalltalk.send(smalltalk.Array || Array, "_new", []);
  3381. smalltalk.send(nodes, "_do_", [function (aNode) {return smalltalk.send(aNode, "_traverseClassesWith_", [expandedClasses]);}]);
  3382. return expandedClasses;
  3383. },
  3384. args: ["classes"],
  3385. source: "sortedClasses: classes\x0a\x09\x22Answer classes, sorted by superclass/subclasses and by class name for common subclasses (Issue #143)\x22\x0a\x0a\x09| children others nodes expandedClasses |\x0a\x09children := #().\x0a\x09others := #().\x0a\x09classes do: [:each |\x0a\x09\x09(classes includes: each superclass)\x0a\x09\x09\x09ifFalse: [children add: each]\x0a\x09\x09\x09ifTrue: [others add: each]].\x0a\x09nodes := children collect: [:each |\x0a\x09\x09ClassSorterNode on: each classes: others level: 0].\x0a\x09nodes := nodes sorted: [:a :b | a theClass name <= b theClass name ].\x0a\x09expandedClasses := Array new.\x0a\x09nodes do: [:aNode |\x0a\x09\x09aNode traverseClassesWith: expandedClasses].\x0a\x09^expandedClasses",
  3386. messageSends: ["do:", "ifFalse:ifTrue:", "add:", "includes:", "superclass", "collect:", "on:classes:level:", "sorted:", "<=", "name", "theClass", "new", "traverseClassesWith:"],
  3387. referencedClasses: ["ClassSorterNode", "Array"]
  3388. }),
  3389. smalltalk.Package.klass);
  3390. smalltalk.addClass('Point', smalltalk.Object, ['x', 'y'], 'Kernel-Objects');
  3391. smalltalk.Point.comment="A `Point` represents an x-y pair of numbers usually designating a geometric coordinate.\x0aPoints are traditionally created using the binary `#@` message to a number:\x0a\x0a\x09100@120\x0a\x0aPoints can then be arithmetically manipulated:\x0a\x0a\x09100@100 + (10@10)\x0a\x0a...or for example:\x0a\x0a\x09(100@100) * 2\x0a\x0a**NOTE:** Creating a Point with a negative y-value will need a space after `@` in order to avoid a parsing error:\x0a\x0a\x09100@ -100 \x22but 100@-100 would not parse\x22\x0a\x0aAmber does not have much behavior in this class out-of-the-box."
  3392. smalltalk.addMethod(
  3393. "__star",
  3394. smalltalk.method({
  3395. selector: "*",
  3396. category: 'arithmetic',
  3397. fn: function (aPoint) {
  3398. var self = this;
  3399. var $1;
  3400. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [smalltalk.send(smalltalk.send(self, "_x", []), "__star", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_x", [])]), smalltalk.send(smalltalk.send(self, "_y", []), "__star", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_y", [])])]);
  3401. return $1;
  3402. },
  3403. args: ["aPoint"],
  3404. source: "* aPoint\x0a\x09^Point x: self x * aPoint asPoint x y: self y * aPoint asPoint y",
  3405. messageSends: ["x:y:", "*", "x", "asPoint", "y"],
  3406. referencedClasses: ["Point"]
  3407. }),
  3408. smalltalk.Point);
  3409. smalltalk.addMethod(
  3410. "__plus",
  3411. smalltalk.method({
  3412. selector: "+",
  3413. category: 'arithmetic',
  3414. fn: function (aPoint) {
  3415. var self = this;
  3416. var $1;
  3417. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [smalltalk.send(smalltalk.send(self, "_x", []), "__plus", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_x", [])]), smalltalk.send(smalltalk.send(self, "_y", []), "__plus", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_y", [])])]);
  3418. return $1;
  3419. },
  3420. args: ["aPoint"],
  3421. source: "+ aPoint\x0a\x09^Point x: self x + aPoint asPoint x y: self y + aPoint asPoint y",
  3422. messageSends: ["x:y:", "+", "x", "asPoint", "y"],
  3423. referencedClasses: ["Point"]
  3424. }),
  3425. smalltalk.Point);
  3426. smalltalk.addMethod(
  3427. "__minus",
  3428. smalltalk.method({
  3429. selector: "-",
  3430. category: 'arithmetic',
  3431. fn: function (aPoint) {
  3432. var self = this;
  3433. var $1;
  3434. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [smalltalk.send(smalltalk.send(self, "_x", []), "__minus", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_x", [])]), smalltalk.send(smalltalk.send(self, "_y", []), "__minus", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_y", [])])]);
  3435. return $1;
  3436. },
  3437. args: ["aPoint"],
  3438. source: "- aPoint\x0a\x09^Point x: self x - aPoint asPoint x y: self y - aPoint asPoint y",
  3439. messageSends: ["x:y:", "-", "x", "asPoint", "y"],
  3440. referencedClasses: ["Point"]
  3441. }),
  3442. smalltalk.Point);
  3443. smalltalk.addMethod(
  3444. "__slash",
  3445. smalltalk.method({
  3446. selector: "/",
  3447. category: 'arithmetic',
  3448. fn: function (aPoint) {
  3449. var self = this;
  3450. var $1;
  3451. $1 = smalltalk.send(smalltalk.Point || Point, "_x_y_", [smalltalk.send(smalltalk.send(self, "_x", []), "__slash", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_x", [])]), smalltalk.send(smalltalk.send(self, "_y", []), "__slash", [smalltalk.send(smalltalk.send(aPoint, "_asPoint", []), "_y", [])])]);
  3452. return $1;
  3453. },
  3454. args: ["aPoint"],
  3455. source: "/ aPoint\x0a\x09^Point x: self x / aPoint asPoint x y: self y / aPoint asPoint y",
  3456. messageSends: ["x:y:", "/", "x", "asPoint", "y"],
  3457. referencedClasses: ["Point"]
  3458. }),
  3459. smalltalk.Point);
  3460. smalltalk.addMethod(
  3461. "__eq",
  3462. smalltalk.method({
  3463. selector: "=",
  3464. category: 'arithmetic',
  3465. fn: function (aPoint) {
  3466. var self = this;
  3467. var $1;
  3468. $1 = smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_class", []), "__eq", [smalltalk.send(self, "_class", [])]), "_and_", [function () {return smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_x", []), "__eq", [smalltalk.send(self, "_x", [])]), "_&", [smalltalk.send(smalltalk.send(aPoint, "_y", []), "__eq", [smalltalk.send(self, "_y", [])])]);}]);
  3469. return $1;
  3470. },
  3471. args: ["aPoint"],
  3472. source: "= aPoint\x0a\x09^aPoint class = self class and: [\x0a\x09\x09(aPoint x = self x) & (aPoint y = self y)]",
  3473. messageSends: ["and:", "&", "=", "y", "x", "class"],
  3474. referencedClasses: []
  3475. }),
  3476. smalltalk.Point);
  3477. smalltalk.addMethod(
  3478. "_asPoint",
  3479. smalltalk.method({
  3480. selector: "asPoint",
  3481. category: 'converting',
  3482. fn: function () {
  3483. var self = this;
  3484. return self;
  3485. },
  3486. args: [],
  3487. source: "asPoint\x0a\x09^self",
  3488. messageSends: [],
  3489. referencedClasses: []
  3490. }),
  3491. smalltalk.Point);
  3492. smalltalk.addMethod(
  3493. "_printString",
  3494. smalltalk.method({
  3495. selector: "printString",
  3496. category: 'printing',
  3497. fn: function () {
  3498. var self = this;
  3499. var $2, $1;
  3500. $1 = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (stream) {smalltalk.send(stream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self['@x'], "_printString", []), "__comma", ["@"])]);$2 = smalltalk.send(smalltalk.send(self['@y'], "_notNil", []), "_and_", [function () {return smalltalk.send(self['@y'], "_negative", []);}]);if (smalltalk.assert($2)) {smalltalk.send(stream, "_space", []);}return smalltalk.send(stream, "_nextPutAll_", [smalltalk.send(self['@y'], "_printString", [])]);}]);
  3501. return $1;
  3502. },
  3503. args: [],
  3504. source: "printString\x0a\x09\x22Print receiver in classic x@y notation.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09stream nextPutAll: x printString, '@'.\x0a\x09\x09(y notNil and: [y negative])\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x22Avoid ambiguous @- construct\x22\x0a\x09\x09\x09\x09stream space].\x0a\x09\x09stream nextPutAll: y printString]",
  3505. messageSends: ["streamContents:", "nextPutAll:", ",", "printString", "ifTrue:", "space", "and:", "negative", "notNil"],
  3506. referencedClasses: ["String"]
  3507. }),
  3508. smalltalk.Point);
  3509. smalltalk.addMethod(
  3510. "_translateBy_",
  3511. smalltalk.method({
  3512. selector: "translateBy:",
  3513. category: 'transforming',
  3514. fn: function (delta) {
  3515. var self = this;
  3516. var $1;
  3517. $1 = smalltalk.send(smalltalk.send(smalltalk.send(delta, "_x", []), "__plus", [self['@x']]), "__at", [smalltalk.send(smalltalk.send(delta, "_y", []), "__plus", [self['@y']])]);
  3518. return $1;
  3519. },
  3520. args: ["delta"],
  3521. source: "translateBy: delta \x0a\x09\x22Answer a Point translated by delta (an instance of Point).\x22\x0a\x09^(delta x + x) @ (delta y + y)",
  3522. messageSends: ["@", "+", "y", "x"],
  3523. referencedClasses: []
  3524. }),
  3525. smalltalk.Point);
  3526. smalltalk.addMethod(
  3527. "_x",
  3528. smalltalk.method({
  3529. selector: "x",
  3530. category: 'accessing',
  3531. fn: function () {
  3532. var self = this;
  3533. return self['@x'];
  3534. },
  3535. args: [],
  3536. source: "x\x0a\x09^x",
  3537. messageSends: [],
  3538. referencedClasses: []
  3539. }),
  3540. smalltalk.Point);
  3541. smalltalk.addMethod(
  3542. "_x_",
  3543. smalltalk.method({
  3544. selector: "x:",
  3545. category: 'accessing',
  3546. fn: function (aNumber) {
  3547. var self = this;
  3548. self['@x'] = aNumber;
  3549. return self;
  3550. },
  3551. args: ["aNumber"],
  3552. source: "x: aNumber\x0a\x09x := aNumber",
  3553. messageSends: [],
  3554. referencedClasses: []
  3555. }),
  3556. smalltalk.Point);
  3557. smalltalk.addMethod(
  3558. "_y",
  3559. smalltalk.method({
  3560. selector: "y",
  3561. category: 'accessing',
  3562. fn: function () {
  3563. var self = this;
  3564. return self['@y'];
  3565. },
  3566. args: [],
  3567. source: "y\x0a\x09^y",
  3568. messageSends: [],
  3569. referencedClasses: []
  3570. }),
  3571. smalltalk.Point);
  3572. smalltalk.addMethod(
  3573. "_y_",
  3574. smalltalk.method({
  3575. selector: "y:",
  3576. category: 'accessing',
  3577. fn: function (aNumber) {
  3578. var self = this;
  3579. self['@y'] = aNumber;
  3580. return self;
  3581. },
  3582. args: ["aNumber"],
  3583. source: "y: aNumber\x0a\x09y := aNumber",
  3584. messageSends: [],
  3585. referencedClasses: []
  3586. }),
  3587. smalltalk.Point);
  3588. smalltalk.addMethod(
  3589. "_x_y_",
  3590. smalltalk.method({
  3591. selector: "x:y:",
  3592. category: 'instance creation',
  3593. fn: function (aNumber, anotherNumber) {
  3594. var self = this;
  3595. var $2, $3, $1;
  3596. $2 = smalltalk.send(self, "_new", []);
  3597. smalltalk.send($2, "_x_", [aNumber]);
  3598. smalltalk.send($2, "_y_", [anotherNumber]);
  3599. $3 = smalltalk.send($2, "_yourself", []);
  3600. $1 = $3;
  3601. return $1;
  3602. },
  3603. args: ["aNumber", "anotherNumber"],
  3604. source: "x: aNumber y: anotherNumber\x0a\x09^self new\x0a\x09\x09x: aNumber;\x0a\x09\x09y: anotherNumber;\x0a\x09\x09yourself",
  3605. messageSends: ["x:", "new", "y:", "yourself"],
  3606. referencedClasses: []
  3607. }),
  3608. smalltalk.Point.klass);
  3609. smalltalk.addClass('Random', smalltalk.Object, [], 'Kernel-Objects');
  3610. smalltalk.Random.comment="`Random` is a random number generator and is implemented as a trivial wrapper around javascript `Math.random()` and is used like this:\x0a\x0a\x09Random new next\x0a\x0aThis will return a float x where x < 1 and x > 0. If you want a random integer from 1 to 10 you can use `#atRandom`\x0a\x0a\x0910 atRandom\x0a\x0a...and if you want a random number in a specific interval this also works:\x0a\x0a\x09(3 to: 7) atRandom\x0a\x0a...but be aware that `#to:` does not create an Interval as in other Smalltalk implementations but in fact an `Array` of numbers, so it's better to use:\x0a\x0a\x095 atRandom + 2\x0a\x0aSince `#atRandom` is implemented in `SequencableCollection` you can easy pick an element at random:\x0a\x0a\x09#('a' 'b' 'c') atRandom\x0a\x0a...or perhaps a letter from a `String`:\x0a\x0a\x09'abc' atRandom\x0a\x0aSince Amber does not have Characters this will return a `String` of length 1 like for example `'b'`."
  3611. smalltalk.addMethod(
  3612. "_next",
  3613. smalltalk.method({
  3614. selector: "next",
  3615. category: 'accessing',
  3616. fn: function () {
  3617. var self = this;
  3618. return Math.random();
  3619. return self;
  3620. },
  3621. args: [],
  3622. source: "next\x0a\x09<return Math.random()>",
  3623. messageSends: [],
  3624. referencedClasses: []
  3625. }),
  3626. smalltalk.Random);
  3627. smalltalk.addMethod(
  3628. "_next_",
  3629. smalltalk.method({
  3630. selector: "next:",
  3631. category: 'accessing',
  3632. fn: function (anInteger) {
  3633. var self = this;
  3634. var $1;
  3635. $1 = smalltalk.send(smalltalk.send(1, "_to_", [anInteger]), "_collect_", [function (each) {return smalltalk.send(self, "_next", []);}]);
  3636. return $1;
  3637. },
  3638. args: ["anInteger"],
  3639. source: "next: anInteger\x0a ^(1 to: anInteger) collect: [:each | self next]",
  3640. messageSends: ["collect:", "next", "to:"],
  3641. referencedClasses: []
  3642. }),
  3643. smalltalk.Random);
  3644. smalltalk.addClass('Smalltalk', smalltalk.Object, [], 'Kernel-Objects');
  3645. smalltalk.Smalltalk.comment="Smalltalk has only one instance, accessed with `Smalltalk current`. \x0aIt represents the global JavaScript variable `smalltalk` declared in `js/boot.js`.\x0a\x0aThe `smalltalk` object holds all class and packages defined in the system.\x0a\x0a## Classes\x0a\x0aClasses can be accessed using the following methods:\x0a\x0a- `#classes` answers the full list of Smalltalk classes in the system\x0a- `#at:` answers a specific class of `nil`\x0a\x0a## Packages\x0a\x0aPackages can be accessed using the following methods:\x0a\x0a- `#packages` answers the full list of packages\x0a- `#packageAt:` answers a specific class of `nil`\x0a\x0a__note:__ classes and packages are accessed using strings, not symbols\x0a\x0a## Parsing\x0a\x0aThe `#parse:` method is used to parse Smalltalk source code. \x0aIt requires the `Compiler` package and the `js/parser.js` parser file in order to work"
  3646. smalltalk.addMethod(
  3647. "_at_",
  3648. smalltalk.method({
  3649. selector: "at:",
  3650. category: 'accessing',
  3651. fn: function (aString) {
  3652. var self = this;
  3653. return self[aString];
  3654. return self;
  3655. },
  3656. args: ["aString"],
  3657. source: "at: aString\x0a\x09<return self[aString]>",
  3658. messageSends: [],
  3659. referencedClasses: []
  3660. }),
  3661. smalltalk.Smalltalk);
  3662. smalltalk.addMethod(
  3663. "_basicParse_",
  3664. smalltalk.method({
  3665. selector: "basicParse:",
  3666. category: 'accessing',
  3667. fn: function (aString) {
  3668. var self = this;
  3669. return smalltalk.parser.parse(aString);
  3670. return self;
  3671. },
  3672. args: ["aString"],
  3673. source: "basicParse: aString\x0a\x09<return smalltalk.parser.parse(aString)>",
  3674. messageSends: [],
  3675. referencedClasses: []
  3676. }),
  3677. smalltalk.Smalltalk);
  3678. smalltalk.addMethod(
  3679. "_classes",
  3680. smalltalk.method({
  3681. selector: "classes",
  3682. category: 'accessing',
  3683. fn: function () {
  3684. var self = this;
  3685. return self.classes();
  3686. return self;
  3687. },
  3688. args: [],
  3689. source: "classes\x0a\x09<return self.classes()>",
  3690. messageSends: [],
  3691. referencedClasses: []
  3692. }),
  3693. smalltalk.Smalltalk);
  3694. smalltalk.addMethod(
  3695. "_createPackage_",
  3696. smalltalk.method({
  3697. selector: "createPackage:",
  3698. category: 'private',
  3699. fn: function (packageName) {
  3700. var self = this;
  3701. return smalltalk.addPackage(packageName, nil);
  3702. return self;
  3703. },
  3704. args: ["packageName"],
  3705. source: "createPackage: packageName\x0a\x09\x22Create and bind a new package with given name and return it.\x22\x0a\x0a <return smalltalk.addPackage(packageName, nil)>",
  3706. messageSends: [],
  3707. referencedClasses: []
  3708. }),
  3709. smalltalk.Smalltalk);
  3710. smalltalk.addMethod(
  3711. "_createPackage_properties_",
  3712. smalltalk.method({
  3713. selector: "createPackage:properties:",
  3714. category: 'private',
  3715. fn: function (packageName, aDict) {
  3716. var self = this;
  3717. var object;
  3718. object = {};
  3719. smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
  3720. return smalltalk.addPackage(packageName, object);
  3721. return self;
  3722. },
  3723. args: ["packageName", "aDict"],
  3724. source: "createPackage: packageName properties: aDict\x0a\x09\x22Create and bind a new package with given name and return it.\x22\x0a\x0a\x09| object |\x0a\x09<object = {};>.\x0a\x09aDict keysAndValuesDo: [:key :value |\x0a\x09\x09<object[key] = value>.\x0a\x09].\x0a <return smalltalk.addPackage(packageName, object)>",
  3725. messageSends: ["keysAndValuesDo:"],
  3726. referencedClasses: []
  3727. }),
  3728. smalltalk.Smalltalk);
  3729. smalltalk.addMethod(
  3730. "_deletePackage_",
  3731. smalltalk.method({
  3732. selector: "deletePackage:",
  3733. category: 'private',
  3734. fn: function (packageName) {
  3735. var self = this;
  3736. delete smalltalk.packages[packageName];
  3737. return self;
  3738. },
  3739. args: ["packageName"],
  3740. source: "deletePackage: packageName\x0a\x09\x22Deletes a package by deleting its binding, but does not check if it contains classes etc.\x0a\x09To remove a package, use #removePackage instead.\x22\x0a\x0a <delete smalltalk.packages[packageName]>",
  3741. messageSends: [],
  3742. referencedClasses: []
  3743. }),
  3744. smalltalk.Smalltalk);
  3745. smalltalk.addMethod(
  3746. "_packageAt_",
  3747. smalltalk.method({
  3748. selector: "packageAt:",
  3749. category: 'packages',
  3750. fn: function (packageName) {
  3751. var self = this;
  3752. return self.packages[packageName];
  3753. return self;
  3754. },
  3755. args: ["packageName"],
  3756. source: "packageAt: packageName\x0a <return self.packages[packageName]>",
  3757. messageSends: [],
  3758. referencedClasses: []
  3759. }),
  3760. smalltalk.Smalltalk);
  3761. smalltalk.addMethod(
  3762. "_packageAt_ifAbsent_",
  3763. smalltalk.method({
  3764. selector: "packageAt:ifAbsent:",
  3765. category: 'packages',
  3766. fn: function (packageName, aBlock) {
  3767. var self = this;
  3768. var $2, $1;
  3769. $2 = smalltalk.send(self, "_packageAt_", [packageName]);
  3770. $1 = smalltalk.send($2, "_ifNil_", [aBlock]);
  3771. return $1;
  3772. },
  3773. args: ["packageName", "aBlock"],
  3774. source: "packageAt: packageName ifAbsent: aBlock\x0a ^(self packageAt: packageName) ifNil: aBlock",
  3775. messageSends: ["ifNil:", "packageAt:"],
  3776. referencedClasses: []
  3777. }),
  3778. smalltalk.Smalltalk);
  3779. smalltalk.addMethod(
  3780. "_packages",
  3781. smalltalk.method({
  3782. selector: "packages",
  3783. category: 'packages',
  3784. fn: function () {
  3785. var self = this;
  3786. return self.packages.all();
  3787. return self;
  3788. },
  3789. args: [],
  3790. source: "packages\x0a\x09\x22Return all Package instances in the system.\x22\x0a\x0a\x09<return self.packages.all()>",
  3791. messageSends: [],
  3792. referencedClasses: []
  3793. }),
  3794. smalltalk.Smalltalk);
  3795. smalltalk.addMethod(
  3796. "_parse_",
  3797. smalltalk.method({
  3798. selector: "parse:",
  3799. category: 'accessing',
  3800. fn: function (aString) {
  3801. var self = this;
  3802. var result;
  3803. smalltalk.send(self, "_try_catch_", [function () {result = smalltalk.send(self, "_basicParse_", [aString]);return result;}, function (ex) {return smalltalk.send(smalltalk.send(self, "_parseError_parsing_", [ex, aString]), "_signal", []);}]);
  3804. return result;
  3805. },
  3806. args: ["aString"],
  3807. source: "parse: aString\x0a\x09| result | \x0a\x09self try: [result := self basicParse: aString] catch: [:ex | (self parseError: ex parsing: aString) signal].\x0a\x09^result",
  3808. messageSends: ["try:catch:", "basicParse:", "signal", "parseError:parsing:"],
  3809. referencedClasses: []
  3810. }),
  3811. smalltalk.Smalltalk);
  3812. smalltalk.addMethod(
  3813. "_parseError_parsing_",
  3814. smalltalk.method({
  3815. selector: "parseError:parsing:",
  3816. category: 'accessing',
  3817. fn: function (anException, aString) {
  3818. var self = this;
  3819. var $1;
  3820. var row;
  3821. var col;
  3822. var message;
  3823. var lines;
  3824. var badLine;
  3825. var code;
  3826. row = anException.line;
  3827. col = anException.column;
  3828. message = anException.message;
  3829. lines = smalltalk.send(aString, "_lines", []);
  3830. badLine = smalltalk.send(lines, "_at_", [row]);
  3831. badLine = smalltalk.send(smalltalk.send(smalltalk.send(badLine, "_copyFrom_to_", [1, smalltalk.send(col, "__minus", [1])]), "__comma", [" ===>"]), "__comma", [smalltalk.send(badLine, "_copyFrom_to_", [col, smalltalk.send(badLine, "_size", [])])]);
  3832. smalltalk.send(lines, "_at_put_", [row, badLine]);
  3833. code = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (s) {return smalltalk.send(lines, "_withIndexDo_", [function (l, i) {return smalltalk.send(s, "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(i, "_asString", []), "__comma", [": "]), "__comma", [l]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])])]);}]);}]);
  3834. $1 = smalltalk.send(smalltalk.send(smalltalk.ParseError || ParseError, "_new", []), "_messageText_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("Parse error on line ", "__comma", [row]), "__comma", [" column "]), "__comma", [col]), "__comma", [" : "]), "__comma", [message]), "__comma", [" Below is code with line numbers and ===> marker inserted:"]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])]), "__comma", [code])]);
  3835. return $1;
  3836. },
  3837. args: ["anException", "aString"],
  3838. source: "parseError: anException parsing: aString\x0a\x09| row col message lines badLine code |\x0a\x09<row = anException.line;\x0a\x09col = anException.column;\x0a\x09message = anException.message;>.\x0a\x09lines := aString lines.\x0a\x09badLine := lines at: row.\x0a\x09badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom: col to: badLine size).\x0a\x09lines at: row put: badLine.\x0a\x09code := String streamContents: [:s |\x0a lines withIndexDo: [:l :i |\x0a s nextPutAll: i asString, ': ', l, String lf]].\x0a\x09^ ParseError new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)",
  3839. messageSends: ["lines", "at:", ",", "copyFrom:to:", "size", "-", "at:put:", "streamContents:", "withIndexDo:", "nextPutAll:", "lf", "asString", "messageText:", "new"],
  3840. referencedClasses: ["String", "ParseError"]
  3841. }),
  3842. smalltalk.Smalltalk);
  3843. smalltalk.addMethod(
  3844. "_pseudoVariableNames",
  3845. smalltalk.method({
  3846. selector: "pseudoVariableNames",
  3847. category: 'packages',
  3848. fn: function () {
  3849. var self = this;
  3850. return ["self", "super", "nil", "true", "false"];
  3851. },
  3852. args: [],
  3853. source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false')",
  3854. messageSends: [],
  3855. referencedClasses: []
  3856. }),
  3857. smalltalk.Smalltalk);
  3858. smalltalk.addMethod(
  3859. "_readJSObject_",
  3860. smalltalk.method({
  3861. selector: "readJSObject:",
  3862. category: 'accessing',
  3863. fn: function (anObject) {
  3864. var self = this;
  3865. return self.readJSObject(anObject);
  3866. return self;
  3867. },
  3868. args: ["anObject"],
  3869. source: "readJSObject: anObject\x0a\x09<return self.readJSObject(anObject)>",
  3870. messageSends: [],
  3871. referencedClasses: []
  3872. }),
  3873. smalltalk.Smalltalk);
  3874. smalltalk.addMethod(
  3875. "_removeClass_",
  3876. smalltalk.method({
  3877. selector: "removeClass:",
  3878. category: 'classes',
  3879. fn: function (aClass) {
  3880. var self = this;
  3881. var $1;
  3882. $1 = smalltalk.send(aClass, "_isMetaclass", []);
  3883. if (smalltalk.assert($1)) {
  3884. smalltalk.send(self, "_error_", [smalltalk.send(smalltalk.send(aClass, "_asString", []), "__comma", [" is a Metaclass and cannot be removed!"])]);
  3885. }
  3886. smalltalk.send(smalltalk.send(smalltalk.send(aClass, "_methodDictionary", []), "_values", []), "_do_", [function (each) {return smalltalk.send(aClass, "_removeCompiledMethod_", [each]);}]);
  3887. smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aClass, "_class", []), "_methodDictionary", []), "_values", []), "_do_", [function (each) {return smalltalk.send(smalltalk.send(aClass, "_class", []), "_removeCompiledMethod_", [each]);}]);
  3888. smalltalk.send(self, "_basicDelete_", [smalltalk.send(aClass, "_name", [])]);
  3889. return self;
  3890. },
  3891. args: ["aClass"],
  3892. source: "removeClass: aClass\x0a\x09aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!'].\x0a\x09aClass methodDictionary values do: [:each |\x0a\x09\x09aClass removeCompiledMethod: each].\x0a\x09aClass class methodDictionary values do: [:each |\x0a\x09\x09aClass class removeCompiledMethod: each].\x0a\x09self basicDelete: aClass name",
  3893. messageSends: ["ifTrue:", "error:", ",", "asString", "isMetaclass", "do:", "removeCompiledMethod:", "values", "methodDictionary", "class", "basicDelete:", "name"],
  3894. referencedClasses: []
  3895. }),
  3896. smalltalk.Smalltalk);
  3897. smalltalk.addMethod(
  3898. "_removePackage_",
  3899. smalltalk.method({
  3900. selector: "removePackage:",
  3901. category: 'packages',
  3902. fn: function (packageName) {
  3903. var self = this;
  3904. var pkg;
  3905. pkg = smalltalk.send(self, "_packageAt_ifAbsent_", [packageName, function () {return smalltalk.send(self, "_error_", [smalltalk.send("Missing package: ", "__comma", [packageName])]);}]);
  3906. smalltalk.send(smalltalk.send(pkg, "_classes", []), "_do_", [function (each) {return smalltalk.send(self, "_removeClass_", [each]);}]);
  3907. smalltalk.send(self, "_deletePackage_", [packageName]);
  3908. return self;
  3909. },
  3910. args: ["packageName"],
  3911. source: "removePackage: packageName\x0a\x09\x22Removes a package and all its classes.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].\x0a\x09pkg classes do: [:each |\x0a \x09self removeClass: each].\x0a\x09self deletePackage: packageName",
  3912. messageSends: ["packageAt:ifAbsent:", "error:", ",", "do:", "removeClass:", "classes", "deletePackage:"],
  3913. referencedClasses: []
  3914. }),
  3915. smalltalk.Smalltalk);
  3916. smalltalk.addMethod(
  3917. "_renamePackage_to_",
  3918. smalltalk.method({
  3919. selector: "renamePackage:to:",
  3920. category: 'packages',
  3921. fn: function (packageName, newName) {
  3922. var self = this;
  3923. var $1;
  3924. var pkg;
  3925. pkg = smalltalk.send(self, "_packageAt_ifAbsent_", [packageName, function () {return smalltalk.send(self, "_error_", [smalltalk.send("Missing package: ", "__comma", [packageName])]);}]);
  3926. $1 = smalltalk.send(self, "_packageAt_", [newName]);
  3927. if (($receiver = $1) == nil || $receiver == undefined) {
  3928. } else {
  3929. smalltalk.send(self, "_error_", [smalltalk.send("Already exists a package called: ", "__comma", [newName])]);
  3930. }
  3931. smalltalk.packages[newName] = smalltalk.packages[packageName];
  3932. smalltalk.send(pkg, "_name_", [newName]);
  3933. smalltalk.send(self, "_deletePackage_", [packageName]);
  3934. return self;
  3935. },
  3936. args: ["packageName", "newName"],
  3937. source: "renamePackage: packageName to: newName\x0a\x09\x22Rename a package.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].\x0a\x09(self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].\x0a\x09<smalltalk.packages[newName] = smalltalk.packages[packageName]>.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
  3938. messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "name:", "deletePackage:"],
  3939. referencedClasses: []
  3940. }),
  3941. smalltalk.Smalltalk);
  3942. smalltalk.addMethod(
  3943. "_reservedWords",
  3944. smalltalk.method({
  3945. selector: "reservedWords",
  3946. category: 'accessing',
  3947. fn: function () {
  3948. var self = this;
  3949. return self.reservedWords;
  3950. return self;
  3951. },
  3952. args: [],
  3953. source: "reservedWords\x0a\x09\x22JavaScript reserved words\x22\x0a\x09<return self.reservedWords>",
  3954. messageSends: [],
  3955. referencedClasses: []
  3956. }),
  3957. smalltalk.Smalltalk);
  3958. smalltalk.addMethod(
  3959. "_send_to_arguments_",
  3960. smalltalk.method({
  3961. selector: "send:to:arguments:",
  3962. category: 'accessing',
  3963. fn: function (aSelector, anObject, aCollection) {
  3964. var self = this;
  3965. var selector;
  3966. selector = smalltalk.send(smalltalk.send(aSelector, "_asString", []), "_asSelector", []);
  3967. return self.send(anObject, selector, aCollection);
  3968. return self;
  3969. },
  3970. args: ["aSelector", "anObject", "aCollection"],
  3971. source: "send: aSelector to: anObject arguments: aCollection\x0a\x09| selector |\x0a\x09selector := aSelector asString asSelector.\x0a\x09<return self.send(anObject, selector, aCollection)>",
  3972. messageSends: ["asSelector", "asString"],
  3973. referencedClasses: []
  3974. }),
  3975. smalltalk.Smalltalk);
  3976. smalltalk.Smalltalk.klass.iVarNames = ['current'];
  3977. smalltalk.addMethod(
  3978. "_current",
  3979. smalltalk.method({
  3980. selector: "current",
  3981. category: 'accessing',
  3982. fn: function () {
  3983. var self = this;
  3984. return smalltalk;
  3985. return self;
  3986. },
  3987. args: [],
  3988. source: "current\x0a\x09<return smalltalk>",
  3989. messageSends: [],
  3990. referencedClasses: []
  3991. }),
  3992. smalltalk.Smalltalk.klass);
  3993. smalltalk.addClass('UndefinedObject', smalltalk.Object, [], 'Kernel-Objects');
  3994. smalltalk.UndefinedObject.comment="UndefinedObject describes the behavior of its sole instance, `nil`. `nil` represents a prior value for variables that have not been initialized, or for results which are meaningless.\x0a\x0a`nil` is the Smalltalk representation of the `undefined` JavaScript object."
  3995. smalltalk.addMethod(
  3996. "_asJSON",
  3997. smalltalk.method({
  3998. selector: "asJSON",
  3999. category: 'converting',
  4000. fn: function () {
  4001. var self = this;
  4002. return null;
  4003. },
  4004. args: [],
  4005. source: "asJSON\x0a\x09^null",
  4006. messageSends: [],
  4007. referencedClasses: []
  4008. }),
  4009. smalltalk.UndefinedObject);
  4010. smalltalk.addMethod(
  4011. "_deepCopy",
  4012. smalltalk.method({
  4013. selector: "deepCopy",
  4014. category: 'copying',
  4015. fn: function () {
  4016. var self = this;
  4017. return self;
  4018. },
  4019. args: [],
  4020. source: "deepCopy\x0a\x09^self",
  4021. messageSends: [],
  4022. referencedClasses: []
  4023. }),
  4024. smalltalk.UndefinedObject);
  4025. smalltalk.addMethod(
  4026. "_ifNil_",
  4027. smalltalk.method({
  4028. selector: "ifNil:",
  4029. category: 'testing',
  4030. fn: function (aBlock) {
  4031. var self = this;
  4032. var $1;
  4033. $1 = smalltalk.send(self, "_ifNil_ifNotNil_", [aBlock, function () {}]);
  4034. return $1;
  4035. },
  4036. args: ["aBlock"],
  4037. source: "ifNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self ifNil: aBlock ifNotNil: []",
  4038. messageSends: ["ifNil:ifNotNil:"],
  4039. referencedClasses: []
  4040. }),
  4041. smalltalk.UndefinedObject);
  4042. smalltalk.addMethod(
  4043. "_ifNil_ifNotNil_",
  4044. smalltalk.method({
  4045. selector: "ifNil:ifNotNil:",
  4046. category: 'testing',
  4047. fn: function (aBlock, anotherBlock) {
  4048. var self = this;
  4049. var $1;
  4050. $1 = smalltalk.send(aBlock, "_value", []);
  4051. return $1;
  4052. },
  4053. args: ["aBlock", "anotherBlock"],
  4054. source: "ifNil: aBlock ifNotNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^aBlock value",
  4055. messageSends: ["value"],
  4056. referencedClasses: []
  4057. }),
  4058. smalltalk.UndefinedObject);
  4059. smalltalk.addMethod(
  4060. "_ifNotNil_",
  4061. smalltalk.method({
  4062. selector: "ifNotNil:",
  4063. category: 'testing',
  4064. fn: function (aBlock) {
  4065. var self = this;
  4066. return self;
  4067. },
  4068. args: ["aBlock"],
  4069. source: "ifNotNil: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^self",
  4070. messageSends: [],
  4071. referencedClasses: []
  4072. }),
  4073. smalltalk.UndefinedObject);
  4074. smalltalk.addMethod(
  4075. "_ifNotNil_ifNil_",
  4076. smalltalk.method({
  4077. selector: "ifNotNil:ifNil:",
  4078. category: 'testing',
  4079. fn: function (aBlock, anotherBlock) {
  4080. var self = this;
  4081. var $1;
  4082. $1 = smalltalk.send(anotherBlock, "_value", []);
  4083. return $1;
  4084. },
  4085. args: ["aBlock", "anotherBlock"],
  4086. source: "ifNotNil: aBlock ifNil: anotherBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09^anotherBlock value",
  4087. messageSends: ["value"],
  4088. referencedClasses: []
  4089. }),
  4090. smalltalk.UndefinedObject);
  4091. smalltalk.addMethod(
  4092. "_isNil",
  4093. smalltalk.method({
  4094. selector: "isNil",
  4095. category: 'testing',
  4096. fn: function () {
  4097. var self = this;
  4098. return true;
  4099. },
  4100. args: [],
  4101. source: "isNil\x0a\x09^true",
  4102. messageSends: [],
  4103. referencedClasses: []
  4104. }),
  4105. smalltalk.UndefinedObject);
  4106. smalltalk.addMethod(
  4107. "_notNil",
  4108. smalltalk.method({
  4109. selector: "notNil",
  4110. category: 'testing',
  4111. fn: function () {
  4112. var self = this;
  4113. return false;
  4114. },
  4115. args: [],
  4116. source: "notNil\x0a\x09^false",
  4117. messageSends: [],
  4118. referencedClasses: []
  4119. }),
  4120. smalltalk.UndefinedObject);
  4121. smalltalk.addMethod(
  4122. "_printString",
  4123. smalltalk.method({
  4124. selector: "printString",
  4125. category: 'printing',
  4126. fn: function () {
  4127. var self = this;
  4128. return "nil";
  4129. },
  4130. args: [],
  4131. source: "printString\x0a ^'nil'",
  4132. messageSends: [],
  4133. referencedClasses: []
  4134. }),
  4135. smalltalk.UndefinedObject);
  4136. smalltalk.addMethod(
  4137. "_shallowCopy",
  4138. smalltalk.method({
  4139. selector: "shallowCopy",
  4140. category: 'copying',
  4141. fn: function () {
  4142. var self = this;
  4143. return self;
  4144. },
  4145. args: [],
  4146. source: "shallowCopy\x0a\x09^self",
  4147. messageSends: [],
  4148. referencedClasses: []
  4149. }),
  4150. smalltalk.UndefinedObject);
  4151. smalltalk.addMethod(
  4152. "_subclass_instanceVariableNames_",
  4153. smalltalk.method({
  4154. selector: "subclass:instanceVariableNames:",
  4155. category: 'class creation',
  4156. fn: function (aString, anotherString) {
  4157. var self = this;
  4158. var $1;
  4159. $1 = smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, anotherString, nil]);
  4160. return $1;
  4161. },
  4162. args: ["aString", "anotherString"],
  4163. source: "subclass: aString instanceVariableNames: anotherString\x0a\x09^self subclass: aString instanceVariableNames: anotherString package: nil",
  4164. messageSends: ["subclass:instanceVariableNames:package:"],
  4165. referencedClasses: []
  4166. }),
  4167. smalltalk.UndefinedObject);
  4168. smalltalk.addMethod(
  4169. "_subclass_instanceVariableNames_category_",
  4170. smalltalk.method({
  4171. selector: "subclass:instanceVariableNames:category:",
  4172. category: 'class creation',
  4173. fn: function (aString, aString2, aString3) {
  4174. var self = this;
  4175. var $1;
  4176. smalltalk.send(self, "_deprecatedAPI", []);
  4177. $1 = smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
  4178. return $1;
  4179. },
  4180. args: ["aString", "aString2", "aString3"],
  4181. source: "subclass: aString instanceVariableNames: aString2 category: aString3\x0a\x09\x22Kept for compatibility.\x22\x0a\x09self deprecatedAPI.\x0a\x09^self subclass: aString instanceVariableNames: aString2 package: aString3",
  4182. messageSends: ["deprecatedAPI", "subclass:instanceVariableNames:package:"],
  4183. referencedClasses: []
  4184. }),
  4185. smalltalk.UndefinedObject);
  4186. smalltalk.addMethod(
  4187. "_subclass_instanceVariableNames_package_",
  4188. smalltalk.method({
  4189. selector: "subclass:instanceVariableNames:package:",
  4190. category: 'class creation',
  4191. fn: function (aString, aString2, aString3) {
  4192. var self = this;
  4193. var $1;
  4194. $1 = smalltalk.send(smalltalk.send(smalltalk.ClassBuilder || ClassBuilder, "_new", []), "_superclass_subclass_instanceVariableNames_package_", [self, aString, aString2, aString3]);
  4195. return $1;
  4196. },
  4197. args: ["aString", "aString2", "aString3"],
  4198. source: "subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09^ClassBuilder new\x0a\x09 superclass: self subclass: aString instanceVariableNames: aString2 package: aString3",
  4199. messageSends: ["superclass:subclass:instanceVariableNames:package:", "new"],
  4200. referencedClasses: ["ClassBuilder"]
  4201. }),
  4202. smalltalk.UndefinedObject);
  4203. smalltalk.addMethod(
  4204. "_new",
  4205. smalltalk.method({
  4206. selector: "new",
  4207. category: 'instance creation',
  4208. fn: function () {
  4209. var self = this;
  4210. smalltalk.send(self, "_error_", ["You cannot create new instances of UndefinedObject. Use nil"]);
  4211. return self;
  4212. },
  4213. args: [],
  4214. source: "new\x0a\x09 self error: 'You cannot create new instances of UndefinedObject. Use nil'",
  4215. messageSends: ["error:"],
  4216. referencedClasses: []
  4217. }),
  4218. smalltalk.UndefinedObject.klass);