Helios-Helpers.js 45 KB

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