1
0

Helios-Helpers.js 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  1. define(["amber/boot", "require", "amber/core/Kernel-Objects"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Helios-Helpers");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"helios"};
  6. $core.addClass("HLClassifier", $globals.Object, ["next", "method"], "Helios-Helpers");
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.HLClassifier.comment="I am an abstract class implementing a link in a `chain of responsibility` pattern.\x0a\x0aSubclasses are in charge of classifying a method according to multiple strategies.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "classify",
  13. protocol: "protocol",
  14. fn: function (){
  15. var self=this,$self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. var $1,$2,$receiver;
  20. $1=$self._next();
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. $ctx1.sendIdx["next"]=1;
  23. //>>excludeEnd("ctx");
  24. if(($receiver = $1) == null || $receiver.a$nil){
  25. return false;
  26. } else {
  27. $1;
  28. }
  29. $2=$self._doClassify();
  30. if($core.assert($2)){
  31. return true;
  32. } else {
  33. return $recv($self._next())._classify();
  34. }
  35. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  36. }, function($ctx1) {$ctx1.fill(self,"classify",{})});
  37. //>>excludeEnd("ctx");
  38. },
  39. //>>excludeStart("ide", pragmas.excludeIdeData);
  40. args: [],
  41. source: "classify\x0a\x09self next ifNil: [ ^ false ].\x0a\x09\x0a\x09^ self doClassify\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: [ self next classify ]",
  42. referencedClasses: [],
  43. //>>excludeEnd("ide");
  44. pragmas: [],
  45. messageSends: ["ifNil:", "next", "ifTrue:ifFalse:", "doClassify", "classify"]
  46. }),
  47. $globals.HLClassifier);
  48. $core.addMethod(
  49. $core.method({
  50. selector: "doClassify",
  51. protocol: "private",
  52. fn: function (){
  53. var self=this,$self=this;
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. return $core.withContext(function($ctx1) {
  56. //>>excludeEnd("ctx");
  57. $self._subclassResponsibility();
  58. return self;
  59. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  60. }, function($ctx1) {$ctx1.fill(self,"doClassify",{})});
  61. //>>excludeEnd("ctx");
  62. },
  63. //>>excludeStart("ide", pragmas.excludeIdeData);
  64. args: [],
  65. source: "doClassify\x0a\x09self subclassResponsibility",
  66. referencedClasses: [],
  67. //>>excludeEnd("ide");
  68. pragmas: [],
  69. messageSends: ["subclassResponsibility"]
  70. }),
  71. $globals.HLClassifier);
  72. $core.addMethod(
  73. $core.method({
  74. selector: "method",
  75. protocol: "accessing",
  76. fn: function (){
  77. var self=this,$self=this;
  78. return $self.method;
  79. },
  80. //>>excludeStart("ide", pragmas.excludeIdeData);
  81. args: [],
  82. source: "method\x0a\x09^ method",
  83. referencedClasses: [],
  84. //>>excludeEnd("ide");
  85. pragmas: [],
  86. messageSends: []
  87. }),
  88. $globals.HLClassifier);
  89. $core.addMethod(
  90. $core.method({
  91. selector: "method:",
  92. protocol: "accessing",
  93. fn: function (anObject){
  94. var self=this,$self=this;
  95. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  96. return $core.withContext(function($ctx1) {
  97. //>>excludeEnd("ctx");
  98. var $1,$receiver;
  99. $self.method=anObject;
  100. $1=$self._next();
  101. if(($receiver = $1) == null || $receiver.a$nil){
  102. $1;
  103. } else {
  104. var nextLink;
  105. nextLink=$receiver;
  106. $recv(nextLink)._method_(anObject);
  107. }
  108. return self;
  109. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  110. }, function($ctx1) {$ctx1.fill(self,"method:",{anObject:anObject})});
  111. //>>excludeEnd("ctx");
  112. },
  113. //>>excludeStart("ide", pragmas.excludeIdeData);
  114. args: ["anObject"],
  115. source: "method: anObject\x0a\x09method := anObject.\x0a\x09self next\x0a\x09\x09ifNotNil: [ :nextLink | nextLink method: anObject ]",
  116. referencedClasses: [],
  117. //>>excludeEnd("ide");
  118. pragmas: [],
  119. messageSends: ["ifNotNil:", "next", "method:"]
  120. }),
  121. $globals.HLClassifier);
  122. $core.addMethod(
  123. $core.method({
  124. selector: "next",
  125. protocol: "accessing",
  126. fn: function (){
  127. var self=this,$self=this;
  128. return $self.next;
  129. },
  130. //>>excludeStart("ide", pragmas.excludeIdeData);
  131. args: [],
  132. source: "next\x0a\x09^ next",
  133. referencedClasses: [],
  134. //>>excludeEnd("ide");
  135. pragmas: [],
  136. messageSends: []
  137. }),
  138. $globals.HLClassifier);
  139. $core.addMethod(
  140. $core.method({
  141. selector: "next:",
  142. protocol: "accessing",
  143. fn: function (anObject){
  144. var self=this,$self=this;
  145. $self.next=anObject;
  146. return self;
  147. },
  148. //>>excludeStart("ide", pragmas.excludeIdeData);
  149. args: ["anObject"],
  150. source: "next: anObject\x0a\x09next := anObject",
  151. referencedClasses: [],
  152. //>>excludeEnd("ide");
  153. pragmas: [],
  154. messageSends: []
  155. }),
  156. $globals.HLClassifier);
  157. $core.addClass("HLAccessorClassifier", $globals.HLClassifier, [], "Helios-Helpers");
  158. //>>excludeStart("ide", pragmas.excludeIdeData);
  159. $globals.HLAccessorClassifier.comment="I am a classifier checking the method selector matches an instance variable name.";
  160. //>>excludeEnd("ide");
  161. $core.addMethod(
  162. $core.method({
  163. selector: "doClassify",
  164. protocol: "private",
  165. fn: function (){
  166. var self=this,$self=this;
  167. var names,selector;
  168. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  169. return $core.withContext(function($ctx1) {
  170. //>>excludeEnd("ctx");
  171. var $1,$2;
  172. names=$recv($recv($self.method)._origin())._allInstanceVariableNames();
  173. selector=$recv($self.method)._selector();
  174. $1=$recv($recv(selector)._last()).__eq(":");
  175. if($core.assert($1)){
  176. selector=$recv(selector)._allButLast();
  177. selector;
  178. }
  179. $2=$recv(names)._includes_(selector);
  180. if(!$core.assert($2)){
  181. return false;
  182. }
  183. $recv($self.method)._protocol_("accessing");
  184. return true;
  185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  186. }, function($ctx1) {$ctx1.fill(self,"doClassify",{names:names,selector:selector})});
  187. //>>excludeEnd("ctx");
  188. },
  189. //>>excludeStart("ide", pragmas.excludeIdeData);
  190. args: [],
  191. source: "doClassify\x0a\x09| names selector |\x0a\x09\x0a\x09names := method origin allInstanceVariableNames.\x0a\x09selector := method selector.\x0a\x09\x0a\x09(selector last = ':')\x0a\x09\x09ifTrue: [ \x22selector might be a setter\x22\x0a\x09\x09\x09selector := selector allButLast ].\x0a\x09\x0a\x09(names includes: selector)\x0a\x09\x09ifFalse: [ ^ false ].\x0a\x09\x09\x0a\x09method protocol: 'accessing'.\x0a\x09^ true.",
  192. referencedClasses: [],
  193. //>>excludeEnd("ide");
  194. pragmas: [],
  195. messageSends: ["allInstanceVariableNames", "origin", "selector", "ifTrue:", "=", "last", "allButLast", "ifFalse:", "includes:", "protocol:"]
  196. }),
  197. $globals.HLAccessorClassifier);
  198. $core.addClass("HLImplementorClassifier", $globals.HLClassifier, [], "Helios-Helpers");
  199. //>>excludeStart("ide", pragmas.excludeIdeData);
  200. $globals.HLImplementorClassifier.comment="I am a classifier checking the other implementations of the same selector and choose the protocol the most populated.";
  201. //>>excludeEnd("ide");
  202. $core.addMethod(
  203. $core.method({
  204. selector: "doClassify",
  205. protocol: "private",
  206. fn: function (){
  207. var self=this,$self=this;
  208. var currentClass;
  209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  210. return $core.withContext(function($ctx1) {
  211. //>>excludeEnd("ctx");
  212. var $1,$3,$4,$2;
  213. var $early={};
  214. try {
  215. currentClass=$recv($self.method)._origin();
  216. $recv((function(){
  217. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  218. return $core.withContext(function($ctx2) {
  219. //>>excludeEnd("ctx");
  220. $1=$recv(currentClass)._superclass();
  221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  222. $ctx2.sendIdx["superclass"]=1;
  223. //>>excludeEnd("ctx");
  224. return $recv($1)._isNil();
  225. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  226. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  227. //>>excludeEnd("ctx");
  228. }))._whileFalse_((function(){
  229. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  230. return $core.withContext(function($ctx2) {
  231. //>>excludeEnd("ctx");
  232. currentClass=$recv(currentClass)._superclass();
  233. $3=currentClass;
  234. $4=$recv($self.method)._selector();
  235. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  236. $ctx2.sendIdx["selector"]=1;
  237. //>>excludeEnd("ctx");
  238. $2=$recv($3)._includesSelector_($4);
  239. if($core.assert($2)){
  240. $recv($self.method)._protocol_($recv($recv(currentClass).__gt_gt($recv($self.method)._selector()))._protocol());
  241. throw $early=[true];
  242. }
  243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  244. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  245. //>>excludeEnd("ctx");
  246. }));
  247. return false;
  248. }
  249. catch(e) {if(e===$early)return e[0]; throw e}
  250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  251. }, function($ctx1) {$ctx1.fill(self,"doClassify",{currentClass:currentClass})});
  252. //>>excludeEnd("ctx");
  253. },
  254. //>>excludeStart("ide", pragmas.excludeIdeData);
  255. args: [],
  256. source: "doClassify\x0a\x09| currentClass |\x0a\x09currentClass := method origin.\x0a\x09\x0a\x09[ currentClass superclass isNil ] whileFalse: [\x0a\x09\x09currentClass := currentClass superclass.\x0a\x09\x09(currentClass includesSelector: method selector)\x0a\x09\x09\x09ifTrue: [ \x0a\x09\x09\x09\x09method protocol: (currentClass >> method selector) protocol.\x0a\x09\x09\x09\x09^ true ]].\x0a\x09\x0a\x09^ false.",
  257. referencedClasses: [],
  258. //>>excludeEnd("ide");
  259. pragmas: [],
  260. messageSends: ["origin", "whileFalse:", "isNil", "superclass", "ifTrue:", "includesSelector:", "selector", "protocol:", "protocol", ">>"]
  261. }),
  262. $globals.HLImplementorClassifier);
  263. $core.addClass("HLPrefixClassifier", $globals.HLClassifier, ["prefixMapping"], "Helios-Helpers");
  264. //>>excludeStart("ide", pragmas.excludeIdeData);
  265. $globals.HLPrefixClassifier.comment="I am classifier checking the method selector to know if it begins with a known prefix.";
  266. //>>excludeEnd("ide");
  267. $core.addMethod(
  268. $core.method({
  269. selector: "buildPrefixDictionary",
  270. protocol: "initialization",
  271. fn: function (){
  272. var self=this,$self=this;
  273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  274. return $core.withContext(function($ctx1) {
  275. //>>excludeEnd("ctx");
  276. var $1;
  277. $self.prefixMapping=$recv($globals.Dictionary)._new();
  278. $1=$self.prefixMapping;
  279. $recv($1)._at_put_("test","tests");
  280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  281. $ctx1.sendIdx["at:put:"]=1;
  282. //>>excludeEnd("ctx");
  283. $recv($1)._at_put_("bench","benchmarking");
  284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  285. $ctx1.sendIdx["at:put:"]=2;
  286. //>>excludeEnd("ctx");
  287. $recv($1)._at_put_("copy","copying");
  288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  289. $ctx1.sendIdx["at:put:"]=3;
  290. //>>excludeEnd("ctx");
  291. $recv($1)._at_put_("initialize","initialization");
  292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  293. $ctx1.sendIdx["at:put:"]=4;
  294. //>>excludeEnd("ctx");
  295. $recv($1)._at_put_("accept","visitor");
  296. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  297. $ctx1.sendIdx["at:put:"]=5;
  298. //>>excludeEnd("ctx");
  299. $recv($1)._at_put_("visit","visitor");
  300. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  301. $ctx1.sendIdx["at:put:"]=6;
  302. //>>excludeEnd("ctx");
  303. $recv($1)._at_put_("signal","signalling");
  304. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  305. $ctx1.sendIdx["at:put:"]=7;
  306. //>>excludeEnd("ctx");
  307. $recv($1)._at_put_("parse","parsing");
  308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  309. $ctx1.sendIdx["at:put:"]=8;
  310. //>>excludeEnd("ctx");
  311. $recv($1)._at_put_("add","adding");
  312. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  313. $ctx1.sendIdx["at:put:"]=9;
  314. //>>excludeEnd("ctx");
  315. $recv($1)._at_put_("is","testing");
  316. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  317. $ctx1.sendIdx["at:put:"]=10;
  318. //>>excludeEnd("ctx");
  319. $recv($1)._at_put_("as","converting");
  320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  321. $ctx1.sendIdx["at:put:"]=11;
  322. //>>excludeEnd("ctx");
  323. $recv($1)._at_put_("new","instance creation");
  324. return self;
  325. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  326. }, function($ctx1) {$ctx1.fill(self,"buildPrefixDictionary",{})});
  327. //>>excludeEnd("ctx");
  328. },
  329. //>>excludeStart("ide", pragmas.excludeIdeData);
  330. args: [],
  331. source: "buildPrefixDictionary\x0a\x09prefixMapping := Dictionary new.\x0a\x09prefixMapping \x0a\x09\x09at: 'test' put: 'tests';\x0a\x09 \x09at: 'bench' put: 'benchmarking';\x0a\x09 \x09at: 'copy' put: 'copying';\x0a\x09\x09at: 'initialize' put: 'initialization';\x0a\x09\x09at: 'accept' put: 'visitor';\x0a\x09\x09at: 'visit' put: 'visitor';\x0a\x09\x09at: 'signal' put: 'signalling';\x0a\x09\x09at: 'parse' put: 'parsing';\x0a\x09\x09at: 'add' put: 'adding';\x0a\x09\x09at: 'is' put: 'testing';\x0a\x09\x09at: 'as' put: 'converting';\x0a\x09\x09at: 'new' put: 'instance creation'.",
  332. referencedClasses: ["Dictionary"],
  333. //>>excludeEnd("ide");
  334. pragmas: [],
  335. messageSends: ["new", "at:put:"]
  336. }),
  337. $globals.HLPrefixClassifier);
  338. $core.addMethod(
  339. $core.method({
  340. selector: "doClassify",
  341. protocol: "private",
  342. fn: function (){
  343. var self=this,$self=this;
  344. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  345. return $core.withContext(function($ctx1) {
  346. //>>excludeEnd("ctx");
  347. var $1;
  348. var $early={};
  349. try {
  350. $recv($self.prefixMapping)._keysAndValuesDo_((function(prefix,protocol){
  351. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  352. return $core.withContext(function($ctx2) {
  353. //>>excludeEnd("ctx");
  354. $1=$recv($recv($self.method)._selector())._beginsWith_(prefix);
  355. if($core.assert($1)){
  356. $recv($self.method)._protocol_(protocol);
  357. throw $early=[true];
  358. }
  359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  360. }, function($ctx2) {$ctx2.fillBlock({prefix:prefix,protocol:protocol},$ctx1,1)});
  361. //>>excludeEnd("ctx");
  362. }));
  363. return false;
  364. }
  365. catch(e) {if(e===$early)return e[0]; throw e}
  366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  367. }, function($ctx1) {$ctx1.fill(self,"doClassify",{})});
  368. //>>excludeEnd("ctx");
  369. },
  370. //>>excludeStart("ide", pragmas.excludeIdeData);
  371. args: [],
  372. source: "doClassify\x0a\x09prefixMapping keysAndValuesDo: [ :prefix :protocol |\x0a\x09\x09(method selector beginsWith: prefix)\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09method protocol: protocol.\x0a\x09\x09\x09\x09^ true ]].\x0a\x09^ false.",
  373. referencedClasses: [],
  374. //>>excludeEnd("ide");
  375. pragmas: [],
  376. messageSends: ["keysAndValuesDo:", "ifTrue:", "beginsWith:", "selector", "protocol:"]
  377. }),
  378. $globals.HLPrefixClassifier);
  379. $core.addMethod(
  380. $core.method({
  381. selector: "initialize",
  382. protocol: "initialization",
  383. fn: function (){
  384. var self=this,$self=this;
  385. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  386. return $core.withContext(function($ctx1) {
  387. //>>excludeEnd("ctx");
  388. (
  389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  390. $ctx1.supercall = true,
  391. //>>excludeEnd("ctx");
  392. ($globals.HLPrefixClassifier.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  393. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  394. $ctx1.supercall = false;
  395. //>>excludeEnd("ctx");;
  396. $self._buildPrefixDictionary();
  397. return self;
  398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  399. }, function($ctx1) {$ctx1.fill(self,"initialize",{})});
  400. //>>excludeEnd("ctx");
  401. },
  402. //>>excludeStart("ide", pragmas.excludeIdeData);
  403. args: [],
  404. source: "initialize\x0a\x09super initialize.\x0a\x0a\x09self buildPrefixDictionary",
  405. referencedClasses: [],
  406. //>>excludeEnd("ide");
  407. pragmas: [],
  408. messageSends: ["initialize", "buildPrefixDictionary"]
  409. }),
  410. $globals.HLPrefixClassifier);
  411. $core.addClass("HLSuperclassClassifier", $globals.HLClassifier, [], "Helios-Helpers");
  412. //>>excludeStart("ide", pragmas.excludeIdeData);
  413. $globals.HLSuperclassClassifier.comment="I am a classifier checking the superclass chain to find a matching selector.";
  414. //>>excludeEnd("ide");
  415. $core.addMethod(
  416. $core.method({
  417. selector: "doClassify",
  418. protocol: "private",
  419. fn: function (){
  420. var self=this,$self=this;
  421. var protocolBag,methods,protocolToUse,counter;
  422. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  423. return $core.withContext(function($ctx1) {
  424. //>>excludeEnd("ctx");
  425. var $2,$1,$4,$3,$5;
  426. var $early={};
  427. try {
  428. protocolBag=$recv($globals.Dictionary)._new();
  429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  430. $ctx1.sendIdx["new"]=1;
  431. //>>excludeEnd("ctx");
  432. methods=$recv($recv($globals.HLReferencesModel)._new())._implementorsOf_($recv($self.method)._selector());
  433. $recv(methods)._ifEmpty_ifNotEmpty_((function(){
  434. throw $early=[false];
  435. }),(function(){
  436. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  437. return $core.withContext(function($ctx2) {
  438. //>>excludeEnd("ctx");
  439. return $recv(methods)._do_((function(aMethod){
  440. var protocol;
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. return $core.withContext(function($ctx3) {
  443. //>>excludeEnd("ctx");
  444. protocol=$recv($recv(aMethod)._method())._protocol();
  445. $2=$recv($self.method)._origin();
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. $ctx3.sendIdx["origin"]=1;
  448. //>>excludeEnd("ctx");
  449. $1=$recv($2).__eq($recv(aMethod)._origin());
  450. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  451. $ctx3.sendIdx["="]=1;
  452. //>>excludeEnd("ctx");
  453. if(!$core.assert($1)){
  454. $4=$recv($recv(protocol)._first()).__eq("*");
  455. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  456. $ctx3.sendIdx["="]=2;
  457. //>>excludeEnd("ctx");
  458. $3=$recv($4)._or_((function(){
  459. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  460. return $core.withContext(function($ctx4) {
  461. //>>excludeEnd("ctx");
  462. return $recv(protocol).__eq($recv($self.method)._defaultProtocol());
  463. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  464. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)});
  465. //>>excludeEnd("ctx");
  466. }));
  467. if(!$core.assert($3)){
  468. return $recv(protocolBag)._at_put_(protocol,$recv($recv(protocolBag)._at_ifAbsent_(protocol,(function(){
  469. return (0);
  470. }))).__plus((1)));
  471. }
  472. }
  473. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  474. }, function($ctx3) {$ctx3.fillBlock({aMethod:aMethod,protocol:protocol},$ctx2,3)});
  475. //>>excludeEnd("ctx");
  476. }));
  477. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  478. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  479. //>>excludeEnd("ctx");
  480. }));
  481. $recv(protocolBag)._ifEmpty_((function(){
  482. throw $early=[false];
  483. }));
  484. protocolToUse=nil;
  485. counter=(0);
  486. $recv(protocolBag)._keysAndValuesDo_((function(key,value){
  487. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  488. return $core.withContext(function($ctx2) {
  489. //>>excludeEnd("ctx");
  490. $5=$recv(value).__gt(counter);
  491. if($core.assert($5)){
  492. counter=value;
  493. protocolToUse=key;
  494. return protocolToUse;
  495. }
  496. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  497. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,9)});
  498. //>>excludeEnd("ctx");
  499. }));
  500. $recv($self.method)._protocol_(protocolToUse);
  501. return true;
  502. }
  503. catch(e) {if(e===$early)return e[0]; throw e}
  504. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  505. }, function($ctx1) {$ctx1.fill(self,"doClassify",{protocolBag:protocolBag,methods:methods,protocolToUse:protocolToUse,counter:counter})});
  506. //>>excludeEnd("ctx");
  507. },
  508. //>>excludeStart("ide", pragmas.excludeIdeData);
  509. args: [],
  510. source: "doClassify\x0a\x09| protocolBag methods protocolToUse counter |\x0a\x09\x0a\x09protocolBag := Dictionary new.\x0a\x09methods := HLReferencesModel new implementorsOf: method selector.\x0a\x09methods\x0a\x09\x09ifEmpty: [ ^ false ]\x0a\x09\x09ifNotEmpty: [\x0a\x09\x09\x09methods \x0a\x09\x09\x09\x09do: [ :aMethod || protocol |\x0a\x09\x09\x09\x09\x09protocol := aMethod method protocol.\x0a\x09\x09\x09\x09\x09(method origin = aMethod origin)\x0a\x09\x09\x09\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09\x09\x09((protocol first = '*') or: [ protocol = method defaultProtocol ])\x0a\x09\x09\x09\x09\x09\x09\x09ifFalse: [ \x0a\x09\x09\x09\x09\x09\x09\x09\x09protocolBag \x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09at: protocol \x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09put: (protocolBag at: protocol ifAbsent: [ 0 ]) + 1 ] ] ] ].\x0a\x09\x09\x09\x0a\x09protocolBag ifEmpty: [ ^ false ].\x0a\x09protocolToUse := nil.\x0a\x09counter := 0.\x0a\x09protocolBag keysAndValuesDo: [ :key :value | value > counter \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09counter := value.\x0a\x09\x09\x09protocolToUse := key ] ].\x0a\x09method protocol: protocolToUse.\x0a\x09^ true",
  511. referencedClasses: ["Dictionary", "HLReferencesModel"],
  512. //>>excludeEnd("ide");
  513. pragmas: [],
  514. messageSends: ["new", "implementorsOf:", "selector", "ifEmpty:ifNotEmpty:", "do:", "protocol", "method", "ifFalse:", "=", "origin", "or:", "first", "defaultProtocol", "at:put:", "+", "at:ifAbsent:", "ifEmpty:", "keysAndValuesDo:", "ifTrue:", ">", "protocol:"]
  515. }),
  516. $globals.HLSuperclassClassifier);
  517. $core.addClass("HLGenerationOutput", $globals.Object, ["sourceCodes", "protocol", "targetClass"], "Helios-Helpers");
  518. //>>excludeStart("ide", pragmas.excludeIdeData);
  519. $globals.HLGenerationOutput.comment="I am a simple data object used to store the result of a generation process.";
  520. //>>excludeEnd("ide");
  521. $core.addMethod(
  522. $core.method({
  523. selector: "addSourceCode:",
  524. protocol: "protocol",
  525. fn: function (aString){
  526. var self=this,$self=this;
  527. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  528. return $core.withContext(function($ctx1) {
  529. //>>excludeEnd("ctx");
  530. $recv($self.sourceCodes)._add_(aString);
  531. return self;
  532. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  533. }, function($ctx1) {$ctx1.fill(self,"addSourceCode:",{aString:aString})});
  534. //>>excludeEnd("ctx");
  535. },
  536. //>>excludeStart("ide", pragmas.excludeIdeData);
  537. args: ["aString"],
  538. source: "addSourceCode: aString\x0a\x09sourceCodes add: aString",
  539. referencedClasses: [],
  540. //>>excludeEnd("ide");
  541. pragmas: [],
  542. messageSends: ["add:"]
  543. }),
  544. $globals.HLGenerationOutput);
  545. $core.addMethod(
  546. $core.method({
  547. selector: "compile",
  548. protocol: "protocol",
  549. fn: function (){
  550. var self=this,$self=this;
  551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  552. return $core.withContext(function($ctx1) {
  553. //>>excludeEnd("ctx");
  554. var $1;
  555. $recv($self.sourceCodes)._do_((function(methodSourceCode){
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. return $core.withContext(function($ctx2) {
  558. //>>excludeEnd("ctx");
  559. $1=$recv($self.targetClass)._includesSelector_($recv(methodSourceCode)._selector());
  560. if(!$core.assert($1)){
  561. return $recv($self.targetClass)._compile_protocol_($recv(methodSourceCode)._sourceCode(),$self.protocol);
  562. }
  563. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  564. }, function($ctx2) {$ctx2.fillBlock({methodSourceCode:methodSourceCode},$ctx1,1)});
  565. //>>excludeEnd("ctx");
  566. }));
  567. return self;
  568. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  569. }, function($ctx1) {$ctx1.fill(self,"compile",{})});
  570. //>>excludeEnd("ctx");
  571. },
  572. //>>excludeStart("ide", pragmas.excludeIdeData);
  573. args: [],
  574. source: "compile\x0a\x09sourceCodes do: [ :methodSourceCode |\x0a\x09\x09(targetClass includesSelector: methodSourceCode selector)\x0a\x09\x09\x09ifFalse: [ \x0a\x09\x09\x09\x09targetClass \x0a\x09\x09\x09\x09\x09compile: methodSourceCode sourceCode\x0a\x09\x09\x09\x09\x09protocol: protocol ] ]",
  575. referencedClasses: [],
  576. //>>excludeEnd("ide");
  577. pragmas: [],
  578. messageSends: ["do:", "ifFalse:", "includesSelector:", "selector", "compile:protocol:", "sourceCode"]
  579. }),
  580. $globals.HLGenerationOutput);
  581. $core.addMethod(
  582. $core.method({
  583. selector: "initialize",
  584. protocol: "initialization",
  585. fn: function (){
  586. var self=this,$self=this;
  587. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  588. return $core.withContext(function($ctx1) {
  589. //>>excludeEnd("ctx");
  590. (
  591. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  592. $ctx1.supercall = true,
  593. //>>excludeEnd("ctx");
  594. ($globals.HLGenerationOutput.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  595. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  596. $ctx1.supercall = false;
  597. //>>excludeEnd("ctx");;
  598. $self.sourceCodes=$recv($globals.OrderedCollection)._new();
  599. return self;
  600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  601. }, function($ctx1) {$ctx1.fill(self,"initialize",{})});
  602. //>>excludeEnd("ctx");
  603. },
  604. //>>excludeStart("ide", pragmas.excludeIdeData);
  605. args: [],
  606. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09sourceCodes := OrderedCollection new",
  607. referencedClasses: ["OrderedCollection"],
  608. //>>excludeEnd("ide");
  609. pragmas: [],
  610. messageSends: ["initialize", "new"]
  611. }),
  612. $globals.HLGenerationOutput);
  613. $core.addMethod(
  614. $core.method({
  615. selector: "protocol",
  616. protocol: "accessing",
  617. fn: function (){
  618. var self=this,$self=this;
  619. return $self.protocol;
  620. },
  621. //>>excludeStart("ide", pragmas.excludeIdeData);
  622. args: [],
  623. source: "protocol\x0a\x09^ protocol",
  624. referencedClasses: [],
  625. //>>excludeEnd("ide");
  626. pragmas: [],
  627. messageSends: []
  628. }),
  629. $globals.HLGenerationOutput);
  630. $core.addMethod(
  631. $core.method({
  632. selector: "protocol:",
  633. protocol: "accessing",
  634. fn: function (aString){
  635. var self=this,$self=this;
  636. $self.protocol=aString;
  637. return self;
  638. },
  639. //>>excludeStart("ide", pragmas.excludeIdeData);
  640. args: ["aString"],
  641. source: "protocol: aString\x0a\x09protocol := aString",
  642. referencedClasses: [],
  643. //>>excludeEnd("ide");
  644. pragmas: [],
  645. messageSends: []
  646. }),
  647. $globals.HLGenerationOutput);
  648. $core.addMethod(
  649. $core.method({
  650. selector: "sourceCodes",
  651. protocol: "accessing",
  652. fn: function (){
  653. var self=this,$self=this;
  654. return $self.sourceCodes;
  655. },
  656. //>>excludeStart("ide", pragmas.excludeIdeData);
  657. args: [],
  658. source: "sourceCodes\x0a\x09^ sourceCodes",
  659. referencedClasses: [],
  660. //>>excludeEnd("ide");
  661. pragmas: [],
  662. messageSends: []
  663. }),
  664. $globals.HLGenerationOutput);
  665. $core.addMethod(
  666. $core.method({
  667. selector: "sourceCodes:",
  668. protocol: "accessing",
  669. fn: function (aCollection){
  670. var self=this,$self=this;
  671. $self.sourceCodes=aCollection;
  672. return self;
  673. },
  674. //>>excludeStart("ide", pragmas.excludeIdeData);
  675. args: ["aCollection"],
  676. source: "sourceCodes: aCollection\x0a\x09sourceCodes := aCollection",
  677. referencedClasses: [],
  678. //>>excludeEnd("ide");
  679. pragmas: [],
  680. messageSends: []
  681. }),
  682. $globals.HLGenerationOutput);
  683. $core.addMethod(
  684. $core.method({
  685. selector: "targetClass",
  686. protocol: "accessing",
  687. fn: function (){
  688. var self=this,$self=this;
  689. return $self.targetClass;
  690. },
  691. //>>excludeStart("ide", pragmas.excludeIdeData);
  692. args: [],
  693. source: "targetClass\x0a\x09^ targetClass",
  694. referencedClasses: [],
  695. //>>excludeEnd("ide");
  696. pragmas: [],
  697. messageSends: []
  698. }),
  699. $globals.HLGenerationOutput);
  700. $core.addMethod(
  701. $core.method({
  702. selector: "targetClass:",
  703. protocol: "accessing",
  704. fn: function (aClass){
  705. var self=this,$self=this;
  706. $self.targetClass=aClass;
  707. return self;
  708. },
  709. //>>excludeStart("ide", pragmas.excludeIdeData);
  710. args: ["aClass"],
  711. source: "targetClass: aClass\x0a\x09targetClass := aClass",
  712. referencedClasses: [],
  713. //>>excludeEnd("ide");
  714. pragmas: [],
  715. messageSends: []
  716. }),
  717. $globals.HLGenerationOutput);
  718. $core.addClass("HLMethodClassifier", $globals.Object, ["firstClassifier"], "Helios-Helpers");
  719. //>>excludeStart("ide", pragmas.excludeIdeData);
  720. $globals.HLMethodClassifier.comment="I am in charge of categorizing methods following this strategy:\x0a\x0a- is it an accessor?\x0a- is it overriding a superclass method?\x0a- is it starting with a know prefix?\x0a- how are categorized the other implementations?";
  721. //>>excludeEnd("ide");
  722. $core.addMethod(
  723. $core.method({
  724. selector: "addClassifier:",
  725. protocol: "private",
  726. fn: function (aClassifier){
  727. var self=this,$self=this;
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. return $core.withContext(function($ctx1) {
  730. //>>excludeEnd("ctx");
  731. $recv(aClassifier)._next_($self.firstClassifier);
  732. $self.firstClassifier=aClassifier;
  733. return self;
  734. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  735. }, function($ctx1) {$ctx1.fill(self,"addClassifier:",{aClassifier:aClassifier})});
  736. //>>excludeEnd("ctx");
  737. },
  738. //>>excludeStart("ide", pragmas.excludeIdeData);
  739. args: ["aClassifier"],
  740. source: "addClassifier: aClassifier\x0a\x09aClassifier next: firstClassifier.\x0a\x09firstClassifier := aClassifier",
  741. referencedClasses: [],
  742. //>>excludeEnd("ide");
  743. pragmas: [],
  744. messageSends: ["next:"]
  745. }),
  746. $globals.HLMethodClassifier);
  747. $core.addMethod(
  748. $core.method({
  749. selector: "classify:",
  750. protocol: "protocol",
  751. fn: function (aMethod){
  752. var self=this,$self=this;
  753. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  754. return $core.withContext(function($ctx1) {
  755. //>>excludeEnd("ctx");
  756. var $1;
  757. $1=$self.firstClassifier;
  758. $recv($1)._method_(aMethod);
  759. $recv($1)._classify();
  760. return self;
  761. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  762. }, function($ctx1) {$ctx1.fill(self,"classify:",{aMethod:aMethod})});
  763. //>>excludeEnd("ctx");
  764. },
  765. //>>excludeStart("ide", pragmas.excludeIdeData);
  766. args: ["aMethod"],
  767. source: "classify: aMethod\x0a\x09firstClassifier\x0a\x09\x09method: aMethod;\x0a\x09\x09classify",
  768. referencedClasses: [],
  769. //>>excludeEnd("ide");
  770. pragmas: [],
  771. messageSends: ["method:", "classify"]
  772. }),
  773. $globals.HLMethodClassifier);
  774. $core.addMethod(
  775. $core.method({
  776. selector: "classifyAll:",
  777. protocol: "protocol",
  778. fn: function (aCollectionOfMethods){
  779. var self=this,$self=this;
  780. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  781. return $core.withContext(function($ctx1) {
  782. //>>excludeEnd("ctx");
  783. $recv(aCollectionOfMethods)._do_((function(method){
  784. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  785. return $core.withContext(function($ctx2) {
  786. //>>excludeEnd("ctx");
  787. return $self._classify_(method);
  788. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  789. }, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)});
  790. //>>excludeEnd("ctx");
  791. }));
  792. return self;
  793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  794. }, function($ctx1) {$ctx1.fill(self,"classifyAll:",{aCollectionOfMethods:aCollectionOfMethods})});
  795. //>>excludeEnd("ctx");
  796. },
  797. //>>excludeStart("ide", pragmas.excludeIdeData);
  798. args: ["aCollectionOfMethods"],
  799. source: "classifyAll: aCollectionOfMethods\x0a\x09aCollectionOfMethods do: [ :method |\x0a\x09\x09self classify: method ]",
  800. referencedClasses: [],
  801. //>>excludeEnd("ide");
  802. pragmas: [],
  803. messageSends: ["do:", "classify:"]
  804. }),
  805. $globals.HLMethodClassifier);
  806. $core.addMethod(
  807. $core.method({
  808. selector: "initialize",
  809. protocol: "initialization",
  810. fn: function (){
  811. var self=this,$self=this;
  812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  813. return $core.withContext(function($ctx1) {
  814. //>>excludeEnd("ctx");
  815. (
  816. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  817. $ctx1.supercall = true,
  818. //>>excludeEnd("ctx");
  819. ($globals.HLMethodClassifier.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  820. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  821. $ctx1.supercall = false;
  822. //>>excludeEnd("ctx");;
  823. $self._setupClassifiers();
  824. return self;
  825. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  826. }, function($ctx1) {$ctx1.fill(self,"initialize",{})});
  827. //>>excludeEnd("ctx");
  828. },
  829. //>>excludeStart("ide", pragmas.excludeIdeData);
  830. args: [],
  831. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09self setupClassifiers",
  832. referencedClasses: [],
  833. //>>excludeEnd("ide");
  834. pragmas: [],
  835. messageSends: ["initialize", "setupClassifiers"]
  836. }),
  837. $globals.HLMethodClassifier);
  838. $core.addMethod(
  839. $core.method({
  840. selector: "setupClassifiers",
  841. protocol: "initialization",
  842. fn: function (){
  843. var self=this,$self=this;
  844. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  845. return $core.withContext(function($ctx1) {
  846. //>>excludeEnd("ctx");
  847. var $1,$2,$3;
  848. $1=$recv($globals.HLImplementorClassifier)._new();
  849. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  850. $ctx1.sendIdx["new"]=1;
  851. //>>excludeEnd("ctx");
  852. $self._addClassifier_($1);
  853. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  854. $ctx1.sendIdx["addClassifier:"]=1;
  855. //>>excludeEnd("ctx");
  856. $2=$recv($globals.HLPrefixClassifier)._new();
  857. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  858. $ctx1.sendIdx["new"]=2;
  859. //>>excludeEnd("ctx");
  860. $self._addClassifier_($2);
  861. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  862. $ctx1.sendIdx["addClassifier:"]=2;
  863. //>>excludeEnd("ctx");
  864. $3=$recv($globals.HLSuperclassClassifier)._new();
  865. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  866. $ctx1.sendIdx["new"]=3;
  867. //>>excludeEnd("ctx");
  868. $self._addClassifier_($3);
  869. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  870. $ctx1.sendIdx["addClassifier:"]=3;
  871. //>>excludeEnd("ctx");
  872. $self._addClassifier_($recv($globals.HLAccessorClassifier)._new());
  873. return self;
  874. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  875. }, function($ctx1) {$ctx1.fill(self,"setupClassifiers",{})});
  876. //>>excludeEnd("ctx");
  877. },
  878. //>>excludeStart("ide", pragmas.excludeIdeData);
  879. args: [],
  880. source: "setupClassifiers\x0a\x09self addClassifier: HLImplementorClassifier new.\x0a\x09self addClassifier: HLPrefixClassifier new.\x0a\x09self addClassifier: HLSuperclassClassifier new.\x0a\x09self addClassifier: HLAccessorClassifier new",
  881. referencedClasses: ["HLImplementorClassifier", "HLPrefixClassifier", "HLSuperclassClassifier", "HLAccessorClassifier"],
  882. //>>excludeEnd("ide");
  883. pragmas: [],
  884. messageSends: ["addClassifier:", "new"]
  885. }),
  886. $globals.HLMethodClassifier);
  887. $core.addClass("HLMethodGenerator", $globals.Object, ["output"], "Helios-Helpers");
  888. //>>excludeStart("ide", pragmas.excludeIdeData);
  889. $globals.HLMethodGenerator.comment="I am the abstract super class of the method generators.\x0a\x0aMy main method is `generate` which produces an `output` object accessed with `#output`.";
  890. //>>excludeEnd("ide");
  891. $core.addMethod(
  892. $core.method({
  893. selector: "class:",
  894. protocol: "accessing",
  895. fn: function (aClass){
  896. var self=this,$self=this;
  897. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  898. return $core.withContext(function($ctx1) {
  899. //>>excludeEnd("ctx");
  900. $recv($self.output)._targetClass_(aClass);
  901. return self;
  902. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  903. }, function($ctx1) {$ctx1.fill(self,"class:",{aClass:aClass})});
  904. //>>excludeEnd("ctx");
  905. },
  906. //>>excludeStart("ide", pragmas.excludeIdeData);
  907. args: ["aClass"],
  908. source: "class: aClass\x0a\x09output targetClass: aClass",
  909. referencedClasses: [],
  910. //>>excludeEnd("ide");
  911. pragmas: [],
  912. messageSends: ["targetClass:"]
  913. }),
  914. $globals.HLMethodGenerator);
  915. $core.addMethod(
  916. $core.method({
  917. selector: "generate",
  918. protocol: "protocol",
  919. fn: function (){
  920. var self=this,$self=this;
  921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  922. return $core.withContext(function($ctx1) {
  923. //>>excludeEnd("ctx");
  924. var $1,$receiver;
  925. $1=$recv($self.output)._targetClass();
  926. if(($receiver = $1) == null || $receiver.a$nil){
  927. $self._error_("class should not be nil");
  928. } else {
  929. $1;
  930. }
  931. return self;
  932. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  933. }, function($ctx1) {$ctx1.fill(self,"generate",{})});
  934. //>>excludeEnd("ctx");
  935. },
  936. //>>excludeStart("ide", pragmas.excludeIdeData);
  937. args: [],
  938. source: "generate\x0a\x09output targetClass ifNil: [ self error: 'class should not be nil'].",
  939. referencedClasses: [],
  940. //>>excludeEnd("ide");
  941. pragmas: [],
  942. messageSends: ["ifNil:", "targetClass", "error:"]
  943. }),
  944. $globals.HLMethodGenerator);
  945. $core.addMethod(
  946. $core.method({
  947. selector: "initialize",
  948. protocol: "initialization",
  949. fn: function (){
  950. var self=this,$self=this;
  951. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  952. return $core.withContext(function($ctx1) {
  953. //>>excludeEnd("ctx");
  954. (
  955. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  956. $ctx1.supercall = true,
  957. //>>excludeEnd("ctx");
  958. ($globals.HLMethodGenerator.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  959. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  960. $ctx1.supercall = false;
  961. //>>excludeEnd("ctx");;
  962. $self.output=$recv($globals.HLGenerationOutput)._new();
  963. return self;
  964. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  965. }, function($ctx1) {$ctx1.fill(self,"initialize",{})});
  966. //>>excludeEnd("ctx");
  967. },
  968. //>>excludeStart("ide", pragmas.excludeIdeData);
  969. args: [],
  970. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09output := HLGenerationOutput new",
  971. referencedClasses: ["HLGenerationOutput"],
  972. //>>excludeEnd("ide");
  973. pragmas: [],
  974. messageSends: ["initialize", "new"]
  975. }),
  976. $globals.HLMethodGenerator);
  977. $core.addMethod(
  978. $core.method({
  979. selector: "output",
  980. protocol: "accessing",
  981. fn: function (){
  982. var self=this,$self=this;
  983. return $self.output;
  984. },
  985. //>>excludeStart("ide", pragmas.excludeIdeData);
  986. args: [],
  987. source: "output\x0a\x09^ output",
  988. referencedClasses: [],
  989. //>>excludeEnd("ide");
  990. pragmas: [],
  991. messageSends: []
  992. }),
  993. $globals.HLMethodGenerator);
  994. $core.addClass("HLAccessorsGenerator", $globals.HLMethodGenerator, [], "Helios-Helpers");
  995. //>>excludeStart("ide", pragmas.excludeIdeData);
  996. $globals.HLAccessorsGenerator.comment="I am a generator used to compile the getters/setters of a class.";
  997. //>>excludeEnd("ide");
  998. $core.addMethod(
  999. $core.method({
  1000. selector: "accessorProtocolForObject",
  1001. protocol: "double-dispatch",
  1002. fn: function (){
  1003. var self=this,$self=this;
  1004. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1005. return $core.withContext(function($ctx1) {
  1006. //>>excludeEnd("ctx");
  1007. $recv($self.output)._protocol_("accessing");
  1008. return self;
  1009. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1010. }, function($ctx1) {$ctx1.fill(self,"accessorProtocolForObject",{})});
  1011. //>>excludeEnd("ctx");
  1012. },
  1013. //>>excludeStart("ide", pragmas.excludeIdeData);
  1014. args: [],
  1015. source: "accessorProtocolForObject\x0a\x09output protocol: 'accessing'",
  1016. referencedClasses: [],
  1017. //>>excludeEnd("ide");
  1018. pragmas: [],
  1019. messageSends: ["protocol:"]
  1020. }),
  1021. $globals.HLAccessorsGenerator);
  1022. $core.addMethod(
  1023. $core.method({
  1024. selector: "accessorsForObject",
  1025. protocol: "double-dispatch",
  1026. fn: function (){
  1027. var self=this,$self=this;
  1028. var sources;
  1029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1030. return $core.withContext(function($ctx1) {
  1031. //>>excludeEnd("ctx");
  1032. var $1;
  1033. sources=$recv($globals.OrderedCollection)._new();
  1034. $recv($recv($recv($recv($self.output)._targetClass())._instanceVariableNames())._sorted())._do_((function(each){
  1035. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1036. return $core.withContext(function($ctx2) {
  1037. //>>excludeEnd("ctx");
  1038. $1=sources;
  1039. $recv($1)._add_($self._getterFor_(each));
  1040. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1041. $ctx2.sendIdx["add:"]=1;
  1042. //>>excludeEnd("ctx");
  1043. return $recv($1)._add_($self._setterFor_(each));
  1044. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1045. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1046. //>>excludeEnd("ctx");
  1047. }));
  1048. $recv($self.output)._sourceCodes_(sources);
  1049. return self;
  1050. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1051. }, function($ctx1) {$ctx1.fill(self,"accessorsForObject",{sources:sources})});
  1052. //>>excludeEnd("ctx");
  1053. },
  1054. //>>excludeStart("ide", pragmas.excludeIdeData);
  1055. args: [],
  1056. source: "accessorsForObject\x0a\x09| sources |\x0a\x09\x0a\x09sources := OrderedCollection new.\x0a\x09output targetClass instanceVariableNames sorted do: [ :each | \x0a\x09\x09sources \x0a\x09\x09\x09add: (self getterFor: each);\x0a\x09\x09\x09add: (self setterFor: each) ].\x0a\x09output sourceCodes: sources",
  1057. referencedClasses: ["OrderedCollection"],
  1058. //>>excludeEnd("ide");
  1059. pragmas: [],
  1060. messageSends: ["new", "do:", "sorted", "instanceVariableNames", "targetClass", "add:", "getterFor:", "setterFor:", "sourceCodes:"]
  1061. }),
  1062. $globals.HLAccessorsGenerator);
  1063. $core.addMethod(
  1064. $core.method({
  1065. selector: "generate",
  1066. protocol: "protocol",
  1067. fn: function (){
  1068. var self=this,$self=this;
  1069. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1070. return $core.withContext(function($ctx1) {
  1071. //>>excludeEnd("ctx");
  1072. var $1;
  1073. (
  1074. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1075. $ctx1.supercall = true,
  1076. //>>excludeEnd("ctx");
  1077. ($globals.HLAccessorsGenerator.superclass||$boot.nilAsClass).fn.prototype._generate.apply($self, []));
  1078. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1079. $ctx1.supercall = false;
  1080. //>>excludeEnd("ctx");;
  1081. $1=$recv($self.output)._targetClass();
  1082. $recv($1)._accessorsSourceCodesWith_(self);
  1083. $recv($1)._accessorProtocolWith_(self);
  1084. return self;
  1085. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1086. }, function($ctx1) {$ctx1.fill(self,"generate",{})});
  1087. //>>excludeEnd("ctx");
  1088. },
  1089. //>>excludeStart("ide", pragmas.excludeIdeData);
  1090. args: [],
  1091. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09accessorsSourceCodesWith: self;\x0a\x09\x09accessorProtocolWith: self",
  1092. referencedClasses: [],
  1093. //>>excludeEnd("ide");
  1094. pragmas: [],
  1095. messageSends: ["generate", "accessorsSourceCodesWith:", "targetClass", "accessorProtocolWith:"]
  1096. }),
  1097. $globals.HLAccessorsGenerator);
  1098. $core.addMethod(
  1099. $core.method({
  1100. selector: "getterFor:",
  1101. protocol: "private",
  1102. fn: function (anInstanceVariable){
  1103. var self=this,$self=this;
  1104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1105. return $core.withContext(function($ctx1) {
  1106. //>>excludeEnd("ctx");
  1107. var $1;
  1108. $1=$recv($globals.HLMethodSourceCode)._new();
  1109. $recv($1)._selector_(anInstanceVariable);
  1110. return $recv($1)._sourceCode_($recv($globals.String)._streamContents_((function(stream){
  1111. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1112. return $core.withContext(function($ctx2) {
  1113. //>>excludeEnd("ctx");
  1114. $recv(stream).__lt_lt(anInstanceVariable);
  1115. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1116. $ctx2.sendIdx["<<"]=1;
  1117. //>>excludeEnd("ctx");
  1118. $recv($recv(stream)._cr())._tab();
  1119. return $recv($recv(stream).__lt_lt("^ ")).__lt_lt(anInstanceVariable);
  1120. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1121. $ctx2.sendIdx["<<"]=2;
  1122. //>>excludeEnd("ctx");
  1123. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1124. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)});
  1125. //>>excludeEnd("ctx");
  1126. })));
  1127. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1128. }, function($ctx1) {$ctx1.fill(self,"getterFor:",{anInstanceVariable:anInstanceVariable})});
  1129. //>>excludeEnd("ctx");
  1130. },
  1131. //>>excludeStart("ide", pragmas.excludeIdeData);
  1132. args: ["anInstanceVariable"],
  1133. source: "getterFor: anInstanceVariable\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector:anInstanceVariable;\x0a\x09\x09sourceCode: (String streamContents: [ :stream |\x0a\x09\x09stream << anInstanceVariable.\x0a\x09\x09stream cr tab.\x0a\x09\x09stream << '^ ' << anInstanceVariable ])",
  1134. referencedClasses: ["HLMethodSourceCode", "String"],
  1135. //>>excludeEnd("ide");
  1136. pragmas: [],
  1137. messageSends: ["selector:", "new", "sourceCode:", "streamContents:", "<<", "tab", "cr"]
  1138. }),
  1139. $globals.HLAccessorsGenerator);
  1140. $core.addMethod(
  1141. $core.method({
  1142. selector: "setterFor:",
  1143. protocol: "private",
  1144. fn: function (anInstanceVariable){
  1145. var self=this,$self=this;
  1146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1147. return $core.withContext(function($ctx1) {
  1148. //>>excludeEnd("ctx");
  1149. var $1,$2;
  1150. $1=$recv($globals.HLMethodSourceCode)._new();
  1151. $recv($1)._selector_($recv(anInstanceVariable).__comma(":"));
  1152. return $recv($1)._sourceCode_($recv($globals.String)._streamContents_((function(stream){
  1153. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1154. return $core.withContext(function($ctx2) {
  1155. //>>excludeEnd("ctx");
  1156. $2=$recv(stream).__lt_lt(anInstanceVariable);
  1157. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1158. $ctx2.sendIdx["<<"]=2;
  1159. //>>excludeEnd("ctx");
  1160. $recv($2).__lt_lt(": anObject");
  1161. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1162. $ctx2.sendIdx["<<"]=1;
  1163. //>>excludeEnd("ctx");
  1164. $recv($recv(stream)._cr())._tab();
  1165. return $recv($recv(stream).__lt_lt(anInstanceVariable)).__lt_lt(" := anObject");
  1166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1167. $ctx2.sendIdx["<<"]=3;
  1168. //>>excludeEnd("ctx");
  1169. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1170. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)});
  1171. //>>excludeEnd("ctx");
  1172. })));
  1173. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1174. }, function($ctx1) {$ctx1.fill(self,"setterFor:",{anInstanceVariable:anInstanceVariable})});
  1175. //>>excludeEnd("ctx");
  1176. },
  1177. //>>excludeStart("ide", pragmas.excludeIdeData);
  1178. args: ["anInstanceVariable"],
  1179. source: "setterFor: anInstanceVariable\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector: anInstanceVariable, ':';\x0a\x09\x09sourceCode: (String streamContents: [ :stream |\x0a\x09\x09stream << anInstanceVariable << ': anObject'.\x0a\x09\x09stream cr tab.\x0a\x09\x09stream << anInstanceVariable << ' := anObject' ])",
  1180. referencedClasses: ["HLMethodSourceCode", "String"],
  1181. //>>excludeEnd("ide");
  1182. pragmas: [],
  1183. messageSends: ["selector:", "new", ",", "sourceCode:", "streamContents:", "<<", "tab", "cr"]
  1184. }),
  1185. $globals.HLAccessorsGenerator);
  1186. $core.addClass("HLInitializeGenerator", $globals.HLMethodGenerator, [], "Helios-Helpers");
  1187. //>>excludeStart("ide", pragmas.excludeIdeData);
  1188. $globals.HLInitializeGenerator.comment="I am used to double-dispatch the `initialize` method(s) generation. I am a disposable object.\x0a\x0a## Usage\x0a\x0a ^ HLInitializeGenerator new\x0a class: aClass;\x0a generate;\x0a output";
  1189. //>>excludeEnd("ide");
  1190. $core.addMethod(
  1191. $core.method({
  1192. selector: "generate",
  1193. protocol: "protocol",
  1194. fn: function (){
  1195. var self=this,$self=this;
  1196. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1197. return $core.withContext(function($ctx1) {
  1198. //>>excludeEnd("ctx");
  1199. var $1;
  1200. (
  1201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1202. $ctx1.supercall = true,
  1203. //>>excludeEnd("ctx");
  1204. ($globals.HLInitializeGenerator.superclass||$boot.nilAsClass).fn.prototype._generate.apply($self, []));
  1205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1206. $ctx1.supercall = false;
  1207. //>>excludeEnd("ctx");;
  1208. $1=$recv($self.output)._targetClass();
  1209. $recv($1)._initializeSourceCodesWith_(self);
  1210. $recv($1)._initializeProtocolWith_(self);
  1211. return self;
  1212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1213. }, function($ctx1) {$ctx1.fill(self,"generate",{})});
  1214. //>>excludeEnd("ctx");
  1215. },
  1216. //>>excludeStart("ide", pragmas.excludeIdeData);
  1217. args: [],
  1218. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09initializeSourceCodesWith: self;\x0a\x09\x09initializeProtocolWith: self",
  1219. referencedClasses: [],
  1220. //>>excludeEnd("ide");
  1221. pragmas: [],
  1222. messageSends: ["generate", "initializeSourceCodesWith:", "targetClass", "initializeProtocolWith:"]
  1223. }),
  1224. $globals.HLInitializeGenerator);
  1225. $core.addMethod(
  1226. $core.method({
  1227. selector: "generateInitializeCodeForObject",
  1228. protocol: "private",
  1229. fn: function (){
  1230. var self=this,$self=this;
  1231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1232. return $core.withContext(function($ctx1) {
  1233. //>>excludeEnd("ctx");
  1234. var $2,$1,$3,$4,$5,$6;
  1235. return $recv($globals.String)._streamContents_((function(str){
  1236. var instVars,size;
  1237. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1238. return $core.withContext(function($ctx2) {
  1239. //>>excludeEnd("ctx");
  1240. instVars=$recv($recv($recv($self.output)._targetClass())._instanceVariableNames())._sorted();
  1241. size=$recv(instVars)._size();
  1242. $recv(str).__lt_lt("initialize");
  1243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1244. $ctx2.sendIdx["<<"]=1;
  1245. //>>excludeEnd("ctx");
  1246. $2=$recv(str)._cr();
  1247. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1248. $ctx2.sendIdx["cr"]=1;
  1249. //>>excludeEnd("ctx");
  1250. $1=$recv($2)._tab();
  1251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1252. $ctx2.sendIdx["tab"]=1;
  1253. //>>excludeEnd("ctx");
  1254. $recv($1).__lt_lt("super initialize.");
  1255. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1256. $ctx2.sendIdx["<<"]=2;
  1257. //>>excludeEnd("ctx");
  1258. $recv($1)._cr();
  1259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1260. $ctx2.sendIdx["cr"]=2;
  1261. //>>excludeEnd("ctx");
  1262. $3=$recv(str)._cr();
  1263. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1264. $ctx2.sendIdx["cr"]=3;
  1265. //>>excludeEnd("ctx");
  1266. $recv($3)._tab();
  1267. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1268. $ctx2.sendIdx["tab"]=2;
  1269. //>>excludeEnd("ctx");
  1270. return $recv(instVars)._withIndexDo_((function(name,index){
  1271. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1272. return $core.withContext(function($ctx3) {
  1273. //>>excludeEnd("ctx");
  1274. $4=$recv(index).__tild_eq((1));
  1275. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1276. $ctx3.sendIdx["~="]=1;
  1277. //>>excludeEnd("ctx");
  1278. if($core.assert($4)){
  1279. $recv($recv(str)._cr())._tab();
  1280. }
  1281. $5=$recv(str).__lt_lt(name);
  1282. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1283. $ctx3.sendIdx["<<"]=4;
  1284. //>>excludeEnd("ctx");
  1285. $recv($5).__lt_lt(" := nil");
  1286. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1287. $ctx3.sendIdx["<<"]=3;
  1288. //>>excludeEnd("ctx");
  1289. $6=$recv(index).__tild_eq(size);
  1290. if($core.assert($6)){
  1291. return $recv(str).__lt_lt(".");
  1292. }
  1293. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1294. }, function($ctx3) {$ctx3.fillBlock({name:name,index:index},$ctx2,2)});
  1295. //>>excludeEnd("ctx");
  1296. }));
  1297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1298. }, function($ctx2) {$ctx2.fillBlock({str:str,instVars:instVars,size:size},$ctx1,1)});
  1299. //>>excludeEnd("ctx");
  1300. }));
  1301. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1302. }, function($ctx1) {$ctx1.fill(self,"generateInitializeCodeForObject",{})});
  1303. //>>excludeEnd("ctx");
  1304. },
  1305. //>>excludeStart("ide", pragmas.excludeIdeData);
  1306. args: [],
  1307. source: "generateInitializeCodeForObject\x09\x0a\x09^ String streamContents: [ :str || instVars size |\x0a\x09\x09instVars := output targetClass instanceVariableNames sorted.\x0a\x09\x09size := instVars size.\x0a\x09\x09str << 'initialize'.\x0a\x09\x09str cr tab << 'super initialize.';cr.\x0a\x09\x09str cr tab.\x0a\x09\x09instVars withIndexDo: [ :name :index |\x0a\x09\x09\x09index ~= 1 ifTrue: [ str cr tab ].\x0a\x09\x09\x09str << name << ' := nil'.\x0a\x09\x09\x09index ~= size ifTrue: [ str << '.' ] ] ].",
  1308. referencedClasses: ["String"],
  1309. //>>excludeEnd("ide");
  1310. pragmas: [],
  1311. messageSends: ["streamContents:", "sorted", "instanceVariableNames", "targetClass", "size", "<<", "tab", "cr", "withIndexDo:", "ifTrue:", "~="]
  1312. }),
  1313. $globals.HLInitializeGenerator);
  1314. $core.addMethod(
  1315. $core.method({
  1316. selector: "initializeForObject",
  1317. protocol: "double-dispatch",
  1318. fn: function (){
  1319. var self=this,$self=this;
  1320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1321. return $core.withContext(function($ctx1) {
  1322. //>>excludeEnd("ctx");
  1323. $recv($self.output)._addSourceCode_($self._initializeMethodForObject());
  1324. return self;
  1325. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1326. }, function($ctx1) {$ctx1.fill(self,"initializeForObject",{})});
  1327. //>>excludeEnd("ctx");
  1328. },
  1329. //>>excludeStart("ide", pragmas.excludeIdeData);
  1330. args: [],
  1331. source: "initializeForObject\x0a\x09output addSourceCode: self initializeMethodForObject",
  1332. referencedClasses: [],
  1333. //>>excludeEnd("ide");
  1334. pragmas: [],
  1335. messageSends: ["addSourceCode:", "initializeMethodForObject"]
  1336. }),
  1337. $globals.HLInitializeGenerator);
  1338. $core.addMethod(
  1339. $core.method({
  1340. selector: "initializeMethodForObject",
  1341. protocol: "private",
  1342. fn: function (){
  1343. var self=this,$self=this;
  1344. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1345. return $core.withContext(function($ctx1) {
  1346. //>>excludeEnd("ctx");
  1347. var $1;
  1348. $1=$recv($globals.HLMethodSourceCode)._new();
  1349. $recv($1)._selector_("initialize");
  1350. $recv($1)._sourceCode_($self._generateInitializeCodeForObject());
  1351. return $recv($1)._yourself();
  1352. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1353. }, function($ctx1) {$ctx1.fill(self,"initializeMethodForObject",{})});
  1354. //>>excludeEnd("ctx");
  1355. },
  1356. //>>excludeStart("ide", pragmas.excludeIdeData);
  1357. args: [],
  1358. source: "initializeMethodForObject\x09\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector: 'initialize';\x0a\x09\x09sourceCode: self generateInitializeCodeForObject;\x0a\x09\x09yourself",
  1359. referencedClasses: ["HLMethodSourceCode"],
  1360. //>>excludeEnd("ide");
  1361. pragmas: [],
  1362. messageSends: ["selector:", "new", "sourceCode:", "generateInitializeCodeForObject", "yourself"]
  1363. }),
  1364. $globals.HLInitializeGenerator);
  1365. $core.addMethod(
  1366. $core.method({
  1367. selector: "initializeProtocolForObject",
  1368. protocol: "double-dispatch",
  1369. fn: function (){
  1370. var self=this,$self=this;
  1371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1372. return $core.withContext(function($ctx1) {
  1373. //>>excludeEnd("ctx");
  1374. $recv($self.output)._protocol_("initialization");
  1375. return self;
  1376. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1377. }, function($ctx1) {$ctx1.fill(self,"initializeProtocolForObject",{})});
  1378. //>>excludeEnd("ctx");
  1379. },
  1380. //>>excludeStart("ide", pragmas.excludeIdeData);
  1381. args: [],
  1382. source: "initializeProtocolForObject\x0a\x09output protocol: 'initialization'",
  1383. referencedClasses: [],
  1384. //>>excludeEnd("ide");
  1385. pragmas: [],
  1386. messageSends: ["protocol:"]
  1387. }),
  1388. $globals.HLInitializeGenerator);
  1389. $core.addClass("HLMethodSourceCode", $globals.Object, ["selector", "sourceCode"], "Helios-Helpers");
  1390. //>>excludeStart("ide", pragmas.excludeIdeData);
  1391. $globals.HLMethodSourceCode.comment="I am a simple data object keeping track of the information about a method that will be compiled at the end of the generation process.";
  1392. //>>excludeEnd("ide");
  1393. $core.addMethod(
  1394. $core.method({
  1395. selector: "selector",
  1396. protocol: "accessing",
  1397. fn: function (){
  1398. var self=this,$self=this;
  1399. return $self.selector;
  1400. },
  1401. //>>excludeStart("ide", pragmas.excludeIdeData);
  1402. args: [],
  1403. source: "selector\x0a\x09^ selector",
  1404. referencedClasses: [],
  1405. //>>excludeEnd("ide");
  1406. pragmas: [],
  1407. messageSends: []
  1408. }),
  1409. $globals.HLMethodSourceCode);
  1410. $core.addMethod(
  1411. $core.method({
  1412. selector: "selector:",
  1413. protocol: "accessing",
  1414. fn: function (aSelector){
  1415. var self=this,$self=this;
  1416. $self.selector=aSelector;
  1417. return self;
  1418. },
  1419. //>>excludeStart("ide", pragmas.excludeIdeData);
  1420. args: ["aSelector"],
  1421. source: "selector: aSelector\x0a\x09selector := aSelector",
  1422. referencedClasses: [],
  1423. //>>excludeEnd("ide");
  1424. pragmas: [],
  1425. messageSends: []
  1426. }),
  1427. $globals.HLMethodSourceCode);
  1428. $core.addMethod(
  1429. $core.method({
  1430. selector: "sourceCode",
  1431. protocol: "accessing",
  1432. fn: function (){
  1433. var self=this,$self=this;
  1434. return $self.sourceCode;
  1435. },
  1436. //>>excludeStart("ide", pragmas.excludeIdeData);
  1437. args: [],
  1438. source: "sourceCode\x0a\x09^ sourceCode",
  1439. referencedClasses: [],
  1440. //>>excludeEnd("ide");
  1441. pragmas: [],
  1442. messageSends: []
  1443. }),
  1444. $globals.HLMethodSourceCode);
  1445. $core.addMethod(
  1446. $core.method({
  1447. selector: "sourceCode:",
  1448. protocol: "accessing",
  1449. fn: function (aString){
  1450. var self=this,$self=this;
  1451. $self.sourceCode=aString;
  1452. return self;
  1453. },
  1454. //>>excludeStart("ide", pragmas.excludeIdeData);
  1455. args: ["aString"],
  1456. source: "sourceCode: aString\x0a\x09sourceCode := aString",
  1457. referencedClasses: [],
  1458. //>>excludeEnd("ide");
  1459. pragmas: [],
  1460. messageSends: []
  1461. }),
  1462. $globals.HLMethodSourceCode);
  1463. $core.addClass("HLPackageCommitErrorHelper", $globals.Object, ["model"], "Helios-Helpers");
  1464. $core.addMethod(
  1465. $core.method({
  1466. selector: "commitPackage",
  1467. protocol: "actions",
  1468. fn: function (){
  1469. var self=this,$self=this;
  1470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1471. return $core.withContext(function($ctx1) {
  1472. //>>excludeEnd("ctx");
  1473. $recv($recv($globals.HLCommitPackageCommand)._for_($self._model()))._execute();
  1474. return self;
  1475. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1476. }, function($ctx1) {$ctx1.fill(self,"commitPackage",{})});
  1477. //>>excludeEnd("ctx");
  1478. },
  1479. //>>excludeStart("ide", pragmas.excludeIdeData);
  1480. args: [],
  1481. source: "commitPackage\x0a\x09(HLCommitPackageCommand for: self model)\x0a\x09\x09execute",
  1482. referencedClasses: ["HLCommitPackageCommand"],
  1483. //>>excludeEnd("ide");
  1484. pragmas: [],
  1485. messageSends: ["execute", "for:", "model"]
  1486. }),
  1487. $globals.HLPackageCommitErrorHelper);
  1488. $core.addMethod(
  1489. $core.method({
  1490. selector: "commitToPath:",
  1491. protocol: "actions",
  1492. fn: function (aString){
  1493. var self=this,$self=this;
  1494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1495. return $core.withContext(function($ctx1) {
  1496. //>>excludeEnd("ctx");
  1497. $recv($recv($self._package())._transport())._setPath_(aString);
  1498. $self._commitPackage();
  1499. return self;
  1500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1501. }, function($ctx1) {$ctx1.fill(self,"commitToPath:",{aString:aString})});
  1502. //>>excludeEnd("ctx");
  1503. },
  1504. //>>excludeStart("ide", pragmas.excludeIdeData);
  1505. args: ["aString"],
  1506. source: "commitToPath: aString\x0a\x09\x22We only take AMD package transport into account for now\x22\x0a\x09\x0a\x09self package transport setPath: aString.\x0a\x09\x0a\x09self commitPackage",
  1507. referencedClasses: [],
  1508. //>>excludeEnd("ide");
  1509. pragmas: [],
  1510. messageSends: ["setPath:", "transport", "package", "commitPackage"]
  1511. }),
  1512. $globals.HLPackageCommitErrorHelper);
  1513. $core.addMethod(
  1514. $core.method({
  1515. selector: "model",
  1516. protocol: "accessing",
  1517. fn: function (){
  1518. var self=this,$self=this;
  1519. return $self.model;
  1520. },
  1521. //>>excludeStart("ide", pragmas.excludeIdeData);
  1522. args: [],
  1523. source: "model\x0a\x09^ model",
  1524. referencedClasses: [],
  1525. //>>excludeEnd("ide");
  1526. pragmas: [],
  1527. messageSends: []
  1528. }),
  1529. $globals.HLPackageCommitErrorHelper);
  1530. $core.addMethod(
  1531. $core.method({
  1532. selector: "model:",
  1533. protocol: "accessing",
  1534. fn: function (aToolModel){
  1535. var self=this,$self=this;
  1536. $self.model=aToolModel;
  1537. return self;
  1538. },
  1539. //>>excludeStart("ide", pragmas.excludeIdeData);
  1540. args: ["aToolModel"],
  1541. source: "model: aToolModel\x0a\x09model := aToolModel",
  1542. referencedClasses: [],
  1543. //>>excludeEnd("ide");
  1544. pragmas: [],
  1545. messageSends: []
  1546. }),
  1547. $globals.HLPackageCommitErrorHelper);
  1548. $core.addMethod(
  1549. $core.method({
  1550. selector: "package",
  1551. protocol: "accessing",
  1552. fn: function (){
  1553. var self=this,$self=this;
  1554. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1555. return $core.withContext(function($ctx1) {
  1556. //>>excludeEnd("ctx");
  1557. return $recv($self._model())._packageToCommit();
  1558. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1559. }, function($ctx1) {$ctx1.fill(self,"package",{})});
  1560. //>>excludeEnd("ctx");
  1561. },
  1562. //>>excludeStart("ide", pragmas.excludeIdeData);
  1563. args: [],
  1564. source: "package\x0a\x09^ self model packageToCommit",
  1565. referencedClasses: [],
  1566. //>>excludeEnd("ide");
  1567. pragmas: [],
  1568. messageSends: ["packageToCommit", "model"]
  1569. }),
  1570. $globals.HLPackageCommitErrorHelper);
  1571. $core.addMethod(
  1572. $core.method({
  1573. selector: "showHelp",
  1574. protocol: "actions",
  1575. fn: function (){
  1576. var self=this,$self=this;
  1577. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1578. return $core.withContext(function($ctx1) {
  1579. //>>excludeEnd("ctx");
  1580. var $1,$2;
  1581. $1=$recv($globals.HLConfirmationWidget)._new();
  1582. $2=$recv("Commit failed for namespace \x22".__comma($recv($recv($self._package())._transport())._namespace())).__comma("\x22. Do you want to commit to another path?");
  1583. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1584. $ctx1.sendIdx[","]=1;
  1585. //>>excludeEnd("ctx");
  1586. $recv($1)._confirmationString_($2);
  1587. $recv($1)._actionBlock_((function(){
  1588. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1589. return $core.withContext(function($ctx2) {
  1590. //>>excludeEnd("ctx");
  1591. return $self._showNewCommitPath();
  1592. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1593. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1594. //>>excludeEnd("ctx");
  1595. }));
  1596. $recv($1)._cancelButtonLabel_("Abandon");
  1597. $recv($1)._confirmButtonLabel_("Set path");
  1598. $recv($1)._show();
  1599. return self;
  1600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1601. }, function($ctx1) {$ctx1.fill(self,"showHelp",{})});
  1602. //>>excludeEnd("ctx");
  1603. },
  1604. //>>excludeStart("ide", pragmas.excludeIdeData);
  1605. args: [],
  1606. source: "showHelp\x0a\x09HLConfirmationWidget new\x0a\x09\x09confirmationString: 'Commit failed for namespace \x22', self package transport namespace, '\x22. Do you want to commit to another path?';\x0a\x09\x09actionBlock: [ self showNewCommitPath ];\x0a\x09\x09cancelButtonLabel: 'Abandon';\x0a\x09\x09confirmButtonLabel: 'Set path';\x0a\x09\x09show",
  1607. referencedClasses: ["HLConfirmationWidget"],
  1608. //>>excludeEnd("ide");
  1609. pragmas: [],
  1610. messageSends: ["confirmationString:", "new", ",", "namespace", "transport", "package", "actionBlock:", "showNewCommitPath", "cancelButtonLabel:", "confirmButtonLabel:", "show"]
  1611. }),
  1612. $globals.HLPackageCommitErrorHelper);
  1613. $core.addMethod(
  1614. $core.method({
  1615. selector: "showNewCommitPath",
  1616. protocol: "actions",
  1617. fn: function (){
  1618. var self=this,$self=this;
  1619. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1620. return $core.withContext(function($ctx1) {
  1621. //>>excludeEnd("ctx");
  1622. var $1;
  1623. $1=$recv($globals.HLRequestWidget)._new();
  1624. $recv($1)._beSingleline();
  1625. $recv($1)._confirmationString_("Set commit path");
  1626. $recv($1)._actionBlock_((function(url){
  1627. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1628. return $core.withContext(function($ctx2) {
  1629. //>>excludeEnd("ctx");
  1630. return $self._commitToPath_(url);
  1631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1632. }, function($ctx2) {$ctx2.fillBlock({url:url},$ctx1,1)});
  1633. //>>excludeEnd("ctx");
  1634. }));
  1635. $recv($1)._confirmButtonLabel_("Commit with new path");
  1636. $recv($1)._value_("/src");
  1637. $recv($1)._show();
  1638. return self;
  1639. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1640. }, function($ctx1) {$ctx1.fill(self,"showNewCommitPath",{})});
  1641. //>>excludeEnd("ctx");
  1642. },
  1643. //>>excludeStart("ide", pragmas.excludeIdeData);
  1644. args: [],
  1645. source: "showNewCommitPath\x0a\x09HLRequestWidget new\x0a\x09\x09beSingleline;\x0a\x09\x09confirmationString: 'Set commit path';\x0a\x09\x09actionBlock: [ :url | self commitToPath: url ];\x0a\x09\x09confirmButtonLabel: 'Commit with new path';\x0a\x09\x09value: '/src';\x0a\x09\x09show",
  1646. referencedClasses: ["HLRequestWidget"],
  1647. //>>excludeEnd("ide");
  1648. pragmas: [],
  1649. messageSends: ["beSingleline", "new", "confirmationString:", "actionBlock:", "commitToPath:", "confirmButtonLabel:", "value:", "show"]
  1650. }),
  1651. $globals.HLPackageCommitErrorHelper);
  1652. $core.addMethod(
  1653. $core.method({
  1654. selector: "on:",
  1655. protocol: "instance creation",
  1656. fn: function (aToolModel){
  1657. var self=this,$self=this;
  1658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1659. return $core.withContext(function($ctx1) {
  1660. //>>excludeEnd("ctx");
  1661. var $1;
  1662. $1=$self._new();
  1663. $recv($1)._model_(aToolModel);
  1664. return $recv($1)._yourself();
  1665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1666. }, function($ctx1) {$ctx1.fill(self,"on:",{aToolModel:aToolModel})});
  1667. //>>excludeEnd("ctx");
  1668. },
  1669. //>>excludeStart("ide", pragmas.excludeIdeData);
  1670. args: ["aToolModel"],
  1671. source: "on: aToolModel\x0a\x09^ self new\x0a\x09\x09model: aToolModel;\x0a\x09\x09yourself",
  1672. referencedClasses: [],
  1673. //>>excludeEnd("ide");
  1674. pragmas: [],
  1675. messageSends: ["model:", "new", "yourself"]
  1676. }),
  1677. $globals.HLPackageCommitErrorHelper.a$cls);
  1678. });