1
0

Kernel-Methods.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  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. "_applyTo_arguments_",
  6. smalltalk.method({
  7. selector: "applyTo:arguments:",
  8. category: 'evaluating',
  9. fn: function (anObject,aCollection){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) { 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. "_asCompiledMethod_",
  21. smalltalk.method({
  22. selector: "asCompiledMethod:",
  23. category: 'converting',
  24. fn: function (aString){
  25. var self=this;
  26. return smalltalk.withContext(function($ctx1) { 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. "_compiledSource",
  36. smalltalk.method({
  37. selector: "compiledSource",
  38. category: 'accessing',
  39. fn: function (){
  40. var self=this;
  41. return smalltalk.withContext(function($ctx1) { 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. "_currySelf",
  51. smalltalk.method({
  52. selector: "currySelf",
  53. category: 'converting',
  54. fn: function (){
  55. var self=this;
  56. return smalltalk.withContext(function($ctx1) {
  57. return function () {
  58. var args = [ this ];
  59. args.push.apply(args, arguments);
  60. return self.apply(null, args);
  61. }
  62. ;
  63. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{}, smalltalk.BlockClosure)})},
  64. args: [],
  65. source: "currySelf\x0a\x09\x22Transforms [ :selfarg :x :y | stcode ] block\x0a which represents JS function (selfarg, x, y, ...) {jscode}\x0a into function (x, y, ...) {jscode} that takes selfarg from 'this'.\x0a IOW, it is usable as JS method and first arg takes the receiver.\x22\x0a \x0a <\x0a \x09return function () {\x0a \x09\x09var args = [ this ];\x0a \x09args.push.apply(args, arguments);\x0a \x09return self.apply(null, args);\x0a \x09}\x0a\x09>",
  66. messageSends: [],
  67. referencedClasses: []
  68. }),
  69. smalltalk.BlockClosure);
  70. smalltalk.addMethod(
  71. "_ensure_",
  72. smalltalk.method({
  73. selector: "ensure:",
  74. category: 'evaluating',
  75. fn: function (aBlock){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) { try{return self()}finally{aBlock._value()};
  78. return self}, function($ctx1) {$ctx1.fill(self,"ensure:",{aBlock:aBlock}, smalltalk.BlockClosure)})},
  79. args: ["aBlock"],
  80. source: "ensure: aBlock\x0a\x09<try{return self()}finally{aBlock._value()}>",
  81. messageSends: [],
  82. referencedClasses: []
  83. }),
  84. smalltalk.BlockClosure);
  85. smalltalk.addMethod(
  86. "_fork",
  87. smalltalk.method({
  88. selector: "fork",
  89. category: 'timeout/interval',
  90. fn: function (){
  91. var self=this;
  92. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.ForkPool || 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. "_new",
  102. smalltalk.method({
  103. selector: "new",
  104. category: 'evaluating',
  105. fn: function (){
  106. var self=this;
  107. return smalltalk.withContext(function($ctx1) { 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. "_newValue_",
  117. smalltalk.method({
  118. selector: "newValue:",
  119. category: 'evaluating',
  120. fn: function (anObject){
  121. var self=this;
  122. return smalltalk.withContext(function($ctx1) { 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. "_newValue_value_",
  132. smalltalk.method({
  133. selector: "newValue:value:",
  134. category: 'evaluating',
  135. fn: function (anObject,anObject2){
  136. var self=this;
  137. return smalltalk.withContext(function($ctx1) { 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. "_newValue_value_value_",
  147. smalltalk.method({
  148. selector: "newValue:value:value:",
  149. category: 'evaluating',
  150. fn: function (anObject,anObject2,anObject3){
  151. var self=this;
  152. return smalltalk.withContext(function($ctx1) { 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. "_numArgs",
  162. smalltalk.method({
  163. selector: "numArgs",
  164. category: 'accessing',
  165. fn: function (){
  166. var self=this;
  167. return smalltalk.withContext(function($ctx1) { 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. "_on_do_",
  177. smalltalk.method({
  178. selector: "on:do:",
  179. category: 'error handling',
  180. fn: function (anErrorClass,aBlock){
  181. var self=this;
  182. return smalltalk.withContext(function($ctx1) { var $2,$1;
  183. $1=_st(self)._try_catch_(self,(function(error){
  184. var smalltalkError;
  185. return smalltalk.withContext(function($ctx2) { smalltalkError=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._asSmalltalkException_(error);
  186. smalltalkError;
  187. $2=_st(smalltalkError)._isKindOf_(anErrorClass);
  188. if(smalltalk.assert($2)){
  189. return _st(aBlock)._value_(smalltalkError);
  190. } else {
  191. return _st(smalltalkError)._signal();
  192. };
  193. }, function($ctx2) {$ctx2.fillBlock({error:error,smalltalkError:smalltalkError},$ctx1)})}));
  194. return $1;
  195. }, function($ctx1) {$ctx1.fill(self,"on:do:",{anErrorClass:anErrorClass,aBlock:aBlock}, smalltalk.BlockClosure)})},
  196. args: ["anErrorClass", "aBlock"],
  197. source: "on: anErrorClass do: aBlock\x0a\x09\x22All exceptions thrown in the Smalltalk stack are cought.\x0a Convert all JS exceptions to JavaScriptException instances.\x22\x0a \x0a\x09^self try: self catch: [ :error | | smalltalkError |\x0a \x09smalltalkError := Smalltalk current asSmalltalkException: error.\x0a\x09 (smalltalkError isKindOf: anErrorClass) \x0a\x09 ifTrue: [ aBlock value: smalltalkError ]\x0a\x09 ifFalse: [ smalltalkError signal ] ]",
  198. messageSends: ["try:catch:", "asSmalltalkException:", "current", "ifTrue:ifFalse:", "value:", "signal", "isKindOf:"],
  199. referencedClasses: ["Smalltalk"]
  200. }),
  201. smalltalk.BlockClosure);
  202. smalltalk.addMethod(
  203. "_timeToRun",
  204. smalltalk.method({
  205. selector: "timeToRun",
  206. category: 'evaluating',
  207. fn: function (){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx1) { var $1;
  210. $1=_st((smalltalk.Date || Date))._millisecondsToRun_(self);
  211. return $1;
  212. }, function($ctx1) {$ctx1.fill(self,"timeToRun",{}, smalltalk.BlockClosure)})},
  213. args: [],
  214. source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
  215. messageSends: ["millisecondsToRun:"],
  216. referencedClasses: ["Date"]
  217. }),
  218. smalltalk.BlockClosure);
  219. smalltalk.addMethod(
  220. "_value",
  221. smalltalk.method({
  222. selector: "value",
  223. category: 'evaluating',
  224. fn: function (){
  225. var self=this;
  226. return smalltalk.withContext(function($ctx1) { return self();;
  227. return self}, function($ctx1) {$ctx1.fill(self,"value",{}, smalltalk.BlockClosure)})},
  228. args: [],
  229. source: "value\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self();>",
  230. messageSends: [],
  231. referencedClasses: []
  232. }),
  233. smalltalk.BlockClosure);
  234. smalltalk.addMethod(
  235. "_value_",
  236. smalltalk.method({
  237. selector: "value:",
  238. category: 'evaluating',
  239. fn: function (anArg){
  240. var self=this;
  241. return smalltalk.withContext(function($ctx1) { return self(anArg);;
  242. return self}, function($ctx1) {$ctx1.fill(self,"value:",{anArg:anArg}, smalltalk.BlockClosure)})},
  243. args: ["anArg"],
  244. source: "value: anArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(anArg);>",
  245. messageSends: [],
  246. referencedClasses: []
  247. }),
  248. smalltalk.BlockClosure);
  249. smalltalk.addMethod(
  250. "_value_value_",
  251. smalltalk.method({
  252. selector: "value:value:",
  253. category: 'evaluating',
  254. fn: function (firstArg,secondArg){
  255. var self=this;
  256. return smalltalk.withContext(function($ctx1) { return self(firstArg, secondArg);;
  257. return self}, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArg:firstArg,secondArg:secondArg}, smalltalk.BlockClosure)})},
  258. args: ["firstArg", "secondArg"],
  259. source: "value: firstArg value: secondArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg);>",
  260. messageSends: [],
  261. referencedClasses: []
  262. }),
  263. smalltalk.BlockClosure);
  264. smalltalk.addMethod(
  265. "_value_value_value_",
  266. smalltalk.method({
  267. selector: "value:value:value:",
  268. category: 'evaluating',
  269. fn: function (firstArg,secondArg,thirdArg){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) { return self(firstArg, secondArg, thirdArg);;
  272. return self}, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArg:firstArg,secondArg:secondArg,thirdArg:thirdArg}, smalltalk.BlockClosure)})},
  273. args: ["firstArg", "secondArg", "thirdArg"],
  274. source: "value: firstArg value: secondArg value: thirdArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
  275. messageSends: [],
  276. referencedClasses: []
  277. }),
  278. smalltalk.BlockClosure);
  279. smalltalk.addMethod(
  280. "_valueWithInterval_",
  281. smalltalk.method({
  282. selector: "valueWithInterval:",
  283. category: 'timeout/interval',
  284. fn: function (aNumber){
  285. var self=this;
  286. return smalltalk.withContext(function($ctx1) {
  287. var interval = setInterval(self, aNumber);
  288. return smalltalk.Timeout._on_(interval);
  289. ;
  290. return self}, function($ctx1) {$ctx1.fill(self,"valueWithInterval:",{aNumber:aNumber}, smalltalk.BlockClosure)})},
  291. args: ["aNumber"],
  292. source: "valueWithInterval: aNumber\x0a\x09<\x0a \x09var interval = setInterval(self, aNumber);\x0a \x09return smalltalk.Timeout._on_(interval);\x0a >",
  293. messageSends: [],
  294. referencedClasses: []
  295. }),
  296. smalltalk.BlockClosure);
  297. smalltalk.addMethod(
  298. "_valueWithPossibleArguments_",
  299. smalltalk.method({
  300. selector: "valueWithPossibleArguments:",
  301. category: 'evaluating',
  302. fn: function (aCollection){
  303. var self=this;
  304. return smalltalk.withContext(function($ctx1) { return self.apply(null, aCollection);;
  305. return self}, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection}, smalltalk.BlockClosure)})},
  306. args: ["aCollection"],
  307. source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
  308. messageSends: [],
  309. referencedClasses: []
  310. }),
  311. smalltalk.BlockClosure);
  312. smalltalk.addMethod(
  313. "_valueWithTimeout_",
  314. smalltalk.method({
  315. selector: "valueWithTimeout:",
  316. category: 'timeout/interval',
  317. fn: function (aNumber){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) {
  320. var timeout = setTimeout(self, aNumber);
  321. return smalltalk.Timeout._on_(timeout);
  322. ;
  323. return self}, function($ctx1) {$ctx1.fill(self,"valueWithTimeout:",{aNumber:aNumber}, smalltalk.BlockClosure)})},
  324. args: ["aNumber"],
  325. source: "valueWithTimeout: aNumber\x0a\x09<\x0a \x09var timeout = setTimeout(self, aNumber);\x0a \x09return smalltalk.Timeout._on_(timeout);\x0a >",
  326. messageSends: [],
  327. referencedClasses: []
  328. }),
  329. smalltalk.BlockClosure);
  330. smalltalk.addMethod(
  331. "_whileFalse",
  332. smalltalk.method({
  333. selector: "whileFalse",
  334. category: 'controlling',
  335. fn: function (){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx1) { _st(self)._whileFalse_((function(){
  338. return smalltalk.withContext(function($ctx2) { }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  339. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse",{}, smalltalk.BlockClosure)})},
  340. args: [],
  341. source: "whileFalse\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileFalse: []",
  342. messageSends: ["whileFalse:"],
  343. referencedClasses: []
  344. }),
  345. smalltalk.BlockClosure);
  346. smalltalk.addMethod(
  347. "_whileFalse_",
  348. smalltalk.method({
  349. selector: "whileFalse:",
  350. category: 'controlling',
  351. fn: function (aBlock){
  352. var self=this;
  353. return smalltalk.withContext(function($ctx1) { while(!self()) {aBlock()};
  354. return self}, function($ctx1) {$ctx1.fill(self,"whileFalse:",{aBlock:aBlock}, smalltalk.BlockClosure)})},
  355. args: ["aBlock"],
  356. source: "whileFalse: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(!self()) {aBlock()}>",
  357. messageSends: [],
  358. referencedClasses: []
  359. }),
  360. smalltalk.BlockClosure);
  361. smalltalk.addMethod(
  362. "_whileTrue",
  363. smalltalk.method({
  364. selector: "whileTrue",
  365. category: 'controlling',
  366. fn: function (){
  367. var self=this;
  368. return smalltalk.withContext(function($ctx1) { _st(self)._whileTrue_((function(){
  369. return smalltalk.withContext(function($ctx2) { }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  370. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue",{}, smalltalk.BlockClosure)})},
  371. args: [],
  372. source: "whileTrue\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileTrue: []",
  373. messageSends: ["whileTrue:"],
  374. referencedClasses: []
  375. }),
  376. smalltalk.BlockClosure);
  377. smalltalk.addMethod(
  378. "_whileTrue_",
  379. smalltalk.method({
  380. selector: "whileTrue:",
  381. category: 'controlling',
  382. fn: function (aBlock){
  383. var self=this;
  384. return smalltalk.withContext(function($ctx1) { while(self()) {aBlock()};
  385. return self}, function($ctx1) {$ctx1.fill(self,"whileTrue:",{aBlock:aBlock}, smalltalk.BlockClosure)})},
  386. args: ["aBlock"],
  387. source: "whileTrue: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(self()) {aBlock()}>",
  388. messageSends: [],
  389. referencedClasses: []
  390. }),
  391. smalltalk.BlockClosure);
  392. smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
  393. 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"
  394. smalltalk.addMethod(
  395. "_arguments",
  396. smalltalk.method({
  397. selector: "arguments",
  398. category: 'accessing',
  399. fn: function (){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) { return self.args || [];
  402. return self}, function($ctx1) {$ctx1.fill(self,"arguments",{}, smalltalk.CompiledMethod)})},
  403. args: [],
  404. source: "arguments\x0a\x09<return self.args || []>",
  405. messageSends: [],
  406. referencedClasses: []
  407. }),
  408. smalltalk.CompiledMethod);
  409. smalltalk.addMethod(
  410. "_category",
  411. smalltalk.method({
  412. selector: "category",
  413. category: 'accessing',
  414. fn: function (){
  415. var self=this;
  416. return smalltalk.withContext(function($ctx1) { var $2,$1;
  417. $2=_st(self)._basicAt_("category");
  418. if(($receiver = $2) == nil || $receiver == undefined){
  419. $1="";
  420. } else {
  421. $1=$2;
  422. };
  423. return $1;
  424. }, function($ctx1) {$ctx1.fill(self,"category",{}, smalltalk.CompiledMethod)})},
  425. args: [],
  426. source: "category\x0a\x09^(self basicAt: 'category') ifNil: ['']",
  427. messageSends: ["ifNil:", "basicAt:"],
  428. referencedClasses: []
  429. }),
  430. smalltalk.CompiledMethod);
  431. smalltalk.addMethod(
  432. "_category_",
  433. smalltalk.method({
  434. selector: "category:",
  435. category: 'accessing',
  436. fn: function (aString){
  437. var self=this;
  438. var oldCategory;
  439. return smalltalk.withContext(function($ctx1) { var $1;
  440. oldCategory=_st(self)._category();
  441. _st(self)._basicAt_put_("category",aString);
  442. $1=_st(self)._methodClass();
  443. if(($receiver = $1) == nil || $receiver == undefined){
  444. $1;
  445. } else {
  446. _st(_st(_st(self)._methodClass())._organization())._addElement_(aString);
  447. _st(_st(_st(_st(self)._methodClass())._methods())._select_((function(each){
  448. return smalltalk.withContext(function($ctx2) { return _st(_st(each)._category()).__eq(oldCategory);
  449. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._ifEmpty_((function(){
  450. return smalltalk.withContext(function($ctx2) { return _st(_st(_st(self)._methodClass())._organization())._removeElement_(oldCategory);
  451. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  452. };
  453. return self}, function($ctx1) {$ctx1.fill(self,"category:",{aString:aString,oldCategory:oldCategory}, smalltalk.CompiledMethod)})},
  454. args: ["aString"],
  455. source: "category: aString\x0a\x09| oldCategory |\x0a oldCategory := self category.\x0a\x09self basicAt: 'category' put: aString.\x0a \x0a self methodClass ifNotNil: [\x0a \x09self methodClass organization addElement: aString.\x0a \x0a\x09\x09(self methodClass methods \x0a \x09\x09select: [ :each | each category = oldCategory ])\x0a \x09ifEmpty: [ self methodClass organization removeElement: oldCategory ] ]",
  456. messageSends: ["category", "basicAt:put:", "ifNotNil:", "addElement:", "organization", "methodClass", "ifEmpty:", "removeElement:", "select:", "=", "methods"],
  457. referencedClasses: []
  458. }),
  459. smalltalk.CompiledMethod);
  460. smalltalk.addMethod(
  461. "_fn",
  462. smalltalk.method({
  463. selector: "fn",
  464. category: 'accessing',
  465. fn: function (){
  466. var self=this;
  467. return smalltalk.withContext(function($ctx1) { var $1;
  468. $1=_st(self)._basicAt_("fn");
  469. return $1;
  470. }, function($ctx1) {$ctx1.fill(self,"fn",{}, smalltalk.CompiledMethod)})},
  471. args: [],
  472. source: "fn\x0a\x09^self basicAt: 'fn'",
  473. messageSends: ["basicAt:"],
  474. referencedClasses: []
  475. }),
  476. smalltalk.CompiledMethod);
  477. smalltalk.addMethod(
  478. "_fn_",
  479. smalltalk.method({
  480. selector: "fn:",
  481. category: 'accessing',
  482. fn: function (aBlock){
  483. var self=this;
  484. return smalltalk.withContext(function($ctx1) { _st(self)._basicAt_put_("fn",aBlock);
  485. return self}, function($ctx1) {$ctx1.fill(self,"fn:",{aBlock:aBlock}, smalltalk.CompiledMethod)})},
  486. args: ["aBlock"],
  487. source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
  488. messageSends: ["basicAt:put:"],
  489. referencedClasses: []
  490. }),
  491. smalltalk.CompiledMethod);
  492. smalltalk.addMethod(
  493. "_messageSends",
  494. smalltalk.method({
  495. selector: "messageSends",
  496. category: 'accessing',
  497. fn: function (){
  498. var self=this;
  499. return smalltalk.withContext(function($ctx1) { var $1;
  500. $1=_st(self)._basicAt_("messageSends");
  501. return $1;
  502. }, function($ctx1) {$ctx1.fill(self,"messageSends",{}, smalltalk.CompiledMethod)})},
  503. args: [],
  504. source: "messageSends\x0a\x09^self basicAt: 'messageSends'",
  505. messageSends: ["basicAt:"],
  506. referencedClasses: []
  507. }),
  508. smalltalk.CompiledMethod);
  509. smalltalk.addMethod(
  510. "_methodClass",
  511. smalltalk.method({
  512. selector: "methodClass",
  513. category: 'accessing',
  514. fn: function (){
  515. var self=this;
  516. return smalltalk.withContext(function($ctx1) { var $1;
  517. $1=_st(self)._basicAt_("methodClass");
  518. return $1;
  519. }, function($ctx1) {$ctx1.fill(self,"methodClass",{}, smalltalk.CompiledMethod)})},
  520. args: [],
  521. source: "methodClass\x0a\x09^self basicAt: 'methodClass'",
  522. messageSends: ["basicAt:"],
  523. referencedClasses: []
  524. }),
  525. smalltalk.CompiledMethod);
  526. smalltalk.addMethod(
  527. "_protocol",
  528. smalltalk.method({
  529. selector: "protocol",
  530. category: 'accessing',
  531. fn: function (){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) { var $1;
  534. $1=_st(self)._category();
  535. return $1;
  536. }, function($ctx1) {$ctx1.fill(self,"protocol",{}, smalltalk.CompiledMethod)})},
  537. args: [],
  538. source: "protocol\x0a\x09^ self category",
  539. messageSends: ["category"],
  540. referencedClasses: []
  541. }),
  542. smalltalk.CompiledMethod);
  543. smalltalk.addMethod(
  544. "_referencedClasses",
  545. smalltalk.method({
  546. selector: "referencedClasses",
  547. category: 'accessing',
  548. fn: function (){
  549. var self=this;
  550. return smalltalk.withContext(function($ctx1) { var $1;
  551. $1=_st(self)._basicAt_("referencedClasses");
  552. return $1;
  553. }, function($ctx1) {$ctx1.fill(self,"referencedClasses",{}, smalltalk.CompiledMethod)})},
  554. args: [],
  555. source: "referencedClasses\x0a\x09^self basicAt: 'referencedClasses'",
  556. messageSends: ["basicAt:"],
  557. referencedClasses: []
  558. }),
  559. smalltalk.CompiledMethod);
  560. smalltalk.addMethod(
  561. "_selector",
  562. smalltalk.method({
  563. selector: "selector",
  564. category: 'accessing',
  565. fn: function (){
  566. var self=this;
  567. return smalltalk.withContext(function($ctx1) { var $1;
  568. $1=_st(self)._basicAt_("selector");
  569. return $1;
  570. }, function($ctx1) {$ctx1.fill(self,"selector",{}, smalltalk.CompiledMethod)})},
  571. args: [],
  572. source: "selector\x0a\x09^self basicAt: 'selector'",
  573. messageSends: ["basicAt:"],
  574. referencedClasses: []
  575. }),
  576. smalltalk.CompiledMethod);
  577. smalltalk.addMethod(
  578. "_selector_",
  579. smalltalk.method({
  580. selector: "selector:",
  581. category: 'accessing',
  582. fn: function (aString){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) { _st(self)._basicAt_put_("selector",aString);
  585. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString}, smalltalk.CompiledMethod)})},
  586. args: ["aString"],
  587. source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
  588. messageSends: ["basicAt:put:"],
  589. referencedClasses: []
  590. }),
  591. smalltalk.CompiledMethod);
  592. smalltalk.addMethod(
  593. "_source",
  594. smalltalk.method({
  595. selector: "source",
  596. category: 'accessing',
  597. fn: function (){
  598. var self=this;
  599. return smalltalk.withContext(function($ctx1) { var $2,$1;
  600. $2=_st(self)._basicAt_("source");
  601. if(($receiver = $2) == nil || $receiver == undefined){
  602. $1="";
  603. } else {
  604. $1=$2;
  605. };
  606. return $1;
  607. }, function($ctx1) {$ctx1.fill(self,"source",{}, smalltalk.CompiledMethod)})},
  608. args: [],
  609. source: "source\x0a\x09^(self basicAt: 'source') ifNil: ['']",
  610. messageSends: ["ifNil:", "basicAt:"],
  611. referencedClasses: []
  612. }),
  613. smalltalk.CompiledMethod);
  614. smalltalk.addMethod(
  615. "_source_",
  616. smalltalk.method({
  617. selector: "source:",
  618. category: 'accessing',
  619. fn: function (aString){
  620. var self=this;
  621. return smalltalk.withContext(function($ctx1) { _st(self)._basicAt_put_("source",aString);
  622. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString}, smalltalk.CompiledMethod)})},
  623. args: ["aString"],
  624. source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
  625. messageSends: ["basicAt:put:"],
  626. referencedClasses: []
  627. }),
  628. smalltalk.CompiledMethod);
  629. smalltalk.addClass('ForkPool', smalltalk.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
  630. 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`"
  631. smalltalk.addMethod(
  632. "_addWorker",
  633. smalltalk.method({
  634. selector: "addWorker",
  635. category: 'private',
  636. fn: function (){
  637. var self=this;
  638. return smalltalk.withContext(function($ctx1) { _st(self["@worker"])._valueWithTimeout_((0));
  639. self["@poolSize"]=_st(self["@poolSize"]).__plus((1));
  640. return self}, function($ctx1) {$ctx1.fill(self,"addWorker",{}, smalltalk.ForkPool)})},
  641. args: [],
  642. source: "addWorker\x0a\x09worker valueWithTimeout: 0.\x0a poolSize := poolSize + 1",
  643. messageSends: ["valueWithTimeout:", "+"],
  644. referencedClasses: []
  645. }),
  646. smalltalk.ForkPool);
  647. smalltalk.addMethod(
  648. "_defaultMaxPoolSize",
  649. smalltalk.method({
  650. selector: "defaultMaxPoolSize",
  651. category: 'defaults',
  652. fn: function (){
  653. var self=this;
  654. return smalltalk.withContext(function($ctx1) { var $1;
  655. $1=_st(_st(self)._class())._defaultMaxPoolSize();
  656. return $1;
  657. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{}, smalltalk.ForkPool)})},
  658. args: [],
  659. source: "defaultMaxPoolSize\x0a\x09^ self class defaultMaxPoolSize",
  660. messageSends: ["defaultMaxPoolSize", "class"],
  661. referencedClasses: []
  662. }),
  663. smalltalk.ForkPool);
  664. smalltalk.addMethod(
  665. "_fork_",
  666. smalltalk.method({
  667. selector: "fork:",
  668. category: 'actions',
  669. fn: function (aBlock){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) { var $1;
  672. $1=_st(self["@poolSize"]).__lt(_st(self)._maxPoolSize());
  673. if(smalltalk.assert($1)){
  674. _st(self)._addWorker();
  675. };
  676. _st(self["@queue"])._back_(aBlock);
  677. return self}, function($ctx1) {$ctx1.fill(self,"fork:",{aBlock:aBlock}, smalltalk.ForkPool)})},
  678. args: ["aBlock"],
  679. source: "fork: aBlock\x0a\x09poolSize < self maxPoolSize ifTrue: [ self addWorker ].\x0a\x09queue back: aBlock",
  680. messageSends: ["ifTrue:", "addWorker", "<", "maxPoolSize", "back:"],
  681. referencedClasses: []
  682. }),
  683. smalltalk.ForkPool);
  684. smalltalk.addMethod(
  685. "_initialize",
  686. smalltalk.method({
  687. selector: "initialize",
  688. category: 'initialization',
  689. fn: function (){
  690. var self=this;
  691. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  692. self["@poolSize"]=(0);
  693. self["@queue"]=_st((smalltalk.Queue || Queue))._new();
  694. self["@worker"]=_st(self)._makeWorker();
  695. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ForkPool)})},
  696. args: [],
  697. source: "initialize\x0a super initialize.\x0a \x0a\x09poolSize := 0.\x0a queue := Queue new.\x0a worker := self makeWorker",
  698. messageSends: ["initialize", "new", "makeWorker"],
  699. referencedClasses: ["Queue"]
  700. }),
  701. smalltalk.ForkPool);
  702. smalltalk.addMethod(
  703. "_makeWorker",
  704. smalltalk.method({
  705. selector: "makeWorker",
  706. category: 'initialization',
  707. fn: function (){
  708. var self=this;
  709. var sentinel;
  710. return smalltalk.withContext(function($ctx1) { var $2,$1;
  711. sentinel=_st((smalltalk.Object || Object))._new();
  712. $1=(function(){
  713. var block;
  714. return smalltalk.withContext(function($ctx2) { self["@poolSize"]=_st(self["@poolSize"]).__minus((1));
  715. self["@poolSize"];
  716. block=_st(self["@queue"])._frontIfAbsent_((function(){
  717. return smalltalk.withContext(function($ctx3) { return sentinel;
  718. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  719. block;
  720. $2=_st(block).__eq_eq(sentinel);
  721. if(! smalltalk.assert($2)){
  722. return _st((function(){
  723. return smalltalk.withContext(function($ctx3) { return _st(block)._value();
  724. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._ensure_((function(){
  725. return smalltalk.withContext(function($ctx3) { return _st(self)._addWorker();
  726. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  727. };
  728. }, function($ctx2) {$ctx2.fillBlock({block:block},$ctx1)})});
  729. return $1;
  730. }, function($ctx1) {$ctx1.fill(self,"makeWorker",{sentinel:sentinel}, smalltalk.ForkPool)})},
  731. args: [],
  732. source: "makeWorker\x0a\x09| sentinel |\x0a sentinel := Object new.\x0a ^[ | block |\x0a poolSize := poolSize - 1.\x0a\x09\x09block := queue frontIfAbsent: [ sentinel ].\x0a block == sentinel ifFalse: [\x0a \x09[ block value ] ensure: [ self addWorker ]]]",
  733. messageSends: ["new", "-", "frontIfAbsent:", "ifFalse:", "ensure:", "addWorker", "value", "=="],
  734. referencedClasses: ["Object"]
  735. }),
  736. smalltalk.ForkPool);
  737. smalltalk.addMethod(
  738. "_maxPoolSize",
  739. smalltalk.method({
  740. selector: "maxPoolSize",
  741. category: 'accessing',
  742. fn: function (){
  743. var self=this;
  744. return smalltalk.withContext(function($ctx1) { var $2,$1;
  745. $2=self["@maxPoolSize"];
  746. if(($receiver = $2) == nil || $receiver == undefined){
  747. $1=_st(self)._defaultMaxPoolSize();
  748. } else {
  749. $1=$2;
  750. };
  751. return $1;
  752. }, function($ctx1) {$ctx1.fill(self,"maxPoolSize",{}, smalltalk.ForkPool)})},
  753. args: [],
  754. source: "maxPoolSize\x0a\x09^ maxPoolSize ifNil: [ self defaultMaxPoolSize ]",
  755. messageSends: ["ifNil:", "defaultMaxPoolSize"],
  756. referencedClasses: []
  757. }),
  758. smalltalk.ForkPool);
  759. smalltalk.addMethod(
  760. "_maxPoolSize_",
  761. smalltalk.method({
  762. selector: "maxPoolSize:",
  763. category: 'accessing',
  764. fn: function (anInteger){
  765. var self=this;
  766. return smalltalk.withContext(function($ctx1) { self["@maxPoolSize"]=anInteger;
  767. return self}, function($ctx1) {$ctx1.fill(self,"maxPoolSize:",{anInteger:anInteger}, smalltalk.ForkPool)})},
  768. args: ["anInteger"],
  769. source: "maxPoolSize: anInteger\x0a\x09maxPoolSize := anInteger",
  770. messageSends: [],
  771. referencedClasses: []
  772. }),
  773. smalltalk.ForkPool);
  774. smalltalk.ForkPool.klass.iVarNames = ['default'];
  775. smalltalk.addMethod(
  776. "_default",
  777. smalltalk.method({
  778. selector: "default",
  779. category: 'accessing',
  780. fn: function (){
  781. var self=this;
  782. return smalltalk.withContext(function($ctx1) { var $2,$1;
  783. $2=self["@default"];
  784. if(($receiver = $2) == nil || $receiver == undefined){
  785. self["@default"]=_st(self)._new();
  786. $1=self["@default"];
  787. } else {
  788. $1=$2;
  789. };
  790. return $1;
  791. }, function($ctx1) {$ctx1.fill(self,"default",{}, smalltalk.ForkPool.klass)})},
  792. args: [],
  793. source: "default\x0a\x09^default ifNil: [ default := self new ]",
  794. messageSends: ["ifNil:", "new"],
  795. referencedClasses: []
  796. }),
  797. smalltalk.ForkPool.klass);
  798. smalltalk.addMethod(
  799. "_defaultMaxPoolSize",
  800. smalltalk.method({
  801. selector: "defaultMaxPoolSize",
  802. category: 'accessing',
  803. fn: function (){
  804. var self=this;
  805. return smalltalk.withContext(function($ctx1) { return (100);
  806. }, function($ctx1) {$ctx1.fill(self,"defaultMaxPoolSize",{}, smalltalk.ForkPool.klass)})},
  807. args: [],
  808. source: "defaultMaxPoolSize\x0a\x09^100",
  809. messageSends: [],
  810. referencedClasses: []
  811. }),
  812. smalltalk.ForkPool.klass);
  813. smalltalk.addMethod(
  814. "_resetDefault",
  815. smalltalk.method({
  816. selector: "resetDefault",
  817. category: 'accessing',
  818. fn: function (){
  819. var self=this;
  820. return smalltalk.withContext(function($ctx1) { self["@default"]=nil;
  821. return self}, function($ctx1) {$ctx1.fill(self,"resetDefault",{}, smalltalk.ForkPool.klass)})},
  822. args: [],
  823. source: "resetDefault\x0a\x09default := nil",
  824. messageSends: [],
  825. referencedClasses: []
  826. }),
  827. smalltalk.ForkPool.klass);
  828. smalltalk.addClass('Message', smalltalk.Object, ['selector', 'arguments'], 'Kernel-Methods');
  829. 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:`"
  830. smalltalk.addMethod(
  831. "_arguments",
  832. smalltalk.method({
  833. selector: "arguments",
  834. category: 'accessing',
  835. fn: function (){
  836. var self=this;
  837. return smalltalk.withContext(function($ctx1) { var $1;
  838. $1=self["@arguments"];
  839. return $1;
  840. }, function($ctx1) {$ctx1.fill(self,"arguments",{}, smalltalk.Message)})},
  841. args: [],
  842. source: "arguments\x0a\x09^arguments",
  843. messageSends: [],
  844. referencedClasses: []
  845. }),
  846. smalltalk.Message);
  847. smalltalk.addMethod(
  848. "_arguments_",
  849. smalltalk.method({
  850. selector: "arguments:",
  851. category: 'accessing',
  852. fn: function (anArray){
  853. var self=this;
  854. return smalltalk.withContext(function($ctx1) { self["@arguments"]=anArray;
  855. return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{anArray:anArray}, smalltalk.Message)})},
  856. args: ["anArray"],
  857. source: "arguments: anArray\x0a\x09arguments := anArray",
  858. messageSends: [],
  859. referencedClasses: []
  860. }),
  861. smalltalk.Message);
  862. smalltalk.addMethod(
  863. "_printString",
  864. smalltalk.method({
  865. selector: "printString",
  866. category: 'printing',
  867. fn: function (){
  868. var self=this;
  869. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  870. $1=_st((smalltalk.String || String))._streamContents_((function(aStream){
  871. return smalltalk.withContext(function($ctx2) { $2=aStream;
  872. _st($2)._nextPutAll_(smalltalk.Object.fn.prototype._printString.apply(_st(self), []));
  873. _st($2)._nextPutAll_("(");
  874. _st($2)._nextPutAll_(self["@selector"]);
  875. $3=_st($2)._nextPutAll_(")");
  876. return $3;
  877. }, function($ctx2) {$ctx2.fillBlock({aStream:aStream},$ctx1)})}));
  878. return $1;
  879. }, function($ctx1) {$ctx1.fill(self,"printString",{}, smalltalk.Message)})},
  880. args: [],
  881. source: "printString\x0a\x09^ String streamContents: [:aStream| \x0a \x09\x09\x09\x09aStream \x0a \x09\x09\x09\x09\x09nextPutAll: super printString;\x0a \x09\x09\x09\x09\x09nextPutAll: '(';\x0a \x09\x09\x09\x09\x09nextPutAll: selector;\x0a \x09\x09\x09\x09\x09nextPutAll: ')' \x09\x09\x09\x09]",
  882. messageSends: ["streamContents:", "nextPutAll:", "printString"],
  883. referencedClasses: ["String"]
  884. }),
  885. smalltalk.Message);
  886. smalltalk.addMethod(
  887. "_selector",
  888. smalltalk.method({
  889. selector: "selector",
  890. category: 'accessing',
  891. fn: function (){
  892. var self=this;
  893. return smalltalk.withContext(function($ctx1) { var $1;
  894. $1=self["@selector"];
  895. return $1;
  896. }, function($ctx1) {$ctx1.fill(self,"selector",{}, smalltalk.Message)})},
  897. args: [],
  898. source: "selector\x0a\x09^selector",
  899. messageSends: [],
  900. referencedClasses: []
  901. }),
  902. smalltalk.Message);
  903. smalltalk.addMethod(
  904. "_selector_",
  905. smalltalk.method({
  906. selector: "selector:",
  907. category: 'accessing',
  908. fn: function (aString){
  909. var self=this;
  910. return smalltalk.withContext(function($ctx1) { self["@selector"]=aString;
  911. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString}, smalltalk.Message)})},
  912. args: ["aString"],
  913. source: "selector: aString\x0a\x09selector := aString",
  914. messageSends: [],
  915. referencedClasses: []
  916. }),
  917. smalltalk.Message);
  918. smalltalk.addMethod(
  919. "_sendTo_",
  920. smalltalk.method({
  921. selector: "sendTo:",
  922. category: 'printing',
  923. fn: function (anObject){
  924. var self=this;
  925. return smalltalk.withContext(function($ctx1) { var $1;
  926. $1=_st(anObject)._perform_withArguments_(_st(self)._selector(),_st(self)._arguments());
  927. return $1;
  928. }, function($ctx1) {$ctx1.fill(self,"sendTo:",{anObject:anObject}, smalltalk.Message)})},
  929. args: ["anObject"],
  930. source: "sendTo: anObject\x0a\x09^ anObject perform: self selector withArguments: self arguments",
  931. messageSends: ["perform:withArguments:", "selector", "arguments"],
  932. referencedClasses: []
  933. }),
  934. smalltalk.Message);
  935. smalltalk.addMethod(
  936. "_selector_arguments_",
  937. smalltalk.method({
  938. selector: "selector:arguments:",
  939. category: 'instance creation',
  940. fn: function (aString,anArray){
  941. var self=this;
  942. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  943. $2=_st(self)._new();
  944. _st($2)._selector_(aString);
  945. _st($2)._arguments_(anArray);
  946. $3=_st($2)._yourself();
  947. $1=$3;
  948. return $1;
  949. }, function($ctx1) {$ctx1.fill(self,"selector:arguments:",{aString:aString,anArray:anArray}, smalltalk.Message.klass)})},
  950. args: ["aString", "anArray"],
  951. source: "selector: aString arguments: anArray\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
  952. messageSends: ["selector:", "new", "arguments:", "yourself"],
  953. referencedClasses: []
  954. }),
  955. smalltalk.Message.klass);
  956. smalltalk.addClass('MethodContext', smalltalk.Object, [], 'Kernel-Methods');
  957. 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"
  958. smalltalk.addMethod(
  959. "_asString",
  960. smalltalk.method({
  961. selector: "asString",
  962. category: 'converting',
  963. fn: function (){
  964. var self=this;
  965. return smalltalk.withContext(function($ctx1) { var $2,$1;
  966. $2=_st(self)._isBlockContext();
  967. if(smalltalk.assert($2)){
  968. $1=_st(_st("a block (in ").__comma(_st(_st(_st(_st(self)._methodContext())._receiver())._class())._printString())).__comma(")");
  969. } else {
  970. $1=_st(_st(_st(_st(_st(self)._receiver())._class())._printString()).__comma(" >> ")).__comma(_st(self)._selector());
  971. };
  972. return $1;
  973. }, function($ctx1) {$ctx1.fill(self,"asString",{}, smalltalk.MethodContext)})},
  974. args: [],
  975. source: "asString\x0a\x09^self isBlockContext \x0a \x09ifTrue: [ 'a block (in ', self methodContext receiver class printString, ')' ]\x0a \x09ifFalse: [ self receiver class printString, ' >> ', self selector ]",
  976. messageSends: ["ifTrue:ifFalse:", ",", "printString", "class", "receiver", "methodContext", "selector", "isBlockContext"],
  977. referencedClasses: []
  978. }),
  979. smalltalk.MethodContext);
  980. smalltalk.addMethod(
  981. "_home",
  982. smalltalk.method({
  983. selector: "home",
  984. category: 'accessing',
  985. fn: function (){
  986. var self=this;
  987. return smalltalk.withContext(function($ctx1) { return self.methodContext || self.homeContext;
  988. return self}, function($ctx1) {$ctx1.fill(self,"home",{}, smalltalk.MethodContext)})},
  989. args: [],
  990. source: "home\x0a\x09<return self.methodContext || self.homeContext>",
  991. messageSends: [],
  992. referencedClasses: []
  993. }),
  994. smalltalk.MethodContext);
  995. smalltalk.addMethod(
  996. "_isBlockContext",
  997. smalltalk.method({
  998. selector: "isBlockContext",
  999. category: 'testing',
  1000. fn: function (){
  1001. var self=this;
  1002. return smalltalk.withContext(function($ctx1) { var $1;
  1003. $1=_st(_st(self)._selector())._isNil();
  1004. return $1;
  1005. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{}, smalltalk.MethodContext)})},
  1006. args: [],
  1007. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a \x0a\x09^ self selector isNil",
  1008. messageSends: ["isNil", "selector"],
  1009. referencedClasses: []
  1010. }),
  1011. smalltalk.MethodContext);
  1012. smalltalk.addMethod(
  1013. "_locals",
  1014. smalltalk.method({
  1015. selector: "locals",
  1016. category: 'accessing',
  1017. fn: function (){
  1018. var self=this;
  1019. return smalltalk.withContext(function($ctx1) { return self.locals;
  1020. return self}, function($ctx1) {$ctx1.fill(self,"locals",{}, smalltalk.MethodContext)})},
  1021. args: [],
  1022. source: "locals\x0a\x09<return self.locals>",
  1023. messageSends: [],
  1024. referencedClasses: []
  1025. }),
  1026. smalltalk.MethodContext);
  1027. smalltalk.addMethod(
  1028. "_method",
  1029. smalltalk.method({
  1030. selector: "method",
  1031. category: 'accessing',
  1032. fn: function (){
  1033. var self=this;
  1034. return smalltalk.withContext(function($ctx1) { var $1;
  1035. $1=_st(_st(_st(_st(self)._methodContext())._receiver())._class())._lookupSelector_(_st(_st(self)._methodContext())._selector());
  1036. return $1;
  1037. }, function($ctx1) {$ctx1.fill(self,"method",{}, smalltalk.MethodContext)})},
  1038. args: [],
  1039. source: "method\x0a\x09^self methodContext receiver class lookupSelector: self methodContext selector",
  1040. messageSends: ["lookupSelector:", "selector", "methodContext", "class", "receiver"],
  1041. referencedClasses: []
  1042. }),
  1043. smalltalk.MethodContext);
  1044. smalltalk.addMethod(
  1045. "_methodContext",
  1046. smalltalk.method({
  1047. selector: "methodContext",
  1048. category: 'accessing',
  1049. fn: function (){
  1050. var self=this;
  1051. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  1052. $1=_st(self)._isBlockContext();
  1053. if(! smalltalk.assert($1)){
  1054. $2=self;
  1055. return $2;
  1056. };
  1057. $3=_st(self)._home();
  1058. return $3;
  1059. }, function($ctx1) {$ctx1.fill(self,"methodContext",{}, smalltalk.MethodContext)})},
  1060. args: [],
  1061. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a \x0a ^ self home",
  1062. messageSends: ["ifFalse:", "isBlockContext", "home"],
  1063. referencedClasses: []
  1064. }),
  1065. smalltalk.MethodContext);
  1066. smalltalk.addMethod(
  1067. "_outerContext",
  1068. smalltalk.method({
  1069. selector: "outerContext",
  1070. category: 'accessing',
  1071. fn: function (){
  1072. var self=this;
  1073. return smalltalk.withContext(function($ctx1) { return self.homeContext;
  1074. return self}, function($ctx1) {$ctx1.fill(self,"outerContext",{}, smalltalk.MethodContext)})},
  1075. args: [],
  1076. source: "outerContext\x0a\x09<return self.homeContext>",
  1077. messageSends: [],
  1078. referencedClasses: []
  1079. }),
  1080. smalltalk.MethodContext);
  1081. smalltalk.addMethod(
  1082. "_pc",
  1083. smalltalk.method({
  1084. selector: "pc",
  1085. category: 'accessing',
  1086. fn: function (){
  1087. var self=this;
  1088. return smalltalk.withContext(function($ctx1) { return self.pc;
  1089. return self}, function($ctx1) {$ctx1.fill(self,"pc",{}, smalltalk.MethodContext)})},
  1090. args: [],
  1091. source: "pc\x0a\x09<return self.pc>",
  1092. messageSends: [],
  1093. referencedClasses: []
  1094. }),
  1095. smalltalk.MethodContext);
  1096. smalltalk.addMethod(
  1097. "_printString",
  1098. smalltalk.method({
  1099. selector: "printString",
  1100. category: 'accessing',
  1101. fn: function (){
  1102. var self=this;
  1103. return smalltalk.withContext(function($ctx1) { var $1;
  1104. $1=_st(_st(_st(smalltalk.Object.fn.prototype._printString.apply(_st(self), [])).__comma("(")).__comma(_st(self)._asString())).__comma(")");
  1105. return $1;
  1106. }, function($ctx1) {$ctx1.fill(self,"printString",{}, smalltalk.MethodContext)})},
  1107. args: [],
  1108. source: "printString\x0a\x09^super printString, '(', self asString, ')'",
  1109. messageSends: [",", "asString", "printString"],
  1110. referencedClasses: []
  1111. }),
  1112. smalltalk.MethodContext);
  1113. smalltalk.addMethod(
  1114. "_receiver",
  1115. smalltalk.method({
  1116. selector: "receiver",
  1117. category: 'accessing',
  1118. fn: function (){
  1119. var self=this;
  1120. return smalltalk.withContext(function($ctx1) { return self.receiver;
  1121. return self}, function($ctx1) {$ctx1.fill(self,"receiver",{}, smalltalk.MethodContext)})},
  1122. args: [],
  1123. source: "receiver\x0a\x09<return self.receiver>",
  1124. messageSends: [],
  1125. referencedClasses: []
  1126. }),
  1127. smalltalk.MethodContext);
  1128. smalltalk.addMethod(
  1129. "_selector",
  1130. smalltalk.method({
  1131. selector: "selector",
  1132. category: 'accessing',
  1133. fn: function (){
  1134. var self=this;
  1135. return smalltalk.withContext(function($ctx1) {
  1136. if(self.selector) {
  1137. return smalltalk.convertSelector(self.selector);
  1138. } else {
  1139. return nil;
  1140. }
  1141. ;
  1142. return self}, function($ctx1) {$ctx1.fill(self,"selector",{}, smalltalk.MethodContext)})},
  1143. args: [],
  1144. source: "selector\x0a\x09<\x0a \x09if(self.selector) {\x0a \x09return smalltalk.convertSelector(self.selector);\x0a } else {\x0a \x09return nil;\x0a }\x0a >",
  1145. messageSends: [],
  1146. referencedClasses: []
  1147. }),
  1148. smalltalk.MethodContext);
  1149. smalltalk.addMethod(
  1150. "_temps",
  1151. smalltalk.method({
  1152. selector: "temps",
  1153. category: 'accessing',
  1154. fn: function (){
  1155. var self=this;
  1156. return smalltalk.withContext(function($ctx1) { var $1;
  1157. _st(self)._deprecatedAPI();
  1158. $1=_st(self)._locals();
  1159. return $1;
  1160. }, function($ctx1) {$ctx1.fill(self,"temps",{}, smalltalk.MethodContext)})},
  1161. args: [],
  1162. source: "temps\x0a\x09self deprecatedAPI.\x0a \x0a\x09^ self locals",
  1163. messageSends: ["deprecatedAPI", "locals"],
  1164. referencedClasses: []
  1165. }),
  1166. smalltalk.MethodContext);
  1167. smalltalk.addClass('NativeFunction', smalltalk.Object, [], 'Kernel-Methods');
  1168. 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 | ws |\x0a ws := NativeFunction constructor: 'WebSocket' value: 'ws://localhost'.\x0a ws at: 'onopen' put: [ ws send: 'hey there from Amber' ]"
  1169. smalltalk.addMethod(
  1170. "_constructor_",
  1171. smalltalk.method({
  1172. selector: "constructor:",
  1173. category: 'instance creation',
  1174. fn: function (aString){
  1175. var self=this;
  1176. return smalltalk.withContext(function($ctx1) {
  1177. var native=eval(aString);
  1178. return new native();
  1179. ;
  1180. return self}, function($ctx1) {$ctx1.fill(self,"constructor:",{aString:aString}, smalltalk.NativeFunction.klass)})},
  1181. args: ["aString"],
  1182. source: "constructor: aString\x0a\x09<\x0a \x09var native=eval(aString); \x0a return new native();\x0a\x09>",
  1183. messageSends: [],
  1184. referencedClasses: []
  1185. }),
  1186. smalltalk.NativeFunction.klass);
  1187. smalltalk.addMethod(
  1188. "_constructor_value_",
  1189. smalltalk.method({
  1190. selector: "constructor:value:",
  1191. category: 'instance creation',
  1192. fn: function (aString,anObject){
  1193. var self=this;
  1194. return smalltalk.withContext(function($ctx1) {
  1195. var native=eval(aString);
  1196. return new native(anObject);
  1197. ;
  1198. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:",{aString:aString,anObject:anObject}, smalltalk.NativeFunction.klass)})},
  1199. args: ["aString", "anObject"],
  1200. source: "constructor: aString value:anObject\x0a\x09<\x0a \x09var native=eval(aString); \x0a return new native(anObject);\x0a\x09>",
  1201. messageSends: [],
  1202. referencedClasses: []
  1203. }),
  1204. smalltalk.NativeFunction.klass);
  1205. smalltalk.addMethod(
  1206. "_constructor_value_value_",
  1207. smalltalk.method({
  1208. selector: "constructor:value:value:",
  1209. category: 'instance creation',
  1210. fn: function (aString,anObject,anObject2){
  1211. var self=this;
  1212. return smalltalk.withContext(function($ctx1) {
  1213. var native=eval(aString);
  1214. return new native(anObject,anObject2);
  1215. ;
  1216. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2}, smalltalk.NativeFunction.klass)})},
  1217. args: ["aString", "anObject", "anObject2"],
  1218. source: "constructor: aString value:anObject value: anObject2\x0a\x09<\x0a \x09var native=eval(aString); \x0a return new native(anObject,anObject2);\x0a\x09>",
  1219. messageSends: [],
  1220. referencedClasses: []
  1221. }),
  1222. smalltalk.NativeFunction.klass);
  1223. smalltalk.addMethod(
  1224. "_constructor_value_value_value_",
  1225. smalltalk.method({
  1226. selector: "constructor:value:value:value:",
  1227. category: 'instance creation',
  1228. fn: function (aString,anObject,anObject2,anObject3){
  1229. var self=this;
  1230. return smalltalk.withContext(function($ctx1) {
  1231. var native=eval(aString);
  1232. return new native(anObject,anObject2, anObject3);
  1233. ;
  1234. return self}, function($ctx1) {$ctx1.fill(self,"constructor:value:value:value:",{aString:aString,anObject:anObject,anObject2:anObject2,anObject3:anObject3}, smalltalk.NativeFunction.klass)})},
  1235. args: ["aString", "anObject", "anObject2", "anObject3"],
  1236. source: "constructor: aString value:anObject value: anObject2 value:anObject3\x0a\x09<\x0a \x09var native=eval(aString); \x0a return new native(anObject,anObject2, anObject3);\x0a\x09>",
  1237. messageSends: [],
  1238. referencedClasses: []
  1239. }),
  1240. smalltalk.NativeFunction.klass);
  1241. smalltalk.addMethod(
  1242. "_exists_",
  1243. smalltalk.method({
  1244. selector: "exists:",
  1245. category: 'testing',
  1246. fn: function (aString){
  1247. var self=this;
  1248. return smalltalk.withContext(function($ctx1) {
  1249. if(aString in window) {
  1250. return true
  1251. } else {
  1252. return false
  1253. }
  1254. ;
  1255. return self}, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString}, smalltalk.NativeFunction.klass)})},
  1256. args: ["aString"],
  1257. source: "exists: aString\x0a\x09<\x0a \x09if(aString in window) {\x0a \x09return true\x0a } else {\x0a \x09return false\x0a }\x0a >",
  1258. messageSends: [],
  1259. referencedClasses: []
  1260. }),
  1261. smalltalk.NativeFunction.klass);