Kernel-Methods.js 64 KB

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