2
0

Kernel-Infrastructure.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. define("amber/Kernel-Infrastructure", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber/Kernel-Objects", "amber/Kernel-Collections"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Kernel-Infrastructure');
  3. smalltalk.packages["Kernel-Infrastructure"].transport = {"type":"amd","amdNamespace":"amber"};
  4. smalltalk.addClass('InspectorHandler', smalltalk.Object, [], 'Kernel-Infrastructure');
  5. smalltalk.InspectorHandler.comment="I am responsible for inspecting object.\x0a\x0aMy class-side `inspector` inst var holds the current inspector I'm delegating object inspection to.\x0a\x0aThe default inspector object is the transcript.";
  6. smalltalk.InspectorHandler.klass.iVarNames = ['inspector'];
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "inspect:",
  10. category: 'registration',
  11. fn: function (anObject){
  12. var self=this;
  13. return smalltalk.withContext(function($ctx1) {
  14. var $1;
  15. $1=_st(self._inspector())._inspect_(anObject);
  16. return $1;
  17. }, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},smalltalk.InspectorHandler.klass)})},
  18. args: ["anObject"],
  19. source: "inspect: anObject\x0a\x09^ self inspector inspect: anObject",
  20. messageSends: ["inspect:", "inspector"],
  21. referencedClasses: []
  22. }),
  23. smalltalk.InspectorHandler.klass);
  24. smalltalk.addMethod(
  25. smalltalk.method({
  26. selector: "inspector",
  27. category: 'accessing',
  28. fn: function (){
  29. var self=this;
  30. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  31. return smalltalk.withContext(function($ctx1) {
  32. var $2,$1;
  33. $2=self["@inspector"];
  34. if(($receiver = $2) == nil || $receiver == undefined){
  35. self["@inspector"]=$Transcript();
  36. $1=self["@inspector"];
  37. } else {
  38. $1=$2;
  39. };
  40. return $1;
  41. }, function($ctx1) {$ctx1.fill(self,"inspector",{},smalltalk.InspectorHandler.klass)})},
  42. args: [],
  43. source: "inspector\x0a\x09^ inspector ifNil: [ inspector := Transcript ]",
  44. messageSends: ["ifNil:"],
  45. referencedClasses: ["Transcript"]
  46. }),
  47. smalltalk.InspectorHandler.klass);
  48. smalltalk.addMethod(
  49. smalltalk.method({
  50. selector: "register:",
  51. category: 'registration',
  52. fn: function (anInspector){
  53. var self=this;
  54. return smalltalk.withContext(function($ctx1) {
  55. self["@inspector"]=anInspector;
  56. return self}, function($ctx1) {$ctx1.fill(self,"register:",{anInspector:anInspector},smalltalk.InspectorHandler.klass)})},
  57. args: ["anInspector"],
  58. source: "register: anInspector\x0a\x09inspector := anInspector",
  59. messageSends: [],
  60. referencedClasses: []
  61. }),
  62. smalltalk.InspectorHandler.klass);
  63. smalltalk.addClass('InterfacingObject', smalltalk.Object, [], 'Kernel-Infrastructure');
  64. smalltalk.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 }.\x0a";
  65. smalltalk.addMethod(
  66. smalltalk.method({
  67. selector: "ajax:",
  68. category: 'actions',
  69. fn: function (anObject){
  70. var self=this;
  71. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  72. return smalltalk.withContext(function($ctx1) {
  73. var $1;
  74. $1=_st($PlatformInterface())._ajax_(anObject);
  75. return $1;
  76. }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},smalltalk.InterfacingObject)})},
  77. args: ["anObject"],
  78. source: "ajax: anObject\x0a\x09^PlatformInterface ajax: anObject",
  79. messageSends: ["ajax:"],
  80. referencedClasses: ["PlatformInterface"]
  81. }),
  82. smalltalk.InterfacingObject);
  83. smalltalk.addMethod(
  84. smalltalk.method({
  85. selector: "alert:",
  86. category: 'actions',
  87. fn: function (aString){
  88. var self=this;
  89. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  90. return smalltalk.withContext(function($ctx1) {
  91. var $1;
  92. $1=_st($PlatformInterface())._alert_(aString);
  93. return $1;
  94. }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},smalltalk.InterfacingObject)})},
  95. args: ["aString"],
  96. source: "alert: aString\x0a\x09^PlatformInterface alert: aString",
  97. messageSends: ["alert:"],
  98. referencedClasses: ["PlatformInterface"]
  99. }),
  100. smalltalk.InterfacingObject);
  101. smalltalk.addMethod(
  102. smalltalk.method({
  103. selector: "confirm:",
  104. category: 'actions',
  105. fn: function (aString){
  106. var self=this;
  107. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  108. return smalltalk.withContext(function($ctx1) {
  109. var $1;
  110. $1=_st($PlatformInterface())._confirm_(aString);
  111. return $1;
  112. }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},smalltalk.InterfacingObject)})},
  113. args: ["aString"],
  114. source: "confirm: aString\x0a\x09^PlatformInterface confirm: aString",
  115. messageSends: ["confirm:"],
  116. referencedClasses: ["PlatformInterface"]
  117. }),
  118. smalltalk.InterfacingObject);
  119. smalltalk.addMethod(
  120. smalltalk.method({
  121. selector: "prompt:",
  122. category: 'actions',
  123. fn: function (aString){
  124. var self=this;
  125. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  126. return smalltalk.withContext(function($ctx1) {
  127. var $1;
  128. $1=_st($PlatformInterface())._prompt_(aString);
  129. return $1;
  130. }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},smalltalk.InterfacingObject)})},
  131. args: ["aString"],
  132. source: "prompt: aString\x0a\x09^PlatformInterface prompt: aString",
  133. messageSends: ["prompt:"],
  134. referencedClasses: ["PlatformInterface"]
  135. }),
  136. smalltalk.InterfacingObject);
  137. smalltalk.addClass('Environment', smalltalk.InterfacingObject, [], 'Kernel-Infrastructure');
  138. smalltalk.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.";
  139. smalltalk.addMethod(
  140. smalltalk.method({
  141. selector: "addInstVarNamed:to:",
  142. category: 'compiling',
  143. fn: function (aString,aClass){
  144. var self=this;
  145. return smalltalk.withContext(function($ctx1) {
  146. var $1,$2;
  147. $1=_st(_st(aClass)._instanceVariableNames())._copy();
  148. _st($1)._add_(aString);
  149. $2=_st($1)._yourself();
  150. _st(self._classBuilder())._addSubclassOf_named_instanceVariableNames_package_(_st(aClass)._superclass(),_st(aClass)._name(),$2,_st(_st(aClass)._package())._name());
  151. return self}, function($ctx1) {$ctx1.fill(self,"addInstVarNamed:to:",{aString:aString,aClass:aClass},smalltalk.Environment)})},
  152. args: ["aString", "aClass"],
  153. 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",
  154. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "superclass", "name", "add:", "copy", "instanceVariableNames", "yourself", "package", "classBuilder"],
  155. referencedClasses: []
  156. }),
  157. smalltalk.Environment);
  158. smalltalk.addMethod(
  159. smalltalk.method({
  160. selector: "allSelectors",
  161. category: 'accessing',
  162. fn: function (){
  163. var self=this;
  164. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  165. return smalltalk.withContext(function($ctx1) {
  166. var $1;
  167. $1=_st(_st(_st($Smalltalk())._current())._at_("allSelectors"))._value();
  168. return $1;
  169. }, function($ctx1) {$ctx1.fill(self,"allSelectors",{},smalltalk.Environment)})},
  170. args: [],
  171. source: "allSelectors\x0a\x09^ (Smalltalk current at: 'allSelectors') value",
  172. messageSends: ["value", "at:", "current"],
  173. referencedClasses: ["Smalltalk"]
  174. }),
  175. smalltalk.Environment);
  176. smalltalk.addMethod(
  177. smalltalk.method({
  178. selector: "availableClassNames",
  179. category: 'accessing',
  180. fn: function (){
  181. var self=this;
  182. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  183. return smalltalk.withContext(function($ctx1) {
  184. var $1;
  185. $1=_st(_st(_st($Smalltalk())._current())._classes())._collect_((function(each){
  186. return smalltalk.withContext(function($ctx2) {
  187. return _st(each)._name();
  188. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  189. return $1;
  190. }, function($ctx1) {$ctx1.fill(self,"availableClassNames",{},smalltalk.Environment)})},
  191. args: [],
  192. source: "availableClassNames\x0a\x09^ Smalltalk current classes \x0a\x09\x09collect: [ :each | each name ]",
  193. messageSends: ["collect:", "name", "classes", "current"],
  194. referencedClasses: ["Smalltalk"]
  195. }),
  196. smalltalk.Environment);
  197. smalltalk.addMethod(
  198. smalltalk.method({
  199. selector: "availablePackageNames",
  200. category: 'accessing',
  201. fn: function (){
  202. var self=this;
  203. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  204. return smalltalk.withContext(function($ctx1) {
  205. var $1;
  206. $1=_st(_st(_st($Smalltalk())._current())._packages())._collect_((function(each){
  207. return smalltalk.withContext(function($ctx2) {
  208. return _st(each)._name();
  209. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  210. return $1;
  211. }, function($ctx1) {$ctx1.fill(self,"availablePackageNames",{},smalltalk.Environment)})},
  212. args: [],
  213. source: "availablePackageNames\x0a\x09^ Smalltalk current packages \x0a\x09\x09collect: [ :each | each name ]",
  214. messageSends: ["collect:", "name", "packages", "current"],
  215. referencedClasses: ["Smalltalk"]
  216. }),
  217. smalltalk.Environment);
  218. smalltalk.addMethod(
  219. smalltalk.method({
  220. selector: "availableProtocolsFor:",
  221. category: 'accessing',
  222. fn: function (aClass){
  223. var self=this;
  224. var protocols;
  225. return smalltalk.withContext(function($ctx1) {
  226. var $1,$2;
  227. protocols=_st(aClass)._protocols();
  228. $1=_st(aClass)._superclass();
  229. if(($receiver = $1) == nil || $receiver == undefined){
  230. $1;
  231. } else {
  232. _st(protocols)._addAll_(self._availableProtocolsFor_(_st(aClass)._superclass()));
  233. };
  234. $2=_st(_st(protocols)._asSet())._asArray();
  235. return $2;
  236. }, function($ctx1) {$ctx1.fill(self,"availableProtocolsFor:",{aClass:aClass,protocols:protocols},smalltalk.Environment)})},
  237. args: ["aClass"],
  238. 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",
  239. messageSends: ["protocols", "ifNotNil:", "addAll:", "availableProtocolsFor:", "superclass", "asArray", "asSet"],
  240. referencedClasses: []
  241. }),
  242. smalltalk.Environment);
  243. smalltalk.addMethod(
  244. smalltalk.method({
  245. selector: "classBuilder",
  246. category: 'accessing',
  247. fn: function (){
  248. var self=this;
  249. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  250. return smalltalk.withContext(function($ctx1) {
  251. var $1;
  252. $1=_st($ClassBuilder())._new();
  253. return $1;
  254. }, function($ctx1) {$ctx1.fill(self,"classBuilder",{},smalltalk.Environment)})},
  255. args: [],
  256. source: "classBuilder\x0a\x09^ ClassBuilder new",
  257. messageSends: ["new"],
  258. referencedClasses: ["ClassBuilder"]
  259. }),
  260. smalltalk.Environment);
  261. smalltalk.addMethod(
  262. smalltalk.method({
  263. selector: "classNamed:",
  264. category: 'accessing',
  265. fn: function (aString){
  266. var self=this;
  267. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  268. return smalltalk.withContext(function($ctx1) {
  269. var $2,$1;
  270. $2=_st(_st($Smalltalk())._current())._at_(_st(aString)._asSymbol());
  271. if(($receiver = $2) == nil || $receiver == undefined){
  272. $1=self._error_("Invalid class name");
  273. } else {
  274. $1=$2;
  275. };
  276. return $1;
  277. }, function($ctx1) {$ctx1.fill(self,"classNamed:",{aString:aString},smalltalk.Environment)})},
  278. args: ["aString"],
  279. source: "classNamed: aString\x0a\x09^ (Smalltalk current at: aString asSymbol)\x0a\x09\x09ifNil: [ self error: 'Invalid class name' ]",
  280. messageSends: ["ifNil:", "error:", "at:", "asSymbol", "current"],
  281. referencedClasses: ["Smalltalk"]
  282. }),
  283. smalltalk.Environment);
  284. smalltalk.addMethod(
  285. smalltalk.method({
  286. selector: "classes",
  287. category: 'accessing',
  288. fn: function (){
  289. var self=this;
  290. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  291. return smalltalk.withContext(function($ctx1) {
  292. var $1;
  293. $1=_st(_st($Smalltalk())._current())._classes();
  294. return $1;
  295. }, function($ctx1) {$ctx1.fill(self,"classes",{},smalltalk.Environment)})},
  296. args: [],
  297. source: "classes\x0a\x09^ Smalltalk current classes",
  298. messageSends: ["classes", "current"],
  299. referencedClasses: ["Smalltalk"]
  300. }),
  301. smalltalk.Environment);
  302. smalltalk.addMethod(
  303. smalltalk.method({
  304. selector: "commitPackage:",
  305. category: 'actions',
  306. fn: function (aPackage){
  307. var self=this;
  308. return smalltalk.withContext(function($ctx1) {
  309. _st(aPackage)._commit();
  310. return self}, function($ctx1) {$ctx1.fill(self,"commitPackage:",{aPackage:aPackage},smalltalk.Environment)})},
  311. args: ["aPackage"],
  312. source: "commitPackage: aPackage\x0a\x09aPackage commit",
  313. messageSends: ["commit"],
  314. referencedClasses: []
  315. }),
  316. smalltalk.Environment);
  317. smalltalk.addMethod(
  318. smalltalk.method({
  319. selector: "compileClassComment:for:",
  320. category: 'compiling',
  321. fn: function (aString,aClass){
  322. var self=this;
  323. return smalltalk.withContext(function($ctx1) {
  324. _st(aClass)._comment_(aString);
  325. return self}, function($ctx1) {$ctx1.fill(self,"compileClassComment:for:",{aString:aString,aClass:aClass},smalltalk.Environment)})},
  326. args: ["aString", "aClass"],
  327. source: "compileClassComment: aString for: aClass\x0a\x09aClass comment: aString",
  328. messageSends: ["comment:"],
  329. referencedClasses: []
  330. }),
  331. smalltalk.Environment);
  332. smalltalk.addMethod(
  333. smalltalk.method({
  334. selector: "compileClassDefinition:",
  335. category: 'compiling',
  336. fn: function (aString){
  337. var self=this;
  338. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  339. return smalltalk.withContext(function($ctx1) {
  340. self._eval_on_(aString,_st($DoIt())._new());
  341. return self}, function($ctx1) {$ctx1.fill(self,"compileClassDefinition:",{aString:aString},smalltalk.Environment)})},
  342. args: ["aString"],
  343. source: "compileClassDefinition: aString\x0a\x09self eval: aString on: DoIt new",
  344. messageSends: ["eval:on:", "new"],
  345. referencedClasses: ["DoIt"]
  346. }),
  347. smalltalk.Environment);
  348. smalltalk.addMethod(
  349. smalltalk.method({
  350. selector: "compileMethod:for:protocol:",
  351. category: 'compiling',
  352. fn: function (sourceCode,class_,protocol){
  353. var self=this;
  354. return smalltalk.withContext(function($ctx1) {
  355. var $1;
  356. $1=_st(class_)._compile_category_(sourceCode,protocol);
  357. return $1;
  358. }, function($ctx1) {$ctx1.fill(self,"compileMethod:for:protocol:",{sourceCode:sourceCode,class_:class_,protocol:protocol},smalltalk.Environment)})},
  359. args: ["sourceCode", "class", "protocol"],
  360. source: "compileMethod: sourceCode for: class protocol: protocol\x0a\x09^ class\x0a\x09\x09compile: sourceCode\x0a\x09\x09category: protocol",
  361. messageSends: ["compile:category:"],
  362. referencedClasses: []
  363. }),
  364. smalltalk.Environment);
  365. smalltalk.addMethod(
  366. smalltalk.method({
  367. selector: "copyClass:to:",
  368. category: 'actions',
  369. fn: function (aClass,aClassName){
  370. var self=this;
  371. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  372. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  373. return smalltalk.withContext(function($ctx1) {
  374. var $1;
  375. $1=_st(_st($Smalltalk())._current())._at_(aClassName);
  376. if(($receiver = $1) == nil || $receiver == undefined){
  377. $1;
  378. } else {
  379. self._error_(_st("A class named ".__comma(aClassName)).__comma(" already exists"));
  380. };
  381. _st(_st($ClassBuilder())._new())._copyClass_named_(aClass,aClassName);
  382. return self}, function($ctx1) {$ctx1.fill(self,"copyClass:to:",{aClass:aClass,aClassName:aClassName},smalltalk.Environment)})},
  383. args: ["aClass", "aClassName"],
  384. source: "copyClass: aClass to: aClassName\x0a\x09(Smalltalk current at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new copyClass: aClass named: aClassName",
  385. messageSends: ["ifNotNil:", "error:", ",", "at:", "current", "copyClass:named:", "new"],
  386. referencedClasses: ["Smalltalk", "ClassBuilder"]
  387. }),
  388. smalltalk.Environment);
  389. smalltalk.addMethod(
  390. smalltalk.method({
  391. selector: "eval:on:",
  392. category: 'actions',
  393. fn: function (aString,aReceiver){
  394. var self=this;
  395. var compiler;
  396. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  397. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  398. return smalltalk.withContext(function($ctx1) {
  399. var $1,$2;
  400. var $early={};
  401. try {
  402. compiler=_st($Compiler())._new();
  403. _st((function(){
  404. return smalltalk.withContext(function($ctx2) {
  405. return _st(compiler)._parseExpression_(aString);
  406. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  407. return smalltalk.withContext(function($ctx2) {
  408. $1=self._alert_(_st(ex)._messageText());
  409. throw $early=[$1];
  410. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  411. $2=_st(compiler)._evaluateExpression_on_(aString,aReceiver);
  412. return $2;
  413. }
  414. catch(e) {if(e===$early)return e[0]; throw e}
  415. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{aString:aString,aReceiver:aReceiver,compiler:compiler},smalltalk.Environment)})},
  416. args: ["aString", "aReceiver"],
  417. 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",
  418. messageSends: ["new", "on:do:", "alert:", "messageText", "parseExpression:", "evaluateExpression:on:"],
  419. referencedClasses: ["Compiler", "Error"]
  420. }),
  421. smalltalk.Environment);
  422. smalltalk.addMethod(
  423. smalltalk.method({
  424. selector: "evaluate:on:do:",
  425. category: 'error handling',
  426. fn: function (aBlock,anErrorClass,exceptionBlock){
  427. var self=this;
  428. return smalltalk.withContext(function($ctx1) {
  429. var $1;
  430. self._try_catch_(aBlock,(function(exception){
  431. return smalltalk.withContext(function($ctx2) {
  432. $1=_st(exception)._isKindOf_(self._classNamed_(_st(anErrorClass)._name()));
  433. if(smalltalk.assert($1)){
  434. return _st(exceptionBlock)._value_(exception);
  435. } else {
  436. return _st(exception)._signal();
  437. };
  438. }, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1)})}));
  439. return self}, function($ctx1) {$ctx1.fill(self,"evaluate:on:do:",{aBlock:aBlock,anErrorClass:anErrorClass,exceptionBlock:exceptionBlock},smalltalk.Environment)})},
  440. args: ["aBlock", "anErrorClass", "exceptionBlock"],
  441. 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 ] ]",
  442. messageSends: ["try:catch:", "ifTrue:ifFalse:", "value:", "signal", "isKindOf:", "classNamed:", "name"],
  443. referencedClasses: []
  444. }),
  445. smalltalk.Environment);
  446. smalltalk.addMethod(
  447. smalltalk.method({
  448. selector: "inspect:",
  449. category: 'actions',
  450. fn: function (anObject){
  451. var self=this;
  452. function $InspectorHandler(){return smalltalk.InspectorHandler||(typeof InspectorHandler=="undefined"?nil:InspectorHandler)}
  453. return smalltalk.withContext(function($ctx1) {
  454. _st(_st($InspectorHandler())._inspector())._inspect_(anObject);
  455. return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},smalltalk.Environment)})},
  456. args: ["anObject"],
  457. source: "inspect: anObject\x0a\x09InspectorHandler inspector inspect: anObject",
  458. messageSends: ["inspect:", "inspector"],
  459. referencedClasses: ["InspectorHandler"]
  460. }),
  461. smalltalk.Environment);
  462. smalltalk.addMethod(
  463. smalltalk.method({
  464. selector: "moveClass:toPackage:",
  465. category: 'actions',
  466. fn: function (aClass,aPackageName){
  467. var self=this;
  468. var package_;
  469. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  470. return smalltalk.withContext(function($ctx1) {
  471. var $1,$2,$3;
  472. package_=_st($Package())._named_(aPackageName);
  473. $1=package_;
  474. if(($receiver = $1) == nil || $receiver == undefined){
  475. self._error_("Invalid package name");
  476. } else {
  477. $1;
  478. };
  479. $2=_st(package_).__eq_eq(_st(aClass)._package());
  480. if(smalltalk.assert($2)){
  481. $3=self;
  482. return $3;
  483. };
  484. _st(aClass)._package_(package_);
  485. return self}, function($ctx1) {$ctx1.fill(self,"moveClass:toPackage:",{aClass:aClass,aPackageName:aPackageName,package_:package_},smalltalk.Environment)})},
  486. args: ["aClass", "aPackageName"],
  487. 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",
  488. messageSends: ["named:", "ifNil:", "error:", "ifTrue:", "==", "package", "package:"],
  489. referencedClasses: ["Package"]
  490. }),
  491. smalltalk.Environment);
  492. smalltalk.addMethod(
  493. smalltalk.method({
  494. selector: "moveMethod:toClass:",
  495. category: 'actions',
  496. fn: function (aMethod,aClassName){
  497. var self=this;
  498. var destinationClass;
  499. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  500. return smalltalk.withContext(function($ctx1) {
  501. var $1,$2,$3;
  502. destinationClass=_st(_st($Smalltalk())._current())._at_(_st(aClassName)._asSymbol());
  503. $1=destinationClass;
  504. if(($receiver = $1) == nil || $receiver == undefined){
  505. self._error_("Invalid class name");
  506. } else {
  507. $1;
  508. };
  509. $2=_st(destinationClass).__eq_eq(_st(aMethod)._methodClass());
  510. if(smalltalk.assert($2)){
  511. $3=self;
  512. return $3;
  513. };
  514. _st(destinationClass)._compile_category_(_st(aMethod)._source(),_st(aMethod)._protocol());
  515. _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
  516. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.Environment)})},
  517. args: ["aMethod", "aClassName"],
  518. source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := Smalltalk current at: aClassName asSymbol.\x0a\x09destinationClass ifNil: [ self error: 'Invalid class name' ].\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass \x0a\x09\x09compile: aMethod source\x0a\x09\x09category: aMethod protocol.\x0a\x09aMethod methodClass \x0a\x09\x09removeCompiledMethod: aMethod",
  519. messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "compile:category:", "source", "protocol", "removeCompiledMethod:"],
  520. referencedClasses: ["Smalltalk"]
  521. }),
  522. smalltalk.Environment);
  523. smalltalk.addMethod(
  524. smalltalk.method({
  525. selector: "moveMethod:toProtocol:",
  526. category: 'actions',
  527. fn: function (aMethod,aProtocol){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) {
  530. _st(aMethod)._category_(aProtocol);
  531. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toProtocol:",{aMethod:aMethod,aProtocol:aProtocol},smalltalk.Environment)})},
  532. args: ["aMethod", "aProtocol"],
  533. source: "moveMethod: aMethod toProtocol: aProtocol\x0a\x09aMethod category: aProtocol",
  534. messageSends: ["category:"],
  535. referencedClasses: []
  536. }),
  537. smalltalk.Environment);
  538. smalltalk.addMethod(
  539. smalltalk.method({
  540. selector: "packages",
  541. category: 'accessing',
  542. fn: function (){
  543. var self=this;
  544. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  545. return smalltalk.withContext(function($ctx1) {
  546. var $1;
  547. $1=_st(_st($Smalltalk())._current())._packages();
  548. return $1;
  549. }, function($ctx1) {$ctx1.fill(self,"packages",{},smalltalk.Environment)})},
  550. args: [],
  551. source: "packages\x0a\x09^ Smalltalk current packages",
  552. messageSends: ["packages", "current"],
  553. referencedClasses: ["Smalltalk"]
  554. }),
  555. smalltalk.Environment);
  556. smalltalk.addMethod(
  557. smalltalk.method({
  558. selector: "registerErrorHandler:",
  559. category: 'actions',
  560. fn: function (anErrorHandler){
  561. var self=this;
  562. function $ErrorHandler(){return smalltalk.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
  563. return smalltalk.withContext(function($ctx1) {
  564. _st($ErrorHandler())._setCurrent_(anErrorHandler);
  565. return self}, function($ctx1) {$ctx1.fill(self,"registerErrorHandler:",{anErrorHandler:anErrorHandler},smalltalk.Environment)})},
  566. args: ["anErrorHandler"],
  567. source: "registerErrorHandler: anErrorHandler\x0a\x09ErrorHandler setCurrent: anErrorHandler",
  568. messageSends: ["setCurrent:"],
  569. referencedClasses: ["ErrorHandler"]
  570. }),
  571. smalltalk.Environment);
  572. smalltalk.addMethod(
  573. smalltalk.method({
  574. selector: "registerInspector:",
  575. category: 'actions',
  576. fn: function (anInspector){
  577. var self=this;
  578. function $InspectorHandler(){return smalltalk.InspectorHandler||(typeof InspectorHandler=="undefined"?nil:InspectorHandler)}
  579. return smalltalk.withContext(function($ctx1) {
  580. _st($InspectorHandler())._register_(anInspector);
  581. return self}, function($ctx1) {$ctx1.fill(self,"registerInspector:",{anInspector:anInspector},smalltalk.Environment)})},
  582. args: ["anInspector"],
  583. source: "registerInspector: anInspector\x0a\x09InspectorHandler register: anInspector",
  584. messageSends: ["register:"],
  585. referencedClasses: ["InspectorHandler"]
  586. }),
  587. smalltalk.Environment);
  588. smalltalk.addMethod(
  589. smalltalk.method({
  590. selector: "registerProgressHandler:",
  591. category: 'actions',
  592. fn: function (aProgressHandler){
  593. var self=this;
  594. function $ProgressHandler(){return smalltalk.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  595. return smalltalk.withContext(function($ctx1) {
  596. _st($ProgressHandler())._setCurrent_(aProgressHandler);
  597. return self}, function($ctx1) {$ctx1.fill(self,"registerProgressHandler:",{aProgressHandler:aProgressHandler},smalltalk.Environment)})},
  598. args: ["aProgressHandler"],
  599. source: "registerProgressHandler: aProgressHandler\x0a\x09ProgressHandler setCurrent: aProgressHandler",
  600. messageSends: ["setCurrent:"],
  601. referencedClasses: ["ProgressHandler"]
  602. }),
  603. smalltalk.Environment);
  604. smalltalk.addMethod(
  605. smalltalk.method({
  606. selector: "removeClass:",
  607. category: 'actions',
  608. fn: function (aClass){
  609. var self=this;
  610. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  611. return smalltalk.withContext(function($ctx1) {
  612. _st(_st($Smalltalk())._current())._removeClass_(aClass);
  613. return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},smalltalk.Environment)})},
  614. args: ["aClass"],
  615. source: "removeClass: aClass\x0a\x09Smalltalk current removeClass: aClass",
  616. messageSends: ["removeClass:", "current"],
  617. referencedClasses: ["Smalltalk"]
  618. }),
  619. smalltalk.Environment);
  620. smalltalk.addMethod(
  621. smalltalk.method({
  622. selector: "removeMethod:",
  623. category: 'actions',
  624. fn: function (aMethod){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) {
  627. _st(_st(aMethod)._methodClass())._removeCompiledMethod_(aMethod);
  628. return self}, function($ctx1) {$ctx1.fill(self,"removeMethod:",{aMethod:aMethod},smalltalk.Environment)})},
  629. args: ["aMethod"],
  630. source: "removeMethod: aMethod\x0a\x09aMethod methodClass removeCompiledMethod: aMethod",
  631. messageSends: ["removeCompiledMethod:", "methodClass"],
  632. referencedClasses: []
  633. }),
  634. smalltalk.Environment);
  635. smalltalk.addMethod(
  636. smalltalk.method({
  637. selector: "removeProtocol:from:",
  638. category: 'actions',
  639. fn: function (aString,aClass){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. _st(_st(_st(aClass)._methods())._select_((function(each){
  643. return smalltalk.withContext(function($ctx2) {
  644. return _st(_st(each)._protocol()).__eq(aString);
  645. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._do_((function(each){
  646. return smalltalk.withContext(function($ctx2) {
  647. return _st(aClass)._removeCompiledMethod_(each);
  648. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  649. return self}, function($ctx1) {$ctx1.fill(self,"removeProtocol:from:",{aString:aString,aClass:aClass},smalltalk.Environment)})},
  650. args: ["aString", "aClass"],
  651. source: "removeProtocol: aString from: aClass\x0a\x09(aClass methods\x0a\x09\x09select: [ :each | each protocol = aString ])\x0a\x09\x09do: [ :each | aClass removeCompiledMethod: each ]",
  652. messageSends: ["do:", "removeCompiledMethod:", "select:", "=", "protocol", "methods"],
  653. referencedClasses: []
  654. }),
  655. smalltalk.Environment);
  656. smalltalk.addMethod(
  657. smalltalk.method({
  658. selector: "renameClass:to:",
  659. category: 'actions',
  660. fn: function (aClass,aClassName){
  661. var self=this;
  662. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  663. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  664. return smalltalk.withContext(function($ctx1) {
  665. var $1;
  666. $1=_st(_st($Smalltalk())._current())._at_(aClassName);
  667. if(($receiver = $1) == nil || $receiver == undefined){
  668. $1;
  669. } else {
  670. self._error_(_st("A class named ".__comma(aClassName)).__comma(" already exists"));
  671. };
  672. _st(_st($ClassBuilder())._new())._renameClass_to_(aClass,aClassName);
  673. return self}, function($ctx1) {$ctx1.fill(self,"renameClass:to:",{aClass:aClass,aClassName:aClassName},smalltalk.Environment)})},
  674. args: ["aClass", "aClassName"],
  675. source: "renameClass: aClass to: aClassName\x0a\x09(Smalltalk current at: aClassName)\x0a\x09\x09ifNotNil: [ self error: 'A class named ', aClassName, ' already exists' ].\x0a\x09\x09\x0a\x09ClassBuilder new renameClass: aClass to: aClassName",
  676. messageSends: ["ifNotNil:", "error:", ",", "at:", "current", "renameClass:to:", "new"],
  677. referencedClasses: ["Smalltalk", "ClassBuilder"]
  678. }),
  679. smalltalk.Environment);
  680. smalltalk.addMethod(
  681. smalltalk.method({
  682. selector: "renameProtocol:to:in:",
  683. category: 'actions',
  684. fn: function (aString,anotherString,aClass){
  685. var self=this;
  686. return smalltalk.withContext(function($ctx1) {
  687. _st(_st(_st(aClass)._methods())._select_((function(each){
  688. return smalltalk.withContext(function($ctx2) {
  689. return _st(_st(each)._protocol()).__eq(aString);
  690. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._do_((function(each){
  691. return smalltalk.withContext(function($ctx2) {
  692. return _st(each)._protocol_(anotherString);
  693. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  694. return self}, function($ctx1) {$ctx1.fill(self,"renameProtocol:to:in:",{aString:aString,anotherString:anotherString,aClass:aClass},smalltalk.Environment)})},
  695. args: ["aString", "anotherString", "aClass"],
  696. source: "renameProtocol: aString to: anotherString in: aClass\x0a\x09(aClass methods\x0a\x09\x09select: [ :each | each protocol = aString ])\x0a\x09\x09do: [ :each | each protocol: anotherString ]",
  697. messageSends: ["do:", "protocol:", "select:", "=", "protocol", "methods"],
  698. referencedClasses: []
  699. }),
  700. smalltalk.Environment);
  701. smalltalk.addMethod(
  702. smalltalk.method({
  703. selector: "setClassCommentOf:to:",
  704. category: 'actions',
  705. fn: function (aClass,aString){
  706. var self=this;
  707. return smalltalk.withContext(function($ctx1) {
  708. _st(aClass)._comment_(aString);
  709. return self}, function($ctx1) {$ctx1.fill(self,"setClassCommentOf:to:",{aClass:aClass,aString:aString},smalltalk.Environment)})},
  710. args: ["aClass", "aString"],
  711. source: "setClassCommentOf: aClass to: aString\x0a\x09aClass comment: aString",
  712. messageSends: ["comment:"],
  713. referencedClasses: []
  714. }),
  715. smalltalk.Environment);
  716. smalltalk.addMethod(
  717. smalltalk.method({
  718. selector: "systemAnnouncer",
  719. category: 'accessing',
  720. fn: function (){
  721. var self=this;
  722. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  723. return smalltalk.withContext(function($ctx1) {
  724. var $1;
  725. $1=_st(_st(_st($Smalltalk())._current())._at_("SystemAnnouncer"))._current();
  726. return $1;
  727. }, function($ctx1) {$ctx1.fill(self,"systemAnnouncer",{},smalltalk.Environment)})},
  728. args: [],
  729. source: "systemAnnouncer\x0a\x09^ (Smalltalk current at: #SystemAnnouncer) current",
  730. messageSends: ["current", "at:"],
  731. referencedClasses: ["Smalltalk"]
  732. }),
  733. smalltalk.Environment);
  734. smalltalk.addClass('JSObjectProxy', smalltalk.Object, ['jsObject'], 'Kernel-Infrastructure');
  735. smalltalk.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`.";
  736. smalltalk.addMethod(
  737. smalltalk.method({
  738. selector: "addObjectVariablesTo:",
  739. category: 'proxy',
  740. fn: function (aDictionary){
  741. var self=this;
  742. return smalltalk.withContext(function($ctx1) {
  743. for(var i in self['@jsObject']) {
  744. aDictionary._at_put_(i, self['@jsObject'][i]);
  745. }
  746. ;
  747. return self}, function($ctx1) {$ctx1.fill(self,"addObjectVariablesTo:",{aDictionary:aDictionary},smalltalk.JSObjectProxy)})},
  748. args: ["aDictionary"],
  749. 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>",
  750. messageSends: [],
  751. referencedClasses: []
  752. }),
  753. smalltalk.JSObjectProxy);
  754. smalltalk.addMethod(
  755. smalltalk.method({
  756. selector: "at:",
  757. category: 'accessing',
  758. fn: function (aString){
  759. var self=this;
  760. return smalltalk.withContext(function($ctx1) {
  761. return self['@jsObject'][aString];
  762. return self}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.JSObjectProxy)})},
  763. args: ["aString"],
  764. source: "at: aString\x0a\x09<return self['@jsObject'][aString]>",
  765. messageSends: [],
  766. referencedClasses: []
  767. }),
  768. smalltalk.JSObjectProxy);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "at:ifAbsent:",
  772. category: 'accessing',
  773. fn: function (aString,aBlock){
  774. var self=this;
  775. return smalltalk.withContext(function($ctx1) {
  776. var obj = self['@jsObject'];
  777. return aString in obj ? obj[aString] : aBlock._value();
  778. ;
  779. return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aString:aString,aBlock:aBlock},smalltalk.JSObjectProxy)})},
  780. args: ["aString", "aBlock"],
  781. 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>",
  782. messageSends: [],
  783. referencedClasses: []
  784. }),
  785. smalltalk.JSObjectProxy);
  786. smalltalk.addMethod(
  787. smalltalk.method({
  788. selector: "at:ifPresent:",
  789. category: 'accessing',
  790. fn: function (aString,aBlock){
  791. var self=this;
  792. return smalltalk.withContext(function($ctx1) {
  793. var obj = self['@jsObject'];
  794. return aString in obj ? aBlock._value_(obj[aString]) : nil;
  795. ;
  796. return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:",{aString:aString,aBlock:aBlock},smalltalk.JSObjectProxy)})},
  797. args: ["aString", "aBlock"],
  798. 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>",
  799. messageSends: [],
  800. referencedClasses: []
  801. }),
  802. smalltalk.JSObjectProxy);
  803. smalltalk.addMethod(
  804. smalltalk.method({
  805. selector: "at:ifPresent:ifAbsent:",
  806. category: 'accessing',
  807. fn: function (aString,aBlock,anotherBlock){
  808. var self=this;
  809. return smalltalk.withContext(function($ctx1) {
  810. var obj = self['@jsObject'];
  811. return aString in obj ? aBlock._value_(obj[aString]) : anotherBlock._value();
  812. ;
  813. return self}, function($ctx1) {$ctx1.fill(self,"at:ifPresent:ifAbsent:",{aString:aString,aBlock:aBlock,anotherBlock:anotherBlock},smalltalk.JSObjectProxy)})},
  814. args: ["aString", "aBlock", "anotherBlock"],
  815. 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>",
  816. messageSends: [],
  817. referencedClasses: []
  818. }),
  819. smalltalk.JSObjectProxy);
  820. smalltalk.addMethod(
  821. smalltalk.method({
  822. selector: "at:put:",
  823. category: 'accessing',
  824. fn: function (aString,anObject){
  825. var self=this;
  826. return smalltalk.withContext(function($ctx1) {
  827. self['@jsObject'][aString] = anObject;
  828. return self}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},smalltalk.JSObjectProxy)})},
  829. args: ["aString", "anObject"],
  830. source: "at: aString put: anObject\x0a\x09<self['@jsObject'][aString] = anObject>",
  831. messageSends: [],
  832. referencedClasses: []
  833. }),
  834. smalltalk.JSObjectProxy);
  835. smalltalk.addMethod(
  836. smalltalk.method({
  837. selector: "doesNotUnderstand:",
  838. category: 'proxy',
  839. fn: function (aMessage){
  840. var self=this;
  841. return smalltalk.withContext(function($ctx1) {
  842. var $2,$1;
  843. $2=self._lookupProperty_(_st(_st(aMessage)._selector())._asJavaScriptSelector());
  844. if(($receiver = $2) == nil || $receiver == undefined){
  845. $1=smalltalk.JSObjectProxy.superclass.fn.prototype._doesNotUnderstand_.apply(_st(self), [aMessage]);
  846. } else {
  847. var jsSelector;
  848. jsSelector=$receiver;
  849. $1=self._forwardMessage_withArguments_(jsSelector,_st(aMessage)._arguments());
  850. };
  851. return $1;
  852. }, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},smalltalk.JSObjectProxy)})},
  853. args: ["aMessage"],
  854. 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 ]",
  855. messageSends: ["ifNil:ifNotNil:", "doesNotUnderstand:", "forwardMessage:withArguments:", "arguments", "lookupProperty:", "asJavaScriptSelector", "selector"],
  856. referencedClasses: []
  857. }),
  858. smalltalk.JSObjectProxy);
  859. smalltalk.addMethod(
  860. smalltalk.method({
  861. selector: "forwardMessage:withArguments:",
  862. category: 'proxy',
  863. fn: function (aString,anArray){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) {
  866. return smalltalk.send(self._jsObject(), aString, anArray);
  867. ;
  868. return self}, function($ctx1) {$ctx1.fill(self,"forwardMessage:withArguments:",{aString:aString,anArray:anArray},smalltalk.JSObjectProxy)})},
  869. args: ["aString", "anArray"],
  870. source: "forwardMessage: aString withArguments: anArray\x0a\x09<\x0a\x09\x09return smalltalk.send(self._jsObject(), aString, anArray);\x0a\x09>",
  871. messageSends: [],
  872. referencedClasses: []
  873. }),
  874. smalltalk.JSObjectProxy);
  875. smalltalk.addMethod(
  876. smalltalk.method({
  877. selector: "inspectOn:",
  878. category: 'proxy',
  879. fn: function (anInspector){
  880. var self=this;
  881. var variables;
  882. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  883. return smalltalk.withContext(function($ctx1) {
  884. variables=_st($Dictionary())._new();
  885. _st(variables)._at_put_("#self",self._jsObject());
  886. _st(anInspector)._setLabel_(self._printString());
  887. self._addObjectVariablesTo_(variables);
  888. _st(anInspector)._setVariables_(variables);
  889. return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector,variables:variables},smalltalk.JSObjectProxy)})},
  890. args: ["anInspector"],
  891. 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",
  892. messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "addObjectVariablesTo:", "setVariables:"],
  893. referencedClasses: ["Dictionary"]
  894. }),
  895. smalltalk.JSObjectProxy);
  896. smalltalk.addMethod(
  897. smalltalk.method({
  898. selector: "jsObject",
  899. category: 'accessing',
  900. fn: function (){
  901. var self=this;
  902. return smalltalk.withContext(function($ctx1) {
  903. var $1;
  904. $1=self["@jsObject"];
  905. return $1;
  906. }, function($ctx1) {$ctx1.fill(self,"jsObject",{},smalltalk.JSObjectProxy)})},
  907. args: [],
  908. source: "jsObject\x0a\x09^jsObject",
  909. messageSends: [],
  910. referencedClasses: []
  911. }),
  912. smalltalk.JSObjectProxy);
  913. smalltalk.addMethod(
  914. smalltalk.method({
  915. selector: "jsObject:",
  916. category: 'accessing',
  917. fn: function (aJSObject){
  918. var self=this;
  919. return smalltalk.withContext(function($ctx1) {
  920. self["@jsObject"]=aJSObject;
  921. return self}, function($ctx1) {$ctx1.fill(self,"jsObject:",{aJSObject:aJSObject},smalltalk.JSObjectProxy)})},
  922. args: ["aJSObject"],
  923. source: "jsObject: aJSObject\x0a\x09jsObject := aJSObject",
  924. messageSends: [],
  925. referencedClasses: []
  926. }),
  927. smalltalk.JSObjectProxy);
  928. smalltalk.addMethod(
  929. smalltalk.method({
  930. selector: "keysAndValuesDo:",
  931. category: 'enumerating',
  932. fn: function (aBlock){
  933. var self=this;
  934. return smalltalk.withContext(function($ctx1) {
  935. var o = self['@jsObject'];
  936. for(var i in o) {
  937. aBlock._value_value_(i, o[i]);
  938. }
  939. ;
  940. return self}, function($ctx1) {$ctx1.fill(self,"keysAndValuesDo:",{aBlock:aBlock},smalltalk.JSObjectProxy)})},
  941. args: ["aBlock"],
  942. 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>",
  943. messageSends: [],
  944. referencedClasses: []
  945. }),
  946. smalltalk.JSObjectProxy);
  947. smalltalk.addMethod(
  948. smalltalk.method({
  949. selector: "lookupProperty:",
  950. category: 'accessing',
  951. fn: function (aString){
  952. var self=this;
  953. return smalltalk.withContext(function($ctx1) {
  954. return aString in self._jsObject() ? aString : nil;
  955. return self}, function($ctx1) {$ctx1.fill(self,"lookupProperty:",{aString:aString},smalltalk.JSObjectProxy)})},
  956. args: ["aString"],
  957. 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>",
  958. messageSends: [],
  959. referencedClasses: []
  960. }),
  961. smalltalk.JSObjectProxy);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "printOn:",
  965. category: 'printing',
  966. fn: function (aStream){
  967. var self=this;
  968. return smalltalk.withContext(function($ctx1) {
  969. _st(aStream)._nextPutAll_(_st(self._jsObject())._toString());
  970. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.JSObjectProxy)})},
  971. args: ["aStream"],
  972. source: "printOn: aStream\x0a\x09aStream nextPutAll: self jsObject toString",
  973. messageSends: ["nextPutAll:", "toString", "jsObject"],
  974. referencedClasses: []
  975. }),
  976. smalltalk.JSObjectProxy);
  977. smalltalk.addMethod(
  978. smalltalk.method({
  979. selector: "value",
  980. category: 'accessing',
  981. fn: function (){
  982. var self=this;
  983. return smalltalk.withContext(function($ctx1) {
  984. var $1;
  985. $1=self._at_ifAbsent_("value",(function(){
  986. return smalltalk.withContext(function($ctx2) {
  987. return smalltalk.JSObjectProxy.superclass.fn.prototype._value.apply(_st(self), []);
  988. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  989. return $1;
  990. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.JSObjectProxy)})},
  991. args: [],
  992. source: "value\x0a\x09\x22if attribute 'value' exists on the JS object return it,\x0a\x09otherwise return the result of Object>>value.\x22\x0a\x09\x0a\x09^ self \x0a\x09\x09at: 'value' \x0a\x09\x09ifAbsent: [ super value ]",
  993. messageSends: ["at:ifAbsent:", "value"],
  994. referencedClasses: []
  995. }),
  996. smalltalk.JSObjectProxy);
  997. smalltalk.addMethod(
  998. smalltalk.method({
  999. selector: "on:",
  1000. category: 'instance creation',
  1001. fn: function (aJSObject){
  1002. var self=this;
  1003. return smalltalk.withContext(function($ctx1) {
  1004. var $2,$3,$1;
  1005. $2=self._new();
  1006. _st($2)._jsObject_(aJSObject);
  1007. $3=_st($2)._yourself();
  1008. $1=$3;
  1009. return $1;
  1010. }, function($ctx1) {$ctx1.fill(self,"on:",{aJSObject:aJSObject},smalltalk.JSObjectProxy.klass)})},
  1011. args: ["aJSObject"],
  1012. source: "on: aJSObject\x0a\x09^self new\x0a\x09\x09jsObject: aJSObject;\x0a\x09\x09yourself",
  1013. messageSends: ["jsObject:", "new", "yourself"],
  1014. referencedClasses: []
  1015. }),
  1016. smalltalk.JSObjectProxy.klass);
  1017. smalltalk.addClass('Organizer', smalltalk.Object, [], 'Kernel-Infrastructure');
  1018. smalltalk.Organizer.comment="I represent categorization information. \x0a\x0a## API\x0a\x0aUse `#addElement:` and `#removeElement:` to manipulate instances.";
  1019. smalltalk.addMethod(
  1020. smalltalk.method({
  1021. selector: "addElement:",
  1022. category: 'accessing',
  1023. fn: function (anObject){
  1024. var self=this;
  1025. return smalltalk.withContext(function($ctx1) {
  1026. self.elements.addElement(anObject);
  1027. return self}, function($ctx1) {$ctx1.fill(self,"addElement:",{anObject:anObject},smalltalk.Organizer)})},
  1028. args: ["anObject"],
  1029. source: "addElement: anObject\x0a\x09<self.elements.addElement(anObject)>",
  1030. messageSends: [],
  1031. referencedClasses: []
  1032. }),
  1033. smalltalk.Organizer);
  1034. smalltalk.addMethod(
  1035. smalltalk.method({
  1036. selector: "elements",
  1037. category: 'accessing',
  1038. fn: function (){
  1039. var self=this;
  1040. return smalltalk.withContext(function($ctx1) {
  1041. var $1;
  1042. $1=_st(self._basicAt_("elements"))._copy();
  1043. return $1;
  1044. }, function($ctx1) {$ctx1.fill(self,"elements",{},smalltalk.Organizer)})},
  1045. args: [],
  1046. source: "elements\x0a\x09^ (self basicAt: 'elements') copy",
  1047. messageSends: ["copy", "basicAt:"],
  1048. referencedClasses: []
  1049. }),
  1050. smalltalk.Organizer);
  1051. smalltalk.addMethod(
  1052. smalltalk.method({
  1053. selector: "removeElement:",
  1054. category: 'accessing',
  1055. fn: function (anObject){
  1056. var self=this;
  1057. return smalltalk.withContext(function($ctx1) {
  1058. self.elements.removeElement(anObject);
  1059. return self}, function($ctx1) {$ctx1.fill(self,"removeElement:",{anObject:anObject},smalltalk.Organizer)})},
  1060. args: ["anObject"],
  1061. source: "removeElement: anObject\x0a\x09<self.elements.removeElement(anObject)>",
  1062. messageSends: [],
  1063. referencedClasses: []
  1064. }),
  1065. smalltalk.Organizer);
  1066. smalltalk.addClass('ClassOrganizer', smalltalk.Organizer, [], 'Kernel-Infrastructure');
  1067. smalltalk.ClassOrganizer.comment="I am an organizer specific to classes. I hold method categorization information for classes.";
  1068. smalltalk.addMethod(
  1069. smalltalk.method({
  1070. selector: "addElement:",
  1071. category: 'accessing',
  1072. fn: function (aString){
  1073. var self=this;
  1074. function $ProtocolAdded(){return smalltalk.ProtocolAdded||(typeof ProtocolAdded=="undefined"?nil:ProtocolAdded)}
  1075. function $SystemAnnouncer(){return smalltalk.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  1076. return smalltalk.withContext(function($ctx1) {
  1077. var $1,$2;
  1078. smalltalk.ClassOrganizer.superclass.fn.prototype._addElement_.apply(_st(self), [aString]);
  1079. $1=_st($ProtocolAdded())._new();
  1080. _st($1)._protocol_(aString);
  1081. _st($1)._theClass_(self._theClass());
  1082. $2=_st($1)._yourself();
  1083. _st(_st($SystemAnnouncer())._current())._announce_($2);
  1084. return self}, function($ctx1) {$ctx1.fill(self,"addElement:",{aString:aString},smalltalk.ClassOrganizer)})},
  1085. args: ["aString"],
  1086. 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)",
  1087. messageSends: ["addElement:", "announce:", "protocol:", "new", "theClass:", "theClass", "yourself", "current"],
  1088. referencedClasses: ["ProtocolAdded", "SystemAnnouncer"]
  1089. }),
  1090. smalltalk.ClassOrganizer);
  1091. smalltalk.addMethod(
  1092. smalltalk.method({
  1093. selector: "removeElement:",
  1094. category: 'accessing',
  1095. fn: function (aString){
  1096. var self=this;
  1097. function $ProtocolRemoved(){return smalltalk.ProtocolRemoved||(typeof ProtocolRemoved=="undefined"?nil:ProtocolRemoved)}
  1098. function $SystemAnnouncer(){return smalltalk.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  1099. return smalltalk.withContext(function($ctx1) {
  1100. var $1,$2;
  1101. smalltalk.ClassOrganizer.superclass.fn.prototype._removeElement_.apply(_st(self), [aString]);
  1102. $1=_st($ProtocolRemoved())._new();
  1103. _st($1)._protocol_(aString);
  1104. _st($1)._theClass_(self._theClass());
  1105. $2=_st($1)._yourself();
  1106. _st(_st($SystemAnnouncer())._current())._announce_($2);
  1107. return self}, function($ctx1) {$ctx1.fill(self,"removeElement:",{aString:aString},smalltalk.ClassOrganizer)})},
  1108. args: ["aString"],
  1109. 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)",
  1110. messageSends: ["removeElement:", "announce:", "protocol:", "new", "theClass:", "theClass", "yourself", "current"],
  1111. referencedClasses: ["ProtocolRemoved", "SystemAnnouncer"]
  1112. }),
  1113. smalltalk.ClassOrganizer);
  1114. smalltalk.addMethod(
  1115. smalltalk.method({
  1116. selector: "theClass",
  1117. category: 'accessing',
  1118. fn: function (){
  1119. var self=this;
  1120. return smalltalk.withContext(function($ctx1) {
  1121. return self.theClass ;
  1122. return self}, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ClassOrganizer)})},
  1123. args: [],
  1124. source: "theClass\x0a\x09< return self.theClass >",
  1125. messageSends: [],
  1126. referencedClasses: []
  1127. }),
  1128. smalltalk.ClassOrganizer);
  1129. smalltalk.addClass('PackageOrganizer', smalltalk.Organizer, [], 'Kernel-Infrastructure');
  1130. smalltalk.PackageOrganizer.comment="I am an organizer specific to packages. I hold classes categorization information.";
  1131. smalltalk.addClass('Package', smalltalk.Object, ['extension'], 'Kernel-Infrastructure');
  1132. smalltalk.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'";
  1133. smalltalk.addMethod(
  1134. smalltalk.method({
  1135. selector: "classes",
  1136. category: 'classes',
  1137. fn: function (){
  1138. var self=this;
  1139. return smalltalk.withContext(function($ctx1) {
  1140. var $1;
  1141. $1=_st(self._organization())._elements();
  1142. return $1;
  1143. }, function($ctx1) {$ctx1.fill(self,"classes",{},smalltalk.Package)})},
  1144. args: [],
  1145. source: "classes\x0a\x09^ self organization elements",
  1146. messageSends: ["elements", "organization"],
  1147. referencedClasses: []
  1148. }),
  1149. smalltalk.Package);
  1150. smalltalk.addMethod(
  1151. smalltalk.method({
  1152. selector: "isPackage",
  1153. category: 'testing',
  1154. fn: function (){
  1155. var self=this;
  1156. return smalltalk.withContext(function($ctx1) {
  1157. return true;
  1158. }, function($ctx1) {$ctx1.fill(self,"isPackage",{},smalltalk.Package)})},
  1159. args: [],
  1160. source: "isPackage\x0a\x09^ true",
  1161. messageSends: [],
  1162. referencedClasses: []
  1163. }),
  1164. smalltalk.Package);
  1165. smalltalk.addMethod(
  1166. smalltalk.method({
  1167. selector: "loadDependencies",
  1168. category: 'dependencies',
  1169. fn: function (){
  1170. var self=this;
  1171. var classes,packages;
  1172. return smalltalk.withContext(function($ctx1) {
  1173. var $2,$3,$1;
  1174. classes=self._loadDependencyClasses();
  1175. $2=_st(_st(classes)._collect_((function(each){
  1176. return smalltalk.withContext(function($ctx2) {
  1177. return _st(each)._package();
  1178. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._asSet();
  1179. _st($2)._remove_ifAbsent_(self,(function(){
  1180. return smalltalk.withContext(function($ctx2) {
  1181. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1182. $3=_st($2)._yourself();
  1183. $1=$3;
  1184. return $1;
  1185. }, function($ctx1) {$ctx1.fill(self,"loadDependencies",{classes:classes,packages:packages},smalltalk.Package)})},
  1186. args: [],
  1187. 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",
  1188. messageSends: ["loadDependencyClasses", "remove:ifAbsent:", "asSet", "collect:", "package", "yourself"],
  1189. referencedClasses: []
  1190. }),
  1191. smalltalk.Package);
  1192. smalltalk.addMethod(
  1193. smalltalk.method({
  1194. selector: "loadDependencyClasses",
  1195. category: 'dependencies',
  1196. fn: function (){
  1197. var self=this;
  1198. var starCategoryName;
  1199. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1200. return smalltalk.withContext(function($ctx1) {
  1201. var $2,$3,$1;
  1202. starCategoryName="*".__comma(self._name());
  1203. $2=_st(_st(self._classes())._collect_((function(each){
  1204. return smalltalk.withContext(function($ctx2) {
  1205. return _st(each)._superclass();
  1206. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._asSet();
  1207. _st($2)._remove_ifAbsent_(nil,(function(){
  1208. return smalltalk.withContext(function($ctx2) {
  1209. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1210. _st($2)._addAll_(_st(_st(_st($Smalltalk())._current())._classes())._select_((function(each){
  1211. return smalltalk.withContext(function($ctx2) {
  1212. return _st(_st(each)._protocols())._includes_(starCategoryName);
  1213. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})));
  1214. $3=_st($2)._yourself();
  1215. $1=$3;
  1216. return $1;
  1217. }, function($ctx1) {$ctx1.fill(self,"loadDependencyClasses",{starCategoryName:starCategoryName},smalltalk.Package)})},
  1218. args: [],
  1219. 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 current classes select: [ :each | each protocols includes: starCategoryName ]);\x0a\x09\x09yourself",
  1220. messageSends: [",", "name", "remove:ifAbsent:", "asSet", "collect:", "superclass", "classes", "addAll:", "select:", "includes:", "protocols", "current", "yourself"],
  1221. referencedClasses: ["Smalltalk"]
  1222. }),
  1223. smalltalk.Package);
  1224. smalltalk.addMethod(
  1225. smalltalk.method({
  1226. selector: "name",
  1227. category: 'accessing',
  1228. fn: function (){
  1229. var self=this;
  1230. return smalltalk.withContext(function($ctx1) {
  1231. return self.pkgName;
  1232. return self}, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.Package)})},
  1233. args: [],
  1234. source: "name\x0a\x09<return self.pkgName>",
  1235. messageSends: [],
  1236. referencedClasses: []
  1237. }),
  1238. smalltalk.Package);
  1239. smalltalk.addMethod(
  1240. smalltalk.method({
  1241. selector: "name:",
  1242. category: 'accessing',
  1243. fn: function (aString){
  1244. var self=this;
  1245. return smalltalk.withContext(function($ctx1) {
  1246. self.pkgName = aString;
  1247. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.Package)})},
  1248. args: ["aString"],
  1249. source: "name: aString\x0a\x09<self.pkgName = aString>",
  1250. messageSends: [],
  1251. referencedClasses: []
  1252. }),
  1253. smalltalk.Package);
  1254. smalltalk.addMethod(
  1255. smalltalk.method({
  1256. selector: "organization",
  1257. category: 'accessing',
  1258. fn: function (){
  1259. var self=this;
  1260. return smalltalk.withContext(function($ctx1) {
  1261. var $1;
  1262. $1=self._basicAt_("organization");
  1263. return $1;
  1264. }, function($ctx1) {$ctx1.fill(self,"organization",{},smalltalk.Package)})},
  1265. args: [],
  1266. source: "organization\x0a\x09^ self basicAt: 'organization'",
  1267. messageSends: ["basicAt:"],
  1268. referencedClasses: []
  1269. }),
  1270. smalltalk.Package);
  1271. smalltalk.addMethod(
  1272. smalltalk.method({
  1273. selector: "printOn:",
  1274. category: 'printing',
  1275. fn: function (aStream){
  1276. var self=this;
  1277. return smalltalk.withContext(function($ctx1) {
  1278. var $1,$2;
  1279. smalltalk.Package.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1280. $1=aStream;
  1281. _st($1)._nextPutAll_(" (");
  1282. _st($1)._nextPutAll_(self._name());
  1283. $2=_st($1)._nextPutAll_(")");
  1284. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.Package)})},
  1285. args: ["aStream"],
  1286. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: ' (';\x0a\x09\x09nextPutAll: self name;\x0a\x09\x09nextPutAll: ')'",
  1287. messageSends: ["printOn:", "nextPutAll:", "name"],
  1288. referencedClasses: []
  1289. }),
  1290. smalltalk.Package);
  1291. smalltalk.addMethod(
  1292. smalltalk.method({
  1293. selector: "setupClasses",
  1294. category: 'classes',
  1295. fn: function (){
  1296. var self=this;
  1297. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  1298. return smalltalk.withContext(function($ctx1) {
  1299. var $1,$2;
  1300. $1=self._classes();
  1301. _st($1)._do_((function(each){
  1302. return smalltalk.withContext(function($ctx2) {
  1303. return _st(_st($ClassBuilder())._new())._setupClass_(each);
  1304. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1305. $2=_st($1)._do_((function(each){
  1306. return smalltalk.withContext(function($ctx2) {
  1307. return _st(each)._initialize();
  1308. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1309. return self}, function($ctx1) {$ctx1.fill(self,"setupClasses",{},smalltalk.Package)})},
  1310. args: [],
  1311. source: "setupClasses\x0a\x09self classes\x0a\x09\x09do: [ :each | ClassBuilder new setupClass: each ];\x0a\x09\x09do: [ :each | each initialize ]",
  1312. messageSends: ["do:", "setupClass:", "new", "classes", "initialize"],
  1313. referencedClasses: ["ClassBuilder"]
  1314. }),
  1315. smalltalk.Package);
  1316. smalltalk.addMethod(
  1317. smalltalk.method({
  1318. selector: "sortedClasses",
  1319. category: 'classes',
  1320. fn: function (){
  1321. var self=this;
  1322. return smalltalk.withContext(function($ctx1) {
  1323. var $1;
  1324. $1=_st(self._class())._sortedClasses_(self._classes());
  1325. return $1;
  1326. }, function($ctx1) {$ctx1.fill(self,"sortedClasses",{},smalltalk.Package)})},
  1327. args: [],
  1328. 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",
  1329. messageSends: ["sortedClasses:", "classes", "class"],
  1330. referencedClasses: []
  1331. }),
  1332. smalltalk.Package);
  1333. smalltalk.addMethod(
  1334. smalltalk.method({
  1335. selector: "withDefaultTransport",
  1336. category: 'accessing',
  1337. fn: function (){
  1338. var self=this;
  1339. return smalltalk.withContext(function($ctx1) {
  1340. return self.withDefaultTransport();
  1341. return self}, function($ctx1) {$ctx1.fill(self,"withDefaultTransport",{},smalltalk.Package)})},
  1342. args: [],
  1343. source: "withDefaultTransport\x0a\x09<return self.withDefaultTransport()>",
  1344. messageSends: [],
  1345. referencedClasses: []
  1346. }),
  1347. smalltalk.Package);
  1348. smalltalk.Package.klass.iVarNames = ['defaultCommitPathJs','defaultCommitPathSt'];
  1349. smalltalk.addMethod(
  1350. smalltalk.method({
  1351. selector: "load:",
  1352. category: 'loading-storing',
  1353. fn: function (aPackageName){
  1354. var self=this;
  1355. return smalltalk.withContext(function($ctx1) {
  1356. self._deprecatedAPI();
  1357. self._load_prefix_(aPackageName,_st(self._defaultCommitPathJs()).__comma("/"));
  1358. return self}, function($ctx1) {$ctx1.fill(self,"load:",{aPackageName:aPackageName},smalltalk.Package.klass)})},
  1359. args: ["aPackageName"],
  1360. source: "load: aPackageName\x0a\x09self deprecatedAPI.\x0a\x09self load: aPackageName prefix: self defaultCommitPathJs, '/'",
  1361. messageSends: ["deprecatedAPI", "load:prefix:", ",", "defaultCommitPathJs"],
  1362. referencedClasses: []
  1363. }),
  1364. smalltalk.Package.klass);
  1365. smalltalk.addMethod(
  1366. smalltalk.method({
  1367. selector: "load:prefix:",
  1368. category: 'loading-storing',
  1369. fn: function (aPackageName,aPrefix){
  1370. var self=this;
  1371. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  1372. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1373. return smalltalk.withContext(function($ctx1) {
  1374. self._deprecatedAPI();
  1375. _st($PlatformInterface())._ajax_(smalltalk.HashedCollection._from_(["url".__minus_gt(_st(_st(aPrefix).__comma(aPackageName)).__comma(".js")),"dataType".__minus_gt("script"),"success".__minus_gt((function(){
  1376. return smalltalk.withContext(function($ctx2) {
  1377. return _st(_st($Package())._named_(aPackageName))._setupClasses();
  1378. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
  1379. return self}, function($ctx1) {$ctx1.fill(self,"load:prefix:",{aPackageName:aPackageName,aPrefix:aPrefix},smalltalk.Package.klass)})},
  1380. args: ["aPackageName", "aPrefix"],
  1381. source: "load: aPackageName prefix: aPrefix\x0a\x09self deprecatedAPI.\x0a\x09PlatformInterface ajax: #{\x0a\x09\x09'url' -> (aPrefix , aPackageName , '.js').\x0a\x09\x09'dataType' -> 'script'.\x0a\x09\x09'success' -> [\x0a\x09\x09\x09(Package named: aPackageName) setupClasses ]\x0a\x09}",
  1382. messageSends: ["deprecatedAPI", "ajax:", "->", ",", "setupClasses", "named:"],
  1383. referencedClasses: ["Package", "PlatformInterface"]
  1384. }),
  1385. smalltalk.Package.klass);
  1386. smalltalk.addMethod(
  1387. smalltalk.method({
  1388. selector: "named:",
  1389. category: 'accessing',
  1390. fn: function (aPackageName){
  1391. var self=this;
  1392. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1393. return smalltalk.withContext(function($ctx1) {
  1394. var $1;
  1395. $1=_st(_st($Smalltalk())._current())._packageAt_(aPackageName);
  1396. return $1;
  1397. }, function($ctx1) {$ctx1.fill(self,"named:",{aPackageName:aPackageName},smalltalk.Package.klass)})},
  1398. args: ["aPackageName"],
  1399. source: "named: aPackageName\x0a\x0a\x09^Smalltalk current packageAt: aPackageName",
  1400. messageSends: ["packageAt:", "current"],
  1401. referencedClasses: ["Smalltalk"]
  1402. }),
  1403. smalltalk.Package.klass);
  1404. smalltalk.addMethod(
  1405. smalltalk.method({
  1406. selector: "named:ifAbsent:",
  1407. category: 'accessing',
  1408. fn: function (aPackageName,aBlock){
  1409. var self=this;
  1410. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1411. return smalltalk.withContext(function($ctx1) {
  1412. var $1;
  1413. $1=_st(_st($Smalltalk())._current())._packageAt_ifAbsent_(aPackageName,aBlock);
  1414. return $1;
  1415. }, function($ctx1) {$ctx1.fill(self,"named:ifAbsent:",{aPackageName:aPackageName,aBlock:aBlock},smalltalk.Package.klass)})},
  1416. args: ["aPackageName", "aBlock"],
  1417. source: "named: aPackageName ifAbsent: aBlock\x0a\x0a\x09^Smalltalk current packageAt: aPackageName ifAbsent: aBlock",
  1418. messageSends: ["packageAt:ifAbsent:", "current"],
  1419. referencedClasses: ["Smalltalk"]
  1420. }),
  1421. smalltalk.Package.klass);
  1422. smalltalk.addMethod(
  1423. smalltalk.method({
  1424. selector: "sortedClasses:",
  1425. category: 'sorting',
  1426. fn: function (classes){
  1427. var self=this;
  1428. var children,others,nodes,expandedClasses;
  1429. function $ClassSorterNode(){return smalltalk.ClassSorterNode||(typeof ClassSorterNode=="undefined"?nil:ClassSorterNode)}
  1430. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1431. return smalltalk.withContext(function($ctx1) {
  1432. var $1,$2;
  1433. children=[];
  1434. others=[];
  1435. _st(classes)._do_((function(each){
  1436. return smalltalk.withContext(function($ctx2) {
  1437. $1=_st(classes)._includes_(_st(each)._superclass());
  1438. if(smalltalk.assert($1)){
  1439. return _st(others)._add_(each);
  1440. } else {
  1441. return _st(children)._add_(each);
  1442. };
  1443. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1444. nodes=_st(children)._collect_((function(each){
  1445. return smalltalk.withContext(function($ctx2) {
  1446. return _st($ClassSorterNode())._on_classes_level_(each,others,(0));
  1447. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1448. nodes=_st(nodes)._sorted_((function(a,b){
  1449. return smalltalk.withContext(function($ctx2) {
  1450. return _st(_st(_st(a)._theClass())._name()).__lt_eq(_st(_st(b)._theClass())._name());
  1451. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
  1452. expandedClasses=_st($Array())._new();
  1453. _st(nodes)._do_((function(aNode){
  1454. return smalltalk.withContext(function($ctx2) {
  1455. return _st(aNode)._traverseClassesWith_(expandedClasses);
  1456. }, function($ctx2) {$ctx2.fillBlock({aNode:aNode},$ctx1)})}));
  1457. $2=expandedClasses;
  1458. return $2;
  1459. }, function($ctx1) {$ctx1.fill(self,"sortedClasses:",{classes:classes,children:children,others:others,nodes:nodes,expandedClasses:expandedClasses},smalltalk.Package.klass)})},
  1460. args: ["classes"],
  1461. 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",
  1462. messageSends: ["do:", "ifFalse:ifTrue:", "add:", "includes:", "superclass", "collect:", "on:classes:level:", "sorted:", "<=", "name", "theClass", "new", "traverseClassesWith:"],
  1463. referencedClasses: ["ClassSorterNode", "Array"]
  1464. }),
  1465. smalltalk.Package.klass);
  1466. smalltalk.addClass('PlatformInterface', smalltalk.Object, [], 'Kernel-Infrastructure');
  1467. smalltalk.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 }.\x0a";
  1468. smalltalk.PlatformInterface.klass.iVarNames = ['worker'];
  1469. smalltalk.addMethod(
  1470. smalltalk.method({
  1471. selector: "ajax:",
  1472. category: 'actions',
  1473. fn: function (anObject){
  1474. var self=this;
  1475. return smalltalk.withContext(function($ctx1) {
  1476. var $2,$1;
  1477. $2=self["@worker"];
  1478. if(($receiver = $2) == nil || $receiver == undefined){
  1479. $1=self._error_("ajax: not available");
  1480. } else {
  1481. $1=_st(self["@worker"])._ajax_(anObject);
  1482. };
  1483. return $1;
  1484. }, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},smalltalk.PlatformInterface.klass)})},
  1485. args: ["anObject"],
  1486. source: "ajax: anObject\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker ajax: anObject ]\x0a\x09\x09ifNil: [ self error: 'ajax: not available' ]",
  1487. messageSends: ["ifNotNil:ifNil:", "ajax:", "error:"],
  1488. referencedClasses: []
  1489. }),
  1490. smalltalk.PlatformInterface.klass);
  1491. smalltalk.addMethod(
  1492. smalltalk.method({
  1493. selector: "alert:",
  1494. category: 'actions',
  1495. fn: function (aString){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx1) {
  1498. var $2,$1;
  1499. $2=self["@worker"];
  1500. if(($receiver = $2) == nil || $receiver == undefined){
  1501. $1=self._error_("alert: not available");
  1502. } else {
  1503. $1=_st(self["@worker"])._alert_(aString);
  1504. };
  1505. return $1;
  1506. }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},smalltalk.PlatformInterface.klass)})},
  1507. args: ["aString"],
  1508. source: "alert: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker alert: aString ]\x0a\x09\x09ifNil: [ self error: 'alert: not available' ]",
  1509. messageSends: ["ifNotNil:ifNil:", "alert:", "error:"],
  1510. referencedClasses: []
  1511. }),
  1512. smalltalk.PlatformInterface.klass);
  1513. smalltalk.addMethod(
  1514. smalltalk.method({
  1515. selector: "confirm:",
  1516. category: 'actions',
  1517. fn: function (aString){
  1518. var self=this;
  1519. return smalltalk.withContext(function($ctx1) {
  1520. var $2,$1;
  1521. $2=self["@worker"];
  1522. if(($receiver = $2) == nil || $receiver == undefined){
  1523. $1=self._error_("confirm: not available");
  1524. } else {
  1525. $1=_st(self["@worker"])._confirm_(aString);
  1526. };
  1527. return $1;
  1528. }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},smalltalk.PlatformInterface.klass)})},
  1529. args: ["aString"],
  1530. source: "confirm: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker confirm: aString ]\x0a\x09\x09ifNil: [ self error: 'confirm: not available' ]",
  1531. messageSends: ["ifNotNil:ifNil:", "confirm:", "error:"],
  1532. referencedClasses: []
  1533. }),
  1534. smalltalk.PlatformInterface.klass);
  1535. smalltalk.addMethod(
  1536. smalltalk.method({
  1537. selector: "existsGlobal:",
  1538. category: 'actions',
  1539. fn: function (aString){
  1540. var self=this;
  1541. return smalltalk.withContext(function($ctx1) {
  1542. var f = new Function('aString',
  1543. 'if (/^[0-9]/.test(aString) || !/^[\\w_]+$/.test(aString))\n'+
  1544. ' return false;\n'+
  1545. 'try { eval(aString); return true; } catch (ex) {}\n'+
  1546. 'return false;');
  1547. return f(aString);;
  1548. return self}, function($ctx1) {$ctx1.fill(self,"existsGlobal:",{aString:aString},smalltalk.PlatformInterface.klass)})},
  1549. args: ["aString"],
  1550. source: "existsGlobal: aString\x0a<\x0a\x09var f = new Function('aString',\x0a\x09'if (/^[0-9]/.test(aString) || !/^[\x5c\x5cw_]+$/.test(aString))\x5cn'+\x0a\x09'\x09return false;\x5cn'+\x0a\x09'try { eval(aString); return true; } catch (ex) {}\x5cn'+\x0a\x09'return false;');\x0a\x09return f(aString);\x0a>",
  1551. messageSends: [],
  1552. referencedClasses: []
  1553. }),
  1554. smalltalk.PlatformInterface.klass);
  1555. smalltalk.addMethod(
  1556. smalltalk.method({
  1557. selector: "initialize",
  1558. category: 'initialization',
  1559. fn: function (){
  1560. var self=this;
  1561. var candidate;
  1562. function $BrowserInterface(){return smalltalk.BrowserInterface||(typeof BrowserInterface=="undefined"?nil:BrowserInterface)}
  1563. return smalltalk.withContext(function($ctx1) {
  1564. var $1,$2,$3;
  1565. smalltalk.PlatformInterface.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
  1566. $1=$BrowserInterface();
  1567. if(($receiver = $1) == nil || $receiver == undefined){
  1568. $1;
  1569. } else {
  1570. candidate=_st($BrowserInterface())._new();
  1571. candidate;
  1572. $2=_st(candidate)._isAvailable();
  1573. if(smalltalk.assert($2)){
  1574. self._setWorker_(candidate);
  1575. $3=self;
  1576. return $3;
  1577. };
  1578. };
  1579. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{candidate:candidate},smalltalk.PlatformInterface.klass)})},
  1580. args: [],
  1581. 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]",
  1582. messageSends: ["initialize", "ifNotNil:", "new", "ifTrue:", "setWorker:", "isAvailable"],
  1583. referencedClasses: ["BrowserInterface"]
  1584. }),
  1585. smalltalk.PlatformInterface.klass);
  1586. smalltalk.addMethod(
  1587. smalltalk.method({
  1588. selector: "prompt:",
  1589. category: 'actions',
  1590. fn: function (aString){
  1591. var self=this;
  1592. return smalltalk.withContext(function($ctx1) {
  1593. var $2,$1;
  1594. $2=self["@worker"];
  1595. if(($receiver = $2) == nil || $receiver == undefined){
  1596. $1=self._error_("prompt: not available");
  1597. } else {
  1598. $1=_st(self["@worker"])._prompt_(aString);
  1599. };
  1600. return $1;
  1601. }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},smalltalk.PlatformInterface.klass)})},
  1602. args: ["aString"],
  1603. source: "prompt: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker prompt: aString ]\x0a\x09\x09ifNil: [ self error: 'prompt: not available' ]",
  1604. messageSends: ["ifNotNil:ifNil:", "prompt:", "error:"],
  1605. referencedClasses: []
  1606. }),
  1607. smalltalk.PlatformInterface.klass);
  1608. smalltalk.addMethod(
  1609. smalltalk.method({
  1610. selector: "setWorker:",
  1611. category: 'accessing',
  1612. fn: function (anObject){
  1613. var self=this;
  1614. return smalltalk.withContext(function($ctx1) {
  1615. self["@worker"]=anObject;
  1616. return self}, function($ctx1) {$ctx1.fill(self,"setWorker:",{anObject:anObject},smalltalk.PlatformInterface.klass)})},
  1617. args: ["anObject"],
  1618. source: "setWorker: anObject\x0a\x09worker := anObject",
  1619. messageSends: [],
  1620. referencedClasses: []
  1621. }),
  1622. smalltalk.PlatformInterface.klass);
  1623. smalltalk.addClass('ProgressHandler', smalltalk.Object, [], 'Kernel-Infrastructure');
  1624. smalltalk.ProgressHandler.comment="I am used to manage progress in collection iterations, see `SequenceableCollection >> #do:displayingProgress:`.\x0a\x0aSubclasses of can register themselves as the current handler with\x0a`ProgressHandler class >> register`.\x0a\x0aThe default behavior is to simply iterate over the collection.";
  1625. smalltalk.addMethod(
  1626. smalltalk.method({
  1627. selector: "do:on:displaying:",
  1628. category: 'progress handling',
  1629. fn: function (aBlock,aCollection,aString){
  1630. var self=this;
  1631. return smalltalk.withContext(function($ctx1) {
  1632. _st(aCollection)._do_(aBlock);
  1633. return self}, function($ctx1) {$ctx1.fill(self,"do:on:displaying:",{aBlock:aBlock,aCollection:aCollection,aString:aString},smalltalk.ProgressHandler)})},
  1634. args: ["aBlock", "aCollection", "aString"],
  1635. source: "do: aBlock on: aCollection displaying: aString\x0a\x09aCollection do: aBlock",
  1636. messageSends: ["do:"],
  1637. referencedClasses: []
  1638. }),
  1639. smalltalk.ProgressHandler);
  1640. smalltalk.ProgressHandler.klass.iVarNames = ['current'];
  1641. smalltalk.addMethod(
  1642. smalltalk.method({
  1643. selector: "current",
  1644. category: 'accessing',
  1645. fn: function (){
  1646. var self=this;
  1647. return smalltalk.withContext(function($ctx1) {
  1648. var $2,$1;
  1649. $2=self["@current"];
  1650. if(($receiver = $2) == nil || $receiver == undefined){
  1651. self["@current"]=self._new();
  1652. $1=self["@current"];
  1653. } else {
  1654. $1=$2;
  1655. };
  1656. return $1;
  1657. }, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.ProgressHandler.klass)})},
  1658. args: [],
  1659. source: "current\x0a\x09^current ifNil: [ current := self new ]",
  1660. messageSends: ["ifNil:", "new"],
  1661. referencedClasses: []
  1662. }),
  1663. smalltalk.ProgressHandler.klass);
  1664. smalltalk.addMethod(
  1665. smalltalk.method({
  1666. selector: "initialize",
  1667. category: 'initialization',
  1668. fn: function (){
  1669. var self=this;
  1670. return smalltalk.withContext(function($ctx1) {
  1671. self._register();
  1672. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ProgressHandler.klass)})},
  1673. args: [],
  1674. source: "initialize\x0a\x09self register",
  1675. messageSends: ["register"],
  1676. referencedClasses: []
  1677. }),
  1678. smalltalk.ProgressHandler.klass);
  1679. smalltalk.addMethod(
  1680. smalltalk.method({
  1681. selector: "register",
  1682. category: 'initialization',
  1683. fn: function (){
  1684. var self=this;
  1685. function $ProgressHandler(){return smalltalk.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  1686. return smalltalk.withContext(function($ctx1) {
  1687. _st($ProgressHandler())._setCurrent_(self._new());
  1688. return self}, function($ctx1) {$ctx1.fill(self,"register",{},smalltalk.ProgressHandler.klass)})},
  1689. args: [],
  1690. source: "register\x0a\x09ProgressHandler setCurrent: self new",
  1691. messageSends: ["setCurrent:", "new"],
  1692. referencedClasses: ["ProgressHandler"]
  1693. }),
  1694. smalltalk.ProgressHandler.klass);
  1695. smalltalk.addMethod(
  1696. smalltalk.method({
  1697. selector: "setCurrent:",
  1698. category: 'accessing',
  1699. fn: function (anHandler){
  1700. var self=this;
  1701. return smalltalk.withContext(function($ctx1) {
  1702. self["@current"]=anHandler;
  1703. return self}, function($ctx1) {$ctx1.fill(self,"setCurrent:",{anHandler:anHandler},smalltalk.ProgressHandler.klass)})},
  1704. args: ["anHandler"],
  1705. source: "setCurrent: anHandler\x0a\x09current := anHandler",
  1706. messageSends: [],
  1707. referencedClasses: []
  1708. }),
  1709. smalltalk.ProgressHandler.klass);
  1710. smalltalk.addClass('Smalltalk', smalltalk.Object, [], 'Kernel-Infrastructure');
  1711. smalltalk.Smalltalk.comment="I represent the global JavaScript variable `smalltalk` declared in `js/boot.js`.\x0a\x0a## API\x0a\x0aI have only one instance, accessed with class-side method `#current`.\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.";
  1712. smalltalk.addMethod(
  1713. smalltalk.method({
  1714. selector: "addGlobalJsVariable:",
  1715. category: 'globals',
  1716. fn: function (aString){
  1717. var self=this;
  1718. return smalltalk.withContext(function($ctx1) {
  1719. _st(self._globalJsVariables())._add_(aString);
  1720. return self}, function($ctx1) {$ctx1.fill(self,"addGlobalJsVariable:",{aString:aString},smalltalk.Smalltalk)})},
  1721. args: ["aString"],
  1722. source: "addGlobalJsVariable: aString\x0a\x09self globalJsVariables add: aString",
  1723. messageSends: ["add:", "globalJsVariables"],
  1724. referencedClasses: []
  1725. }),
  1726. smalltalk.Smalltalk);
  1727. smalltalk.addMethod(
  1728. smalltalk.method({
  1729. selector: "asSmalltalkException:",
  1730. category: 'error handling',
  1731. fn: function (anObject){
  1732. var self=this;
  1733. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  1734. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1735. return smalltalk.withContext(function($ctx1) {
  1736. var $2,$1;
  1737. $2=_st(self._isSmalltalkObject_(anObject))._and_((function(){
  1738. return smalltalk.withContext(function($ctx2) {
  1739. return _st(anObject)._isKindOf_($Error());
  1740. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1741. if(smalltalk.assert($2)){
  1742. $1=anObject;
  1743. } else {
  1744. $1=_st($JavaScriptException())._on_(anObject);
  1745. };
  1746. return $1;
  1747. }, function($ctx1) {$ctx1.fill(self,"asSmalltalkException:",{anObject:anObject},smalltalk.Smalltalk)})},
  1748. args: ["anObject"],
  1749. 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 ]",
  1750. messageSends: ["ifTrue:ifFalse:", "on:", "and:", "isKindOf:", "isSmalltalkObject:"],
  1751. referencedClasses: ["JavaScriptException", "Error"]
  1752. }),
  1753. smalltalk.Smalltalk);
  1754. smalltalk.addMethod(
  1755. smalltalk.method({
  1756. selector: "at:",
  1757. category: 'accessing',
  1758. fn: function (aString){
  1759. var self=this;
  1760. return smalltalk.withContext(function($ctx1) {
  1761. return self[aString];
  1762. return self}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.Smalltalk)})},
  1763. args: ["aString"],
  1764. source: "at: aString\x0a\x09<return self[aString]>",
  1765. messageSends: [],
  1766. referencedClasses: []
  1767. }),
  1768. smalltalk.Smalltalk);
  1769. smalltalk.addMethod(
  1770. smalltalk.method({
  1771. selector: "basicParse:",
  1772. category: 'private',
  1773. fn: function (aString){
  1774. var self=this;
  1775. return smalltalk.withContext(function($ctx1) {
  1776. return smalltalk.parser.parse(aString);
  1777. return self}, function($ctx1) {$ctx1.fill(self,"basicParse:",{aString:aString},smalltalk.Smalltalk)})},
  1778. args: ["aString"],
  1779. source: "basicParse: aString\x0a\x09<return smalltalk.parser.parse(aString)>",
  1780. messageSends: [],
  1781. referencedClasses: []
  1782. }),
  1783. smalltalk.Smalltalk);
  1784. smalltalk.addMethod(
  1785. smalltalk.method({
  1786. selector: "classes",
  1787. category: 'classes',
  1788. fn: function (){
  1789. var self=this;
  1790. return smalltalk.withContext(function($ctx1) {
  1791. return self.classes();
  1792. return self}, function($ctx1) {$ctx1.fill(self,"classes",{},smalltalk.Smalltalk)})},
  1793. args: [],
  1794. source: "classes\x0a\x09<return self.classes()>",
  1795. messageSends: [],
  1796. referencedClasses: []
  1797. }),
  1798. smalltalk.Smalltalk);
  1799. smalltalk.addMethod(
  1800. smalltalk.method({
  1801. selector: "createDefaultPackage:",
  1802. category: 'packages',
  1803. fn: function (packageName){
  1804. var self=this;
  1805. return smalltalk.withContext(function($ctx1) {
  1806. var $1;
  1807. $1=_st(self._createPackage_(packageName))._withDefaultTransport();
  1808. return $1;
  1809. }, function($ctx1) {$ctx1.fill(self,"createDefaultPackage:",{packageName:packageName},smalltalk.Smalltalk)})},
  1810. args: ["packageName"],
  1811. source: "createDefaultPackage: packageName\x0a\x09\x22Create and bind a new package with given name and default transport type and return it.\x22\x0a\x09^ (self createPackage: packageName) withDefaultTransport",
  1812. messageSends: ["withDefaultTransport", "createPackage:"],
  1813. referencedClasses: []
  1814. }),
  1815. smalltalk.Smalltalk);
  1816. smalltalk.addMethod(
  1817. smalltalk.method({
  1818. selector: "createPackage:",
  1819. category: 'private',
  1820. fn: function (packageName){
  1821. var self=this;
  1822. return smalltalk.withContext(function($ctx1) {
  1823. return smalltalk.addPackage(packageName);
  1824. return self}, function($ctx1) {$ctx1.fill(self,"createPackage:",{packageName:packageName},smalltalk.Smalltalk)})},
  1825. args: ["packageName"],
  1826. source: "createPackage: packageName\x0a\x09\x22Create and bind a new bare package with given name and return it.\x22\x0a\x09<return smalltalk.addPackage(packageName)>",
  1827. messageSends: [],
  1828. referencedClasses: []
  1829. }),
  1830. smalltalk.Smalltalk);
  1831. smalltalk.addMethod(
  1832. smalltalk.method({
  1833. selector: "createPackage:properties:",
  1834. category: 'private',
  1835. fn: function (packageName,aDict){
  1836. var self=this;
  1837. return smalltalk.withContext(function($ctx1) {
  1838. var $1,$2;
  1839. self._deprecatedAPI();
  1840. $1=_st(aDict)._isEmpty();
  1841. if(! smalltalk.assert($1)){
  1842. self._error_("createPackage:properties: called with nonempty properties");
  1843. };
  1844. $2=self._createPackage_(packageName);
  1845. return $2;
  1846. }, function($ctx1) {$ctx1.fill(self,"createPackage:properties:",{packageName:packageName,aDict:aDict},smalltalk.Smalltalk)})},
  1847. args: ["packageName", "aDict"],
  1848. 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",
  1849. messageSends: ["deprecatedAPI", "ifFalse:", "error:", "isEmpty", "createPackage:"],
  1850. referencedClasses: []
  1851. }),
  1852. smalltalk.Smalltalk);
  1853. smalltalk.addMethod(
  1854. smalltalk.method({
  1855. selector: "deleteClass:",
  1856. category: 'classes',
  1857. fn: function (aClass){
  1858. var self=this;
  1859. return smalltalk.withContext(function($ctx1) {
  1860. self.removeClass(aClass);
  1861. return self}, function($ctx1) {$ctx1.fill(self,"deleteClass:",{aClass:aClass},smalltalk.Smalltalk)})},
  1862. args: ["aClass"],
  1863. source: "deleteClass: aClass\x0a\x09\x22Deletes a class by deleting its binding only. Use #removeClass instead\x22\x0a\x09\x0a\x09<self.removeClass(aClass)>",
  1864. messageSends: [],
  1865. referencedClasses: []
  1866. }),
  1867. smalltalk.Smalltalk);
  1868. smalltalk.addMethod(
  1869. smalltalk.method({
  1870. selector: "deleteGlobalJsVariable:",
  1871. category: 'globals',
  1872. fn: function (aString){
  1873. var self=this;
  1874. return smalltalk.withContext(function($ctx1) {
  1875. _st(self._globalJsVariables())._remove_ifAbsent_(aString,(function(){
  1876. return smalltalk.withContext(function($ctx2) {
  1877. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1878. return self}, function($ctx1) {$ctx1.fill(self,"deleteGlobalJsVariable:",{aString:aString},smalltalk.Smalltalk)})},
  1879. args: ["aString"],
  1880. source: "deleteGlobalJsVariable: aString\x0a\x09self globalJsVariables remove: aString ifAbsent:[]",
  1881. messageSends: ["remove:ifAbsent:", "globalJsVariables"],
  1882. referencedClasses: []
  1883. }),
  1884. smalltalk.Smalltalk);
  1885. smalltalk.addMethod(
  1886. smalltalk.method({
  1887. selector: "deletePackage:",
  1888. category: 'packages',
  1889. fn: function (packageName){
  1890. var self=this;
  1891. return smalltalk.withContext(function($ctx1) {
  1892. delete smalltalk.packages[packageName];
  1893. return self}, function($ctx1) {$ctx1.fill(self,"deletePackage:",{packageName:packageName},smalltalk.Smalltalk)})},
  1894. args: ["packageName"],
  1895. 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]>",
  1896. messageSends: [],
  1897. referencedClasses: []
  1898. }),
  1899. smalltalk.Smalltalk);
  1900. smalltalk.addMethod(
  1901. smalltalk.method({
  1902. selector: "globalJsVariables",
  1903. category: 'globals',
  1904. fn: function (){
  1905. var self=this;
  1906. return smalltalk.withContext(function($ctx1) {
  1907. return self.globalJsVariables;
  1908. return self}, function($ctx1) {$ctx1.fill(self,"globalJsVariables",{},smalltalk.Smalltalk)})},
  1909. args: [],
  1910. source: "globalJsVariables\x0a\x09\x22Array of global JavaScript variables\x22\x0a\x09<return self.globalJsVariables>",
  1911. messageSends: [],
  1912. referencedClasses: []
  1913. }),
  1914. smalltalk.Smalltalk);
  1915. smalltalk.addMethod(
  1916. smalltalk.method({
  1917. selector: "isSmalltalkObject:",
  1918. category: 'testing',
  1919. fn: function (anObject){
  1920. var self=this;
  1921. return smalltalk.withContext(function($ctx1) {
  1922. return typeof anObject.klass !== 'undefined';
  1923. return self}, function($ctx1) {$ctx1.fill(self,"isSmalltalkObject:",{anObject:anObject},smalltalk.Smalltalk)})},
  1924. args: ["anObject"],
  1925. 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'>",
  1926. messageSends: [],
  1927. referencedClasses: []
  1928. }),
  1929. smalltalk.Smalltalk);
  1930. smalltalk.addMethod(
  1931. smalltalk.method({
  1932. selector: "packageAt:",
  1933. category: 'packages',
  1934. fn: function (packageName){
  1935. var self=this;
  1936. return smalltalk.withContext(function($ctx1) {
  1937. return self.packages[packageName];
  1938. return self}, function($ctx1) {$ctx1.fill(self,"packageAt:",{packageName:packageName},smalltalk.Smalltalk)})},
  1939. args: ["packageName"],
  1940. source: "packageAt: packageName\x0a\x09<return self.packages[packageName]>",
  1941. messageSends: [],
  1942. referencedClasses: []
  1943. }),
  1944. smalltalk.Smalltalk);
  1945. smalltalk.addMethod(
  1946. smalltalk.method({
  1947. selector: "packageAt:ifAbsent:",
  1948. category: 'packages',
  1949. fn: function (packageName,aBlock){
  1950. var self=this;
  1951. return smalltalk.withContext(function($ctx1) {
  1952. var $2,$1;
  1953. $2=self._packageAt_(packageName);
  1954. $1=_st($2)._ifNil_(aBlock);
  1955. return $1;
  1956. }, function($ctx1) {$ctx1.fill(self,"packageAt:ifAbsent:",{packageName:packageName,aBlock:aBlock},smalltalk.Smalltalk)})},
  1957. args: ["packageName", "aBlock"],
  1958. source: "packageAt: packageName ifAbsent: aBlock\x0a\x09^(self packageAt: packageName) ifNil: aBlock",
  1959. messageSends: ["ifNil:", "packageAt:"],
  1960. referencedClasses: []
  1961. }),
  1962. smalltalk.Smalltalk);
  1963. smalltalk.addMethod(
  1964. smalltalk.method({
  1965. selector: "packages",
  1966. category: 'packages',
  1967. fn: function (){
  1968. var self=this;
  1969. return smalltalk.withContext(function($ctx1) {
  1970. return self.packages.all();
  1971. return self}, function($ctx1) {$ctx1.fill(self,"packages",{},smalltalk.Smalltalk)})},
  1972. args: [],
  1973. source: "packages\x0a\x09\x22Return all Package instances in the system.\x22\x0a\x0a\x09<return self.packages.all()>",
  1974. messageSends: [],
  1975. referencedClasses: []
  1976. }),
  1977. smalltalk.Smalltalk);
  1978. smalltalk.addMethod(
  1979. smalltalk.method({
  1980. selector: "parse:",
  1981. category: 'accessing',
  1982. fn: function (aString){
  1983. var self=this;
  1984. var result;
  1985. return smalltalk.withContext(function($ctx1) {
  1986. var $2,$3,$1;
  1987. self._try_catch_((function(){
  1988. return smalltalk.withContext(function($ctx2) {
  1989. result=self._basicParse_(aString);
  1990. return result;
  1991. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(ex){
  1992. return smalltalk.withContext(function($ctx2) {
  1993. return _st(self._parseError_parsing_(ex,aString))._signal();
  1994. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  1995. $2=result;
  1996. _st($2)._source_(aString);
  1997. $3=_st($2)._yourself();
  1998. $1=$3;
  1999. return $1;
  2000. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString,result:result},smalltalk.Smalltalk)})},
  2001. args: ["aString"],
  2002. 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",
  2003. messageSends: ["try:catch:", "basicParse:", "signal", "parseError:parsing:", "source:", "yourself"],
  2004. referencedClasses: []
  2005. }),
  2006. smalltalk.Smalltalk);
  2007. smalltalk.addMethod(
  2008. smalltalk.method({
  2009. selector: "parseError:parsing:",
  2010. category: 'error handling',
  2011. fn: function (anException,aString){
  2012. var self=this;
  2013. function $ParseError(){return smalltalk.ParseError||(typeof ParseError=="undefined"?nil:ParseError)}
  2014. return smalltalk.withContext(function($ctx1) {
  2015. var $1;
  2016. $1=_st(_st($ParseError())._new())._messageText_(_st(_st(_st(_st("Parse error on line ".__comma(_st(anException)._basicAt_("line"))).__comma(" column ")).__comma(_st(anException)._basicAt_("column"))).__comma(" : Unexpected character ")).__comma(_st(anException)._basicAt_("found")));
  2017. return $1;
  2018. }, function($ctx1) {$ctx1.fill(self,"parseError:parsing:",{anException:anException,aString:aString},smalltalk.Smalltalk)})},
  2019. args: ["anException", "aString"],
  2020. 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')",
  2021. messageSends: ["messageText:", ",", "basicAt:", "new"],
  2022. referencedClasses: ["ParseError"]
  2023. }),
  2024. smalltalk.Smalltalk);
  2025. smalltalk.addMethod(
  2026. smalltalk.method({
  2027. selector: "pseudoVariableNames",
  2028. category: 'packages',
  2029. fn: function (){
  2030. var self=this;
  2031. return smalltalk.withContext(function($ctx1) {
  2032. var $1;
  2033. $1=["self", "super", "nil", "true", "false", "thisContext"];
  2034. return $1;
  2035. }, function($ctx1) {$ctx1.fill(self,"pseudoVariableNames",{},smalltalk.Smalltalk)})},
  2036. args: [],
  2037. source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')",
  2038. messageSends: [],
  2039. referencedClasses: []
  2040. }),
  2041. smalltalk.Smalltalk);
  2042. smalltalk.addMethod(
  2043. smalltalk.method({
  2044. selector: "readJSObject:",
  2045. category: 'accessing',
  2046. fn: function (anObject){
  2047. var self=this;
  2048. return smalltalk.withContext(function($ctx1) {
  2049. return self.readJSObject(anObject);
  2050. return self}, function($ctx1) {$ctx1.fill(self,"readJSObject:",{anObject:anObject},smalltalk.Smalltalk)})},
  2051. args: ["anObject"],
  2052. source: "readJSObject: anObject\x0a\x09<return self.readJSObject(anObject)>",
  2053. messageSends: [],
  2054. referencedClasses: []
  2055. }),
  2056. smalltalk.Smalltalk);
  2057. smalltalk.addMethod(
  2058. smalltalk.method({
  2059. selector: "removeClass:",
  2060. category: 'classes',
  2061. fn: function (aClass){
  2062. var self=this;
  2063. function $ClassRemoved(){return smalltalk.ClassRemoved||(typeof ClassRemoved=="undefined"?nil:ClassRemoved)}
  2064. function $SystemAnnouncer(){return smalltalk.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  2065. return smalltalk.withContext(function($ctx1) {
  2066. var $1,$2,$3;
  2067. $1=_st(aClass)._isMetaclass();
  2068. if(smalltalk.assert($1)){
  2069. self._error_(_st(_st(aClass)._asString()).__comma(" is a Metaclass and cannot be removed!"));
  2070. };
  2071. self._deleteClass_(aClass);
  2072. $2=_st($ClassRemoved())._new();
  2073. _st($2)._theClass_(aClass);
  2074. $3=_st($2)._yourself();
  2075. _st(_st($SystemAnnouncer())._current())._announce_($3);
  2076. return self}, function($ctx1) {$ctx1.fill(self,"removeClass:",{aClass:aClass},smalltalk.Smalltalk)})},
  2077. args: ["aClass"],
  2078. 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)",
  2079. messageSends: ["ifTrue:", "error:", ",", "asString", "isMetaclass", "deleteClass:", "announce:", "theClass:", "new", "yourself", "current"],
  2080. referencedClasses: ["ClassRemoved", "SystemAnnouncer"]
  2081. }),
  2082. smalltalk.Smalltalk);
  2083. smalltalk.addMethod(
  2084. smalltalk.method({
  2085. selector: "removePackage:",
  2086. category: 'packages',
  2087. fn: function (packageName){
  2088. var self=this;
  2089. var pkg;
  2090. return smalltalk.withContext(function($ctx1) {
  2091. pkg=self._packageAt_ifAbsent_(packageName,(function(){
  2092. return smalltalk.withContext(function($ctx2) {
  2093. return self._error_("Missing package: ".__comma(packageName));
  2094. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2095. _st(_st(pkg)._classes())._do_((function(each){
  2096. return smalltalk.withContext(function($ctx2) {
  2097. return self._removeClass_(each);
  2098. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  2099. self._deletePackage_(packageName);
  2100. return self}, function($ctx1) {$ctx1.fill(self,"removePackage:",{packageName:packageName,pkg:pkg},smalltalk.Smalltalk)})},
  2101. args: ["packageName"],
  2102. 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",
  2103. messageSends: ["packageAt:ifAbsent:", "error:", ",", "do:", "removeClass:", "classes", "deletePackage:"],
  2104. referencedClasses: []
  2105. }),
  2106. smalltalk.Smalltalk);
  2107. smalltalk.addMethod(
  2108. smalltalk.method({
  2109. selector: "renamePackage:to:",
  2110. category: 'packages',
  2111. fn: function (packageName,newName){
  2112. var self=this;
  2113. var pkg;
  2114. return smalltalk.withContext(function($ctx1) {
  2115. var $1;
  2116. pkg=self._packageAt_ifAbsent_(packageName,(function(){
  2117. return smalltalk.withContext(function($ctx2) {
  2118. return self._error_("Missing package: ".__comma(packageName));
  2119. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2120. $1=self._packageAt_(newName);
  2121. if(($receiver = $1) == nil || $receiver == undefined){
  2122. $1;
  2123. } else {
  2124. self._error_("Already exists a package called: ".__comma(newName));
  2125. };
  2126. _st(self._basicAt_("packages"))._at_put_(newName,pkg);
  2127. _st(pkg)._name_(newName);
  2128. self._deletePackage_(packageName);
  2129. return self}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},smalltalk.Smalltalk)})},
  2130. args: ["packageName", "newName"],
  2131. 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 basicAt: 'packages') at: newName put: pkg.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
  2132. messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "basicAt:", "name:", "deletePackage:"],
  2133. referencedClasses: []
  2134. }),
  2135. smalltalk.Smalltalk);
  2136. smalltalk.addMethod(
  2137. smalltalk.method({
  2138. selector: "reservedWords",
  2139. category: 'accessing',
  2140. fn: function (){
  2141. var self=this;
  2142. return smalltalk.withContext(function($ctx1) {
  2143. return self.reservedWords;
  2144. return self}, function($ctx1) {$ctx1.fill(self,"reservedWords",{},smalltalk.Smalltalk)})},
  2145. args: [],
  2146. source: "reservedWords\x0a\x09\x22JavaScript reserved words\x22\x0a\x09<return self.reservedWords>",
  2147. messageSends: [],
  2148. referencedClasses: []
  2149. }),
  2150. smalltalk.Smalltalk);
  2151. smalltalk.addMethod(
  2152. smalltalk.method({
  2153. selector: "version",
  2154. category: 'accessing',
  2155. fn: function (){
  2156. var self=this;
  2157. return smalltalk.withContext(function($ctx1) {
  2158. return "0.11.0";
  2159. }, function($ctx1) {$ctx1.fill(self,"version",{},smalltalk.Smalltalk)})},
  2160. args: [],
  2161. source: "version\x0a\x09\x22Answer the version string of Amber\x22\x0a\x09\x0a\x09^ '0.11.0'",
  2162. messageSends: [],
  2163. referencedClasses: []
  2164. }),
  2165. smalltalk.Smalltalk);
  2166. smalltalk.Smalltalk.klass.iVarNames = ['current'];
  2167. smalltalk.addMethod(
  2168. smalltalk.method({
  2169. selector: "current",
  2170. category: 'accessing',
  2171. fn: function (){
  2172. var self=this;
  2173. return smalltalk.withContext(function($ctx1) {
  2174. return smalltalk;
  2175. return self}, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.Smalltalk.klass)})},
  2176. args: [],
  2177. source: "current\x0a\x09<return smalltalk>",
  2178. messageSends: [],
  2179. referencedClasses: []
  2180. }),
  2181. smalltalk.Smalltalk.klass);
  2182. smalltalk.addMethod(
  2183. smalltalk.method({
  2184. selector: "do:displayingProgress:",
  2185. category: '*Kernel-Infrastructure',
  2186. fn: function (aBlock,aString){
  2187. var self=this;
  2188. function $ProgressHandler(){return smalltalk.ProgressHandler||(typeof ProgressHandler=="undefined"?nil:ProgressHandler)}
  2189. return smalltalk.withContext(function($ctx1) {
  2190. _st(_st($ProgressHandler())._current())._do_on_displaying_(aBlock,self,aString);
  2191. return self}, function($ctx1) {$ctx1.fill(self,"do:displayingProgress:",{aBlock:aBlock,aString:aString},smalltalk.SequenceableCollection)})},
  2192. args: ["aBlock", "aString"],
  2193. source: "do: aBlock displayingProgress: aString\x0a\x09ProgressHandler current\x0a\x09\x09do: aBlock on: self displaying: aString",
  2194. messageSends: ["do:on:displaying:", "current"],
  2195. referencedClasses: ["ProgressHandler"]
  2196. }),
  2197. smalltalk.SequenceableCollection);
  2198. smalltalk.addMethod(
  2199. smalltalk.method({
  2200. selector: "asJavaScriptSelector",
  2201. category: '*Kernel-Infrastructure',
  2202. fn: function (){
  2203. var self=this;
  2204. return smalltalk.withContext(function($ctx1) {
  2205. var $1;
  2206. $1=self._replace_with_("^([a-zA-Z0-9]*).*$","$1");
  2207. return $1;
  2208. }, function($ctx1) {$ctx1.fill(self,"asJavaScriptSelector",{},smalltalk.String)})},
  2209. args: [],
  2210. source: "asJavaScriptSelector\x0a\x09\x22Return first keyword of the selector, without trailing colon.\x22\x0a\x09^self replace: '^([a-zA-Z0-9]*).*$' with: '$1'",
  2211. messageSends: ["replace:with:"],
  2212. referencedClasses: []
  2213. }),
  2214. smalltalk.String);
  2215. });