1
0

Kernel-Methods.deploy.js 15 KB

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