Trapped-Backend.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. define("gh_herby_trapped/Trapped-Backend", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Collections"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Trapped-Backend');
  3. smalltalk.packages["Trapped-Backend"].transport = {"type":"amd","amdNamespace":"gh_herby_trapped"};
  4. smalltalk.addClass('EavModel', smalltalk.Object, ['getBlock', 'putBlock'], 'Trapped-Backend');
  5. smalltalk.EavModel.comment="External actor value model.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "getBlock:",
  9. category: 'accessing',
  10. fn: function (aBlock){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. self["@getBlock"]=aBlock;
  14. return self}, function($ctx1) {$ctx1.fill(self,"getBlock:",{aBlock:aBlock},smalltalk.EavModel)})},
  15. args: ["aBlock"],
  16. source: "getBlock: aBlock\x0a\x0agetBlock := aBlock",
  17. messageSends: [],
  18. referencedClasses: []
  19. }),
  20. smalltalk.EavModel);
  21. smalltalk.addMethod(
  22. smalltalk.method({
  23. selector: "initialize",
  24. category: 'initialization',
  25. fn: function (){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx1) {
  28. smalltalk.EavModel.superclass.fn.prototype._initialize.apply(_st(self), []);
  29. self["@getBlock"]=(function(){
  30. return smalltalk.withContext(function($ctx2) {
  31. return self._error_("No getter block.");
  32. $ctx2.sendIdx["error:"]=1;
  33. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  34. self["@putBlock"]=(function(){
  35. return smalltalk.withContext(function($ctx2) {
  36. return self._error_("No putter block.");
  37. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})});
  38. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.EavModel)})},
  39. args: [],
  40. source: "initialize\x0a\x09super initialize.\x0a\x09getBlock := [ self error: 'No getter block.' ].\x0a\x09putBlock := [ self error: 'No putter block.' ].",
  41. messageSends: ["initialize", "error:"],
  42. referencedClasses: []
  43. }),
  44. smalltalk.EavModel);
  45. smalltalk.addMethod(
  46. smalltalk.method({
  47. selector: "on:",
  48. category: 'accessing',
  49. fn: function (anObject){
  50. var self=this;
  51. return smalltalk.withContext(function($ctx1) {
  52. var $1;
  53. $1=_st(self["@getBlock"])._value_(anObject);
  54. return $1;
  55. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},smalltalk.EavModel)})},
  56. args: ["anObject"],
  57. source: "on: anObject\x0a\x22Returns value of model applied on object\x22\x0a\x0a^getBlock value: anObject",
  58. messageSends: ["value:"],
  59. referencedClasses: []
  60. }),
  61. smalltalk.EavModel);
  62. smalltalk.addMethod(
  63. smalltalk.method({
  64. selector: "on:put:",
  65. category: 'accessing',
  66. fn: function (anObject,anObject2){
  67. var self=this;
  68. return smalltalk.withContext(function($ctx1) {
  69. var $1;
  70. $1=_st(self["@putBlock"])._value_value_(anObject,anObject2);
  71. return $1;
  72. }, function($ctx1) {$ctx1.fill(self,"on:put:",{anObject:anObject,anObject2:anObject2},smalltalk.EavModel)})},
  73. args: ["anObject", "anObject2"],
  74. source: "on: anObject put: anObject2\x0a\x22Puts a value via model applied on object\x22\x0a\x0a^putBlock value: anObject value: anObject2",
  75. messageSends: ["value:value:"],
  76. referencedClasses: []
  77. }),
  78. smalltalk.EavModel);
  79. smalltalk.addMethod(
  80. smalltalk.method({
  81. selector: "putBlock:",
  82. category: 'accessing',
  83. fn: function (aBlock){
  84. var self=this;
  85. return smalltalk.withContext(function($ctx1) {
  86. self["@putBlock"]=aBlock;
  87. return self}, function($ctx1) {$ctx1.fill(self,"putBlock:",{aBlock:aBlock},smalltalk.EavModel)})},
  88. args: ["aBlock"],
  89. source: "putBlock: aBlock\x0a\x0aputBlock := aBlock",
  90. messageSends: [],
  91. referencedClasses: []
  92. }),
  93. smalltalk.EavModel);
  94. smalltalk.addClass('Isolator', smalltalk.Object, ['root'], 'Trapped-Backend');
  95. smalltalk.addMethod(
  96. smalltalk.method({
  97. selector: "model:modify:",
  98. category: 'action',
  99. fn: function (anEavModel,aBlock){
  100. var self=this;
  101. var newValue;
  102. return smalltalk.withContext(function($ctx1) {
  103. newValue=_st(aBlock)._value_(_st(anEavModel)._on_(self));
  104. _st(anEavModel)._on_put_(self,_st(newValue)._deepCopy());
  105. return self}, function($ctx1) {$ctx1.fill(self,"model:modify:",{anEavModel:anEavModel,aBlock:aBlock,newValue:newValue},smalltalk.Isolator)})},
  106. args: ["anEavModel", "aBlock"],
  107. source: "model: anEavModel modify: aBlock\x0a\x0a| newValue |\x0anewValue := aBlock value: (anEavModel on: self).\x0aanEavModel on: self put: newValue deepCopy",
  108. messageSends: ["value:", "on:", "on:put:", "deepCopy"],
  109. referencedClasses: []
  110. }),
  111. smalltalk.Isolator);
  112. smalltalk.addMethod(
  113. smalltalk.method({
  114. selector: "model:read:",
  115. category: 'action',
  116. fn: function (anEavModel,aBlock){
  117. var self=this;
  118. return smalltalk.withContext(function($ctx1) {
  119. _st(aBlock)._value_(_st(_st(anEavModel)._on_(self))._deepCopy());
  120. return self}, function($ctx1) {$ctx1.fill(self,"model:read:",{anEavModel:anEavModel,aBlock:aBlock},smalltalk.Isolator)})},
  121. args: ["anEavModel", "aBlock"],
  122. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  123. messageSends: ["value:", "deepCopy", "on:"],
  124. referencedClasses: []
  125. }),
  126. smalltalk.Isolator);
  127. smalltalk.addMethod(
  128. smalltalk.method({
  129. selector: "root",
  130. category: 'accessing',
  131. fn: function (){
  132. var self=this;
  133. return smalltalk.withContext(function($ctx1) {
  134. var $1;
  135. $1=self["@root"];
  136. return $1;
  137. }, function($ctx1) {$ctx1.fill(self,"root",{},smalltalk.Isolator)})},
  138. args: [],
  139. source: "root\x0a\x0a^root",
  140. messageSends: [],
  141. referencedClasses: []
  142. }),
  143. smalltalk.Isolator);
  144. smalltalk.addMethod(
  145. smalltalk.method({
  146. selector: "root:",
  147. category: 'accessing',
  148. fn: function (anObject){
  149. var self=this;
  150. return smalltalk.withContext(function($ctx1) {
  151. self["@root"]=anObject;
  152. return self}, function($ctx1) {$ctx1.fill(self,"root:",{anObject:anObject},smalltalk.Isolator)})},
  153. args: ["anObject"],
  154. source: "root: anObject\x0a\x0aroot := anObject",
  155. messageSends: [],
  156. referencedClasses: []
  157. }),
  158. smalltalk.Isolator);
  159. smalltalk.addMethod(
  160. smalltalk.method({
  161. selector: "on:",
  162. category: 'instance creation',
  163. fn: function (anObject){
  164. var self=this;
  165. return smalltalk.withContext(function($ctx1) {
  166. var $1;
  167. $1=_st(self._new())._root_(anObject);
  168. return $1;
  169. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},smalltalk.Isolator.klass)})},
  170. args: ["anObject"],
  171. source: "on: anObject\x0a^self new root: anObject",
  172. messageSends: ["root:", "new"],
  173. referencedClasses: []
  174. }),
  175. smalltalk.Isolator.klass);
  176. smalltalk.addClass('KeyedPubSubBase', smalltalk.Object, ['factory'], 'Trapped-Backend');
  177. smalltalk.KeyedPubSubBase.comment="I represent a pub-sub based on a key.\x0d\x0aI manage key-block subscriptions as well as running blocks that are dirty.\x0d\x0aThe subscription objects are reponsible of decision if the change is relevant for them.\x0d\x0aSubscription object must be subclasses of KeyedSubscriptionBase.\x0d\x0a\x0d\x0aMy subclasses must provide implementation for:\x0d\x0a\x09add:\x0d\x0a do:\x0d\x0a clean\x0d\x0a (optionally) run\x0d\x0a\x0d\x0aand issue this call before actual use:\x0d\x0a\x09subscritionFactory: (setting [:key:block|...] factory that creates appropriate subscription)";
  178. smalltalk.addMethod(
  179. smalltalk.method({
  180. selector: "changed:",
  181. category: 'action',
  182. fn: function (key){
  183. var self=this;
  184. var needsToRun;
  185. return smalltalk.withContext(function($ctx1) {
  186. var $1;
  187. needsToRun=false;
  188. self._do_((function(each){
  189. return smalltalk.withContext(function($ctx2) {
  190. $1=_st(each)._accepts_(key);
  191. if(smalltalk.assert($1)){
  192. _st(each)._flag();
  193. needsToRun=true;
  194. return needsToRun;
  195. };
  196. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  197. self._dirty_(needsToRun);
  198. return self}, function($ctx1) {$ctx1.fill(self,"changed:",{key:key,needsToRun:needsToRun},smalltalk.KeyedPubSubBase)})},
  199. args: ["key"],
  200. source: "changed: key\x0a\x09| needsToRun |\x0a needsToRun := false.\x0a\x09self do: [ :each |\x0a\x09\x09(each accepts: key) ifTrue: [\x0a\x09\x09\x09each flag.\x0a needsToRun := true.\x0a\x09\x09]\x0a\x09].\x0a\x09self dirty: needsToRun",
  201. messageSends: ["do:", "ifTrue:", "accepts:", "flag", "dirty:"],
  202. referencedClasses: []
  203. }),
  204. smalltalk.KeyedPubSubBase);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "dirty:",
  208. category: 'action',
  209. fn: function (aBoolean){
  210. var self=this;
  211. return smalltalk.withContext(function($ctx1) {
  212. if(smalltalk.assert(aBoolean)){
  213. _st((function(){
  214. return smalltalk.withContext(function($ctx2) {
  215. return self._run();
  216. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}))._fork();
  217. };
  218. return self}, function($ctx1) {$ctx1.fill(self,"dirty:",{aBoolean:aBoolean},smalltalk.KeyedPubSubBase)})},
  219. args: ["aBoolean"],
  220. source: "dirty: aBoolean\x0a\x09aBoolean ifTrue: [[ self run ] fork]",
  221. messageSends: ["ifTrue:", "fork", "run"],
  222. referencedClasses: []
  223. }),
  224. smalltalk.KeyedPubSubBase);
  225. smalltalk.addMethod(
  226. smalltalk.method({
  227. selector: "on:hook:",
  228. category: 'action',
  229. fn: function (key,aBlock){
  230. var self=this;
  231. return smalltalk.withContext(function($ctx1) {
  232. self._add_(_st(_st(self["@factory"])._value_value_(key,aBlock))._flag());
  233. self._dirty_(true);
  234. return self}, function($ctx1) {$ctx1.fill(self,"on:hook:",{key:key,aBlock:aBlock},smalltalk.KeyedPubSubBase)})},
  235. args: ["key", "aBlock"],
  236. source: "on: key hook: aBlock\x0a\x09self add: (factory value: key value: aBlock) flag.\x0a \x09self dirty: true",
  237. messageSends: ["add:", "flag", "value:value:", "dirty:"],
  238. referencedClasses: []
  239. }),
  240. smalltalk.KeyedPubSubBase);
  241. smalltalk.addMethod(
  242. smalltalk.method({
  243. selector: "run",
  244. category: 'action',
  245. fn: function (){
  246. var self=this;
  247. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  248. return smalltalk.withContext(function($ctx1) {
  249. var $1,$2,$3;
  250. _st((function(){
  251. var needsClean;
  252. return smalltalk.withContext(function($ctx2) {
  253. needsClean=false;
  254. needsClean;
  255. self._do_((function(each){
  256. return smalltalk.withContext(function($ctx3) {
  257. $1=_st(each)._isFlagged();
  258. if(smalltalk.assert($1)){
  259. _st(each)._run();
  260. };
  261. $2=_st(each)._isEnabled();
  262. if(! smalltalk.assert($2)){
  263. needsClean=true;
  264. return needsClean;
  265. };
  266. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}));
  267. $3=needsClean;
  268. if(smalltalk.assert($3)){
  269. return self._clean();
  270. };
  271. }, function($ctx2) {$ctx2.fillBlock({needsClean:needsClean},$ctx1,1)})}))._on_do_($Error(),(function(){
  272. return smalltalk.withContext(function($ctx2) {
  273. return self._dirty_(true);
  274. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}));
  275. return self}, function($ctx1) {$ctx1.fill(self,"run",{},smalltalk.KeyedPubSubBase)})},
  276. args: [],
  277. source: "run\x0a\x09[\x0a\x09\x09| needsClean |\x0a\x09 needsClean := false.\x0a\x09\x09self do: [ :each |\x0a\x09\x09\x09each isFlagged ifTrue: [ each run ].\x0a\x09 each isEnabled ifFalse: [ needsClean := true ]\x0a\x09\x09].\x0a \x09needsClean ifTrue: [ self clean ]\x0a\x09] on: Error do: [ self dirty: true ]",
  278. messageSends: ["on:do:", "do:", "ifTrue:", "isFlagged", "run", "ifFalse:", "isEnabled", "clean", "dirty:"],
  279. referencedClasses: ["Error"]
  280. }),
  281. smalltalk.KeyedPubSubBase);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "subscriptionFactory:",
  285. category: 'action',
  286. fn: function (aBlock){
  287. var self=this;
  288. return smalltalk.withContext(function($ctx1) {
  289. self["@factory"]=aBlock;
  290. return self}, function($ctx1) {$ctx1.fill(self,"subscriptionFactory:",{aBlock:aBlock},smalltalk.KeyedPubSubBase)})},
  291. args: ["aBlock"],
  292. source: "subscriptionFactory: aBlock\x0a factory := aBlock",
  293. messageSends: [],
  294. referencedClasses: []
  295. }),
  296. smalltalk.KeyedPubSubBase);
  297. smalltalk.addClass('SimpleKeyedPubSub', smalltalk.KeyedPubSubBase, ['queue'], 'Trapped-Backend');
  298. smalltalk.addMethod(
  299. smalltalk.method({
  300. selector: "add:",
  301. category: 'accessing',
  302. fn: function (aSubscription){
  303. var self=this;
  304. return smalltalk.withContext(function($ctx1) {
  305. _st(self["@queue"])._add_(aSubscription);
  306. return self}, function($ctx1) {$ctx1.fill(self,"add:",{aSubscription:aSubscription},smalltalk.SimpleKeyedPubSub)})},
  307. args: ["aSubscription"],
  308. source: "add: aSubscription\x0a\x09queue add: aSubscription.",
  309. messageSends: ["add:"],
  310. referencedClasses: []
  311. }),
  312. smalltalk.SimpleKeyedPubSub);
  313. smalltalk.addMethod(
  314. smalltalk.method({
  315. selector: "clean",
  316. category: 'bookkeeping',
  317. fn: function (){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) {
  320. self["@queue"]=_st(self["@queue"])._select_((function(each){
  321. return smalltalk.withContext(function($ctx2) {
  322. return _st(each)._isEnabled();
  323. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  324. return self}, function($ctx1) {$ctx1.fill(self,"clean",{},smalltalk.SimpleKeyedPubSub)})},
  325. args: [],
  326. source: "clean\x0a\x09queue := queue select: [ :each | each isEnabled ]",
  327. messageSends: ["select:", "isEnabled"],
  328. referencedClasses: []
  329. }),
  330. smalltalk.SimpleKeyedPubSub);
  331. smalltalk.addMethod(
  332. smalltalk.method({
  333. selector: "do:",
  334. category: 'enumeration',
  335. fn: function (aBlock){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx1) {
  338. _st(self["@queue"])._do_(aBlock);
  339. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.SimpleKeyedPubSub)})},
  340. args: ["aBlock"],
  341. source: "do: aBlock\x0a\x09queue do: aBlock",
  342. messageSends: ["do:"],
  343. referencedClasses: []
  344. }),
  345. smalltalk.SimpleKeyedPubSub);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "initialize",
  349. category: 'initialization',
  350. fn: function (){
  351. var self=this;
  352. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  353. return smalltalk.withContext(function($ctx1) {
  354. smalltalk.SimpleKeyedPubSub.superclass.fn.prototype._initialize.apply(_st(self), []);
  355. self["@queue"]=_st($OrderedCollection())._new();
  356. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.SimpleKeyedPubSub)})},
  357. args: [],
  358. source: "initialize\x0a super initialize.\x0a\x09queue := OrderedCollection new",
  359. messageSends: ["initialize", "new"],
  360. referencedClasses: ["OrderedCollection"]
  361. }),
  362. smalltalk.SimpleKeyedPubSub);
  363. smalltalk.addClass('KeyedPubSubUnsubscribe', smalltalk.Error, [], 'Trapped-Backend');
  364. smalltalk.KeyedPubSubUnsubscribe.comment="SIgnal me from the subscription block to unsubscribe it.";
  365. smalltalk.addClass('KeyedSubscriptionBase', smalltalk.Object, ['key', 'actionBlock', 'flagged'], 'Trapped-Backend');
  366. smalltalk.addMethod(
  367. smalltalk.method({
  368. selector: "accepts:",
  369. category: 'testing',
  370. fn: function (aKey){
  371. var self=this;
  372. return smalltalk.withContext(function($ctx1) {
  373. self._subclassResponsibility();
  374. return self}, function($ctx1) {$ctx1.fill(self,"accepts:",{aKey:aKey},smalltalk.KeyedSubscriptionBase)})},
  375. args: ["aKey"],
  376. source: "accepts: aKey\x0a \x22Should return true if change for aKey is relevant for this subscription\x22\x0a self subclassResponsibility",
  377. messageSends: ["subclassResponsibility"],
  378. referencedClasses: []
  379. }),
  380. smalltalk.KeyedSubscriptionBase);
  381. smalltalk.addMethod(
  382. smalltalk.method({
  383. selector: "flag",
  384. category: 'accessing',
  385. fn: function (){
  386. var self=this;
  387. return smalltalk.withContext(function($ctx1) {
  388. self["@flagged"]=true;
  389. return self}, function($ctx1) {$ctx1.fill(self,"flag",{},smalltalk.KeyedSubscriptionBase)})},
  390. args: [],
  391. source: "flag\x0a\x09flagged := true",
  392. messageSends: [],
  393. referencedClasses: []
  394. }),
  395. smalltalk.KeyedSubscriptionBase);
  396. smalltalk.addMethod(
  397. smalltalk.method({
  398. selector: "initialize",
  399. category: 'initialization',
  400. fn: function (){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx1) {
  403. smalltalk.KeyedSubscriptionBase.superclass.fn.prototype._initialize.apply(_st(self), []);
  404. self["@key"]=nil;
  405. self["@actionBlock"]=nil;
  406. self["@flagged"]=false;
  407. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.KeyedSubscriptionBase)})},
  408. args: [],
  409. source: "initialize\x0a\x09super initialize.\x0a key := nil.\x0a actionBlock := nil.\x0a flagged := false.",
  410. messageSends: ["initialize"],
  411. referencedClasses: []
  412. }),
  413. smalltalk.KeyedSubscriptionBase);
  414. smalltalk.addMethod(
  415. smalltalk.method({
  416. selector: "isEnabled",
  417. category: 'testing',
  418. fn: function (){
  419. var self=this;
  420. return smalltalk.withContext(function($ctx1) {
  421. var $1;
  422. $1=_st(self["@actionBlock"])._notNil();
  423. return $1;
  424. }, function($ctx1) {$ctx1.fill(self,"isEnabled",{},smalltalk.KeyedSubscriptionBase)})},
  425. args: [],
  426. source: "isEnabled\x0a\x09^actionBlock notNil",
  427. messageSends: ["notNil"],
  428. referencedClasses: []
  429. }),
  430. smalltalk.KeyedSubscriptionBase);
  431. smalltalk.addMethod(
  432. smalltalk.method({
  433. selector: "isFlagged",
  434. category: 'testing',
  435. fn: function (){
  436. var self=this;
  437. return smalltalk.withContext(function($ctx1) {
  438. var $1;
  439. $1=self["@flagged"];
  440. return $1;
  441. }, function($ctx1) {$ctx1.fill(self,"isFlagged",{},smalltalk.KeyedSubscriptionBase)})},
  442. args: [],
  443. source: "isFlagged\x0a\x09^flagged",
  444. messageSends: [],
  445. referencedClasses: []
  446. }),
  447. smalltalk.KeyedSubscriptionBase);
  448. smalltalk.addMethod(
  449. smalltalk.method({
  450. selector: "key:block:",
  451. category: 'accessing',
  452. fn: function (anObject,aBlock){
  453. var self=this;
  454. return smalltalk.withContext(function($ctx1) {
  455. self["@key"]=anObject;
  456. self["@actionBlock"]=aBlock;
  457. return self}, function($ctx1) {$ctx1.fill(self,"key:block:",{anObject:anObject,aBlock:aBlock},smalltalk.KeyedSubscriptionBase)})},
  458. args: ["anObject", "aBlock"],
  459. source: "key: anObject block: aBlock\x0a\x09key := anObject.\x0a actionBlock := aBlock",
  460. messageSends: [],
  461. referencedClasses: []
  462. }),
  463. smalltalk.KeyedSubscriptionBase);
  464. smalltalk.addMethod(
  465. smalltalk.method({
  466. selector: "run",
  467. category: 'action',
  468. fn: function (){
  469. var self=this;
  470. function $KeyedPubSubUnsubscribe(){return smalltalk.KeyedPubSubUnsubscribe||(typeof KeyedPubSubUnsubscribe=="undefined"?nil:KeyedPubSubUnsubscribe)}
  471. return smalltalk.withContext(function($ctx1) {
  472. _st((function(){
  473. return smalltalk.withContext(function($ctx2) {
  474. self["@flagged"]=false;
  475. self["@flagged"];
  476. return _st(self["@actionBlock"])._value();
  477. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($KeyedPubSubUnsubscribe(),(function(){
  478. return smalltalk.withContext(function($ctx2) {
  479. self["@actionBlock"]=nil;
  480. return self["@actionBlock"];
  481. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  482. return self}, function($ctx1) {$ctx1.fill(self,"run",{},smalltalk.KeyedSubscriptionBase)})},
  483. args: [],
  484. source: "run\x0a\x09[ flagged := false. actionBlock value ]\x0a on: KeyedPubSubUnsubscribe do: [ actionBlock := nil ]",
  485. messageSends: ["on:do:", "value"],
  486. referencedClasses: ["KeyedPubSubUnsubscribe"]
  487. }),
  488. smalltalk.KeyedSubscriptionBase);
  489. smalltalk.addClass('ListKeyedSubscription', smalltalk.KeyedSubscriptionBase, [], 'Trapped-Backend');
  490. smalltalk.addMethod(
  491. smalltalk.method({
  492. selector: "accepts:",
  493. category: 'testing',
  494. fn: function (aKey){
  495. var self=this;
  496. return smalltalk.withContext(function($ctx1) {
  497. var $3,$4,$2,$1;
  498. $3=_st(aKey)._size();
  499. $ctx1.sendIdx["size"]=1;
  500. $4=_st(self["@key"])._size();
  501. $ctx1.sendIdx["size"]=2;
  502. $2=_st($3).__lt_eq($4);
  503. $1=_st($2)._and_((function(){
  504. return smalltalk.withContext(function($ctx2) {
  505. return _st(aKey).__eq(_st(self["@key"])._copyFrom_to_((1),_st(aKey)._size()));
  506. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  507. return $1;
  508. }, function($ctx1) {$ctx1.fill(self,"accepts:",{aKey:aKey},smalltalk.ListKeyedSubscription)})},
  509. args: ["aKey"],
  510. source: "accepts: aKey\x0a ^aKey size <= key size and: [aKey = (key copyFrom: 1 to: aKey size)]",
  511. messageSends: ["and:", "<=", "size", "=", "copyFrom:to:"],
  512. referencedClasses: []
  513. }),
  514. smalltalk.ListKeyedSubscription);
  515. smalltalk.addClass('TwoWayListKeyedSubscription', smalltalk.KeyedSubscriptionBase, [], 'Trapped-Backend');
  516. smalltalk.addMethod(
  517. smalltalk.method({
  518. selector: "accepts:",
  519. category: 'testing',
  520. fn: function (aKey){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. var $3,$4,$2,$6,$7,$5,$1;
  524. $3=_st(aKey)._size();
  525. $ctx1.sendIdx["size"]=1;
  526. $4=_st(self["@key"])._size();
  527. $ctx1.sendIdx["size"]=2;
  528. $2=_st($3).__lt_eq($4);
  529. if(smalltalk.assert($2)){
  530. $6=self["@key"];
  531. $7=_st(aKey)._size();
  532. $ctx1.sendIdx["size"]=3;
  533. $5=_st($6)._copyFrom_to_((1),$7);
  534. $ctx1.sendIdx["copyFrom:to:"]=1;
  535. $1=_st(aKey).__eq($5);
  536. $ctx1.sendIdx["="]=1;
  537. } else {
  538. $1=_st(self["@key"]).__eq(_st(aKey)._copyFrom_to_((1),_st(self["@key"])._size()));
  539. };
  540. return $1;
  541. }, function($ctx1) {$ctx1.fill(self,"accepts:",{aKey:aKey},smalltalk.TwoWayListKeyedSubscription)})},
  542. args: ["aKey"],
  543. source: "accepts: aKey\x0a ^aKey size <= key size\x0a\x09\x09ifTrue: [aKey = (key copyFrom: 1 to: aKey size)]\x0a\x09\x09ifFalse: [key = (aKey copyFrom: 1 to: key size)]",
  544. messageSends: ["ifTrue:ifFalse:", "<=", "size", "=", "copyFrom:to:"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.TwoWayListKeyedSubscription);
  548. smalltalk.addClass('ListKeyedEntity', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Backend');
  549. smalltalk.ListKeyedEntity.comment="I am base class for #('string-at-index' #selector numeric-at-index)-array-path-keyed entities,\x0d\x0athat moderate access to the wrapped model object via read;do and modify:do:\x0d\x0aand allow pub-sub via watch:do:.\x0d\x0aThis wrapped model can be any smalltalk object.\x0d\x0a\x0d\x0aMy subclasses need to provide implementation for:\x0d\x0a\x09read:do:\x0d\x0a modify:do:\x0d\x0a\x0d\x0aand must issue these calls when initializing:\x0d\x0a\x09model: (with a wrapped object)\x0d\x0a\x09dispatcher: (with a subclass of KeyedPubSubBase)";
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "dispatcher",
  553. category: 'accessing',
  554. fn: function (){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1;
  558. $1=self["@dispatcher"];
  559. return $1;
  560. }, function($ctx1) {$ctx1.fill(self,"dispatcher",{},smalltalk.ListKeyedEntity)})},
  561. args: [],
  562. source: "dispatcher\x0a\x09^dispatcher",
  563. messageSends: [],
  564. referencedClasses: []
  565. }),
  566. smalltalk.ListKeyedEntity);
  567. smalltalk.addMethod(
  568. smalltalk.method({
  569. selector: "dispatcher:",
  570. category: 'accessing',
  571. fn: function (aDispatcher){
  572. var self=this;
  573. function $TwoWayListKeyedSubscription(){return smalltalk.TwoWayListKeyedSubscription||(typeof TwoWayListKeyedSubscription=="undefined"?nil:TwoWayListKeyedSubscription)}
  574. function $ListKeyedSubscription(){return smalltalk.ListKeyedSubscription||(typeof ListKeyedSubscription=="undefined"?nil:ListKeyedSubscription)}
  575. return smalltalk.withContext(function($ctx1) {
  576. var $1,$2,$3,$4,$5,$6;
  577. _st(aDispatcher)._subscriptionFactory_((function(key,block){
  578. return smalltalk.withContext(function($ctx2) {
  579. $1=_st(_st(key)._notEmpty())._and_((function(){
  580. return smalltalk.withContext(function($ctx3) {
  581. return _st(_st(key)._last())._isNil();
  582. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  583. if(smalltalk.assert($1)){
  584. $2=_st($TwoWayListKeyedSubscription())._new();
  585. $ctx2.sendIdx["new"]=1;
  586. _st($2)._key_block_(_st(key)._allButLast(),block);
  587. $ctx2.sendIdx["key:block:"]=1;
  588. $3=_st($2)._yourself();
  589. $ctx2.sendIdx["yourself"]=1;
  590. return $3;
  591. } else {
  592. $4=_st($ListKeyedSubscription())._new();
  593. _st($4)._key_block_(key,block);
  594. $5=_st($4)._yourself();
  595. $ctx2.sendIdx["yourself"]=2;
  596. return $5;
  597. };
  598. }, function($ctx2) {$ctx2.fillBlock({key:key,block:block},$ctx1,1)})}));
  599. $6=_st(aDispatcher)._yourself();
  600. self["@dispatcher"]=$6;
  601. return self}, function($ctx1) {$ctx1.fill(self,"dispatcher:",{aDispatcher:aDispatcher},smalltalk.ListKeyedEntity)})},
  602. args: ["aDispatcher"],
  603. source: "dispatcher: aDispatcher\x0a\x09dispatcher := aDispatcher\x0a subscriptionFactory: [ :key :block |\x0a\x09\x09\x09(key notEmpty and: [ key last isNil ])\x0a\x09\x09\x09\x09ifTrue: [ TwoWayListKeyedSubscription new key: key allButLast block: block; yourself ]\x0a\x09\x09\x09\x09ifFalse: [ ListKeyedSubscription new key: key block: block; yourself ]];\x0a yourself",
  604. messageSends: ["subscriptionFactory:", "ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "key:block:", "new", "allButLast", "yourself"],
  605. referencedClasses: ["TwoWayListKeyedSubscription", "ListKeyedSubscription"]
  606. }),
  607. smalltalk.ListKeyedEntity);
  608. smalltalk.addMethod(
  609. smalltalk.method({
  610. selector: "model:",
  611. category: 'accessing',
  612. fn: function (anObject){
  613. var self=this;
  614. return smalltalk.withContext(function($ctx1) {
  615. self["@payload"]=anObject;
  616. _st(self._dispatcher())._changed_([]);
  617. return self}, function($ctx1) {$ctx1.fill(self,"model:",{anObject:anObject},smalltalk.ListKeyedEntity)})},
  618. args: ["anObject"],
  619. source: "model: anObject\x0a\x09payload := anObject.\x0a self dispatcher changed: #()",
  620. messageSends: ["changed:", "dispatcher"],
  621. referencedClasses: []
  622. }),
  623. smalltalk.ListKeyedEntity);
  624. smalltalk.addMethod(
  625. smalltalk.method({
  626. selector: "watch:do:",
  627. category: 'action',
  628. fn: function (path,aBlock){
  629. var self=this;
  630. return smalltalk.withContext(function($ctx1) {
  631. _st(self._dispatcher())._on_hook_(path,(function(){
  632. return smalltalk.withContext(function($ctx2) {
  633. return self._read_do_(path,aBlock);
  634. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  635. return self}, function($ctx1) {$ctx1.fill(self,"watch:do:",{path:path,aBlock:aBlock},smalltalk.ListKeyedEntity)})},
  636. args: ["path", "aBlock"],
  637. source: "watch: path do: aBlock\x0a\x09self dispatcher on: path hook: [ self read: path do: aBlock ]",
  638. messageSends: ["on:hook:", "dispatcher", "read:do:"],
  639. referencedClasses: []
  640. }),
  641. smalltalk.ListKeyedEntity);
  642. smalltalk.addClass('ListKeyedDirectEntity', smalltalk.ListKeyedEntity, [], 'Trapped-Backend');
  643. smalltalk.ListKeyedDirectEntity.comment="I am ListKeyedEntity that directly manipulate\x0d\x0athe wrapped model object.";
  644. smalltalk.addMethod(
  645. smalltalk.method({
  646. selector: "modify:do:",
  647. category: 'action',
  648. fn: function (path,aBlock){
  649. var self=this;
  650. var newValue,eavModel;
  651. return smalltalk.withContext(function($ctx1) {
  652. eavModel=_st(path)._asEavModel();
  653. newValue=_st(aBlock)._value_(_st(eavModel)._on_(self["@payload"]));
  654. _st((function(){
  655. return smalltalk.withContext(function($ctx2) {
  656. return _st(eavModel)._on_put_(self["@payload"],newValue);
  657. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._ensure_((function(){
  658. return smalltalk.withContext(function($ctx2) {
  659. return _st(self._dispatcher())._changed_(path);
  660. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  661. return self}, function($ctx1) {$ctx1.fill(self,"modify:do:",{path:path,aBlock:aBlock,newValue:newValue,eavModel:eavModel},smalltalk.ListKeyedDirectEntity)})},
  662. args: ["path", "aBlock"],
  663. source: "modify: path do: aBlock\x0a | newValue eavModel |\x0a eavModel := path asEavModel.\x0a newValue := aBlock value: (eavModel on: payload).\x0a [ eavModel on: payload put: newValue ] ensure: [ self dispatcher changed: path ]",
  664. messageSends: ["asEavModel", "value:", "on:", "ensure:", "on:put:", "changed:", "dispatcher"],
  665. referencedClasses: []
  666. }),
  667. smalltalk.ListKeyedDirectEntity);
  668. smalltalk.addMethod(
  669. smalltalk.method({
  670. selector: "read:do:",
  671. category: 'action',
  672. fn: function (path,aBlock){
  673. var self=this;
  674. var eavModel;
  675. return smalltalk.withContext(function($ctx1) {
  676. eavModel=_st(path)._asEavModel();
  677. _st(aBlock)._value_(_st(eavModel)._on_(self["@payload"]));
  678. return self}, function($ctx1) {$ctx1.fill(self,"read:do:",{path:path,aBlock:aBlock,eavModel:eavModel},smalltalk.ListKeyedDirectEntity)})},
  679. args: ["path", "aBlock"],
  680. source: "read: path do: aBlock\x0a | eavModel |\x0a eavModel := path asEavModel.\x0a aBlock value: (eavModel on: payload)",
  681. messageSends: ["asEavModel", "value:", "on:"],
  682. referencedClasses: []
  683. }),
  684. smalltalk.ListKeyedDirectEntity);
  685. smalltalk.addClass('ListKeyedIsolatedEntity', smalltalk.ListKeyedEntity, [], 'Trapped-Backend');
  686. smalltalk.ListKeyedIsolatedEntity.comment="I am ListKeyedEntity that guards access\x0d\x0ato the wrapped model object via Isolator.";
  687. smalltalk.addMethod(
  688. smalltalk.method({
  689. selector: "model:",
  690. category: 'accessing',
  691. fn: function (anObject){
  692. var self=this;
  693. function $Isolator(){return smalltalk.Isolator||(typeof Isolator=="undefined"?nil:Isolator)}
  694. return smalltalk.withContext(function($ctx1) {
  695. smalltalk.ListKeyedIsolatedEntity.superclass.fn.prototype._model_.apply(_st(self), [_st($Isolator())._on_(anObject)]);
  696. return self}, function($ctx1) {$ctx1.fill(self,"model:",{anObject:anObject},smalltalk.ListKeyedIsolatedEntity)})},
  697. args: ["anObject"],
  698. source: "model: anObject\x0a\x09super model: (Isolator on: anObject)",
  699. messageSends: ["model:", "on:"],
  700. referencedClasses: ["Isolator"]
  701. }),
  702. smalltalk.ListKeyedIsolatedEntity);
  703. smalltalk.addMethod(
  704. smalltalk.method({
  705. selector: "modify:do:",
  706. category: 'action',
  707. fn: function (path,aBlock){
  708. var self=this;
  709. var eavModel;
  710. return smalltalk.withContext(function($ctx1) {
  711. eavModel=_st(_st([["root"]]).__comma(path))._asEavModel();
  712. _st((function(){
  713. return smalltalk.withContext(function($ctx2) {
  714. return _st(self["@payload"])._model_modify_(eavModel,aBlock);
  715. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._ensure_((function(){
  716. return smalltalk.withContext(function($ctx2) {
  717. return _st(self._dispatcher())._changed_(path);
  718. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  719. return self}, function($ctx1) {$ctx1.fill(self,"modify:do:",{path:path,aBlock:aBlock,eavModel:eavModel},smalltalk.ListKeyedIsolatedEntity)})},
  720. args: ["path", "aBlock"],
  721. source: "modify: path do: aBlock\x0a | eavModel |\x0a eavModel := ({{#root}},path) asEavModel.\x0a [ payload model: eavModel modify: aBlock ] ensure: [ self dispatcher changed: path ]",
  722. messageSends: ["asEavModel", ",", "ensure:", "model:modify:", "changed:", "dispatcher"],
  723. referencedClasses: []
  724. }),
  725. smalltalk.ListKeyedIsolatedEntity);
  726. smalltalk.addMethod(
  727. smalltalk.method({
  728. selector: "read:do:",
  729. category: 'action',
  730. fn: function (path,aBlock){
  731. var self=this;
  732. var eavModel;
  733. return smalltalk.withContext(function($ctx1) {
  734. eavModel=_st(_st([["root"]]).__comma(path))._asEavModel();
  735. _st(self["@payload"])._model_read_(eavModel,aBlock);
  736. return self}, function($ctx1) {$ctx1.fill(self,"read:do:",{path:path,aBlock:aBlock,eavModel:eavModel},smalltalk.ListKeyedIsolatedEntity)})},
  737. args: ["path", "aBlock"],
  738. source: "read: path do: aBlock\x0a | eavModel |\x0a eavModel := ({{#root}},path) asEavModel.\x0a payload model: eavModel read: aBlock",
  739. messageSends: ["asEavModel", ",", "model:read:"],
  740. referencedClasses: []
  741. }),
  742. smalltalk.ListKeyedIsolatedEntity);
  743. smalltalk.addMethod(
  744. smalltalk.method({
  745. selector: "reverseTrapAt:",
  746. category: '*Trapped-Backend',
  747. fn: function (anObject){
  748. var self=this;
  749. return smalltalk.withContext(function($ctx1) {
  750. return nil;
  751. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.Object)})},
  752. args: ["anObject"],
  753. source: "reverseTrapAt: anObject\x0a\x09^nil",
  754. messageSends: [],
  755. referencedClasses: []
  756. }),
  757. smalltalk.Object);
  758. smalltalk.addMethod(
  759. smalltalk.method({
  760. selector: "reverseTrapAt:put:",
  761. category: '*Trapped-Backend',
  762. fn: function (anObject,value){
  763. var self=this;
  764. return smalltalk.withContext(function($ctx1) {
  765. var $1;
  766. $1=_st("Trapped cannot put at ".__comma(_st(self._class())._name())).__comma(" type key.");
  767. $ctx1.sendIdx[","]=1;
  768. self._error_($1);
  769. return self}, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:put:",{anObject:anObject,value:value},smalltalk.Object)})},
  770. args: ["anObject", "value"],
  771. source: "reverseTrapAt: anObject put: value\x0a\x09self error: 'Trapped cannot put at ', self class name, ' type key.'",
  772. messageSends: ["error:", ",", "name", "class"],
  773. referencedClasses: []
  774. }),
  775. smalltalk.Object);
  776. smalltalk.addMethod(
  777. smalltalk.method({
  778. selector: "reverseTrapAt:",
  779. category: '*Trapped-Backend',
  780. fn: function (anObject){
  781. var self=this;
  782. return smalltalk.withContext(function($ctx1) {
  783. var $1;
  784. if(($receiver = anObject) == nil || $receiver == null){
  785. $1=anObject;
  786. } else {
  787. $1=_st(anObject)._at_ifAbsent_(self,(function(){
  788. return smalltalk.withContext(function($ctx2) {
  789. return nil;
  790. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  791. };
  792. return $1;
  793. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.Number)})},
  794. args: ["anObject"],
  795. source: "reverseTrapAt: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
  796. messageSends: ["ifNotNil:", "at:ifAbsent:"],
  797. referencedClasses: []
  798. }),
  799. smalltalk.Number);
  800. smalltalk.addMethod(
  801. smalltalk.method({
  802. selector: "reverseTrapAt:put:",
  803. category: '*Trapped-Backend',
  804. fn: function (anObject,value){
  805. var self=this;
  806. return smalltalk.withContext(function($ctx1) {
  807. var $1;
  808. $1=_st(anObject)._at_put_(self,value);
  809. return $1;
  810. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:put:",{anObject:anObject,value:value},smalltalk.Number)})},
  811. args: ["anObject", "value"],
  812. source: "reverseTrapAt: anObject put: value\x0a\x09^anObject at: self put: value",
  813. messageSends: ["at:put:"],
  814. referencedClasses: []
  815. }),
  816. smalltalk.Number);
  817. smalltalk.addMethod(
  818. smalltalk.method({
  819. selector: "asEavModel",
  820. category: '*Trapped-Backend',
  821. fn: function (){
  822. var self=this;
  823. var model;
  824. function $EavModel(){return smalltalk.EavModel||(typeof EavModel=="undefined"?nil:EavModel)}
  825. return smalltalk.withContext(function($ctx1) {
  826. var $1,$2;
  827. model=_st($EavModel())._new();
  828. _st(model)._getBlock_((function(anObject){
  829. return smalltalk.withContext(function($ctx2) {
  830. return self._inject_into_(anObject,(function(soFar,segment){
  831. return smalltalk.withContext(function($ctx3) {
  832. return _st(segment)._reverseTrapAt_(soFar);
  833. $ctx3.sendIdx["reverseTrapAt:"]=1;
  834. }, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,2)})}));
  835. $ctx2.sendIdx["inject:into:"]=1;
  836. }, function($ctx2) {$ctx2.fillBlock({anObject:anObject},$ctx1,1)})}));
  837. $1=self._isEmpty();
  838. if(! smalltalk.assert($1)){
  839. _st(model)._putBlock_((function(anObject,value){
  840. var penultimate;
  841. return smalltalk.withContext(function($ctx2) {
  842. penultimate=_st(self._allButLast())._inject_into_(anObject,(function(soFar,segment){
  843. return smalltalk.withContext(function($ctx3) {
  844. if(($receiver = soFar) == nil || $receiver == null){
  845. return soFar;
  846. } else {
  847. return _st(segment)._reverseTrapAt_(soFar);
  848. };
  849. }, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,5)})}));
  850. penultimate;
  851. return _st(self._last())._reverseTrapAt_put_(penultimate,value);
  852. }, function($ctx2) {$ctx2.fillBlock({anObject:anObject,value:value,penultimate:penultimate},$ctx1,4)})}));
  853. };
  854. $2=model;
  855. return $2;
  856. }, function($ctx1) {$ctx1.fill(self,"asEavModel",{model:model},smalltalk.SequenceableCollection)})},
  857. args: [],
  858. source: "asEavModel\x0a | model |\x0a model := EavModel new.\x0a model getBlock: [ :anObject |\x0a self inject: anObject into: [ :soFar :segment |\x0a segment reverseTrapAt: soFar ]].\x0a self isEmpty ifFalse: [\x0a model putBlock: [ :anObject :value | | penultimate |\x0a penultimate := self allButLast inject: anObject into: [ :soFar :segment |\x0a soFar ifNotNil: [ segment reverseTrapAt: soFar ]].\x0a self last reverseTrapAt: penultimate put: value ]].\x0a ^model",
  859. messageSends: ["new", "getBlock:", "inject:into:", "reverseTrapAt:", "ifFalse:", "isEmpty", "putBlock:", "allButLast", "ifNotNil:", "reverseTrapAt:put:", "last"],
  860. referencedClasses: ["EavModel"]
  861. }),
  862. smalltalk.SequenceableCollection);
  863. smalltalk.addMethod(
  864. smalltalk.method({
  865. selector: "reverseTrapAt:",
  866. category: '*Trapped-Backend',
  867. fn: function (anObject){
  868. var self=this;
  869. return smalltalk.withContext(function($ctx1) {
  870. var $1;
  871. if(($receiver = anObject) == nil || $receiver == null){
  872. $1=anObject;
  873. } else {
  874. $1=_st(anObject)._at_ifAbsent_(self,(function(){
  875. return smalltalk.withContext(function($ctx2) {
  876. return nil;
  877. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  878. };
  879. return $1;
  880. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.String)})},
  881. args: ["anObject"],
  882. source: "reverseTrapAt: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
  883. messageSends: ["ifNotNil:", "at:ifAbsent:"],
  884. referencedClasses: []
  885. }),
  886. smalltalk.String);
  887. smalltalk.addMethod(
  888. smalltalk.method({
  889. selector: "reverseTrapAt:put:",
  890. category: '*Trapped-Backend',
  891. fn: function (anObject,value){
  892. var self=this;
  893. return smalltalk.withContext(function($ctx1) {
  894. var $1;
  895. $1=_st(anObject)._at_put_(self,value);
  896. return $1;
  897. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:put:",{anObject:anObject,value:value},smalltalk.String)})},
  898. args: ["anObject", "value"],
  899. source: "reverseTrapAt: anObject put: value\x0a\x09^anObject at: self put: value",
  900. messageSends: ["at:put:"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.String);
  904. smalltalk.addMethod(
  905. smalltalk.method({
  906. selector: "reverseTrapAt:",
  907. category: '*Trapped-Backend',
  908. fn: function (anObject){
  909. var self=this;
  910. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  911. return smalltalk.withContext(function($ctx1) {
  912. var $1;
  913. var $early={};
  914. try {
  915. $1=_st((function(){
  916. return smalltalk.withContext(function($ctx2) {
  917. return _st(anObject)._perform_(self._first());
  918. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($MessageNotUnderstood(),(function(){
  919. return smalltalk.withContext(function($ctx2) {
  920. throw $early=[nil];
  921. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  922. return $1;
  923. }
  924. catch(e) {if(e===$early)return e[0]; throw e}
  925. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:",{anObject:anObject},smalltalk.Array)})},
  926. args: ["anObject"],
  927. source: "reverseTrapAt: anObject\x0a\x09^[anObject perform: self first] on: MessageNotUnderstood do: [^nil]",
  928. messageSends: ["on:do:", "perform:", "first"],
  929. referencedClasses: ["MessageNotUnderstood"]
  930. }),
  931. smalltalk.Array);
  932. smalltalk.addMethod(
  933. smalltalk.method({
  934. selector: "reverseTrapAt:put:",
  935. category: '*Trapped-Backend',
  936. fn: function (anObject,value){
  937. var self=this;
  938. return smalltalk.withContext(function($ctx1) {
  939. var $1;
  940. $1=_st(anObject)._perform_withArguments_(_st(_st(self._first()).__comma(":"))._asSymbol(),[value]);
  941. return $1;
  942. }, function($ctx1) {$ctx1.fill(self,"reverseTrapAt:put:",{anObject:anObject,value:value},smalltalk.Array)})},
  943. args: ["anObject", "value"],
  944. source: "reverseTrapAt: anObject put: value\x0a ^anObject perform: (self first, ':') asSymbol withArguments: { value }",
  945. messageSends: ["perform:withArguments:", "asSymbol", ",", "first"],
  946. referencedClasses: []
  947. }),
  948. smalltalk.Array);
  949. });