1
0

Kernel-Methods.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. smalltalk.addPackage('Kernel-Methods');
  2. smalltalk.addClass('BlockClosure', smalltalk.Object, [], 'Kernel-Methods');
  3. smalltalk.BlockClosure.comment="A BlockClosure is a lexical closure.\x0aThe JavaScript representation is a function.\x0a\x0aA BlockClosure is evaluated with the `#value*` methods in the 'evaluating' protocol."
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "applyTo:arguments:",
  7. category: 'evaluating',
  8. fn: function (anObject,aCollection){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. return self.apply(anObject, aCollection);
  12. return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},smalltalk.BlockClosure)})},
  13. args: ["anObject", "aCollection"],
  14. source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. smalltalk.BlockClosure);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "asCompiledMethod:",
  22. category: 'converting',
  23. fn: function (aString){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx1) {
  26. return smalltalk.method({selector:aString, fn:self});;
  27. return self}, function($ctx1) {$ctx1.fill(self,"asCompiledMethod:",{aString:aString},smalltalk.BlockClosure)})},
  28. args: ["aString"],
  29. source: "asCompiledMethod: aString\x0a\x09<return smalltalk.method({selector:aString, fn:self});>",
  30. messageSends: [],
  31. referencedClasses: []
  32. }),
  33. smalltalk.BlockClosure);
  34. smalltalk.addMethod(
  35. smalltalk.method({
  36. selector: "compiledSource",
  37. category: 'accessing',
  38. fn: function (){
  39. var self=this;
  40. return smalltalk.withContext(function($ctx1) {
  41. return self.toString();
  42. return self}, function($ctx1) {$ctx1.fill(self,"compiledSource",{},smalltalk.BlockClosure)})},
  43. args: [],
  44. source: "compiledSource\x0a\x09<return self.toString()>",
  45. messageSends: [],
  46. referencedClasses: []
  47. }),
  48. smalltalk.BlockClosure);
  49. smalltalk.addMethod(
  50. smalltalk.method({
  51. selector: "currySelf",
  52. category: 'converting',
  53. fn: function (){
  54. var self=this;
  55. return smalltalk.withContext(function($ctx1) {
  56. return function () {
  57. var args = [ this ];
  58. args.push.apply(args, arguments);
  59. return self.apply(null, args);
  60. }
  61. ;
  62. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},smalltalk.BlockClosure)})},
  63. args: [],
  64. 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>",
  65. messageSends: [],
  66. referencedClasses: []
  67. }),
  68. smalltalk.BlockClosure);
  69. smalltalk.addMethod(
  70. smalltalk.method({
  71. selector: "ensure:",
  72. category: 'evaluating',
  73. fn: function (aBlock){
  74. var self=this;
  75. return smalltalk.withContext(function($ctx1) {
  76. try{return self()}finally{aBlock._value()};
  77. return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock},smalltalk.BlockClosure)})},
  78. args: ["aBlock"],
  79. source: "ensure: aBlock\x0a\x09<try{return self()}finally{aBlock._value()}>",
  80. messageSends: [],
  81. referencedClasses: []
  82. }),
  83. smalltalk.BlockClosure);
  84. smalltalk.addMethod(
  85. smalltalk.method({
  86. selector: "fork",
  87. category: 'timeout/interval',
  88. fn: function (){
  89. var self=this;
  90. function $ForkPool(){return smalltalk.ForkPool||(typeof ForkPool=="undefined"?nil:ForkPool)}
  91. return smalltalk.withContext(function($ctx1) {
  92. _st(_st($ForkPool())._default())._fork_(self);
  93. return self}, function($ctx1) {$ctx1.fill(self,"fork",{},smalltalk.BlockClosure)})},
  94. args: [],
  95. source: "fork\x0a\x09ForkPool default fork: self",
  96. messageSends: ["fork:", "default"],
  97. referencedClasses: ["ForkPool"]
  98. }),
  99. smalltalk.BlockClosure);
  100. smalltalk.addMethod(
  101. smalltalk.method({
  102. selector: "new",
  103. category: 'evaluating',
  104. fn: function (){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) {
  107. return new self();
  108. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.BlockClosure)})},
  109. args: [],
  110. 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()>",
  111. messageSends: [],
  112. referencedClasses: []
  113. }),
  114. smalltalk.BlockClosure);
  115. smalltalk.addMethod(
  116. smalltalk.method({
  117. selector: "newValue:",
  118. category: 'evaluating',
  119. fn: function (anObject){
  120. var self=this;
  121. return smalltalk.withContext(function($ctx1) {
  122. return new self(anObject);
  123. return self}, function($ctx1) {$ctx1.fill(self,"newValue:",{anObject:anObject},smalltalk.BlockClosure)})},
  124. args: ["anObject"],
  125. source: "newValue: anObject\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(anObject)>",
  126. messageSends: [],
  127. referencedClasses: []
  128. }),
  129. smalltalk.BlockClosure);
  130. smalltalk.addMethod(
  131. smalltalk.method({
  132. selector: "newValue:value:",
  133. category: 'evaluating',
  134. fn: function (anObject,anObject2){
  135. var self=this;
  136. return smalltalk.withContext(function($ctx1) {
  137. return new self(anObject, anObject2);
  138. return self}, function($ctx1) {$ctx1.fill(self,"newValue:value:",{anObject:anObject,anObject2:anObject2},smalltalk.BlockClosure)})},
  139. args: ["anObject", "anObject2"],
  140. source: "newValue: anObject value: anObject2\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(anObject, anObject2)>",
  141. messageSends: [],
  142. referencedClasses: []
  143. }),
  144. smalltalk.BlockClosure);
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "newValue:value:value:",
  148. category: 'evaluating',
  149. fn: function (anObject,anObject2,anObject3){
  150. var self=this;
  151. return smalltalk.withContext(function($ctx1) {
  152. return new self(anObject, anObject2,anObject3);
  153. return self}, function($ctx1) {$ctx1.fill(self,"newValue:value:value:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3},smalltalk.BlockClosure)})},
  154. args: ["anObject", "anObject2", "anObject3"],
  155. source: "newValue: anObject value: anObject2 value: anObject3\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(anObject, anObject2,anObject3)>",
  156. messageSends: [],
  157. referencedClasses: []
  158. }),
  159. smalltalk.BlockClosure);
  160. smalltalk.addMethod(
  161. smalltalk.method({
  162. selector: "numArgs",
  163. category: 'accessing',
  164. fn: function (){
  165. var self=this;
  166. return smalltalk.withContext(function($ctx1) {
  167. return self.length;
  168. return self}, function($ctx1) {$ctx1.fill(self,"numArgs",{},smalltalk.BlockClosure)})},
  169. args: [],
  170. source: "numArgs\x0a\x09<return self.length>",
  171. messageSends: [],
  172. referencedClasses: []
  173. }),
  174. smalltalk.BlockClosure);
  175. smalltalk.addMethod(
  176. smalltalk.method({
  177. selector: "on:do:",
  178. category: 'error handling',
  179. fn: function (anErrorClass,aBlock){
  180. var self=this;
  181. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  182. return smalltalk.withContext(function($ctx1) {
  183. var $2,$1;
  184. $1=_st(self)._try_catch_(self,(function(error){
  185. var smalltalkError;
  186. return smalltalk.withContext(function($ctx2) {
  187. smalltalkError=_st(_st($Smalltalk())._current())._asSmalltalkException_(error);
  188. smalltalkError;
  189. $2=_st(smalltalkError)._isKindOf_(anErrorClass);
  190. if(smalltalk.assert($2)){
  191. return _st(aBlock)._value_(smalltalkError);
  192. } else {
  193. return _st(smalltalkError)._signal();
  194. };
  195. }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1)})}));
  196. return $1;
  197. }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock},smalltalk.BlockClosure)})},
  198. args: ["anErrorClass", "aBlock"],
  199. 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 signal ] ]",
  200. messageSends: ["try:catch:", "asSmalltalkException:", "current", "ifTrue:ifFalse:", "value:", "signal", "isKindOf:"],
  201. referencedClasses: ["Smalltalk"]
  202. }),
  203. smalltalk.BlockClosure);
  204. smalltalk.addMethod(
  205. smalltalk.method({
  206. selector: "receiver",
  207. category: 'accessing',
  208. fn: function (){
  209. var self=this;
  210. return smalltalk.withContext(function($ctx1) {
  211. return nil;
  212. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.BlockClosure)})},
  213. args: [],
  214. source: "receiver\x0a\x09^ nil",
  215. messageSends: [],
  216. referencedClasses: []
  217. }),
  218. smalltalk.BlockClosure);
  219. smalltalk.addMethod(
  220. smalltalk.method({
  221. selector: "timeToRun",
  222. category: 'evaluating',
  223. fn: function (){
  224. var self=this;
  225. function $Date(){return smalltalk.Date||(typeof Date=="undefined"?nil:Date)}
  226. return smalltalk.withContext(function($ctx1) {
  227. var $1;
  228. $1=_st($Date())._millisecondsToRun_(self);
  229. return $1;
  230. }, function($ctx1) {$ctx1.fill(self,"timeToRun",{},smalltalk.BlockClosure)})},
  231. args: [],
  232. source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
  233. messageSends: ["millisecondsToRun:"],
  234. referencedClasses: ["Date"]
  235. }),
  236. smalltalk.BlockClosure);
  237. smalltalk.addMethod(
  238. smalltalk.method({
  239. selector: "value",
  240. category: 'evaluating',
  241. fn: function (){
  242. var self=this;
  243. return smalltalk.withContext(function($ctx1) {
  244. return self();;
  245. return self}, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.BlockClosure)})},
  246. args: [],
  247. source: "value\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self();>",
  248. messageSends: [],
  249. referencedClasses: []
  250. }),
  251. smalltalk.BlockClosure);
  252. smalltalk.addMethod(
  253. smalltalk.method({
  254. selector: "value:",
  255. category: 'evaluating',
  256. fn: function (anArg){
  257. var self=this;
  258. return smalltalk.withContext(function($ctx1) {
  259. return self(anArg);;
  260. return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg},smalltalk.BlockClosure)})},
  261. args: ["anArg"],
  262. source: "value: anArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(anArg);>",
  263. messageSends: [],
  264. referencedClasses: []
  265. }),
  266. smalltalk.BlockClosure);
  267. smalltalk.addMethod(
  268. smalltalk.method({
  269. selector: "value:value:",
  270. category: 'evaluating',
  271. fn: function (firstArg,secondArg){
  272. var self=this;
  273. return smalltalk.withContext(function($ctx1) {
  274. return self(firstArg, secondArg);;
  275. return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg},smalltalk.BlockClosure)})},
  276. args: ["firstArg", "secondArg"],
  277. source: "value: firstArg value: secondArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg);>",
  278. messageSends: [],
  279. referencedClasses: []
  280. }),
  281. smalltalk.BlockClosure);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "value:value:value:",
  285. category: 'evaluating',
  286. fn: function (firstArg,secondArg,thirdArg){
  287. var self=this;
  288. return smalltalk.withContext(function($ctx1) {
  289. return self(firstArg, secondArg, thirdArg);;
  290. return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg},smalltalk.BlockClosure)})},
  291. args: ["firstArg", "secondArg", "thirdArg"],
  292. source: "value: firstArg value: secondArg value: thirdArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
  293. messageSends: [],
  294. referencedClasses: []
  295. }),
  296. smalltalk.BlockClosure);
  297. smalltalk.addMethod(
  298. smalltalk.method({
  299. selector: "valueWithInterval:",
  300. category: 'timeout/interval',
  301. fn: function (aNumber){
  302. var self=this;
  303. return smalltalk.withContext(function($ctx1) {
  304. var interval = setInterval(self, aNumber);
  305. return smalltalk.Timeout._on_(interval);
  306. ;
  307. return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber},smalltalk.BlockClosure)})},
  308. args: ["aNumber"],
  309. source: "valueWithInterval: aNumber\x0a\x09<\x0a\x09\x09var interval = setInterval(self, aNumber);\x0a\x09\x09return smalltalk.Timeout._on_(interval);\x0a\x09>",
  310. messageSends: [],
  311. referencedClasses: []
  312. }),
  313. smalltalk.BlockClosure);
  314. smalltalk.addMethod(
  315. smalltalk.method({
  316. selector: "valueWithPossibleArguments:",
  317. category: 'evaluating',
  318. fn: function (aCollection){
  319. var self=this;
  320. return smalltalk.withContext(function($ctx1) {
  321. return self.apply(null, aCollection);;
  322. return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection},smalltalk.BlockClosure)})},
  323. args: ["aCollection"],
  324. source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
  325. messageSends: [],
  326. referencedClasses: []
  327. }),
  328. smalltalk.BlockClosure);
  329. smalltalk.addMethod(
  330. smalltalk.method({
  331. selector: "valueWithTimeout:",
  332. category: 'timeout/interval',
  333. fn: function (aNumber){
  334. var self=this;
  335. return smalltalk.withContext(function($ctx1) {
  336. var timeout = setTimeout(self, aNumber);
  337. return smalltalk.Timeout._on_(timeout);
  338. ;
  339. return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber},smalltalk.BlockClosure)})},
  340. args: ["aNumber"],
  341. source: "valueWithTimeout: aNumber\x0a\x09<\x0a\x09\x09var timeout = setTimeout(self, aNumber);\x0a\x09\x09return smalltalk.Timeout._on_(timeout);\x0a\x09>",
  342. messageSends: [],
  343. referencedClasses: []
  344. }),
  345. smalltalk.BlockClosure);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "whileFalse",
  349. category: 'controlling',
  350. fn: function (){
  351. var self=this;
  352. return smalltalk.withContext(function($ctx1) {
  353. _st(self)._whileFalse_((function(){
  354. return smalltalk.withContext(function($ctx2) {
  355. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  356. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{},smalltalk.BlockClosure)})},
  357. args: [],
  358. source: "whileFalse\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileFalse: []",
  359. messageSends: ["whileFalse:"],
  360. referencedClasses: []
  361. }),
  362. smalltalk.BlockClosure);
  363. smalltalk.addMethod(
  364. smalltalk.method({
  365. selector: "whileFalse:",
  366. category: 'controlling',
  367. fn: function (aBlock){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) {
  370. while(!self()) {aBlock()};
  371. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock},smalltalk.BlockClosure)})},
  372. args: ["aBlock"],
  373. source: "whileFalse: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(!self()) {aBlock()}>",
  374. messageSends: [],
  375. referencedClasses: []
  376. }),
  377. smalltalk.BlockClosure);
  378. smalltalk.addMethod(
  379. smalltalk.method({
  380. selector: "whileTrue",
  381. category: 'controlling',
  382. fn: function (){
  383. var self=this;
  384. return smalltalk.withContext(function($ctx1) {
  385. _st(self)._whileTrue_((function(){
  386. return smalltalk.withContext(function($ctx2) {
  387. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  388. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{},smalltalk.BlockClosure)})},
  389. args: [],
  390. source: "whileTrue\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileTrue: []",
  391. messageSends: ["whileTrue:"],
  392. referencedClasses: []
  393. }),
  394. smalltalk.BlockClosure);
  395. smalltalk.addMethod(
  396. smalltalk.method({
  397. selector: "whileTrue:",
  398. category: 'controlling',
  399. fn: function (aBlock){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) {
  402. while(self()) {aBlock()};
  403. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock},smalltalk.BlockClosure)})},
  404. args: ["aBlock"],
  405. source: "whileTrue: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(self()) {aBlock()}>",
  406. messageSends: [],
  407. referencedClasses: []
  408. }),
  409. smalltalk.BlockClosure);
  410. smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
  411. smalltalk.CompiledMethod.comment="CompiledMethod hold the source and compiled code of a class method.\x0a\x0aYou can get a CompiledMethod using `Behavior>>methodAt:`\x0a\x0a\x09String methodAt: 'lines'\x0a\x0aand read the source code\x0a\x0a\x09(String methodAt: 'lines') source\x0a\x0aSee referenced classes:\x0a\x0a\x09(String methodAt: 'lines') referencedClasses\x0a\x0aor messages sent from this method:\x0a\x09\x0a\x09(String methodAt: 'lines') messageSends"
  412. smalltalk.addMethod(
  413. smalltalk.method({
  414. selector: "arguments",
  415. category: 'accessing',
  416. fn: function (){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) {
  419. return self.args || [];
  420. return self}, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.CompiledMethod)})},
  421. args: [],
  422. source: "arguments\x0a\x09<return self.args || []>",
  423. messageSends: [],
  424. referencedClasses: []
  425. }),
  426. smalltalk.CompiledMethod);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "category",
  430. category: 'accessing',
  431. fn: function (){
  432. var self=this;
  433. return smalltalk.withContext(function($ctx1) {
  434. var $2,$1;
  435. $2=_st(self)._basicAt_("category");
  436. if(($receiver = $2) == nil || $receiver == undefined){
  437. $1=_st(self)._defaultCategory();
  438. } else {
  439. $1=$2;
  440. };
  441. return $1;
  442. }, function($ctx1) {$ctx1.fill(self,"category",{},smalltalk.CompiledMethod)})},
  443. args: [],
  444. source: "category\x0a\x09^(self basicAt: 'category') ifNil: [ self defaultCategory ]",
  445. messageSends: ["ifNil:", "defaultCategory", "basicAt:"],
  446. referencedClasses: []
  447. }),
  448. smalltalk.CompiledMethod);
  449. smalltalk.addMethod(
  450. smalltalk.method({
  451. selector: "category:",
  452. category: 'accessing',
  453. fn: function (aString){
  454. var self=this;
  455. var oldProtocol;
  456. function $MethodMoved(){return smalltalk.MethodMoved||(typeof MethodMoved=="undefined"?nil:MethodMoved)}
  457. function $SystemAnnouncer(){return smalltalk.SystemAnnouncer||(typeof SystemAnnouncer=="undefined"?nil:SystemAnnouncer)}
  458. return smalltalk.withContext(function($ctx1) {
  459. var $1,$2,$3;
  460. oldProtocol=_st(self)._protocol();
  461. _st(self)._basicAt_put_("category",aString);
  462. $1=_st($MethodMoved())._new();
  463. _st($1)._method_(self);
  464. _st($1)._oldProtocol_(oldProtocol);
  465. $2=_st($1)._yourself();
  466. _st(_st($SystemAnnouncer())._current())._announce_($2);
  467. $3=_st(self)._methodClass();
  468. if(($receiver = $3) == nil || $receiver == undefined){
  469. $3;
  470. } else {
  471. _st(_st(_st(self)._methodClass())._organization())._addElement_(aString);
  472. _st(_st(_st(_st(self)._methodClass())._methods())._select_((function(each){
  473. return smalltalk.withContext(function($ctx2) {
  474. return _st(_st(each)._protocol()).__eq(oldProtocol);
  475. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._ifEmpty_((function(){
  476. return smalltalk.withContext(function($ctx2) {
  477. return _st(_st(_st(self)._methodClass())._organization())._removeElement_(oldProtocol);
  478. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  479. };
  480. return self}, function($ctx1) {$ctx1.fill(self,"category:",{aString:aString,oldProtocol:oldProtocol},smalltalk.CompiledMethod)})},
  481. args: ["aString"],
  482. 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 ] ]",
  483. messageSends: ["protocol", "basicAt:put:", "announce:", "method:", "new", "oldProtocol:", "yourself", "current", "ifNotNil:", "addElement:", "organization", "methodClass", "ifEmpty:", "removeElement:", "select:", "=", "methods"],
  484. referencedClasses: ["MethodMoved", "SystemAnnouncer"]
  485. }),
  486. smalltalk.CompiledMethod);
  487. smalltalk.addMethod(
  488. smalltalk.method({
  489. selector: "defaultCategory",
  490. category: 'defaults',
  491. fn: function (){
  492. var self=this;
  493. return smalltalk.withContext(function($ctx1) {
  494. return "as yet unclassified";
  495. }, function($ctx1) {$ctx1.fill(self,"defaultCategory",{},smalltalk.CompiledMethod)})},
  496. args: [],
  497. source: "defaultCategory\x0a\x09^ 'as yet unclassified'",
  498. messageSends: [],
  499. referencedClasses: []
  500. }),
  501. smalltalk.CompiledMethod);
  502. smalltalk.addMethod(
  503. smalltalk.method({
  504. selector: "fn",
  505. category: 'accessing',
  506. fn: function (){
  507. var self=this;
  508. return smalltalk.withContext(function($ctx1) {
  509. var $1;
  510. $1=_st(self)._basicAt_("fn");
  511. return $1;
  512. }, function($ctx1) {$ctx1.fill(self,"fn",{},smalltalk.CompiledMethod)})},
  513. args: [],
  514. source: "fn\x0a\x09^self basicAt: 'fn'",
  515. messageSends: ["basicAt:"],
  516. referencedClasses: []
  517. }),
  518. smalltalk.CompiledMethod);
  519. smalltalk.addMethod(
  520. smalltalk.method({
  521. selector: "fn:",
  522. category: 'accessing',
  523. fn: function (aBlock){
  524. var self=this;
  525. return smalltalk.withContext(function($ctx1) {
  526. _st(self)._basicAt_put_("fn",aBlock);
  527. return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock},smalltalk.CompiledMethod)})},
  528. args: ["aBlock"],
  529. source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
  530. messageSends: ["basicAt:put:"],
  531. referencedClasses: []
  532. }),
  533. smalltalk.CompiledMethod);
  534. smalltalk.addMethod(
  535. smalltalk.method({
  536. selector: "isCompiledMethod",
  537. category: 'testing',
  538. fn: function (){
  539. var self=this;
  540. return smalltalk.withContext(function($ctx1) {
  541. return true;
  542. }, function($ctx1) {$ctx1.fill(self,"isCompiledMethod",{},smalltalk.CompiledMethod)})},
  543. args: [],
  544. source: "isCompiledMethod\x0a\x09^ true",
  545. messageSends: [],
  546. referencedClasses: []
  547. }),
  548. smalltalk.CompiledMethod);
  549. smalltalk.addMethod(
  550. smalltalk.method({
  551. selector: "isOverridden",
  552. category: 'testing',
  553. fn: function (){
  554. var self=this;
  555. var selector;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1;
  558. var $early={};
  559. try {
  560. selector=_st(self)._selector();
  561. _st(_st(self)._methodClass())._allSubclassesDo_((function(each){
  562. return smalltalk.withContext(function($ctx2) {
  563. $1=_st(each)._includesSelector_(selector);
  564. if(smalltalk.assert($1)){
  565. throw $early=[true];
  566. };
  567. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  568. return false;
  569. }
  570. catch(e) {if(e===$early)return e[0]; throw e}
  571. }, function($ctx1) {$ctx1.fill(self,"isOverridden",{selector:selector},smalltalk.CompiledMethod)})},
  572. args: [],
  573. 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",
  574. messageSends: ["selector", "allSubclassesDo:", "ifTrue:", "includesSelector:", "methodClass"],
  575. referencedClasses: []
  576. }),
  577. smalltalk.CompiledMethod);
  578. smalltalk.addMethod(
  579. smalltalk.method({
  580. selector: "isOverride",
  581. category: 'testing',
  582. fn: function (){
  583. var self=this;
  584. var superclass;
  585. return smalltalk.withContext(function($ctx1) {
  586. var $1,$2;
  587. superclass=_st(_st(self)._methodClass())._superclass();
  588. $1=superclass;
  589. if(($receiver = $1) == nil || $receiver == undefined){
  590. return false;
  591. } else {
  592. $1;
  593. };
  594. $2=_st(_st(_st(_st(self)._methodClass())._superclass())._lookupSelector_(_st(self)._selector()))._notNil();
  595. return $2;
  596. }, function($ctx1) {$ctx1.fill(self,"isOverride",{superclass:superclass},smalltalk.CompiledMethod)})},
  597. args: [],
  598. 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",
  599. messageSends: ["superclass", "methodClass", "ifNil:", "notNil", "lookupSelector:", "selector"],
  600. referencedClasses: []
  601. }),
  602. smalltalk.CompiledMethod);
  603. smalltalk.addMethod(
  604. smalltalk.method({
  605. selector: "messageSends",
  606. category: 'accessing',
  607. fn: function (){
  608. var self=this;
  609. return smalltalk.withContext(function($ctx1) {
  610. var $1;
  611. $1=_st(self)._basicAt_("messageSends");
  612. return $1;
  613. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},smalltalk.CompiledMethod)})},
  614. args: [],
  615. source: "messageSends\x0a\x09^self basicAt: 'messageSends'",
  616. messageSends: ["basicAt:"],
  617. referencedClasses: []
  618. }),
  619. smalltalk.CompiledMethod);
  620. smalltalk.addMethod(
  621. smalltalk.method({
  622. selector: "methodClass",
  623. category: 'accessing',
  624. fn: function (){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) {
  627. var $1;
  628. $1=_st(self)._basicAt_("methodClass");
  629. return $1;
  630. }, function($ctx1) {$ctx1.fill(self,"methodClass",{},smalltalk.CompiledMethod)})},
  631. args: [],
  632. source: "methodClass\x0a\x09^self basicAt: 'methodClass'",
  633. messageSends: ["basicAt:"],
  634. referencedClasses: []
  635. }),
  636. smalltalk.CompiledMethod);
  637. smalltalk.addMethod(
  638. smalltalk.method({
  639. selector: "protocol",
  640. category: 'accessing',
  641. fn: function (){
  642. var self=this;
  643. return smalltalk.withContext(function($ctx1) {
  644. var $1;
  645. $1=_st(self)._category();
  646. return $1;
  647. }, function($ctx1) {$ctx1.fill(self,"protocol",{},smalltalk.CompiledMethod)})},
  648. args: [],
  649. source: "protocol\x0a\x09^ self category",
  650. messageSends: ["category"],
  651. referencedClasses: []
  652. }),
  653. smalltalk.CompiledMethod);
  654. smalltalk.addMethod(
  655. smalltalk.method({
  656. selector: "protocol:",
  657. category: 'accessing',
  658. fn: function (aString){
  659. var self=this;
  660. return smalltalk.withContext(function($ctx1) {
  661. _st(self)._category_(aString);
  662. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString},smalltalk.CompiledMethod)})},
  663. args: ["aString"],
  664. source: "protocol: aString\x0a\x09self category: aString",
  665. messageSends: ["category:"],
  666. referencedClasses: []
  667. }),
  668. smalltalk.CompiledMethod);
  669. smalltalk.addMethod(
  670. smalltalk.method({
  671. selector: "referencedClasses",
  672. category: 'accessing',
  673. fn: function (){
  674. var self=this;
  675. return smalltalk.withContext(function($ctx1) {
  676. var $1;
  677. $1=_st(self)._basicAt_("referencedClasses");
  678. return $1;
  679. }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{},smalltalk.CompiledMethod)})},
  680. args: [],
  681. source: "referencedClasses\x0a\x09^self basicAt: 'referencedClasses'",
  682. messageSends: ["basicAt:"],
  683. referencedClasses: []
  684. }),
  685. smalltalk.CompiledMethod);
  686. smalltalk.addMethod(
  687. smalltalk.method({
  688. selector: "selector",
  689. category: 'accessing',
  690. fn: function (){
  691. var self=this;
  692. return smalltalk.withContext(function($ctx1) {
  693. var $1;
  694. $1=_st(self)._basicAt_("selector");
  695. return $1;
  696. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.CompiledMethod)})},
  697. args: [],
  698. source: "selector\x0a\x09^self basicAt: 'selector'",
  699. messageSends: ["basicAt:"],
  700. referencedClasses: []
  701. }),
  702. smalltalk.CompiledMethod);
  703. smalltalk.addMethod(
  704. smalltalk.method({
  705. selector: "selector:",
  706. category: 'accessing',
  707. fn: function (aString){
  708. var self=this;
  709. return smalltalk.withContext(function($ctx1) {
  710. _st(self)._basicAt_put_("selector",aString);
  711. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.CompiledMethod)})},
  712. args: ["aString"],
  713. source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
  714. messageSends: ["basicAt:put:"],
  715. referencedClasses: []
  716. }),
  717. smalltalk.CompiledMethod);
  718. smalltalk.addMethod(
  719. smalltalk.method({
  720. selector: "source",
  721. category: 'accessing',
  722. fn: function (){
  723. var self=this;
  724. return smalltalk.withContext(function($ctx1) {
  725. var $2,$1;
  726. $2=_st(self)._basicAt_("source");
  727. if(($receiver = $2) == nil || $receiver == undefined){
  728. $1="";
  729. } else {
  730. $1=$2;
  731. };
  732. return $1;
  733. }, function($ctx1) {$ctx1.fill(self,"source",{},smalltalk.CompiledMethod)})},
  734. args: [],
  735. source: "source\x0a\x09^(self basicAt: 'source') ifNil: ['']",
  736. messageSends: ["ifNil:", "basicAt:"],
  737. referencedClasses: []
  738. }),
  739. smalltalk.CompiledMethod);
  740. smalltalk.addMethod(
  741. smalltalk.method({
  742. selector: "source:",
  743. category: 'accessing',
  744. fn: function (aString){
  745. var self=this;
  746. return smalltalk.withContext(function($ctx1) {
  747. _st(self)._basicAt_put_("source",aString);
  748. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString},smalltalk.CompiledMethod)})},
  749. args: ["aString"],
  750. source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
  751. messageSends: ["basicAt:put:"],
  752. referencedClasses: []
  753. }),
  754. smalltalk.CompiledMethod);
  755. smalltalk.addClass('ForkPool', smalltalk.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
  756. smalltalk.ForkPool.comment="A ForkPool is responsible for handling forked blocks.\x0aThe pool size sets the maximum concurrent forked blocks.\x0a\x0aThe default instance is accessed with `ForkPool default`"
  757. smalltalk.addMethod(
  758. smalltalk.method({
  759. selector: "addWorker",
  760. category: 'private',
  761. fn: function (){
  762. var self=this;
  763. return smalltalk.withContext(function($ctx1) {
  764. _st(self["@worker"])._valueWithTimeout_((0));
  765. self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
  766. return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{},smalltalk.ForkPool)})},
  767. args: [],
  768. source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a\x09poolSize := poolSize + 1",
  769. messageSends: ["valueWithTimeout:", "+"],
  770. referencedClasses: []
  771. }),
  772. smalltalk.ForkPool);
  773. smalltalk.addMethod(
  774. smalltalk.method({
  775. selector: "defaultMaxPoolSize",
  776. category: 'defaults',
  777. fn: function (){
  778. var self=this;
  779. return smalltalk.withContext(function($ctx1) {
  780. var $1;
  781. $1=_st(_st(self)._class())._defaultMaxPoolSize();
  782. return $1;
  783. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},smalltalk.ForkPool)})},
  784. args: [],
  785. source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
  786. messageSends: ["defaultMaxPoolSize", "class"],
  787. referencedClasses: []
  788. }),
  789. smalltalk.ForkPool);
  790. smalltalk.addMethod(
  791. smalltalk.method({
  792. selector: "fork:",
  793. category: 'actions',
  794. fn: function (aBlock){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. var $1;
  798. $1=_st(self["@poolSize"]).__lt(_st(self)._maxPoolSize());
  799. if(smalltalk.assert($1)){
  800. _st(self)._addWorker();
  801. };
  802. _st(self["@queue"])._nextPut_(aBlock);
  803. return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock},smalltalk.ForkPool)})},
  804. args: ["aBlock"],
  805. source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue nextPut: aBlock",
  806. messageSends: ["ifTrue:", "addWorker", "<", "maxPoolSize", "nextPut:"],
  807. referencedClasses: []
  808. }),
  809. smalltalk.ForkPool);
  810. smalltalk.addMethod(
  811. smalltalk.method({
  812. selector: "initialize",
  813. category: 'initialization',
  814. fn: function (){
  815. var self=this;
  816. function $Queue(){return smalltalk.Queue||(typeof Queue=="undefined"?nil:Queue)}
  817. return smalltalk.withContext(function($ctx1) {
  818. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  819. self["@poolSize"]=(0);
  820. self["@queue"]=_st($Queue())._new();
  821. self["@worker"]=_st(self)._makeWorker();
  822. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ForkPool)})},
  823. args: [],
  824. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09poolSize := 0.\x0a\x09queue := Queue new.\x0a\x09worker := self makeWorker",
  825. messageSends: ["initialize", "new", "makeWorker"],
  826. referencedClasses: ["Queue"]
  827. }),
  828. smalltalk.ForkPool);
  829. smalltalk.addMethod(
  830. smalltalk.method({
  831. selector: "makeWorker",
  832. category: 'initialization',
  833. fn: function (){
  834. var self=this;
  835. var sentinel;
  836. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  837. return smalltalk.withContext(function($ctx1) {
  838. var $2,$1;
  839. sentinel=_st($Object())._new();
  840. $1=(function(){
  841. var block;
  842. return smalltalk.withContext(function($ctx2) {
  843. self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
  844. self["@poolSize"];
  845. block=_st(self["@queue"])._nextIfAbsent_((function(){
  846. return smalltalk.withContext(function($ctx3) {
  847. return sentinel;
  848. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  849. block;
  850. $2=_st(block).__eq_eq(sentinel);
  851. if(! smalltalk.assert($2)){
  852. return _st((function(){
  853. return smalltalk.withContext(function($ctx3) {
  854. return _st(block)._value();
  855. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._ensure_((function(){
  856. return smalltalk.withContext(function($ctx3) {
  857. return _st(self)._addWorker();
  858. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  859. };
  860. }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1)})});
  861. return $1;
  862. }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel},smalltalk.ForkPool)})},
  863. args: [],
  864. 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 ]]]",
  865. messageSends: ["new", "-", "nextIfAbsent:", "ifFalse:", "ensure:", "addWorker", "value", "=="],
  866. referencedClasses: ["Object"]
  867. }),
  868. smalltalk.ForkPool);
  869. smalltalk.addMethod(
  870. smalltalk.method({
  871. selector: "maxPoolSize",
  872. category: 'accessing',
  873. fn: function (){
  874. var self=this;
  875. return smalltalk.withContext(function($ctx1) {
  876. var $2,$1;
  877. $2=self["@maxPoolSize"];
  878. if(($receiver = $2) == nil || $receiver == undefined){
  879. $1=_st(self)._defaultMaxPoolSize();
  880. } else {
  881. $1=$2;
  882. };
  883. return $1;
  884. }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{},smalltalk.ForkPool)})},
  885. args: [],
  886. source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
  887. messageSends: ["ifNil:", "defaultMaxPoolSize"],
  888. referencedClasses: []
  889. }),
  890. smalltalk.ForkPool);
  891. smalltalk.addMethod(
  892. smalltalk.method({
  893. selector: "maxPoolSize:",
  894. category: 'accessing',
  895. fn: function (anInteger){
  896. var self=this;
  897. return smalltalk.withContext(function($ctx1) {
  898. self["@maxPoolSize"]=anInteger;
  899. return self}, function($ctx1) {$ctx1.fill(self,"maxPoolSize:",{anInteger:anInteger},smalltalk.ForkPool)})},
  900. args: ["anInteger"],
  901. source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
  902. messageSends: [],
  903. referencedClasses: []
  904. }),
  905. smalltalk.ForkPool);
  906. smalltalk.ForkPool.klass.iVarNames = ['default'];
  907. smalltalk.addMethod(
  908. smalltalk.method({
  909. selector: "default",
  910. category: 'accessing',
  911. fn: function (){
  912. var self=this;
  913. return smalltalk.withContext(function($ctx1) {
  914. var $2,$1;
  915. $2=self["@default"];
  916. if(($receiver = $2) == nil || $receiver == undefined){
  917. self["@default"]=_st(self)._new();
  918. $1=self["@default"];
  919. } else {
  920. $1=$2;
  921. };
  922. return $1;
  923. }, function($ctx1) {$ctx1.fill(self,"default",{},smalltalk.ForkPool.klass)})},
  924. args: [],
  925. source: "default\x0a\x09^default ifNil: [ default := self new ]",
  926. messageSends: ["ifNil:", "new"],
  927. referencedClasses: []
  928. }),
  929. smalltalk.ForkPool.klass);
  930. smalltalk.addMethod(
  931. smalltalk.method({
  932. selector: "defaultMaxPoolSize",
  933. category: 'accessing',
  934. fn: function (){
  935. var self=this;
  936. return smalltalk.withContext(function($ctx1) {
  937. var $1;
  938. $1=(100);
  939. return $1;
  940. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{},smalltalk.ForkPool.klass)})},
  941. args: [],
  942. source: "defaultMaxPoolSize\x0a\x09^100",
  943. messageSends: [],
  944. referencedClasses: []
  945. }),
  946. smalltalk.ForkPool.klass);
  947. smalltalk.addMethod(
  948. smalltalk.method({
  949. selector: "resetDefault",
  950. category: 'accessing',
  951. fn: function (){
  952. var self=this;
  953. return smalltalk.withContext(function($ctx1) {
  954. self["@default"]=nil;
  955. return self}, function($ctx1) {$ctx1.fill(self,"resetDefault",{},smalltalk.ForkPool.klass)})},
  956. args: [],
  957. source: "resetDefault\x0a\x09default := nil",
  958. messageSends: [],
  959. referencedClasses: []
  960. }),
  961. smalltalk.ForkPool.klass);
  962. smalltalk.addClass('Message', smalltalk.Object, ['selector', 'arguments'], 'Kernel-Methods');
  963. smalltalk.Message.comment="Generally, the system does not use instances of Message 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:`"
  964. smalltalk.addMethod(
  965. smalltalk.method({
  966. selector: "arguments",
  967. category: 'accessing',
  968. fn: function (){
  969. var self=this;
  970. return smalltalk.withContext(function($ctx1) {
  971. var $1;
  972. $1=self["@arguments"];
  973. return $1;
  974. }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.Message)})},
  975. args: [],
  976. source: "arguments\x0a\x09^arguments",
  977. messageSends: [],
  978. referencedClasses: []
  979. }),
  980. smalltalk.Message);
  981. smalltalk.addMethod(
  982. smalltalk.method({
  983. selector: "arguments:",
  984. category: 'accessing',
  985. fn: function (anArray){
  986. var self=this;
  987. return smalltalk.withContext(function($ctx1) {
  988. self["@arguments"]=anArray;
  989. return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{anArray:anArray},smalltalk.Message)})},
  990. args: ["anArray"],
  991. source: "arguments: anArray\x0a\x09arguments := anArray",
  992. messageSends: [],
  993. referencedClasses: []
  994. }),
  995. smalltalk.Message);
  996. smalltalk.addMethod(
  997. smalltalk.method({
  998. selector: "printOn:",
  999. category: 'printing',
  1000. fn: function (aStream){
  1001. var self=this;
  1002. return smalltalk.withContext(function($ctx1) {
  1003. var $1,$2;
  1004. smalltalk.Object.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1005. $1=aStream;
  1006. _st($1)._nextPutAll_("(");
  1007. _st($1)._nextPutAll_(_st(self)._selector());
  1008. $2=_st($1)._nextPutAll_(")");
  1009. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.Message)})},
  1010. args: ["aStream"],
  1011. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream\x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self selector;\x0a\x09\x09nextPutAll: ')'",
  1012. messageSends: ["printOn:", "nextPutAll:", "selector"],
  1013. referencedClasses: []
  1014. }),
  1015. smalltalk.Message);
  1016. smalltalk.addMethod(
  1017. smalltalk.method({
  1018. selector: "selector",
  1019. category: 'accessing',
  1020. fn: function (){
  1021. var self=this;
  1022. return smalltalk.withContext(function($ctx1) {
  1023. var $1;
  1024. $1=self["@selector"];
  1025. return $1;
  1026. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.Message)})},
  1027. args: [],
  1028. source: "selector\x0a\x09^selector",
  1029. messageSends: [],
  1030. referencedClasses: []
  1031. }),
  1032. smalltalk.Message);
  1033. smalltalk.addMethod(
  1034. smalltalk.method({
  1035. selector: "selector:",
  1036. category: 'accessing',
  1037. fn: function (aString){
  1038. var self=this;
  1039. return smalltalk.withContext(function($ctx1) {
  1040. self["@selector"]=aString;
  1041. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.Message)})},
  1042. args: ["aString"],
  1043. source: "selector: aString\x0a\x09selector := aString",
  1044. messageSends: [],
  1045. referencedClasses: []
  1046. }),
  1047. smalltalk.Message);
  1048. smalltalk.addMethod(
  1049. smalltalk.method({
  1050. selector: "sendTo:",
  1051. category: 'actions',
  1052. fn: function (anObject){
  1053. var self=this;
  1054. return smalltalk.withContext(function($ctx1) {
  1055. var $1;
  1056. $1=_st(anObject)._perform_withArguments_(_st(self)._selector(),_st(self)._arguments());
  1057. return $1;
  1058. }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject},smalltalk.Message)})},
  1059. args: ["anObject"],
  1060. source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
  1061. messageSends: ["perform:withArguments:", "selector", "arguments"],
  1062. referencedClasses: []
  1063. }),
  1064. smalltalk.Message);
  1065. smalltalk.addMethod(
  1066. smalltalk.method({
  1067. selector: "selector:arguments:",
  1068. category: 'instance creation',
  1069. fn: function (aString,anArray){
  1070. var self=this;
  1071. return smalltalk.withContext(function($ctx1) {
  1072. var $2,$3,$1;
  1073. $2=_st(self)._new();
  1074. _st($2)._selector_(aString);
  1075. _st($2)._arguments_(anArray);
  1076. $3=_st($2)._yourself();
  1077. $1=$3;
  1078. return $1;
  1079. }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray},smalltalk.Message.klass)})},
  1080. args: ["aString", "anArray"],
  1081. source: "selector: aString arguments: anArray\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
  1082. messageSends: ["selector:", "new", "arguments:", "yourself"],
  1083. referencedClasses: []
  1084. }),
  1085. smalltalk.Message.klass);
  1086. smalltalk.addClass('MethodContext', smalltalk.Object, [], 'Kernel-Methods');
  1087. smalltalk.MethodContext.comment="MethodContext holds all the dynamic state associated with the execution of either a method activation resulting from a message send. That is used to build the call stack while debugging.\x0a\x0aMethodContext instances are JavaScript `SmalltalkMethodContext` objects defined in boot.js"
  1088. smalltalk.addMethod(
  1089. smalltalk.method({
  1090. selector: "asString",
  1091. category: 'converting',
  1092. fn: function (){
  1093. var self=this;
  1094. return smalltalk.withContext(function($ctx1) {
  1095. var $2,$1;
  1096. $2=_st(self)._isBlockContext();
  1097. if(smalltalk.assert($2)){
  1098. $1=_st(_st("a block (in ").__comma(_st(_st(_st(_st(self)._methodContext())._receiver())._class())._printString())).__comma(")");
  1099. } else {
  1100. $1=_st(_st(_st(_st(_st(self)._receiver())._class())._printString()).__comma(" >> ")).__comma(_st(self)._selector());
  1101. };
  1102. return $1;
  1103. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.MethodContext)})},
  1104. args: [],
  1105. source: "asString\x0a\x09^self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext receiver class printString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class printString, ' >> ', self selector ]",
  1106. messageSends: ["ifTrue:ifFalse:", ",", "printString", "class", "receiver", "methodContext", "selector", "isBlockContext"],
  1107. referencedClasses: []
  1108. }),
  1109. smalltalk.MethodContext);
  1110. smalltalk.addMethod(
  1111. smalltalk.method({
  1112. selector: "home",
  1113. category: 'accessing',
  1114. fn: function (){
  1115. var self=this;
  1116. return smalltalk.withContext(function($ctx1) {
  1117. return self.methodContext || self.homeContext;
  1118. return self}, function($ctx1) {$ctx1.fill(self,"home",{},smalltalk.MethodContext)})},
  1119. args: [],
  1120. source: "home\x0a\x09<return self.methodContext || self.homeContext>",
  1121. messageSends: [],
  1122. referencedClasses: []
  1123. }),
  1124. smalltalk.MethodContext);
  1125. smalltalk.addMethod(
  1126. smalltalk.method({
  1127. selector: "isBlockContext",
  1128. category: 'testing',
  1129. fn: function (){
  1130. var self=this;
  1131. return smalltalk.withContext(function($ctx1) {
  1132. var $1;
  1133. $1=_st(_st(self)._selector())._isNil();
  1134. return $1;
  1135. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},smalltalk.MethodContext)})},
  1136. args: [],
  1137. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
  1138. messageSends: ["isNil", "selector"],
  1139. referencedClasses: []
  1140. }),
  1141. smalltalk.MethodContext);
  1142. smalltalk.addMethod(
  1143. smalltalk.method({
  1144. selector: "locals",
  1145. category: 'accessing',
  1146. fn: function (){
  1147. var self=this;
  1148. return smalltalk.withContext(function($ctx1) {
  1149. return self.locals;
  1150. return self}, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.MethodContext)})},
  1151. args: [],
  1152. source: "locals\x0a\x09<return self.locals>",
  1153. messageSends: [],
  1154. referencedClasses: []
  1155. }),
  1156. smalltalk.MethodContext);
  1157. smalltalk.addMethod(
  1158. smalltalk.method({
  1159. selector: "method",
  1160. category: 'accessing',
  1161. fn: function (){
  1162. var self=this;
  1163. return smalltalk.withContext(function($ctx1) {
  1164. var $1;
  1165. $1=_st(_st(_st(_st(self)._methodContext())._receiver())._class())._lookupSelector_(_st(_st(self)._methodContext())._selector());
  1166. return $1;
  1167. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.MethodContext)})},
  1168. args: [],
  1169. source: "method\x0a\x09^self methodContext receiver class lookupSelector: self methodContext selector",
  1170. messageSends: ["lookupSelector:", "selector", "methodContext", "class", "receiver"],
  1171. referencedClasses: []
  1172. }),
  1173. smalltalk.MethodContext);
  1174. smalltalk.addMethod(
  1175. smalltalk.method({
  1176. selector: "methodContext",
  1177. category: 'accessing',
  1178. fn: function (){
  1179. var self=this;
  1180. return smalltalk.withContext(function($ctx1) {
  1181. var $1,$2,$3;
  1182. $1=_st(self)._isBlockContext();
  1183. if(! smalltalk.assert($1)){
  1184. $2=self;
  1185. return $2;
  1186. };
  1187. $3=_st(self)._home();
  1188. return $3;
  1189. }, function($ctx1) {$ctx1.fill(self,"methodContext",{},smalltalk.MethodContext)})},
  1190. args: [],
  1191. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self home",
  1192. messageSends: ["ifFalse:", "isBlockContext", "home"],
  1193. referencedClasses: []
  1194. }),
  1195. smalltalk.MethodContext);
  1196. smalltalk.addMethod(
  1197. smalltalk.method({
  1198. selector: "outerContext",
  1199. category: 'accessing',
  1200. fn: function (){
  1201. var self=this;
  1202. return smalltalk.withContext(function($ctx1) {
  1203. return self.homeContext;
  1204. return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.MethodContext)})},
  1205. args: [],
  1206. source: "outerContext\x0a\x09<return self.homeContext>",
  1207. messageSends: [],
  1208. referencedClasses: []
  1209. }),
  1210. smalltalk.MethodContext);
  1211. smalltalk.addMethod(
  1212. smalltalk.method({
  1213. selector: "pc",
  1214. category: 'accessing',
  1215. fn: function (){
  1216. var self=this;
  1217. return smalltalk.withContext(function($ctx1) {
  1218. return self.pc;
  1219. return self}, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.MethodContext)})},
  1220. args: [],
  1221. source: "pc\x0a\x09<return self.pc>",
  1222. messageSends: [],
  1223. referencedClasses: []
  1224. }),
  1225. smalltalk.MethodContext);
  1226. smalltalk.addMethod(
  1227. smalltalk.method({
  1228. selector: "printOn:",
  1229. category: 'printing',
  1230. fn: function (aStream){
  1231. var self=this;
  1232. return smalltalk.withContext(function($ctx1) {
  1233. var $1,$2;
  1234. smalltalk.Object.fn.prototype._printOn_.apply(_st(self), [aStream]);
  1235. $1=aStream;
  1236. _st($1)._nextPutAll_("(");
  1237. _st($1)._nextPutAll_(_st(self)._asString());
  1238. $2=_st($1)._nextPutAll_(")");
  1239. return self}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream},smalltalk.MethodContext)})},
  1240. args: ["aStream"],
  1241. source: "printOn: aStream\x0a\x09super printOn: aStream.\x0a\x09aStream \x0a\x09\x09nextPutAll: '(';\x0a\x09\x09nextPutAll: self asString;\x0a\x09\x09nextPutAll: ')'",
  1242. messageSends: ["printOn:", "nextPutAll:", "asString"],
  1243. referencedClasses: []
  1244. }),
  1245. smalltalk.MethodContext);
  1246. smalltalk.addMethod(
  1247. smalltalk.method({
  1248. selector: "receiver",
  1249. category: 'accessing',
  1250. fn: function (){
  1251. var self=this;
  1252. return smalltalk.withContext(function($ctx1) {
  1253. return self.receiver;
  1254. return self}, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.MethodContext)})},
  1255. args: [],
  1256. source: "receiver\x0a\x09<return self.receiver>",
  1257. messageSends: [],
  1258. referencedClasses: []
  1259. }),
  1260. smalltalk.MethodContext);
  1261. smalltalk.addMethod(
  1262. smalltalk.method({
  1263. selector: "selector",
  1264. category: 'accessing',
  1265. fn: function (){
  1266. var self=this;
  1267. return smalltalk.withContext(function($ctx1) {
  1268. if(self.selector) {
  1269. return smalltalk.convertSelector(self.selector);
  1270. } else {
  1271. return nil;
  1272. }
  1273. ;
  1274. return self}, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.MethodContext)})},
  1275. args: [],
  1276. 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>",
  1277. messageSends: [],
  1278. referencedClasses: []
  1279. }),
  1280. smalltalk.MethodContext);
  1281. smalltalk.addMethod(
  1282. smalltalk.method({
  1283. selector: "temps",
  1284. category: 'accessing',
  1285. fn: function (){
  1286. var self=this;
  1287. return smalltalk.withContext(function($ctx1) {
  1288. var $1;
  1289. _st(self)._deprecatedAPI();
  1290. $1=_st(self)._locals();
  1291. return $1;
  1292. }, function($ctx1) {$ctx1.fill(self,"temps",{},smalltalk.MethodContext)})},
  1293. args: [],
  1294. source: "temps\x0a\x09self deprecatedAPI.\x0a\x09\x0a\x09^ self locals",
  1295. messageSends: ["deprecatedAPI", "locals"],
  1296. referencedClasses: []
  1297. }),
  1298. smalltalk.MethodContext);
  1299. smalltalk.addClass('NativeFunction', smalltalk.Object, [], 'Kernel-Methods');
  1300. smalltalk.NativeFunction.comment="NativeFunction is a wrapper around native functions, such as `WebSocket`.\x0aFor 'normal' functions (whose constructor is the JavaScript `Function` object), use `BlockClosure`.\x0a\x0aSee the class-side `instance creation` methods.\x0a\x0aCreated instances will most probably be instance of `JSObjectProxy`.\x0a\x0aUsage example:\x0a\x0a\x09| ws |\x0a\x09ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a\x09ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]"
  1301. smalltalk.addMethod(
  1302. smalltalk.method({
  1303. selector: "constructor:",
  1304. category: 'instance creation',
  1305. fn: function (aString){
  1306. var self=this;
  1307. return smalltalk.withContext(function($ctx1) {
  1308. var native=eval(aString);
  1309. return new native();
  1310. ;
  1311. return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString},smalltalk.NativeFunction.klass)})},
  1312. args: ["aString"],
  1313. source: "constructor: aString\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native();\x0a\x09>",
  1314. messageSends: [],
  1315. referencedClasses: []
  1316. }),
  1317. smalltalk.NativeFunction.klass);
  1318. smalltalk.addMethod(
  1319. smalltalk.method({
  1320. selector: "constructor:value:",
  1321. category: 'instance creation',
  1322. fn: function (aString,anObject){
  1323. var self=this;
  1324. return smalltalk.withContext(function($ctx1) {
  1325. var native=eval(aString);
  1326. return new native(anObject);
  1327. ;
  1328. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject},smalltalk.NativeFunction.klass)})},
  1329. args: ["aString", "anObject"],
  1330. source: "constructor: aString value:anObject\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject);\x0a\x09>",
  1331. messageSends: [],
  1332. referencedClasses: []
  1333. }),
  1334. smalltalk.NativeFunction.klass);
  1335. smalltalk.addMethod(
  1336. smalltalk.method({
  1337. selector: "constructor:value:value:",
  1338. category: 'instance creation',
  1339. fn: function (aString,anObject,anObject2){
  1340. var self=this;
  1341. return smalltalk.withContext(function($ctx1) {
  1342. var native=eval(aString);
  1343. return new native(anObject,anObject2);
  1344. ;
  1345. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2},smalltalk.NativeFunction.klass)})},
  1346. args: ["aString", "anObject", "anObject2"],
  1347. source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a\x09\x09var native=eval(aString);\x0a\x09\x09return new native(anObject,anObject2);\x0a\x09>",
  1348. messageSends: [],
  1349. referencedClasses: []
  1350. }),
  1351. smalltalk.NativeFunction.klass);
  1352. smalltalk.addMethod(
  1353. smalltalk.method({
  1354. selector: "constructor:value:value:value:",
  1355. category: 'instance creation',
  1356. fn: function (aString,anObject,anObject2,anObject3){
  1357. var self=this;
  1358. return smalltalk.withContext(function($ctx1) {
  1359. var native=eval(aString);
  1360. return new native(anObject,anObject2, anObject3);
  1361. ;
  1362. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3},smalltalk.NativeFunction.klass)})},
  1363. args: ["aString", "anObject", "anObject2", "anObject3"],
  1364. 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>",
  1365. messageSends: [],
  1366. referencedClasses: []
  1367. }),
  1368. smalltalk.NativeFunction.klass);
  1369. smalltalk.addMethod(
  1370. smalltalk.method({
  1371. selector: "exists:",
  1372. category: 'testing',
  1373. fn: function (aString){
  1374. var self=this;
  1375. return smalltalk.withContext(function($ctx1) {
  1376. if(aString in window) {
  1377. return true
  1378. } else {
  1379. return false
  1380. }
  1381. ;
  1382. return self}, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},smalltalk.NativeFunction.klass)})},
  1383. args: ["aString"],
  1384. source: "exists: aString\x0a\x09<\x0a\x09\x09if(aString in window) {\x0a\x09\x09\x09return true\x0a\x09\x09} else {\x0a\x09\x09\x09return false\x0a\x09\x09}\x0a\x09>",
  1385. messageSends: [],
  1386. referencedClasses: []
  1387. }),
  1388. smalltalk.NativeFunction.klass);