Trapped-Backend.deploy.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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('TrappedDispatcher', smalltalk.Object, [], 'Trapped-Backend');
  119. smalltalk.addMethod(
  120. "_changed_",
  121. smalltalk.method({
  122. selector: "changed:",
  123. fn: function (path){
  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_",[path]);
  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.TrappedDispatcher);
  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.TrappedDispatcher);
  154. smalltalk.addMethod(
  155. "_on_hook_",
  156. smalltalk.method({
  157. selector: "on:hook:",
  158. fn: function (path,aBlock){
  159. var self=this;
  160. smalltalk.send(self,"_add_",[smalltalk.send(smalltalk.send((smalltalk.TrappedSubscription || TrappedSubscription),"_path_action_",[path,aBlock]),"_flag",[])]);
  161. smalltalk.send(self,"_dirty_",[true]);
  162. return self}
  163. }),
  164. smalltalk.TrappedDispatcher);
  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.TrappedDispatcher);
  191. smalltalk.addClass('TrappedSubscription', smalltalk.Object, ['path', 'actionBlock', 'flagged'], 'Trapped-Backend');
  192. smalltalk.addMethod(
  193. "_accepts_",
  194. smalltalk.method({
  195. selector: "accepts:",
  196. fn: function (aPath){
  197. var self=this;
  198. var $1;
  199. var lesser;
  200. lesser=smalltalk.send(smalltalk.send(self["@path"],"_size",[]),"_min_",[smalltalk.send(aPath,"_size",[])]);
  201. $1=smalltalk.send(smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(self["@path"],"_copyFrom_to_",[(1),lesser])]);
  202. return $1;
  203. }
  204. }),
  205. smalltalk.TrappedSubscription);
  206. smalltalk.addMethod(
  207. "_flag",
  208. smalltalk.method({
  209. selector: "flag",
  210. fn: function (){
  211. var self=this;
  212. self["@flagged"]=true;
  213. return self}
  214. }),
  215. smalltalk.TrappedSubscription);
  216. smalltalk.addMethod(
  217. "_initialize",
  218. smalltalk.method({
  219. selector: "initialize",
  220. fn: function (){
  221. var self=this;
  222. smalltalk.send(self,"_initialize",[],smalltalk.Object);
  223. self["@path"]=nil;
  224. self["@actionBlock"]=nil;
  225. self["@flagged"]=false;
  226. return self}
  227. }),
  228. smalltalk.TrappedSubscription);
  229. smalltalk.addMethod(
  230. "_isEnabled",
  231. smalltalk.method({
  232. selector: "isEnabled",
  233. fn: function (){
  234. var self=this;
  235. var $1;
  236. $1=smalltalk.send(self["@actionBlock"],"_notNil",[]);
  237. return $1;
  238. }
  239. }),
  240. smalltalk.TrappedSubscription);
  241. smalltalk.addMethod(
  242. "_isFlagged",
  243. smalltalk.method({
  244. selector: "isFlagged",
  245. fn: function (){
  246. var self=this;
  247. return self["@flagged"];
  248. }
  249. }),
  250. smalltalk.TrappedSubscription);
  251. smalltalk.addMethod(
  252. "_path_actionBlock_",
  253. smalltalk.method({
  254. selector: "path:actionBlock:",
  255. fn: function (anArray,aBlock){
  256. var self=this;
  257. self["@path"]=anArray;
  258. self["@actionBlock"]=aBlock;
  259. return self}
  260. }),
  261. smalltalk.TrappedSubscription);
  262. smalltalk.addMethod(
  263. "_run",
  264. smalltalk.method({
  265. selector: "run",
  266. fn: function (){
  267. var self=this;
  268. smalltalk.send((function(){
  269. return smalltalk.send((function(){
  270. return smalltalk.send(self["@actionBlock"],"_value",[]);
  271. }),"_ensure_",[(function(){
  272. self["@flagged"]=false;
  273. return self["@flagged"];
  274. })]);
  275. }),"_on_do_",[(smalltalk.TrappedUnwatch || TrappedUnwatch),(function(){
  276. self["@actionBlock"]=nil;
  277. return self["@actionBlock"];
  278. })]);
  279. return self}
  280. }),
  281. smalltalk.TrappedSubscription);
  282. smalltalk.addMethod(
  283. "_new",
  284. smalltalk.method({
  285. selector: "new",
  286. fn: function (){
  287. var self=this;
  288. smalltalk.send(self,"_shouldNotImplement",[]);
  289. return self}
  290. }),
  291. smalltalk.TrappedSubscription.klass);
  292. smalltalk.addMethod(
  293. "_path_action_",
  294. smalltalk.method({
  295. selector: "path:action:",
  296. fn: function (anArray,aBlock){
  297. var self=this;
  298. var $1;
  299. $1=smalltalk.send(smalltalk.send(self,"_new",[],smalltalk.Object.klass),"_path_actionBlock_",[anArray,aBlock]);
  300. return $1;
  301. }
  302. }),
  303. smalltalk.TrappedSubscription.klass);
  304. smalltalk.addClass('TrappedUnwatch', smalltalk.Error, [], 'Trapped-Backend');
  305. smalltalk.addMethod(
  306. "_reverseTrapAt_",
  307. smalltalk.method({
  308. selector: "reverseTrapAt:",
  309. fn: function (anObject){
  310. var self=this;
  311. return nil;
  312. }
  313. }),
  314. smalltalk.Object);
  315. smalltalk.addMethod(
  316. "_reverseTrapAt_put_",
  317. smalltalk.method({
  318. selector: "reverseTrapAt:put:",
  319. fn: function (anObject,value){
  320. var self=this;
  321. smalltalk.send(self,"_error_",[smalltalk.send(smalltalk.send("Trapped cannot put at ","__comma",[smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[])]),"__comma",[" type key."])]);
  322. return self}
  323. }),
  324. smalltalk.Object);
  325. smalltalk.addMethod(
  326. "_asEavModel",
  327. smalltalk.method({
  328. selector: "asEavModel",
  329. fn: function (){
  330. var self=this;
  331. var $1;
  332. var model;
  333. model=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  334. smalltalk.send(model,"_getBlock_",[(function(anObject){
  335. return smalltalk.send(self,"_inject_into_",[anObject,(function(soFar,segment){
  336. if(($receiver = soFar) == nil || $receiver == undefined){
  337. return soFar;
  338. } else {
  339. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  340. };
  341. })]);
  342. })]);
  343. $1=smalltalk.send(self,"_isEmpty",[]);
  344. if(! smalltalk.assert($1)){
  345. smalltalk.send(model,"_putBlock_",[(function(anObject,value){
  346. var penultimate;
  347. penultimate=smalltalk.send(smalltalk.send(self,"_allButLast",[]),"_inject_into_",[anObject,(function(soFar,segment){
  348. if(($receiver = soFar) == nil || $receiver == undefined){
  349. return soFar;
  350. } else {
  351. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  352. };
  353. })]);
  354. penultimate;
  355. return smalltalk.send(smalltalk.send(self,"_last",[]),"_reverseTrapAt_put_",[penultimate,value]);
  356. })]);
  357. };
  358. return model;
  359. }
  360. }),
  361. smalltalk.SequenceableCollection);
  362. smalltalk.addMethod(
  363. "_reverseTrapAt_",
  364. smalltalk.method({
  365. selector: "reverseTrapAt:",
  366. fn: function (anObject){
  367. var self=this;
  368. var $1;
  369. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  370. return nil;
  371. })]);
  372. return $1;
  373. }
  374. }),
  375. smalltalk.String);
  376. smalltalk.addMethod(
  377. "_reverseTrapAt_put_",
  378. smalltalk.method({
  379. selector: "reverseTrapAt:put:",
  380. fn: function (anObject,value){
  381. var self=this;
  382. var $1;
  383. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  384. return $1;
  385. }
  386. }),
  387. smalltalk.String);
  388. smalltalk.addMethod(
  389. "_reverseTrapAt_",
  390. smalltalk.method({
  391. selector: "reverseTrapAt:",
  392. fn: function (anObject){
  393. var self=this;
  394. var $1;
  395. var $early={};
  396. try {
  397. $1=smalltalk.send((function(){
  398. return smalltalk.send(anObject,"_perform_",[self]);
  399. }),"_on_do_",[(smalltalk.MessageNotUnderstood || MessageNotUnderstood),(function(){
  400. throw $early=[nil];
  401. })]);
  402. return $1;
  403. }
  404. catch(e) {if(e===$early)return e[0]; throw e}
  405. }
  406. }),
  407. smalltalk.Symbol);
  408. smalltalk.addMethod(
  409. "_reverseTrapAt_put_",
  410. smalltalk.method({
  411. selector: "reverseTrapAt:put:",
  412. fn: function (anObject,value){
  413. var self=this;
  414. var $1;
  415. $1=smalltalk.send(anObject,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"__comma",[":"]),"_asSymbol",[]),[value]]);
  416. return $1;
  417. }
  418. }),
  419. smalltalk.Symbol);
  420. smalltalk.addMethod(
  421. "_reverseTrapAt_",
  422. smalltalk.method({
  423. selector: "reverseTrapAt:",
  424. fn: function (anObject){
  425. var self=this;
  426. var $1;
  427. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  428. return nil;
  429. })]);
  430. return $1;
  431. }
  432. }),
  433. smalltalk.Number);
  434. smalltalk.addMethod(
  435. "_reverseTrapAt_put_",
  436. smalltalk.method({
  437. selector: "reverseTrapAt:put:",
  438. fn: function (anObject,value){
  439. var self=this;
  440. var $1;
  441. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  442. return $1;
  443. }
  444. }),
  445. smalltalk.Number);