Trapped-Backend.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. define(["amber/boot"
  2. //>>excludeStart("imports", pragmas.excludeImports);
  3. , "axxord/Axxord"
  4. //>>excludeEnd("imports");
  5. , "amber_core/Kernel-Objects", "axxord/Axxord"], function($boot
  6. //>>excludeStart("imports", pragmas.excludeImports);
  7. //>>excludeEnd("imports");
  8. ){"use strict";
  9. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  10. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  11. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  12. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  13. $core.addPackage("Trapped-Backend");
  14. $core.packages["Trapped-Backend"].innerEval = function (expr) { return eval(expr); };
  15. $core.packages["Trapped-Backend"].imports = ["axxord/Axxord"];
  16. $core.packages["Trapped-Backend"].transport = {"type":"amd","amdNamespace":"trapped"};
  17. $core.addClass("InterestedInTrapPath", $globals.AxonInterest, [], "Trapped-Backend");
  18. $core.addMethod(
  19. $core.method({
  20. selector: "accepts:",
  21. protocol: "testing",
  22. fn: function (anAspect){
  23. var self=this,$self=this;
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. return $core.withContext(function($ctx1) {
  26. //>>excludeEnd("ctx");
  27. var $2,$3,$1;
  28. $2=$recv(anAspect)._size();
  29. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  30. $ctx1.sendIdx["size"]=1;
  31. //>>excludeEnd("ctx");
  32. $3=$recv($self["@aspect"])._size();
  33. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  34. $ctx1.sendIdx["size"]=2;
  35. //>>excludeEnd("ctx");
  36. $1=$recv($2).__lt_eq($3);
  37. return $recv($1)._and_((function(){
  38. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  39. return $core.withContext(function($ctx2) {
  40. //>>excludeEnd("ctx");
  41. return $recv(anAspect).__eq($recv($self["@aspect"])._copyFrom_to_((1),$recv(anAspect)._size()));
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  44. //>>excludeEnd("ctx");
  45. }));
  46. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  47. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.InterestedInTrapPath)});
  48. //>>excludeEnd("ctx");
  49. },
  50. //>>excludeStart("ide", pragmas.excludeIdeData);
  51. args: ["anAspect"],
  52. source: "accepts: anAspect\x0a ^anAspect size <= aspect size and: [anAspect = (aspect copyFrom: 1 to: anAspect size)]",
  53. referencedClasses: [],
  54. //>>excludeEnd("ide");
  55. messageSends: ["and:", "<=", "size", "=", "copyFrom:to:"]
  56. }),
  57. $globals.InterestedInTrapPath);
  58. $core.addClass("InterestedInTrapPathSubtree", $globals.AxonInterest, [], "Trapped-Backend");
  59. $core.addMethod(
  60. $core.method({
  61. selector: "accepts:",
  62. protocol: "testing",
  63. fn: function (anAspect){
  64. var self=this,$self=this;
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. return $core.withContext(function($ctx1) {
  67. //>>excludeEnd("ctx");
  68. var $2,$3,$1,$5,$6,$4;
  69. $2=$recv(anAspect)._size();
  70. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  71. $ctx1.sendIdx["size"]=1;
  72. //>>excludeEnd("ctx");
  73. $3=$recv($self["@aspect"])._size();
  74. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  75. $ctx1.sendIdx["size"]=2;
  76. //>>excludeEnd("ctx");
  77. $1=$recv($2).__lt_eq($3);
  78. if($core.assert($1)){
  79. $5=$self["@aspect"];
  80. $6=$recv(anAspect)._size();
  81. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  82. $ctx1.sendIdx["size"]=3;
  83. //>>excludeEnd("ctx");
  84. $4=$recv($5)._copyFrom_to_((1),$6);
  85. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  86. $ctx1.sendIdx["copyFrom:to:"]=1;
  87. //>>excludeEnd("ctx");
  88. return $recv(anAspect).__eq($4);
  89. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  90. $ctx1.sendIdx["="]=1;
  91. //>>excludeEnd("ctx");
  92. } else {
  93. return $recv($self["@aspect"]).__eq($recv(anAspect)._copyFrom_to_((1),$recv($self["@aspect"])._size()));
  94. }
  95. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  96. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.InterestedInTrapPathSubtree)});
  97. //>>excludeEnd("ctx");
  98. },
  99. //>>excludeStart("ide", pragmas.excludeIdeData);
  100. args: ["anAspect"],
  101. source: "accepts: anAspect\x0a ^anAspect size <= aspect size\x0a\x09\x09ifTrue: [anAspect = (aspect copyFrom: 1 to: anAspect size)]\x0a\x09\x09ifFalse: [aspect = (anAspect copyFrom: 1 to: aspect size)]",
  102. referencedClasses: [],
  103. //>>excludeEnd("ide");
  104. messageSends: ["ifTrue:ifFalse:", "<=", "size", "=", "copyFrom:to:"]
  105. }),
  106. $globals.InterestedInTrapPathSubtree);
  107. $core.addClass("Isolator", $globals.Object, ["root"], "Trapped-Backend");
  108. $core.addMethod(
  109. $core.method({
  110. selector: "model:modify:",
  111. protocol: "action",
  112. fn: function (anEavModel,aBlock){
  113. var self=this,$self=this;
  114. var newValue;
  115. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  116. return $core.withContext(function($ctx1) {
  117. //>>excludeEnd("ctx");
  118. newValue=$recv(aBlock)._value_($recv(anEavModel)._on_(self));
  119. $recv(anEavModel)._on_put_(self,$recv(newValue)._deepCopy());
  120. return self;
  121. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  122. }, function($ctx1) {$ctx1.fill(self,"model:modify:",{anEavModel:anEavModel,aBlock:aBlock,newValue:newValue},$globals.Isolator)});
  123. //>>excludeEnd("ctx");
  124. },
  125. //>>excludeStart("ide", pragmas.excludeIdeData);
  126. args: ["anEavModel", "aBlock"],
  127. source: "model: anEavModel modify: aBlock\x0a\x0a| newValue |\x0anewValue := aBlock value: (anEavModel on: self).\x0aanEavModel on: self put: newValue deepCopy",
  128. referencedClasses: [],
  129. //>>excludeEnd("ide");
  130. messageSends: ["value:", "on:", "on:put:", "deepCopy"]
  131. }),
  132. $globals.Isolator);
  133. $core.addMethod(
  134. $core.method({
  135. selector: "model:read:",
  136. protocol: "action",
  137. fn: function (anEavModel,aBlock){
  138. var self=this,$self=this;
  139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  140. return $core.withContext(function($ctx1) {
  141. //>>excludeEnd("ctx");
  142. $recv(aBlock)._value_($recv($recv(anEavModel)._on_(self))._deepCopy());
  143. return self;
  144. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  145. }, function($ctx1) {$ctx1.fill(self,"model:read:",{anEavModel:anEavModel,aBlock:aBlock},$globals.Isolator)});
  146. //>>excludeEnd("ctx");
  147. },
  148. //>>excludeStart("ide", pragmas.excludeIdeData);
  149. args: ["anEavModel", "aBlock"],
  150. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  151. referencedClasses: [],
  152. //>>excludeEnd("ide");
  153. messageSends: ["value:", "deepCopy", "on:"]
  154. }),
  155. $globals.Isolator);
  156. $core.addMethod(
  157. $core.method({
  158. selector: "root",
  159. protocol: "accessing",
  160. fn: function (){
  161. var self=this,$self=this;
  162. return $self["@root"];
  163. },
  164. //>>excludeStart("ide", pragmas.excludeIdeData);
  165. args: [],
  166. source: "root\x0a\x0a^root",
  167. referencedClasses: [],
  168. //>>excludeEnd("ide");
  169. messageSends: []
  170. }),
  171. $globals.Isolator);
  172. $core.addMethod(
  173. $core.method({
  174. selector: "root:",
  175. protocol: "accessing",
  176. fn: function (anObject){
  177. var self=this,$self=this;
  178. $self["@root"]=anObject;
  179. return self;
  180. },
  181. //>>excludeStart("ide", pragmas.excludeIdeData);
  182. args: ["anObject"],
  183. source: "root: anObject\x0a\x0aroot := anObject",
  184. referencedClasses: [],
  185. //>>excludeEnd("ide");
  186. messageSends: []
  187. }),
  188. $globals.Isolator);
  189. $core.addMethod(
  190. $core.method({
  191. selector: "on:",
  192. protocol: "instance creation",
  193. fn: function (anObject){
  194. var self=this,$self=this;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. return $core.withContext(function($ctx1) {
  197. //>>excludeEnd("ctx");
  198. return $recv($self._new())._root_(anObject);
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},$globals.Isolator.a$cls)});
  201. //>>excludeEnd("ctx");
  202. },
  203. //>>excludeStart("ide", pragmas.excludeIdeData);
  204. args: ["anObject"],
  205. source: "on: anObject\x0a^self new root: anObject",
  206. referencedClasses: [],
  207. //>>excludeEnd("ide");
  208. messageSends: ["root:", "new"]
  209. }),
  210. $globals.Isolator.a$cls);
  211. $core.addClass("TrappedPosition", $globals.Object, ["path", "model"], "Trapped-Backend");
  212. $core.addMethod(
  213. $core.method({
  214. selector: "interestOn:block:",
  215. protocol: "private",
  216. fn: function (anAspect,aBlock){
  217. var self=this,$self=this;
  218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  219. return $core.withContext(function($ctx1) {
  220. //>>excludeEnd("ctx");
  221. var $1,$3,$2;
  222. $1=$recv($recv(anAspect)._notEmpty())._and_((function(){
  223. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  224. return $core.withContext(function($ctx2) {
  225. //>>excludeEnd("ctx");
  226. return $recv($recv(anAspect)._last())._isNil();
  227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  228. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  229. //>>excludeEnd("ctx");
  230. }));
  231. if($core.assert($1)){
  232. $3=$recv($globals.InterestedInTrapPathSubtree)._new();
  233. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  234. $ctx1.sendIdx["new"]=1;
  235. //>>excludeEnd("ctx");
  236. $2=$recv($3)._aspect_block_($recv(anAspect)._allButLast(),aBlock);
  237. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  238. $ctx1.sendIdx["aspect:block:"]=1;
  239. //>>excludeEnd("ctx");
  240. return $2;
  241. } else {
  242. return $recv($recv($globals.InterestedInTrapPath)._new())._aspect_block_(anAspect,aBlock);
  243. }
  244. return self;
  245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  246. }, function($ctx1) {$ctx1.fill(self,"interestOn:block:",{anAspect:anAspect,aBlock:aBlock},$globals.TrappedPosition)});
  247. //>>excludeEnd("ctx");
  248. },
  249. //>>excludeStart("ide", pragmas.excludeIdeData);
  250. args: ["anAspect", "aBlock"],
  251. source: "interestOn: anAspect block: aBlock\x0a\x09(anAspect notEmpty and: [ anAspect last isNil ])\x0a\x09\x09ifTrue: [ ^ InterestedInTrapPathSubtree new aspect: anAspect allButLast block: aBlock ]\x0a\x09\x09ifFalse: [ ^ InterestedInTrapPath new aspect: anAspect block: aBlock ]",
  252. referencedClasses: ["InterestedInTrapPathSubtree", "InterestedInTrapPath"],
  253. //>>excludeEnd("ide");
  254. messageSends: ["ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "aspect:block:", "new", "allButLast"]
  255. }),
  256. $globals.TrappedPosition);
  257. $core.addMethod(
  258. $core.method({
  259. selector: "model",
  260. protocol: "accessing",
  261. fn: function (){
  262. var self=this,$self=this;
  263. return $self["@model"];
  264. },
  265. //>>excludeStart("ide", pragmas.excludeIdeData);
  266. args: [],
  267. source: "model\x0a\x09^model",
  268. referencedClasses: [],
  269. //>>excludeEnd("ide");
  270. messageSends: []
  271. }),
  272. $globals.TrappedPosition);
  273. $core.addMethod(
  274. $core.method({
  275. selector: "modify:",
  276. protocol: "action",
  277. fn: function (aBlock){
  278. var self=this,$self=this;
  279. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  280. return $core.withContext(function($ctx1) {
  281. //>>excludeEnd("ctx");
  282. $recv($self._model())._axes_transform_($self._path(),aBlock);
  283. return self;
  284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  285. }, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},$globals.TrappedPosition)});
  286. //>>excludeEnd("ctx");
  287. },
  288. //>>excludeStart("ide", pragmas.excludeIdeData);
  289. args: ["aBlock"],
  290. source: "modify: aBlock\x0a\x09self model axes: self path transform: aBlock",
  291. referencedClasses: [],
  292. //>>excludeEnd("ide");
  293. messageSends: ["axes:transform:", "model", "path"]
  294. }),
  295. $globals.TrappedPosition);
  296. $core.addMethod(
  297. $core.method({
  298. selector: "path",
  299. protocol: "accessing",
  300. fn: function (){
  301. var self=this,$self=this;
  302. return $self["@path"];
  303. },
  304. //>>excludeStart("ide", pragmas.excludeIdeData);
  305. args: [],
  306. source: "path\x0a\x09^path",
  307. referencedClasses: [],
  308. //>>excludeEnd("ide");
  309. messageSends: []
  310. }),
  311. $globals.TrappedPosition);
  312. $core.addMethod(
  313. $core.method({
  314. selector: "path:model:",
  315. protocol: "accessing",
  316. fn: function (anArray,aTrappedMW){
  317. var self=this,$self=this;
  318. $self["@path"]=anArray;
  319. $self["@model"]=aTrappedMW;
  320. return self;
  321. },
  322. //>>excludeStart("ide", pragmas.excludeIdeData);
  323. args: ["anArray", "aTrappedMW"],
  324. source: "path: anArray model: aTrappedMW\x0a\x09path := anArray.\x0a model := aTrappedMW",
  325. referencedClasses: [],
  326. //>>excludeEnd("ide");
  327. messageSends: []
  328. }),
  329. $globals.TrappedPosition);
  330. $core.addMethod(
  331. $core.method({
  332. selector: "read:",
  333. protocol: "action",
  334. fn: function (aBlock){
  335. var self=this,$self=this;
  336. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  337. return $core.withContext(function($ctx1) {
  338. //>>excludeEnd("ctx");
  339. $recv($self._model())._axes_consume_($self._path(),aBlock);
  340. return self;
  341. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  342. }, function($ctx1) {$ctx1.fill(self,"read:",{aBlock:aBlock},$globals.TrappedPosition)});
  343. //>>excludeEnd("ctx");
  344. },
  345. //>>excludeStart("ide", pragmas.excludeIdeData);
  346. args: ["aBlock"],
  347. source: "read: aBlock\x0a\x09self model axes: self path consume: aBlock",
  348. referencedClasses: [],
  349. //>>excludeEnd("ide");
  350. messageSends: ["axes:consume:", "model", "path"]
  351. }),
  352. $globals.TrappedPosition);
  353. $core.addMethod(
  354. $core.method({
  355. selector: "watch:",
  356. protocol: "action",
  357. fn: function (aBlock){
  358. var self=this,$self=this;
  359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  360. return $core.withContext(function($ctx1) {
  361. //>>excludeEnd("ctx");
  362. $recv($recv($self._model())._registeredAxon())._addInterest_($self._interestOn_block_($self._path(),(function(){
  363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  364. return $core.withContext(function($ctx2) {
  365. //>>excludeEnd("ctx");
  366. return $self._read_(aBlock);
  367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  368. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  369. //>>excludeEnd("ctx");
  370. })));
  371. return self;
  372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  373. }, function($ctx1) {$ctx1.fill(self,"watch:",{aBlock:aBlock},$globals.TrappedPosition)});
  374. //>>excludeEnd("ctx");
  375. },
  376. //>>excludeStart("ide", pragmas.excludeIdeData);
  377. args: ["aBlock"],
  378. source: "watch: aBlock\x0a\x09self model registeredAxon addInterest: (self\x0a\x09\x09interestOn: self path\x0a\x09\x09block: [ self read: aBlock ])",
  379. referencedClasses: [],
  380. //>>excludeEnd("ide");
  381. messageSends: ["addInterest:", "registeredAxon", "model", "interestOn:block:", "path", "read:"]
  382. }),
  383. $globals.TrappedPosition);
  384. });