Trapped-Backend.deploy.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. smalltalk.addPackage('Trapped-Backend', {});
  2. smalltalk.addClass('EavModel', smalltalk.Object, ['getBlock', 'putBlock'], 'Trapped-Backend');
  3. smalltalk.addMethod(
  4. "_getBlock_",
  5. smalltalk.method({
  6. selector: "getBlock:",
  7. fn: function (aBlock){
  8. var self=this;
  9. self["@getBlock"]=aBlock;
  10. return self}
  11. }),
  12. smalltalk.EavModel);
  13. smalltalk.addMethod(
  14. "_initialize",
  15. smalltalk.method({
  16. selector: "initialize",
  17. fn: function (){
  18. var self=this;
  19. smalltalk.send(self,"_initialize",[],smalltalk.Object);
  20. self["@getBlock"]=(function(){
  21. return smalltalk.send(self,"_error_",["No getter block."]);
  22. });
  23. self["@putBlock"]=(function(){
  24. return smalltalk.send(self,"_error_",["No putter block."]);
  25. });
  26. return self}
  27. }),
  28. smalltalk.EavModel);
  29. smalltalk.addMethod(
  30. "_on_",
  31. smalltalk.method({
  32. selector: "on:",
  33. fn: function (anObject){
  34. var self=this;
  35. var $1;
  36. $1=smalltalk.send(self["@getBlock"],"_value_",[anObject]);
  37. return $1;
  38. }
  39. }),
  40. smalltalk.EavModel);
  41. smalltalk.addMethod(
  42. "_on_put_",
  43. smalltalk.method({
  44. selector: "on:put:",
  45. fn: function (anObject,anObject2){
  46. var self=this;
  47. var $1;
  48. $1=smalltalk.send(self["@putBlock"],"_value_value_",[anObject,anObject2]);
  49. return $1;
  50. }
  51. }),
  52. smalltalk.EavModel);
  53. smalltalk.addMethod(
  54. "_putBlock_",
  55. smalltalk.method({
  56. selector: "putBlock:",
  57. fn: function (aBlock){
  58. var self=this;
  59. self["@putBlock"]=aBlock;
  60. return self}
  61. }),
  62. smalltalk.EavModel);
  63. smalltalk.addClass('Isolator', smalltalk.Object, ['root'], 'Trapped-Backend');
  64. smalltalk.addMethod(
  65. "_model_modify_",
  66. smalltalk.method({
  67. selector: "model:modify:",
  68. fn: function (anEavModel,aBlock){
  69. var self=this;
  70. var newValue;
  71. newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(anEavModel,"_on_",[self])]);
  72. smalltalk.send(anEavModel,"_on_put_",[self,smalltalk.send(newValue,"_deepCopy",[])]);
  73. return self}
  74. }),
  75. smalltalk.Isolator);
  76. smalltalk.addMethod(
  77. "_model_read_",
  78. smalltalk.method({
  79. selector: "model:read:",
  80. fn: function (anEavModel,aBlock){
  81. var self=this;
  82. smalltalk.send(aBlock,"_value_",[smalltalk.send(smalltalk.send(anEavModel,"_on_",[self]),"_deepCopy",[])]);
  83. return self}
  84. }),
  85. smalltalk.Isolator);
  86. smalltalk.addMethod(
  87. "_root",
  88. smalltalk.method({
  89. selector: "root",
  90. fn: function (){
  91. var self=this;
  92. return self["@root"];
  93. }
  94. }),
  95. smalltalk.Isolator);
  96. smalltalk.addMethod(
  97. "_root_",
  98. smalltalk.method({
  99. selector: "root:",
  100. fn: function (anObject){
  101. var self=this;
  102. self["@root"]=anObject;
  103. return self}
  104. }),
  105. smalltalk.Isolator);
  106. smalltalk.addMethod(
  107. "_on_",
  108. smalltalk.method({
  109. selector: "on:",
  110. fn: function (anObject){
  111. var self=this;
  112. var $1;
  113. $1=smalltalk.send(smalltalk.send(self,"_new",[]),"_root_",[anObject]);
  114. return $1;
  115. }
  116. }),
  117. smalltalk.Isolator.klass);
  118. smalltalk.addClass('KeyedPubSubBase', smalltalk.Object, [], 'Trapped-Backend');
  119. smalltalk.addMethod(
  120. "_changed_",
  121. smalltalk.method({
  122. selector: "changed:",
  123. fn: function (key){
  124. var self=this;
  125. var $1;
  126. var needsToRun;
  127. needsToRun=false;
  128. smalltalk.send(self,"_do_",[(function(each){
  129. $1=smalltalk.send(each,"_accepts_",[key]);
  130. if(smalltalk.assert($1)){
  131. smalltalk.send(each,"_flag",[]);
  132. needsToRun=true;
  133. return needsToRun;
  134. };
  135. })]);
  136. smalltalk.send(self,"_dirty_",[needsToRun]);
  137. return self}
  138. }),
  139. smalltalk.KeyedPubSubBase);
  140. smalltalk.addMethod(
  141. "_dirty_",
  142. smalltalk.method({
  143. selector: "dirty:",
  144. fn: function (aBoolean){
  145. var self=this;
  146. if(smalltalk.assert(aBoolean)){
  147. smalltalk.send((function(){
  148. return smalltalk.send(self,"_run",[]);
  149. }),"_fork",[]);
  150. };
  151. return self}
  152. }),
  153. smalltalk.KeyedPubSubBase);
  154. smalltalk.addMethod(
  155. "_on_hook_",
  156. smalltalk.method({
  157. selector: "on:hook:",
  158. fn: function (key,aBlock){
  159. var self=this;
  160. smalltalk.send(self,"_add_",[smalltalk.send(smalltalk.send(self,"_subscriptionKey_block_",[key,aBlock]),"_flag",[])]);
  161. smalltalk.send(self,"_dirty_",[true]);
  162. return self}
  163. }),
  164. smalltalk.KeyedPubSubBase);
  165. smalltalk.addMethod(
  166. "_run",
  167. smalltalk.method({
  168. selector: "run",
  169. fn: function (){
  170. var self=this;
  171. var $1,$2;
  172. var needsClean;
  173. needsClean=false;
  174. smalltalk.send(self,"_do_",[(function(each){
  175. $1=smalltalk.send(each,"_isFlagged",[]);
  176. if(smalltalk.assert($1)){
  177. smalltalk.send(each,"_run",[]);
  178. $2=smalltalk.send(each,"_isEnabled",[]);
  179. if(! smalltalk.assert($2)){
  180. needsClean=true;
  181. return needsClean;
  182. };
  183. };
  184. })]);
  185. if(smalltalk.assert(needsClean)){
  186. smalltalk.send(self,"_clean",[]);
  187. };
  188. return self}
  189. }),
  190. smalltalk.KeyedPubSubBase);
  191. smalltalk.addMethod(
  192. "_subscriptionKey_block_",
  193. smalltalk.method({
  194. selector: "subscriptionKey:block:",
  195. fn: function (key,aBlock){
  196. var self=this;
  197. smalltalk.send(self,"_subclassReponsibility",[]);
  198. return self}
  199. }),
  200. smalltalk.KeyedPubSubBase);
  201. smalltalk.addClass('KeyedPubSubUnsubscribe', smalltalk.Error, [], 'Trapped-Backend');
  202. smalltalk.addClass('KeyedSubscriptionBase', smalltalk.Object, ['key', 'actionBlock', 'flagged'], 'Trapped-Backend');
  203. smalltalk.addMethod(
  204. "_accepts_",
  205. smalltalk.method({
  206. selector: "accepts:",
  207. fn: function (aKey){
  208. var self=this;
  209. smalltalk.send(self,"_subclassResponsibility",[]);
  210. return self}
  211. }),
  212. smalltalk.KeyedSubscriptionBase);
  213. smalltalk.addMethod(
  214. "_flag",
  215. smalltalk.method({
  216. selector: "flag",
  217. fn: function (){
  218. var self=this;
  219. self["@flagged"]=true;
  220. return self}
  221. }),
  222. smalltalk.KeyedSubscriptionBase);
  223. smalltalk.addMethod(
  224. "_initialize",
  225. smalltalk.method({
  226. selector: "initialize",
  227. fn: function (){
  228. var self=this;
  229. smalltalk.send(self,"_initialize",[],smalltalk.Object);
  230. self["@key"]=nil;
  231. self["@actionBlock"]=nil;
  232. self["@flagged"]=false;
  233. return self}
  234. }),
  235. smalltalk.KeyedSubscriptionBase);
  236. smalltalk.addMethod(
  237. "_isEnabled",
  238. smalltalk.method({
  239. selector: "isEnabled",
  240. fn: function (){
  241. var self=this;
  242. var $1;
  243. $1=smalltalk.send(self["@actionBlock"],"_notNil",[]);
  244. return $1;
  245. }
  246. }),
  247. smalltalk.KeyedSubscriptionBase);
  248. smalltalk.addMethod(
  249. "_isFlagged",
  250. smalltalk.method({
  251. selector: "isFlagged",
  252. fn: function (){
  253. var self=this;
  254. return self["@flagged"];
  255. }
  256. }),
  257. smalltalk.KeyedSubscriptionBase);
  258. smalltalk.addMethod(
  259. "_key_block_",
  260. smalltalk.method({
  261. selector: "key:block:",
  262. fn: function (anObject,aBlock){
  263. var self=this;
  264. self["@key"]=anObject;
  265. self["@actionBlock"]=aBlock;
  266. return self}
  267. }),
  268. smalltalk.KeyedSubscriptionBase);
  269. smalltalk.addMethod(
  270. "_run",
  271. smalltalk.method({
  272. selector: "run",
  273. fn: function (){
  274. var self=this;
  275. smalltalk.send((function(){
  276. return smalltalk.send((function(){
  277. return smalltalk.send(self["@actionBlock"],"_value",[]);
  278. }),"_ensure_",[(function(){
  279. self["@flagged"]=false;
  280. return self["@flagged"];
  281. })]);
  282. }),"_on_do_",[(smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe),(function(){
  283. self["@actionBlock"]=nil;
  284. return self["@actionBlock"];
  285. })]);
  286. return self}
  287. }),
  288. smalltalk.KeyedSubscriptionBase);
  289. smalltalk.addMethod(
  290. "_reverseTrapAt_",
  291. smalltalk.method({
  292. selector: "reverseTrapAt:",
  293. fn: function (anObject){
  294. var self=this;
  295. return nil;
  296. }
  297. }),
  298. smalltalk.Object);
  299. smalltalk.addMethod(
  300. "_reverseTrapAt_put_",
  301. smalltalk.method({
  302. selector: "reverseTrapAt:put:",
  303. fn: function (anObject,value){
  304. var self=this;
  305. smalltalk.send(self,"_error_",[smalltalk.send(smalltalk.send("Trapped cannot put at ","__comma",[smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[])]),"__comma",[" type key."])]);
  306. return self}
  307. }),
  308. smalltalk.Object);
  309. smalltalk.addMethod(
  310. "_asEavModel",
  311. smalltalk.method({
  312. selector: "asEavModel",
  313. fn: function (){
  314. var self=this;
  315. var $1;
  316. var model;
  317. model=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  318. smalltalk.send(model,"_getBlock_",[(function(anObject){
  319. return smalltalk.send(self,"_inject_into_",[anObject,(function(soFar,segment){
  320. if(($receiver = soFar) == nil || $receiver == undefined){
  321. return soFar;
  322. } else {
  323. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  324. };
  325. })]);
  326. })]);
  327. $1=smalltalk.send(self,"_isEmpty",[]);
  328. if(! smalltalk.assert($1)){
  329. smalltalk.send(model,"_putBlock_",[(function(anObject,value){
  330. var penultimate;
  331. penultimate=smalltalk.send(smalltalk.send(self,"_allButLast",[]),"_inject_into_",[anObject,(function(soFar,segment){
  332. if(($receiver = soFar) == nil || $receiver == undefined){
  333. return soFar;
  334. } else {
  335. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  336. };
  337. })]);
  338. penultimate;
  339. return smalltalk.send(smalltalk.send(self,"_last",[]),"_reverseTrapAt_put_",[penultimate,value]);
  340. })]);
  341. };
  342. return model;
  343. }
  344. }),
  345. smalltalk.SequenceableCollection);
  346. smalltalk.addMethod(
  347. "_reverseTrapAt_",
  348. smalltalk.method({
  349. selector: "reverseTrapAt:",
  350. fn: function (anObject){
  351. var self=this;
  352. var $1;
  353. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  354. return nil;
  355. })]);
  356. return $1;
  357. }
  358. }),
  359. smalltalk.String);
  360. smalltalk.addMethod(
  361. "_reverseTrapAt_put_",
  362. smalltalk.method({
  363. selector: "reverseTrapAt:put:",
  364. fn: function (anObject,value){
  365. var self=this;
  366. var $1;
  367. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  368. return $1;
  369. }
  370. }),
  371. smalltalk.String);
  372. smalltalk.addMethod(
  373. "_reverseTrapAt_",
  374. smalltalk.method({
  375. selector: "reverseTrapAt:",
  376. fn: function (anObject){
  377. var self=this;
  378. var $1;
  379. var $early={};
  380. try {
  381. $1=smalltalk.send((function(){
  382. return smalltalk.send(anObject,"_perform_",[self]);
  383. }),"_on_do_",[(smalltalk.MessageNotUnderstood || MessageNotUnderstood),(function(){
  384. throw $early=[nil];
  385. })]);
  386. return $1;
  387. }
  388. catch(e) {if(e===$early)return e[0]; throw e}
  389. }
  390. }),
  391. smalltalk.Symbol);
  392. smalltalk.addMethod(
  393. "_reverseTrapAt_put_",
  394. smalltalk.method({
  395. selector: "reverseTrapAt:put:",
  396. fn: function (anObject,value){
  397. var self=this;
  398. var $1;
  399. $1=smalltalk.send(anObject,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"__comma",[":"]),"_asSymbol",[]),[value]]);
  400. return $1;
  401. }
  402. }),
  403. smalltalk.Symbol);
  404. smalltalk.addMethod(
  405. "_reverseTrapAt_",
  406. smalltalk.method({
  407. selector: "reverseTrapAt:",
  408. fn: function (anObject){
  409. var self=this;
  410. var $1;
  411. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  412. return nil;
  413. })]);
  414. return $1;
  415. }
  416. }),
  417. smalltalk.Number);
  418. smalltalk.addMethod(
  419. "_reverseTrapAt_put_",
  420. smalltalk.method({
  421. selector: "reverseTrapAt:put:",
  422. fn: function (anObject,value){
  423. var self=this;
  424. var $1;
  425. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  426. return $1;
  427. }
  428. }),
  429. smalltalk.Number);