Helios-Helpers.js 60 KB

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