Kernel-Methods.deploy.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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 $1;
  462. var sentinel;
  463. self["@poolSize"]=(0);
  464. self["@maxPoolSize"]=smalltalk.send(smalltalk.send(self,"_class",[]),"_defaultMaxPoolSize",[]);
  465. self["@queue"]=smalltalk.send((smalltalk.Queue || Queue),"_new",[]);
  466. sentinel=smalltalk.send((smalltalk.Object || Object),"_new",[]);
  467. self["@worker"]=(function(){
  468. var block;
  469. self["@poolSize"]=smalltalk.send(self["@poolSize"],"__minus",[(1)]);
  470. self["@poolSize"];
  471. block=smalltalk.send(self["@queue"],"_frontIfAbsent_",[(function(){
  472. return sentinel;
  473. })]);
  474. block;
  475. $1=smalltalk.send(block,"__eq_eq",[sentinel]);
  476. if(! smalltalk.assert($1)){
  477. return smalltalk.send((function(){
  478. return smalltalk.send(block,"_value",[]);
  479. }),"_ensure_",[(function(){
  480. return smalltalk.send(self,"_addWorker",[]);
  481. })]);
  482. };
  483. });
  484. return self}
  485. }),
  486. smalltalk.ForkPool);
  487. smalltalk.ForkPool.klass.iVarNames = ['default'];
  488. smalltalk.addMethod(
  489. "_default",
  490. smalltalk.method({
  491. selector: "default",
  492. fn: function (){
  493. var self=this;
  494. var $1;
  495. if(($receiver = self["@default"]) == nil || $receiver == undefined){
  496. self["@default"]=smalltalk.send(self,"_new",[]);
  497. $1=self["@default"];
  498. } else {
  499. $1=self["@default"];
  500. };
  501. return $1;
  502. }
  503. }),
  504. smalltalk.ForkPool.klass);
  505. smalltalk.addMethod(
  506. "_defaultMaxPoolSize",
  507. smalltalk.method({
  508. selector: "defaultMaxPoolSize",
  509. fn: function (){
  510. var self=this;
  511. return (100);
  512. }
  513. }),
  514. smalltalk.ForkPool.klass);
  515. smalltalk.addMethod(
  516. "_resetDefault",
  517. smalltalk.method({
  518. selector: "resetDefault",
  519. fn: function (){
  520. var self=this;
  521. self["@default"]=nil;
  522. return self}
  523. }),
  524. smalltalk.ForkPool.klass);
  525. smalltalk.addClass('Message', smalltalk.Object, ['selector', 'arguments'], 'Kernel-Methods');
  526. smalltalk.addMethod(
  527. "_arguments",
  528. smalltalk.method({
  529. selector: "arguments",
  530. fn: function () {
  531. var self = this;
  532. return self['@arguments'];
  533. }
  534. }),
  535. smalltalk.Message);
  536. smalltalk.addMethod(
  537. "_arguments_",
  538. smalltalk.method({
  539. selector: "arguments:",
  540. fn: function (anArray) {
  541. var self = this;
  542. self['@arguments'] = anArray;
  543. return self;
  544. }
  545. }),
  546. smalltalk.Message);
  547. smalltalk.addMethod(
  548. "_printString",
  549. smalltalk.method({
  550. selector: "printString",
  551. fn: function () {
  552. var self = this;
  553. var $2, $1;
  554. $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;}]);
  555. return $1;
  556. }
  557. }),
  558. smalltalk.Message);
  559. smalltalk.addMethod(
  560. "_selector",
  561. smalltalk.method({
  562. selector: "selector",
  563. fn: function () {
  564. var self = this;
  565. return self['@selector'];
  566. }
  567. }),
  568. smalltalk.Message);
  569. smalltalk.addMethod(
  570. "_selector_",
  571. smalltalk.method({
  572. selector: "selector:",
  573. fn: function (aString) {
  574. var self = this;
  575. self['@selector'] = aString;
  576. return self;
  577. }
  578. }),
  579. smalltalk.Message);
  580. smalltalk.addMethod(
  581. "_sendTo_",
  582. smalltalk.method({
  583. selector: "sendTo:",
  584. fn: function (anObject) {
  585. var self = this;
  586. var $1;
  587. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_send_to_arguments_", [smalltalk.send(self, "_selector", []), anObject, smalltalk.send(self, "_arguments", [])]);
  588. return $1;
  589. }
  590. }),
  591. smalltalk.Message);
  592. smalltalk.addMethod(
  593. "_selector_arguments_",
  594. smalltalk.method({
  595. selector: "selector:arguments:",
  596. fn: function (aString, anArray) {
  597. var self = this;
  598. var $2, $3, $1;
  599. $2 = smalltalk.send(self, "_new", []);
  600. smalltalk.send($2, "_selector_", [aString]);
  601. smalltalk.send($2, "_arguments_", [anArray]);
  602. $3 = smalltalk.send($2, "_yourself", []);
  603. $1 = $3;
  604. return $1;
  605. }
  606. }),
  607. smalltalk.Message.klass);
  608. smalltalk.addClass('MethodContext', smalltalk.Object, [], 'Kernel-Methods');
  609. smalltalk.addMethod(
  610. "_asString",
  611. smalltalk.method({
  612. selector: "asString",
  613. fn: function () {
  614. var self = this;
  615. var $1;
  616. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_receiver", []), "_class", []), "_printString", []), "__comma", [" >> "]), "__comma", [smalltalk.send(self, "_selector", [])]);
  617. return $1;
  618. }
  619. }),
  620. smalltalk.MethodContext);
  621. smalltalk.addMethod(
  622. "_home",
  623. smalltalk.method({
  624. selector: "home",
  625. fn: function () {
  626. var self = this;
  627. return self.homeContext;
  628. return self;
  629. }
  630. }),
  631. smalltalk.MethodContext);
  632. smalltalk.addMethod(
  633. "_pc",
  634. smalltalk.method({
  635. selector: "pc",
  636. fn: function () {
  637. var self = this;
  638. return self.pc;
  639. return self;
  640. }
  641. }),
  642. smalltalk.MethodContext);
  643. smalltalk.addMethod(
  644. "_printString",
  645. smalltalk.method({
  646. selector: "printString",
  647. fn: function () {
  648. var self = this;
  649. var $1;
  650. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_printString", [], smalltalk.Object), "__comma", ["("]), "__comma", [smalltalk.send(self, "_asString", [])]), "__comma", [")"]);
  651. return $1;
  652. }
  653. }),
  654. smalltalk.MethodContext);
  655. smalltalk.addMethod(
  656. "_receiver",
  657. smalltalk.method({
  658. selector: "receiver",
  659. fn: function () {
  660. var self = this;
  661. return self.receiver;
  662. return self;
  663. }
  664. }),
  665. smalltalk.MethodContext);
  666. smalltalk.addMethod(
  667. "_selector",
  668. smalltalk.method({
  669. selector: "selector",
  670. fn: function () {
  671. var self = this;
  672. return smalltalk.convertSelector(self.selector);
  673. return self;
  674. }
  675. }),
  676. smalltalk.MethodContext);
  677. smalltalk.addMethod(
  678. "_temps",
  679. smalltalk.method({
  680. selector: "temps",
  681. fn: function () {
  682. var self = this;
  683. return self.temps;
  684. return self;
  685. }
  686. }),
  687. smalltalk.MethodContext);