Trapped-Backend.deploy.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. "_on_hook_",
  162. smalltalk.method({
  163. selector: "on:hook:",
  164. fn: function (path,aBlock){
  165. var self=this;
  166. smalltalk.send(self,"_add_",[[true,path,aBlock]]);
  167. smalltalk.send(self,"_dirty_",[true]);
  168. return self}
  169. }),
  170. smalltalk.TrappedDispatcher);
  171. smalltalk.addMethod(
  172. "_run",
  173. smalltalk.method({
  174. selector: "run",
  175. fn: function (){
  176. var self=this;
  177. var $1;
  178. var needsClean;
  179. needsClean=false;
  180. smalltalk.send(self,"_do_",[(function(each){
  181. $1=smalltalk.send(each,"_first",[]);
  182. if(smalltalk.assert($1)){
  183. return smalltalk.send((function(){
  184. return smalltalk.send((function(){
  185. return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
  186. }),"_ensure_",[(function(){
  187. return smalltalk.send(each,"_at_put_",[(1),false]);
  188. })]);
  189. }),"_on_do_",[(smalltalk.TrappedUnwatch || TrappedUnwatch),(function(){
  190. smalltalk.send(each,"_at_put_",[(3),nil]);
  191. needsClean=true;
  192. return needsClean;
  193. })]);
  194. };
  195. })]);
  196. if(smalltalk.assert(needsClean)){
  197. smalltalk.send(self,"_clean",[]);
  198. };
  199. return self}
  200. }),
  201. smalltalk.TrappedDispatcher);
  202. smalltalk.addClass('TrappedUnwatch', smalltalk.Error, [], 'Trapped-Backend');
  203. smalltalk.addMethod(
  204. "_reverseTrapAt_",
  205. smalltalk.method({
  206. selector: "reverseTrapAt:",
  207. fn: function (anObject){
  208. var self=this;
  209. return nil;
  210. }
  211. }),
  212. smalltalk.Object);
  213. smalltalk.addMethod(
  214. "_reverseTrapAt_put_",
  215. smalltalk.method({
  216. selector: "reverseTrapAt:put:",
  217. fn: function (anObject,value){
  218. var self=this;
  219. smalltalk.send(self,"_error_",[smalltalk.send(smalltalk.send("Trapped cannot put at ","__comma",[smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[])]),"__comma",[" type key."])]);
  220. return self}
  221. }),
  222. smalltalk.Object);
  223. smalltalk.addMethod(
  224. "_asEavModel",
  225. smalltalk.method({
  226. selector: "asEavModel",
  227. fn: function (){
  228. var self=this;
  229. var $1;
  230. var model;
  231. model=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  232. smalltalk.send(model,"_getBlock_",[(function(anObject){
  233. return smalltalk.send(self,"_inject_into_",[anObject,(function(soFar,segment){
  234. if(($receiver = soFar) == nil || $receiver == undefined){
  235. return soFar;
  236. } else {
  237. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  238. };
  239. })]);
  240. })]);
  241. $1=smalltalk.send(self,"_isEmpty",[]);
  242. if(! smalltalk.assert($1)){
  243. smalltalk.send(model,"_putBlock_",[(function(anObject,value){
  244. var penultimate;
  245. penultimate=smalltalk.send(smalltalk.send(self,"_allButLast",[]),"_inject_into_",[anObject,(function(soFar,segment){
  246. if(($receiver = soFar) == nil || $receiver == undefined){
  247. return soFar;
  248. } else {
  249. return smalltalk.send(segment,"_reverseTrapAt_",[soFar]);
  250. };
  251. })]);
  252. penultimate;
  253. return smalltalk.send(smalltalk.send(self,"_last",[]),"_reverseTrapAt_put_",[penultimate,value]);
  254. })]);
  255. };
  256. return model;
  257. }
  258. }),
  259. smalltalk.SequenceableCollection);
  260. smalltalk.addMethod(
  261. "_reverseTrapAt_",
  262. smalltalk.method({
  263. selector: "reverseTrapAt:",
  264. fn: function (anObject){
  265. var self=this;
  266. var $1;
  267. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  268. return nil;
  269. })]);
  270. return $1;
  271. }
  272. }),
  273. smalltalk.String);
  274. smalltalk.addMethod(
  275. "_reverseTrapAt_put_",
  276. smalltalk.method({
  277. selector: "reverseTrapAt:put:",
  278. fn: function (anObject,value){
  279. var self=this;
  280. var $1;
  281. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  282. return $1;
  283. }
  284. }),
  285. smalltalk.String);
  286. smalltalk.addMethod(
  287. "_reverseTrapAt_",
  288. smalltalk.method({
  289. selector: "reverseTrapAt:",
  290. fn: function (anObject){
  291. var self=this;
  292. var $1;
  293. var $early={};
  294. try {
  295. $1=smalltalk.send((function(){
  296. return smalltalk.send(anObject,"_perform_",[self]);
  297. }),"_on_do_",[(smalltalk.MessageNotUnderstood || MessageNotUnderstood),(function(){
  298. throw $early=[nil];
  299. })]);
  300. return $1;
  301. }
  302. catch(e) {if(e===$early)return e[0]; throw e}
  303. }
  304. }),
  305. smalltalk.Symbol);
  306. smalltalk.addMethod(
  307. "_reverseTrapAt_put_",
  308. smalltalk.method({
  309. selector: "reverseTrapAt:put:",
  310. fn: function (anObject,value){
  311. var self=this;
  312. var $1;
  313. $1=smalltalk.send(anObject,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"__comma",[":"]),"_asSymbol",[]),[value]]);
  314. return $1;
  315. }
  316. }),
  317. smalltalk.Symbol);
  318. smalltalk.addMethod(
  319. "_reverseTrapAt_",
  320. smalltalk.method({
  321. selector: "reverseTrapAt:",
  322. fn: function (anObject){
  323. var self=this;
  324. var $1;
  325. $1=smalltalk.send(anObject,"_at_ifAbsent_",[self,(function(){
  326. return nil;
  327. })]);
  328. return $1;
  329. }
  330. }),
  331. smalltalk.Number);
  332. smalltalk.addMethod(
  333. "_reverseTrapAt_put_",
  334. smalltalk.method({
  335. selector: "reverseTrapAt:put:",
  336. fn: function (anObject,value){
  337. var self=this;
  338. var $1;
  339. $1=smalltalk.send(anObject,"_at_put_",[self,value]);
  340. return $1;
  341. }
  342. }),
  343. smalltalk.Number);