Trapped-Backend.deploy.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. var aPath;
  130. var lesser;
  131. aPath=smalltalk.send(each,"_second",[]);
  132. aPath;
  133. lesser=smalltalk.send(smalltalk.send(aPath,"_size",[]),"_min_",[smalltalk.send(path,"_size",[])]);
  134. lesser;
  135. $1=smalltalk.send(smalltalk.send(path,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser])]);
  136. if(smalltalk.assert($1)){
  137. smalltalk.send(each,"_at_put_",[(1),true]);
  138. needsToRun=true;
  139. return needsToRun;
  140. };
  141. })]);
  142. smalltalk.send(self,"_dirty_",[needsToRun]);
  143. return self}
  144. }),
  145. smalltalk.TrappedDispatcher);
  146. smalltalk.addMethod(
  147. "_dirty_",
  148. smalltalk.method({
  149. selector: "dirty:",
  150. fn: function (aBoolean){
  151. var self=this;
  152. if(smalltalk.assert(aBoolean)){
  153. smalltalk.send((function(){
  154. return smalltalk.send(self,"_run",[]);
  155. }),"_fork",[]);
  156. };
  157. return self}
  158. }),
  159. smalltalk.TrappedDispatcher);
  160. smalltalk.addMethod(
  161. "_run",
  162. smalltalk.method({
  163. selector: "run",
  164. fn: function (){
  165. var self=this;
  166. var $1;
  167. var needsClean;
  168. needsClean=false;
  169. smalltalk.send(self,"_do_",[(function(each){
  170. $1=smalltalk.send(each,"_first",[]);
  171. if(smalltalk.assert($1)){
  172. return smalltalk.send((function(){
  173. return smalltalk.send((function(){
  174. return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
  175. }),"_ensure_",[(function(){
  176. return smalltalk.send(each,"_at_put_",[(1),false]);
  177. })]);
  178. }),"_on_do_",[(smalltalk.TrappedUnwatch || TrappedUnwatch),(function(){
  179. smalltalk.send(each,"_at_put_",[(3),nil]);
  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('TrappedUnwatch', smalltalk.Error, [], 'Trapped-Backend');
  192. smalltalk.addMethod(
  193. "_reverseTrapAt_",
  194. smalltalk.method({
  195. selector: "reverseTrapAt:",
  196. fn: function (anObject){
  197. var self=this;
  198. return nil;
  199. }
  200. }),
  201. smalltalk.Object);
  202. smalltalk.addMethod(
  203. "_reverseTrapAt_put_",
  204. smalltalk.method({
  205. selector: "reverseTrapAt:put:",
  206. fn: function (anObject,value){
  207. var self=this;
  208. smalltalk.send(self,"_error_",[smalltalk.send(smalltalk.send("Trapped cannot put at ","__comma",[smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[])]),"__comma",[" type key."])]);
  209. return self}
  210. }),
  211. smalltalk.Object);
  212. smalltalk.addMethod(
  213. "_asEavModel",
  214. smalltalk.method({
  215. selector: "asEavModel",
  216. fn: function (){
  217. var self=this;
  218. var $1;
  219. var model;
  220. model=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  221. smalltalk.send(model,"_getBlock_",[(function(anObject){
  222. return smalltalk.send(self,"_inject_into_",[anObject,(function(soFar,segment){
  223. if(($receiver = soFar) == nil || $receiver == undefined){
  224. return soFar;
  225. } else {
  226. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  227. };
  228. })]);
  229. })]);
  230. $1=smalltalk.send(self,"_isEmpty",[]);
  231. if(! smalltalk.assert($1)){
  232. smalltalk.send(model,"_putBlock_",[(function(anObject,value){
  233. var penultimate;
  234. penultimate=smalltalk.send(smalltalk.send(self,"_allButLast",[]),"_inject_into_",[anObject,(function(soFar,segment){
  235. if(($receiver = soFar) == nil || $receiver == undefined){
  236. return soFar;
  237. } else {
  238. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  239. };
  240. })]);
  241. penultimate;
  242. return smalltalk.send(smalltalk.send(self,"_last",[]),"_reverseTrapAt_put_",[penultimate,value]);
  243. })]);
  244. };
  245. return model;
  246. }
  247. }),
  248. smalltalk.SequenceableCollection);
  249. smalltalk.addMethod(
  250. "_reverseTrapAt_",
  251. smalltalk.method({
  252. selector: "reverseTrapAt:",
  253. fn: function (anObject){
  254. var self=this;
  255. var $1;
  256. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  257. return nil;
  258. })]);
  259. return $1;
  260. }
  261. }),
  262. smalltalk.String);
  263. smalltalk.addMethod(
  264. "_reverseTrapAt_put_",
  265. smalltalk.method({
  266. selector: "reverseTrapAt:put:",
  267. fn: function (anObject,value){
  268. var self=this;
  269. var $1;
  270. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  271. return $1;
  272. }
  273. }),
  274. smalltalk.String);
  275. smalltalk.addMethod(
  276. "_reverseTrapAt_",
  277. smalltalk.method({
  278. selector: "reverseTrapAt:",
  279. fn: function (anObject){
  280. var self=this;
  281. var $1;
  282. var $early={};
  283. try {
  284. $1=smalltalk.send((function(){
  285. return smalltalk.send(anObject,"_perform_",[self]);
  286. }),"_on_do_",[(smalltalk.MessageNotUnderstood || MessageNotUnderstood),(function(){
  287. throw $early=[nil];
  288. })]);
  289. return $1;
  290. }
  291. catch(e) {if(e===$early)return e[0]; throw e}
  292. }
  293. }),
  294. smalltalk.Symbol);
  295. smalltalk.addMethod(
  296. "_reverseTrapAt_put_",
  297. smalltalk.method({
  298. selector: "reverseTrapAt:put:",
  299. fn: function (anObject,value){
  300. var self=this;
  301. var $1;
  302. $1=smalltalk.send(anObject,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"__comma",[":"]),"_asSymbol",[]),[value]]);
  303. return $1;
  304. }
  305. }),
  306. smalltalk.Symbol);
  307. smalltalk.addMethod(
  308. "_reverseTrapAt_",
  309. smalltalk.method({
  310. selector: "reverseTrapAt:",
  311. fn: function (anObject){
  312. var self=this;
  313. var $1;
  314. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  315. return nil;
  316. })]);
  317. return $1;
  318. }
  319. }),
  320. smalltalk.Number);
  321. smalltalk.addMethod(
  322. "_reverseTrapAt_put_",
  323. smalltalk.method({
  324. selector: "reverseTrapAt:put:",
  325. fn: function (anObject,value){
  326. var self=this;
  327. var $1;
  328. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  329. return $1;
  330. }
  331. }),
  332. smalltalk.Number);