Kernel-Methods.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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($ctx) { return self.apply(anObject, aCollection);
  12. ;
  13. return self}, self, "applyTo:arguments:", [anObject,aCollection], smalltalk.BlockClosure)},
  14. args: ["anObject", "aCollection"],
  15. source: "applyTo: anObject arguments: aCollection\x0a\x09<return self.apply(anObject, aCollection)>",
  16. messageSends: [],
  17. referencedClasses: []
  18. }),
  19. smalltalk.BlockClosure);
  20. smalltalk.addMethod(
  21. "_compiledSource",
  22. smalltalk.method({
  23. selector: "compiledSource",
  24. category: 'accessing',
  25. fn: function (){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx) { return self.toString();
  28. ;
  29. return self}, self, "compiledSource", [], smalltalk.BlockClosure)},
  30. args: [],
  31. source: "compiledSource\x0a\x09<return self.toString()>",
  32. messageSends: [],
  33. referencedClasses: []
  34. }),
  35. smalltalk.BlockClosure);
  36. smalltalk.addMethod(
  37. "_ensure_",
  38. smalltalk.method({
  39. selector: "ensure:",
  40. category: 'evaluating',
  41. fn: function (aBlock){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx) { var $1;
  44. var success;
  45. success=false;
  46. $1=_st((function(){
  47. _st(self)._value();
  48. success=true;
  49. success;
  50. return _st(aBlock)._value();
  51. }))._on_do_((smalltalk.Error || Error),(function(ex){
  52. if(! smalltalk.assert(success)){
  53. _st(aBlock)._value();
  54. };
  55. return _st(ex)._signal();
  56. }));
  57. return $1;
  58. }, self, "ensure:", [aBlock], smalltalk.BlockClosure)},
  59. args: ["aBlock"],
  60. source: "ensure: aBlock\x0a\x09| success |\x0a\x09success := false.\x0a\x09^[self value. success := true. aBlock value]\x0a\x09\x09on: Error\x0a\x09\x09do: [:ex |\x0a\x09\x09\x09success ifFalse: [aBlock value].\x0a\x09\x09\x09ex signal]",
  61. messageSends: ["on:do:", "ifFalse:", "value", "signal"],
  62. referencedClasses: ["Error"]
  63. }),
  64. smalltalk.BlockClosure);
  65. smalltalk.addMethod(
  66. "_new",
  67. smalltalk.method({
  68. selector: "new",
  69. category: 'evaluating',
  70. fn: function (){
  71. var self=this;
  72. return smalltalk.withContext(function($ctx) { return new self();
  73. ;
  74. return self}, self, "new", [], smalltalk.BlockClosure)},
  75. args: [],
  76. 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()>",
  77. messageSends: [],
  78. referencedClasses: []
  79. }),
  80. smalltalk.BlockClosure);
  81. smalltalk.addMethod(
  82. "_newValue_",
  83. smalltalk.method({
  84. selector: "newValue:",
  85. category: 'evaluating',
  86. fn: function (anObject){
  87. var self=this;
  88. return smalltalk.withContext(function($ctx) { return new self(anObject);
  89. ;
  90. return self}, self, "newValue:", [anObject], smalltalk.BlockClosure)},
  91. args: ["anObject"],
  92. 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)>",
  93. messageSends: [],
  94. referencedClasses: []
  95. }),
  96. smalltalk.BlockClosure);
  97. smalltalk.addMethod(
  98. "_newValue_value_",
  99. smalltalk.method({
  100. selector: "newValue:value:",
  101. category: 'evaluating',
  102. fn: function (anObject,anObject2){
  103. var self=this;
  104. return smalltalk.withContext(function($ctx) { return new self(anObject, anObject2);
  105. ;
  106. return self}, self, "newValue:value:", [anObject,anObject2], smalltalk.BlockClosure)},
  107. args: ["anObject", "anObject2"],
  108. 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)>",
  109. messageSends: [],
  110. referencedClasses: []
  111. }),
  112. smalltalk.BlockClosure);
  113. smalltalk.addMethod(
  114. "_newValue_value_value_",
  115. smalltalk.method({
  116. selector: "newValue:value:value:",
  117. category: 'evaluating',
  118. fn: function (anObject,anObject2,anObject3){
  119. var self=this;
  120. return smalltalk.withContext(function($ctx) { return new self(anObject, anObject2);
  121. ;
  122. return self}, self, "newValue:value:value:", [anObject,anObject2,anObject3], smalltalk.BlockClosure)},
  123. args: ["anObject", "anObject2", "anObject3"],
  124. 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)>",
  125. messageSends: [],
  126. referencedClasses: []
  127. }),
  128. smalltalk.BlockClosure);
  129. smalltalk.addMethod(
  130. "_numArgs",
  131. smalltalk.method({
  132. selector: "numArgs",
  133. category: 'accessing',
  134. fn: function (){
  135. var self=this;
  136. return smalltalk.withContext(function($ctx) { return self.length;
  137. ;
  138. return self}, self, "numArgs", [], smalltalk.BlockClosure)},
  139. args: [],
  140. source: "numArgs\x0a\x09<return self.length>",
  141. messageSends: [],
  142. referencedClasses: []
  143. }),
  144. smalltalk.BlockClosure);
  145. smalltalk.addMethod(
  146. "_on_do_",
  147. smalltalk.method({
  148. selector: "on:do:",
  149. category: 'error handling',
  150. fn: function (anErrorClass,aBlock){
  151. var self=this;
  152. return smalltalk.withContext(function($ctx) { var $2,$1;
  153. $1=_st(self)._try_catch_(self,(function(error){
  154. $2=_st(error)._isKindOf_(anErrorClass);
  155. if(smalltalk.assert($2)){
  156. return _st(aBlock)._value_(error);
  157. } else {
  158. return _st(error)._signal();
  159. };
  160. }));
  161. return $1;
  162. }, self, "on:do:", [anErrorClass,aBlock], smalltalk.BlockClosure)},
  163. args: ["anErrorClass", "aBlock"],
  164. source: "on: anErrorClass do: aBlock\x0a\x09^self try: self catch: [:error |\x0a\x09 (error isKindOf: anErrorClass) \x0a\x09 ifTrue: [aBlock value: error]\x0a\x09 ifFalse: [error signal]]",
  165. messageSends: ["try:catch:", "ifTrue:ifFalse:", "value:", "signal", "isKindOf:"],
  166. referencedClasses: []
  167. }),
  168. smalltalk.BlockClosure);
  169. smalltalk.addMethod(
  170. "_timeToRun",
  171. smalltalk.method({
  172. selector: "timeToRun",
  173. category: 'evaluating',
  174. fn: function (){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx) { var $1;
  177. $1=_st((smalltalk.Date || Date))._millisecondsToRun_(self);
  178. return $1;
  179. }, self, "timeToRun", [], smalltalk.BlockClosure)},
  180. args: [],
  181. source: "timeToRun\x0a\x09\x22Answer the number of milliseconds taken to execute this block.\x22\x0a\x0a\x09^ Date millisecondsToRun: self",
  182. messageSends: ["millisecondsToRun:"],
  183. referencedClasses: ["Date"]
  184. }),
  185. smalltalk.BlockClosure);
  186. smalltalk.addMethod(
  187. "_value",
  188. smalltalk.method({
  189. selector: "value",
  190. category: 'evaluating',
  191. fn: function (){
  192. var self=this;
  193. return smalltalk.withContext(function($ctx) { return self();;
  194. ;
  195. return self}, self, "value", [], smalltalk.BlockClosure)},
  196. args: [],
  197. source: "value\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self();>",
  198. messageSends: [],
  199. referencedClasses: []
  200. }),
  201. smalltalk.BlockClosure);
  202. smalltalk.addMethod(
  203. "_value_",
  204. smalltalk.method({
  205. selector: "value:",
  206. category: 'evaluating',
  207. fn: function (anArg){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx) { return self(anArg);;
  210. ;
  211. return self}, self, "value:", [anArg], smalltalk.BlockClosure)},
  212. args: ["anArg"],
  213. source: "value: anArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(anArg);>",
  214. messageSends: [],
  215. referencedClasses: []
  216. }),
  217. smalltalk.BlockClosure);
  218. smalltalk.addMethod(
  219. "_value_value_",
  220. smalltalk.method({
  221. selector: "value:value:",
  222. category: 'evaluating',
  223. fn: function (firstArg,secondArg){
  224. var self=this;
  225. return smalltalk.withContext(function($ctx) { return self(firstArg, secondArg);;
  226. ;
  227. return self}, self, "value:value:", [firstArg,secondArg], smalltalk.BlockClosure)},
  228. args: ["firstArg", "secondArg"],
  229. source: "value: firstArg value: secondArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg);>",
  230. messageSends: [],
  231. referencedClasses: []
  232. }),
  233. smalltalk.BlockClosure);
  234. smalltalk.addMethod(
  235. "_value_value_value_",
  236. smalltalk.method({
  237. selector: "value:value:value:",
  238. category: 'evaluating',
  239. fn: function (firstArg,secondArg,thirdArg){
  240. var self=this;
  241. return smalltalk.withContext(function($ctx) { return self(firstArg, secondArg, thirdArg);;
  242. ;
  243. return self}, self, "value:value:value:", [firstArg,secondArg,thirdArg], smalltalk.BlockClosure)},
  244. args: ["firstArg", "secondArg", "thirdArg"],
  245. source: "value: firstArg value: secondArg value: thirdArg\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<return self(firstArg, secondArg, thirdArg);>",
  246. messageSends: [],
  247. referencedClasses: []
  248. }),
  249. smalltalk.BlockClosure);
  250. smalltalk.addMethod(
  251. "_valueWithInterval_",
  252. smalltalk.method({
  253. selector: "valueWithInterval:",
  254. category: 'timeout/interval',
  255. fn: function (aNumber){
  256. var self=this;
  257. return smalltalk.withContext(function($ctx) { return setInterval(self, aNumber);
  258. ;
  259. return self}, self, "valueWithInterval:", [aNumber], smalltalk.BlockClosure)},
  260. args: ["aNumber"],
  261. source: "valueWithInterval: aNumber\x0a\x09<return setInterval(self, aNumber)>",
  262. messageSends: [],
  263. referencedClasses: []
  264. }),
  265. smalltalk.BlockClosure);
  266. smalltalk.addMethod(
  267. "_valueWithPossibleArguments_",
  268. smalltalk.method({
  269. selector: "valueWithPossibleArguments:",
  270. category: 'evaluating',
  271. fn: function (aCollection){
  272. var self=this;
  273. return smalltalk.withContext(function($ctx) { return self.apply(null, aCollection);;
  274. ;
  275. return self}, self, "valueWithPossibleArguments:", [aCollection], smalltalk.BlockClosure)},
  276. args: ["aCollection"],
  277. source: "valueWithPossibleArguments: aCollection\x0a\x09<return self.apply(null, aCollection);>",
  278. messageSends: [],
  279. referencedClasses: []
  280. }),
  281. smalltalk.BlockClosure);
  282. smalltalk.addMethod(
  283. "_valueWithTimeout_",
  284. smalltalk.method({
  285. selector: "valueWithTimeout:",
  286. category: 'timeout/interval',
  287. fn: function (aNumber){
  288. var self=this;
  289. return smalltalk.withContext(function($ctx) { return setTimeout(self, aNumber);
  290. ;
  291. return self}, self, "valueWithTimeout:", [aNumber], smalltalk.BlockClosure)},
  292. args: ["aNumber"],
  293. source: "valueWithTimeout: aNumber\x0a\x09<return setTimeout(self, aNumber)>",
  294. messageSends: [],
  295. referencedClasses: []
  296. }),
  297. smalltalk.BlockClosure);
  298. smalltalk.addMethod(
  299. "_whileFalse",
  300. smalltalk.method({
  301. selector: "whileFalse",
  302. category: 'controlling',
  303. fn: function (){
  304. var self=this;
  305. return smalltalk.withContext(function($ctx) { _st(self)._whileFalse_((function(){
  306. }));
  307. return self}, self, "whileFalse", [], smalltalk.BlockClosure)},
  308. args: [],
  309. source: "whileFalse\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileFalse: []",
  310. messageSends: ["whileFalse:"],
  311. referencedClasses: []
  312. }),
  313. smalltalk.BlockClosure);
  314. smalltalk.addMethod(
  315. "_whileFalse_",
  316. smalltalk.method({
  317. selector: "whileFalse:",
  318. category: 'controlling',
  319. fn: function (aBlock){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx) { while(!self()) {aBlock()};
  322. ;
  323. return self}, self, "whileFalse:", [aBlock], smalltalk.BlockClosure)},
  324. args: ["aBlock"],
  325. source: "whileFalse: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(!self()) {aBlock()}>",
  326. messageSends: [],
  327. referencedClasses: []
  328. }),
  329. smalltalk.BlockClosure);
  330. smalltalk.addMethod(
  331. "_whileTrue",
  332. smalltalk.method({
  333. selector: "whileTrue",
  334. category: 'controlling',
  335. fn: function (){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx) { _st(self)._whileTrue_((function(){
  338. }));
  339. return self}, self, "whileTrue", [], smalltalk.BlockClosure)},
  340. args: [],
  341. source: "whileTrue\x0a\x09\x22inlined in the Compiler\x22\x0a\x09self whileTrue: []",
  342. messageSends: ["whileTrue:"],
  343. referencedClasses: []
  344. }),
  345. smalltalk.BlockClosure);
  346. smalltalk.addMethod(
  347. "_whileTrue_",
  348. smalltalk.method({
  349. selector: "whileTrue:",
  350. category: 'controlling',
  351. fn: function (aBlock){
  352. var self=this;
  353. return smalltalk.withContext(function($ctx) { while(self()) {aBlock()};
  354. ;
  355. return self}, self, "whileTrue:", [aBlock], smalltalk.BlockClosure)},
  356. args: ["aBlock"],
  357. source: "whileTrue: aBlock\x0a\x09\x22inlined in the Compiler\x22\x0a\x09<while(self()) {aBlock()}>",
  358. messageSends: [],
  359. referencedClasses: []
  360. }),
  361. smalltalk.BlockClosure);
  362. smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
  363. 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"
  364. smalltalk.addMethod(
  365. "_arguments",
  366. smalltalk.method({
  367. selector: "arguments",
  368. category: 'accessing',
  369. fn: function (){
  370. var self=this;
  371. return smalltalk.withContext(function($ctx) { return self.args || [];
  372. ;
  373. return self}, self, "arguments", [], smalltalk.CompiledMethod)},
  374. args: [],
  375. source: "arguments\x0a\x09<return self.args || []>",
  376. messageSends: [],
  377. referencedClasses: []
  378. }),
  379. smalltalk.CompiledMethod);
  380. smalltalk.addMethod(
  381. "_category",
  382. smalltalk.method({
  383. selector: "category",
  384. category: 'accessing',
  385. fn: function (){
  386. var self=this;
  387. return smalltalk.withContext(function($ctx) { var $2,$1;
  388. $2=_st(self)._basicAt_("category");
  389. if(($receiver = $2) == nil || $receiver == undefined){
  390. $1="";
  391. } else {
  392. $1=$2;
  393. };
  394. return $1;
  395. }, self, "category", [], smalltalk.CompiledMethod)},
  396. args: [],
  397. source: "category\x0a\x09^(self basicAt: 'category') ifNil: ['']",
  398. messageSends: ["ifNil:", "basicAt:"],
  399. referencedClasses: []
  400. }),
  401. smalltalk.CompiledMethod);
  402. smalltalk.addMethod(
  403. "_category_",
  404. smalltalk.method({
  405. selector: "category:",
  406. category: 'accessing',
  407. fn: function (aString){
  408. var self=this;
  409. return smalltalk.withContext(function($ctx) { var $1;
  410. var oldCategory;
  411. oldCategory=_st(self)._category();
  412. _st(self)._basicAt_put_("category",aString);
  413. $1=_st(self)._methodClass();
  414. if(($receiver = $1) == nil || $receiver == undefined){
  415. $1;
  416. } else {
  417. _st(_st(_st(self)._methodClass())._organization())._addElement_(aString);
  418. _st(_st(_st(_st(self)._methodClass())._methods())._select_((function(each){
  419. return _st(_st(each)._category()).__eq(oldCategory);
  420. })))._ifEmpty_((function(){
  421. return _st(_st(_st(self)._methodClass())._organization())._removeElement_(oldCategory);
  422. }));
  423. };
  424. return self}, self, "category:", [aString], smalltalk.CompiledMethod)},
  425. args: ["aString"],
  426. 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 ] ]",
  427. messageSends: ["category", "basicAt:put:", "ifNotNil:", "addElement:", "organization", "methodClass", "ifEmpty:", "removeElement:", "select:", "=", "methods"],
  428. referencedClasses: []
  429. }),
  430. smalltalk.CompiledMethod);
  431. smalltalk.addMethod(
  432. "_fn",
  433. smalltalk.method({
  434. selector: "fn",
  435. category: 'accessing',
  436. fn: function (){
  437. var self=this;
  438. return smalltalk.withContext(function($ctx) { var $1;
  439. $1=_st(self)._basicAt_("fn");
  440. return $1;
  441. }, self, "fn", [], smalltalk.CompiledMethod)},
  442. args: [],
  443. source: "fn\x0a\x09^self basicAt: 'fn'",
  444. messageSends: ["basicAt:"],
  445. referencedClasses: []
  446. }),
  447. smalltalk.CompiledMethod);
  448. smalltalk.addMethod(
  449. "_fn_",
  450. smalltalk.method({
  451. selector: "fn:",
  452. category: 'accessing',
  453. fn: function (aBlock){
  454. var self=this;
  455. return smalltalk.withContext(function($ctx) { _st(self)._basicAt_put_("fn",aBlock);
  456. return self}, self, "fn:", [aBlock], smalltalk.CompiledMethod)},
  457. args: ["aBlock"],
  458. source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
  459. messageSends: ["basicAt:put:"],
  460. referencedClasses: []
  461. }),
  462. smalltalk.CompiledMethod);
  463. smalltalk.addMethod(
  464. "_messageSends",
  465. smalltalk.method({
  466. selector: "messageSends",
  467. category: 'accessing',
  468. fn: function (){
  469. var self=this;
  470. return smalltalk.withContext(function($ctx) { var $1;
  471. $1=_st(self)._basicAt_("messageSends");
  472. return $1;
  473. }, self, "messageSends", [], smalltalk.CompiledMethod)},
  474. args: [],
  475. source: "messageSends\x0a\x09^self basicAt: 'messageSends'",
  476. messageSends: ["basicAt:"],
  477. referencedClasses: []
  478. }),
  479. smalltalk.CompiledMethod);
  480. smalltalk.addMethod(
  481. "_methodClass",
  482. smalltalk.method({
  483. selector: "methodClass",
  484. category: 'accessing',
  485. fn: function (){
  486. var self=this;
  487. return smalltalk.withContext(function($ctx) { var $1;
  488. $1=_st(self)._basicAt_("methodClass");
  489. return $1;
  490. }, self, "methodClass", [], smalltalk.CompiledMethod)},
  491. args: [],
  492. source: "methodClass\x0a\x09^self basicAt: 'methodClass'",
  493. messageSends: ["basicAt:"],
  494. referencedClasses: []
  495. }),
  496. smalltalk.CompiledMethod);
  497. smalltalk.addMethod(
  498. "_protocol",
  499. smalltalk.method({
  500. selector: "protocol",
  501. category: 'accessing',
  502. fn: function (){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx) { var $1;
  505. $1=_st(self)._category();
  506. return $1;
  507. }, self, "protocol", [], smalltalk.CompiledMethod)},
  508. args: [],
  509. source: "protocol\x0a\x09^ self category",
  510. messageSends: ["category"],
  511. referencedClasses: []
  512. }),
  513. smalltalk.CompiledMethod);
  514. smalltalk.addMethod(
  515. "_referencedClasses",
  516. smalltalk.method({
  517. selector: "referencedClasses",
  518. category: 'accessing',
  519. fn: function (){
  520. var self=this;
  521. return smalltalk.withContext(function($ctx) { var $1;
  522. $1=_st(self)._basicAt_("referencedClasses");
  523. return $1;
  524. }, self, "referencedClasses", [], smalltalk.CompiledMethod)},
  525. args: [],
  526. source: "referencedClasses\x0a\x09^self basicAt: 'referencedClasses'",
  527. messageSends: ["basicAt:"],
  528. referencedClasses: []
  529. }),
  530. smalltalk.CompiledMethod);
  531. smalltalk.addMethod(
  532. "_selector",
  533. smalltalk.method({
  534. selector: "selector",
  535. category: 'accessing',
  536. fn: function (){
  537. var self=this;
  538. return smalltalk.withContext(function($ctx) { var $1;
  539. $1=_st(self)._basicAt_("selector");
  540. return $1;
  541. }, self, "selector", [], smalltalk.CompiledMethod)},
  542. args: [],
  543. source: "selector\x0a\x09^self basicAt: 'selector'",
  544. messageSends: ["basicAt:"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.CompiledMethod);
  548. smalltalk.addMethod(
  549. "_selector_",
  550. smalltalk.method({
  551. selector: "selector:",
  552. category: 'accessing',
  553. fn: function (aString){
  554. var self=this;
  555. return smalltalk.withContext(function($ctx) { _st(self)._basicAt_put_("selector",aString);
  556. return self}, self, "selector:", [aString], smalltalk.CompiledMethod)},
  557. args: ["aString"],
  558. source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
  559. messageSends: ["basicAt:put:"],
  560. referencedClasses: []
  561. }),
  562. smalltalk.CompiledMethod);
  563. smalltalk.addMethod(
  564. "_source",
  565. smalltalk.method({
  566. selector: "source",
  567. category: 'accessing',
  568. fn: function (){
  569. var self=this;
  570. return smalltalk.withContext(function($ctx) { var $2,$1;
  571. $2=_st(self)._basicAt_("source");
  572. if(($receiver = $2) == nil || $receiver == undefined){
  573. $1="";
  574. } else {
  575. $1=$2;
  576. };
  577. return $1;
  578. }, self, "source", [], smalltalk.CompiledMethod)},
  579. args: [],
  580. source: "source\x0a\x09^(self basicAt: 'source') ifNil: ['']",
  581. messageSends: ["ifNil:", "basicAt:"],
  582. referencedClasses: []
  583. }),
  584. smalltalk.CompiledMethod);
  585. smalltalk.addMethod(
  586. "_source_",
  587. smalltalk.method({
  588. selector: "source:",
  589. category: 'accessing',
  590. fn: function (aString){
  591. var self=this;
  592. return smalltalk.withContext(function($ctx) { _st(self)._basicAt_put_("source",aString);
  593. return self}, self, "source:", [aString], smalltalk.CompiledMethod)},
  594. args: ["aString"],
  595. source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
  596. messageSends: ["basicAt:put:"],
  597. referencedClasses: []
  598. }),
  599. smalltalk.CompiledMethod);
  600. smalltalk.addClass('Message', smalltalk.Object, ['selector', 'arguments'], 'Kernel-Methods');
  601. 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:`"
  602. smalltalk.addMethod(
  603. "_arguments",
  604. smalltalk.method({
  605. selector: "arguments",
  606. category: 'accessing',
  607. fn: function (){
  608. var self=this;
  609. return smalltalk.withContext(function($ctx) { return self["@arguments"];
  610. }, self, "arguments", [], smalltalk.Message)},
  611. args: [],
  612. source: "arguments\x0a\x09^arguments",
  613. messageSends: [],
  614. referencedClasses: []
  615. }),
  616. smalltalk.Message);
  617. smalltalk.addMethod(
  618. "_arguments_",
  619. smalltalk.method({
  620. selector: "arguments:",
  621. category: 'accessing',
  622. fn: function (anArray){
  623. var self=this;
  624. return smalltalk.withContext(function($ctx) { self["@arguments"]=anArray;
  625. return self}, self, "arguments:", [anArray], smalltalk.Message)},
  626. args: ["anArray"],
  627. source: "arguments: anArray\x0a\x09arguments := anArray",
  628. messageSends: [],
  629. referencedClasses: []
  630. }),
  631. smalltalk.Message);
  632. smalltalk.addMethod(
  633. "_printString",
  634. smalltalk.method({
  635. selector: "printString",
  636. category: 'printing',
  637. fn: function (){
  638. var self=this;
  639. return smalltalk.withContext(function($ctx) { var $2,$1;
  640. $1=_st((smalltalk.String || String))._streamContents_((function(aStream){
  641. _st(aStream)._nextPutAll_(smalltalk.Object.fn.prototype._printString.apply(_st(self), []));
  642. _st(aStream)._nextPutAll_("(");
  643. _st(aStream)._nextPutAll_(self["@selector"]);
  644. $2=_st(aStream)._nextPutAll_(")");
  645. return $2;
  646. }));
  647. return $1;
  648. }, self, "printString", [], smalltalk.Message)},
  649. args: [],
  650. 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]",
  651. messageSends: ["streamContents:", "nextPutAll:", "printString"],
  652. referencedClasses: ["String"]
  653. }),
  654. smalltalk.Message);
  655. smalltalk.addMethod(
  656. "_selector",
  657. smalltalk.method({
  658. selector: "selector",
  659. category: 'accessing',
  660. fn: function (){
  661. var self=this;
  662. return smalltalk.withContext(function($ctx) { return self["@selector"];
  663. }, self, "selector", [], smalltalk.Message)},
  664. args: [],
  665. source: "selector\x0a\x09^selector",
  666. messageSends: [],
  667. referencedClasses: []
  668. }),
  669. smalltalk.Message);
  670. smalltalk.addMethod(
  671. "_selector_",
  672. smalltalk.method({
  673. selector: "selector:",
  674. category: 'accessing',
  675. fn: function (aString){
  676. var self=this;
  677. return smalltalk.withContext(function($ctx) { self["@selector"]=aString;
  678. return self}, self, "selector:", [aString], smalltalk.Message)},
  679. args: ["aString"],
  680. source: "selector: aString\x0a\x09selector := aString",
  681. messageSends: [],
  682. referencedClasses: []
  683. }),
  684. smalltalk.Message);
  685. smalltalk.addMethod(
  686. "_sendTo_",
  687. smalltalk.method({
  688. selector: "sendTo:",
  689. category: 'printing',
  690. fn: function (anObject){
  691. var self=this;
  692. return smalltalk.withContext(function($ctx) { var $1;
  693. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._send_to_arguments_(_st(self)._selector(),anObject,_st(self)._arguments());
  694. return $1;
  695. }, self, "sendTo:", [anObject], smalltalk.Message)},
  696. args: ["anObject"],
  697. source: "sendTo: anObject\x0a\x09^ Smalltalk current send: self selector to: anObject arguments: self arguments",
  698. messageSends: ["send:to:arguments:", "selector", "arguments", "current"],
  699. referencedClasses: ["Smalltalk"]
  700. }),
  701. smalltalk.Message);
  702. smalltalk.addMethod(
  703. "_selector_arguments_",
  704. smalltalk.method({
  705. selector: "selector:arguments:",
  706. category: 'instance creation',
  707. fn: function (aString,anArray){
  708. var self=this;
  709. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  710. $2=_st(self)._new();
  711. _st($2)._selector_(aString);
  712. _st($2)._arguments_(anArray);
  713. $3=_st($2)._yourself();
  714. $1=$3;
  715. return $1;
  716. }, self, "selector:arguments:", [aString,anArray], smalltalk.Message.klass)},
  717. args: ["aString", "anArray"],
  718. source: "selector: aString arguments: anArray\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09arguments: anArray;\x0a\x09\x09yourself",
  719. messageSends: ["selector:", "new", "arguments:", "yourself"],
  720. referencedClasses: []
  721. }),
  722. smalltalk.Message.klass);
  723. smalltalk.addClass('MethodContext', smalltalk.Object, [], 'Kernel-Methods');
  724. 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 \x0a\x0aCurrent limitation: MethodContext instances are not created on Block evaluation. That means it's actually impossible to debug inside a Block."
  725. smalltalk.addMethod(
  726. "_asString",
  727. smalltalk.method({
  728. selector: "asString",
  729. category: 'accessing',
  730. fn: function (){
  731. var self=this;
  732. return smalltalk.withContext(function($ctx) { var $1;
  733. $1=_st(_st(_st(_st(_st(self)._receiver())._class())._printString()).__comma(" >> ")).__comma(_st(self)._selector());
  734. return $1;
  735. }, self, "asString", [], smalltalk.MethodContext)},
  736. args: [],
  737. source: "asString\x0a\x09^self receiver class printString, ' >> ', self selector",
  738. messageSends: [",", "selector", "printString", "class", "receiver"],
  739. referencedClasses: []
  740. }),
  741. smalltalk.MethodContext);
  742. smalltalk.addMethod(
  743. "_home",
  744. smalltalk.method({
  745. selector: "home",
  746. category: 'accessing',
  747. fn: function (){
  748. var self=this;
  749. return smalltalk.withContext(function($ctx) { return self.homeContext;
  750. ;
  751. return self}, self, "home", [], smalltalk.MethodContext)},
  752. args: [],
  753. source: "home\x0a\x09<return self.homeContext>",
  754. messageSends: [],
  755. referencedClasses: []
  756. }),
  757. smalltalk.MethodContext);
  758. smalltalk.addMethod(
  759. "_locals",
  760. smalltalk.method({
  761. selector: "locals",
  762. category: 'accessing',
  763. fn: function (){
  764. var self=this;
  765. return smalltalk.withContext(function($ctx) { return self.locals;
  766. ;
  767. return self}, self, "locals", [], smalltalk.MethodContext)},
  768. args: [],
  769. source: "locals\x0a\x09<return self.locals>",
  770. messageSends: [],
  771. referencedClasses: []
  772. }),
  773. smalltalk.MethodContext);
  774. smalltalk.addMethod(
  775. "_method",
  776. smalltalk.method({
  777. selector: "method",
  778. category: 'accessing',
  779. fn: function (){
  780. var self=this;
  781. return smalltalk.withContext(function($ctx) { return self.method();
  782. ;
  783. return self}, self, "method", [], smalltalk.MethodContext)},
  784. args: [],
  785. source: "method\x0a\x09<return self.method()>",
  786. messageSends: [],
  787. referencedClasses: []
  788. }),
  789. smalltalk.MethodContext);
  790. smalltalk.addMethod(
  791. "_pc",
  792. smalltalk.method({
  793. selector: "pc",
  794. category: 'accessing',
  795. fn: function (){
  796. var self=this;
  797. return smalltalk.withContext(function($ctx) { return self.pc;
  798. ;
  799. return self}, self, "pc", [], smalltalk.MethodContext)},
  800. args: [],
  801. source: "pc\x0a\x09<return self.pc>",
  802. messageSends: [],
  803. referencedClasses: []
  804. }),
  805. smalltalk.MethodContext);
  806. smalltalk.addMethod(
  807. "_printString",
  808. smalltalk.method({
  809. selector: "printString",
  810. category: 'accessing',
  811. fn: function (){
  812. var self=this;
  813. return smalltalk.withContext(function($ctx) { var $1;
  814. $1=_st(_st(_st(smalltalk.Object.fn.prototype._printString.apply(_st(self), [])).__comma("(")).__comma(_st(self)._asString())).__comma(")");
  815. return $1;
  816. }, self, "printString", [], smalltalk.MethodContext)},
  817. args: [],
  818. source: "printString\x0a\x09^super printString, '(', self asString, ')'",
  819. messageSends: [",", "asString", "printString"],
  820. referencedClasses: []
  821. }),
  822. smalltalk.MethodContext);
  823. smalltalk.addMethod(
  824. "_receiver",
  825. smalltalk.method({
  826. selector: "receiver",
  827. category: 'accessing',
  828. fn: function (){
  829. var self=this;
  830. return smalltalk.withContext(function($ctx) { return self.receiver;
  831. ;
  832. return self}, self, "receiver", [], smalltalk.MethodContext)},
  833. args: [],
  834. source: "receiver\x0a\x09<return self.receiver>",
  835. messageSends: [],
  836. referencedClasses: []
  837. }),
  838. smalltalk.MethodContext);
  839. smalltalk.addMethod(
  840. "_selector",
  841. smalltalk.method({
  842. selector: "selector",
  843. category: 'accessing',
  844. fn: function (){
  845. var self=this;
  846. return smalltalk.withContext(function($ctx) { return smalltalk.convertSelector(self.selector);
  847. ;
  848. return self}, self, "selector", [], smalltalk.MethodContext)},
  849. args: [],
  850. source: "selector\x0a\x09<return smalltalk.convertSelector(self.selector)>",
  851. messageSends: [],
  852. referencedClasses: []
  853. }),
  854. smalltalk.MethodContext);
  855. smalltalk.addMethod(
  856. "_temps",
  857. smalltalk.method({
  858. selector: "temps",
  859. category: 'accessing',
  860. fn: function (){
  861. var self=this;
  862. return smalltalk.withContext(function($ctx) { var $1;
  863. $1=_st(self)._locals();
  864. return $1;
  865. }, self, "temps", [], smalltalk.MethodContext)},
  866. args: [],
  867. source: "temps\x0a\x09^ self locals",
  868. messageSends: ["locals"],
  869. referencedClasses: []
  870. }),
  871. smalltalk.MethodContext);