Kernel-Methods.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  1. define("amber_core/Kernel-Methods", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Kernel-Methods');
  4. smalltalk.packages["Kernel-Methods"].transport = {"type":"amd","amdNamespace":"amber_core"};
  5. smalltalk.addClass('BlockClosure', globals.Object, [], 'Kernel-Methods');
  6. globals.BlockClosure.comment="I represent a lexical closure.\x0aI am is directly mapped to JavaScript Function.\x0a\x0a## API\x0a\x0a1. Evaluation\x0a\x0a My instances get evaluated with the `#value*` methods in the 'evaluating' protocol.\x0a\x0a Example: ` [ :x | x + 1 ] value: 3 \x22Answers 4\x22 `\x0a\x0a2. Control structures\x0a\x0a Blocks are used (together with `Boolean`) for control structures (methods in the `controlling` protocol).\x0a\x0a Example: `aBlock whileTrue: [ ... ]`\x0a\x0a3. Error handling\x0a\x0a I provide the `#on:do:` method for handling exceptions.\x0a\x0a Example: ` aBlock on: MessageNotUnderstood do: [ :ex | ... ] `";
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "applyTo:arguments:",
  10. protocol: 'evaluating',
  11. fn: function (anObject,aCollection){
  12. var self=this;
  13. return smalltalk.withContext(function($ctx1) {
  14. return self.apply(anObject, aCollection);
  15. return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.BlockClosure)})},
  16. args: ["anObject", "aCollection"],
  17. source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
  18. messageSends: [],
  19. referencedClasses: []
  20. }),
  21. globals.BlockClosure);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "asCompiledMethod:",
  25. protocol: 'converting',
  26. fn: function (aString){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) {
  29. return smalltalk.method({selector:aString, fn:self});;
  30. return self}, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},globals.BlockClosure)})},
  31. args: ["aString"],
  32. source: "asCompiledMethod: aString\x0a\x09<return smalltalk.method({selector:aString, fn:self});>",
  33. messageSends: [],
  34. referencedClasses: []
  35. }),
  36. globals.BlockClosure);
  37. smalltalk.addMethod(
  38. smalltalk.method({
  39. selector: "compiledSource",
  40. protocol: 'accessing',
  41. fn: function (){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) {
  44. return self.toString();
  45. return self}, function($ctx1) {$ctx1.fill(self,"compiledSource",{},globals.BlockClosure)})},
  46. args: [],
  47. source: "compiledSource\x0a\x09<return self.toString()>",
  48. messageSends: [],
  49. referencedClasses: []
  50. }),
  51. globals.BlockClosure);
  52. smalltalk.addMethod(
  53. smalltalk.method({
  54. selector: "currySelf",
  55. protocol: 'converting',
  56. fn: function (){
  57. var self=this;
  58. return smalltalk.withContext(function($ctx1) {
  59. return function () {
  60. var args = [ this ];
  61. args.push.apply(args, arguments);
  62. return self.apply(null, args);
  63. }
  64. ;
  65. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},globals.BlockClosure)})},
  66. args: [],
  67. source: "currySelf\x0a\x09\x22Transforms [ :selfarg :x :y | stcode ] block\x0a\x09which represents JS function (selfarg, x, y, ...) {jscode}\x0a\x09into function (x, y, ...) {jscode} that takes selfarg from 'this'.\x0a\x09IOW, it is usable as JS method and first arg takes the receiver.\x22\x0a\x09\x0a\x09<\x0a\x09\x09return function () {\x0a\x09\x09\x09var args = [ this ];\x0a\x09\x09\x09args.push.apply(args, arguments);\x0a\x09\x09\x09return self.apply(null, args);\x0a\x09\x09}\x0a\x09>",
  68. messageSends: [],
  69. referencedClasses: []
  70. }),
  71. globals.BlockClosure);
  72. smalltalk.addMethod(
  73. smalltalk.method({
  74. selector: "ensure:",
  75. protocol: 'evaluating',
  76. fn: function (aBlock){
  77. var self=this;
  78. return smalltalk.withContext(function($ctx1) {
  79. try{return self._value()}finally{aBlock._value()};
  80. return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},globals.BlockClosure)})},
  81. args: ["aBlock"],
  82. source: "ensure: aBlock\x0a\x09<try{return self._value()}finally{aBlock._value()}>",
  83. messageSends: [],
  84. referencedClasses: []
  85. }),
  86. globals.BlockClosure);
  87. smalltalk.addMethod(
  88. smalltalk.method({
  89. selector: "fork",
  90. protocol: 'timeout/interval',
  91. fn: function (){
  92. var self=this;
  93. function $ForkPool(){return globals.ForkPool||(typeof ForkPool=="undefined"?nil:ForkPool)}
  94. return smalltalk.withContext(function($ctx1) {
  95. _st(_st($ForkPool())._default())._fork_(self);
  96. return self}, function($ctx1) {$ctx1.fill(self,"fork",{},globals.BlockClosure)})},
  97. args: [],
  98. source: "fork\x0a\x09ForkPool default fork: self",
  99. messageSends: ["fork:", "default"],
  100. referencedClasses: ["ForkPool"]
  101. }),
  102. globals.BlockClosure);
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "new",
  106. protocol: 'evaluating',
  107. fn: function (){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx1) {
  110. return new self();
  111. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.BlockClosure)})},
  112. args: [],
  113. source: "new\x0a\x09\x22Use the receiver as a JS constructor.\x0a\x09*Do not* use this method to instanciate Smalltalk objects!\x22\x0a\x09<return new self()>",
  114. messageSends: [],
  115. referencedClasses: []
  116. }),
  117. globals.BlockClosure);
  118. smalltalk.addMethod(
  119. smalltalk.method({
  120. selector: "newValue:",
  121. protocol: 'evaluating',
  122. fn: function (anObject){
  123. var self=this;
  124. return smalltalk.withContext(function($ctx1) {
  125. var $1;
  126. $1=self._newWithValues_([anObject]);
  127. return $1;
  128. }, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},globals.BlockClosure)})},
  129. args: ["anObject"],
  130. source: "newValue: anObject\x0a\x09^ self newWithValues: { anObject }",
  131. messageSends: ["newWithValues:"],
  132. referencedClasses: []
  133. }),
  134. globals.BlockClosure);
  135. smalltalk.addMethod(
  136. smalltalk.method({
  137. selector: "newValue:value:",
  138. protocol: 'evaluating',
  139. fn: function (anObject,anObject2){
  140. var self=this;
  141. return smalltalk.withContext(function($ctx1) {
  142. var $1;
  143. $1=self._newWithValues_([anObject,anObject2]);
  144. return $1;
  145. }, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},globals.BlockClosure)})},
  146. args: ["anObject", "anObject2"],
  147. source: "newValue: anObject value: anObject2\x0a\x09^ self newWithValues: { anObject. anObject2 }.",
  148. messageSends: ["newWithValues:"],
  149. referencedClasses: []
  150. }),
  151. globals.BlockClosure);
  152. smalltalk.addMethod(
  153. smalltalk.method({
  154. selector: "newValue:value:value:",
  155. protocol: 'evaluating',
  156. fn: function (anObject,anObject2,anObject3){
  157. var self=this;
  158. return smalltalk.withContext(function($ctx1) {
  159. var $1;
  160. $1=self._newWithValues_([anObject,anObject2,anObject3]);
  161. return $1;
  162. }, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.BlockClosure)})},
  163. args: ["anObject", "anObject2", "anObject3"],
  164. source: "newValue: anObject value: anObject2 value: anObject3\x0a\x09^ self newWithValues: { anObject. anObject2. anObject3 }.",
  165. messageSends: ["newWithValues:"],
  166. referencedClasses: []
  167. }),
  168. globals.BlockClosure);
  169. smalltalk.addMethod(
  170. smalltalk.method({
  171. selector: "newWithValues:",
  172. protocol: 'evaluating',
  173. fn: function (aCollection){
  174. var self=this;
  175. return smalltalk.withContext(function($ctx1) {
  176. var object = Object.create(self.prototype);
  177. var result = self.apply(object, aCollection);
  178. return typeof result === "object" ? result : object;
  179. ;
  180. return self}, function($ctx1) {$ctx1.fill(self,"newWithValues:",{aCollection:aCollection},globals.BlockClosure)})},
  181. args: ["aCollection"],
  182. source: "newWithValues: aCollection\x0a\x09\x22Simulates JS new operator by combination of Object.create and .apply\x22\x0a\x09<\x0a\x09\x09var object = Object.create(self.prototype);\x0a\x09\x09var result = self.apply(object, aCollection);\x0a\x09\x09return typeof result === \x22object\x22 ? result : object;\x0a\x09>",
  183. messageSends: [],
  184. referencedClasses: []
  185. }),
  186. globals.BlockClosure);
  187. smalltalk.addMethod(
  188. smalltalk.method({
  189. selector: "numArgs",
  190. protocol: 'accessing',
  191. fn: function (){
  192. var self=this;
  193. return smalltalk.withContext(function($ctx1) {
  194. return self.length;
  195. return self}, function($ctx1) {$ctx1.fill(self,"numArgs",{},globals.BlockClosure)})},
  196. args: [],
  197. source: "numArgs\x0a\x09<return self.length>",
  198. messageSends: [],
  199. referencedClasses: []
  200. }),
  201. globals.BlockClosure);
  202. smalltalk.addMethod(
  203. smalltalk.method({
  204. selector: "on:do:",
  205. protocol: 'error handling',
  206. fn: function (anErrorClass,aBlock){
  207. var self=this;
  208. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  209. return smalltalk.withContext(function($ctx1) {
  210. var $2,$1;
  211. $1=self._tryCatch_((function(error){
  212. var smalltalkError;
  213. return smalltalk.withContext(function($ctx2) {
  214. smalltalkError=_st($Smalltalk())._asSmalltalkException_(error);
  215. smalltalkError;
  216. $2=_st(smalltalkError)._isKindOf_(anErrorClass);
  217. if(smalltalk.assert($2)){
  218. return _st(aBlock)._value_(smalltalkError);
  219. } else {
  220. return _st(smalltalkError)._resignal();
  221. };
  222. }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1,1)})}));
  223. return $1;
  224. }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},globals.BlockClosure)})},
  225. args: ["anErrorClass", "aBlock"],
  226. source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a\x09Convert all JS exceptions to JavaScriptException instances.\x22\x0a\x09\x0a\x09^ self tryCatch: [ :error | | smalltalkError |\x0a\x09\x09smalltalkError := Smalltalk asSmalltalkException: error.\x0a\x09\x09(smalltalkError isKindOf: anErrorClass)\x0a\x09\x09ifTrue: [ aBlock value: smalltalkError ]\x0a\x09\x09ifFalse: [ smalltalkError resignal ] ]",
  227. messageSends: ["tryCatch:", "asSmalltalkException:", "ifTrue:ifFalse:", "isKindOf:", "value:", "resignal"],
  228. referencedClasses: ["Smalltalk"]
  229. }),
  230. globals.BlockClosure);
  231. smalltalk.addMethod(
  232. smalltalk.method({
  233. selector: "receiver",
  234. protocol: 'accessing',
  235. fn: function (){
  236. var self=this;
  237. return nil;
  238. },
  239. args: [],
  240. source: "receiver\x0a\x09^ nil",
  241. messageSends: [],
  242. referencedClasses: []
  243. }),
  244. globals.BlockClosure);
  245. smalltalk.addMethod(
  246. smalltalk.method({
  247. selector: "timeToRun",
  248. protocol: 'evaluating',
  249. fn: function (){
  250. var self=this;
  251. function $Date(){return globals.Date||(typeof Date=="undefined"?nil:Date)}
  252. return smalltalk.withContext(function($ctx1) {
  253. var $1;
  254. $1=_st($Date())._millisecondsToRun_(self);
  255. return $1;
  256. }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},globals.BlockClosure)})},
  257. args: [],
  258. source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
  259. messageSends: ["millisecondsToRun:"],
  260. referencedClasses: ["Date"]
  261. }),
  262. globals.BlockClosure);
  263. smalltalk.addMethod(
  264. smalltalk.method({
  265. selector: "tryCatch:",
  266. protocol: 'error handling',
  267. fn: function (aBlock){
  268. var self=this;
  269. return smalltalk.withContext(function($ctx1) {
  270. try {
  271. return self._value();
  272. } catch(error) {
  273. return aBlock._value_(error);
  274. }
  275. ;
  276. return self}, function($ctx1) {$ctx1.fill(self,"tryCatch:",{aBlock:aBlock},globals.BlockClosure)})},
  277. args: ["aBlock"],
  278. source: "tryCatch: aBlock\x0a\x09<\x0a\x09\x09try {\x0a\x09\x09\x09return self._value();\x0a\x09\x09} catch(error) {\x0a\x09\x09\x09return aBlock._value_(error);\x0a\x09\x09}\x0a\x09>",
  279. messageSends: [],
  280. referencedClasses: []
  281. }),
  282. globals.BlockClosure);
  283. smalltalk.addMethod(
  284. smalltalk.method({
  285. selector: "value",
  286. protocol: 'evaluating',
  287. fn: function (){
  288. var self=this;
  289. return smalltalk.withContext(function($ctx1) {
  290. return self();;
  291. return self}, function($ctx1) {$ctx1.fill(self,"value",{},globals.BlockClosure)})},
  292. args: [],
  293. source: "value\x0a\x09<return self();>",
  294. messageSends: [],
  295. referencedClasses: []
  296. }),
  297. globals.BlockClosure);
  298. smalltalk.addMethod(
  299. smalltalk.method({
  300. selector: "value:",
  301. protocol: 'evaluating',
  302. fn: function (anArg){
  303. var self=this;
  304. return smalltalk.withContext(function($ctx1) {
  305. return self(anArg);;
  306. return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},globals.BlockClosure)})},
  307. args: ["anArg"],
  308. source: "value: anArg\x0a\x09<return self(anArg);>",
  309. messageSends: [],
  310. referencedClasses: []
  311. }),
  312. globals.BlockClosure);
  313. smalltalk.addMethod(
  314. smalltalk.method({
  315. selector: "value:value:",
  316. protocol: 'evaluating',
  317. fn: function (firstArg,secondArg){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) {
  320. return self(firstArg, secondArg);;
  321. return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},globals.BlockClosure)})},
  322. args: ["firstArg", "secondArg"],
  323. source: "value: firstArg value: secondArg\x0a\x09<return self(firstArg, secondArg);>",
  324. messageSends: [],
  325. referencedClasses: []
  326. }),
  327. globals.BlockClosure);
  328. smalltalk.addMethod(
  329. smalltalk.method({
  330. selector: "value:value:value:",
  331. protocol: 'evaluating',
  332. fn: function (firstArg,secondArg,thirdArg){
  333. var self=this;
  334. return smalltalk.withContext(function($ctx1) {
  335. return self(firstArg, secondArg, thirdArg);;
  336. return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},globals.BlockClosure)})},
  337. args: ["firstArg", "secondArg", "thirdArg"],
  338. source: "value: firstArg value: secondArg value: thirdArg\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
  339. messageSends: [],
  340. referencedClasses: []
  341. }),
  342. globals.BlockClosure);
  343. smalltalk.addMethod(
  344. smalltalk.method({
  345. selector: "valueWithInterval:",
  346. protocol: 'timeout/interval',
  347. fn: function (aNumber){
  348. var self=this;
  349. return smalltalk.withContext(function($ctx1) {
  350. var interval = setInterval(self, aNumber);
  351. return globals.Timeout._on_(interval);
  352. ;
  353. return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},globals.BlockClosure)})},
  354. args: ["aNumber"],
  355. source: "valueWithInterval: aNumber\x0a\x09<\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(interval);\x0a\x09>",
  356. messageSends: [],
  357. referencedClasses: []
  358. }),
  359. globals.BlockClosure);
  360. smalltalk.addMethod(
  361. smalltalk.method({
  362. selector: "valueWithPossibleArguments:",
  363. protocol: 'evaluating',
  364. fn: function (aCollection){
  365. var self=this;
  366. return smalltalk.withContext(function($ctx1) {
  367. return self.apply(null, aCollection);;
  368. return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.BlockClosure)})},
  369. args: ["aCollection"],
  370. source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
  371. messageSends: [],
  372. referencedClasses: []
  373. }),
  374. globals.BlockClosure);
  375. smalltalk.addMethod(
  376. smalltalk.method({
  377. selector: "valueWithTimeout:",
  378. protocol: 'timeout/interval',
  379. fn: function (aNumber){
  380. var self=this;
  381. return smalltalk.withContext(function($ctx1) {
  382. var timeout = setTimeout(self, aNumber);
  383. return globals.Timeout._on_(timeout);
  384. ;
  385. return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},globals.BlockClosure)})},
  386. args: ["aNumber"],
  387. source: "valueWithTimeout: aNumber\x0a\x09<\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return globals.Timeout._on_(timeout);\x0a\x09>",
  388. messageSends: [],
  389. referencedClasses: []
  390. }),
  391. globals.BlockClosure);
  392. smalltalk.addMethod(
  393. smalltalk.method({
  394. selector: "whileFalse",
  395. protocol: 'controlling',
  396. fn: function (){
  397. var self=this;
  398. return smalltalk.withContext(function($ctx1) {
  399. self._whileFalse_((function(){
  400. }));
  401. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{},globals.BlockClosure)})},
  402. args: [],
  403. source: "whileFalse\x0a\x09self whileFalse: []",
  404. messageSends: ["whileFalse:"],
  405. referencedClasses: []
  406. }),
  407. globals.BlockClosure);
  408. smalltalk.addMethod(
  409. smalltalk.method({
  410. selector: "whileFalse:",
  411. protocol: 'controlling',
  412. fn: function (aBlock){
  413. var self=this;
  414. return smalltalk.withContext(function($ctx1) {
  415. while(!smalltalk.assert(self._value())) {aBlock._value()};
  416. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},globals.BlockClosure)})},
  417. args: ["aBlock"],
  418. source: "whileFalse: aBlock\x0a\x09<while(!smalltalk.assert(self._value())) {aBlock._value()}>",
  419. messageSends: [],
  420. referencedClasses: []
  421. }),
  422. globals.BlockClosure);
  423. smalltalk.addMethod(
  424. smalltalk.method({
  425. selector: "whileTrue",
  426. protocol: 'controlling',
  427. fn: function (){
  428. var self=this;
  429. return smalltalk.withContext(function($ctx1) {
  430. self._whileTrue_((function(){
  431. }));
  432. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{},globals.BlockClosure)})},
  433. args: [],
  434. source: "whileTrue\x0a\x09self whileTrue: []",
  435. messageSends: ["whileTrue:"],
  436. referencedClasses: []
  437. }),
  438. globals.BlockClosure);
  439. smalltalk.addMethod(
  440. smalltalk.method({
  441. selector: "whileTrue:",
  442. protocol: 'controlling',
  443. fn: function (aBlock){
  444. var self=this;
  445. return smalltalk.withContext(function($ctx1) {
  446. while(smalltalk.assert(self._value())) {aBlock._value()};
  447. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},globals.BlockClosure)})},
  448. args: ["aBlock"],
  449. source: "whileTrue: aBlock\x0a\x09<while(smalltalk.assert(self._value())) {aBlock._value()}>",
  450. messageSends: [],
  451. referencedClasses: []
  452. }),
  453. globals.BlockClosure);
  454. smalltalk.addClass('CompiledMethod', globals.Object, [], 'Kernel-Methods');
  455. globals.CompiledMethod.comment="I represent a class method of the system. I hold the source and compiled code of a class method.\x0a\x0a## API\x0aMy instances can be accessed using `Behavior >> #methodAt:`\x0a\x0a Object methodAt: 'asString'\x0a\x0aSource code access:\x0a\x0a\x09(String methodAt: 'lines') source\x0a\x0aReferenced classes:\x0a\x0a\x09(String methodAt: 'lines') referencedClasses\x0a\x0aMessages sent from an instance:\x0a\x09\x0a\x09(String methodAt: 'lines') messageSends";
  456. smalltalk.addMethod(
  457. smalltalk.method({
  458. selector: "arguments",
  459. protocol: 'accessing',
  460. fn: function (){
  461. var self=this;
  462. return smalltalk.withContext(function($ctx1) {
  463. return self.args || [];
  464. return self}, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.CompiledMethod)})},
  465. args: [],
  466. source: "arguments\x0a\x09<return self.args || []>",
  467. messageSends: [],
  468. referencedClasses: []
  469. }),
  470. globals.CompiledMethod);
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "browse",
  474. protocol: 'browsing',
  475. fn: function (){
  476. var self=this;
  477. function $Finder(){return globals.Finder||(typeof Finder=="undefined"?nil:Finder)}
  478. return smalltalk.withContext(function($ctx1) {
  479. _st($Finder())._findMethod_(self);
  480. return self}, function($ctx1) {$ctx1.fill(self,"browse",{},globals.CompiledMethod)})},
  481. args: [],
  482. source: "browse\x0a\x09Finder findMethod: self",
  483. messageSends: ["findMethod:"],
  484. referencedClasses: ["Finder"]
  485. }),
  486. globals.CompiledMethod);
  487. smalltalk.addMethod(
  488. smalltalk.method({
  489. selector: "category",
  490. protocol: 'accessing',
  491. fn: function (){
  492. var self=this;
  493. return smalltalk.withContext(function($ctx1) {
  494. var $1;
  495. $1=self._protocol();
  496. return $1;
  497. }, function($ctx1) {$ctx1.fill(self,"category",{},globals.CompiledMethod)})},
  498. args: [],
  499. source: "category\x0a\x09^ self protocol",
  500. messageSends: ["protocol"],
  501. referencedClasses: []
  502. }),
  503. globals.CompiledMethod);
  504. smalltalk.addMethod(
  505. smalltalk.method({
  506. selector: "defaultProtocol",
  507. protocol: 'defaults',
  508. fn: function (){
  509. var self=this;
  510. return "as yet unclassified";
  511. },
  512. args: [],
  513. source: "defaultProtocol\x0a\x09^ 'as yet unclassified'",
  514. messageSends: [],
  515. referencedClasses: []
  516. }),
  517. globals.CompiledMethod);
  518. smalltalk.addMethod(
  519. smalltalk.method({
  520. selector: "fn",
  521. protocol: 'accessing',
  522. fn: function (){
  523. var self=this;
  524. return smalltalk.withContext(function($ctx1) {
  525. var $1;
  526. $1=self._basicAt_("fn");
  527. return $1;
  528. }, function($ctx1) {$ctx1.fill(self,"fn",{},globals.CompiledMethod)})},
  529. args: [],
  530. source: "fn\x0a\x09^ self basicAt: 'fn'",
  531. messageSends: ["basicAt:"],
  532. referencedClasses: []
  533. }),
  534. globals.CompiledMethod);
  535. smalltalk.addMethod(
  536. smalltalk.method({
  537. selector: "fn:",
  538. protocol: 'accessing',
  539. fn: function (aBlock){
  540. var self=this;
  541. return smalltalk.withContext(function($ctx1) {
  542. self._basicAt_put_("fn",aBlock);
  543. return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},globals.CompiledMethod)})},
  544. args: ["aBlock"],
  545. source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
  546. messageSends: ["basicAt:put:"],
  547. referencedClasses: []
  548. }),
  549. globals.CompiledMethod);
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "isCompiledMethod",
  553. protocol: 'testing',
  554. fn: function (){
  555. var self=this;
  556. return true;
  557. },
  558. args: [],
  559. source: "isCompiledMethod\x0a\x09^ true",
  560. messageSends: [],
  561. referencedClasses: []
  562. }),
  563. globals.CompiledMethod);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "isOverridden",
  567. protocol: 'testing',
  568. fn: function (){
  569. var self=this;
  570. var selector;
  571. return smalltalk.withContext(function($ctx1) {
  572. var $1;
  573. var $early={};
  574. try {
  575. selector=self._selector();
  576. _st(self._methodClass())._allSubclassesDo_((function(each){
  577. return smalltalk.withContext(function($ctx2) {
  578. $1=_st(each)._includesSelector_(selector);
  579. if(smalltalk.assert($1)){
  580. throw $early=[true];
  581. };
  582. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  583. return false;
  584. }
  585. catch(e) {if(e===$early)return e[0]; throw e}
  586. }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},globals.CompiledMethod)})},
  587. args: [],
  588. source: "isOverridden\x0a\x09| selector |\x0a \x0a selector := self selector.\x0a self methodClass allSubclassesDo: [ :each |\x0a\x09 (each includesSelector: selector)\x0a \x09ifTrue: [ ^ true ] ].\x0a\x09^ false",
  589. messageSends: ["selector", "allSubclassesDo:", "methodClass", "ifTrue:", "includesSelector:"],
  590. referencedClasses: []
  591. }),
  592. globals.CompiledMethod);
  593. smalltalk.addMethod(
  594. smalltalk.method({
  595. selector: "isOverride",
  596. protocol: 'testing',
  597. fn: function (){
  598. var self=this;
  599. var superclass;
  600. return smalltalk.withContext(function($ctx1) {
  601. var $1,$2,$3,$receiver;
  602. $1=self._methodClass();
  603. $ctx1.sendIdx["methodClass"]=1;
  604. superclass=_st($1)._superclass();
  605. $ctx1.sendIdx["superclass"]=1;
  606. $2=superclass;
  607. if(($receiver = $2) == null || $receiver.isNil){
  608. return false;
  609. } else {
  610. $2;
  611. };
  612. $3=_st(_st(_st(self._methodClass())._superclass())._lookupSelector_(self._selector()))._notNil();
  613. return $3;
  614. }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},globals.CompiledMethod)})},
  615. args: [],
  616. source: "isOverride\x0a\x09| superclass |\x0a \x0a superclass := self methodClass superclass.\x0a\x09superclass ifNil: [ ^ false ].\x0a\x09\x0a ^ (self methodClass superclass lookupSelector: self selector) notNil",
  617. messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"],
  618. referencedClasses: []
  619. }),
  620. globals.CompiledMethod);
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "messageSends",
  624. protocol: 'accessing',
  625. fn: function (){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. var $1;
  629. $1=self._basicAt_("messageSends");
  630. return $1;
  631. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.CompiledMethod)})},
  632. args: [],
  633. source: "messageSends\x0a\x09^ self basicAt: 'messageSends'",
  634. messageSends: ["basicAt:"],
  635. referencedClasses: []
  636. }),
  637. globals.CompiledMethod);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "methodClass",
  641. protocol: 'accessing',
  642. fn: function (){
  643. var self=this;
  644. return smalltalk.withContext(function($ctx1) {
  645. var $1;
  646. $1=self._basicAt_("methodClass");
  647. return $1;
  648. }, function($ctx1) {$ctx1.fill(self,"methodClass",{},globals.CompiledMethod)})},
  649. args: [],
  650. source: "methodClass\x0a\x09^ self basicAt: 'methodClass'",
  651. messageSends: ["basicAt:"],
  652. referencedClasses: []
  653. }),
  654. globals.CompiledMethod);
  655. smalltalk.addMethod(
  656. smalltalk.method({
  657. selector: "package",
  658. protocol: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. function $Package(){return globals.Package||(typeof Package=="undefined"?nil:Package)}
  662. return smalltalk.withContext(function($ctx1) {
  663. var $1,$3,$2,$4,$5,$receiver;
  664. $1=self._methodClass();
  665. $ctx1.sendIdx["methodClass"]=1;
  666. if(($receiver = $1) == null || $receiver.isNil){
  667. return nil;
  668. } else {
  669. $1;
  670. };
  671. $3=self._protocol();
  672. $ctx1.sendIdx["protocol"]=1;
  673. $2=_st($3)._beginsWith_("*");
  674. if(! smalltalk.assert($2)){
  675. $4=_st(self._methodClass())._package();
  676. return $4;
  677. };
  678. $5=_st($Package())._named_ifAbsent_(_st(self._protocol())._allButFirst(),(function(){
  679. return nil;
  680. }));
  681. return $5;
  682. }, function($ctx1) {$ctx1.fill(self,"package",{},globals.CompiledMethod)})},
  683. args: [],
  684. source: "package\x0a\x09\x22Answer the package the receiver belongs to:\x0a\x09- if it is an extension method, answer the corresponding package\x0a\x09- else answer the `methodClass` package\x22\x0a\x09\x0a\x09self methodClass ifNil: [ ^ nil ].\x0a\x09\x0a\x09(self protocol beginsWith: '*') ifFalse: [\x0a\x09\x09^ self methodClass package ].\x0a\x09\x09\x0a\x09^ Package \x0a\x09\x09named: self protocol allButFirst\x0a\x09\x09ifAbsent: [ nil ]",
  685. messageSends: ["ifNil:", "methodClass", "ifFalse:", "beginsWith:", "protocol", "package", "named:ifAbsent:", "allButFirst"],
  686. referencedClasses: ["Package"]
  687. }),
  688. globals.CompiledMethod);
  689. smalltalk.addMethod(
  690. smalltalk.method({
  691. selector: "protocol",
  692. protocol: 'accessing',
  693. fn: function (){
  694. var self=this;
  695. return smalltalk.withContext(function($ctx1) {
  696. var $2,$1,$receiver;
  697. $2=self._basicAt_("protocol");
  698. if(($receiver = $2) == null || $receiver.isNil){
  699. $1=self._defaultProtocol();
  700. } else {
  701. $1=$2;
  702. };
  703. return $1;
  704. }, function($ctx1) {$ctx1.fill(self,"protocol",{},globals.CompiledMethod)})},
  705. args: [],
  706. source: "protocol\x0a\x09^ (self basicAt: 'protocol') ifNil: [ self defaultProtocol ]",
  707. messageSends: ["ifNil:", "basicAt:", "defaultProtocol"],
  708. referencedClasses: []
  709. }),
  710. globals.CompiledMethod);
  711. smalltalk.addMethod(
  712. smalltalk.method({
  713. selector: "protocol:",
  714. protocol: 'accessing',
  715. fn: function (aString){
  716. var self=this;
  717. var oldProtocol;
  718. function $SystemAnnouncer(){return globals.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  719. function $MethodMoved(){return globals.MethodMoved||(typeof MethodMoved=="undefined"?nil:MethodMoved)}
  720. return smalltalk.withContext(function($ctx1) {
  721. var $1,$2,$3,$receiver;
  722. oldProtocol=self._protocol();
  723. self._basicAt_put_("protocol",aString);
  724. $1=_st($MethodMoved())._new();
  725. _st($1)._method_(self);
  726. _st($1)._oldProtocol_(oldProtocol);
  727. $2=_st($1)._yourself();
  728. _st(_st($SystemAnnouncer())._current())._announce_($2);
  729. $3=self._methodClass();
  730. if(($receiver = $3) == null || $receiver.isNil){
  731. $3;
  732. } else {
  733. var methodClass;
  734. methodClass=$receiver;
  735. _st(_st(methodClass)._organization())._addElement_(aString);
  736. _st(methodClass)._removeProtocolIfEmpty_(oldProtocol);
  737. };
  738. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString,oldProtocol:oldProtocol},globals.CompiledMethod)})},
  739. args: ["aString"],
  740. source: "protocol: aString\x0a\x09| oldProtocol |\x0a\x09oldProtocol := self protocol.\x0a\x09self basicAt: 'protocol' put: aString.\x0a\x0a\x09SystemAnnouncer current announce: (MethodMoved new\x0a\x09\x09method: self;\x0a\x09\x09oldProtocol: oldProtocol;\x0a\x09\x09yourself).\x0a\x0a\x09self methodClass ifNotNil: [ :methodClass |\x0a\x09\x09methodClass organization addElement: aString.\x0a\x09\x09methodClass removeProtocolIfEmpty: oldProtocol ]",
  741. messageSends: ["protocol", "basicAt:put:", "announce:", "current", "method:", "new", "oldProtocol:", "yourself", "ifNotNil:", "methodClass", "addElement:", "organization", "removeProtocolIfEmpty:"],
  742. referencedClasses: ["SystemAnnouncer", "MethodMoved"]
  743. }),
  744. globals.CompiledMethod);
  745. smalltalk.addMethod(
  746. smalltalk.method({
  747. selector: "referencedClasses",
  748. protocol: 'accessing',
  749. fn: function (){
  750. var self=this;
  751. return smalltalk.withContext(function($ctx1) {
  752. var $1;
  753. $1=self._basicAt_("referencedClasses");
  754. return $1;
  755. }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},globals.CompiledMethod)})},
  756. args: [],
  757. source: "referencedClasses\x0a\x09^ self basicAt: 'referencedClasses'",
  758. messageSends: ["basicAt:"],
  759. referencedClasses: []
  760. }),
  761. globals.CompiledMethod);
  762. smalltalk.addMethod(
  763. smalltalk.method({
  764. selector: "selector",
  765. protocol: 'accessing',
  766. fn: function (){
  767. var self=this;
  768. return smalltalk.withContext(function($ctx1) {
  769. var $1;
  770. $1=self._basicAt_("selector");
  771. return $1;
  772. }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.CompiledMethod)})},
  773. args: [],
  774. source: "selector\x0a\x09^ self basicAt: 'selector'",
  775. messageSends: ["basicAt:"],
  776. referencedClasses: []
  777. }),
  778. globals.CompiledMethod);
  779. smalltalk.addMethod(
  780. smalltalk.method({
  781. selector: "selector:",
  782. protocol: 'accessing',
  783. fn: function (aString){
  784. var self=this;
  785. return smalltalk.withContext(function($ctx1) {
  786. self._basicAt_put_("selector",aString);
  787. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.CompiledMethod)})},
  788. args: ["aString"],
  789. source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
  790. messageSends: ["basicAt:put:"],
  791. referencedClasses: []
  792. }),
  793. globals.CompiledMethod);
  794. smalltalk.addMethod(
  795. smalltalk.method({
  796. selector: "sendTo:arguments:",
  797. protocol: 'evaluating',
  798. fn: function (anObject,aCollection){
  799. var self=this;
  800. return smalltalk.withContext(function($ctx1) {
  801. var $1;
  802. $1=_st(self._fn())._applyTo_arguments_(anObject,aCollection);
  803. return $1;
  804. }, function($ctx1) {$ctx1.fill(self,"sendTo:arguments:",{anObject:anObject,aCollection:aCollection},globals.CompiledMethod)})},
  805. args: ["anObject", "aCollection"],
  806. source: "sendTo: anObject arguments: aCollection\x0a\x09^ self fn applyTo: anObject arguments: aCollection",
  807. messageSends: ["applyTo:arguments:", "fn"],
  808. referencedClasses: []
  809. }),
  810. globals.CompiledMethod);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "source",
  814. protocol: 'accessing',
  815. fn: function (){
  816. var self=this;
  817. return smalltalk.withContext(function($ctx1) {
  818. var $2,$1,$receiver;
  819. $2=self._basicAt_("source");
  820. if(($receiver = $2) == null || $receiver.isNil){
  821. $1="";
  822. } else {
  823. $1=$2;
  824. };
  825. return $1;
  826. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.CompiledMethod)})},
  827. args: [],
  828. source: "source\x0a\x09^ (self basicAt: 'source') ifNil: [ '' ]",
  829. messageSends: ["ifNil:", "basicAt:"],
  830. referencedClasses: []
  831. }),
  832. globals.CompiledMethod);
  833. smalltalk.addMethod(
  834. smalltalk.method({
  835. selector: "source:",
  836. protocol: 'accessing',
  837. fn: function (aString){
  838. var self=this;
  839. return smalltalk.withContext(function($ctx1) {
  840. self._basicAt_put_("source",aString);
  841. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},globals.CompiledMethod)})},
  842. args: ["aString"],
  843. source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
  844. messageSends: ["basicAt:put:"],
  845. referencedClasses: []
  846. }),
  847. globals.CompiledMethod);
  848. smalltalk.addClass('ForkPool', globals.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
  849. globals.ForkPool.comment="I am responsible for handling forked blocks.\x0aThe pool size sets the maximum concurrent forked blocks.\x0a\x0a## API\x0a\x0aThe default instance is accessed with `#default`.\x0aThe maximum concurrent forked blocks can be set with `#maxPoolSize:`.\x0a\x0aForking is done via `BlockClosure >> #fork`";
  850. smalltalk.addMethod(
  851. smalltalk.method({
  852. selector: "addWorker",
  853. protocol: 'private',
  854. fn: function (){
  855. var self=this;
  856. return smalltalk.withContext(function($ctx1) {
  857. _st(self["@worker"])._valueWithTimeout_((0));
  858. self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
  859. return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{},globals.ForkPool)})},
  860. args: [],
  861. source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1",
  862. messageSends: ["valueWithTimeout:", "+"],
  863. referencedClasses: []
  864. }),
  865. globals.ForkPool);
  866. smalltalk.addMethod(
  867. smalltalk.method({
  868. selector: "defaultMaxPoolSize",
  869. protocol: 'defaults',
  870. fn: function (){
  871. var self=this;
  872. return smalltalk.withContext(function($ctx1) {
  873. var $1;
  874. $1=_st(self._class())._defaultMaxPoolSize();
  875. return $1;
  876. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},globals.ForkPool)})},
  877. args: [],
  878. source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
  879. messageSends: ["defaultMaxPoolSize", "class"],
  880. referencedClasses: []
  881. }),
  882. globals.ForkPool);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "fork:",
  886. protocol: 'actions',
  887. fn: function (aBlock){
  888. var self=this;
  889. return smalltalk.withContext(function($ctx1) {
  890. var $1;
  891. $1=_st(self["@poolSize"]).__lt(self._maxPoolSize());
  892. if(smalltalk.assert($1)){
  893. self._addWorker();
  894. };
  895. _st(self["@queue"])._nextPut_(aBlock);
  896. return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},globals.ForkPool)})},
  897. args: ["aBlock"],
  898. source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock",
  899. messageSends: ["ifTrue:", "<", "maxPoolSize", "addWorker", "nextPut:"],
  900. referencedClasses: []
  901. }),
  902. globals.ForkPool);
  903. smalltalk.addMethod(
  904. smalltalk.method({
  905. selector: "initialize",
  906. protocol: 'initialization',
  907. fn: function (){
  908. var self=this;
  909. function $Queue(){return globals.Queue||(typeof Queue=="undefined"?nil:Queue)}
  910. return smalltalk.withContext(function($ctx1) {
  911. ($ctx1.supercall = true, globals.ForkPool.superclass.fn.prototype._initialize.apply(_st(self), []));
  912. $ctx1.supercall = false;
  913. self["@poolSize"]=(0);
  914. self["@queue"]=_st($Queue())._new();
  915. self["@worker"]=self._makeWorker();
  916. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.ForkPool)})},
  917. args: [],
  918. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker",
  919. messageSends: ["initialize", "new", "makeWorker"],
  920. referencedClasses: ["Queue"]
  921. }),
  922. globals.ForkPool);
  923. smalltalk.addMethod(
  924. smalltalk.method({
  925. selector: "makeWorker",
  926. protocol: 'initialization',
  927. fn: function (){
  928. var self=this;
  929. var sentinel;
  930. function $Object(){return globals.Object||(typeof Object=="undefined"?nil:Object)}
  931. return smalltalk.withContext(function($ctx1) {
  932. var $2,$1;
  933. sentinel=_st($Object())._new();
  934. $1=(function(){
  935. var block;
  936. return smalltalk.withContext(function($ctx2) {
  937. self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
  938. self["@poolSize"];
  939. block=_st(self["@queue"])._nextIfAbsent_((function(){
  940. return sentinel;
  941. }));
  942. block;
  943. $2=_st(block).__eq_eq(sentinel);
  944. if(! smalltalk.assert($2)){
  945. return _st((function(){
  946. return smalltalk.withContext(function($ctx3) {
  947. return _st(block)._value();
  948. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)})}))._ensure_((function(){
  949. return smalltalk.withContext(function($ctx3) {
  950. return self._addWorker();
  951. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
  952. };
  953. }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1,1)})});
  954. return $1;
  955. }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},globals.ForkPool)})},
  956. args: [],
  957. source: "makeWorker\x0a\x09| sentinel |\x0a\x09sentinel := Object new.\x0a\x09^ [ | block |\x0a\x09\x09poolSize := poolSize - 1.\x0a\x09\x09block := queue nextIfAbsent: [ sentinel ].\x0a\x09\x09block == sentinel ifFalse: [\x0a\x09\x09\x09[ block value ] ensure: [ self addWorker ] ]]",
  958. messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "==", "ensure:", "value", "addWorker"],
  959. referencedClasses: ["Object"]
  960. }),
  961. globals.ForkPool);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "maxPoolSize",
  965. protocol: 'accessing',
  966. fn: function (){
  967. var self=this;
  968. return smalltalk.withContext(function($ctx1) {
  969. var $2,$1,$receiver;
  970. $2=self["@maxPoolSize"];
  971. if(($receiver = $2) == null || $receiver.isNil){
  972. $1=self._defaultMaxPoolSize();
  973. } else {
  974. $1=$2;
  975. };
  976. return $1;
  977. }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},globals.ForkPool)})},
  978. args: [],
  979. source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
  980. messageSends: ["ifNil:", "defaultMaxPoolSize"],
  981. referencedClasses: []
  982. }),
  983. globals.ForkPool);
  984. smalltalk.addMethod(
  985. smalltalk.method({
  986. selector: "maxPoolSize:",
  987. protocol: 'accessing',
  988. fn: function (anInteger){
  989. var self=this;
  990. self["@maxPoolSize"]=anInteger;
  991. return self},
  992. args: ["anInteger"],
  993. source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
  994. messageSends: [],
  995. referencedClasses: []
  996. }),
  997. globals.ForkPool);
  998. globals.ForkPool.klass.iVarNames = ['default'];
  999. smalltalk.addMethod(
  1000. smalltalk.method({
  1001. selector: "default",
  1002. protocol: 'accessing',
  1003. fn: function (){
  1004. var self=this;
  1005. return smalltalk.withContext(function($ctx1) {
  1006. var $2,$1,$receiver;
  1007. $2=self["@default"];
  1008. if(($receiver = $2) == null || $receiver.isNil){
  1009. self["@default"]=self._new();
  1010. $1=self["@default"];
  1011. } else {
  1012. $1=$2;
  1013. };
  1014. return $1;
  1015. }, function($ctx1) {$ctx1.fill(self,"default",{},globals.ForkPool.klass)})},
  1016. args: [],
  1017. source: "default\x0a\x09^ default ifNil: [ default := self new ]",
  1018. messageSends: ["ifNil:", "new"],
  1019. referencedClasses: []
  1020. }),
  1021. globals.ForkPool.klass);
  1022. smalltalk.addMethod(
  1023. smalltalk.method({
  1024. selector: "defaultMaxPoolSize",
  1025. protocol: 'accessing',
  1026. fn: function (){
  1027. var self=this;
  1028. return (100);
  1029. },
  1030. args: [],
  1031. source: "defaultMaxPoolSize\x0a\x09^ 100",
  1032. messageSends: [],
  1033. referencedClasses: []
  1034. }),
  1035. globals.ForkPool.klass);
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "resetDefault",
  1039. protocol: 'accessing',
  1040. fn: function (){
  1041. var self=this;
  1042. self["@default"]=nil;
  1043. return self},
  1044. args: [],
  1045. source: "resetDefault\x0a\x09default := nil",
  1046. messageSends: [],
  1047. referencedClasses: []
  1048. }),
  1049. globals.ForkPool.klass);
  1050. smalltalk.addClass('Message', globals.Object, ['selector', 'arguments'], 'Kernel-Methods');
  1051. globals.Message.comment="In general, the system does not use instances of me for efficiency reasons.\x0aHowever, when a message is not understood by its receiver, the interpreter will make up an instance of it in order to capture the information involved in an actual message transmission.\x0aThis instance is sent it as an argument with the message `#doesNotUnderstand:` to the receiver.\x0a\x0aSee boot.js, `messageNotUnderstood` and its counterpart `Object >> #doesNotUnderstand:`\x0a\x0a## API\x0a\x0aBesides accessing methods, `#sendTo:` provides a convenient way to send a message to an object.";
  1052. smalltalk.addMethod(
  1053. smalltalk.method({
  1054. selector: "arguments",
  1055. protocol: 'accessing',
  1056. fn: function (){
  1057. var self=this;
  1058. var $1;
  1059. $1=self["@arguments"];
  1060. return $1;
  1061. },
  1062. args: [],
  1063. source: "arguments\x0a\x09^ arguments",
  1064. messageSends: [],
  1065. referencedClasses: []
  1066. }),
  1067. globals.Message);
  1068. smalltalk.addMethod(
  1069. smalltalk.method({
  1070. selector: "arguments:",
  1071. protocol: 'accessing',
  1072. fn: function (anArray){
  1073. var self=this;
  1074. self["@arguments"]=anArray;
  1075. return self},
  1076. args: ["anArray"],
  1077. source: "arguments: anArray\x0a\x09arguments := anArray",
  1078. messageSends: [],
  1079. referencedClasses: []
  1080. }),
  1081. globals.Message);
  1082. smalltalk.addMethod(
  1083. smalltalk.method({
  1084. selector: "printOn:",
  1085. protocol: 'printing',
  1086. fn: function (aStream){
  1087. var self=this;
  1088. return smalltalk.withContext(function($ctx1) {
  1089. var $1;
  1090. ($ctx1.supercall = true, globals.Message.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]));
  1091. $ctx1.supercall = false;
  1092. _st(aStream)._nextPutAll_("(");
  1093. $ctx1.sendIdx["nextPutAll:"]=1;
  1094. _st(aStream)._nextPutAll_(self._selector());
  1095. $ctx1.sendIdx["nextPutAll:"]=2;
  1096. $1=_st(aStream)._nextPutAll_(")");
  1097. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.Message)})},
  1098. args: ["aStream"],
  1099. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
  1100. messageSends: ["printOn:", "nextPutAll:", "selector"],
  1101. referencedClasses: []
  1102. }),
  1103. globals.Message);
  1104. smalltalk.addMethod(
  1105. smalltalk.method({
  1106. selector: "selector",
  1107. protocol: 'accessing',
  1108. fn: function (){
  1109. var self=this;
  1110. var $1;
  1111. $1=self["@selector"];
  1112. return $1;
  1113. },
  1114. args: [],
  1115. source: "selector\x0a\x09^ selector",
  1116. messageSends: [],
  1117. referencedClasses: []
  1118. }),
  1119. globals.Message);
  1120. smalltalk.addMethod(
  1121. smalltalk.method({
  1122. selector: "selector:",
  1123. protocol: 'accessing',
  1124. fn: function (aString){
  1125. var self=this;
  1126. self["@selector"]=aString;
  1127. return self},
  1128. args: ["aString"],
  1129. source: "selector: aString\x0a\x09selector := aString",
  1130. messageSends: [],
  1131. referencedClasses: []
  1132. }),
  1133. globals.Message);
  1134. smalltalk.addMethod(
  1135. smalltalk.method({
  1136. selector: "sendTo:",
  1137. protocol: 'actions',
  1138. fn: function (anObject){
  1139. var self=this;
  1140. return smalltalk.withContext(function($ctx1) {
  1141. var $1;
  1142. $1=_st(anObject)._perform_withArguments_(self._selector(),self._arguments());
  1143. return $1;
  1144. }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject},globals.Message)})},
  1145. args: ["anObject"],
  1146. source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
  1147. messageSends: ["perform:withArguments:", "selector", "arguments"],
  1148. referencedClasses: []
  1149. }),
  1150. globals.Message);
  1151. smalltalk.addMethod(
  1152. smalltalk.method({
  1153. selector: "selector:arguments:",
  1154. protocol: 'instance creation',
  1155. fn: function (aString,anArray){
  1156. var self=this;
  1157. return smalltalk.withContext(function($ctx1) {
  1158. var $2,$3,$1;
  1159. $2=self._new();
  1160. _st($2)._selector_(aString);
  1161. _st($2)._arguments_(anArray);
  1162. $3=_st($2)._yourself();
  1163. $1=$3;
  1164. return $1;
  1165. }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray},globals.Message.klass)})},
  1166. args: ["aString", "anArray"],
  1167. source: "selector: aString arguments: anArray\x0a\x09^ self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
  1168. messageSends: ["selector:", "new", "arguments:", "yourself"],
  1169. referencedClasses: []
  1170. }),
  1171. globals.Message.klass);
  1172. smalltalk.addClass('MessageSend', globals.Object, ['receiver', 'message'], 'Kernel-Methods');
  1173. globals.MessageSend.comment="I encapsulate message sends to objects. Arguments can be either predefined or supplied when the message send is performed. \x0a\x0a## API\x0a\x0aUse `#value` to perform a message send with its predefined arguments and `#value:*` if additonal arguments have to supplied.";
  1174. smalltalk.addMethod(
  1175. smalltalk.method({
  1176. selector: "arguments",
  1177. protocol: 'accessing',
  1178. fn: function (){
  1179. var self=this;
  1180. return smalltalk.withContext(function($ctx1) {
  1181. var $1;
  1182. $1=_st(self["@message"])._arguments();
  1183. return $1;
  1184. }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MessageSend)})},
  1185. args: [],
  1186. source: "arguments\x0a\x09^ message arguments",
  1187. messageSends: ["arguments"],
  1188. referencedClasses: []
  1189. }),
  1190. globals.MessageSend);
  1191. smalltalk.addMethod(
  1192. smalltalk.method({
  1193. selector: "arguments:",
  1194. protocol: 'accessing',
  1195. fn: function (aCollection){
  1196. var self=this;
  1197. return smalltalk.withContext(function($ctx1) {
  1198. _st(self["@message"])._arguments_(aCollection);
  1199. return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.MessageSend)})},
  1200. args: ["aCollection"],
  1201. source: "arguments: aCollection\x0a\x09message arguments: aCollection",
  1202. messageSends: ["arguments:"],
  1203. referencedClasses: []
  1204. }),
  1205. globals.MessageSend);
  1206. smalltalk.addMethod(
  1207. smalltalk.method({
  1208. selector: "initialize",
  1209. protocol: 'initialization',
  1210. fn: function (){
  1211. var self=this;
  1212. function $Message(){return globals.Message||(typeof Message=="undefined"?nil:Message)}
  1213. return smalltalk.withContext(function($ctx1) {
  1214. ($ctx1.supercall = true, globals.MessageSend.superclass.fn.prototype._initialize.apply(_st(self), []));
  1215. $ctx1.supercall = false;
  1216. self["@message"]=_st($Message())._new();
  1217. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.MessageSend)})},
  1218. args: [],
  1219. source: "initialize\x0a\x09super initialize.\x0a\x09message := Message new",
  1220. messageSends: ["initialize", "new"],
  1221. referencedClasses: ["Message"]
  1222. }),
  1223. globals.MessageSend);
  1224. smalltalk.addMethod(
  1225. smalltalk.method({
  1226. selector: "printOn:",
  1227. protocol: 'printing',
  1228. fn: function (aStream){
  1229. var self=this;
  1230. return smalltalk.withContext(function($ctx1) {
  1231. var $1;
  1232. ($ctx1.supercall = true, globals.MessageSend.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]));
  1233. $ctx1.supercall = false;
  1234. _st(aStream)._nextPutAll_("(");
  1235. $ctx1.sendIdx["nextPutAll:"]=1;
  1236. _st(aStream)._nextPutAll_(self._receiver());
  1237. $ctx1.sendIdx["nextPutAll:"]=2;
  1238. _st(aStream)._nextPutAll_(" >> ");
  1239. $ctx1.sendIdx["nextPutAll:"]=3;
  1240. _st(aStream)._nextPutAll_(self._selector());
  1241. $ctx1.sendIdx["nextPutAll:"]=4;
  1242. $1=_st(aStream)._nextPutAll_(")");
  1243. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MessageSend)})},
  1244. args: ["aStream"],
  1245. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self receiver;\x0a\x09\x09nextPutAll: ' >> ';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
  1246. messageSends: ["printOn:", "nextPutAll:", "receiver", "selector"],
  1247. referencedClasses: []
  1248. }),
  1249. globals.MessageSend);
  1250. smalltalk.addMethod(
  1251. smalltalk.method({
  1252. selector: "receiver",
  1253. protocol: 'accessing',
  1254. fn: function (){
  1255. var self=this;
  1256. var $1;
  1257. $1=self["@receiver"];
  1258. return $1;
  1259. },
  1260. args: [],
  1261. source: "receiver\x0a\x09^ receiver",
  1262. messageSends: [],
  1263. referencedClasses: []
  1264. }),
  1265. globals.MessageSend);
  1266. smalltalk.addMethod(
  1267. smalltalk.method({
  1268. selector: "receiver:",
  1269. protocol: 'accessing',
  1270. fn: function (anObject){
  1271. var self=this;
  1272. self["@receiver"]=anObject;
  1273. return self},
  1274. args: ["anObject"],
  1275. source: "receiver: anObject\x0a\x09receiver := anObject",
  1276. messageSends: [],
  1277. referencedClasses: []
  1278. }),
  1279. globals.MessageSend);
  1280. smalltalk.addMethod(
  1281. smalltalk.method({
  1282. selector: "selector",
  1283. protocol: 'accessing',
  1284. fn: function (){
  1285. var self=this;
  1286. return smalltalk.withContext(function($ctx1) {
  1287. var $1;
  1288. $1=_st(self["@message"])._selector();
  1289. return $1;
  1290. }, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MessageSend)})},
  1291. args: [],
  1292. source: "selector\x0a\x09^ message selector",
  1293. messageSends: ["selector"],
  1294. referencedClasses: []
  1295. }),
  1296. globals.MessageSend);
  1297. smalltalk.addMethod(
  1298. smalltalk.method({
  1299. selector: "selector:",
  1300. protocol: 'accessing',
  1301. fn: function (aString){
  1302. var self=this;
  1303. return smalltalk.withContext(function($ctx1) {
  1304. _st(self["@message"])._selector_(aString);
  1305. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},globals.MessageSend)})},
  1306. args: ["aString"],
  1307. source: "selector: aString\x0a\x09message selector: aString",
  1308. messageSends: ["selector:"],
  1309. referencedClasses: []
  1310. }),
  1311. globals.MessageSend);
  1312. smalltalk.addMethod(
  1313. smalltalk.method({
  1314. selector: "value",
  1315. protocol: 'evaluating',
  1316. fn: function (){
  1317. var self=this;
  1318. return smalltalk.withContext(function($ctx1) {
  1319. var $1;
  1320. $1=_st(self["@message"])._sendTo_(self._receiver());
  1321. return $1;
  1322. }, function($ctx1) {$ctx1.fill(self,"value",{},globals.MessageSend)})},
  1323. args: [],
  1324. source: "value\x0a\x09^ message sendTo: self receiver",
  1325. messageSends: ["sendTo:", "receiver"],
  1326. referencedClasses: []
  1327. }),
  1328. globals.MessageSend);
  1329. smalltalk.addMethod(
  1330. smalltalk.method({
  1331. selector: "value:",
  1332. protocol: 'evaluating',
  1333. fn: function (anObject){
  1334. var self=this;
  1335. return smalltalk.withContext(function($ctx1) {
  1336. var $2,$3,$1;
  1337. $2=self["@message"];
  1338. _st($2)._arguments_([anObject]);
  1339. $3=_st($2)._sendTo_(self._receiver());
  1340. $1=$3;
  1341. return $1;
  1342. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},globals.MessageSend)})},
  1343. args: ["anObject"],
  1344. source: "value: anObject\x0a\x09^ message \x0a\x09\x09arguments: { anObject };\x0a\x09\x09sendTo: self receiver",
  1345. messageSends: ["arguments:", "sendTo:", "receiver"],
  1346. referencedClasses: []
  1347. }),
  1348. globals.MessageSend);
  1349. smalltalk.addMethod(
  1350. smalltalk.method({
  1351. selector: "value:value:",
  1352. protocol: 'evaluating',
  1353. fn: function (firstArgument,secondArgument){
  1354. var self=this;
  1355. return smalltalk.withContext(function($ctx1) {
  1356. var $2,$3,$1;
  1357. $2=self["@message"];
  1358. _st($2)._arguments_([firstArgument,secondArgument]);
  1359. $3=_st($2)._sendTo_(self._receiver());
  1360. $1=$3;
  1361. return $1;
  1362. }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},globals.MessageSend)})},
  1363. args: ["firstArgument", "secondArgument"],
  1364. source: "value: firstArgument value: secondArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument };\x0a\x09\x09sendTo: self receiver",
  1365. messageSends: ["arguments:", "sendTo:", "receiver"],
  1366. referencedClasses: []
  1367. }),
  1368. globals.MessageSend);
  1369. smalltalk.addMethod(
  1370. smalltalk.method({
  1371. selector: "value:value:value:",
  1372. protocol: 'evaluating',
  1373. fn: function (firstArgument,secondArgument,thirdArgument){
  1374. var self=this;
  1375. return smalltalk.withContext(function($ctx1) {
  1376. var $2,$3,$1;
  1377. $2=self["@message"];
  1378. _st($2)._arguments_([firstArgument,secondArgument,thirdArgument]);
  1379. $3=_st($2)._sendTo_(self._receiver());
  1380. $1=$3;
  1381. return $1;
  1382. }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},globals.MessageSend)})},
  1383. args: ["firstArgument", "secondArgument", "thirdArgument"],
  1384. source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ message \x0a\x09\x09arguments: { firstArgument. secondArgument. thirdArgument };\x0a\x09\x09sendTo: self receiver",
  1385. messageSends: ["arguments:", "sendTo:", "receiver"],
  1386. referencedClasses: []
  1387. }),
  1388. globals.MessageSend);
  1389. smalltalk.addMethod(
  1390. smalltalk.method({
  1391. selector: "valueWithPossibleArguments:",
  1392. protocol: 'evaluating',
  1393. fn: function (aCollection){
  1394. var self=this;
  1395. return smalltalk.withContext(function($ctx1) {
  1396. var $1;
  1397. self._arguments_(aCollection);
  1398. $1=self._value();
  1399. return $1;
  1400. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},globals.MessageSend)})},
  1401. args: ["aCollection"],
  1402. source: "valueWithPossibleArguments: aCollection\x0a\x09self arguments: aCollection.\x0a\x09^ self value",
  1403. messageSends: ["arguments:", "value"],
  1404. referencedClasses: []
  1405. }),
  1406. globals.MessageSend);
  1407. smalltalk.addClass('MethodContext', globals.Object, [], 'Kernel-Methods');
  1408. globals.MethodContext.comment="I hold all the dynamic state associated with the execution of either a method activation resulting from a message send. I am used to build the call stack while debugging.\x0a\x0aMy instances are JavaScript `SmalltalkMethodContext` objects defined in `boot.js`.";
  1409. smalltalk.addMethod(
  1410. smalltalk.method({
  1411. selector: "asString",
  1412. protocol: 'converting',
  1413. fn: function (){
  1414. var self=this;
  1415. return smalltalk.withContext(function($ctx1) {
  1416. var $2,$3,$5,$7,$6,$4,$11,$10,$9,$8,$12,$16,$15,$14,$13,$1;
  1417. $2=self._isBlockContext();
  1418. if(smalltalk.assert($2)){
  1419. $3="a block (in ".__comma(_st(self._methodContext())._asString());
  1420. $ctx1.sendIdx[","]=2;
  1421. $1=_st($3).__comma(")");
  1422. $ctx1.sendIdx[","]=1;
  1423. } else {
  1424. var methodClass;
  1425. methodClass=_st(self._method())._methodClass();
  1426. methodClass;
  1427. $5=methodClass;
  1428. $7=self._receiver();
  1429. $ctx1.sendIdx["receiver"]=1;
  1430. $6=_st($7)._class();
  1431. $ctx1.sendIdx["class"]=1;
  1432. $4=_st($5).__eq($6);
  1433. if(smalltalk.assert($4)){
  1434. $11=self._receiver();
  1435. $ctx1.sendIdx["receiver"]=2;
  1436. $10=_st($11)._class();
  1437. $ctx1.sendIdx["class"]=2;
  1438. $9=_st($10)._name();
  1439. $ctx1.sendIdx["name"]=1;
  1440. $8=_st($9).__comma(" >> ");
  1441. $ctx1.sendIdx[","]=4;
  1442. $12=self._selector();
  1443. $ctx1.sendIdx["selector"]=1;
  1444. $1=_st($8).__comma($12);
  1445. $ctx1.sendIdx[","]=3;
  1446. } else {
  1447. $16=_st(_st(self._receiver())._class())._name();
  1448. $ctx1.sendIdx["name"]=2;
  1449. $15=_st($16).__comma("(");
  1450. $14=_st($15).__comma(_st(methodClass)._name());
  1451. $ctx1.sendIdx[","]=7;
  1452. $13=_st($14).__comma(") >> ");
  1453. $ctx1.sendIdx[","]=6;
  1454. $1=_st($13).__comma(self._selector());
  1455. $ctx1.sendIdx[","]=5;
  1456. };
  1457. };
  1458. return $1;
  1459. }, function($ctx1) {$ctx1.fill(self,"asString",{},globals.MethodContext)})},
  1460. args: [],
  1461. source: "asString\x0a\x09^ self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ \x0a\x09\x09\x09| methodClass |\x0a\x09\x09\x09methodClass := self method methodClass.\x0a\x09\x09\x09methodClass = self receiver class \x0a\x09\x09\x09\x09ifTrue: [ self receiver class name, ' >> ', self selector ]\x0a\x09\x09\x09\x09ifFalse: [ self receiver class name, '(', methodClass name, ') >> ', self selector ] ]",
  1462. messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "methodClass", "method", "=", "class", "receiver", "name", "selector"],
  1463. referencedClasses: []
  1464. }),
  1465. globals.MethodContext);
  1466. smalltalk.addMethod(
  1467. smalltalk.method({
  1468. selector: "basicReceiver",
  1469. protocol: 'accessing',
  1470. fn: function (){
  1471. var self=this;
  1472. return smalltalk.withContext(function($ctx1) {
  1473. return self.receiver;
  1474. return self}, function($ctx1) {$ctx1.fill(self,"basicReceiver",{},globals.MethodContext)})},
  1475. args: [],
  1476. source: "basicReceiver\x0a\x09<return self.receiver>",
  1477. messageSends: [],
  1478. referencedClasses: []
  1479. }),
  1480. globals.MethodContext);
  1481. smalltalk.addMethod(
  1482. smalltalk.method({
  1483. selector: "evaluatedSelector",
  1484. protocol: 'accessing',
  1485. fn: function (){
  1486. var self=this;
  1487. return smalltalk.withContext(function($ctx1) {
  1488. return self.evaluatedSelector;
  1489. return self}, function($ctx1) {$ctx1.fill(self,"evaluatedSelector",{},globals.MethodContext)})},
  1490. args: [],
  1491. source: "evaluatedSelector\x0a\x09<return self.evaluatedSelector>",
  1492. messageSends: [],
  1493. referencedClasses: []
  1494. }),
  1495. globals.MethodContext);
  1496. smalltalk.addMethod(
  1497. smalltalk.method({
  1498. selector: "findContextSuchThat:",
  1499. protocol: 'accessing',
  1500. fn: function (testBlock){
  1501. var self=this;
  1502. var context;
  1503. return smalltalk.withContext(function($ctx1) {
  1504. var $1,$2;
  1505. var $early={};
  1506. try {
  1507. context=self;
  1508. _st((function(){
  1509. return smalltalk.withContext(function($ctx2) {
  1510. return _st(context)._isNil();
  1511. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1512. return smalltalk.withContext(function($ctx2) {
  1513. $1=_st(testBlock)._value_(context);
  1514. if(smalltalk.assert($1)){
  1515. $2=context;
  1516. throw $early=[$2];
  1517. };
  1518. context=_st(context)._outerContext();
  1519. return context;
  1520. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1521. return nil;
  1522. }
  1523. catch(e) {if(e===$early)return e[0]; throw e}
  1524. }, function($ctx1) {$ctx1.fill(self,"findContextSuchThat:",{testBlock:testBlock,context:context},globals.MethodContext)})},
  1525. args: ["testBlock"],
  1526. source: "findContextSuchThat: testBlock\x0a\x09\x22Search self and my sender chain for first one that satisfies `testBlock`. \x0a\x09Answer `nil` if none satisfy\x22\x0a\x0a\x09| context |\x0a\x09\x0a\x09context := self.\x0a\x09[ context isNil] whileFalse: [\x0a\x09\x09(testBlock value: context) \x0a\x09\x09\x09ifTrue: [ ^ context ].\x0a\x09\x09context := context outerContext ].\x0a\x0a\x09^ nil",
  1527. messageSends: ["whileFalse:", "isNil", "ifTrue:", "value:", "outerContext"],
  1528. referencedClasses: []
  1529. }),
  1530. globals.MethodContext);
  1531. smalltalk.addMethod(
  1532. smalltalk.method({
  1533. selector: "home",
  1534. protocol: 'accessing',
  1535. fn: function (){
  1536. var self=this;
  1537. return smalltalk.withContext(function($ctx1) {
  1538. return self.homeContext;
  1539. return self}, function($ctx1) {$ctx1.fill(self,"home",{},globals.MethodContext)})},
  1540. args: [],
  1541. source: "home\x0a\x09<return self.homeContext>",
  1542. messageSends: [],
  1543. referencedClasses: []
  1544. }),
  1545. globals.MethodContext);
  1546. smalltalk.addMethod(
  1547. smalltalk.method({
  1548. selector: "index",
  1549. protocol: 'accessing',
  1550. fn: function (){
  1551. var self=this;
  1552. return smalltalk.withContext(function($ctx1) {
  1553. return self.index || 0;
  1554. return self}, function($ctx1) {$ctx1.fill(self,"index",{},globals.MethodContext)})},
  1555. args: [],
  1556. source: "index\x0a\x09<return self.index || 0>",
  1557. messageSends: [],
  1558. referencedClasses: []
  1559. }),
  1560. globals.MethodContext);
  1561. smalltalk.addMethod(
  1562. smalltalk.method({
  1563. selector: "isBlockContext",
  1564. protocol: 'testing',
  1565. fn: function (){
  1566. var self=this;
  1567. return smalltalk.withContext(function($ctx1) {
  1568. var $1;
  1569. $1=_st(self._selector())._isNil();
  1570. return $1;
  1571. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},globals.MethodContext)})},
  1572. args: [],
  1573. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
  1574. messageSends: ["isNil", "selector"],
  1575. referencedClasses: []
  1576. }),
  1577. globals.MethodContext);
  1578. smalltalk.addMethod(
  1579. smalltalk.method({
  1580. selector: "locals",
  1581. protocol: 'accessing',
  1582. fn: function (){
  1583. var self=this;
  1584. return smalltalk.withContext(function($ctx1) {
  1585. return self.locals || {};
  1586. return self}, function($ctx1) {$ctx1.fill(self,"locals",{},globals.MethodContext)})},
  1587. args: [],
  1588. source: "locals\x0a\x09<return self.locals || {}>",
  1589. messageSends: [],
  1590. referencedClasses: []
  1591. }),
  1592. globals.MethodContext);
  1593. smalltalk.addMethod(
  1594. smalltalk.method({
  1595. selector: "method",
  1596. protocol: 'accessing',
  1597. fn: function (){
  1598. var self=this;
  1599. var method,lookupClass,receiverClass,supercall;
  1600. return smalltalk.withContext(function($ctx1) {
  1601. var $1,$3,$2,$4,$6,$5,$7,$9,$8,$receiver;
  1602. $1=self._methodContext();
  1603. $ctx1.sendIdx["methodContext"]=1;
  1604. if(($receiver = $1) == null || $receiver.isNil){
  1605. return nil;
  1606. } else {
  1607. $1;
  1608. };
  1609. $3=self._methodContext();
  1610. $ctx1.sendIdx["methodContext"]=2;
  1611. $2=_st($3)._receiver();
  1612. receiverClass=_st($2)._class();
  1613. $4=receiverClass;
  1614. $6=self._methodContext();
  1615. $ctx1.sendIdx["methodContext"]=3;
  1616. $5=_st($6)._selector();
  1617. $ctx1.sendIdx["selector"]=1;
  1618. method=_st($4)._lookupSelector_($5);
  1619. $ctx1.sendIdx["lookupSelector:"]=1;
  1620. $7=self._outerContext();
  1621. if(($receiver = $7) == null || $receiver.isNil){
  1622. supercall=false;
  1623. } else {
  1624. var outer;
  1625. outer=$receiver;
  1626. supercall=_st(outer)._supercall();
  1627. };
  1628. $9=supercall;
  1629. if(smalltalk.assert($9)){
  1630. $8=_st(_st(_st(method)._methodClass())._superclass())._lookupSelector_(_st(self._methodContext())._selector());
  1631. } else {
  1632. $8=method;
  1633. };
  1634. return $8;
  1635. }, function($ctx1) {$ctx1.fill(self,"method",{method:method,lookupClass:lookupClass,receiverClass:receiverClass,supercall:supercall},globals.MethodContext)})},
  1636. args: [],
  1637. source: "method\x0a\x09| method lookupClass receiverClass supercall |\x0a\x09\x0a\x09self methodContext ifNil: [ ^ nil ].\x0a\x0a\x09receiverClass := self methodContext receiver class.\x0a\x09method := receiverClass lookupSelector: self methodContext selector.\x0a\x09supercall := self outerContext \x0a\x09\x09ifNil: [ false ]\x0a\x09\x09ifNotNil: [ :outer | outer supercall ].\x0a\x0a\x09^ supercall\x0a\x09\x09ifFalse: [ method ]\x0a\x09\x09ifTrue: [ method methodClass superclass lookupSelector: self methodContext selector ]",
  1638. messageSends: ["ifNil:", "methodContext", "class", "receiver", "lookupSelector:", "selector", "ifNil:ifNotNil:", "outerContext", "supercall", "ifFalse:ifTrue:", "superclass", "methodClass"],
  1639. referencedClasses: []
  1640. }),
  1641. globals.MethodContext);
  1642. smalltalk.addMethod(
  1643. smalltalk.method({
  1644. selector: "methodContext",
  1645. protocol: 'accessing',
  1646. fn: function (){
  1647. var self=this;
  1648. return smalltalk.withContext(function($ctx1) {
  1649. var $1,$3,$2,$receiver;
  1650. $1=self._isBlockContext();
  1651. if(! smalltalk.assert($1)){
  1652. return self;
  1653. };
  1654. $3=self._outerContext();
  1655. if(($receiver = $3) == null || $receiver.isNil){
  1656. $2=$3;
  1657. } else {
  1658. var outer;
  1659. outer=$receiver;
  1660. $2=_st(outer)._methodContext();
  1661. };
  1662. return $2;
  1663. }, function($ctx1) {$ctx1.fill(self,"methodContext",{},globals.MethodContext)})},
  1664. args: [],
  1665. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
  1666. messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
  1667. referencedClasses: []
  1668. }),
  1669. globals.MethodContext);
  1670. smalltalk.addMethod(
  1671. smalltalk.method({
  1672. selector: "outerContext",
  1673. protocol: 'accessing',
  1674. fn: function (){
  1675. var self=this;
  1676. return smalltalk.withContext(function($ctx1) {
  1677. return self.outerContext || self.homeContext;
  1678. return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{},globals.MethodContext)})},
  1679. args: [],
  1680. source: "outerContext\x0a\x09<return self.outerContext || self.homeContext>",
  1681. messageSends: [],
  1682. referencedClasses: []
  1683. }),
  1684. globals.MethodContext);
  1685. smalltalk.addMethod(
  1686. smalltalk.method({
  1687. selector: "printOn:",
  1688. protocol: 'printing',
  1689. fn: function (aStream){
  1690. var self=this;
  1691. return smalltalk.withContext(function($ctx1) {
  1692. var $1;
  1693. ($ctx1.supercall = true, globals.MethodContext.superclass.fn.prototype._printOn_.apply(_st(self), [aStream]));
  1694. $ctx1.supercall = false;
  1695. _st(aStream)._nextPutAll_("(");
  1696. $ctx1.sendIdx["nextPutAll:"]=1;
  1697. _st(aStream)._nextPutAll_(self._asString());
  1698. $ctx1.sendIdx["nextPutAll:"]=2;
  1699. $1=_st(aStream)._nextPutAll_(")");
  1700. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},globals.MethodContext)})},
  1701. args: ["aStream"],
  1702. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self asString;\x0a\x09\x09nextPutAll: ')'",
  1703. messageSends: ["printOn:", "nextPutAll:", "asString"],
  1704. referencedClasses: []
  1705. }),
  1706. globals.MethodContext);
  1707. smalltalk.addMethod(
  1708. smalltalk.method({
  1709. selector: "receiver",
  1710. protocol: 'accessing',
  1711. fn: function (){
  1712. var self=this;
  1713. return smalltalk.withContext(function($ctx1) {
  1714. var $3,$2,$1;
  1715. $2=_st(self._isBlockContext())._and_((function(){
  1716. return smalltalk.withContext(function($ctx2) {
  1717. $3=self._outerContext();
  1718. $ctx2.sendIdx["outerContext"]=1;
  1719. return _st($3)._notNil();
  1720. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1721. if(smalltalk.assert($2)){
  1722. $1=_st(self._outerContext())._receiver();
  1723. } else {
  1724. $1=self._basicReceiver();
  1725. };
  1726. return $1;
  1727. }, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.MethodContext)})},
  1728. args: [],
  1729. source: "receiver\x0a\x09^ (self isBlockContext and: [ self outerContext notNil ])\x0a\x09\x09ifTrue: [ self outerContext receiver ]\x0a\x09\x09ifFalse: [ self basicReceiver ]",
  1730. messageSends: ["ifTrue:ifFalse:", "and:", "isBlockContext", "notNil", "outerContext", "receiver", "basicReceiver"],
  1731. referencedClasses: []
  1732. }),
  1733. globals.MethodContext);
  1734. smalltalk.addMethod(
  1735. smalltalk.method({
  1736. selector: "selector",
  1737. protocol: 'accessing',
  1738. fn: function (){
  1739. var self=this;
  1740. return smalltalk.withContext(function($ctx1) {
  1741. if(self.selector) {
  1742. return smalltalk.convertSelector(self.selector);
  1743. } else {
  1744. return nil;
  1745. }
  1746. ;
  1747. return self}, function($ctx1) {$ctx1.fill(self,"selector",{},globals.MethodContext)})},
  1748. args: [],
  1749. source: "selector\x0a\x09<\x0a\x09\x09if(self.selector) {\x0a\x09\x09\x09return smalltalk.convertSelector(self.selector);\x0a\x09\x09} else {\x0a\x09\x09\x09return nil;\x0a\x09\x09}\x0a\x09>",
  1750. messageSends: [],
  1751. referencedClasses: []
  1752. }),
  1753. globals.MethodContext);
  1754. smalltalk.addMethod(
  1755. smalltalk.method({
  1756. selector: "sendIndexAt:",
  1757. protocol: 'accessing',
  1758. fn: function (aSelector){
  1759. var self=this;
  1760. return smalltalk.withContext(function($ctx1) {
  1761. return self.sendIdx[aSelector] || 0;
  1762. return self}, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aSelector:aSelector},globals.MethodContext)})},
  1763. args: ["aSelector"],
  1764. source: "sendIndexAt: aSelector\x0a\x09<return self.sendIdx[aSelector] || 0>",
  1765. messageSends: [],
  1766. referencedClasses: []
  1767. }),
  1768. globals.MethodContext);
  1769. smalltalk.addMethod(
  1770. smalltalk.method({
  1771. selector: "sendIndexes",
  1772. protocol: 'accessing',
  1773. fn: function (){
  1774. var self=this;
  1775. return smalltalk.withContext(function($ctx1) {
  1776. return self.sendIdx;
  1777. return self}, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},globals.MethodContext)})},
  1778. args: [],
  1779. source: "sendIndexes\x0a\x09<return self.sendIdx>",
  1780. messageSends: [],
  1781. referencedClasses: []
  1782. }),
  1783. globals.MethodContext);
  1784. smalltalk.addMethod(
  1785. smalltalk.method({
  1786. selector: "supercall",
  1787. protocol: 'accessing',
  1788. fn: function (){
  1789. var self=this;
  1790. return smalltalk.withContext(function($ctx1) {
  1791. return self.supercall == true;
  1792. return self}, function($ctx1) {$ctx1.fill(self,"supercall",{},globals.MethodContext)})},
  1793. args: [],
  1794. source: "supercall\x0a\x09<return self.supercall == true>",
  1795. messageSends: [],
  1796. referencedClasses: []
  1797. }),
  1798. globals.MethodContext);
  1799. smalltalk.addMethod(
  1800. smalltalk.method({
  1801. selector: "temps",
  1802. protocol: 'accessing',
  1803. fn: function (){
  1804. var self=this;
  1805. return smalltalk.withContext(function($ctx1) {
  1806. var $1;
  1807. self._deprecatedAPI();
  1808. $1=self._locals();
  1809. return $1;
  1810. }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.MethodContext)})},
  1811. args: [],
  1812. source: "temps\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09^ self locals",
  1813. messageSends: ["deprecatedAPI", "locals"],
  1814. referencedClasses: []
  1815. }),
  1816. globals.MethodContext);
  1817. smalltalk.addClass('NativeFunction', globals.Object, [], 'Kernel-Methods');
  1818. globals.NativeFunction.comment="I am a wrapper around native functions, such as `WebSocket`.\x0aFor 'normal' functions (whose constructor is the JavaScript `Function` object), use `BlockClosure`.\x0a\x0a## API\x0a\x0aSee the class-side `instance creation` methods for instance creation.\x0a\x0aCreated instances will most probably be instance of `JSObjectProxy`.\x0a\x0a## Usage example:\x0a\x0a\x09| ws |\x0a\x09ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a\x09ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]";
  1819. smalltalk.addMethod(
  1820. smalltalk.method({
  1821. selector: "constructor:",
  1822. protocol: 'instance creation',
  1823. fn: function (aString){
  1824. var self=this;
  1825. return smalltalk.withContext(function($ctx1) {
  1826. var nativeFunc=eval(aString);
  1827. return new nativeFunc();
  1828. ;
  1829. return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString},globals.NativeFunction.klass)})},
  1830. args: ["aString"],
  1831. source: "constructor: aString\x0a\x09<\x0a\x09\x09var nativeFunc=eval(aString);\x0a\x09\x09return new nativeFunc();\x0a\x09>",
  1832. messageSends: [],
  1833. referencedClasses: []
  1834. }),
  1835. globals.NativeFunction.klass);
  1836. smalltalk.addMethod(
  1837. smalltalk.method({
  1838. selector: "constructor:value:",
  1839. protocol: 'instance creation',
  1840. fn: function (aString,anObject){
  1841. var self=this;
  1842. return smalltalk.withContext(function($ctx1) {
  1843. var nativeFunc=eval(aString);
  1844. return new nativeFunc(anObject);
  1845. ;
  1846. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject},globals.NativeFunction.klass)})},
  1847. args: ["aString", "anObject"],
  1848. source: "constructor: aString value:anObject\x0a\x09<\x0a\x09\x09var nativeFunc=eval(aString);\x0a\x09\x09return new nativeFunc(anObject);\x0a\x09>",
  1849. messageSends: [],
  1850. referencedClasses: []
  1851. }),
  1852. globals.NativeFunction.klass);
  1853. smalltalk.addMethod(
  1854. smalltalk.method({
  1855. selector: "constructor:value:value:",
  1856. protocol: 'instance creation',
  1857. fn: function (aString,anObject,anObject2){
  1858. var self=this;
  1859. return smalltalk.withContext(function($ctx1) {
  1860. var nativeFunc=eval(aString);
  1861. return new nativeFunc(anObject,anObject2);
  1862. ;
  1863. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2},globals.NativeFunction.klass)})},
  1864. args: ["aString", "anObject", "anObject2"],
  1865. source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a\x09\x09var nativeFunc=eval(aString);\x0a\x09\x09return new nativeFunc(anObject,anObject2);\x0a\x09>",
  1866. messageSends: [],
  1867. referencedClasses: []
  1868. }),
  1869. globals.NativeFunction.klass);
  1870. smalltalk.addMethod(
  1871. smalltalk.method({
  1872. selector: "constructor:value:value:value:",
  1873. protocol: 'instance creation',
  1874. fn: function (aString,anObject,anObject2,anObject3){
  1875. var self=this;
  1876. return smalltalk.withContext(function($ctx1) {
  1877. var nativeFunc=eval(aString);
  1878. return new nativeFunc(anObject,anObject2, anObject3);
  1879. ;
  1880. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3},globals.NativeFunction.klass)})},
  1881. args: ["aString", "anObject", "anObject2", "anObject3"],
  1882. source: "constructor: aString value:anObject value: anObject2 value:anObject3\x0a\x09<\x0a\x09\x09var nativeFunc=eval(aString);\x0a\x09\x09return new nativeFunc(anObject,anObject2, anObject3);\x0a\x09>",
  1883. messageSends: [],
  1884. referencedClasses: []
  1885. }),
  1886. globals.NativeFunction.klass);
  1887. smalltalk.addMethod(
  1888. smalltalk.method({
  1889. selector: "exists:",
  1890. protocol: 'testing',
  1891. fn: function (aString){
  1892. var self=this;
  1893. function $PlatformInterface(){return globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1894. return smalltalk.withContext(function($ctx1) {
  1895. var $1;
  1896. $1=_st($PlatformInterface())._existsGlobal_(aString);
  1897. return $1;
  1898. }, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},globals.NativeFunction.klass)})},
  1899. args: ["aString"],
  1900. source: "exists: aString\x0a\x09^ PlatformInterface existsGlobal: aString",
  1901. messageSends: ["existsGlobal:"],
  1902. referencedClasses: ["PlatformInterface"]
  1903. }),
  1904. globals.NativeFunction.klass);
  1905. smalltalk.addClass('Timeout', globals.Object, ['rawTimeout'], 'Kernel-Methods');
  1906. globals.Timeout.comment="I am wrapping the returns from `set{Timeout,Interval}`.\x0a\x0a## Motivation\x0a\x0aNumber suffices in browsers, but node.js returns an object.";
  1907. smalltalk.addMethod(
  1908. smalltalk.method({
  1909. selector: "clearInterval",
  1910. protocol: 'timeout/interval',
  1911. fn: function (){
  1912. var self=this;
  1913. return smalltalk.withContext(function($ctx1) {
  1914. var interval = self["@rawTimeout"];
  1915. clearInterval(interval);
  1916. ;
  1917. return self}, function($ctx1) {$ctx1.fill(self,"clearInterval",{},globals.Timeout)})},
  1918. args: [],
  1919. source: "clearInterval\x0a\x09<\x0a\x09\x09var interval = self[\x22@rawTimeout\x22];\x0a\x09\x09clearInterval(interval);\x0a\x09>",
  1920. messageSends: [],
  1921. referencedClasses: []
  1922. }),
  1923. globals.Timeout);
  1924. smalltalk.addMethod(
  1925. smalltalk.method({
  1926. selector: "clearTimeout",
  1927. protocol: 'timeout/interval',
  1928. fn: function (){
  1929. var self=this;
  1930. return smalltalk.withContext(function($ctx1) {
  1931. var timeout = self["@rawTimeout"];
  1932. clearTimeout(timeout);
  1933. ;
  1934. return self}, function($ctx1) {$ctx1.fill(self,"clearTimeout",{},globals.Timeout)})},
  1935. args: [],
  1936. source: "clearTimeout\x0a\x09<\x0a\x09\x09var timeout = self[\x22@rawTimeout\x22];\x0a\x09\x09clearTimeout(timeout);\x0a\x09>",
  1937. messageSends: [],
  1938. referencedClasses: []
  1939. }),
  1940. globals.Timeout);
  1941. smalltalk.addMethod(
  1942. smalltalk.method({
  1943. selector: "rawTimeout:",
  1944. protocol: 'accessing',
  1945. fn: function (anObject){
  1946. var self=this;
  1947. self["@rawTimeout"]=anObject;
  1948. return self},
  1949. args: ["anObject"],
  1950. source: "rawTimeout: anObject\x0a\x09rawTimeout := anObject",
  1951. messageSends: [],
  1952. referencedClasses: []
  1953. }),
  1954. globals.Timeout);
  1955. smalltalk.addMethod(
  1956. smalltalk.method({
  1957. selector: "on:",
  1958. protocol: 'instance creation',
  1959. fn: function (anObject){
  1960. var self=this;
  1961. return smalltalk.withContext(function($ctx1) {
  1962. var $2,$3,$1;
  1963. $2=self._new();
  1964. _st($2)._rawTimeout_(anObject);
  1965. $3=_st($2)._yourself();
  1966. $1=$3;
  1967. return $1;
  1968. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},globals.Timeout.klass)})},
  1969. args: ["anObject"],
  1970. source: "on: anObject\x0a\x09^ self new rawTimeout: anObject; yourself",
  1971. messageSends: ["rawTimeout:", "new", "yourself"],
  1972. referencedClasses: []
  1973. }),
  1974. globals.Timeout.klass);
  1975. });