Lyst.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. define(["amber/boot", "amber_core/Kernel-Collections", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  4. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  5. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  6. $core.addPackage("Lyst");
  7. $core.packages["Lyst"].innerEval = function (expr) { return eval(expr); };
  8. $core.packages["Lyst"].transport = {"type":"amd","amdNamespace":"lyst"};
  9. $core.addClass("Lyst", $globals.Object, [], "Lyst");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "parse:",
  13. protocol: "parsing",
  14. fn: function (message){
  15. var self=this,$self=this;
  16. var result,stack,anArray;
  17. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  18. return $core.withContext(function($ctx1) {
  19. //>>excludeEnd("ctx");
  20. var $1,$2,$3,$5,$4,$6,$7,$8,$9,$10,$11;
  21. anArray=$recv(message)._tokenize_(" ");
  22. result=[];
  23. stack=[result];
  24. $recv(anArray)._do_((function(each){
  25. var asNum,inner,close;
  26. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  27. return $core.withContext(function($ctx2) {
  28. //>>excludeEnd("ctx");
  29. close=(0);
  30. close;
  31. inner=each;
  32. inner;
  33. $recv((function(){
  34. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  35. return $core.withContext(function($ctx3) {
  36. //>>excludeEnd("ctx");
  37. $1=$recv(inner)._notEmpty();
  38. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  39. $ctx3.sendIdx["notEmpty"]=1;
  40. //>>excludeEnd("ctx");
  41. return $recv($1)._and_((function(){
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. return $core.withContext(function($ctx4) {
  44. //>>excludeEnd("ctx");
  45. $2=$recv(inner)._first();
  46. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  47. $ctx4.sendIdx["first"]=1;
  48. //>>excludeEnd("ctx");
  49. return $recv($2).__eq("(");
  50. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  51. $ctx4.sendIdx["="]=1;
  52. //>>excludeEnd("ctx");
  53. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  54. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
  55. //>>excludeEnd("ctx");
  56. }));
  57. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  58. $ctx3.sendIdx["and:"]=1;
  59. //>>excludeEnd("ctx");
  60. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  61. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  62. //>>excludeEnd("ctx");
  63. }))._whileTrue_((function(){
  64. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  65. return $core.withContext(function($ctx3) {
  66. //>>excludeEnd("ctx");
  67. inner=$recv(inner)._allButFirst();
  68. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  69. $ctx3.sendIdx["allButFirst"]=1;
  70. //>>excludeEnd("ctx");
  71. inner;
  72. $3=stack;
  73. $5=$recv(stack)._last();
  74. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  75. $ctx3.sendIdx["last"]=1;
  76. //>>excludeEnd("ctx");
  77. $4=$recv($5)._add_([]);
  78. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  79. $ctx3.sendIdx["add:"]=2;
  80. //>>excludeEnd("ctx");
  81. return $recv($3)._add_($4);
  82. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  83. $ctx3.sendIdx["add:"]=1;
  84. //>>excludeEnd("ctx");
  85. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  86. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)});
  87. //>>excludeEnd("ctx");
  88. }));
  89. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  90. $ctx2.sendIdx["whileTrue:"]=1;
  91. //>>excludeEnd("ctx");
  92. $recv((function(){
  93. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  94. return $core.withContext(function($ctx3) {
  95. //>>excludeEnd("ctx");
  96. $6=$recv(inner)._notEmpty();
  97. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  98. $ctx3.sendIdx["notEmpty"]=2;
  99. //>>excludeEnd("ctx");
  100. return $recv($6)._and_((function(){
  101. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  102. return $core.withContext(function($ctx4) {
  103. //>>excludeEnd("ctx");
  104. $7=$recv(inner)._last();
  105. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  106. $ctx4.sendIdx["last"]=2;
  107. //>>excludeEnd("ctx");
  108. return $recv($7).__eq(")");
  109. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  110. $ctx4.sendIdx["="]=2;
  111. //>>excludeEnd("ctx");
  112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  113. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
  114. //>>excludeEnd("ctx");
  115. }));
  116. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  117. $ctx3.sendIdx["and:"]=2;
  118. //>>excludeEnd("ctx");
  119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  120. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)});
  121. //>>excludeEnd("ctx");
  122. }))._whileTrue_((function(){
  123. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  124. return $core.withContext(function($ctx3) {
  125. //>>excludeEnd("ctx");
  126. inner=$recv(inner)._allButLast();
  127. inner;
  128. close=$recv(close).__plus((1));
  129. return close;
  130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  131. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)});
  132. //>>excludeEnd("ctx");
  133. }));
  134. $8=$recv($recv(inner)._notEmpty())._and_((function(){
  135. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  136. return $core.withContext(function($ctx3) {
  137. //>>excludeEnd("ctx");
  138. return $recv($recv(inner)._first()).__eq("~");
  139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  140. $ctx3.sendIdx["="]=3;
  141. //>>excludeEnd("ctx");
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,8)});
  144. //>>excludeEnd("ctx");
  145. }));
  146. if($core.assert($8)){
  147. inner=[$recv(inner)._allButFirst()];
  148. inner;
  149. }
  150. $9=$recv(inner)._isString();
  151. if($core.assert($9)){
  152. asNum=$recv($recv(inner)._ifEmpty_((function(){
  153. return "NaN";
  154. })))._asNumber();
  155. } else {
  156. asNum=inner;
  157. }
  158. asNum;
  159. $10=$recv(asNum).__eq(asNum);
  160. if($core.assert($10)){
  161. $11=$recv(stack)._last();
  162. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  163. $ctx2.sendIdx["last"]=3;
  164. //>>excludeEnd("ctx");
  165. $recv($11)._add_(asNum);
  166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  167. $ctx2.sendIdx["add:"]=3;
  168. //>>excludeEnd("ctx");
  169. } else {
  170. $recv(inner)._ifNotEmpty_((function(){
  171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  172. return $core.withContext(function($ctx3) {
  173. //>>excludeEnd("ctx");
  174. return $recv($recv(stack)._last())._add_(inner);
  175. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  176. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,15)});
  177. //>>excludeEnd("ctx");
  178. }));
  179. }
  180. return $recv(close)._timesRepeat_((function(){
  181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  182. return $core.withContext(function($ctx3) {
  183. //>>excludeEnd("ctx");
  184. return $recv(stack)._removeLast();
  185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  186. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,16)});
  187. //>>excludeEnd("ctx");
  188. }));
  189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  190. }, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum,inner:inner,close:close},$ctx1,1)});
  191. //>>excludeEnd("ctx");
  192. }));
  193. return result;
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. }, function($ctx1) {$ctx1.fill(self,"parse:",{message:message,result:result,stack:stack,anArray:anArray},$globals.Lyst.a$cls)});
  196. //>>excludeEnd("ctx");
  197. },
  198. //>>excludeStart("ide", pragmas.excludeIdeData);
  199. args: ["message"],
  200. source: "parse: message\x0a\x09| result stack anArray |\x0a\x09anArray := message tokenize: ' '.\x0a\x09result := #().\x0a\x09stack := { result }.\x0a\x09anArray do: [ :each |\x0a\x09\x09| asNum inner close |\x0a\x09\x09close := 0.\x0a\x09\x09inner := each.\x0a\x09\x09[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].\x0a\x09\x09[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].\x0a\x09\x09(inner notEmpty and: [ inner first = '~' ]) ifTrue: [ inner := { inner allButFirst } ].\x0a\x09\x09asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].\x0a\x09\x09asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [\x0a\x09\x09\x09inner ifNotEmpty: [ stack last add: inner ] ].\x0a\x09\x09close timesRepeat: [ stack removeLast ] ].\x0a\x09^ result",
  201. referencedClasses: [],
  202. //>>excludeEnd("ide");
  203. messageSends: ["tokenize:", "do:", "whileTrue:", "and:", "notEmpty", "=", "first", "allButFirst", "add:", "last", "allButLast", "+", "ifTrue:", "ifTrue:ifFalse:", "isString", "asNumber", "ifEmpty:", "ifNotEmpty:", "timesRepeat:", "removeLast"]
  204. }),
  205. $globals.Lyst.a$cls);
  206. $core.addMethod(
  207. $core.method({
  208. selector: "atYndexIn:ifAbsent:",
  209. protocol: "*Lyst",
  210. fn: function (anObject,aBlock){
  211. var self=this,$self=this;
  212. var receiver,selector,result;
  213. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  214. return $core.withContext(function($ctx1) {
  215. //>>excludeEnd("ctx");
  216. var $5,$4,$3,$2,$1;
  217. var $early={};
  218. try {
  219. selector=$self._first();
  220. receiver=$recv(anObject)._yourself();
  221. $recv((function(){
  222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  223. return $core.withContext(function($ctx2) {
  224. //>>excludeEnd("ctx");
  225. result=$recv(receiver)._perform_(selector);
  226. return result;
  227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  228. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  229. //>>excludeEnd("ctx");
  230. }))._on_do_($globals.MessageNotUnderstood,(function(mnu){
  231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  232. return $core.withContext(function($ctx2) {
  233. //>>excludeEnd("ctx");
  234. $5=$recv(mnu)._message();
  235. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  236. $ctx2.sendIdx["message"]=1;
  237. //>>excludeEnd("ctx");
  238. $4=$recv($5)._selector();
  239. $3=$recv($4).__eq(selector);
  240. $2=$recv($3)._and_((function(){
  241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  242. return $core.withContext(function($ctx3) {
  243. //>>excludeEnd("ctx");
  244. return $recv($recv(mnu)._receiver()).__eq_eq(receiver);
  245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  246. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  247. //>>excludeEnd("ctx");
  248. }));
  249. $1=$recv($2)._and_((function(){
  250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  251. return $core.withContext(function($ctx3) {
  252. //>>excludeEnd("ctx");
  253. return $recv($recv($recv(mnu)._message())._arguments())._isEmpty();
  254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  255. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)});
  256. //>>excludeEnd("ctx");
  257. }));
  258. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  259. $ctx2.sendIdx["and:"]=1;
  260. //>>excludeEnd("ctx");
  261. if(!$core.assert($1)){
  262. $recv(mnu)._resignal();
  263. }
  264. throw $early=[$recv(aBlock)._value()];
  265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  266. }, function($ctx2) {$ctx2.fillBlock({mnu:mnu},$ctx1,2)});
  267. //>>excludeEnd("ctx");
  268. }));
  269. return result;
  270. }
  271. catch(e) {if(e===$early)return e[0]; throw e}
  272. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  273. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock,receiver:receiver,selector:selector,result:result},$globals.Array)});
  274. //>>excludeEnd("ctx");
  275. },
  276. //>>excludeStart("ide", pragmas.excludeIdeData);
  277. args: ["anObject", "aBlock"],
  278. source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09| receiver selector result |\x0a\x09selector := self first.\x0a\x09receiver := anObject yourself. \x22JSObjectProxy hack\x22\x0a\x09\x0a\x09[ result := receiver perform: selector ]\x0a\x09on: MessageNotUnderstood do: [ :mnu |\x0a\x09\x09((mnu message selector = selector\x0a\x09\x09\x09and: [ mnu receiver == receiver ])\x0a\x09\x09\x09and: [ mnu message arguments isEmpty ])\x0a\x09\x09\x09ifFalse: [ mnu resignal ].\x0a\x09\x09^ aBlock value ].\x0a\x09^ result",
  279. referencedClasses: ["MessageNotUnderstood"],
  280. //>>excludeEnd("ide");
  281. messageSends: ["first", "yourself", "on:do:", "perform:", "ifFalse:", "and:", "=", "selector", "message", "==", "receiver", "isEmpty", "arguments", "resignal", "value"]
  282. }),
  283. $globals.Array);
  284. $core.addMethod(
  285. $core.method({
  286. selector: "atYndexIn:ifAbsent:put:",
  287. protocol: "*Lyst",
  288. fn: function (anObject,aBlock,anotherObject){
  289. var self=this,$self=this;
  290. var receiver,selector,arguments_,result;
  291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  292. return $core.withContext(function($ctx1) {
  293. //>>excludeEnd("ctx");
  294. var $5,$4,$3,$2,$1;
  295. var $early={};
  296. try {
  297. selector=$recv($self._first())._asMutator();
  298. receiver=$recv(anObject)._yourself();
  299. arguments_=[anotherObject];
  300. $recv((function(){
  301. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  302. return $core.withContext(function($ctx2) {
  303. //>>excludeEnd("ctx");
  304. result=$recv(receiver)._perform_withArguments_(selector,arguments_);
  305. return result;
  306. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  307. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  308. //>>excludeEnd("ctx");
  309. }))._on_do_($globals.MessageNotUnderstood,(function(mnu){
  310. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  311. return $core.withContext(function($ctx2) {
  312. //>>excludeEnd("ctx");
  313. $5=$recv(mnu)._message();
  314. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  315. $ctx2.sendIdx["message"]=1;
  316. //>>excludeEnd("ctx");
  317. $4=$recv($5)._selector();
  318. $3=$recv($4).__eq(selector);
  319. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  320. $ctx2.sendIdx["="]=1;
  321. //>>excludeEnd("ctx");
  322. $2=$recv($3)._and_((function(){
  323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  324. return $core.withContext(function($ctx3) {
  325. //>>excludeEnd("ctx");
  326. return $recv($recv(mnu)._receiver()).__eq_eq(receiver);
  327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  328. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  329. //>>excludeEnd("ctx");
  330. }));
  331. $1=$recv($2)._and_((function(){
  332. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  333. return $core.withContext(function($ctx3) {
  334. //>>excludeEnd("ctx");
  335. return $recv($recv($recv(mnu)._message())._arguments()).__eq(arguments_);
  336. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  337. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)});
  338. //>>excludeEnd("ctx");
  339. }));
  340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  341. $ctx2.sendIdx["and:"]=1;
  342. //>>excludeEnd("ctx");
  343. if(!$core.assert($1)){
  344. $recv(mnu)._resignal();
  345. }
  346. throw $early=[$recv(aBlock)._value()];
  347. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  348. }, function($ctx2) {$ctx2.fillBlock({mnu:mnu},$ctx1,2)});
  349. //>>excludeEnd("ctx");
  350. }));
  351. return result;
  352. }
  353. catch(e) {if(e===$early)return e[0]; throw e}
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject,receiver:receiver,selector:selector,arguments_:arguments_,result:result},$globals.Array)});
  356. //>>excludeEnd("ctx");
  357. },
  358. //>>excludeStart("ide", pragmas.excludeIdeData);
  359. args: ["anObject", "aBlock", "anotherObject"],
  360. source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09| receiver selector arguments result |\x0a\x09selector := self first asMutator.\x0a\x09receiver := anObject yourself. \x22JSObjectProxy hack\x22\x0a\x09arguments := { anotherObject }.\x0a\x09\x0a\x09[ result := receiver perform: selector withArguments: arguments ]\x0a\x09on: MessageNotUnderstood do: [ :mnu |\x0a\x09\x09((mnu message selector = selector\x0a\x09\x09\x09and: [ mnu receiver == receiver ])\x0a\x09\x09\x09and: [ mnu message arguments = arguments ])\x0a\x09\x09\x09ifFalse: [ mnu resignal ].\x0a\x09\x09^ aBlock value ].\x0a\x09^ result",
  361. referencedClasses: ["MessageNotUnderstood"],
  362. //>>excludeEnd("ide");
  363. messageSends: ["asMutator", "first", "yourself", "on:do:", "perform:withArguments:", "ifFalse:", "and:", "=", "selector", "message", "==", "receiver", "arguments", "resignal", "value"]
  364. }),
  365. $globals.Array);
  366. $core.addMethod(
  367. $core.method({
  368. selector: "atYndexIn:ifAbsent:",
  369. protocol: "*Lyst",
  370. fn: function (anObject,aBlock){
  371. var self=this,$self=this;
  372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  373. return $core.withContext(function($ctx1) {
  374. //>>excludeEnd("ctx");
  375. var $1;
  376. var $early={};
  377. try {
  378. $1=$recv(anObject)._respondsTo_("at:ifAbsent:");
  379. $recv($1)._ifTrue_ifFalse_((function(){
  380. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  381. return $core.withContext(function($ctx2) {
  382. //>>excludeEnd("ctx");
  383. throw $early=[$recv(anObject)._at_ifAbsent_(self,aBlock)];
  384. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  385. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  386. //>>excludeEnd("ctx");
  387. }),aBlock);
  388. return self;
  389. }
  390. catch(e) {if(e===$early)return e[0]; throw e}
  391. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  392. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.Number)});
  393. //>>excludeEnd("ctx");
  394. },
  395. //>>excludeStart("ide", pragmas.excludeIdeData);
  396. args: ["anObject", "aBlock"],
  397. source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09(anObject respondsTo: #at:ifAbsent:)\x0a\x09\x09ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]\x0a\x09\x09ifFalse: aBlock",
  398. referencedClasses: [],
  399. //>>excludeEnd("ide");
  400. messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:ifAbsent:"]
  401. }),
  402. $globals.Number);
  403. $core.addMethod(
  404. $core.method({
  405. selector: "atYndexIn:ifAbsent:put:",
  406. protocol: "*Lyst",
  407. fn: function (anObject,aBlock,anotherObject){
  408. var self=this,$self=this;
  409. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  410. return $core.withContext(function($ctx1) {
  411. //>>excludeEnd("ctx");
  412. var $1;
  413. var $early={};
  414. try {
  415. $1=$recv(anObject)._respondsTo_("at:put:");
  416. $recv($1)._ifTrue_ifFalse_((function(){
  417. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  418. return $core.withContext(function($ctx2) {
  419. //>>excludeEnd("ctx");
  420. throw $early=[$recv(anObject)._at_put_(self,anotherObject)];
  421. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  422. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  423. //>>excludeEnd("ctx");
  424. }),aBlock);
  425. return self;
  426. }
  427. catch(e) {if(e===$early)return e[0]; throw e}
  428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  429. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.Number)});
  430. //>>excludeEnd("ctx");
  431. },
  432. //>>excludeStart("ide", pragmas.excludeIdeData);
  433. args: ["anObject", "aBlock", "anotherObject"],
  434. source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09(anObject respondsTo: #at:put:)\x0a\x09\x09ifTrue: [ ^ anObject at: self put: anotherObject ]\x0a\x09\x09ifFalse: aBlock",
  435. referencedClasses: [],
  436. //>>excludeEnd("ide");
  437. messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:put:"]
  438. }),
  439. $globals.Number);
  440. $core.addMethod(
  441. $core.method({
  442. selector: "atLyst:ifAbsent:",
  443. protocol: "*Lyst",
  444. fn: function (aCollection,aBlock){
  445. var self=this,$self=this;
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. return $core.withContext(function($ctx1) {
  448. //>>excludeEnd("ctx");
  449. var $early={};
  450. try {
  451. return $recv(aCollection)._inject_into_(self,(function(soFar,segment){
  452. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  453. return $core.withContext(function($ctx2) {
  454. //>>excludeEnd("ctx");
  455. return $recv(segment)._atYndexIn_ifAbsent_(soFar,(function(){
  456. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  457. return $core.withContext(function($ctx3) {
  458. //>>excludeEnd("ctx");
  459. throw $early=[$recv(aBlock)._value()];
  460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  461. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  462. //>>excludeEnd("ctx");
  463. }));
  464. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  465. }, function($ctx2) {$ctx2.fillBlock({soFar:soFar,segment:segment},$ctx1,1)});
  466. //>>excludeEnd("ctx");
  467. }));
  468. }
  469. catch(e) {if(e===$early)return e[0]; throw e}
  470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  471. }, function($ctx1) {$ctx1.fill(self,"atLyst:ifAbsent:",{aCollection:aCollection,aBlock:aBlock},$globals.Object)});
  472. //>>excludeEnd("ctx");
  473. },
  474. //>>excludeStart("ide", pragmas.excludeIdeData);
  475. args: ["aCollection", "aBlock"],
  476. source: "atLyst: aCollection ifAbsent: aBlock\x0a\x09^ aCollection inject: self into: [ :soFar :segment |\x0a\x09\x09segment atYndexIn: soFar ifAbsent: [ ^ aBlock value ]]",
  477. referencedClasses: [],
  478. //>>excludeEnd("ide");
  479. messageSends: ["inject:into:", "atYndexIn:ifAbsent:", "value"]
  480. }),
  481. $globals.Object);
  482. $core.addMethod(
  483. $core.method({
  484. selector: "atLyst:ifAbsent:put:",
  485. protocol: "*Lyst",
  486. fn: function (aCollection,aBlock,value){
  487. var self=this,$self=this;
  488. var penultimate;
  489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  490. return $core.withContext(function($ctx1) {
  491. //>>excludeEnd("ctx");
  492. penultimate=$self._atLyst_ifAbsent_($recv(aCollection)._allButLast(),aBlock);
  493. return $recv($recv(aCollection)._last())._atYndexIn_ifAbsent_put_(penultimate,aBlock,value);
  494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  495. }, function($ctx1) {$ctx1.fill(self,"atLyst:ifAbsent:put:",{aCollection:aCollection,aBlock:aBlock,value:value,penultimate:penultimate},$globals.Object)});
  496. //>>excludeEnd("ctx");
  497. },
  498. //>>excludeStart("ide", pragmas.excludeIdeData);
  499. args: ["aCollection", "aBlock", "value"],
  500. source: "atLyst: aCollection ifAbsent: aBlock put: value\x0a\x09| penultimate |\x0a\x09penultimate := self atLyst: aCollection allButLast ifAbsent: aBlock.\x0a\x09^ aCollection last atYndexIn: penultimate ifAbsent: aBlock put: value",
  501. referencedClasses: [],
  502. //>>excludeEnd("ide");
  503. messageSends: ["atLyst:ifAbsent:", "allButLast", "atYndexIn:ifAbsent:put:", "last"]
  504. }),
  505. $globals.Object);
  506. $core.addMethod(
  507. $core.method({
  508. selector: "atYndexIn:ifAbsent:",
  509. protocol: "*Lyst",
  510. fn: function (anObject,aBlock){
  511. var self=this,$self=this;
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. return $core.withContext(function($ctx1) {
  514. //>>excludeEnd("ctx");
  515. return $recv(aBlock)._value();
  516. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  517. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.Object)});
  518. //>>excludeEnd("ctx");
  519. },
  520. //>>excludeStart("ide", pragmas.excludeIdeData);
  521. args: ["anObject", "aBlock"],
  522. source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09^ aBlock value",
  523. referencedClasses: [],
  524. //>>excludeEnd("ide");
  525. messageSends: ["value"]
  526. }),
  527. $globals.Object);
  528. $core.addMethod(
  529. $core.method({
  530. selector: "atYndexIn:ifAbsent:put:",
  531. protocol: "*Lyst",
  532. fn: function (anObject,aBlock,anotherObject){
  533. var self=this,$self=this;
  534. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  535. return $core.withContext(function($ctx1) {
  536. //>>excludeEnd("ctx");
  537. return $recv(aBlock)._value();
  538. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  539. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.Object)});
  540. //>>excludeEnd("ctx");
  541. },
  542. //>>excludeStart("ide", pragmas.excludeIdeData);
  543. args: ["anObject", "aBlock", "anotherObject"],
  544. source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09^ aBlock value",
  545. referencedClasses: [],
  546. //>>excludeEnd("ide");
  547. messageSends: ["value"]
  548. }),
  549. $globals.Object);
  550. $core.addMethod(
  551. $core.method({
  552. selector: "atYndexIn:ifAbsent:",
  553. protocol: "*Lyst",
  554. fn: function (anObject,aBlock){
  555. var self=this,$self=this;
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. return $core.withContext(function($ctx1) {
  558. //>>excludeEnd("ctx");
  559. var $1;
  560. var $early={};
  561. try {
  562. $1=$recv(anObject)._respondsTo_("at:ifAbsent:");
  563. $recv($1)._ifTrue_ifFalse_((function(){
  564. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  565. return $core.withContext(function($ctx2) {
  566. //>>excludeEnd("ctx");
  567. throw $early=[$recv(anObject)._at_ifAbsent_(self,aBlock)];
  568. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  569. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  570. //>>excludeEnd("ctx");
  571. }),aBlock);
  572. return self;
  573. }
  574. catch(e) {if(e===$early)return e[0]; throw e}
  575. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  576. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.String)});
  577. //>>excludeEnd("ctx");
  578. },
  579. //>>excludeStart("ide", pragmas.excludeIdeData);
  580. args: ["anObject", "aBlock"],
  581. source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09(anObject respondsTo: #at:ifAbsent:)\x0a\x09\x09ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]\x0a\x09\x09ifFalse: aBlock",
  582. referencedClasses: [],
  583. //>>excludeEnd("ide");
  584. messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:ifAbsent:"]
  585. }),
  586. $globals.String);
  587. $core.addMethod(
  588. $core.method({
  589. selector: "atYndexIn:ifAbsent:put:",
  590. protocol: "*Lyst",
  591. fn: function (anObject,aBlock,anotherObject){
  592. var self=this,$self=this;
  593. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  594. return $core.withContext(function($ctx1) {
  595. //>>excludeEnd("ctx");
  596. var $1;
  597. var $early={};
  598. try {
  599. $1=$recv(anObject)._respondsTo_("at:put:");
  600. $recv($1)._ifTrue_ifFalse_((function(){
  601. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  602. return $core.withContext(function($ctx2) {
  603. //>>excludeEnd("ctx");
  604. throw $early=[$recv(anObject)._at_put_(self,anotherObject)];
  605. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  606. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  607. //>>excludeEnd("ctx");
  608. }),aBlock);
  609. return self;
  610. }
  611. catch(e) {if(e===$early)return e[0]; throw e}
  612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  613. }, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.String)});
  614. //>>excludeEnd("ctx");
  615. },
  616. //>>excludeStart("ide", pragmas.excludeIdeData);
  617. args: ["anObject", "aBlock", "anotherObject"],
  618. source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09(anObject respondsTo: #at:put:)\x0a\x09\x09ifTrue: [ ^ anObject at: self put: anotherObject ]\x0a\x09\x09ifFalse: aBlock",
  619. referencedClasses: [],
  620. //>>excludeEnd("ide");
  621. messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:put:"]
  622. }),
  623. $globals.String);
  624. });