Kernel-Methods.deploy.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. smalltalk.addPackage('Kernel-Methods', {});
  2. smalltalk.addClass('BlockClosure', smalltalk.Object, [], 'Kernel-Methods');
  3. smalltalk.addMethod(
  4. "_applyTo_arguments_",
  5. smalltalk.method({
  6. selector: "applyTo:arguments:",
  7. fn: function (anObject, aCollection) {
  8. var self = this;
  9. return self.apply(anObject, aCollection);
  10. return self;
  11. }
  12. }),
  13. smalltalk.BlockClosure);
  14. smalltalk.addMethod(
  15. "_compiledSource",
  16. smalltalk.method({
  17. selector: "compiledSource",
  18. fn: function () {
  19. var self = this;
  20. return self.toString();
  21. return self;
  22. }
  23. }),
  24. smalltalk.BlockClosure);
  25. smalltalk.addMethod(
  26. "_ensure_",
  27. smalltalk.method({
  28. selector: "ensure:",
  29. fn: function (aBlock) {
  30. var self = this;
  31. var $1;
  32. var success;
  33. success = false;
  34. $1 = smalltalk.send(function () {smalltalk.send(self, "_value", []);success = true;success;return smalltalk.send(aBlock, "_value", []);}, "_on_do_", [smalltalk.Error || Error, function (ex) {if (!smalltalk.assert(success)) {smalltalk.send(aBlock, "_value", []);}return smalltalk.send(ex, "_signal", []);}]);
  35. return $1;
  36. }
  37. }),
  38. smalltalk.BlockClosure);
  39. smalltalk.addMethod(
  40. "_fork",
  41. smalltalk.method({
  42. selector: "fork",
  43. fn: function (){
  44. var self=this;
  45. smalltalk.send(smalltalk.send((smalltalk.ForkPool || ForkPool),"_default",[]),"_fork_",[self]);
  46. return self}
  47. }),
  48. smalltalk.BlockClosure);
  49. smalltalk.addMethod(
  50. "_new",
  51. smalltalk.method({
  52. selector: "new",
  53. fn: function () {
  54. var self = this;
  55. return new self;
  56. return self;
  57. }
  58. }),
  59. smalltalk.BlockClosure);
  60. smalltalk.addMethod(
  61. "_newValue_",
  62. smalltalk.method({
  63. selector: "newValue:",
  64. fn: function (anObject) {
  65. var self = this;
  66. return new self(anObject);
  67. return self;
  68. }
  69. }),
  70. smalltalk.BlockClosure);
  71. smalltalk.addMethod(
  72. "_newValue_value_",
  73. smalltalk.method({
  74. selector: "newValue:value:",
  75. fn: function (anObject, anObject2) {
  76. var self = this;
  77. return new self(anObject, anObject2);
  78. return self;
  79. }
  80. }),
  81. smalltalk.BlockClosure);
  82. smalltalk.addMethod(
  83. "_newValue_value_value_",
  84. smalltalk.method({
  85. selector: "newValue:value:value:",
  86. fn: function (anObject, anObject2, anObject3) {
  87. var self = this;
  88. return new self(anObject, anObject2);
  89. return self;
  90. }
  91. }),
  92. smalltalk.BlockClosure);
  93. smalltalk.addMethod(
  94. "_numArgs",
  95. smalltalk.method({
  96. selector: "numArgs",
  97. fn: function () {
  98. var self = this;
  99. return self.length;
  100. return self;
  101. }
  102. }),
  103. smalltalk.BlockClosure);
  104. smalltalk.addMethod(
  105. "_on_do_",
  106. smalltalk.method({
  107. selector: "on:do:",
  108. fn: function (anErrorClass, aBlock) {
  109. var self = this;
  110. var $2, $1;
  111. $1 = smalltalk.send(self, "_try_catch_", [self, function (error) {$2 = smalltalk.send(error, "_isKindOf_", [anErrorClass]);if (smalltalk.assert($2)) {return smalltalk.send(aBlock, "_value_", [error]);} else {return smalltalk.send(error, "_signal", []);}}]);
  112. return $1;
  113. }
  114. }),
  115. smalltalk.BlockClosure);
  116. smalltalk.addMethod(
  117. "_timeToRun",
  118. smalltalk.method({
  119. selector: "timeToRun",
  120. fn: function () {
  121. var self = this;
  122. var $1;
  123. $1 = smalltalk.send(smalltalk.Date || Date, "_millisecondsToRun_", [self]);
  124. return $1;
  125. }
  126. }),
  127. smalltalk.BlockClosure);
  128. smalltalk.addMethod(
  129. "_value",
  130. smalltalk.method({
  131. selector: "value",
  132. fn: function () {
  133. var self = this;
  134. return self();
  135. return self;
  136. }
  137. }),
  138. smalltalk.BlockClosure);
  139. smalltalk.addMethod(
  140. "_value_",
  141. smalltalk.method({
  142. selector: "value:",
  143. fn: function (anArg) {
  144. var self = this;
  145. return self(anArg);
  146. return self;
  147. }
  148. }),
  149. smalltalk.BlockClosure);
  150. smalltalk.addMethod(
  151. "_value_value_",
  152. smalltalk.method({
  153. selector: "value:value:",
  154. fn: function (firstArg, secondArg) {
  155. var self = this;
  156. return self(firstArg, secondArg);
  157. return self;
  158. }
  159. }),
  160. smalltalk.BlockClosure);
  161. smalltalk.addMethod(
  162. "_value_value_value_",
  163. smalltalk.method({
  164. selector: "value:value:value:",
  165. fn: function (firstArg, secondArg, thirdArg) {
  166. var self = this;
  167. return self(firstArg, secondArg, thirdArg);
  168. return self;
  169. }
  170. }),
  171. smalltalk.BlockClosure);
  172. smalltalk.addMethod(
  173. "_valueWithInterval_",
  174. smalltalk.method({
  175. selector: "valueWithInterval:",
  176. fn: function (aNumber) {
  177. var self = this;
  178. return setInterval(self, aNumber);
  179. return self;
  180. }
  181. }),
  182. smalltalk.BlockClosure);
  183. smalltalk.addMethod(
  184. "_valueWithPossibleArguments_",
  185. smalltalk.method({
  186. selector: "valueWithPossibleArguments:",
  187. fn: function (aCollection) {
  188. var self = this;
  189. return self.apply(null, aCollection);
  190. return self;
  191. }
  192. }),
  193. smalltalk.BlockClosure);
  194. smalltalk.addMethod(
  195. "_valueWithTimeout_",
  196. smalltalk.method({
  197. selector: "valueWithTimeout:",
  198. fn: function (aNumber) {
  199. var self = this;
  200. return setTimeout(self, aNumber);
  201. return self;
  202. }
  203. }),
  204. smalltalk.BlockClosure);
  205. smalltalk.addMethod(
  206. "_whileFalse",
  207. smalltalk.method({
  208. selector: "whileFalse",
  209. fn: function () {
  210. var self = this;
  211. smalltalk.send(self, "_whileFalse_", [function () {}]);
  212. return self;
  213. }
  214. }),
  215. smalltalk.BlockClosure);
  216. smalltalk.addMethod(
  217. "_whileFalse_",
  218. smalltalk.method({
  219. selector: "whileFalse:",
  220. fn: function (aBlock) {
  221. var self = this;
  222. while (!self()) {
  223. aBlock();
  224. }
  225. return self;
  226. }
  227. }),
  228. smalltalk.BlockClosure);
  229. smalltalk.addMethod(
  230. "_whileTrue",
  231. smalltalk.method({
  232. selector: "whileTrue",
  233. fn: function () {
  234. var self = this;
  235. smalltalk.send(self, "_whileTrue_", [function () {}]);
  236. return self;
  237. }
  238. }),
  239. smalltalk.BlockClosure);
  240. smalltalk.addMethod(
  241. "_whileTrue_",
  242. smalltalk.method({
  243. selector: "whileTrue:",
  244. fn: function (aBlock) {
  245. var self = this;
  246. while (self()) {
  247. aBlock();
  248. }
  249. return self;
  250. }
  251. }),
  252. smalltalk.BlockClosure);
  253. smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
  254. smalltalk.addMethod(
  255. "_arguments",
  256. smalltalk.method({
  257. selector: "arguments",
  258. fn: function () {
  259. var self = this;
  260. return self.args || [];
  261. return self;
  262. }
  263. }),
  264. smalltalk.CompiledMethod);
  265. smalltalk.addMethod(
  266. "_category",
  267. smalltalk.method({
  268. selector: "category",
  269. fn: function () {
  270. var self = this;
  271. var $2, $1;
  272. $2 = smalltalk.send(self, "_basicAt_", ["category"]);
  273. if (($receiver = $2) == nil || $receiver == undefined) {
  274. $1 = "";
  275. } else {
  276. $1 = $2;
  277. }
  278. return $1;
  279. }
  280. }),
  281. smalltalk.CompiledMethod);
  282. smalltalk.addMethod(
  283. "_category_",
  284. smalltalk.method({
  285. selector: "category:",
  286. fn: function (aString){
  287. var self=this;
  288. var $1;
  289. var oldCategory;
  290. oldCategory=smalltalk.send(self,"_category",[]);
  291. smalltalk.send(self,"_basicAt_put_",["category",aString]);
  292. $1=smalltalk.send(self,"_methodClass",[]);
  293. if(($receiver = $1) == nil || $receiver == undefined){
  294. $1;
  295. } else {
  296. smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_addElement_",[aString]);
  297. smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_methods",[]),"_select_",[(function(each){
  298. return smalltalk.send(smalltalk.send(each,"_category",[]),"__eq",[oldCategory]);
  299. })]),"_ifEmpty_",[(function(){
  300. return smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_removeElement_",[oldCategory]);
  301. })]);
  302. };
  303. return self}
  304. }),
  305. smalltalk.CompiledMethod);
  306. smalltalk.addMethod(
  307. "_fn",
  308. smalltalk.method({
  309. selector: "fn",
  310. fn: function () {
  311. var self = this;
  312. var $1;
  313. $1 = smalltalk.send(self, "_basicAt_", ["fn"]);
  314. return $1;
  315. }
  316. }),
  317. smalltalk.CompiledMethod);
  318. smalltalk.addMethod(
  319. "_fn_",
  320. smalltalk.method({
  321. selector: "fn:",
  322. fn: function (aBlock) {
  323. var self = this;
  324. smalltalk.send(self, "_basicAt_put_", ["fn", aBlock]);
  325. return self;
  326. }
  327. }),
  328. smalltalk.CompiledMethod);
  329. smalltalk.addMethod(
  330. "_messageSends",
  331. smalltalk.method({
  332. selector: "messageSends",
  333. fn: function () {
  334. var self = this;
  335. var $1;
  336. $1 = smalltalk.send(self, "_basicAt_", ["messageSends"]);
  337. return $1;
  338. }
  339. }),
  340. smalltalk.CompiledMethod);
  341. smalltalk.addMethod(
  342. "_methodClass",
  343. smalltalk.method({
  344. selector: "methodClass",
  345. fn: function () {
  346. var self = this;
  347. var $1;
  348. $1 = smalltalk.send(self, "_basicAt_", ["methodClass"]);
  349. return $1;
  350. }
  351. }),
  352. smalltalk.CompiledMethod);
  353. smalltalk.addMethod(
  354. "_protocol",
  355. smalltalk.method({
  356. selector: "protocol",
  357. fn: function () {
  358. var self = this;
  359. var $1;
  360. $1 = smalltalk.send(self, "_category", []);
  361. return $1;
  362. }
  363. }),
  364. smalltalk.CompiledMethod);
  365. smalltalk.addMethod(
  366. "_referencedClasses",
  367. smalltalk.method({
  368. selector: "referencedClasses",
  369. fn: function () {
  370. var self = this;
  371. var $1;
  372. $1 = smalltalk.send(self, "_basicAt_", ["referencedClasses"]);
  373. return $1;
  374. }
  375. }),
  376. smalltalk.CompiledMethod);
  377. smalltalk.addMethod(
  378. "_selector",
  379. smalltalk.method({
  380. selector: "selector",
  381. fn: function () {
  382. var self = this;
  383. var $1;
  384. $1 = smalltalk.send(self, "_basicAt_", ["selector"]);
  385. return $1;
  386. }
  387. }),
  388. smalltalk.CompiledMethod);
  389. smalltalk.addMethod(
  390. "_selector_",
  391. smalltalk.method({
  392. selector: "selector:",
  393. fn: function (aString) {
  394. var self = this;
  395. smalltalk.send(self, "_basicAt_put_", ["selector", aString]);
  396. return self;
  397. }
  398. }),
  399. smalltalk.CompiledMethod);
  400. smalltalk.addMethod(
  401. "_source",
  402. smalltalk.method({
  403. selector: "source",
  404. fn: function () {
  405. var self = this;
  406. var $2, $1;
  407. $2 = smalltalk.send(self, "_basicAt_", ["source"]);
  408. if (($receiver = $2) == nil || $receiver == undefined) {
  409. $1 = "";
  410. } else {
  411. $1 = $2;
  412. }
  413. return $1;
  414. }
  415. }),
  416. smalltalk.CompiledMethod);
  417. smalltalk.addMethod(
  418. "_source_",
  419. smalltalk.method({
  420. selector: "source:",
  421. fn: function (aString) {
  422. var self = this;
  423. smalltalk.send(self, "_basicAt_put_", ["source", aString]);
  424. return self;
  425. }
  426. }),
  427. smalltalk.CompiledMethod);
  428. smalltalk.addClass('ForkPool', smalltalk.Object, ['poolSize', 'maxPoolSize', 'queue', 'worker'], 'Kernel-Methods');
  429. smalltalk.addMethod(
  430. "_addWorker",
  431. smalltalk.method({
  432. selector: "addWorker",
  433. fn: function (){
  434. var self=this;
  435. smalltalk.send(self["@worker"],"_valueWithTimeout_",[(0)]);
  436. self["@poolSize"]=smalltalk.send(self["@poolSize"],"__plus",[(1)]);
  437. return self}
  438. }),
  439. smalltalk.ForkPool);
  440. smalltalk.addMethod(
  441. "_fork_",
  442. smalltalk.method({
  443. selector: "fork:",
  444. fn: function (aBlock){
  445. var self=this;
  446. var $1;
  447. $1=smalltalk.send(self["@poolSize"],"__lt",[self["@maxPoolSize"]]);
  448. if(smalltalk.assert($1)){
  449. smalltalk.send(self,"_addWorker",[]);
  450. };
  451. smalltalk.send(self["@queue"],"_back_",[aBlock]);
  452. return self}
  453. }),
  454. smalltalk.ForkPool);
  455. smalltalk.addMethod(
  456. "_initialize",
  457. smalltalk.method({
  458. selector: "initialize",
  459. fn: function (){
  460. var self=this;
  461. var $early={};
  462. try {
  463. self["@poolSize"]=(0);
  464. self["@maxPoolSize"]=smalltalk.send(smalltalk.send(self,"_class",[]),"_defaultMaxPoolSize",[]);
  465. self["@queue"]=smalltalk.send((smalltalk.Queue || Queue),"_new",[]);
  466. self["@worker"]=(function(){
  467. var block;
  468. self["@poolSize"]=smalltalk.send(self["@poolSize"],"__minus",[(1)]);
  469. self["@poolSize"];
  470. block=smalltalk.send(self["@queue"],"_frontIfAbsent_",[(function(){
  471. throw $early=[nil];
  472. })]);
  473. block;
  474. return smalltalk.send((function(){
  475. return smalltalk.send(block,"_value",[]);
  476. }),"_ensure_",[(function(){
  477. return smalltalk.send(self,"_addWorker",[]);
  478. })]);
  479. });
  480. return self}
  481. catch(e) {if(e===$early)return e[0]; throw e}
  482. }
  483. }),
  484. smalltalk.ForkPool);
  485. smalltalk.ForkPool.klass.iVarNames = ['default'];
  486. smalltalk.addMethod(
  487. "_default",
  488. smalltalk.method({
  489. selector: "default",
  490. fn: function (){
  491. var self=this;
  492. var $1;
  493. if(($receiver = self["@default"]) == nil || $receiver == undefined){
  494. self["@default"]=smalltalk.send(self,"_new",[]);
  495. $1=self["@default"];
  496. } else {
  497. $1=self["@default"];
  498. };
  499. return $1;
  500. }
  501. }),
  502. smalltalk.ForkPool.klass);
  503. smalltalk.addMethod(
  504. "_defaultMaxPoolSize",
  505. smalltalk.method({
  506. selector: "defaultMaxPoolSize",
  507. fn: function (){
  508. var self=this;
  509. return (100);
  510. }
  511. }),
  512. smalltalk.ForkPool.klass);
  513. smalltalk.addClass('Message', smalltalk.Object, ['selector', 'arguments'], 'Kernel-Methods');
  514. smalltalk.addMethod(
  515. "_arguments",
  516. smalltalk.method({
  517. selector: "arguments",
  518. fn: function () {
  519. var self = this;
  520. return self['@arguments'];
  521. }
  522. }),
  523. smalltalk.Message);
  524. smalltalk.addMethod(
  525. "_arguments_",
  526. smalltalk.method({
  527. selector: "arguments:",
  528. fn: function (anArray) {
  529. var self = this;
  530. self['@arguments'] = anArray;
  531. return self;
  532. }
  533. }),
  534. smalltalk.Message);
  535. smalltalk.addMethod(
  536. "_printString",
  537. smalltalk.method({
  538. selector: "printString",
  539. fn: function () {
  540. var self = this;
  541. var $2, $1;
  542. $1 = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (aStream) {smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(self, "_printString", [], smalltalk.Object)]);smalltalk.send(aStream, "_nextPutAll_", ["("]);smalltalk.send(aStream, "_nextPutAll_", [self['@selector']]);$2 = smalltalk.send(aStream, "_nextPutAll_", [")"]);return $2;}]);
  543. return $1;
  544. }
  545. }),
  546. smalltalk.Message);
  547. smalltalk.addMethod(
  548. "_selector",
  549. smalltalk.method({
  550. selector: "selector",
  551. fn: function () {
  552. var self = this;
  553. return self['@selector'];
  554. }
  555. }),
  556. smalltalk.Message);
  557. smalltalk.addMethod(
  558. "_selector_",
  559. smalltalk.method({
  560. selector: "selector:",
  561. fn: function (aString) {
  562. var self = this;
  563. self['@selector'] = aString;
  564. return self;
  565. }
  566. }),
  567. smalltalk.Message);
  568. smalltalk.addMethod(
  569. "_sendTo_",
  570. smalltalk.method({
  571. selector: "sendTo:",
  572. fn: function (anObject) {
  573. var self = this;
  574. var $1;
  575. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_send_to_arguments_", [smalltalk.send(self, "_selector", []), anObject, smalltalk.send(self, "_arguments", [])]);
  576. return $1;
  577. }
  578. }),
  579. smalltalk.Message);
  580. smalltalk.addMethod(
  581. "_selector_arguments_",
  582. smalltalk.method({
  583. selector: "selector:arguments:",
  584. fn: function (aString, anArray) {
  585. var self = this;
  586. var $2, $3, $1;
  587. $2 = smalltalk.send(self, "_new", []);
  588. smalltalk.send($2, "_selector_", [aString]);
  589. smalltalk.send($2, "_arguments_", [anArray]);
  590. $3 = smalltalk.send($2, "_yourself", []);
  591. $1 = $3;
  592. return $1;
  593. }
  594. }),
  595. smalltalk.Message.klass);
  596. smalltalk.addClass('MethodContext', smalltalk.Object, [], 'Kernel-Methods');
  597. smalltalk.addMethod(
  598. "_asString",
  599. smalltalk.method({
  600. selector: "asString",
  601. fn: function () {
  602. var self = this;
  603. var $1;
  604. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_receiver", []), "_class", []), "_printString", []), "__comma", [" >> "]), "__comma", [smalltalk.send(self, "_selector", [])]);
  605. return $1;
  606. }
  607. }),
  608. smalltalk.MethodContext);
  609. smalltalk.addMethod(
  610. "_home",
  611. smalltalk.method({
  612. selector: "home",
  613. fn: function () {
  614. var self = this;
  615. return self.homeContext;
  616. return self;
  617. }
  618. }),
  619. smalltalk.MethodContext);
  620. smalltalk.addMethod(
  621. "_pc",
  622. smalltalk.method({
  623. selector: "pc",
  624. fn: function () {
  625. var self = this;
  626. return self.pc;
  627. return self;
  628. }
  629. }),
  630. smalltalk.MethodContext);
  631. smalltalk.addMethod(
  632. "_printString",
  633. smalltalk.method({
  634. selector: "printString",
  635. fn: function () {
  636. var self = this;
  637. var $1;
  638. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_printString", [], smalltalk.Object), "__comma", ["("]), "__comma", [smalltalk.send(self, "_asString", [])]), "__comma", [")"]);
  639. return $1;
  640. }
  641. }),
  642. smalltalk.MethodContext);
  643. smalltalk.addMethod(
  644. "_receiver",
  645. smalltalk.method({
  646. selector: "receiver",
  647. fn: function () {
  648. var self = this;
  649. return self.receiver;
  650. return self;
  651. }
  652. }),
  653. smalltalk.MethodContext);
  654. smalltalk.addMethod(
  655. "_selector",
  656. smalltalk.method({
  657. selector: "selector",
  658. fn: function () {
  659. var self = this;
  660. return smalltalk.convertSelector(self.selector);
  661. return self;
  662. }
  663. }),
  664. smalltalk.MethodContext);
  665. smalltalk.addMethod(
  666. "_temps",
  667. smalltalk.method({
  668. selector: "temps",
  669. fn: function () {
  670. var self = this;
  671. return self.temps;
  672. return self;
  673. }
  674. }),
  675. smalltalk.MethodContext);