Kernel-Methods.deploy.js 15 KB

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