Helios-Helpers.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. define("helios/Helios-Helpers", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Helios-Helpers');
  4. smalltalk.packages["Helios-Helpers"].transport = {"type":"amd","amdNamespace":"helios"};
  5. smalltalk.addClass('HLClassifier', globals.Object, ['next', 'method'], 'Helios-Helpers');
  6. 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.";
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "classify",
  10. protocol: 'protocol',
  11. fn: function (){
  12. var self=this;
  13. return smalltalk.withContext(function($ctx1) {
  14. var $1,$3,$2,$receiver;
  15. $1=self._next();
  16. $ctx1.sendIdx["next"]=1;
  17. if(($receiver = $1) == null || $receiver.isNil){
  18. return false;
  19. } else {
  20. $1;
  21. };
  22. $3=self._doClassify();
  23. if(smalltalk.assert($3)){
  24. $2=true;
  25. } else {
  26. $2=_st(self._next())._classify();
  27. };
  28. return $2;
  29. }, function($ctx1) {$ctx1.fill(self,"classify",{},globals.HLClassifier)})},
  30. args: [],
  31. source: "classify\x0a\x09self next ifNil: [ ^ false ].\x0a\x09\x0a\x09^ self doClassify\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: [ self next classify ]",
  32. messageSends: ["ifNil:", "next", "ifTrue:ifFalse:", "doClassify", "classify"],
  33. referencedClasses: []
  34. }),
  35. globals.HLClassifier);
  36. smalltalk.addMethod(
  37. smalltalk.method({
  38. selector: "doClassify",
  39. protocol: 'private',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. self._subclassResponsibility();
  44. return self}, function($ctx1) {$ctx1.fill(self,"doClassify",{},globals.HLClassifier)})},
  45. args: [],
  46. source: "doClassify\x0a\x09self subclassResponsibility",
  47. messageSends: ["subclassResponsibility"],
  48. referencedClasses: []
  49. }),
  50. globals.HLClassifier);
  51. smalltalk.addMethod(
  52. smalltalk.method({
  53. selector: "method",
  54. protocol: 'accessing',
  55. fn: function (){
  56. var self=this;
  57. var $1;
  58. $1=self["@method"];
  59. return $1;
  60. },
  61. args: [],
  62. source: "method\x0a\x09^ method",
  63. messageSends: [],
  64. referencedClasses: []
  65. }),
  66. globals.HLClassifier);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "method:",
  70. protocol: 'accessing',
  71. fn: function (anObject){
  72. var self=this;
  73. return smalltalk.withContext(function($ctx1) {
  74. var $1,$receiver;
  75. self["@method"]=anObject;
  76. $1=self._next();
  77. if(($receiver = $1) == null || $receiver.isNil){
  78. $1;
  79. } else {
  80. var nextLink;
  81. nextLink=$receiver;
  82. _st(nextLink)._method_(anObject);
  83. };
  84. return self}, function($ctx1) {$ctx1.fill(self,"method:",{anObject:anObject},globals.HLClassifier)})},
  85. args: ["anObject"],
  86. source: "method: anObject\x0a\x09method := anObject.\x0a\x09self next\x0a\x09\x09ifNotNil: [ :nextLink | nextLink method: anObject ]",
  87. messageSends: ["ifNotNil:", "next", "method:"],
  88. referencedClasses: []
  89. }),
  90. globals.HLClassifier);
  91. smalltalk.addMethod(
  92. smalltalk.method({
  93. selector: "next",
  94. protocol: 'accessing',
  95. fn: function (){
  96. var self=this;
  97. var $1;
  98. $1=self["@next"];
  99. return $1;
  100. },
  101. args: [],
  102. source: "next\x0a\x09^ next",
  103. messageSends: [],
  104. referencedClasses: []
  105. }),
  106. globals.HLClassifier);
  107. smalltalk.addMethod(
  108. smalltalk.method({
  109. selector: "next:",
  110. protocol: 'accessing',
  111. fn: function (anObject){
  112. var self=this;
  113. self["@next"]=anObject;
  114. return self},
  115. args: ["anObject"],
  116. source: "next: anObject\x0a\x09next := anObject",
  117. messageSends: [],
  118. referencedClasses: []
  119. }),
  120. globals.HLClassifier);
  121. smalltalk.addClass('HLAccessorClassifier', globals.HLClassifier, [], 'Helios-Helpers');
  122. globals.HLAccessorClassifier.comment="I am a classifier checking the method selector matches an instance variable name.";
  123. smalltalk.addMethod(
  124. smalltalk.method({
  125. selector: "doClassify",
  126. protocol: 'private',
  127. fn: function (){
  128. var self=this;
  129. var names,selector;
  130. return smalltalk.withContext(function($ctx1) {
  131. var $1,$2;
  132. names=_st(_st(self["@method"])._methodClass())._allInstanceVariableNames();
  133. selector=_st(self["@method"])._selector();
  134. $1=_st(_st(selector)._last()).__eq(":");
  135. if(smalltalk.assert($1)){
  136. selector=_st(selector)._allButLast();
  137. selector;
  138. };
  139. $2=_st(names)._includes_(selector);
  140. if(! smalltalk.assert($2)){
  141. return false;
  142. };
  143. _st(self["@method"])._protocol_("accessing");
  144. return true;
  145. }, function($ctx1) {$ctx1.fill(self,"doClassify",{names:names,selector:selector},globals.HLAccessorClassifier)})},
  146. args: [],
  147. source: "doClassify\x0a\x09| names selector |\x0a\x09\x0a\x09names := method methodClass 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.",
  148. messageSends: ["allInstanceVariableNames", "methodClass", "selector", "ifTrue:", "=", "last", "allButLast", "ifFalse:", "includes:", "protocol:"],
  149. referencedClasses: []
  150. }),
  151. globals.HLAccessorClassifier);
  152. smalltalk.addClass('HLImplementorClassifier', globals.HLClassifier, [], 'Helios-Helpers');
  153. globals.HLImplementorClassifier.comment="I am a classifier checking the other implementations of the same selector and choose the protocol the most populated.";
  154. smalltalk.addMethod(
  155. smalltalk.method({
  156. selector: "doClassify",
  157. protocol: 'private',
  158. fn: function (){
  159. var self=this;
  160. var currentClass;
  161. return smalltalk.withContext(function($ctx1) {
  162. var $1,$3,$4,$2;
  163. var $early={};
  164. try {
  165. currentClass=_st(self["@method"])._methodClass();
  166. _st((function(){
  167. return smalltalk.withContext(function($ctx2) {
  168. $1=_st(currentClass)._superclass();
  169. $ctx2.sendIdx["superclass"]=1;
  170. return _st($1)._isNil();
  171. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  172. return smalltalk.withContext(function($ctx2) {
  173. currentClass=_st(currentClass)._superclass();
  174. currentClass;
  175. $3=currentClass;
  176. $4=_st(self["@method"])._selector();
  177. $ctx2.sendIdx["selector"]=1;
  178. $2=_st($3)._includesSelector_($4);
  179. if(smalltalk.assert($2)){
  180. _st(self["@method"])._protocol_(_st(_st(currentClass).__gt_gt(_st(self["@method"])._selector()))._protocol());
  181. throw $early=[true];
  182. };
  183. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  184. return false;
  185. }
  186. catch(e) {if(e===$early)return e[0]; throw e}
  187. }, function($ctx1) {$ctx1.fill(self,"doClassify",{currentClass:currentClass},globals.HLImplementorClassifier)})},
  188. args: [],
  189. source: "doClassify\x0a\x09| currentClass |\x0a\x09currentClass := method methodClass.\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.",
  190. messageSends: ["methodClass", "whileFalse:", "isNil", "superclass", "ifTrue:", "includesSelector:", "selector", "protocol:", "protocol", ">>"],
  191. referencedClasses: []
  192. }),
  193. globals.HLImplementorClassifier);
  194. smalltalk.addClass('HLPrefixClassifier', globals.HLClassifier, ['prefixMapping'], 'Helios-Helpers');
  195. globals.HLPrefixClassifier.comment="I am classifier checking the method selector to know if it begins with a known prefix.";
  196. smalltalk.addMethod(
  197. smalltalk.method({
  198. selector: "buildPrefixDictionary",
  199. protocol: 'initialization',
  200. fn: function (){
  201. var self=this;
  202. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  203. return smalltalk.withContext(function($ctx1) {
  204. var $1,$2;
  205. self["@prefixMapping"]=_st($Dictionary())._new();
  206. $1=self["@prefixMapping"];
  207. _st($1)._at_put_("test","tests");
  208. $ctx1.sendIdx["at:put:"]=1;
  209. _st($1)._at_put_("bench","benchmarking");
  210. $ctx1.sendIdx["at:put:"]=2;
  211. _st($1)._at_put_("copy","copying");
  212. $ctx1.sendIdx["at:put:"]=3;
  213. _st($1)._at_put_("initialize","initialization");
  214. $ctx1.sendIdx["at:put:"]=4;
  215. _st($1)._at_put_("accept","visitor");
  216. $ctx1.sendIdx["at:put:"]=5;
  217. _st($1)._at_put_("visit","visitor");
  218. $ctx1.sendIdx["at:put:"]=6;
  219. _st($1)._at_put_("signal","signalling");
  220. $ctx1.sendIdx["at:put:"]=7;
  221. _st($1)._at_put_("parse","parsing");
  222. $ctx1.sendIdx["at:put:"]=8;
  223. _st($1)._at_put_("add","adding");
  224. $ctx1.sendIdx["at:put:"]=9;
  225. _st($1)._at_put_("is","testing");
  226. $ctx1.sendIdx["at:put:"]=10;
  227. _st($1)._at_put_("as","converting");
  228. $ctx1.sendIdx["at:put:"]=11;
  229. $2=_st($1)._at_put_("new","instance creation");
  230. return self}, function($ctx1) {$ctx1.fill(self,"buildPrefixDictionary",{},globals.HLPrefixClassifier)})},
  231. args: [],
  232. 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'.",
  233. messageSends: ["new", "at:put:"],
  234. referencedClasses: ["Dictionary"]
  235. }),
  236. globals.HLPrefixClassifier);
  237. smalltalk.addMethod(
  238. smalltalk.method({
  239. selector: "doClassify",
  240. protocol: 'private',
  241. fn: function (){
  242. var self=this;
  243. return smalltalk.withContext(function($ctx1) {
  244. var $1;
  245. var $early={};
  246. try {
  247. _st(self["@prefixMapping"])._keysAndValuesDo_((function(prefix,protocol){
  248. return smalltalk.withContext(function($ctx2) {
  249. $1=_st(_st(self["@method"])._selector())._beginsWith_(prefix);
  250. if(smalltalk.assert($1)){
  251. _st(self["@method"])._protocol_(protocol);
  252. throw $early=[true];
  253. };
  254. }, function($ctx2) {$ctx2.fillBlock({prefix:prefix,protocol:protocol},$ctx1,1)})}));
  255. return false;
  256. }
  257. catch(e) {if(e===$early)return e[0]; throw e}
  258. }, function($ctx1) {$ctx1.fill(self,"doClassify",{},globals.HLPrefixClassifier)})},
  259. args: [],
  260. 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.",
  261. messageSends: ["keysAndValuesDo:", "ifTrue:", "beginsWith:", "selector", "protocol:"],
  262. referencedClasses: []
  263. }),
  264. globals.HLPrefixClassifier);
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "initialize",
  268. protocol: 'initialization',
  269. fn: function (){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) {
  272. ($ctx1.supercall = true, globals.HLPrefixClassifier.superclass.fn.prototype._initialize.apply(_st(self), []));
  273. $ctx1.supercall = false;
  274. self._buildPrefixDictionary();
  275. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLPrefixClassifier)})},
  276. args: [],
  277. source: "initialize\x0a\x09super initialize.\x0a\x0a\x09self buildPrefixDictionary",
  278. messageSends: ["initialize", "buildPrefixDictionary"],
  279. referencedClasses: []
  280. }),
  281. globals.HLPrefixClassifier);
  282. smalltalk.addClass('HLSuperclassClassifier', globals.HLClassifier, [], 'Helios-Helpers');
  283. globals.HLSuperclassClassifier.comment="I am a classifier checking the superclass chain to find a matching selector.";
  284. smalltalk.addMethod(
  285. smalltalk.method({
  286. selector: "doClassify",
  287. protocol: 'private',
  288. fn: function (){
  289. var self=this;
  290. var protocolBag,methods,protocolToUse,counter;
  291. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  292. function $HLReferencesModel(){return globals.HLReferencesModel||(typeof HLReferencesModel=="undefined"?nil:HLReferencesModel)}
  293. return smalltalk.withContext(function($ctx1) {
  294. var $2,$1,$4,$3,$5;
  295. var $early={};
  296. try {
  297. protocolBag=_st($Dictionary())._new();
  298. $ctx1.sendIdx["new"]=1;
  299. methods=_st(_st($HLReferencesModel())._new())._implementorsOf_(_st(self["@method"])._selector());
  300. _st(methods)._ifEmpty_ifNotEmpty_((function(){
  301. throw $early=[false];
  302. }),(function(){
  303. return smalltalk.withContext(function($ctx2) {
  304. return _st(methods)._do_((function(aMethod){
  305. var protocol;
  306. return smalltalk.withContext(function($ctx3) {
  307. protocol=_st(_st(aMethod)._method())._protocol();
  308. protocol;
  309. $2=_st(self["@method"])._methodClass();
  310. $ctx3.sendIdx["methodClass"]=1;
  311. $1=_st($2).__eq(_st(aMethod)._methodClass());
  312. $ctx3.sendIdx["="]=1;
  313. if(! smalltalk.assert($1)){
  314. $4=_st(_st(protocol)._first()).__eq("*");
  315. $ctx3.sendIdx["="]=2;
  316. $3=_st($4)._or_((function(){
  317. return smalltalk.withContext(function($ctx4) {
  318. return _st(protocol).__eq(_st(self["@method"])._defaultProtocol());
  319. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)})}));
  320. if(! smalltalk.assert($3)){
  321. return _st(protocolBag)._at_put_(protocol,_st(_st(protocolBag)._at_ifAbsent_(protocol,(function(){
  322. return (0);
  323. }))).__plus((1)));
  324. };
  325. };
  326. }, function($ctx3) {$ctx3.fillBlock({aMethod:aMethod,protocol:protocol},$ctx2,3)})}));
  327. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  328. _st(protocolBag)._ifEmpty_((function(){
  329. throw $early=[false];
  330. }));
  331. protocolToUse=nil;
  332. counter=(0);
  333. _st(protocolBag)._keysAndValuesDo_((function(key,value){
  334. return smalltalk.withContext(function($ctx2) {
  335. $5=_st(value).__gt(counter);
  336. if(smalltalk.assert($5)){
  337. counter=value;
  338. counter;
  339. protocolToUse=key;
  340. return protocolToUse;
  341. };
  342. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,9)})}));
  343. _st(self["@method"])._protocol_(protocolToUse);
  344. return true;
  345. }
  346. catch(e) {if(e===$early)return e[0]; throw e}
  347. }, function($ctx1) {$ctx1.fill(self,"doClassify",{protocolBag:protocolBag,methods:methods,protocolToUse:protocolToUse,counter:counter},globals.HLSuperclassClassifier)})},
  348. args: [],
  349. 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 methodClass = aMethod methodClass)\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",
  350. messageSends: ["new", "implementorsOf:", "selector", "ifEmpty:ifNotEmpty:", "do:", "protocol", "method", "ifFalse:", "=", "methodClass", "or:", "first", "defaultProtocol", "at:put:", "+", "at:ifAbsent:", "ifEmpty:", "keysAndValuesDo:", "ifTrue:", ">", "protocol:"],
  351. referencedClasses: ["Dictionary", "HLReferencesModel"]
  352. }),
  353. globals.HLSuperclassClassifier);
  354. smalltalk.addClass('HLGenerationOutput', globals.Object, ['sourceCodes', 'protocol', 'targetClass'], 'Helios-Helpers');
  355. globals.HLGenerationOutput.comment="I am a simple data object used to store the result of a generation process.";
  356. smalltalk.addMethod(
  357. smalltalk.method({
  358. selector: "addSourceCode:",
  359. protocol: 'protocol',
  360. fn: function (aString){
  361. var self=this;
  362. return smalltalk.withContext(function($ctx1) {
  363. _st(self["@sourceCodes"])._add_(aString);
  364. return self}, function($ctx1) {$ctx1.fill(self,"addSourceCode:",{aString:aString},globals.HLGenerationOutput)})},
  365. args: ["aString"],
  366. source: "addSourceCode: aString\x0a\x09sourceCodes add: aString",
  367. messageSends: ["add:"],
  368. referencedClasses: []
  369. }),
  370. globals.HLGenerationOutput);
  371. smalltalk.addMethod(
  372. smalltalk.method({
  373. selector: "compile",
  374. protocol: 'protocol',
  375. fn: function (){
  376. var self=this;
  377. return smalltalk.withContext(function($ctx1) {
  378. var $1;
  379. _st(self["@sourceCodes"])._do_((function(methodSourceCode){
  380. return smalltalk.withContext(function($ctx2) {
  381. $1=_st(self["@targetClass"])._includesSelector_(_st(methodSourceCode)._selector());
  382. if(! smalltalk.assert($1)){
  383. return _st(self["@targetClass"])._compile_protocol_(_st(methodSourceCode)._sourceCode(),self["@protocol"]);
  384. };
  385. }, function($ctx2) {$ctx2.fillBlock({methodSourceCode:methodSourceCode},$ctx1,1)})}));
  386. return self}, function($ctx1) {$ctx1.fill(self,"compile",{},globals.HLGenerationOutput)})},
  387. args: [],
  388. 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 ] ]",
  389. messageSends: ["do:", "ifFalse:", "includesSelector:", "selector", "compile:protocol:", "sourceCode"],
  390. referencedClasses: []
  391. }),
  392. globals.HLGenerationOutput);
  393. smalltalk.addMethod(
  394. smalltalk.method({
  395. selector: "initialize",
  396. protocol: 'initialization',
  397. fn: function (){
  398. var self=this;
  399. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  400. return smalltalk.withContext(function($ctx1) {
  401. ($ctx1.supercall = true, globals.HLGenerationOutput.superclass.fn.prototype._initialize.apply(_st(self), []));
  402. $ctx1.supercall = false;
  403. self["@sourceCodes"]=_st($OrderedCollection())._new();
  404. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLGenerationOutput)})},
  405. args: [],
  406. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09sourceCodes := OrderedCollection new",
  407. messageSends: ["initialize", "new"],
  408. referencedClasses: ["OrderedCollection"]
  409. }),
  410. globals.HLGenerationOutput);
  411. smalltalk.addMethod(
  412. smalltalk.method({
  413. selector: "protocol",
  414. protocol: 'accessing',
  415. fn: function (){
  416. var self=this;
  417. var $1;
  418. $1=self["@protocol"];
  419. return $1;
  420. },
  421. args: [],
  422. source: "protocol\x0a\x09^ protocol",
  423. messageSends: [],
  424. referencedClasses: []
  425. }),
  426. globals.HLGenerationOutput);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "protocol:",
  430. protocol: 'accessing',
  431. fn: function (aString){
  432. var self=this;
  433. self["@protocol"]=aString;
  434. return self},
  435. args: ["aString"],
  436. source: "protocol: aString\x0a\x09protocol := aString",
  437. messageSends: [],
  438. referencedClasses: []
  439. }),
  440. globals.HLGenerationOutput);
  441. smalltalk.addMethod(
  442. smalltalk.method({
  443. selector: "sourceCodes",
  444. protocol: 'accessing',
  445. fn: function (){
  446. var self=this;
  447. var $1;
  448. $1=self["@sourceCodes"];
  449. return $1;
  450. },
  451. args: [],
  452. source: "sourceCodes\x0a\x09^ sourceCodes",
  453. messageSends: [],
  454. referencedClasses: []
  455. }),
  456. globals.HLGenerationOutput);
  457. smalltalk.addMethod(
  458. smalltalk.method({
  459. selector: "sourceCodes:",
  460. protocol: 'accessing',
  461. fn: function (aCollection){
  462. var self=this;
  463. self["@sourceCodes"]=aCollection;
  464. return self},
  465. args: ["aCollection"],
  466. source: "sourceCodes: aCollection\x0a\x09sourceCodes := aCollection",
  467. messageSends: [],
  468. referencedClasses: []
  469. }),
  470. globals.HLGenerationOutput);
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "targetClass",
  474. protocol: 'accessing',
  475. fn: function (){
  476. var self=this;
  477. var $1;
  478. $1=self["@targetClass"];
  479. return $1;
  480. },
  481. args: [],
  482. source: "targetClass\x0a\x09^ targetClass",
  483. messageSends: [],
  484. referencedClasses: []
  485. }),
  486. globals.HLGenerationOutput);
  487. smalltalk.addMethod(
  488. smalltalk.method({
  489. selector: "targetClass:",
  490. protocol: 'accessing',
  491. fn: function (aClass){
  492. var self=this;
  493. self["@targetClass"]=aClass;
  494. return self},
  495. args: ["aClass"],
  496. source: "targetClass: aClass\x0a\x09targetClass := aClass",
  497. messageSends: [],
  498. referencedClasses: []
  499. }),
  500. globals.HLGenerationOutput);
  501. smalltalk.addClass('HLMethodClassifier', globals.Object, ['firstClassifier'], 'Helios-Helpers');
  502. 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?";
  503. smalltalk.addMethod(
  504. smalltalk.method({
  505. selector: "addClassifier:",
  506. protocol: 'private',
  507. fn: function (aClassifier){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) {
  510. _st(aClassifier)._next_(self["@firstClassifier"]);
  511. self["@firstClassifier"]=aClassifier;
  512. return self}, function($ctx1) {$ctx1.fill(self,"addClassifier:",{aClassifier:aClassifier},globals.HLMethodClassifier)})},
  513. args: ["aClassifier"],
  514. source: "addClassifier: aClassifier\x0a\x09aClassifier next: firstClassifier.\x0a\x09firstClassifier := aClassifier",
  515. messageSends: ["next:"],
  516. referencedClasses: []
  517. }),
  518. globals.HLMethodClassifier);
  519. smalltalk.addMethod(
  520. smalltalk.method({
  521. selector: "classify:",
  522. protocol: 'protocol',
  523. fn: function (aMethod){
  524. var self=this;
  525. return smalltalk.withContext(function($ctx1) {
  526. var $1,$2;
  527. $1=self["@firstClassifier"];
  528. _st($1)._method_(aMethod);
  529. $2=_st($1)._classify();
  530. return self}, function($ctx1) {$ctx1.fill(self,"classify:",{aMethod:aMethod},globals.HLMethodClassifier)})},
  531. args: ["aMethod"],
  532. source: "classify: aMethod\x0a\x09firstClassifier\x0a\x09\x09method: aMethod;\x0a\x09\x09classify",
  533. messageSends: ["method:", "classify"],
  534. referencedClasses: []
  535. }),
  536. globals.HLMethodClassifier);
  537. smalltalk.addMethod(
  538. smalltalk.method({
  539. selector: "classifyAll:",
  540. protocol: 'protocol',
  541. fn: function (aCollectionOfMethods){
  542. var self=this;
  543. return smalltalk.withContext(function($ctx1) {
  544. _st(aCollectionOfMethods)._do_((function(method){
  545. return smalltalk.withContext(function($ctx2) {
  546. return self._classify_(method);
  547. }, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)})}));
  548. return self}, function($ctx1) {$ctx1.fill(self,"classifyAll:",{aCollectionOfMethods:aCollectionOfMethods},globals.HLMethodClassifier)})},
  549. args: ["aCollectionOfMethods"],
  550. source: "classifyAll: aCollectionOfMethods\x0a\x09aCollectionOfMethods do: [ :method |\x0a\x09\x09self classify: method ]",
  551. messageSends: ["do:", "classify:"],
  552. referencedClasses: []
  553. }),
  554. globals.HLMethodClassifier);
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "initialize",
  558. protocol: 'initialization',
  559. fn: function (){
  560. var self=this;
  561. return smalltalk.withContext(function($ctx1) {
  562. ($ctx1.supercall = true, globals.HLMethodClassifier.superclass.fn.prototype._initialize.apply(_st(self), []));
  563. $ctx1.supercall = false;
  564. self._setupClassifiers();
  565. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLMethodClassifier)})},
  566. args: [],
  567. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09self setupClassifiers",
  568. messageSends: ["initialize", "setupClassifiers"],
  569. referencedClasses: []
  570. }),
  571. globals.HLMethodClassifier);
  572. smalltalk.addMethod(
  573. smalltalk.method({
  574. selector: "setupClassifiers",
  575. protocol: 'initialization',
  576. fn: function (){
  577. var self=this;
  578. function $HLImplementorClassifier(){return globals.HLImplementorClassifier||(typeof HLImplementorClassifier=="undefined"?nil:HLImplementorClassifier)}
  579. function $HLPrefixClassifier(){return globals.HLPrefixClassifier||(typeof HLPrefixClassifier=="undefined"?nil:HLPrefixClassifier)}
  580. function $HLSuperclassClassifier(){return globals.HLSuperclassClassifier||(typeof HLSuperclassClassifier=="undefined"?nil:HLSuperclassClassifier)}
  581. function $HLAccessorClassifier(){return globals.HLAccessorClassifier||(typeof HLAccessorClassifier=="undefined"?nil:HLAccessorClassifier)}
  582. return smalltalk.withContext(function($ctx1) {
  583. var $1,$2,$3;
  584. $1=_st($HLImplementorClassifier())._new();
  585. $ctx1.sendIdx["new"]=1;
  586. self._addClassifier_($1);
  587. $ctx1.sendIdx["addClassifier:"]=1;
  588. $2=_st($HLPrefixClassifier())._new();
  589. $ctx1.sendIdx["new"]=2;
  590. self._addClassifier_($2);
  591. $ctx1.sendIdx["addClassifier:"]=2;
  592. $3=_st($HLSuperclassClassifier())._new();
  593. $ctx1.sendIdx["new"]=3;
  594. self._addClassifier_($3);
  595. $ctx1.sendIdx["addClassifier:"]=3;
  596. self._addClassifier_(_st($HLAccessorClassifier())._new());
  597. return self}, function($ctx1) {$ctx1.fill(self,"setupClassifiers",{},globals.HLMethodClassifier)})},
  598. args: [],
  599. source: "setupClassifiers\x0a\x09self addClassifier: HLImplementorClassifier new.\x0a\x09self addClassifier: HLPrefixClassifier new.\x0a\x09self addClassifier: HLSuperclassClassifier new.\x0a\x09self addClassifier: HLAccessorClassifier new",
  600. messageSends: ["addClassifier:", "new"],
  601. referencedClasses: ["HLImplementorClassifier", "HLPrefixClassifier", "HLSuperclassClassifier", "HLAccessorClassifier"]
  602. }),
  603. globals.HLMethodClassifier);
  604. smalltalk.addClass('HLMethodGenerator', globals.Object, ['output'], 'Helios-Helpers');
  605. 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`.";
  606. smalltalk.addMethod(
  607. smalltalk.method({
  608. selector: "class:",
  609. protocol: 'accessing',
  610. fn: function (aClass){
  611. var self=this;
  612. return smalltalk.withContext(function($ctx1) {
  613. _st(self["@output"])._targetClass_(aClass);
  614. return self}, function($ctx1) {$ctx1.fill(self,"class:",{aClass:aClass},globals.HLMethodGenerator)})},
  615. args: ["aClass"],
  616. source: "class: aClass\x0a\x09output targetClass: aClass",
  617. messageSends: ["targetClass:"],
  618. referencedClasses: []
  619. }),
  620. globals.HLMethodGenerator);
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "generate",
  624. protocol: 'protocol',
  625. fn: function (){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. var $1,$receiver;
  629. $1=_st(self["@output"])._targetClass();
  630. if(($receiver = $1) == null || $receiver.isNil){
  631. self._error_("class should not be nil");
  632. } else {
  633. $1;
  634. };
  635. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLMethodGenerator)})},
  636. args: [],
  637. source: "generate\x0a\x09output targetClass ifNil: [ self error: 'class should not be nil'].",
  638. messageSends: ["ifNil:", "targetClass", "error:"],
  639. referencedClasses: []
  640. }),
  641. globals.HLMethodGenerator);
  642. smalltalk.addMethod(
  643. smalltalk.method({
  644. selector: "initialize",
  645. protocol: 'initialization',
  646. fn: function (){
  647. var self=this;
  648. function $HLGenerationOutput(){return globals.HLGenerationOutput||(typeof HLGenerationOutput=="undefined"?nil:HLGenerationOutput)}
  649. return smalltalk.withContext(function($ctx1) {
  650. ($ctx1.supercall = true, globals.HLMethodGenerator.superclass.fn.prototype._initialize.apply(_st(self), []));
  651. $ctx1.supercall = false;
  652. self["@output"]=_st($HLGenerationOutput())._new();
  653. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLMethodGenerator)})},
  654. args: [],
  655. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09output := HLGenerationOutput new",
  656. messageSends: ["initialize", "new"],
  657. referencedClasses: ["HLGenerationOutput"]
  658. }),
  659. globals.HLMethodGenerator);
  660. smalltalk.addMethod(
  661. smalltalk.method({
  662. selector: "output",
  663. protocol: 'accessing',
  664. fn: function (){
  665. var self=this;
  666. var $1;
  667. $1=self["@output"];
  668. return $1;
  669. },
  670. args: [],
  671. source: "output\x0a\x09^ output",
  672. messageSends: [],
  673. referencedClasses: []
  674. }),
  675. globals.HLMethodGenerator);
  676. smalltalk.addClass('HLAccessorsGenerator', globals.HLMethodGenerator, [], 'Helios-Helpers');
  677. globals.HLAccessorsGenerator.comment="I am a generator used to compile the getters/setters of a class.";
  678. smalltalk.addMethod(
  679. smalltalk.method({
  680. selector: "accessorProtocolForObject",
  681. protocol: 'double-dispatch',
  682. fn: function (){
  683. var self=this;
  684. return smalltalk.withContext(function($ctx1) {
  685. _st(self["@output"])._protocol_("accessing");
  686. return self}, function($ctx1) {$ctx1.fill(self,"accessorProtocolForObject",{},globals.HLAccessorsGenerator)})},
  687. args: [],
  688. source: "accessorProtocolForObject\x0a\x09output protocol: 'accessing'",
  689. messageSends: ["protocol:"],
  690. referencedClasses: []
  691. }),
  692. globals.HLAccessorsGenerator);
  693. smalltalk.addMethod(
  694. smalltalk.method({
  695. selector: "accessorsForObject",
  696. protocol: 'double-dispatch',
  697. fn: function (){
  698. var self=this;
  699. var sources;
  700. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  701. return smalltalk.withContext(function($ctx1) {
  702. var $1,$2;
  703. sources=_st($OrderedCollection())._new();
  704. _st(_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted())._do_((function(each){
  705. return smalltalk.withContext(function($ctx2) {
  706. $1=sources;
  707. _st($1)._add_(self._getterFor_(each));
  708. $ctx2.sendIdx["add:"]=1;
  709. $2=_st($1)._add_(self._setterFor_(each));
  710. return $2;
  711. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  712. _st(self["@output"])._sourceCodes_(sources);
  713. return self}, function($ctx1) {$ctx1.fill(self,"accessorsForObject",{sources:sources},globals.HLAccessorsGenerator)})},
  714. args: [],
  715. 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",
  716. messageSends: ["new", "do:", "sorted", "instanceVariableNames", "targetClass", "add:", "getterFor:", "setterFor:", "sourceCodes:"],
  717. referencedClasses: ["OrderedCollection"]
  718. }),
  719. globals.HLAccessorsGenerator);
  720. smalltalk.addMethod(
  721. smalltalk.method({
  722. selector: "generate",
  723. protocol: 'protocol',
  724. fn: function (){
  725. var self=this;
  726. return smalltalk.withContext(function($ctx1) {
  727. var $1,$2;
  728. ($ctx1.supercall = true, globals.HLAccessorsGenerator.superclass.fn.prototype._generate.apply(_st(self), []));
  729. $ctx1.supercall = false;
  730. $1=_st(self["@output"])._targetClass();
  731. _st($1)._accessorsSourceCodesWith_(self);
  732. $2=_st($1)._accessorProtocolWith_(self);
  733. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLAccessorsGenerator)})},
  734. args: [],
  735. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09accessorsSourceCodesWith: self;\x0a\x09\x09accessorProtocolWith: self",
  736. messageSends: ["generate", "accessorsSourceCodesWith:", "targetClass", "accessorProtocolWith:"],
  737. referencedClasses: []
  738. }),
  739. globals.HLAccessorsGenerator);
  740. smalltalk.addMethod(
  741. smalltalk.method({
  742. selector: "getterFor:",
  743. protocol: 'private',
  744. fn: function (anInstanceVariable){
  745. var self=this;
  746. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  747. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  748. return smalltalk.withContext(function($ctx1) {
  749. var $2,$3,$1;
  750. $2=_st($HLMethodSourceCode())._new();
  751. _st($2)._selector_(anInstanceVariable);
  752. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  753. return smalltalk.withContext(function($ctx2) {
  754. _st(stream).__lt_lt(anInstanceVariable);
  755. $ctx2.sendIdx["<<"]=1;
  756. _st(_st(stream)._cr())._tab();
  757. return _st(_st(stream).__lt_lt("^ ")).__lt_lt(anInstanceVariable);
  758. $ctx2.sendIdx["<<"]=2;
  759. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  760. $1=$3;
  761. return $1;
  762. }, function($ctx1) {$ctx1.fill(self,"getterFor:",{anInstanceVariable:anInstanceVariable},globals.HLAccessorsGenerator)})},
  763. args: ["anInstanceVariable"],
  764. 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 ])",
  765. messageSends: ["selector:", "new", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  766. referencedClasses: ["HLMethodSourceCode", "String"]
  767. }),
  768. globals.HLAccessorsGenerator);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "setterFor:",
  772. protocol: 'private',
  773. fn: function (anInstanceVariable){
  774. var self=this;
  775. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  776. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  777. return smalltalk.withContext(function($ctx1) {
  778. var $2,$4,$3,$1;
  779. $2=_st($HLMethodSourceCode())._new();
  780. _st($2)._selector_(_st(anInstanceVariable).__comma(":"));
  781. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  782. return smalltalk.withContext(function($ctx2) {
  783. $4=_st(stream).__lt_lt(anInstanceVariable);
  784. $ctx2.sendIdx["<<"]=2;
  785. _st($4).__lt_lt(": anObject");
  786. $ctx2.sendIdx["<<"]=1;
  787. _st(_st(stream)._cr())._tab();
  788. return _st(_st(stream).__lt_lt(anInstanceVariable)).__lt_lt(" := anObject");
  789. $ctx2.sendIdx["<<"]=3;
  790. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  791. $1=$3;
  792. return $1;
  793. }, function($ctx1) {$ctx1.fill(self,"setterFor:",{anInstanceVariable:anInstanceVariable},globals.HLAccessorsGenerator)})},
  794. args: ["anInstanceVariable"],
  795. 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' ])",
  796. messageSends: ["selector:", "new", ",", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  797. referencedClasses: ["HLMethodSourceCode", "String"]
  798. }),
  799. globals.HLAccessorsGenerator);
  800. smalltalk.addClass('HLInitializeGenerator', globals.HLMethodGenerator, [], 'Helios-Helpers');
  801. 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";
  802. smalltalk.addMethod(
  803. smalltalk.method({
  804. selector: "generate",
  805. protocol: 'protocol',
  806. fn: function (){
  807. var self=this;
  808. return smalltalk.withContext(function($ctx1) {
  809. var $1,$2;
  810. ($ctx1.supercall = true, globals.HLInitializeGenerator.superclass.fn.prototype._generate.apply(_st(self), []));
  811. $ctx1.supercall = false;
  812. $1=_st(self["@output"])._targetClass();
  813. _st($1)._initializeSourceCodesWith_(self);
  814. $2=_st($1)._initializeProtocolWith_(self);
  815. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLInitializeGenerator)})},
  816. args: [],
  817. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09initializeSourceCodesWith: self;\x0a\x09\x09initializeProtocolWith: self",
  818. messageSends: ["generate", "initializeSourceCodesWith:", "targetClass", "initializeProtocolWith:"],
  819. referencedClasses: []
  820. }),
  821. globals.HLInitializeGenerator);
  822. smalltalk.addMethod(
  823. smalltalk.method({
  824. selector: "generateInitializeCodeForObject",
  825. protocol: 'private',
  826. fn: function (){
  827. var self=this;
  828. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  829. return smalltalk.withContext(function($ctx1) {
  830. var $3,$2,$4,$5,$6,$7,$8,$1;
  831. $1=_st($String())._streamContents_((function(str){
  832. var instVars,size;
  833. return smalltalk.withContext(function($ctx2) {
  834. instVars=_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted();
  835. instVars;
  836. size=_st(instVars)._size();
  837. size;
  838. _st(str).__lt_lt("initialize");
  839. $ctx2.sendIdx["<<"]=1;
  840. $3=_st(str)._cr();
  841. $ctx2.sendIdx["cr"]=1;
  842. $2=_st($3)._tab();
  843. $ctx2.sendIdx["tab"]=1;
  844. _st($2).__lt_lt("super initialize.");
  845. $ctx2.sendIdx["<<"]=2;
  846. $4=_st($2)._cr();
  847. $ctx2.sendIdx["cr"]=2;
  848. $4;
  849. $5=_st(str)._cr();
  850. $ctx2.sendIdx["cr"]=3;
  851. _st($5)._tab();
  852. $ctx2.sendIdx["tab"]=2;
  853. return _st(instVars)._withIndexDo_((function(name,index){
  854. return smalltalk.withContext(function($ctx3) {
  855. $6=_st(index).__tild_eq((1));
  856. $ctx3.sendIdx["~="]=1;
  857. if(smalltalk.assert($6)){
  858. _st(_st(str)._cr())._tab();
  859. };
  860. $7=_st(str).__lt_lt(name);
  861. $ctx3.sendIdx["<<"]=4;
  862. _st($7).__lt_lt(" := nil");
  863. $ctx3.sendIdx["<<"]=3;
  864. $8=_st(index).__tild_eq(size);
  865. if(smalltalk.assert($8)){
  866. return _st(str).__lt_lt(".");
  867. };
  868. }, function($ctx3) {$ctx3.fillBlock({name:name,index:index},$ctx2,2)})}));
  869. }, function($ctx2) {$ctx2.fillBlock({str:str,instVars:instVars,size:size},$ctx1,1)})}));
  870. return $1;
  871. }, function($ctx1) {$ctx1.fill(self,"generateInitializeCodeForObject",{},globals.HLInitializeGenerator)})},
  872. args: [],
  873. 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 << '.' ] ] ].",
  874. messageSends: ["streamContents:", "sorted", "instanceVariableNames", "targetClass", "size", "<<", "tab", "cr", "withIndexDo:", "ifTrue:", "~="],
  875. referencedClasses: ["String"]
  876. }),
  877. globals.HLInitializeGenerator);
  878. smalltalk.addMethod(
  879. smalltalk.method({
  880. selector: "initializeForObject",
  881. protocol: 'double-dispatch',
  882. fn: function (){
  883. var self=this;
  884. return smalltalk.withContext(function($ctx1) {
  885. _st(self["@output"])._addSourceCode_(self._initializeMethodForObject());
  886. return self}, function($ctx1) {$ctx1.fill(self,"initializeForObject",{},globals.HLInitializeGenerator)})},
  887. args: [],
  888. source: "initializeForObject\x0a\x09output addSourceCode: self initializeMethodForObject",
  889. messageSends: ["addSourceCode:", "initializeMethodForObject"],
  890. referencedClasses: []
  891. }),
  892. globals.HLInitializeGenerator);
  893. smalltalk.addMethod(
  894. smalltalk.method({
  895. selector: "initializeMethodForObject",
  896. protocol: 'private',
  897. fn: function (){
  898. var self=this;
  899. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  900. return smalltalk.withContext(function($ctx1) {
  901. var $2,$3,$1;
  902. $2=_st($HLMethodSourceCode())._new();
  903. _st($2)._selector_("initialize");
  904. _st($2)._sourceCode_(self._generateInitializeCodeForObject());
  905. $3=_st($2)._yourself();
  906. $1=$3;
  907. return $1;
  908. }, function($ctx1) {$ctx1.fill(self,"initializeMethodForObject",{},globals.HLInitializeGenerator)})},
  909. args: [],
  910. source: "initializeMethodForObject\x09\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector: 'initialize';\x0a\x09\x09sourceCode: self generateInitializeCodeForObject;\x0a\x09\x09yourself",
  911. messageSends: ["selector:", "new", "sourceCode:", "generateInitializeCodeForObject", "yourself"],
  912. referencedClasses: ["HLMethodSourceCode"]
  913. }),
  914. globals.HLInitializeGenerator);
  915. smalltalk.addMethod(
  916. smalltalk.method({
  917. selector: "initializeProtocolForObject",
  918. protocol: 'double-dispatch',
  919. fn: function (){
  920. var self=this;
  921. return smalltalk.withContext(function($ctx1) {
  922. _st(self["@output"])._protocol_("initialization");
  923. return self}, function($ctx1) {$ctx1.fill(self,"initializeProtocolForObject",{},globals.HLInitializeGenerator)})},
  924. args: [],
  925. source: "initializeProtocolForObject\x0a\x09output protocol: 'initialization'",
  926. messageSends: ["protocol:"],
  927. referencedClasses: []
  928. }),
  929. globals.HLInitializeGenerator);
  930. smalltalk.addClass('HLMethodSourceCode', globals.Object, ['selector', 'sourceCode'], 'Helios-Helpers');
  931. 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.";
  932. smalltalk.addMethod(
  933. smalltalk.method({
  934. selector: "selector",
  935. protocol: 'accessing',
  936. fn: function (){
  937. var self=this;
  938. var $1;
  939. $1=self["@selector"];
  940. return $1;
  941. },
  942. args: [],
  943. source: "selector\x0a\x09^ selector",
  944. messageSends: [],
  945. referencedClasses: []
  946. }),
  947. globals.HLMethodSourceCode);
  948. smalltalk.addMethod(
  949. smalltalk.method({
  950. selector: "selector:",
  951. protocol: 'accessing',
  952. fn: function (aSelector){
  953. var self=this;
  954. self["@selector"]=aSelector;
  955. return self},
  956. args: ["aSelector"],
  957. source: "selector: aSelector\x0a\x09selector := aSelector",
  958. messageSends: [],
  959. referencedClasses: []
  960. }),
  961. globals.HLMethodSourceCode);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "sourceCode",
  965. protocol: 'accessing',
  966. fn: function (){
  967. var self=this;
  968. var $1;
  969. $1=self["@sourceCode"];
  970. return $1;
  971. },
  972. args: [],
  973. source: "sourceCode\x0a\x09^ sourceCode",
  974. messageSends: [],
  975. referencedClasses: []
  976. }),
  977. globals.HLMethodSourceCode);
  978. smalltalk.addMethod(
  979. smalltalk.method({
  980. selector: "sourceCode:",
  981. protocol: 'accessing',
  982. fn: function (aString){
  983. var self=this;
  984. self["@sourceCode"]=aString;
  985. return self},
  986. args: ["aString"],
  987. source: "sourceCode: aString\x0a\x09sourceCode := aString",
  988. messageSends: [],
  989. referencedClasses: []
  990. }),
  991. globals.HLMethodSourceCode);
  992. smalltalk.addClass('HLPackageCommitErrorHelper', globals.Object, ['model'], 'Helios-Helpers');
  993. smalltalk.addMethod(
  994. smalltalk.method({
  995. selector: "commitPackage",
  996. protocol: 'actions',
  997. fn: function (){
  998. var self=this;
  999. function $HLCommitPackageCommand(){return globals.HLCommitPackageCommand||(typeof HLCommitPackageCommand=="undefined"?nil:HLCommitPackageCommand)}
  1000. return smalltalk.withContext(function($ctx1) {
  1001. _st(_st($HLCommitPackageCommand())._for_(self._model()))._execute();
  1002. return self}, function($ctx1) {$ctx1.fill(self,"commitPackage",{},globals.HLPackageCommitErrorHelper)})},
  1003. args: [],
  1004. source: "commitPackage\x0a\x09(HLCommitPackageCommand for: self model)\x0a\x09\x09execute",
  1005. messageSends: ["execute", "for:", "model"],
  1006. referencedClasses: ["HLCommitPackageCommand"]
  1007. }),
  1008. globals.HLPackageCommitErrorHelper);
  1009. smalltalk.addMethod(
  1010. smalltalk.method({
  1011. selector: "commitToPath:",
  1012. protocol: 'actions',
  1013. fn: function (aString){
  1014. var self=this;
  1015. return smalltalk.withContext(function($ctx1) {
  1016. _st(_st(self._package())._transport())._setPath_(aString);
  1017. self._commitPackage();
  1018. return self}, function($ctx1) {$ctx1.fill(self,"commitToPath:",{aString:aString},globals.HLPackageCommitErrorHelper)})},
  1019. args: ["aString"],
  1020. 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",
  1021. messageSends: ["setPath:", "transport", "package", "commitPackage"],
  1022. referencedClasses: []
  1023. }),
  1024. globals.HLPackageCommitErrorHelper);
  1025. smalltalk.addMethod(
  1026. smalltalk.method({
  1027. selector: "model",
  1028. protocol: 'accessing',
  1029. fn: function (){
  1030. var self=this;
  1031. var $1;
  1032. $1=self["@model"];
  1033. return $1;
  1034. },
  1035. args: [],
  1036. source: "model\x0a\x09^ model",
  1037. messageSends: [],
  1038. referencedClasses: []
  1039. }),
  1040. globals.HLPackageCommitErrorHelper);
  1041. smalltalk.addMethod(
  1042. smalltalk.method({
  1043. selector: "model:",
  1044. protocol: 'accessing',
  1045. fn: function (aToolModel){
  1046. var self=this;
  1047. self["@model"]=aToolModel;
  1048. return self},
  1049. args: ["aToolModel"],
  1050. source: "model: aToolModel\x0a\x09model := aToolModel",
  1051. messageSends: [],
  1052. referencedClasses: []
  1053. }),
  1054. globals.HLPackageCommitErrorHelper);
  1055. smalltalk.addMethod(
  1056. smalltalk.method({
  1057. selector: "package",
  1058. protocol: 'accessing',
  1059. fn: function (){
  1060. var self=this;
  1061. return smalltalk.withContext(function($ctx1) {
  1062. var $1;
  1063. $1=_st(self._model())._packageToCommit();
  1064. return $1;
  1065. }, function($ctx1) {$ctx1.fill(self,"package",{},globals.HLPackageCommitErrorHelper)})},
  1066. args: [],
  1067. source: "package\x0a\x09^ self model packageToCommit",
  1068. messageSends: ["packageToCommit", "model"],
  1069. referencedClasses: []
  1070. }),
  1071. globals.HLPackageCommitErrorHelper);
  1072. smalltalk.addMethod(
  1073. smalltalk.method({
  1074. selector: "showHelp",
  1075. protocol: 'actions',
  1076. fn: function (){
  1077. var self=this;
  1078. function $HLConfirmationWidget(){return globals.HLConfirmationWidget||(typeof HLConfirmationWidget=="undefined"?nil:HLConfirmationWidget)}
  1079. return smalltalk.withContext(function($ctx1) {
  1080. var $1,$2,$3,$4;
  1081. $1=_st($HLConfirmationWidget())._new();
  1082. $2=$1;
  1083. $3=_st("Commit failed for namespace \x22".__comma(_st(_st(self._package())._transport())._namespace())).__comma("\x22. Do you want to commit to another path?");
  1084. $ctx1.sendIdx[","]=1;
  1085. _st($2)._confirmationString_($3);
  1086. _st($1)._actionBlock_((function(){
  1087. return smalltalk.withContext(function($ctx2) {
  1088. return self._showNewCommitPath();
  1089. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1090. _st($1)._cancelButtonLabel_("Abandon");
  1091. _st($1)._confirmButtonLabel_("Set path");
  1092. $4=_st($1)._show();
  1093. return self}, function($ctx1) {$ctx1.fill(self,"showHelp",{},globals.HLPackageCommitErrorHelper)})},
  1094. args: [],
  1095. 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",
  1096. messageSends: ["confirmationString:", "new", ",", "namespace", "transport", "package", "actionBlock:", "showNewCommitPath", "cancelButtonLabel:", "confirmButtonLabel:", "show"],
  1097. referencedClasses: ["HLConfirmationWidget"]
  1098. }),
  1099. globals.HLPackageCommitErrorHelper);
  1100. smalltalk.addMethod(
  1101. smalltalk.method({
  1102. selector: "showNewCommitPath",
  1103. protocol: 'actions',
  1104. fn: function (){
  1105. var self=this;
  1106. function $HLRequestWidget(){return globals.HLRequestWidget||(typeof HLRequestWidget=="undefined"?nil:HLRequestWidget)}
  1107. return smalltalk.withContext(function($ctx1) {
  1108. var $1,$2;
  1109. $1=_st($HLRequestWidget())._new();
  1110. _st($1)._beSingleline();
  1111. _st($1)._confirmationString_("Set commit path");
  1112. _st($1)._actionBlock_((function(url){
  1113. return smalltalk.withContext(function($ctx2) {
  1114. return self._commitToPath_(url);
  1115. }, function($ctx2) {$ctx2.fillBlock({url:url},$ctx1,1)})}));
  1116. _st($1)._confirmButtonLabel_("Commit with new path");
  1117. _st($1)._value_("/src");
  1118. $2=_st($1)._show();
  1119. return self}, function($ctx1) {$ctx1.fill(self,"showNewCommitPath",{},globals.HLPackageCommitErrorHelper)})},
  1120. args: [],
  1121. 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",
  1122. messageSends: ["beSingleline", "new", "confirmationString:", "actionBlock:", "commitToPath:", "confirmButtonLabel:", "value:", "show"],
  1123. referencedClasses: ["HLRequestWidget"]
  1124. }),
  1125. globals.HLPackageCommitErrorHelper);
  1126. smalltalk.addMethod(
  1127. smalltalk.method({
  1128. selector: "on:",
  1129. protocol: 'instance creation',
  1130. fn: function (aToolModel){
  1131. var self=this;
  1132. return smalltalk.withContext(function($ctx1) {
  1133. var $2,$3,$1;
  1134. $2=self._new();
  1135. _st($2)._model_(aToolModel);
  1136. $3=_st($2)._yourself();
  1137. $1=$3;
  1138. return $1;
  1139. }, function($ctx1) {$ctx1.fill(self,"on:",{aToolModel:aToolModel},globals.HLPackageCommitErrorHelper.klass)})},
  1140. args: ["aToolModel"],
  1141. source: "on: aToolModel\x0a\x09^ self new\x0a\x09\x09model: aToolModel;\x0a\x09\x09yourself",
  1142. messageSends: ["model:", "new", "yourself"],
  1143. referencedClasses: []
  1144. }),
  1145. globals.HLPackageCommitErrorHelper.klass);
  1146. });