1
0

Kernel-Infrastructure.js 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993
  1. define("amber_core/Kernel-Infrastructure", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Kernel-Infrastructure');
  3. smalltalk.packages["Kernel-Infrastructure"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('ConsoleErrorHandler', globals.Object, [], 'Kernel-Infrastructure');
  5. globals.ConsoleErrorHandler.comment="I am manage Smalltalk errors, displaying the stack in the console.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "handleError:",
  9. protocol: 'error handling',
  10. fn: function (anError){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. $1=_st(anError)._context();
  15. $ctx1.sendIdx["context"]=1;
  16. if(($receiver = $1) == nil || $receiver == null){
  17. $1;
  18. } else {
  19. self._logErrorContext_(_st(anError)._context());
  20. };
  21. self._logError_(anError);
  22. return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.ConsoleErrorHandler)})},
  23. args: ["anError"],
  24. source: "handleError: anError\x0a\x09anError context ifNotNil: [ self logErrorContext: anError context ].\x0a\x09self logError: anError",
  25. messageSends: ["ifNotNil:", "context", "logErrorContext:", "logError:"],
  26. referencedClasses: []
  27. }),
  28. globals.ConsoleErrorHandler);
  29. smalltalk.addMethod(
  30. smalltalk.method({
  31. selector: "log:",
  32. protocol: 'private',
  33. fn: function (aString){
  34. var self=this;
  35. return smalltalk.withContext(function($ctx1) {
  36. _st(console)._log_(aString);
  37. return self}, function($ctx1) {$ctx1.fill(self,"log:",{aString:aString},globals.ConsoleErrorHandler)})},
  38. args: ["aString"],
  39. source: "log: aString\x0a\x09console log: aString",
  40. messageSends: ["log:"],
  41. referencedClasses: []
  42. }),
  43. globals.ConsoleErrorHandler);
  44. smalltalk.addMethod(
  45. smalltalk.method({
  46. selector: "logContext:",
  47. protocol: 'private',
  48. fn: function (aContext){
  49. var self=this;
  50. return smalltalk.withContext(function($ctx1) {
  51. var $1;
  52. $1=_st(aContext)._home();
  53. $ctx1.sendIdx["home"]=1;
  54. if(($receiver = $1) == nil || $receiver == null){
  55. $1;
  56. } else {
  57. self._logContext_(_st(aContext)._home());
  58. };
  59. self._log_(_st(aContext)._asString());
  60. return self}, function($ctx1) {$ctx1.fill(self,"logContext:",{aContext:aContext},globals.ConsoleErrorHandler)})},
  61. args: ["aContext"],
  62. source: "logContext: aContext\x0a\x09aContext home ifNotNil: [\x0a\x09\x09self logContext: aContext home ].\x0a\x09self log: aContext asString",
  63. messageSends: ["ifNotNil:", "home", "logContext:", "log:", "asString"],
  64. referencedClasses: []
  65. }),
  66. globals.ConsoleErrorHandler);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "logError:",
  70. protocol: 'private',
  71. fn: function (anError){
  72. var self=this;
  73. return smalltalk.withContext(function($ctx1) {
  74. self._log_(_st(anError)._messageText());
  75. return self}, function($ctx1) {$ctx1.fill(self,"logError:",{anError:anError},globals.ConsoleErrorHandler)})},
  76. args: ["anError"],
  77. source: "logError: anError\x0a\x09self log: anError messageText",
  78. messageSends: ["log:", "messageText"],
  79. referencedClasses: []
  80. }),
  81. globals.ConsoleErrorHandler);
  82. smalltalk.addMethod(
  83. smalltalk.method({
  84. selector: "logErrorContext:",
  85. protocol: 'private',
  86. fn: function (aContext){
  87. var self=this;
  88. return smalltalk.withContext(function($ctx1) {
  89. var $1;
  90. if(($receiver = aContext) == nil || $receiver == null){
  91. aContext;
  92. } else {
  93. $1=_st(aContext)._home();
  94. $ctx1.sendIdx["home"]=1;
  95. if(($receiver = $1) == nil || $receiver == null){
  96. $1;
  97. } else {
  98. self._logContext_(_st(aContext)._home());
  99. };
  100. };
  101. return self}, function($ctx1) {$ctx1.fill(self,"logErrorContext:",{aContext:aContext},globals.ConsoleErrorHandler)})},
  102. args: ["aContext"],
  103. source: "logErrorContext: aContext\x0a\x09aContext ifNotNil: [\x0a\x09\x09aContext home ifNotNil: [\x0a\x09\x09\x09self logContext: aContext home ]]",
  104. messageSends: ["ifNotNil:", "home", "logContext:"],
  105. referencedClasses: []
  106. }),
  107. globals.ConsoleErrorHandler);
  108. globals.ConsoleErrorHandler.klass.iVarNames = ['current'];
  109. smalltalk.addMethod(
  110. smalltalk.method({
  111. selector: "initialize",
  112. protocol: 'initialization',
  113. fn: function (){
  114. var self=this;
  115. function $ErrorHandler(){return globals.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
  116. return smalltalk.withContext(function($ctx1) {
  117. _st($ErrorHandler())._registerIfNone_(self._new());
  118. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ConsoleErrorHandler.klass)})},
  119. args: [],
  120. source: "initialize\x0a\x09ErrorHandler registerIfNone: self new",
  121. messageSends: ["registerIfNone:", "new"],
  122. referencedClasses: ["ErrorHandler"]
  123. }),
  124. globals.ConsoleErrorHandler.klass);
  125. smalltalk.addClass('InterfacingObject', globals.Object, [], 'Kernel-Infrastructure');
  126. globals.InterfacingObject.comment="I am superclass of all object that interface with user or environment. `Widget` and a few other classes are subclasses of me. I delegate all of the above APIs to `PlatformInterface`.\x0a\x0a## API\x0a\x0a self alert: 'Hey, there is a problem'.\x0a self confirm: 'Affirmative?'.\x0a self prompt: 'Your name:'.\x0a\x0a self ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.";
  127. smalltalk.addMethod(
  128. smalltalk.method({
  129. selector: "ajax:",
  130. protocol: 'actions',
  131. fn: function (anObject){
  132. var self=this;
  133. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  134. return smalltalk.withContext(function($ctx1) {
  135. var $1;
  136. $1=_st($PlatformInterface())._ajax_(anObject);
  137. return $1;
  138. }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},globals.InterfacingObject)})},
  139. args: ["anObject"],
  140. source: "ajax: anObject\x0a\x09^ PlatformInterface ajax: anObject",
  141. messageSends: ["ajax:"],
  142. referencedClasses: ["PlatformInterface"]
  143. }),
  144. globals.InterfacingObject);
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "alert:",
  148. protocol: 'actions',
  149. fn: function (aString){
  150. var self=this;
  151. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  152. return smalltalk.withContext(function($ctx1) {
  153. var $1;
  154. $1=_st($PlatformInterface())._alert_(aString);
  155. return $1;
  156. }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},globals.InterfacingObject)})},
  157. args: ["aString"],
  158. source: "alert: aString\x0a\x09^ PlatformInterface alert: aString",
  159. messageSends: ["alert:"],
  160. referencedClasses: ["PlatformInterface"]
  161. }),
  162. globals.InterfacingObject);
  163. smalltalk.addMethod(
  164. smalltalk.method({
  165. selector: "confirm:",
  166. protocol: 'actions',
  167. fn: function (aString){
  168. var self=this;
  169. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  170. return smalltalk.withContext(function($ctx1) {
  171. var $1;
  172. $1=_st($PlatformInterface())._confirm_(aString);
  173. return $1;
  174. }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},globals.InterfacingObject)})},
  175. args: ["aString"],
  176. source: "confirm: aString\x0a\x09^ PlatformInterface confirm: aString",
  177. messageSends: ["confirm:"],
  178. referencedClasses: ["PlatformInterface"]
  179. }),
  180. globals.InterfacingObject);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "prompt:",
  184. protocol: 'actions',
  185. fn: function (aString){
  186. var self=this;
  187. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  188. return smalltalk.withContext(function($ctx1) {
  189. var $1;
  190. $1=_st($PlatformInterface())._prompt_(aString);
  191. return $1;
  192. }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},globals.InterfacingObject)})},
  193. args: ["aString"],
  194. source: "prompt: aString\x0a\x09^ PlatformInterface prompt: aString",
  195. messageSends: ["prompt:"],
  196. referencedClasses: ["PlatformInterface"]
  197. }),
  198. globals.InterfacingObject);
  199. smalltalk.addClass('Environment', globals.InterfacingObject, [], 'Kernel-Infrastructure');
  200. globals.Environment.comment="I provide an unified entry point to manipulate Amber packages, classes and methods.\x0a\x0aTypical use cases include IDEs, remote access and restricting browsing.";
  201. smalltalk.addMethod(
  202. smalltalk.method({
  203. selector: "addInstVarNamed:to:",
  204. protocol: 'compiling',
  205. fn: function (aString,aClass){
  206. var self=this;
  207. return smalltalk.withContext(function($ctx1) {
  208. var $1,$2,$3,$4,$5;
  209. $1=self._classBuilder();
  210. $2=_st(aClass)._superclass();
  211. $3=_st(aClass)._name();
  212. $ctx1.sendIdx["name"]=1;
  213. $4=_st(_st(aClass)._instanceVariableNames())._copy();
  214. _st($4)._add_(aString);
  215. $5=_st($4)._yourself();
  216. _st($1)._addSubclassOf_named_instanceVariableNames_package_($2,$3,$5,_st(_st(aClass)._package())._name());
  217. return self}, function($ctx1) {$ctx1.fill(self,"addInstVarNamed:to:",{aString:aString,aClass:aClass},globals.Environment)})},
  218. args: ["aString", "aClass"],
  219. source: "addInstVarNamed: aString to: aClass\x0a\x09self classBuilder\x0a\x09\x09addSubclassOf: aClass superclass \x0a\x09\x09named: aClass name \x0a\x09\x09instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)\x0a\x09\x09package: aClass package name",
  220. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "classBuilder", "superclass", "name", "add:", "copy", "instanceVariableNames", "yourself", "package"],
  221. referencedClasses: []
  222. }),
  223. globals.Environment);
  224. smalltalk.addMethod(
  225. smalltalk.method({
  226. selector: "allSelectors",
  227. protocol: 'accessing',
  228. fn: function (){
  229. var self=this;
  230. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  231. return smalltalk.withContext(function($ctx1) {
  232. var $1;
  233. $1=_st(_st($Smalltalk())._vm())._allSelectors();
  234. return $1;
  235. }, function($ctx1) {$ctx1.fill(self,"allSelectors",{},globals.Environment)})},
  236. args: [],
  237. source: "allSelectors\x0a\x09^ Smalltalk vm allSelectors",
  238. messageSends: ["allSelectors", "vm"],
  239. referencedClasses: ["Smalltalk"]
  240. }),
  241. globals.Environment);
  242. smalltalk.addMethod(
  243. smalltalk.method({
  244. selector: "availableClassNames",
  245. protocol: 'accessing',
  246. fn: function (){
  247. var self=this;
  248. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  249. return smalltalk.withContext(function($ctx1) {
  250. var $1;
  251. $1=_st(_st($Smalltalk())._classes())._collect_((function(each){
  252. return smalltalk.withContext(function($ctx2) {
  253. return _st(each)._name();
  254. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  255. return $1;
  256. }, function($ctx1) {$ctx1.fill(self,"availableClassNames",{},globals.Environment)})},
  257. args: [],
  258. source: "availableClassNames\x0a\x09^ Smalltalk classes \x0a\x09\x09collect: [ :each | each name ]",
  259. messageSends: ["collect:", "classes", "name"],
  260. referencedClasses: ["Smalltalk"]
  261. }),
  262. globals.Environment);
  263. smalltalk.addMethod(
  264. smalltalk.method({
  265. selector: "availablePackageNames",
  266. protocol: 'accessing',
  267. fn: function (){
  268. var self=this;
  269. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  270. return smalltalk.withContext(function($ctx1) {
  271. var $1;
  272. $1=_st(_st($Smalltalk())._packages())._collect_((function(each){
  273. return smalltalk.withContext(function($ctx2) {
  274. return _st(each)._name();
  275. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  276. return $1;
  277. }, function($ctx1) {$ctx1.fill(self,"availablePackageNames",{},globals.Environment)})},
  278. args: [],
  279. source: "availablePackageNames\x0a\x09^ Smalltalk packages \x0a\x09\x09collect: [ :each | each name ]",
  280. messageSends: ["collect:", "packages", "name"],
  281. referencedClasses: ["Smalltalk"]
  282. }),
  283. globals.Environment);
  284. smalltalk.addMethod(
  285. smalltalk.method({
  286. selector: "availableProtocolsFor:",
  287. protocol: 'accessing',
  288. fn: function (aClass){
  289. var self=this;
  290. var protocols;
  291. return smalltalk.withContext(function($ctx1) {
  292. var $1,$2;
  293. protocols=_st(aClass)._protocols();
  294. $1=_st(aClass)._superclass();
  295. $ctx1.sendIdx["superclass"]=1;
  296. if(($receiver = $1) == nil || $receiver == null){
  297. $1;
  298. } else {
  299. _st(protocols)._addAll_(self._availableProtocolsFor_(_st(aClass)._superclass()));
  300. };
  301. $2=_st(_st(_st(protocols)._asSet())._asArray())._sort();
  302. return $2;
  303. }, function($ctx1) {$ctx1.fill(self,"availableProtocolsFor:",{aClass:aClass,protocols:protocols},globals.Environment)})},
  304. args: ["aClass"],
  305. source: "availableProtocolsFor: aClass\x0a\x09| protocols |\x0a\x09\x0a\x09protocols := aClass protocols.\x0a\x09aClass superclass ifNotNil: [ protocols addAll: (self availableProtocolsFor: aClass superclass) ].\x0a\x09^ protocols asSet asArray sort",
  306. messageSends: ["protocols", "ifNotNil:", "superclass", "addAll:", "availableProtocolsFor:", "sort", "asArray", "asSet"],
  307. referencedClasses: []
  308. }),
  309. globals.Environment);
  310. smalltalk.addMethod(
  311. smalltalk.method({
  312. selector: "classBuilder",
  313. protocol: 'accessing',
  314. fn: function (){
  315. var self=this;
  316. function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  317. return smalltalk.withContext(function($ctx1) {
  318. var $1;
  319. $1=_st($ClassBuilder())._new();
  320. return $1;
  321. }, function($ctx1) {$ctx1.fill(self,"classBuilder",{},globals.Environment)})},
  322. args: [],
  323. source: "classBuilder\x0a\x09^ ClassBuilder new",
  324. messageSends: ["new"],
  325. referencedClasses: ["ClassBuilder"]
  326. }),
  327. globals.Environment);
  328. smalltalk.addMethod(
  329. smalltalk.method({
  330. selector: "classNamed:",
  331. protocol: 'accessing',
  332. fn: function (aString){
  333. var self=this;
  334. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  335. return smalltalk.withContext(function($ctx1) {
  336. var $2,$1;
  337. $2=_st(_st($Smalltalk())._globals())._at_(_st(aString)._asSymbol());
  338. if(($receiver = $2) == nil || $receiver == null){
  339. $1=self._error_("Invalid class name");
  340. } else {
  341. $1=$2;
  342. };
  343. return $1;
  344. }, function($ctx1) {$ctx1.fill(self,"classNamed:",{aString:aString},globals.Environment)})},
  345. args: ["aString"],
  346. source: "classNamed: aString\x0a\x09^ (Smalltalk globals at: aString asSymbol)\x0a\x09\x09ifNil: [ self error: 'Invalid class name' ]",
  347. messageSends: ["ifNil:", "at:", "globals", "asSymbol", "error:"],
  348. referencedClasses: ["Smalltalk"]
  349. }),
  350. globals.Environment);
  351. smalltalk.addMethod(
  352. smalltalk.method({
  353. selector: "classes",
  354. protocol: 'accessing',
  355. fn: function (){
  356. var self=this;
  357. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  358. return smalltalk.withContext(function($ctx1) {
  359. var $1;
  360. $1=_st($Smalltalk())._classes();
  361. return $1;
  362. }, function($ctx1) {$ctx1.fill(self,"classes",{},globals.Environment)})},
  363. args: [],
  364. source: "classes\x0a\x09^ Smalltalk classes",
  365. messageSends: ["classes"],
  366. referencedClasses: ["Smalltalk"]
  367. }),
  368. globals.Environment);
  369. smalltalk.addMethod(
  370. smalltalk.method({
  371. selector: "commitPackage:",
  372. protocol: 'actions',
  373. fn: function (aPackage){
  374. var self=this;
  375. return smalltalk.withContext(function($ctx1) {
  376. _st(aPackage)._commit();
  377. return self}, function($ctx1) {$ctx1.fill(self,"commitPackage:",{aPackage:aPackage},globals.Environment)})},
  378. args: ["aPackage"],
  379. source: "commitPackage: aPackage\x0a\x09aPackage commit",
  380. messageSends: ["commit"],
  381. referencedClasses: []
  382. }),
  383. globals.Environment);
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "compileClassComment:for:",
  387. protocol: 'compiling',
  388. fn: function (aString,aClass){
  389. var self=this;
  390. return smalltalk.withContext(function($ctx1) {
  391. _st(aClass)._comment_(aString);
  392. return self}, function($ctx1) {$ctx1.fill(self,"compileClassComment:for:",{aString:aString,aClass:aClass},globals.Environment)})},
  393. args: ["aString", "aClass"],
  394. source: "compileClassComment: aString for: aClass\x0a\x09aClass comment: aString",
  395. messageSends: ["comment:"],
  396. referencedClasses: []
  397. }),
  398. globals.Environment);
  399. smalltalk.addMethod(
  400. smalltalk.method({
  401. selector: "compileClassDefinition:",
  402. protocol: 'compiling',
  403. fn: function (aString){
  404. var self=this;
  405. function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  406. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  407. return smalltalk.withContext(function($ctx1) {
  408. _st((function(){
  409. return smalltalk.withContext(function($ctx2) {
  410. return self._eval_on_(aString,_st($DoIt())._new());
  411. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(error){
  412. return smalltalk.withContext(function($ctx2) {
  413. return self._alert_(_st(error)._messageText());
  414. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
  415. return self}, function($ctx1) {$ctx1.fill(self,"compileClassDefinition:",{aString:aString},globals.Environment)})},
  416. args: ["aString"],
  417. source: "compileClassDefinition: aString\x0a\x09[ self eval: aString on: DoIt new ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :error | self alert: error messageText ]",
  418. messageSends: ["on:do:", "eval:on:", "new", "alert:", "messageText"],
  419. referencedClasses: ["DoIt", "Error"]
  420. }),
  421. globals.Environment);
  422. smalltalk.addMethod(
  423. smalltalk.method({
  424. selector: "compileMethod:for:protocol:",
  425. protocol: 'compiling',
  426. fn: function (sourceCode,class_,protocol){
  427. var self=this;
  428. return smalltalk.withContext(function($ctx1) {
  429. var $1;
  430. $1=_st(class_)._compile_protocol_(sourceCode,protocol);
  431. return $1;
  432. }, function($ctx1) {$ctx1.fill(self,"compileMethod:for:protocol:",{sourceCode:sourceCode,class_:class_,protocol:protocol},globals.Environment)})},
  433. args: ["sourceCode", "class", "protocol"],
  434. source: "compileMethod: sourceCode for: class protocol: protocol\x0a\x09^ class\x0a\x09\x09compile: sourceCode\x0a\x09\x09protocol: protocol",
  435. messageSends: ["compile:protocol:"],
  436. referencedClasses: []
  437. }),
  438. globals.Environment);
  439. smalltalk.addMethod(
  440. smalltalk.method({
  441. selector: "copyClass:to:",
  442. protocol: 'actions',
  443. fn: function (aClass,aClassName){
  444. var self=this;
  445. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  446. function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  447. return smalltalk.withContext(function($ctx1) {
  448. var $1,$2;
  449. $1=_st(_st($Smalltalk())._globals())._at_(aClassName);
  450. if(($receiver = $1) == nil || $receiver == null){
  451. $1;
  452. } else {
  453. $2=_st("A class named ".__comma(aClassName)).__comma(" already exists");
  454. $ctx1.sendIdx[","]=1;
  455. self._error_($2);
  456. };
  457. _st(_st($ClassBuilder())._new())._copyClass_named_(aClass,aClassName);
  458. return self}, function($ctx1) {$ctx1.fill(self,"copyClass:to:",{aClass:aClass,aClassName:aClassName},globals.Environment)})},
  459. args: ["aClass", "aClassName"],
  460. source: "copyClass: aClass to: aClassName\x0a\x09(Smalltalk globals at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new copyClass: aClass named: aClassName",
  461. messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "copyClass:named:", "new"],
  462. referencedClasses: ["Smalltalk", "ClassBuilder"]
  463. }),
  464. globals.Environment);
  465. smalltalk.addMethod(
  466. smalltalk.method({
  467. selector: "doItReceiver",
  468. protocol: 'accessing',
  469. fn: function (){
  470. var self=this;
  471. function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  472. return smalltalk.withContext(function($ctx1) {
  473. var $1;
  474. $1=_st($DoIt())._new();
  475. return $1;
  476. }, function($ctx1) {$ctx1.fill(self,"doItReceiver",{},globals.Environment)})},
  477. args: [],
  478. source: "doItReceiver\x0a\x09^ DoIt new",
  479. messageSends: ["new"],
  480. referencedClasses: ["DoIt"]
  481. }),
  482. globals.Environment);
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "eval:on:",
  486. protocol: 'actions',
  487. fn: function (aString,aReceiver){
  488. var self=this;
  489. var compiler;
  490. function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  491. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  492. return smalltalk.withContext(function($ctx1) {
  493. var $1,$2;
  494. var $early={};
  495. try {
  496. compiler=_st($Compiler())._new();
  497. _st((function(){
  498. return smalltalk.withContext(function($ctx2) {
  499. return _st(compiler)._parseExpression_(aString);
  500. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
  501. return smalltalk.withContext(function($ctx2) {
  502. $1=self._alert_(_st(ex)._messageText());
  503. throw $early=[$1];
  504. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
  505. $2=_st(compiler)._evaluateExpression_on_(aString,aReceiver);
  506. return $2;
  507. }
  508. catch(e) {if(e===$early)return e[0]; throw e}
  509. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{aString:aString,aReceiver:aReceiver,compiler:compiler},globals.Environment)})},
  510. args: ["aString", "aReceiver"],
  511. source: "eval: aString on: aReceiver\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09[ compiler parseExpression: aString ] on: Error do: [ :ex |\x0a\x09\x09^ self alert: ex messageText ].\x0a\x09^ compiler evaluateExpression: aString on: aReceiver",
  512. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"],
  513. referencedClasses: ["Compiler", "Error"]
  514. }),
  515. globals.Environment);
  516. smalltalk.addMethod(
  517. smalltalk.method({
  518. selector: "evaluate:on:do:",
  519. protocol: 'error handling',
  520. fn: function (aBlock,anErrorClass,exceptionBlock){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. var $1;
  524. self._try_catch_(aBlock,(function(exception){
  525. return smalltalk.withContext(function($ctx2) {
  526. $1=_st(exception)._isKindOf_(self._classNamed_(_st(anErrorClass)._name()));
  527. if(smalltalk.assert($1)){
  528. return _st(exceptionBlock)._value_(exception);
  529. } else {
  530. return _st(exception)._signal();
  531. };
  532. }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,1)})}));
  533. return self}, function($ctx1) {$ctx1.fill(self,"evaluate:on:do:",{aBlock:aBlock,anErrorClass:anErrorClass,exceptionBlock:exceptionBlock},globals.Environment)})},
  534. args: ["aBlock", "anErrorClass", "exceptionBlock"],
  535. source: "evaluate: aBlock on: anErrorClass do: exceptionBlock\x0a\x09\x22Evaluate a block and catch exceptions happening on the environment stack\x22\x0a\x09\x0a\x09self try: aBlock catch: [ :exception | \x0a\x09\x09(exception isKindOf: (self classNamed: anErrorClass name))\x0a\x09\x09\x09ifTrue: [ exceptionBlock value: exception ]\x0a \x09\x09\x09ifFalse: [ exception signal ] ]",
  536. messageSends: ["try:catch:", "ifTrue:ifFalse:", "isKindOf:", "classNamed:", "name", "value:", "signal"],
  537. referencedClasses: []
  538. }),
  539. globals.Environment);
  540. smalltalk.addMethod(
  541. smalltalk.method({
  542. selector: "inspect:",
  543. protocol: 'actions',
  544. fn: function (anObject){
  545. var self=this;
  546. function $Inspector(){return globals.Inspector||(typeof Inspector=="undefined"?nil:Inspector)}
  547. return smalltalk.withContext(function($ctx1) {
  548. _st($Inspector())._inspect_(anObject);
  549. return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Environment)})},
  550. args: ["anObject"],
  551. source: "inspect: anObject\x0a\x09Inspector inspect: anObject",
  552. messageSends: ["inspect:"],
  553. referencedClasses: ["Inspector"]
  554. }),
  555. globals.Environment);
  556. smalltalk.addMethod(
  557. smalltalk.method({
  558. selector: "moveClass:toPackage:",
  559. protocol: 'actions',
  560. fn: function (aClass,aPackageName){
  561. var self=this;
  562. var package_;
  563. function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
  564. return smalltalk.withContext(function($ctx1) {
  565. var $1,$2;
  566. package_=_st($Package())._named_(aPackageName);
  567. $1=package_;
  568. if(($receiver = $1) == nil || $receiver == null){
  569. self._error_("Invalid package name");
  570. } else {
  571. $1;
  572. };
  573. $2=_st(package_).__eq_eq(_st(aClass)._package());
  574. if(smalltalk.assert($2)){
  575. return self;
  576. };
  577. _st(aClass)._package_(package_);
  578. return self}, function($ctx1) {$ctx1.fill(self,"moveClass:toPackage:",{aClass:aClass,aPackageName:aPackageName,package_:package_},globals.Environment)})},
  579. args: ["aClass", "aPackageName"],
  580. source: "moveClass: aClass toPackage: aPackageName\x0a\x09| package |\x0a\x09\x0a\x09package := Package named: aPackageName.\x0a\x09package ifNil: [ self error: 'Invalid package name' ].\x0a\x09package == aClass package ifTrue: [ ^ self ].\x0a\x09\x0a\x09aClass package: package",
  581. messageSends: ["named:", "ifNil:", "error:", "ifTrue:", "==", "package", "package:"],
  582. referencedClasses: ["Package"]
  583. }),
  584. globals.Environment);
  585. smalltalk.addMethod(
  586. smalltalk.method({
  587. selector: "moveMethod:toClass:",
  588. protocol: 'actions',
  589. fn: function (aMethod,aClassName){
  590. var self=this;
  591. var destinationClass;
  592. return smalltalk.withContext(function($ctx1) {
  593. var $2,$3,$1;
  594. destinationClass=self._classNamed_(aClassName);
  595. $2=destinationClass;
  596. $3=_st(aMethod)._methodClass();
  597. $ctx1.sendIdx["methodClass"]=1;
  598. $1=_st($2).__eq_eq($3);
  599. if(smalltalk.assert($1)){
  600. return self;
  601. };
  602. _st(destinationClass)._compile_protocol_(_st(aMethod)._source(),_st(aMethod)._protocol());
  603. _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
  604. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},globals.Environment)})},
  605. args: ["aMethod", "aClassName"],
  606. source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := self classNamed: aClassName.\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass \x0a\x09\x09compile: aMethod source\x0a\x09\x09protocol: aMethod protocol.\x0a\x09aMethod methodClass \x0a\x09\x09removeCompiledMethod: aMethod",
  607. messageSends: ["classNamed:", "ifTrue:", "==", "methodClass", "compile:protocol:", "source", "protocol", "removeCompiledMethod:"],
  608. referencedClasses: []
  609. }),
  610. globals.Environment);
  611. smalltalk.addMethod(
  612. smalltalk.method({
  613. selector: "moveMethod:toProtocol:",
  614. protocol: 'actions',
  615. fn: function (aMethod,aProtocol){
  616. var self=this;
  617. return smalltalk.withContext(function($ctx1) {
  618. _st(aMethod)._protocol_(aProtocol);
  619. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toProtocol:",{aMethod:aMethod,aProtocol:aProtocol},globals.Environment)})},
  620. args: ["aMethod", "aProtocol"],
  621. source: "moveMethod: aMethod toProtocol: aProtocol\x0a\x09aMethod protocol: aProtocol",
  622. messageSends: ["protocol:"],
  623. referencedClasses: []
  624. }),
  625. globals.Environment);
  626. smalltalk.addMethod(
  627. smalltalk.method({
  628. selector: "packages",
  629. protocol: 'accessing',
  630. fn: function (){
  631. var self=this;
  632. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  633. return smalltalk.withContext(function($ctx1) {
  634. var $1;
  635. $1=_st($Smalltalk())._packages();
  636. return $1;
  637. }, function($ctx1) {$ctx1.fill(self,"packages",{},globals.Environment)})},
  638. args: [],
  639. source: "packages\x0a\x09^ Smalltalk packages",
  640. messageSends: ["packages"],
  641. referencedClasses: ["Smalltalk"]
  642. }),
  643. globals.Environment);
  644. smalltalk.addMethod(
  645. smalltalk.method({
  646. selector: "registerErrorHandler:",
  647. protocol: 'services',
  648. fn: function (anErrorHandler){
  649. var self=this;
  650. function $ErrorHandler(){return globals.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
  651. return smalltalk.withContext(function($ctx1) {
  652. _st($ErrorHandler())._register_(anErrorHandler);
  653. return self}, function($ctx1) {$ctx1.fill(self,"registerErrorHandler:",{anErrorHandler:anErrorHandler},globals.Environment)})},
  654. args: ["anErrorHandler"],
  655. source: "registerErrorHandler: anErrorHandler\x0a\x09ErrorHandler register: anErrorHandler",
  656. messageSends: ["register:"],
  657. referencedClasses: ["ErrorHandler"]
  658. }),
  659. globals.Environment);
  660. smalltalk.addMethod(
  661. smalltalk.method({
  662. selector: "registerInspector:",
  663. protocol: 'services',
  664. fn: function (anInspector){
  665. var self=this;
  666. function $Inspector(){return globals.Inspector||(typeof Inspector=="undefined"?nil:Inspector)}
  667. return smalltalk.withContext(function($ctx1) {
  668. _st($Inspector())._register_(anInspector);
  669. return self}, function($ctx1) {$ctx1.fill(self,"registerInspector:",{anInspector:anInspector},globals.Environment)})},
  670. args: ["anInspector"],
  671. source: "registerInspector: anInspector\x0a\x09Inspector register: anInspector",
  672. messageSends: ["register:"],
  673. referencedClasses: ["Inspector"]
  674. }),
  675. globals.Environment);
  676. smalltalk.addMethod(
  677. smalltalk.method({
  678. selector: "registerProgressHandler:",
  679. protocol: 'services',
  680. fn: function (aProgressHandler){
  681. var self=this;
  682. function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  683. return smalltalk.withContext(function($ctx1) {
  684. _st($ProgressHandler())._register_(aProgressHandler);
  685. return self}, function($ctx1) {$ctx1.fill(self,"registerProgressHandler:",{aProgressHandler:aProgressHandler},globals.Environment)})},
  686. args: ["aProgressHandler"],
  687. source: "registerProgressHandler: aProgressHandler\x0a\x09ProgressHandler register: aProgressHandler",
  688. messageSends: ["register:"],
  689. referencedClasses: ["ProgressHandler"]
  690. }),
  691. globals.Environment);
  692. smalltalk.addMethod(
  693. smalltalk.method({
  694. selector: "registerTranscript:",
  695. protocol: 'services',
  696. fn: function (aTranscript){
  697. var self=this;
  698. function $Transcript(){return globals.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  699. return smalltalk.withContext(function($ctx1) {
  700. _st($Transcript())._register_(aTranscript);
  701. return self}, function($ctx1) {$ctx1.fill(self,"registerTranscript:",{aTranscript:aTranscript},globals.Environment)})},
  702. args: ["aTranscript"],
  703. source: "registerTranscript: aTranscript\x0a\x09Transcript register: aTranscript",
  704. messageSends: ["register:"],
  705. referencedClasses: ["Transcript"]
  706. }),
  707. globals.Environment);
  708. smalltalk.addMethod(
  709. smalltalk.method({
  710. selector: "removeClass:",
  711. protocol: 'actions',
  712. fn: function (aClass){
  713. var self=this;
  714. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  715. return smalltalk.withContext(function($ctx1) {
  716. _st($Smalltalk())._removeClass_(aClass);
  717. return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},globals.Environment)})},
  718. args: ["aClass"],
  719. source: "removeClass: aClass\x0a\x09Smalltalk removeClass: aClass",
  720. messageSends: ["removeClass:"],
  721. referencedClasses: ["Smalltalk"]
  722. }),
  723. globals.Environment);
  724. smalltalk.addMethod(
  725. smalltalk.method({
  726. selector: "removeMethod:",
  727. protocol: 'actions',
  728. fn: function (aMethod){
  729. var self=this;
  730. return smalltalk.withContext(function($ctx1) {
  731. _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
  732. return self}, function($ctx1) {$ctx1.fill(self,"removeMethod:",{aMethod:aMethod},globals.Environment)})},
  733. args: ["aMethod"],
  734. source: "removeMethod: aMethod\x0a\x09aMethod methodClass removeCompiledMethod: aMethod",
  735. messageSends: ["removeCompiledMethod:", "methodClass"],
  736. referencedClasses: []
  737. }),
  738. globals.Environment);
  739. smalltalk.addMethod(
  740. smalltalk.method({
  741. selector: "removeProtocol:from:",
  742. protocol: 'actions',
  743. fn: function (aString,aClass){
  744. var self=this;
  745. return smalltalk.withContext(function($ctx1) {
  746. _st(_st(aClass)._methodsInProtocol_(aString))._do_((function(each){
  747. return smalltalk.withContext(function($ctx2) {
  748. return _st(aClass)._removeCompiledMethod_(each);
  749. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  750. return self}, function($ctx1) {$ctx1.fill(self,"removeProtocol:from:",{aString:aString,aClass:aClass},globals.Environment)})},
  751. args: ["aString", "aClass"],
  752. source: "removeProtocol: aString from: aClass\x0a\x09(aClass methodsInProtocol: aString)\x0a\x09\x09do: [ :each | aClass removeCompiledMethod: each ]",
  753. messageSends: ["do:", "methodsInProtocol:", "removeCompiledMethod:"],
  754. referencedClasses: []
  755. }),
  756. globals.Environment);
  757. smalltalk.addMethod(
  758. smalltalk.method({
  759. selector: "renameClass:to:",
  760. protocol: 'actions',
  761. fn: function (aClass,aClassName){
  762. var self=this;
  763. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  764. function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  765. return smalltalk.withContext(function($ctx1) {
  766. var $1,$2;
  767. $1=_st(_st($Smalltalk())._globals())._at_(aClassName);
  768. if(($receiver = $1) == nil || $receiver == null){
  769. $1;
  770. } else {
  771. $2=_st("A class named ".__comma(aClassName)).__comma(" already exists");
  772. $ctx1.sendIdx[","]=1;
  773. self._error_($2);
  774. };
  775. _st(_st($ClassBuilder())._new())._renameClass_to_(aClass,aClassName);
  776. return self}, function($ctx1) {$ctx1.fill(self,"renameClass:to:",{aClass:aClass,aClassName:aClassName},globals.Environment)})},
  777. args: ["aClass", "aClassName"],
  778. source: "renameClass: aClass to: aClassName\x0a\x09(Smalltalk globals at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new renameClass: aClass to: aClassName",
  779. messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "renameClass:to:", "new"],
  780. referencedClasses: ["Smalltalk", "ClassBuilder"]
  781. }),
  782. globals.Environment);
  783. smalltalk.addMethod(
  784. smalltalk.method({
  785. selector: "renameProtocol:to:in:",
  786. protocol: 'actions',
  787. fn: function (aString,anotherString,aClass){
  788. var self=this;
  789. return smalltalk.withContext(function($ctx1) {
  790. _st(_st(aClass)._methodsInProtocol_(aString))._do_((function(each){
  791. return smalltalk.withContext(function($ctx2) {
  792. return _st(each)._protocol_(anotherString);
  793. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  794. return self}, function($ctx1) {$ctx1.fill(self,"renameProtocol:to:in:",{aString:aString,anotherString:anotherString,aClass:aClass},globals.Environment)})},
  795. args: ["aString", "anotherString", "aClass"],
  796. source: "renameProtocol: aString to: anotherString in: aClass\x0a\x09(aClass methodsInProtocol: aString)\x0a\x09\x09do: [ :each | each protocol: anotherString ]",
  797. messageSends: ["do:", "methodsInProtocol:", "protocol:"],
  798. referencedClasses: []
  799. }),
  800. globals.Environment);
  801. smalltalk.addMethod(
  802. smalltalk.method({
  803. selector: "setClassCommentOf:to:",
  804. protocol: 'actions',
  805. fn: function (aClass,aString){
  806. var self=this;
  807. return smalltalk.withContext(function($ctx1) {
  808. _st(aClass)._comment_(aString);
  809. return self}, function($ctx1) {$ctx1.fill(self,"setClassCommentOf:to:",{aClass:aClass,aString:aString},globals.Environment)})},
  810. args: ["aClass", "aString"],
  811. source: "setClassCommentOf: aClass to: aString\x0a\x09aClass comment: aString",
  812. messageSends: ["comment:"],
  813. referencedClasses: []
  814. }),
  815. globals.Environment);
  816. smalltalk.addMethod(
  817. smalltalk.method({
  818. selector: "systemAnnouncer",
  819. protocol: 'accessing',
  820. fn: function (){
  821. var self=this;
  822. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  823. return smalltalk.withContext(function($ctx1) {
  824. var $1;
  825. $1=_st(_st(_st($Smalltalk())._globals())._at_("SystemAnnouncer"))._current();
  826. return $1;
  827. }, function($ctx1) {$ctx1.fill(self,"systemAnnouncer",{},globals.Environment)})},
  828. args: [],
  829. source: "systemAnnouncer\x0a\x09^ (Smalltalk globals at: #SystemAnnouncer) current",
  830. messageSends: ["current", "at:", "globals"],
  831. referencedClasses: ["Smalltalk"]
  832. }),
  833. globals.Environment);
  834. smalltalk.addClass('JSObjectProxy', globals.ProtoObject, ['jsObject'], 'Kernel-Infrastructure');
  835. globals.JSObjectProxy.comment="I handle sending messages to JavaScript objects, making JavaScript object accessing from Amber fully transparent.\x0aMy instances make intensive use of `#doesNotUnderstand:`.\x0a\x0aMy instances are automatically created by Amber whenever a message is sent to a JavaScript object.\x0a\x0a## Usage examples\x0a\x0aJSObjectProxy objects are instanciated by Amber when a Smalltalk message is sent to a JavaScript object.\x0a\x0a\x09window alert: 'hello world'.\x0a\x09window inspect.\x0a\x09(window jQuery: 'body') append: 'hello world'\x0a\x0aAmber 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`.";
  836. smalltalk.addMethod(
  837. smalltalk.method({
  838. selector: "=",
  839. protocol: 'comparing',
  840. fn: function (anObject){
  841. var self=this;
  842. return smalltalk.withContext(function($ctx1) {
  843. var $2,$1,$3;
  844. $2=_st(anObject)._class();
  845. $ctx1.sendIdx["class"]=1;
  846. $1=_st($2).__eq_eq(self._class());
  847. if(! smalltalk.assert($1)){
  848. return false;
  849. };
  850. $3=self._compareJSObjectWith_(_st(anObject)._jsObject());
  851. return $3;
  852. }, function($ctx1) {$ctx1.fill(self,"=",{anObject:anObject},globals.JSObjectProxy)})},
  853. args: ["anObject"],
  854. source: "= anObject\x0a\x09anObject class == self class ifFalse: [ ^ false ].\x0a\x09^ self compareJSObjectWith: anObject jsObject",
  855. messageSends: ["ifFalse:", "==", "class", "compareJSObjectWith:", "jsObject"],
  856. referencedClasses: []
  857. }),
  858. globals.JSObjectProxy);
  859. smalltalk.addMethod(
  860. smalltalk.method({
  861. selector: "addObjectVariablesTo:",
  862. protocol: 'proxy',
  863. fn: function (aDictionary){
  864. var self=this;
  865. for(var i in self['@jsObject']) {
  866. aDictionary._at_put_(i, self['@jsObject'][i]);
  867. }
  868. ;
  869. return self},
  870. args: ["aDictionary"],
  871. source: "addObjectVariablesTo: aDictionary\x0a\x09<\x0a\x09\x09for(var i in self['@jsObject']) {\x0a\x09\x09\x09aDictionary._at_put_(i, self['@jsObject'][i]);\x0a\x09\x09}\x0a\x09>",
  872. messageSends: [],
  873. referencedClasses: []
  874. }),
  875. globals.JSObjectProxy);
  876. smalltalk.addMethod(
  877. smalltalk.method({
  878. selector: "asJSON",
  879. protocol: 'enumerating',
  880. fn: function (){
  881. var self=this;
  882. var $1;
  883. $1=self["@jsObject"];
  884. return $1;
  885. },
  886. args: [],
  887. source: "asJSON\x0a\x09\x22Answers the receiver in a stringyfy-friendly fashion\x22\x0a\x0a\x09^ jsObject",
  888. messageSends: [],
  889. referencedClasses: []
  890. }),
  891. globals.JSObjectProxy);
  892. smalltalk.addMethod(
  893. smalltalk.method({
  894. selector: "at:",
  895. protocol: 'accessing',
  896. fn: function (aString){
  897. var self=this;
  898. return self['@jsObject'][aString];
  899. return self},
  900. args: ["aString"],
  901. source: "at: aString\x0a\x09<return self['@jsObject'][aString]>",
  902. messageSends: [],
  903. referencedClasses: []
  904. }),
  905. globals.JSObjectProxy);
  906. smalltalk.addMethod(
  907. smalltalk.method({
  908. selector: "at:ifAbsent:",
  909. protocol: 'accessing',
  910. fn: function (aString,aBlock){
  911. var self=this;
  912. var obj = self['@jsObject'];
  913. return aString in obj ? obj[aString] : aBlock._value();
  914. ;
  915. return self},
  916. args: ["aString", "aBlock"],
  917. source: "at: aString ifAbsent: aBlock\x0a\x09\x22return the aString property or evaluate aBlock if the property is not defined on the object\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? obj[aString] : aBlock._value();\x0a\x09>",
  918. messageSends: [],
  919. referencedClasses: []
  920. }),
  921. globals.JSObjectProxy);
  922. smalltalk.addMethod(
  923. smalltalk.method({
  924. selector: "at:ifPresent:",
  925. protocol: 'accessing',
  926. fn: function (aString,aBlock){
  927. var self=this;
  928. var obj = self['@jsObject'];
  929. return aString in obj ? aBlock._value_(obj[aString]) : nil;
  930. ;
  931. return self},
  932. args: ["aString", "aBlock"],
  933. source: "at: aString ifPresent: aBlock\x0a\x09\x22return the evaluation of aBlock with the value if the property is defined or return nil\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? aBlock._value_(obj[aString]) : nil;\x0a\x09>",
  934. messageSends: [],
  935. referencedClasses: []
  936. }),
  937. globals.JSObjectProxy);
  938. smalltalk.addMethod(
  939. smalltalk.method({
  940. selector: "at:ifPresent:ifAbsent:",
  941. protocol: 'accessing',
  942. fn: function (aString,aBlock,anotherBlock){
  943. var self=this;
  944. var obj = self['@jsObject'];
  945. return aString in obj ? aBlock._value_(obj[aString]) : anotherBlock._value();
  946. ;
  947. return self},
  948. args: ["aString", "aBlock", "anotherBlock"],
  949. source: "at: aString ifPresent: aBlock ifAbsent: anotherBlock\x0a\x09\x22return the evaluation of aBlock with the value if the property is defined\x0a\x09or return value of anotherBlock\x22\x0a\x09<\x0a\x09\x09var obj = self['@jsObject'];\x0a\x09\x09return aString in obj ? aBlock._value_(obj[aString]) : anotherBlock._value();\x0a\x09>",
  950. messageSends: [],
  951. referencedClasses: []
  952. }),
  953. globals.JSObjectProxy);
  954. smalltalk.addMethod(
  955. smalltalk.method({
  956. selector: "at:put:",
  957. protocol: 'accessing',
  958. fn: function (aString,anObject){
  959. var self=this;
  960. return self['@jsObject'][aString] = anObject;
  961. return self},
  962. args: ["aString", "anObject"],
  963. source: "at: aString put: anObject\x0a\x09<return self['@jsObject'][aString] = anObject>",
  964. messageSends: [],
  965. referencedClasses: []
  966. }),
  967. globals.JSObjectProxy);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "compareJSObjectWith:",
  971. protocol: 'private',
  972. fn: function (aJSObject){
  973. var self=this;
  974. return self["@jsObject"] === aJSObject;
  975. return self},
  976. args: ["aJSObject"],
  977. source: " compareJSObjectWith: aJSObject\x0a \x09<return self[\x22@jsObject\x22] === aJSObject>",
  978. messageSends: [],
  979. referencedClasses: []
  980. }),
  981. globals.JSObjectProxy);
  982. smalltalk.addMethod(
  983. smalltalk.method({
  984. selector: "doesNotUnderstand:",
  985. protocol: 'proxy',
  986. fn: function (aMessage){
  987. var self=this;
  988. return smalltalk.withContext(function($ctx1) {
  989. var $2,$1;
  990. $2=self._lookupProperty_(_st(_st(aMessage)._selector())._asJavaScriptSelector());
  991. if(($receiver = $2) == nil || $receiver == null){
  992. $1=globals.JSObjectProxy.superclass.fn.prototype._doesNotUnderstand_.apply(_st(self), [aMessage]);
  993. } else {
  994. var jsSelector;
  995. jsSelector=$receiver;
  996. $1=self._forwardMessage_withArguments_(jsSelector,_st(aMessage)._arguments());
  997. };
  998. return $1;
  999. }, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},globals.JSObjectProxy)})},
  1000. args: ["aMessage"],
  1001. source: "doesNotUnderstand: aMessage\x0a\x09^ (self lookupProperty: aMessage selector asJavaScriptSelector)\x0a\x09\x09ifNil: [ super doesNotUnderstand: aMessage ]\x0a\x09\x09ifNotNil: [ :jsSelector | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09forwardMessage: jsSelector \x0a\x09\x09\x09\x09withArguments: aMessage arguments ]",
  1002. messageSends: ["ifNil:ifNotNil:", "lookupProperty:", "asJavaScriptSelector", "selector", "doesNotUnderstand:", "forwardMessage:withArguments:", "arguments"],
  1003. referencedClasses: []
  1004. }),
  1005. globals.JSObjectProxy);
  1006. smalltalk.addMethod(
  1007. smalltalk.method({
  1008. selector: "forwardMessage:withArguments:",
  1009. protocol: 'proxy',
  1010. fn: function (aString,anArray){
  1011. var self=this;
  1012. return smalltalk.send(self._jsObject(), aString, anArray);
  1013. ;
  1014. return self},
  1015. args: ["aString", "anArray"],
  1016. source: "forwardMessage: aString withArguments: anArray\x0a\x09<\x0a\x09\x09return smalltalk.send(self._jsObject(), aString, anArray);\x0a\x09>",
  1017. messageSends: [],
  1018. referencedClasses: []
  1019. }),
  1020. globals.JSObjectProxy);
  1021. smalltalk.addMethod(
  1022. smalltalk.method({
  1023. selector: "inspectOn:",
  1024. protocol: 'proxy',
  1025. fn: function (anInspector){
  1026. var self=this;
  1027. var variables;
  1028. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1029. return smalltalk.withContext(function($ctx1) {
  1030. variables=_st($Dictionary())._new();
  1031. _st(variables)._at_put_("#self",self._jsObject());
  1032. _st(anInspector)._setLabel_(self._printString());
  1033. self._addObjectVariablesTo_(variables);
  1034. _st(anInspector)._setVariables_(variables);
  1035. return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector,variables:variables},globals.JSObjectProxy)})},
  1036. args: ["anInspector"],
  1037. source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self jsObject.\x0a\x09anInspector setLabel: self printString.\x0a\x09self addObjectVariablesTo: variables.\x0a\x09anInspector setVariables: variables",
  1038. messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "addObjectVariablesTo:", "setVariables:"],
  1039. referencedClasses: ["Dictionary"]
  1040. }),
  1041. globals.JSObjectProxy);
  1042. smalltalk.addMethod(
  1043. smalltalk.method({
  1044. selector: "jsObject",
  1045. protocol: 'accessing',
  1046. fn: function (){
  1047. var self=this;
  1048. var $1;
  1049. $1=self["@jsObject"];
  1050. return $1;
  1051. },
  1052. args: [],
  1053. source: "jsObject\x0a\x09^ jsObject",
  1054. messageSends: [],
  1055. referencedClasses: []
  1056. }),
  1057. globals.JSObjectProxy);
  1058. smalltalk.addMethod(
  1059. smalltalk.method({
  1060. selector: "jsObject:",
  1061. protocol: 'accessing',
  1062. fn: function (aJSObject){
  1063. var self=this;
  1064. self["@jsObject"]=aJSObject;
  1065. return self},
  1066. args: ["aJSObject"],
  1067. source: "jsObject: aJSObject\x0a\x09jsObject := aJSObject",
  1068. messageSends: [],
  1069. referencedClasses: []
  1070. }),
  1071. globals.JSObjectProxy);
  1072. smalltalk.addMethod(
  1073. smalltalk.method({
  1074. selector: "keysAndValuesDo:",
  1075. protocol: 'enumerating',
  1076. fn: function (aBlock){
  1077. var self=this;
  1078. var o = self['@jsObject'];
  1079. for(var i in o) {
  1080. aBlock._value_value_(i, o[i]);
  1081. }
  1082. ;
  1083. return self},
  1084. args: ["aBlock"],
  1085. source: "keysAndValuesDo: aBlock\x0a\x09<\x0a\x09\x09var o = self['@jsObject'];\x0a\x09\x09for(var i in o) {\x0a\x09\x09\x09aBlock._value_value_(i, o[i]);\x0a\x09\x09}\x0a\x09>",
  1086. messageSends: [],
  1087. referencedClasses: []
  1088. }),
  1089. globals.JSObjectProxy);
  1090. smalltalk.addMethod(
  1091. smalltalk.method({
  1092. selector: "lookupProperty:",
  1093. protocol: 'accessing',
  1094. fn: function (aString){
  1095. var self=this;
  1096. return aString in self._jsObject() ? aString : nil;
  1097. return self},
  1098. args: ["aString"],
  1099. source: "lookupProperty: aString\x0a\x09\x22Looks up a property in JS object.\x0a\x09Answer the property if it is present, or nil if it is not present.\x22\x0a\x09\x0a\x09<return aString in self._jsObject() ? aString : nil>",
  1100. messageSends: [],
  1101. referencedClasses: []
  1102. }),
  1103. globals.JSObjectProxy);
  1104. smalltalk.addMethod(
  1105. smalltalk.method({
  1106. selector: "printOn:",
  1107. protocol: 'printing',
  1108. fn: function (aStream){
  1109. var self=this;
  1110. return smalltalk.withContext(function($ctx1) {
  1111. _st(aStream)._nextPutAll_(self._printString());
  1112. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.JSObjectProxy)})},
  1113. args: ["aStream"],
  1114. source: "printOn: aStream\x0a\x09aStream nextPutAll: self printString",
  1115. messageSends: ["nextPutAll:", "printString"],
  1116. referencedClasses: []
  1117. }),
  1118. globals.JSObjectProxy);
  1119. smalltalk.addMethod(
  1120. smalltalk.method({
  1121. selector: "printString",
  1122. protocol: 'printing',
  1123. fn: function (){
  1124. var self=this;
  1125. var js = self['@jsObject'];
  1126. return js.toString
  1127. ? js.toString()
  1128. : Object.prototype.toString.call(js)
  1129. ;
  1130. return self},
  1131. args: [],
  1132. source: "printString\x0a\x09<\x0a\x09\x09var js = self['@jsObject'];\x0a\x09\x09return js.toString\x0a\x09\x09\x09? js.toString()\x0a\x09\x09\x09: Object.prototype.toString.call(js)\x0a\x09>",
  1133. messageSends: [],
  1134. referencedClasses: []
  1135. }),
  1136. globals.JSObjectProxy);
  1137. smalltalk.addMethod(
  1138. smalltalk.method({
  1139. selector: "on:",
  1140. protocol: 'instance creation',
  1141. fn: function (aJSObject){
  1142. var self=this;
  1143. return smalltalk.withContext(function($ctx1) {
  1144. var $2,$3,$1;
  1145. $2=self._new();
  1146. _st($2)._jsObject_(aJSObject);
  1147. $3=_st($2)._yourself();
  1148. $1=$3;
  1149. return $1;
  1150. }, function($ctx1) {$ctx1.fill(self,"on:",{aJSObject:aJSObject},globals.JSObjectProxy.klass)})},
  1151. args: ["aJSObject"],
  1152. source: "on: aJSObject\x0a\x09^ self new\x0a\x09\x09jsObject: aJSObject;\x0a\x09\x09yourself",
  1153. messageSends: ["jsObject:", "new", "yourself"],
  1154. referencedClasses: []
  1155. }),
  1156. globals.JSObjectProxy.klass);
  1157. smalltalk.addClass('NullProgressHandler', globals.Object, [], 'Kernel-Infrastructure');
  1158. globals.NullProgressHandler.comment="I am the default progress handler. I do not display any progress, and simply iterate over the collection.";
  1159. smalltalk.addMethod(
  1160. smalltalk.method({
  1161. selector: "do:on:displaying:",
  1162. protocol: 'progress handling',
  1163. fn: function (aBlock,aCollection,aString){
  1164. var self=this;
  1165. return smalltalk.withContext(function($ctx1) {
  1166. _st(aCollection)._do_(aBlock);
  1167. return self}, function($ctx1) {$ctx1.fill(self,"do:on:displaying:",{aBlock:aBlock,aCollection:aCollection,aString:aString},globals.NullProgressHandler)})},
  1168. args: ["aBlock", "aCollection", "aString"],
  1169. source: "do: aBlock on: aCollection displaying: aString\x0a\x09aCollection do: aBlock",
  1170. messageSends: ["do:"],
  1171. referencedClasses: []
  1172. }),
  1173. globals.NullProgressHandler);
  1174. globals.NullProgressHandler.klass.iVarNames = ['current'];
  1175. smalltalk.addMethod(
  1176. smalltalk.method({
  1177. selector: "initialize",
  1178. protocol: 'initialization',
  1179. fn: function (){
  1180. var self=this;
  1181. function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  1182. return smalltalk.withContext(function($ctx1) {
  1183. _st($ProgressHandler())._registerIfNone_(self._new());
  1184. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.NullProgressHandler.klass)})},
  1185. args: [],
  1186. source: "initialize\x0a\x09ProgressHandler registerIfNone: self new",
  1187. messageSends: ["registerIfNone:", "new"],
  1188. referencedClasses: ["ProgressHandler"]
  1189. }),
  1190. globals.NullProgressHandler.klass);
  1191. smalltalk.addClass('Organizer', globals.Object, [], 'Kernel-Infrastructure');
  1192. globals.Organizer.comment="I represent categorization information. \x0a\x0a## API\x0a\x0aUse `#addElement:` and `#removeElement:` to manipulate instances.";
  1193. smalltalk.addMethod(
  1194. smalltalk.method({
  1195. selector: "addElement:",
  1196. protocol: 'accessing',
  1197. fn: function (anObject){
  1198. var self=this;
  1199. self.elements.addElement(anObject);
  1200. return self},
  1201. args: ["anObject"],
  1202. source: "addElement: anObject\x0a\x09<self.elements.addElement(anObject)>",
  1203. messageSends: [],
  1204. referencedClasses: []
  1205. }),
  1206. globals.Organizer);
  1207. smalltalk.addMethod(
  1208. smalltalk.method({
  1209. selector: "elements",
  1210. protocol: 'accessing',
  1211. fn: function (){
  1212. var self=this;
  1213. return smalltalk.withContext(function($ctx1) {
  1214. var $1;
  1215. $1=_st(self._basicAt_("elements"))._copy();
  1216. return $1;
  1217. }, function($ctx1) {$ctx1.fill(self,"elements",{},globals.Organizer)})},
  1218. args: [],
  1219. source: "elements\x0a\x09^ (self basicAt: 'elements') copy",
  1220. messageSends: ["copy", "basicAt:"],
  1221. referencedClasses: []
  1222. }),
  1223. globals.Organizer);
  1224. smalltalk.addMethod(
  1225. smalltalk.method({
  1226. selector: "removeElement:",
  1227. protocol: 'accessing',
  1228. fn: function (anObject){
  1229. var self=this;
  1230. self.elements.removeElement(anObject);
  1231. return self},
  1232. args: ["anObject"],
  1233. source: "removeElement: anObject\x0a\x09<self.elements.removeElement(anObject)>",
  1234. messageSends: [],
  1235. referencedClasses: []
  1236. }),
  1237. globals.Organizer);
  1238. smalltalk.addClass('ClassOrganizer', globals.Organizer, [], 'Kernel-Infrastructure');
  1239. globals.ClassOrganizer.comment="I am an organizer specific to classes. I hold method categorization information for classes.";
  1240. smalltalk.addMethod(
  1241. smalltalk.method({
  1242. selector: "addElement:",
  1243. protocol: 'accessing',
  1244. fn: function (aString){
  1245. var self=this;
  1246. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  1247. function $ProtocolAdded(){return globals.ProtocolAdded||(typeof ProtocolAdded=="undefined"?nil:ProtocolAdded)}
  1248. return smalltalk.withContext(function($ctx1) {
  1249. var $1,$2;
  1250. globals.ClassOrganizer.superclass.fn.prototype._addElement_.apply(_st(self), [aString]);
  1251. $1=_st($ProtocolAdded())._new();
  1252. _st($1)._protocol_(aString);
  1253. _st($1)._theClass_(self._theClass());
  1254. $2=_st($1)._yourself();
  1255. _st(_st($SystemAnnouncer())._current())._announce_($2);
  1256. return self}, function($ctx1) {$ctx1.fill(self,"addElement:",{aString:aString},globals.ClassOrganizer)})},
  1257. args: ["aString"],
  1258. source: "addElement: aString\x0a\x09super addElement: aString.\x0a\x0a\x09SystemAnnouncer current announce: (ProtocolAdded new\x0a\x09\x09protocol: aString;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09yourself)",
  1259. messageSends: ["addElement:", "announce:", "current", "protocol:", "new", "theClass:", "theClass", "yourself"],
  1260. referencedClasses: ["SystemAnnouncer", "ProtocolAdded"]
  1261. }),
  1262. globals.ClassOrganizer);
  1263. smalltalk.addMethod(
  1264. smalltalk.method({
  1265. selector: "removeElement:",
  1266. protocol: 'accessing',
  1267. fn: function (aString){
  1268. var self=this;
  1269. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  1270. function $ProtocolRemoved(){return globals.ProtocolRemoved||(typeof ProtocolRemoved=="undefined"?nil:ProtocolRemoved)}
  1271. return smalltalk.withContext(function($ctx1) {
  1272. var $1,$2;
  1273. globals.ClassOrganizer.superclass.fn.prototype._removeElement_.apply(_st(self), [aString]);
  1274. $1=_st($ProtocolRemoved())._new();
  1275. _st($1)._protocol_(aString);
  1276. _st($1)._theClass_(self._theClass());
  1277. $2=_st($1)._yourself();
  1278. _st(_st($SystemAnnouncer())._current())._announce_($2);
  1279. return self}, function($ctx1) {$ctx1.fill(self,"removeElement:",{aString:aString},globals.ClassOrganizer)})},
  1280. args: ["aString"],
  1281. source: "removeElement: aString\x0a\x09super removeElement: aString.\x0a\x0a\x09SystemAnnouncer current announce: (ProtocolRemoved new\x0a\x09\x09protocol: aString;\x0a\x09\x09theClass: self theClass;\x0a\x09\x09yourself)",
  1282. messageSends: ["removeElement:", "announce:", "current", "protocol:", "new", "theClass:", "theClass", "yourself"],
  1283. referencedClasses: ["SystemAnnouncer", "ProtocolRemoved"]
  1284. }),
  1285. globals.ClassOrganizer);
  1286. smalltalk.addMethod(
  1287. smalltalk.method({
  1288. selector: "theClass",
  1289. protocol: 'accessing',
  1290. fn: function (){
  1291. var self=this;
  1292. return self.theClass ;
  1293. return self},
  1294. args: [],
  1295. source: "theClass\x0a\x09< return self.theClass >",
  1296. messageSends: [],
  1297. referencedClasses: []
  1298. }),
  1299. globals.ClassOrganizer);
  1300. smalltalk.addClass('PackageOrganizer', globals.Organizer, [], 'Kernel-Infrastructure');
  1301. globals.PackageOrganizer.comment="I am an organizer specific to packages. I hold classes categorization information.";
  1302. smalltalk.addClass('Package', globals.Object, ['transport'], 'Kernel-Infrastructure');
  1303. globals.Package.comment="I am 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\x0aEach package has a name and can be queried for its classes, but it will then resort to a reverse scan of all classes to find them.\x0a\x0a## API\x0a\x0aPackages are manipulated through \x22Smalltalk current\x22, like for example finding one based on a name or with `Package class >> #name` directly:\x0a\x0a Smalltalk current packageAt: 'Kernel'\x0a Package 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 can 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.\x0a\x0aYou can fetch a package from the server:\x0a\x0a\x09Package load: 'Additional-Examples'";
  1304. smalltalk.addMethod(
  1305. smalltalk.method({
  1306. selector: "basicTransport",
  1307. protocol: 'accessing',
  1308. fn: function (){
  1309. var self=this;
  1310. return self.transport;
  1311. return self},
  1312. args: [],
  1313. source: "basicTransport\x0a\x09\x22Answer the transport literal JavaScript object as setup in the JavaScript file, if any\x22\x0a\x09\x0a\x09<return self.transport>",
  1314. messageSends: [],
  1315. referencedClasses: []
  1316. }),
  1317. globals.Package);
  1318. smalltalk.addMethod(
  1319. smalltalk.method({
  1320. selector: "classes",
  1321. protocol: 'classes',
  1322. fn: function (){
  1323. var self=this;
  1324. return smalltalk.withContext(function($ctx1) {
  1325. var $1;
  1326. $1=_st(self._organization())._elements();
  1327. return $1;
  1328. }, function($ctx1) {$ctx1.fill(self,"classes",{},globals.Package)})},
  1329. args: [],
  1330. source: "classes\x0a\x09^ self organization elements",
  1331. messageSends: ["elements", "organization"],
  1332. referencedClasses: []
  1333. }),
  1334. globals.Package);
  1335. smalltalk.addMethod(
  1336. smalltalk.method({
  1337. selector: "definition",
  1338. protocol: 'accessing',
  1339. fn: function (){
  1340. var self=this;
  1341. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  1342. return smalltalk.withContext(function($ctx1) {
  1343. var $2,$4,$5,$3,$7,$6,$8,$9,$1;
  1344. $1=_st($String())._streamContents_((function(stream){
  1345. return smalltalk.withContext(function($ctx2) {
  1346. $2=_st(self._class())._name();
  1347. $ctx2.sendIdx["name"]=1;
  1348. _st(stream)._nextPutAll_($2);
  1349. $ctx2.sendIdx["nextPutAll:"]=1;
  1350. $4=_st($String())._lf();
  1351. $ctx2.sendIdx["lf"]=1;
  1352. $5=_st($String())._tab();
  1353. $ctx2.sendIdx["tab"]=1;
  1354. $3=_st($4).__comma($5);
  1355. $ctx2.sendIdx[","]=1;
  1356. _st(stream)._nextPutAll_($3);
  1357. $ctx2.sendIdx["nextPutAll:"]=2;
  1358. _st(stream)._nextPutAll_(" named: ");
  1359. $ctx2.sendIdx["nextPutAll:"]=3;
  1360. $7="'".__comma(self._name());
  1361. $ctx2.sendIdx[","]=3;
  1362. $6=_st($7).__comma("'");
  1363. $ctx2.sendIdx[","]=2;
  1364. _st(stream)._nextPutAll_($6);
  1365. $ctx2.sendIdx["nextPutAll:"]=4;
  1366. $8=_st(_st($String())._lf()).__comma(_st($String())._tab());
  1367. $ctx2.sendIdx[","]=4;
  1368. _st(stream)._nextPutAll_($8);
  1369. $ctx2.sendIdx["nextPutAll:"]=5;
  1370. _st(stream)._nextPutAll_(" transport: (");
  1371. $ctx2.sendIdx["nextPutAll:"]=6;
  1372. $9=_st(stream)._nextPutAll_(_st(_st(self._transport())._definition()).__comma(")"));
  1373. return $9;
  1374. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
  1375. return $1;
  1376. }, function($ctx1) {$ctx1.fill(self,"definition",{},globals.Package)})},
  1377. args: [],
  1378. source: "definition\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09stream \x0a\x09\x09\x09nextPutAll: self class name;\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: ' named: ';\x0a\x09\x09\x09nextPutAll: '''', self name, '''';\x0a\x09\x09\x09nextPutAll: String lf, String tab;\x0a\x09\x09\x09nextPutAll: ' transport: (';\x0a\x09\x09\x09nextPutAll: self transport definition, ')' ]",
  1379. messageSends: ["streamContents:", "nextPutAll:", "name", "class", ",", "lf", "tab", "definition", "transport"],
  1380. referencedClasses: ["String"]
  1381. }),
  1382. globals.Package);
  1383. smalltalk.addMethod(
  1384. smalltalk.method({
  1385. selector: "isPackage",
  1386. protocol: 'testing',
  1387. fn: function (){
  1388. var self=this;
  1389. return true;
  1390. },
  1391. args: [],
  1392. source: "isPackage\x0a\x09^ true",
  1393. messageSends: [],
  1394. referencedClasses: []
  1395. }),
  1396. globals.Package);
  1397. smalltalk.addMethod(
  1398. smalltalk.method({
  1399. selector: "loadDependencies",
  1400. protocol: 'dependencies',
  1401. fn: function (){
  1402. var self=this;
  1403. var classes,packages;
  1404. return smalltalk.withContext(function($ctx1) {
  1405. var $2,$3,$1;
  1406. classes=self._loadDependencyClasses();
  1407. $2=_st(_st(classes)._collect_((function(each){
  1408. return smalltalk.withContext(function($ctx2) {
  1409. return _st(each)._package();
  1410. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._asSet();
  1411. _st($2)._remove_ifAbsent_(self,(function(){
  1412. return smalltalk.withContext(function($ctx2) {
  1413. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1414. $3=_st($2)._yourself();
  1415. $1=$3;
  1416. return $1;
  1417. }, function($ctx1) {$ctx1.fill(self,"loadDependencies",{classes:classes,packages:packages},globals.Package)})},
  1418. args: [],
  1419. source: "loadDependencies\x0a\x09\x22Returns list of packages that need to be loaded\x0a\x09before loading this package.\x22\x0a\x09\x0a\x09| classes packages |\x0a\x09classes := self loadDependencyClasses.\x0a\x09^ (classes collect: [ :each | each package ]) asSet\x0a\x09\x09remove: self ifAbsent: [];\x0a\x09\x09yourself",
  1420. messageSends: ["loadDependencyClasses", "remove:ifAbsent:", "asSet", "collect:", "package", "yourself"],
  1421. referencedClasses: []
  1422. }),
  1423. globals.Package);
  1424. smalltalk.addMethod(
  1425. smalltalk.method({
  1426. selector: "loadDependencyClasses",
  1427. protocol: 'dependencies',
  1428. fn: function (){
  1429. var self=this;
  1430. var starCategoryName;
  1431. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1432. return smalltalk.withContext(function($ctx1) {
  1433. var $4,$3,$2,$6,$5,$7,$1;
  1434. starCategoryName="*".__comma(self._name());
  1435. $ctx1.sendIdx[","]=1;
  1436. $4=self._classes();
  1437. $ctx1.sendIdx["classes"]=1;
  1438. $3=_st($4)._collect_((function(each){
  1439. return smalltalk.withContext(function($ctx2) {
  1440. return _st(each)._superclass();
  1441. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1442. $2=_st($3)._asSet();
  1443. _st($2)._remove_ifAbsent_(nil,(function(){
  1444. return smalltalk.withContext(function($ctx2) {
  1445. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1446. _st($2)._addAll_(_st(_st($Smalltalk())._classes())._select_((function(each){
  1447. return smalltalk.withContext(function($ctx2) {
  1448. $6=_st(each)._protocols();
  1449. $ctx2.sendIdx["protocols"]=1;
  1450. $5=_st($6).__comma(_st(_st(each)._class())._protocols());
  1451. return _st($5)._includes_(starCategoryName);
  1452. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)})})));
  1453. $7=_st($2)._yourself();
  1454. $1=$7;
  1455. return $1;
  1456. }, function($ctx1) {$ctx1.fill(self,"loadDependencyClasses",{starCategoryName:starCategoryName},globals.Package)})},
  1457. args: [],
  1458. source: "loadDependencyClasses\x0a\x09\x22Returns classes needed at the time of loading a package.\x0a\x09These are all that are used to subclass\x0a\x09and to define an extension method\x22\x0a\x09\x0a\x09| starCategoryName |\x0a\x09starCategoryName := '*', self name.\x0a\x09^ (self classes collect: [ :each | each superclass ]) asSet\x0a\x09\x09remove: nil ifAbsent: [];\x0a\x09\x09addAll: (Smalltalk classes select: [ :each | each protocols, each class protocols includes: starCategoryName ]);\x0a\x09\x09yourself",
  1459. messageSends: [",", "name", "remove:ifAbsent:", "asSet", "collect:", "classes", "superclass", "addAll:", "select:", "includes:", "protocols", "class", "yourself"],
  1460. referencedClasses: ["Smalltalk"]
  1461. }),
  1462. globals.Package);
  1463. smalltalk.addMethod(
  1464. smalltalk.method({
  1465. selector: "name",
  1466. protocol: 'accessing',
  1467. fn: function (){
  1468. var self=this;
  1469. return self.pkgName;
  1470. return self},
  1471. args: [],
  1472. source: "name\x0a\x09<return self.pkgName>",
  1473. messageSends: [],
  1474. referencedClasses: []
  1475. }),
  1476. globals.Package);
  1477. smalltalk.addMethod(
  1478. smalltalk.method({
  1479. selector: "name:",
  1480. protocol: 'accessing',
  1481. fn: function (aString){
  1482. var self=this;
  1483. self.pkgName = aString;
  1484. return self},
  1485. args: ["aString"],
  1486. source: "name: aString\x0a\x09<self.pkgName = aString>",
  1487. messageSends: [],
  1488. referencedClasses: []
  1489. }),
  1490. globals.Package);
  1491. smalltalk.addMethod(
  1492. smalltalk.method({
  1493. selector: "organization",
  1494. protocol: 'accessing',
  1495. fn: function (){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx1) {
  1498. var $1;
  1499. $1=self._basicAt_("organization");
  1500. return $1;
  1501. }, function($ctx1) {$ctx1.fill(self,"organization",{},globals.Package)})},
  1502. args: [],
  1503. source: "organization\x0a\x09^ self basicAt: 'organization'",
  1504. messageSends: ["basicAt:"],
  1505. referencedClasses: []
  1506. }),
  1507. globals.Package);
  1508. smalltalk.addMethod(
  1509. smalltalk.method({
  1510. selector: "printOn:",
  1511. protocol: 'printing',
  1512. fn: function (aStream){
  1513. var self=this;
  1514. return smalltalk.withContext(function($ctx1) {
  1515. var $1;
  1516. globals.Package.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1517. _st(aStream)._nextPutAll_(" (");
  1518. $ctx1.sendIdx["nextPutAll:"]=1;
  1519. _st(aStream)._nextPutAll_(self._name());
  1520. $ctx1.sendIdx["nextPutAll:"]=2;
  1521. $1=_st(aStream)._nextPutAll_(")");
  1522. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Package)})},
  1523. args: ["aStream"],
  1524. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: ' (';\x0a\x09\x09nextPutAll: self name;\x0a\x09\x09nextPutAll: ')'",
  1525. messageSends: ["printOn:", "nextPutAll:", "name"],
  1526. referencedClasses: []
  1527. }),
  1528. globals.Package);
  1529. smalltalk.addMethod(
  1530. smalltalk.method({
  1531. selector: "setupClasses",
  1532. protocol: 'classes',
  1533. fn: function (){
  1534. var self=this;
  1535. function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  1536. return smalltalk.withContext(function($ctx1) {
  1537. var $1,$2;
  1538. $1=self._classes();
  1539. _st($1)._do_((function(each){
  1540. return smalltalk.withContext(function($ctx2) {
  1541. return _st(_st($ClassBuilder())._new())._setupClass_(each);
  1542. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1543. $ctx1.sendIdx["do:"]=1;
  1544. $2=_st($1)._do_((function(each){
  1545. return smalltalk.withContext(function($ctx2) {
  1546. return _st(each)._initialize();
  1547. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1548. return self}, function($ctx1) {$ctx1.fill(self,"setupClasses",{},globals.Package)})},
  1549. args: [],
  1550. source: "setupClasses\x0a\x09self classes\x0a\x09\x09do: [ :each | ClassBuilder new setupClass: each ];\x0a\x09\x09do: [ :each | each initialize ]",
  1551. messageSends: ["do:", "classes", "setupClass:", "new", "initialize"],
  1552. referencedClasses: ["ClassBuilder"]
  1553. }),
  1554. globals.Package);
  1555. smalltalk.addMethod(
  1556. smalltalk.method({
  1557. selector: "sortedClasses",
  1558. protocol: 'classes',
  1559. fn: function (){
  1560. var self=this;
  1561. return smalltalk.withContext(function($ctx1) {
  1562. var $1;
  1563. $1=_st(self._class())._sortedClasses_(self._classes());
  1564. return $1;
  1565. }, function($ctx1) {$ctx1.fill(self,"sortedClasses",{},globals.Package)})},
  1566. args: [],
  1567. 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",
  1568. messageSends: ["sortedClasses:", "class", "classes"],
  1569. referencedClasses: []
  1570. }),
  1571. globals.Package);
  1572. smalltalk.addMethod(
  1573. smalltalk.method({
  1574. selector: "transport",
  1575. protocol: 'accessing',
  1576. fn: function (){
  1577. var self=this;
  1578. function $PackageTransport(){return globals.PackageTransport||(typeof PackageTransport=="undefined"?nil:PackageTransport)}
  1579. return smalltalk.withContext(function($ctx1) {
  1580. var $2,$3,$4,$1;
  1581. $2=self["@transport"];
  1582. if(($receiver = $2) == nil || $receiver == null){
  1583. $3=_st($PackageTransport())._fromJson_(self._basicTransport());
  1584. _st($3)._package_(self);
  1585. $4=_st($3)._yourself();
  1586. self["@transport"]=$4;
  1587. $1=self["@transport"];
  1588. } else {
  1589. $1=$2;
  1590. };
  1591. return $1;
  1592. }, function($ctx1) {$ctx1.fill(self,"transport",{},globals.Package)})},
  1593. args: [],
  1594. source: "transport\x0a\x09^ transport ifNil: [ \x0a\x09\x09transport := (PackageTransport fromJson: self basicTransport)\x0a\x09\x09\x09package: self;\x0a\x09\x09\x09yourself ]",
  1595. messageSends: ["ifNil:", "package:", "fromJson:", "basicTransport", "yourself"],
  1596. referencedClasses: ["PackageTransport"]
  1597. }),
  1598. globals.Package);
  1599. smalltalk.addMethod(
  1600. smalltalk.method({
  1601. selector: "transport:",
  1602. protocol: 'accessing',
  1603. fn: function (aPackageTransport){
  1604. var self=this;
  1605. return smalltalk.withContext(function($ctx1) {
  1606. self["@transport"]=aPackageTransport;
  1607. _st(aPackageTransport)._package_(self);
  1608. return self}, function($ctx1) {$ctx1.fill(self,"transport:",{aPackageTransport:aPackageTransport},globals.Package)})},
  1609. args: ["aPackageTransport"],
  1610. source: "transport: aPackageTransport\x0a\x09transport := aPackageTransport.\x0a\x09aPackageTransport package: self",
  1611. messageSends: ["package:"],
  1612. referencedClasses: []
  1613. }),
  1614. globals.Package);
  1615. globals.Package.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
  1616. smalltalk.addMethod(
  1617. smalltalk.method({
  1618. selector: "named:",
  1619. protocol: 'accessing',
  1620. fn: function (aPackageName){
  1621. var self=this;
  1622. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1623. return smalltalk.withContext(function($ctx1) {
  1624. var $1;
  1625. $1=_st($Smalltalk())._packageAt_ifAbsent_(aPackageName,(function(){
  1626. return smalltalk.withContext(function($ctx2) {
  1627. return _st($Smalltalk())._createPackage_(aPackageName);
  1628. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1629. return $1;
  1630. }, function($ctx1) {$ctx1.fill(self,"named:",{aPackageName:aPackageName},globals.Package.klass)})},
  1631. args: ["aPackageName"],
  1632. source: "named: aPackageName\x0a\x09^ Smalltalk \x0a\x09\x09packageAt: aPackageName\x0a\x09\x09ifAbsent: [ \x0a\x09\x09\x09Smalltalk createPackage: aPackageName ]",
  1633. messageSends: ["packageAt:ifAbsent:", "createPackage:"],
  1634. referencedClasses: ["Smalltalk"]
  1635. }),
  1636. globals.Package.klass);
  1637. smalltalk.addMethod(
  1638. smalltalk.method({
  1639. selector: "named:ifAbsent:",
  1640. protocol: 'accessing',
  1641. fn: function (aPackageName,aBlock){
  1642. var self=this;
  1643. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1644. return smalltalk.withContext(function($ctx1) {
  1645. var $1;
  1646. $1=_st($Smalltalk())._packageAt_ifAbsent_(aPackageName,aBlock);
  1647. return $1;
  1648. }, function($ctx1) {$ctx1.fill(self,"named:ifAbsent:",{aPackageName:aPackageName,aBlock:aBlock},globals.Package.klass)})},
  1649. args: ["aPackageName", "aBlock"],
  1650. source: "named: aPackageName ifAbsent: aBlock\x0a\x09^ Smalltalk packageAt: aPackageName ifAbsent: aBlock",
  1651. messageSends: ["packageAt:ifAbsent:"],
  1652. referencedClasses: ["Smalltalk"]
  1653. }),
  1654. globals.Package.klass);
  1655. smalltalk.addMethod(
  1656. smalltalk.method({
  1657. selector: "named:transport:",
  1658. protocol: 'accessing',
  1659. fn: function (aPackageName,aTransport){
  1660. var self=this;
  1661. var package_;
  1662. return smalltalk.withContext(function($ctx1) {
  1663. var $1;
  1664. package_=self._named_(aPackageName);
  1665. _st(package_)._transport_(aTransport);
  1666. $1=package_;
  1667. return $1;
  1668. }, function($ctx1) {$ctx1.fill(self,"named:transport:",{aPackageName:aPackageName,aTransport:aTransport,package_:package_},globals.Package.klass)})},
  1669. args: ["aPackageName", "aTransport"],
  1670. source: "named: aPackageName transport: aTransport\x0a\x09| package |\x0a\x09\x0a\x09package := self named: aPackageName.\x0a\x09package transport: aTransport.\x0a\x09\x0a\x09^ package",
  1671. messageSends: ["named:", "transport:"],
  1672. referencedClasses: []
  1673. }),
  1674. globals.Package.klass);
  1675. smalltalk.addMethod(
  1676. smalltalk.method({
  1677. selector: "sortedClasses:",
  1678. protocol: 'sorting',
  1679. fn: function (classes){
  1680. var self=this;
  1681. var children,others,nodes,expandedClasses;
  1682. function $ClassSorterNode(){return globals.ClassSorterNode||(typeof ClassSorterNode=="undefined"?nil:ClassSorterNode)}
  1683. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  1684. return smalltalk.withContext(function($ctx1) {
  1685. var $1,$3,$2,$4;
  1686. children=[];
  1687. others=[];
  1688. _st(classes)._do_((function(each){
  1689. return smalltalk.withContext(function($ctx2) {
  1690. $1=_st(classes)._includes_(_st(each)._superclass());
  1691. if(smalltalk.assert($1)){
  1692. return _st(others)._add_(each);
  1693. } else {
  1694. return _st(children)._add_(each);
  1695. $ctx2.sendIdx["add:"]=1;
  1696. };
  1697. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1698. $ctx1.sendIdx["do:"]=1;
  1699. nodes=_st(children)._collect_((function(each){
  1700. return smalltalk.withContext(function($ctx2) {
  1701. return _st($ClassSorterNode())._on_classes_level_(each,others,(0));
  1702. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
  1703. nodes=_st(nodes)._sorted_((function(a,b){
  1704. return smalltalk.withContext(function($ctx2) {
  1705. $3=_st(a)._theClass();
  1706. $ctx2.sendIdx["theClass"]=1;
  1707. $2=_st($3)._name();
  1708. $ctx2.sendIdx["name"]=1;
  1709. return _st($2).__lt_eq(_st(_st(b)._theClass())._name());
  1710. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,5)})}));
  1711. expandedClasses=_st($Array())._new();
  1712. _st(nodes)._do_((function(aNode){
  1713. return smalltalk.withContext(function($ctx2) {
  1714. return _st(aNode)._traverseClassesWith_(expandedClasses);
  1715. }, function($ctx2) {$ctx2.fillBlock({aNode:aNode},$ctx1,6)})}));
  1716. $4=expandedClasses;
  1717. return $4;
  1718. }, function($ctx1) {$ctx1.fill(self,"sortedClasses:",{classes:classes,children:children,others:others,nodes:nodes,expandedClasses:expandedClasses},globals.Package.klass)})},
  1719. args: ["classes"],
  1720. 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",
  1721. messageSends: ["do:", "ifFalse:ifTrue:", "includes:", "superclass", "add:", "collect:", "on:classes:level:", "sorted:", "<=", "name", "theClass", "new", "traverseClassesWith:"],
  1722. referencedClasses: ["ClassSorterNode", "Array"]
  1723. }),
  1724. globals.Package.klass);
  1725. smalltalk.addClass('PlatformInterface', globals.Object, [], 'Kernel-Infrastructure');
  1726. globals.PlatformInterface.comment="I am single entry point to UI and environment interface.\x0aMy `initialize` tries several options (for now, browser environment only) to set myself up.\x0a\x0a## API\x0a\x0a PlatformInterface alert: 'Hey, there is a problem'.\x0a PlatformInterface confirm: 'Affirmative?'.\x0a PlatformInterface prompt: 'Your name:'.\x0a\x0a PlatformInterface ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.";
  1727. globals.PlatformInterface.klass.iVarNames = ['worker'];
  1728. smalltalk.addMethod(
  1729. smalltalk.method({
  1730. selector: "ajax:",
  1731. protocol: 'actions',
  1732. fn: function (anObject){
  1733. var self=this;
  1734. return smalltalk.withContext(function($ctx1) {
  1735. var $2,$1;
  1736. $2=self["@worker"];
  1737. if(($receiver = $2) == nil || $receiver == null){
  1738. $1=self._error_("ajax: not available");
  1739. } else {
  1740. $1=_st(self["@worker"])._ajax_(anObject);
  1741. };
  1742. return $1;
  1743. }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},globals.PlatformInterface.klass)})},
  1744. args: ["anObject"],
  1745. source: "ajax: anObject\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker ajax: anObject ]\x0a\x09\x09ifNil: [ self error: 'ajax: not available' ]",
  1746. messageSends: ["ifNotNil:ifNil:", "ajax:", "error:"],
  1747. referencedClasses: []
  1748. }),
  1749. globals.PlatformInterface.klass);
  1750. smalltalk.addMethod(
  1751. smalltalk.method({
  1752. selector: "alert:",
  1753. protocol: 'actions',
  1754. fn: function (aString){
  1755. var self=this;
  1756. return smalltalk.withContext(function($ctx1) {
  1757. var $2,$1;
  1758. $2=self["@worker"];
  1759. if(($receiver = $2) == nil || $receiver == null){
  1760. $1=self._error_("alert: not available");
  1761. } else {
  1762. $1=_st(self["@worker"])._alert_(aString);
  1763. };
  1764. return $1;
  1765. }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},globals.PlatformInterface.klass)})},
  1766. args: ["aString"],
  1767. source: "alert: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker alert: aString ]\x0a\x09\x09ifNil: [ self error: 'alert: not available' ]",
  1768. messageSends: ["ifNotNil:ifNil:", "alert:", "error:"],
  1769. referencedClasses: []
  1770. }),
  1771. globals.PlatformInterface.klass);
  1772. smalltalk.addMethod(
  1773. smalltalk.method({
  1774. selector: "confirm:",
  1775. protocol: 'actions',
  1776. fn: function (aString){
  1777. var self=this;
  1778. return smalltalk.withContext(function($ctx1) {
  1779. var $2,$1;
  1780. $2=self["@worker"];
  1781. if(($receiver = $2) == nil || $receiver == null){
  1782. $1=self._error_("confirm: not available");
  1783. } else {
  1784. $1=_st(self["@worker"])._confirm_(aString);
  1785. };
  1786. return $1;
  1787. }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},globals.PlatformInterface.klass)})},
  1788. args: ["aString"],
  1789. source: "confirm: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker confirm: aString ]\x0a\x09\x09ifNil: [ self error: 'confirm: not available' ]",
  1790. messageSends: ["ifNotNil:ifNil:", "confirm:", "error:"],
  1791. referencedClasses: []
  1792. }),
  1793. globals.PlatformInterface.klass);
  1794. smalltalk.addMethod(
  1795. smalltalk.method({
  1796. selector: "existsGlobal:",
  1797. protocol: 'actions',
  1798. fn: function (aString){
  1799. var self=this;
  1800. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1801. return smalltalk.withContext(function($ctx1) {
  1802. var $1;
  1803. $1=_st(_st($PlatformInterface())._globals())._at_ifPresent_ifAbsent_(aString,(function(){
  1804. return smalltalk.withContext(function($ctx2) {
  1805. return true;
  1806. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  1807. return smalltalk.withContext(function($ctx2) {
  1808. return false;
  1809. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1810. return $1;
  1811. }, function($ctx1) {$ctx1.fill(self,"existsGlobal:",{aString:aString},globals.PlatformInterface.klass)})},
  1812. args: ["aString"],
  1813. source: "existsGlobal: aString\x0a\x09^ PlatformInterface globals \x0a\x09\x09at: aString \x0a\x09\x09ifPresent: [ true ] \x0a\x09\x09ifAbsent: [ false ]",
  1814. messageSends: ["at:ifPresent:ifAbsent:", "globals"],
  1815. referencedClasses: ["PlatformInterface"]
  1816. }),
  1817. globals.PlatformInterface.klass);
  1818. smalltalk.addMethod(
  1819. smalltalk.method({
  1820. selector: "globals",
  1821. protocol: 'accessing',
  1822. fn: function (){
  1823. var self=this;
  1824. return (new Function('return this'))();;
  1825. return self},
  1826. args: [],
  1827. source: "globals\x0a\x09<return (new Function('return this'))();>",
  1828. messageSends: [],
  1829. referencedClasses: []
  1830. }),
  1831. globals.PlatformInterface.klass);
  1832. smalltalk.addMethod(
  1833. smalltalk.method({
  1834. selector: "initialize",
  1835. protocol: 'initialization',
  1836. fn: function (){
  1837. var self=this;
  1838. var candidate;
  1839. function $BrowserInterface(){return globals.BrowserInterface||(typeof BrowserInterface=="undefined"?nil:BrowserInterface)}
  1840. return smalltalk.withContext(function($ctx1) {
  1841. var $1;
  1842. globals.PlatformInterface.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1843. if(($receiver = $BrowserInterface()) == nil || $receiver == null){
  1844. $BrowserInterface();
  1845. } else {
  1846. candidate=_st($BrowserInterface())._new();
  1847. candidate;
  1848. $1=_st(candidate)._isAvailable();
  1849. if(smalltalk.assert($1)){
  1850. self._setWorker_(candidate);
  1851. return self;
  1852. };
  1853. };
  1854. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{candidate:candidate},globals.PlatformInterface.klass)})},
  1855. args: [],
  1856. source: "initialize\x0a\x09| candidate |\x0a\x09\x0a\x09super initialize.\x0a\x09\x0a\x09BrowserInterface ifNotNil: [\x0a\x09\x09candidate := BrowserInterface new.\x0a\x09\x09candidate isAvailable ifTrue: [ self setWorker: candidate. ^ self ]\x0a\x09]",
  1857. messageSends: ["initialize", "ifNotNil:", "new", "ifTrue:", "isAvailable", "setWorker:"],
  1858. referencedClasses: ["BrowserInterface"]
  1859. }),
  1860. globals.PlatformInterface.klass);
  1861. smalltalk.addMethod(
  1862. smalltalk.method({
  1863. selector: "prompt:",
  1864. protocol: 'actions',
  1865. fn: function (aString){
  1866. var self=this;
  1867. return smalltalk.withContext(function($ctx1) {
  1868. var $2,$1;
  1869. $2=self["@worker"];
  1870. if(($receiver = $2) == nil || $receiver == null){
  1871. $1=self._error_("prompt: not available");
  1872. } else {
  1873. $1=_st(self["@worker"])._prompt_(aString);
  1874. };
  1875. return $1;
  1876. }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},globals.PlatformInterface.klass)})},
  1877. args: ["aString"],
  1878. source: "prompt: aString\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker prompt: aString ]\x0a\x09\x09ifNil: [ self error: 'prompt: not available' ]",
  1879. messageSends: ["ifNotNil:ifNil:", "prompt:", "error:"],
  1880. referencedClasses: []
  1881. }),
  1882. globals.PlatformInterface.klass);
  1883. smalltalk.addMethod(
  1884. smalltalk.method({
  1885. selector: "setWorker:",
  1886. protocol: 'accessing',
  1887. fn: function (anObject){
  1888. var self=this;
  1889. self["@worker"]=anObject;
  1890. return self},
  1891. args: ["anObject"],
  1892. source: "setWorker: anObject\x0a\x09worker := anObject",
  1893. messageSends: [],
  1894. referencedClasses: []
  1895. }),
  1896. globals.PlatformInterface.klass);
  1897. smalltalk.addClass('Service', globals.Object, [], 'Kernel-Infrastructure');
  1898. globals.Service.comment="I implement the basic behavior for class registration to a service.\x0a\x0aSee the `Transcript` class for a concrete service.\x0a\x0a## API\x0a\x0aUse class-side methods `#register:` and `#registerIfNone:` to register classes to a specific service.";
  1899. globals.Service.klass.iVarNames = ['current'];
  1900. smalltalk.addMethod(
  1901. smalltalk.method({
  1902. selector: "current",
  1903. protocol: 'accessing',
  1904. fn: function (){
  1905. var self=this;
  1906. var $1;
  1907. $1=self["@current"];
  1908. return $1;
  1909. },
  1910. args: [],
  1911. source: "current\x0a\x09^ current",
  1912. messageSends: [],
  1913. referencedClasses: []
  1914. }),
  1915. globals.Service.klass);
  1916. smalltalk.addMethod(
  1917. smalltalk.method({
  1918. selector: "new",
  1919. protocol: 'instance creation',
  1920. fn: function (){
  1921. var self=this;
  1922. return smalltalk.withContext(function($ctx1) {
  1923. self._shouldNotImplement();
  1924. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.Service.klass)})},
  1925. args: [],
  1926. source: "new\x0a\x09self shouldNotImplement",
  1927. messageSends: ["shouldNotImplement"],
  1928. referencedClasses: []
  1929. }),
  1930. globals.Service.klass);
  1931. smalltalk.addMethod(
  1932. smalltalk.method({
  1933. selector: "register:",
  1934. protocol: 'registration',
  1935. fn: function (anObject){
  1936. var self=this;
  1937. self["@current"]=anObject;
  1938. return self},
  1939. args: ["anObject"],
  1940. source: "register: anObject\x0a\x09current := anObject",
  1941. messageSends: [],
  1942. referencedClasses: []
  1943. }),
  1944. globals.Service.klass);
  1945. smalltalk.addMethod(
  1946. smalltalk.method({
  1947. selector: "registerIfNone:",
  1948. protocol: 'registration',
  1949. fn: function (anObject){
  1950. var self=this;
  1951. return smalltalk.withContext(function($ctx1) {
  1952. var $1;
  1953. $1=self._current();
  1954. if(($receiver = $1) == nil || $receiver == null){
  1955. self._register_(anObject);
  1956. } else {
  1957. $1;
  1958. };
  1959. return self}, function($ctx1) {$ctx1.fill(self,"registerIfNone:",{anObject:anObject},globals.Service.klass)})},
  1960. args: ["anObject"],
  1961. source: "registerIfNone: anObject\x0a\x09self current ifNil: [ self register: anObject ]",
  1962. messageSends: ["ifNil:", "current", "register:"],
  1963. referencedClasses: []
  1964. }),
  1965. globals.Service.klass);
  1966. smalltalk.addClass('ErrorHandler', globals.Service, [], 'Kernel-Infrastructure');
  1967. globals.ErrorHandler.comment="I am the service used to handle Smalltalk errors.\x0aSee `boot.js` `handleError()` function.\x0a\x0aRegistered service instances must implement `#handleError:` to perform an action on the thrown exception.";
  1968. smalltalk.addMethod(
  1969. smalltalk.method({
  1970. selector: "handleError:",
  1971. protocol: 'error handling',
  1972. fn: function (anError){
  1973. var self=this;
  1974. return smalltalk.withContext(function($ctx1) {
  1975. _st(self._current())._handleError_(anError);
  1976. return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.ErrorHandler.klass)})},
  1977. args: ["anError"],
  1978. source: "handleError: anError\x0a\x09self current handleError: anError",
  1979. messageSends: ["handleError:", "current"],
  1980. referencedClasses: []
  1981. }),
  1982. globals.ErrorHandler.klass);
  1983. smalltalk.addClass('Inspector', globals.Service, [], 'Kernel-Infrastructure');
  1984. globals.Inspector.comment="I am the service responsible for inspecting objects.\x0a\x0aThe default inspector object is the transcript.";
  1985. smalltalk.addMethod(
  1986. smalltalk.method({
  1987. selector: "inspect:",
  1988. protocol: 'inspecting',
  1989. fn: function (anObject){
  1990. var self=this;
  1991. return smalltalk.withContext(function($ctx1) {
  1992. var $1;
  1993. $1=_st(self._current())._inspect_(anObject);
  1994. return $1;
  1995. }, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Inspector.klass)})},
  1996. args: ["anObject"],
  1997. source: "inspect: anObject\x0a\x09^ self current inspect: anObject",
  1998. messageSends: ["inspect:", "current"],
  1999. referencedClasses: []
  2000. }),
  2001. globals.Inspector.klass);
  2002. smalltalk.addClass('ProgressHandler', globals.Service, [], 'Kernel-Infrastructure');
  2003. globals.ProgressHandler.comment="I am used to manage progress in collection iterations, see `SequenceableCollection >> #do:displayingProgress:`.\x0a\x0aRegistered instances must implement `#do:on:displaying:`.\x0a\x0aThe default behavior is to simply iterate over the collection, using `NullProgressHandler`.";
  2004. smalltalk.addMethod(
  2005. smalltalk.method({
  2006. selector: "do:on:displaying:",
  2007. protocol: 'progress handling',
  2008. fn: function (aBlock,aCollection,aString){
  2009. var self=this;
  2010. return smalltalk.withContext(function($ctx1) {
  2011. _st(self._current())._do_on_displaying_(aBlock,aCollection,aString);
  2012. return self}, function($ctx1) {$ctx1.fill(self,"do:on:displaying:",{aBlock:aBlock,aCollection:aCollection,aString:aString},globals.ProgressHandler.klass)})},
  2013. args: ["aBlock", "aCollection", "aString"],
  2014. source: "do: aBlock on: aCollection displaying: aString\x0a\x09self current do: aBlock on: aCollection displaying: aString",
  2015. messageSends: ["do:on:displaying:", "current"],
  2016. referencedClasses: []
  2017. }),
  2018. globals.ProgressHandler.klass);
  2019. smalltalk.addClass('Transcript', globals.Service, [], 'Kernel-Infrastructure');
  2020. globals.Transcript.comment="I am a facade for Transcript actions.\x0a\x0aI delegate actions to the currently registered transcript.\x0a\x0a## API\x0a\x0a Transcript \x0a show: 'hello world';\x0a cr;\x0a show: anObject.";
  2021. smalltalk.addMethod(
  2022. smalltalk.method({
  2023. selector: "clear",
  2024. protocol: 'printing',
  2025. fn: function (){
  2026. var self=this;
  2027. return smalltalk.withContext(function($ctx1) {
  2028. _st(self._current())._clear();
  2029. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},globals.Transcript.klass)})},
  2030. args: [],
  2031. source: "clear\x0a\x09self current clear",
  2032. messageSends: ["clear", "current"],
  2033. referencedClasses: []
  2034. }),
  2035. globals.Transcript.klass);
  2036. smalltalk.addMethod(
  2037. smalltalk.method({
  2038. selector: "cr",
  2039. protocol: 'printing',
  2040. fn: function (){
  2041. var self=this;
  2042. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  2043. return smalltalk.withContext(function($ctx1) {
  2044. _st(self._current())._show_(_st($String())._cr());
  2045. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},globals.Transcript.klass)})},
  2046. args: [],
  2047. source: "cr\x0a\x09self current show: String cr",
  2048. messageSends: ["show:", "current", "cr"],
  2049. referencedClasses: ["String"]
  2050. }),
  2051. globals.Transcript.klass);
  2052. smalltalk.addMethod(
  2053. smalltalk.method({
  2054. selector: "inspect:",
  2055. protocol: 'printing',
  2056. fn: function (anObject){
  2057. var self=this;
  2058. return smalltalk.withContext(function($ctx1) {
  2059. self._show_(anObject);
  2060. return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},globals.Transcript.klass)})},
  2061. args: ["anObject"],
  2062. source: "inspect: anObject\x0a\x09self show: anObject",
  2063. messageSends: ["show:"],
  2064. referencedClasses: []
  2065. }),
  2066. globals.Transcript.klass);
  2067. smalltalk.addMethod(
  2068. smalltalk.method({
  2069. selector: "open",
  2070. protocol: 'instance creation',
  2071. fn: function (){
  2072. var self=this;
  2073. return smalltalk.withContext(function($ctx1) {
  2074. _st(self._current())._open();
  2075. return self}, function($ctx1) {$ctx1.fill(self,"open",{},globals.Transcript.klass)})},
  2076. args: [],
  2077. source: "open\x0a\x09self current open",
  2078. messageSends: ["open", "current"],
  2079. referencedClasses: []
  2080. }),
  2081. globals.Transcript.klass);
  2082. smalltalk.addMethod(
  2083. smalltalk.method({
  2084. selector: "show:",
  2085. protocol: 'printing',
  2086. fn: function (anObject){
  2087. var self=this;
  2088. return smalltalk.withContext(function($ctx1) {
  2089. _st(self._current())._show_(anObject);
  2090. return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},globals.Transcript.klass)})},
  2091. args: ["anObject"],
  2092. source: "show: anObject\x0a\x09self current show: anObject",
  2093. messageSends: ["show:", "current"],
  2094. referencedClasses: []
  2095. }),
  2096. globals.Transcript.klass);
  2097. smalltalk.addClass('SmalltalkImage', globals.Object, [], 'Kernel-Infrastructure');
  2098. globals.SmalltalkImage.comment="I represent the Smalltalk system, wrapping\x0aoperations of variable `smalltalk` declared in `js/boot.js`.\x0a\x0a## API\x0a\x0aI have only one instance, accessed with global variable `Smalltalk`.\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 or `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 package or `nil`\x0a\x0a## Parsing\x0a\x0aThe `#parse:` method is used to parse Amber source code.\x0aIt requires the `Compiler` package and the `js/parser.js` parser file in order to work.";
  2099. smalltalk.addMethod(
  2100. smalltalk.method({
  2101. selector: "addGlobalJsVariable:",
  2102. protocol: 'globals',
  2103. fn: function (aString){
  2104. var self=this;
  2105. return smalltalk.withContext(function($ctx1) {
  2106. _st(self._globalJsVariables())._add_(aString);
  2107. return self}, function($ctx1) {$ctx1.fill(self,"addGlobalJsVariable:",{aString:aString},globals.SmalltalkImage)})},
  2108. args: ["aString"],
  2109. source: "addGlobalJsVariable: aString\x0a\x09self globalJsVariables add: aString",
  2110. messageSends: ["add:", "globalJsVariables"],
  2111. referencedClasses: []
  2112. }),
  2113. globals.SmalltalkImage);
  2114. smalltalk.addMethod(
  2115. smalltalk.method({
  2116. selector: "amdRequire",
  2117. protocol: 'accessing amd',
  2118. fn: function (){
  2119. var self=this;
  2120. return smalltalk.withContext(function($ctx1) {
  2121. var $1;
  2122. $1=_st(self._vm())._at_("amdRequire");
  2123. return $1;
  2124. }, function($ctx1) {$ctx1.fill(self,"amdRequire",{},globals.SmalltalkImage)})},
  2125. args: [],
  2126. source: "amdRequire\x0a\x09^ self vm at: 'amdRequire'",
  2127. messageSends: ["at:", "vm"],
  2128. referencedClasses: []
  2129. }),
  2130. globals.SmalltalkImage);
  2131. smalltalk.addMethod(
  2132. smalltalk.method({
  2133. selector: "asSmalltalkException:",
  2134. protocol: 'error handling',
  2135. fn: function (anObject){
  2136. var self=this;
  2137. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  2138. function $JavaScriptException(){return globals.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  2139. return smalltalk.withContext(function($ctx1) {
  2140. var $2,$1;
  2141. $2=_st(self._isSmalltalkObject_(anObject))._and_((function(){
  2142. return smalltalk.withContext(function($ctx2) {
  2143. return _st(anObject)._isKindOf_($Error());
  2144. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2145. if(smalltalk.assert($2)){
  2146. $1=anObject;
  2147. } else {
  2148. $1=_st($JavaScriptException())._on_(anObject);
  2149. };
  2150. return $1;
  2151. }, function($ctx1) {$ctx1.fill(self,"asSmalltalkException:",{anObject:anObject},globals.SmalltalkImage)})},
  2152. args: ["anObject"],
  2153. source: "asSmalltalkException: anObject\x0a\x09\x22A JavaScript exception may be thrown.\x0a\x09We then need to convert it back to a Smalltalk object\x22\x0a\x09\x0a\x09^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])\x0a\x09\x09ifTrue: [ anObject ]\x0a\x09\x09ifFalse: [ JavaScriptException on: anObject ]",
  2154. messageSends: ["ifTrue:ifFalse:", "and:", "isSmalltalkObject:", "isKindOf:", "on:"],
  2155. referencedClasses: ["Error", "JavaScriptException"]
  2156. }),
  2157. globals.SmalltalkImage);
  2158. smalltalk.addMethod(
  2159. smalltalk.method({
  2160. selector: "at:",
  2161. protocol: 'accessing',
  2162. fn: function (aString){
  2163. var self=this;
  2164. return smalltalk.withContext(function($ctx1) {
  2165. var $1;
  2166. self._deprecatedAPI();
  2167. $1=_st(self._globals())._at_(aString);
  2168. return $1;
  2169. }, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},globals.SmalltalkImage)})},
  2170. args: ["aString"],
  2171. source: "at: aString\x0a\x09self deprecatedAPI.\x0a\x09^ self globals at: aString",
  2172. messageSends: ["deprecatedAPI", "at:", "globals"],
  2173. referencedClasses: []
  2174. }),
  2175. globals.SmalltalkImage);
  2176. smalltalk.addMethod(
  2177. smalltalk.method({
  2178. selector: "at:ifAbsent:",
  2179. protocol: 'accessing',
  2180. fn: function (aKey,aBlock){
  2181. var self=this;
  2182. return smalltalk.withContext(function($ctx1) {
  2183. var $2,$1;
  2184. $2=self._includesKey_(aKey);
  2185. if(smalltalk.assert($2)){
  2186. $1=self._at_(aKey);
  2187. } else {
  2188. $1=_st(aBlock)._value();
  2189. };
  2190. return $1;
  2191. }, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aKey:aKey,aBlock:aBlock},globals.SmalltalkImage)})},
  2192. args: ["aKey", "aBlock"],
  2193. source: "at: aKey ifAbsent: aBlock\x0a\x09^ (self includesKey: aKey)\x0a\x09\x09ifTrue: [ self at: aKey ]\x0a\x09\x09ifFalse: [ aBlock value ]",
  2194. messageSends: ["ifTrue:ifFalse:", "includesKey:", "at:", "value"],
  2195. referencedClasses: []
  2196. }),
  2197. globals.SmalltalkImage);
  2198. smalltalk.addMethod(
  2199. smalltalk.method({
  2200. selector: "at:put:",
  2201. protocol: 'accessing',
  2202. fn: function (aString,anObject){
  2203. var self=this;
  2204. return smalltalk.withContext(function($ctx1) {
  2205. var $1;
  2206. self._deprecatedAPI();
  2207. $1=_st(self._globals())._at_put_(aString,anObject);
  2208. return $1;
  2209. }, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},globals.SmalltalkImage)})},
  2210. args: ["aString", "anObject"],
  2211. source: "at: aString put: anObject\x0a\x09self deprecatedAPI.\x0a\x09^ self globals at: aString put: anObject",
  2212. messageSends: ["deprecatedAPI", "at:put:", "globals"],
  2213. referencedClasses: []
  2214. }),
  2215. globals.SmalltalkImage);
  2216. smalltalk.addMethod(
  2217. smalltalk.method({
  2218. selector: "basicCreatePackage:",
  2219. protocol: 'private',
  2220. fn: function (packageName){
  2221. var self=this;
  2222. return smalltalk.addPackage(packageName);
  2223. return self},
  2224. args: ["packageName"],
  2225. source: "basicCreatePackage: packageName\x0a\x09\x22Create and bind a new bare package with given name and return it.\x22\x0a\x09<return smalltalk.addPackage(packageName)>",
  2226. messageSends: [],
  2227. referencedClasses: []
  2228. }),
  2229. globals.SmalltalkImage);
  2230. smalltalk.addMethod(
  2231. smalltalk.method({
  2232. selector: "basicParse:",
  2233. protocol: 'private',
  2234. fn: function (aString){
  2235. var self=this;
  2236. return smalltalk.parser.parse(aString);
  2237. return self},
  2238. args: ["aString"],
  2239. source: "basicParse: aString\x0a\x09<return smalltalk.parser.parse(aString)>",
  2240. messageSends: [],
  2241. referencedClasses: []
  2242. }),
  2243. globals.SmalltalkImage);
  2244. smalltalk.addMethod(
  2245. smalltalk.method({
  2246. selector: "classes",
  2247. protocol: 'classes',
  2248. fn: function (){
  2249. var self=this;
  2250. return smalltalk.classes();
  2251. return self},
  2252. args: [],
  2253. source: "classes\x0a\x09<return smalltalk.classes()>",
  2254. messageSends: [],
  2255. referencedClasses: []
  2256. }),
  2257. globals.SmalltalkImage);
  2258. smalltalk.addMethod(
  2259. smalltalk.method({
  2260. selector: "createPackage:",
  2261. protocol: 'packages',
  2262. fn: function (packageName){
  2263. var self=this;
  2264. var package_,announcement;
  2265. function $PackageAdded(){return globals.PackageAdded||(typeof PackageAdded=="undefined"?nil:PackageAdded)}
  2266. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  2267. return smalltalk.withContext(function($ctx1) {
  2268. var $1,$2,$3;
  2269. package_=self._basicCreatePackage_(packageName);
  2270. $1=_st($PackageAdded())._new();
  2271. _st($1)._package_(package_);
  2272. $2=_st($1)._yourself();
  2273. announcement=$2;
  2274. _st(_st($SystemAnnouncer())._current())._announce_(announcement);
  2275. $3=package_;
  2276. return $3;
  2277. }, function($ctx1) {$ctx1.fill(self,"createPackage:",{packageName:packageName,package_:package_,announcement:announcement},globals.SmalltalkImage)})},
  2278. args: ["packageName"],
  2279. source: "createPackage: packageName\x0a\x09| package announcement |\x0a\x09\x0a\x09package := self basicCreatePackage: packageName.\x0a\x09announcement := PackageAdded new\x0a\x09\x09package: package;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09SystemAnnouncer current announce: announcement.\x0a\x09\x0a\x09^ package",
  2280. messageSends: ["basicCreatePackage:", "package:", "new", "yourself", "announce:", "current"],
  2281. referencedClasses: ["PackageAdded", "SystemAnnouncer"]
  2282. }),
  2283. globals.SmalltalkImage);
  2284. smalltalk.addMethod(
  2285. smalltalk.method({
  2286. selector: "createPackage:properties:",
  2287. protocol: 'private',
  2288. fn: function (packageName,aDict){
  2289. var self=this;
  2290. return smalltalk.withContext(function($ctx1) {
  2291. var $1,$2;
  2292. self._deprecatedAPI();
  2293. $1=_st(aDict)._isEmpty();
  2294. if(! smalltalk.assert($1)){
  2295. self._error_("createPackage:properties: called with nonempty properties");
  2296. };
  2297. $2=self._createPackage_(packageName);
  2298. return $2;
  2299. }, function($ctx1) {$ctx1.fill(self,"createPackage:properties:",{packageName:packageName,aDict:aDict},globals.SmalltalkImage)})},
  2300. args: ["packageName", "aDict"],
  2301. source: "createPackage: packageName properties: aDict\x0a\x09\x22Needed to import .st files: they begin with this call.\x22\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09aDict isEmpty ifFalse: [ self error: 'createPackage:properties: called with nonempty properties' ].\x0a\x09^ self createPackage: packageName",
  2302. messageSends: ["deprecatedAPI", "ifFalse:", "isEmpty", "error:", "createPackage:"],
  2303. referencedClasses: []
  2304. }),
  2305. globals.SmalltalkImage);
  2306. smalltalk.addMethod(
  2307. smalltalk.method({
  2308. selector: "current",
  2309. protocol: 'accessing',
  2310. fn: function (){
  2311. var self=this;
  2312. return smalltalk.withContext(function($ctx1) {
  2313. self._deprecatedAPI();
  2314. return self;
  2315. }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SmalltalkImage)})},
  2316. args: [],
  2317. source: "current\x0a\x09\x22Backward compatibility for Smalltalk current ...\x22\x0a\x09self deprecatedAPI.\x0a\x09^ self",
  2318. messageSends: ["deprecatedAPI"],
  2319. referencedClasses: []
  2320. }),
  2321. globals.SmalltalkImage);
  2322. smalltalk.addMethod(
  2323. smalltalk.method({
  2324. selector: "defaultAmdNamespace",
  2325. protocol: 'accessing amd',
  2326. fn: function (){
  2327. var self=this;
  2328. return smalltalk.withContext(function($ctx1) {
  2329. var $1;
  2330. $1=_st(self._vm())._defaultAmdNamespace();
  2331. return $1;
  2332. }, function($ctx1) {$ctx1.fill(self,"defaultAmdNamespace",{},globals.SmalltalkImage)})},
  2333. args: [],
  2334. source: "defaultAmdNamespace\x0a\x09^ self vm defaultAmdNamespace",
  2335. messageSends: ["defaultAmdNamespace", "vm"],
  2336. referencedClasses: []
  2337. }),
  2338. globals.SmalltalkImage);
  2339. smalltalk.addMethod(
  2340. smalltalk.method({
  2341. selector: "defaultAmdNamespace:",
  2342. protocol: 'accessing amd',
  2343. fn: function (aString){
  2344. var self=this;
  2345. return smalltalk.withContext(function($ctx1) {
  2346. _st(self._vm())._defaultAmdNamespace_(aString);
  2347. return self}, function($ctx1) {$ctx1.fill(self,"defaultAmdNamespace:",{aString:aString},globals.SmalltalkImage)})},
  2348. args: ["aString"],
  2349. source: "defaultAmdNamespace: aString\x0a\x09self vm defaultAmdNamespace: aString",
  2350. messageSends: ["defaultAmdNamespace:", "vm"],
  2351. referencedClasses: []
  2352. }),
  2353. globals.SmalltalkImage);
  2354. smalltalk.addMethod(
  2355. smalltalk.method({
  2356. selector: "deleteClass:",
  2357. protocol: 'private',
  2358. fn: function (aClass){
  2359. var self=this;
  2360. smalltalk.removeClass(aClass);
  2361. return self},
  2362. args: ["aClass"],
  2363. source: "deleteClass: aClass\x0a\x09\x22Deletes a class by deleting its binding only. Use #removeClass instead\x22\x0a\x09\x0a\x09<smalltalk.removeClass(aClass)>",
  2364. messageSends: [],
  2365. referencedClasses: []
  2366. }),
  2367. globals.SmalltalkImage);
  2368. smalltalk.addMethod(
  2369. smalltalk.method({
  2370. selector: "deleteGlobalJsVariable:",
  2371. protocol: 'globals',
  2372. fn: function (aString){
  2373. var self=this;
  2374. return smalltalk.withContext(function($ctx1) {
  2375. _st(self._globalJsVariables())._remove_ifAbsent_(aString,(function(){
  2376. return smalltalk.withContext(function($ctx2) {
  2377. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2378. return self}, function($ctx1) {$ctx1.fill(self,"deleteGlobalJsVariable:",{aString:aString},globals.SmalltalkImage)})},
  2379. args: ["aString"],
  2380. source: "deleteGlobalJsVariable: aString\x0a\x09self globalJsVariables remove: aString ifAbsent:[]",
  2381. messageSends: ["remove:ifAbsent:", "globalJsVariables"],
  2382. referencedClasses: []
  2383. }),
  2384. globals.SmalltalkImage);
  2385. smalltalk.addMethod(
  2386. smalltalk.method({
  2387. selector: "deletePackage:",
  2388. protocol: 'private',
  2389. fn: function (packageName){
  2390. var self=this;
  2391. delete smalltalk.packages[packageName];
  2392. return self},
  2393. args: ["packageName"],
  2394. 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\x09<delete smalltalk.packages[packageName]>",
  2395. messageSends: [],
  2396. referencedClasses: []
  2397. }),
  2398. globals.SmalltalkImage);
  2399. smalltalk.addMethod(
  2400. smalltalk.method({
  2401. selector: "globalJsVariables",
  2402. protocol: 'globals',
  2403. fn: function (){
  2404. var self=this;
  2405. return smalltalk.globalJsVariables;
  2406. return self},
  2407. args: [],
  2408. source: "globalJsVariables\x0a\x09\x22Array of global JavaScript variables\x22\x0a\x09<return smalltalk.globalJsVariables>",
  2409. messageSends: [],
  2410. referencedClasses: []
  2411. }),
  2412. globals.SmalltalkImage);
  2413. smalltalk.addMethod(
  2414. smalltalk.method({
  2415. selector: "globals",
  2416. protocol: 'accessing',
  2417. fn: function (){
  2418. var self=this;
  2419. return globals;
  2420. return self},
  2421. args: [],
  2422. source: "globals\x0a\x09\x22Future compatibility to be able to use Smalltalk globals at: ...\x22\x0a\x09<return globals>",
  2423. messageSends: [],
  2424. referencedClasses: []
  2425. }),
  2426. globals.SmalltalkImage);
  2427. smalltalk.addMethod(
  2428. smalltalk.method({
  2429. selector: "includesKey:",
  2430. protocol: 'accessing',
  2431. fn: function (aKey){
  2432. var self=this;
  2433. return smalltalk.hasOwnProperty(aKey);
  2434. return self},
  2435. args: ["aKey"],
  2436. source: "includesKey: aKey\x0a\x09<return smalltalk.hasOwnProperty(aKey)>",
  2437. messageSends: [],
  2438. referencedClasses: []
  2439. }),
  2440. globals.SmalltalkImage);
  2441. smalltalk.addMethod(
  2442. smalltalk.method({
  2443. selector: "isSmalltalkObject:",
  2444. protocol: 'testing',
  2445. fn: function (anObject){
  2446. var self=this;
  2447. return typeof anObject.klass !== 'undefined';
  2448. return self},
  2449. args: ["anObject"],
  2450. source: "isSmalltalkObject: anObject\x0a\x09\x22Consider anObject a Smalltalk object if it has a 'klass' property.\x0a\x09Note that this may be unaccurate\x22\x0a\x09\x0a\x09<return typeof anObject.klass !== 'undefined'>",
  2451. messageSends: [],
  2452. referencedClasses: []
  2453. }),
  2454. globals.SmalltalkImage);
  2455. smalltalk.addMethod(
  2456. smalltalk.method({
  2457. selector: "packageAt:",
  2458. protocol: 'packages',
  2459. fn: function (packageName){
  2460. var self=this;
  2461. return smalltalk.packages[packageName];
  2462. return self},
  2463. args: ["packageName"],
  2464. source: "packageAt: packageName\x0a\x09<return smalltalk.packages[packageName]>",
  2465. messageSends: [],
  2466. referencedClasses: []
  2467. }),
  2468. globals.SmalltalkImage);
  2469. smalltalk.addMethod(
  2470. smalltalk.method({
  2471. selector: "packageAt:ifAbsent:",
  2472. protocol: 'packages',
  2473. fn: function (packageName,aBlock){
  2474. var self=this;
  2475. return smalltalk.withContext(function($ctx1) {
  2476. var $2,$1;
  2477. $2=self._packageAt_(packageName);
  2478. $1=_st($2)._ifNil_(aBlock);
  2479. return $1;
  2480. }, function($ctx1) {$ctx1.fill(self,"packageAt:ifAbsent:",{packageName:packageName,aBlock:aBlock},globals.SmalltalkImage)})},
  2481. args: ["packageName", "aBlock"],
  2482. source: "packageAt: packageName ifAbsent: aBlock\x0a\x09^ (self packageAt: packageName) ifNil: aBlock",
  2483. messageSends: ["ifNil:", "packageAt:"],
  2484. referencedClasses: []
  2485. }),
  2486. globals.SmalltalkImage);
  2487. smalltalk.addMethod(
  2488. smalltalk.method({
  2489. selector: "packages",
  2490. protocol: 'packages',
  2491. fn: function (){
  2492. var self=this;
  2493. return Object.keys(smalltalk.packages).map(function(k) {
  2494. return smalltalk.packages[k];
  2495. })
  2496. ;
  2497. return self},
  2498. args: [],
  2499. source: "packages\x0a\x09\x22Return all Package instances in the system.\x22\x0a\x0a\x09<\x0a\x09\x09return Object.keys(smalltalk.packages).map(function(k) {\x0a\x09\x09\x09return smalltalk.packages[k];\x0a\x09\x09})\x0a\x09>",
  2500. messageSends: [],
  2501. referencedClasses: []
  2502. }),
  2503. globals.SmalltalkImage);
  2504. smalltalk.addMethod(
  2505. smalltalk.method({
  2506. selector: "parse:",
  2507. protocol: 'accessing',
  2508. fn: function (aString){
  2509. var self=this;
  2510. var result;
  2511. return smalltalk.withContext(function($ctx1) {
  2512. var $2,$3,$1;
  2513. self._try_catch_((function(){
  2514. return smalltalk.withContext(function($ctx2) {
  2515. result=self._basicParse_(aString);
  2516. return result;
  2517. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(ex){
  2518. return smalltalk.withContext(function($ctx2) {
  2519. return _st(self._parseError_parsing_(ex,aString))._signal();
  2520. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
  2521. $2=result;
  2522. _st($2)._source_(aString);
  2523. $3=_st($2)._yourself();
  2524. $1=$3;
  2525. return $1;
  2526. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString,result:result},globals.SmalltalkImage)})},
  2527. args: ["aString"],
  2528. source: "parse: aString\x0a\x09| result |\x0a\x09\x0a\x09self \x0a\x09\x09try: [ result := self basicParse: aString ] \x0a\x09\x09catch: [ :ex | (self parseError: ex parsing: aString) signal ].\x0a\x09\x09\x0a\x09^ result\x0a\x09\x09source: aString;\x0a\x09\x09yourself",
  2529. messageSends: ["try:catch:", "basicParse:", "signal", "parseError:parsing:", "source:", "yourself"],
  2530. referencedClasses: []
  2531. }),
  2532. globals.SmalltalkImage);
  2533. smalltalk.addMethod(
  2534. smalltalk.method({
  2535. selector: "parseError:parsing:",
  2536. protocol: 'error handling',
  2537. fn: function (anException,aString){
  2538. var self=this;
  2539. function $ParseError(){return globals.ParseError||(typeof ParseError=="undefined"?nil:ParseError)}
  2540. return smalltalk.withContext(function($ctx1) {
  2541. var $2,$8,$7,$6,$9,$5,$4,$3,$1;
  2542. $2=_st($ParseError())._new();
  2543. $8=_st(anException)._basicAt_("line");
  2544. $ctx1.sendIdx["basicAt:"]=1;
  2545. $7="Parse error on line ".__comma($8);
  2546. $6=_st($7).__comma(" column ");
  2547. $ctx1.sendIdx[","]=4;
  2548. $9=_st(anException)._basicAt_("column");
  2549. $ctx1.sendIdx["basicAt:"]=2;
  2550. $5=_st($6).__comma($9);
  2551. $ctx1.sendIdx[","]=3;
  2552. $4=_st($5).__comma(" : Unexpected character ");
  2553. $ctx1.sendIdx[","]=2;
  2554. $3=_st($4).__comma(_st(anException)._basicAt_("found"));
  2555. $ctx1.sendIdx[","]=1;
  2556. $1=_st($2)._messageText_($3);
  2557. return $1;
  2558. }, function($ctx1) {$ctx1.fill(self,"parseError:parsing:",{anException:anException,aString:aString},globals.SmalltalkImage)})},
  2559. args: ["anException", "aString"],
  2560. source: "parseError: anException parsing: aString\x0a\x09^ ParseError new messageText: 'Parse error on line ', (anException basicAt: 'line') ,' column ' , (anException basicAt: 'column') ,' : Unexpected character ', (anException basicAt: 'found')",
  2561. messageSends: ["messageText:", "new", ",", "basicAt:"],
  2562. referencedClasses: ["ParseError"]
  2563. }),
  2564. globals.SmalltalkImage);
  2565. smalltalk.addMethod(
  2566. smalltalk.method({
  2567. selector: "pseudoVariableNames",
  2568. protocol: 'accessing',
  2569. fn: function (){
  2570. var self=this;
  2571. var $1;
  2572. $1=["self", "super", "nil", "true", "false", "thisContext"];
  2573. return $1;
  2574. },
  2575. args: [],
  2576. source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')",
  2577. messageSends: [],
  2578. referencedClasses: []
  2579. }),
  2580. globals.SmalltalkImage);
  2581. smalltalk.addMethod(
  2582. smalltalk.method({
  2583. selector: "readJSObject:",
  2584. protocol: 'accessing',
  2585. fn: function (anObject){
  2586. var self=this;
  2587. return smalltalk.readJSObject(anObject);
  2588. return self},
  2589. args: ["anObject"],
  2590. source: "readJSObject: anObject\x0a\x09<return smalltalk.readJSObject(anObject)>",
  2591. messageSends: [],
  2592. referencedClasses: []
  2593. }),
  2594. globals.SmalltalkImage);
  2595. smalltalk.addMethod(
  2596. smalltalk.method({
  2597. selector: "removeClass:",
  2598. protocol: 'classes',
  2599. fn: function (aClass){
  2600. var self=this;
  2601. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  2602. function $ClassRemoved(){return globals.ClassRemoved||(typeof ClassRemoved=="undefined"?nil:ClassRemoved)}
  2603. return smalltalk.withContext(function($ctx1) {
  2604. var $1,$2,$3;
  2605. $1=_st(aClass)._isMetaclass();
  2606. if(smalltalk.assert($1)){
  2607. self._error_(_st(_st(aClass)._asString()).__comma(" is a Metaclass and cannot be removed!"));
  2608. };
  2609. self._deleteClass_(aClass);
  2610. $2=_st($ClassRemoved())._new();
  2611. _st($2)._theClass_(aClass);
  2612. $3=_st($2)._yourself();
  2613. _st(_st($SystemAnnouncer())._current())._announce_($3);
  2614. return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},globals.SmalltalkImage)})},
  2615. args: ["aClass"],
  2616. source: "removeClass: aClass\x0a\x09aClass isMetaclass ifTrue: [ self error: aClass asString, ' is a Metaclass and cannot be removed!' ].\x0a\x09\x0a\x09self deleteClass: aClass.\x0a\x09\x0a\x09SystemAnnouncer current\x0a\x09\x09announce: (ClassRemoved new\x0a\x09\x09\x09theClass: aClass;\x0a\x09\x09\x09yourself)",
  2617. messageSends: ["ifTrue:", "isMetaclass", "error:", ",", "asString", "deleteClass:", "announce:", "current", "theClass:", "new", "yourself"],
  2618. referencedClasses: ["SystemAnnouncer", "ClassRemoved"]
  2619. }),
  2620. globals.SmalltalkImage);
  2621. smalltalk.addMethod(
  2622. smalltalk.method({
  2623. selector: "removePackage:",
  2624. protocol: 'packages',
  2625. fn: function (packageName){
  2626. var self=this;
  2627. var pkg;
  2628. return smalltalk.withContext(function($ctx1) {
  2629. pkg=self._packageAt_ifAbsent_(packageName,(function(){
  2630. return smalltalk.withContext(function($ctx2) {
  2631. return self._error_("Missing package: ".__comma(packageName));
  2632. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2633. _st(_st(pkg)._classes())._do_((function(each){
  2634. return smalltalk.withContext(function($ctx2) {
  2635. return self._removeClass_(each);
  2636. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  2637. self._deletePackage_(packageName);
  2638. return self}, function($ctx1) {$ctx1.fill(self,"removePackage:",{packageName:packageName,pkg:pkg},globals.SmalltalkImage)})},
  2639. args: ["packageName"],
  2640. 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\x09\x09\x09self removeClass: each ].\x0a\x09self deletePackage: packageName",
  2641. messageSends: ["packageAt:ifAbsent:", "error:", ",", "do:", "classes", "removeClass:", "deletePackage:"],
  2642. referencedClasses: []
  2643. }),
  2644. globals.SmalltalkImage);
  2645. smalltalk.addMethod(
  2646. smalltalk.method({
  2647. selector: "renamePackage:to:",
  2648. protocol: 'packages',
  2649. fn: function (packageName,newName){
  2650. var self=this;
  2651. var pkg;
  2652. return smalltalk.withContext(function($ctx1) {
  2653. var $1,$2;
  2654. pkg=self._packageAt_ifAbsent_(packageName,(function(){
  2655. return smalltalk.withContext(function($ctx2) {
  2656. $1="Missing package: ".__comma(packageName);
  2657. $ctx2.sendIdx[","]=1;
  2658. return self._error_($1);
  2659. $ctx2.sendIdx["error:"]=1;
  2660. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2661. $2=self._packageAt_(newName);
  2662. if(($receiver = $2) == nil || $receiver == null){
  2663. $2;
  2664. } else {
  2665. self._error_("Already exists a package called: ".__comma(newName));
  2666. };
  2667. _st(self._at_("packages"))._at_put_(newName,pkg);
  2668. _st(pkg)._name_(newName);
  2669. self._deletePackage_(packageName);
  2670. return self}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},globals.SmalltalkImage)})},
  2671. args: ["packageName", "newName"],
  2672. 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(self at: 'packages') at: newName put: pkg.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
  2673. messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "at:", "name:", "deletePackage:"],
  2674. referencedClasses: []
  2675. }),
  2676. globals.SmalltalkImage);
  2677. smalltalk.addMethod(
  2678. smalltalk.method({
  2679. selector: "reservedWords",
  2680. protocol: 'accessing',
  2681. fn: function (){
  2682. var self=this;
  2683. return smalltalk.reservedWords;
  2684. return self},
  2685. args: [],
  2686. source: "reservedWords\x0a\x09\x22JavaScript reserved words\x22\x0a\x09<return smalltalk.reservedWords>",
  2687. messageSends: [],
  2688. referencedClasses: []
  2689. }),
  2690. globals.SmalltalkImage);
  2691. smalltalk.addMethod(
  2692. smalltalk.method({
  2693. selector: "version",
  2694. protocol: 'accessing',
  2695. fn: function (){
  2696. var self=this;
  2697. return "0.13.0-pre";
  2698. },
  2699. args: [],
  2700. source: "version\x0a\x09\x22Answer the version string of Amber\x22\x0a\x09\x0a\x09^ '0.13.0-pre'",
  2701. messageSends: [],
  2702. referencedClasses: []
  2703. }),
  2704. globals.SmalltalkImage);
  2705. smalltalk.addMethod(
  2706. smalltalk.method({
  2707. selector: "vm",
  2708. protocol: 'accessing',
  2709. fn: function (){
  2710. var self=this;
  2711. return smalltalk;
  2712. return self},
  2713. args: [],
  2714. source: "vm\x0a\x09\x22Future compatibility to be able to use Smalltalk vm ...\x22\x0a\x09<return smalltalk>",
  2715. messageSends: [],
  2716. referencedClasses: []
  2717. }),
  2718. globals.SmalltalkImage);
  2719. globals.SmalltalkImage.klass.iVarNames = ['current'];
  2720. smalltalk.addMethod(
  2721. smalltalk.method({
  2722. selector: "current",
  2723. protocol: 'instance creation',
  2724. fn: function (){
  2725. var self=this;
  2726. return smalltalk.withContext(function($ctx1) {
  2727. var $2,$1;
  2728. $2=self["@current"];
  2729. if(($receiver = $2) == nil || $receiver == null){
  2730. self["@current"]=globals.SmalltalkImage.klass.superclass.fn.prototype._new.apply(_st(self), []);
  2731. $1=self["@current"];
  2732. } else {
  2733. self._deprecatedAPI();
  2734. $1=self["@current"];
  2735. };
  2736. return $1;
  2737. }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SmalltalkImage.klass)})},
  2738. args: [],
  2739. source: "current\x0a\x09^ current ifNil: [ current := super new ] ifNotNil: [ self deprecatedAPI. current ]",
  2740. messageSends: ["ifNil:ifNotNil:", "new", "deprecatedAPI"],
  2741. referencedClasses: []
  2742. }),
  2743. globals.SmalltalkImage.klass);
  2744. smalltalk.addMethod(
  2745. smalltalk.method({
  2746. selector: "initialize",
  2747. protocol: 'initialization',
  2748. fn: function (){
  2749. var self=this;
  2750. return smalltalk.withContext(function($ctx1) {
  2751. _st(globals)._at_put_("Smalltalk",self._current());
  2752. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.SmalltalkImage.klass)})},
  2753. args: [],
  2754. source: "initialize\x0a\x09globals at: 'Smalltalk' put: self current",
  2755. messageSends: ["at:put:", "current"],
  2756. referencedClasses: []
  2757. }),
  2758. globals.SmalltalkImage.klass);
  2759. smalltalk.addMethod(
  2760. smalltalk.method({
  2761. selector: "new",
  2762. protocol: 'instance creation',
  2763. fn: function (){
  2764. var self=this;
  2765. return smalltalk.withContext(function($ctx1) {
  2766. self._shouldNotImplement();
  2767. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.SmalltalkImage.klass)})},
  2768. args: [],
  2769. source: "new\x0a\x09self shouldNotImplement",
  2770. messageSends: ["shouldNotImplement"],
  2771. referencedClasses: []
  2772. }),
  2773. globals.SmalltalkImage.klass);
  2774. smalltalk.addMethod(
  2775. smalltalk.method({
  2776. selector: "do:displayingProgress:",
  2777. protocol: '*Kernel-Infrastructure',
  2778. fn: function (aBlock,aString){
  2779. var self=this;
  2780. function $ProgressHandler(){return globals.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  2781. return smalltalk.withContext(function($ctx1) {
  2782. _st($ProgressHandler())._do_on_displaying_(aBlock,self,aString);
  2783. return self}, function($ctx1) {$ctx1.fill(self,"do:displayingProgress:",{aBlock:aBlock,aString:aString},globals.SequenceableCollection)})},
  2784. args: ["aBlock", "aString"],
  2785. source: "do: aBlock displayingProgress: aString\x0a\x09ProgressHandler \x0a\x09\x09do: aBlock \x0a\x09\x09on: self \x0a\x09\x09displaying: aString",
  2786. messageSends: ["do:on:displaying:"],
  2787. referencedClasses: ["ProgressHandler"]
  2788. }),
  2789. globals.SequenceableCollection);
  2790. smalltalk.addMethod(
  2791. smalltalk.method({
  2792. selector: "asJavaScriptSelector",
  2793. protocol: '*Kernel-Infrastructure',
  2794. fn: function (){
  2795. var self=this;
  2796. return smalltalk.withContext(function($ctx1) {
  2797. var $1;
  2798. $1=self._replace_with_("^([a-zA-Z0-9]*).*$","$1");
  2799. return $1;
  2800. }, function($ctx1) {$ctx1.fill(self,"asJavaScriptSelector",{},globals.String)})},
  2801. args: [],
  2802. source: "asJavaScriptSelector\x0a\x09\x22Return first keyword of the selector, without trailing colon.\x22\x0a\x09^ self replace: '^([a-zA-Z0-9]*).*$' with: '$1'",
  2803. messageSends: ["replace:with:"],
  2804. referencedClasses: []
  2805. }),
  2806. globals.String);
  2807. });