Helios-Helpers.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. define("amber_core/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":"amber_core"};
  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;
  14. $1=self._next();
  15. $ctx1.sendIdx["next"]=1;
  16. if(($receiver = $1) == nil || $receiver == null){
  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;
  74. self["@method"]=anObject;
  75. $1=self._next();
  76. if(($receiver = $1) == nil || $receiver == null){
  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. globals.HLPrefixClassifier.superclass.fn.prototype._initialize.apply(_st(self), []);
  272. self._buildPrefixDictionary();
  273. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLPrefixClassifier)})},
  274. args: [],
  275. source: "initialize\x0a\x09super initialize.\x0a\x0a\x09self buildPrefixDictionary",
  276. messageSends: ["initialize", "buildPrefixDictionary"],
  277. referencedClasses: []
  278. }),
  279. globals.HLPrefixClassifier);
  280. smalltalk.addClass('HLSuperclassClassifier', globals.HLClassifier, [], 'Helios-Helpers');
  281. globals.HLSuperclassClassifier.comment="I am a classifier checking the superclass chain to find a matching selector.";
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "doClassify",
  285. protocol: 'private',
  286. fn: function (){
  287. var self=this;
  288. var protocolBag,methods,protocolToUse,counter;
  289. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  290. function $HLReferencesModel(){return globals.HLReferencesModel||(typeof HLReferencesModel=="undefined"?nil:HLReferencesModel)}
  291. return smalltalk.withContext(function($ctx1) {
  292. var $2,$1,$4,$3,$5;
  293. var $early={};
  294. try {
  295. protocolBag=_st($Dictionary())._new();
  296. $ctx1.sendIdx["new"]=1;
  297. methods=_st(_st($HLReferencesModel())._new())._implementorsOf_(_st(self["@method"])._selector());
  298. _st(methods)._ifEmpty_ifNotEmpty_((function(){
  299. throw $early=[false];
  300. }),(function(){
  301. return smalltalk.withContext(function($ctx2) {
  302. return _st(methods)._do_((function(aMethod){
  303. var protocol;
  304. return smalltalk.withContext(function($ctx3) {
  305. protocol=_st(_st(aMethod)._method())._protocol();
  306. protocol;
  307. $2=_st(self["@method"])._methodClass();
  308. $ctx3.sendIdx["methodClass"]=1;
  309. $1=_st($2).__eq(_st(aMethod)._methodClass());
  310. $ctx3.sendIdx["="]=1;
  311. if(! smalltalk.assert($1)){
  312. $4=_st(_st(protocol)._first()).__eq("*");
  313. $ctx3.sendIdx["="]=2;
  314. $3=_st($4)._or_((function(){
  315. return smalltalk.withContext(function($ctx4) {
  316. return _st(protocol).__eq(_st(self["@method"])._defaultProtocol());
  317. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)})}));
  318. if(! smalltalk.assert($3)){
  319. return _st(protocolBag)._at_put_(protocol,_st(_st(protocolBag)._at_ifAbsent_(protocol,(function(){
  320. return (0);
  321. }))).__plus((1)));
  322. };
  323. };
  324. }, function($ctx3) {$ctx3.fillBlock({aMethod:aMethod,protocol:protocol},$ctx2,3)})}));
  325. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  326. _st(protocolBag)._ifEmpty_((function(){
  327. throw $early=[false];
  328. }));
  329. protocolToUse=nil;
  330. counter=(0);
  331. _st(protocolBag)._keysAndValuesDo_((function(key,value){
  332. return smalltalk.withContext(function($ctx2) {
  333. $5=_st(value).__gt(counter);
  334. if(smalltalk.assert($5)){
  335. counter=value;
  336. counter;
  337. protocolToUse=key;
  338. return protocolToUse;
  339. };
  340. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,9)})}));
  341. _st(self["@method"])._protocol_(protocolToUse);
  342. return true;
  343. }
  344. catch(e) {if(e===$early)return e[0]; throw e}
  345. }, function($ctx1) {$ctx1.fill(self,"doClassify",{protocolBag:protocolBag,methods:methods,protocolToUse:protocolToUse,counter:counter},globals.HLSuperclassClassifier)})},
  346. args: [],
  347. 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",
  348. messageSends: ["new", "implementorsOf:", "selector", "ifEmpty:ifNotEmpty:", "do:", "protocol", "method", "ifFalse:", "=", "methodClass", "or:", "first", "defaultProtocol", "at:put:", "+", "at:ifAbsent:", "ifEmpty:", "keysAndValuesDo:", "ifTrue:", ">", "protocol:"],
  349. referencedClasses: ["Dictionary", "HLReferencesModel"]
  350. }),
  351. globals.HLSuperclassClassifier);
  352. smalltalk.addClass('HLGenerationOutput', globals.Object, ['sourceCodes', 'protocol', 'targetClass'], 'Helios-Helpers');
  353. globals.HLGenerationOutput.comment="I am a simple data object used to store the result of a generation process.";
  354. smalltalk.addMethod(
  355. smalltalk.method({
  356. selector: "addSourceCode:",
  357. protocol: 'protocol',
  358. fn: function (aString){
  359. var self=this;
  360. return smalltalk.withContext(function($ctx1) {
  361. _st(self["@sourceCodes"])._add_(aString);
  362. return self}, function($ctx1) {$ctx1.fill(self,"addSourceCode:",{aString:aString},globals.HLGenerationOutput)})},
  363. args: ["aString"],
  364. source: "addSourceCode: aString\x0a\x09sourceCodes add: aString",
  365. messageSends: ["add:"],
  366. referencedClasses: []
  367. }),
  368. globals.HLGenerationOutput);
  369. smalltalk.addMethod(
  370. smalltalk.method({
  371. selector: "compile",
  372. protocol: 'protocol',
  373. fn: function (){
  374. var self=this;
  375. return smalltalk.withContext(function($ctx1) {
  376. var $1;
  377. _st(self["@sourceCodes"])._do_((function(methodSourceCode){
  378. return smalltalk.withContext(function($ctx2) {
  379. $1=_st(self["@targetClass"])._includesSelector_(_st(methodSourceCode)._selector());
  380. if(! smalltalk.assert($1)){
  381. return _st(self["@targetClass"])._compile_protocol_(_st(methodSourceCode)._sourceCode(),self["@protocol"]);
  382. };
  383. }, function($ctx2) {$ctx2.fillBlock({methodSourceCode:methodSourceCode},$ctx1,1)})}));
  384. return self}, function($ctx1) {$ctx1.fill(self,"compile",{},globals.HLGenerationOutput)})},
  385. args: [],
  386. 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 ] ]",
  387. messageSends: ["do:", "ifFalse:", "includesSelector:", "selector", "compile:protocol:", "sourceCode"],
  388. referencedClasses: []
  389. }),
  390. globals.HLGenerationOutput);
  391. smalltalk.addMethod(
  392. smalltalk.method({
  393. selector: "initialize",
  394. protocol: 'initialization',
  395. fn: function (){
  396. var self=this;
  397. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  398. return smalltalk.withContext(function($ctx1) {
  399. globals.HLGenerationOutput.superclass.fn.prototype._initialize.apply(_st(self), []);
  400. self["@sourceCodes"]=_st($OrderedCollection())._new();
  401. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLGenerationOutput)})},
  402. args: [],
  403. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09sourceCodes := OrderedCollection new",
  404. messageSends: ["initialize", "new"],
  405. referencedClasses: ["OrderedCollection"]
  406. }),
  407. globals.HLGenerationOutput);
  408. smalltalk.addMethod(
  409. smalltalk.method({
  410. selector: "protocol",
  411. protocol: 'accessing',
  412. fn: function (){
  413. var self=this;
  414. var $1;
  415. $1=self["@protocol"];
  416. return $1;
  417. },
  418. args: [],
  419. source: "protocol\x0a\x09^ protocol",
  420. messageSends: [],
  421. referencedClasses: []
  422. }),
  423. globals.HLGenerationOutput);
  424. smalltalk.addMethod(
  425. smalltalk.method({
  426. selector: "protocol:",
  427. protocol: 'accessing',
  428. fn: function (aString){
  429. var self=this;
  430. self["@protocol"]=aString;
  431. return self},
  432. args: ["aString"],
  433. source: "protocol: aString\x0a\x09protocol := aString",
  434. messageSends: [],
  435. referencedClasses: []
  436. }),
  437. globals.HLGenerationOutput);
  438. smalltalk.addMethod(
  439. smalltalk.method({
  440. selector: "sourceCodes",
  441. protocol: 'accessing',
  442. fn: function (){
  443. var self=this;
  444. var $1;
  445. $1=self["@sourceCodes"];
  446. return $1;
  447. },
  448. args: [],
  449. source: "sourceCodes\x0a\x09^ sourceCodes",
  450. messageSends: [],
  451. referencedClasses: []
  452. }),
  453. globals.HLGenerationOutput);
  454. smalltalk.addMethod(
  455. smalltalk.method({
  456. selector: "sourceCodes:",
  457. protocol: 'accessing',
  458. fn: function (aCollection){
  459. var self=this;
  460. self["@sourceCodes"]=aCollection;
  461. return self},
  462. args: ["aCollection"],
  463. source: "sourceCodes: aCollection\x0a\x09sourceCodes := aCollection",
  464. messageSends: [],
  465. referencedClasses: []
  466. }),
  467. globals.HLGenerationOutput);
  468. smalltalk.addMethod(
  469. smalltalk.method({
  470. selector: "targetClass",
  471. protocol: 'accessing',
  472. fn: function (){
  473. var self=this;
  474. var $1;
  475. $1=self["@targetClass"];
  476. return $1;
  477. },
  478. args: [],
  479. source: "targetClass\x0a\x09^ targetClass",
  480. messageSends: [],
  481. referencedClasses: []
  482. }),
  483. globals.HLGenerationOutput);
  484. smalltalk.addMethod(
  485. smalltalk.method({
  486. selector: "targetClass:",
  487. protocol: 'accessing',
  488. fn: function (aClass){
  489. var self=this;
  490. self["@targetClass"]=aClass;
  491. return self},
  492. args: ["aClass"],
  493. source: "targetClass: aClass\x0a\x09targetClass := aClass",
  494. messageSends: [],
  495. referencedClasses: []
  496. }),
  497. globals.HLGenerationOutput);
  498. smalltalk.addClass('HLMethodClassifier', globals.Object, ['firstClassifier'], 'Helios-Helpers');
  499. 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?";
  500. smalltalk.addMethod(
  501. smalltalk.method({
  502. selector: "addClassifier:",
  503. protocol: 'private',
  504. fn: function (aClassifier){
  505. var self=this;
  506. return smalltalk.withContext(function($ctx1) {
  507. _st(aClassifier)._next_(self["@firstClassifier"]);
  508. self["@firstClassifier"]=aClassifier;
  509. return self}, function($ctx1) {$ctx1.fill(self,"addClassifier:",{aClassifier:aClassifier},globals.HLMethodClassifier)})},
  510. args: ["aClassifier"],
  511. source: "addClassifier: aClassifier\x0a\x09aClassifier next: firstClassifier.\x0a\x09firstClassifier := aClassifier",
  512. messageSends: ["next:"],
  513. referencedClasses: []
  514. }),
  515. globals.HLMethodClassifier);
  516. smalltalk.addMethod(
  517. smalltalk.method({
  518. selector: "classify:",
  519. protocol: 'protocol',
  520. fn: function (aMethod){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. var $1,$2;
  524. $1=self["@firstClassifier"];
  525. _st($1)._method_(aMethod);
  526. $2=_st($1)._classify();
  527. return self}, function($ctx1) {$ctx1.fill(self,"classify:",{aMethod:aMethod},globals.HLMethodClassifier)})},
  528. args: ["aMethod"],
  529. source: "classify: aMethod\x0a\x09firstClassifier\x0a\x09\x09method: aMethod;\x0a\x09\x09classify",
  530. messageSends: ["method:", "classify"],
  531. referencedClasses: []
  532. }),
  533. globals.HLMethodClassifier);
  534. smalltalk.addMethod(
  535. smalltalk.method({
  536. selector: "classifyAll:",
  537. protocol: 'protocol',
  538. fn: function (aCollectionOfMethods){
  539. var self=this;
  540. return smalltalk.withContext(function($ctx1) {
  541. _st(aCollectionOfMethods)._do_((function(method){
  542. return smalltalk.withContext(function($ctx2) {
  543. return self._classify_(method);
  544. }, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)})}));
  545. return self}, function($ctx1) {$ctx1.fill(self,"classifyAll:",{aCollectionOfMethods:aCollectionOfMethods},globals.HLMethodClassifier)})},
  546. args: ["aCollectionOfMethods"],
  547. source: "classifyAll: aCollectionOfMethods\x0a\x09aCollectionOfMethods do: [ :method |\x0a\x09\x09self classify: method ]",
  548. messageSends: ["do:", "classify:"],
  549. referencedClasses: []
  550. }),
  551. globals.HLMethodClassifier);
  552. smalltalk.addMethod(
  553. smalltalk.method({
  554. selector: "initialize",
  555. protocol: 'initialization',
  556. fn: function (){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx1) {
  559. globals.HLMethodClassifier.superclass.fn.prototype._initialize.apply(_st(self), []);
  560. self._setupClassifiers();
  561. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLMethodClassifier)})},
  562. args: [],
  563. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09self setupClassifiers",
  564. messageSends: ["initialize", "setupClassifiers"],
  565. referencedClasses: []
  566. }),
  567. globals.HLMethodClassifier);
  568. smalltalk.addMethod(
  569. smalltalk.method({
  570. selector: "setupClassifiers",
  571. protocol: 'initialization',
  572. fn: function (){
  573. var self=this;
  574. function $HLImplementorClassifier(){return globals.HLImplementorClassifier||(typeof HLImplementorClassifier=="undefined"?nil:HLImplementorClassifier)}
  575. function $HLPrefixClassifier(){return globals.HLPrefixClassifier||(typeof HLPrefixClassifier=="undefined"?nil:HLPrefixClassifier)}
  576. function $HLSuperclassClassifier(){return globals.HLSuperclassClassifier||(typeof HLSuperclassClassifier=="undefined"?nil:HLSuperclassClassifier)}
  577. function $HLAccessorClassifier(){return globals.HLAccessorClassifier||(typeof HLAccessorClassifier=="undefined"?nil:HLAccessorClassifier)}
  578. return smalltalk.withContext(function($ctx1) {
  579. var $1,$2,$3;
  580. $1=_st($HLImplementorClassifier())._new();
  581. $ctx1.sendIdx["new"]=1;
  582. self._addClassifier_($1);
  583. $ctx1.sendIdx["addClassifier:"]=1;
  584. $2=_st($HLPrefixClassifier())._new();
  585. $ctx1.sendIdx["new"]=2;
  586. self._addClassifier_($2);
  587. $ctx1.sendIdx["addClassifier:"]=2;
  588. $3=_st($HLSuperclassClassifier())._new();
  589. $ctx1.sendIdx["new"]=3;
  590. self._addClassifier_($3);
  591. $ctx1.sendIdx["addClassifier:"]=3;
  592. self._addClassifier_(_st($HLAccessorClassifier())._new());
  593. return self}, function($ctx1) {$ctx1.fill(self,"setupClassifiers",{},globals.HLMethodClassifier)})},
  594. args: [],
  595. source: "setupClassifiers\x0a\x09self addClassifier: HLImplementorClassifier new.\x0a\x09self addClassifier: HLPrefixClassifier new.\x0a\x09self addClassifier: HLSuperclassClassifier new.\x0a\x09self addClassifier: HLAccessorClassifier new",
  596. messageSends: ["addClassifier:", "new"],
  597. referencedClasses: ["HLImplementorClassifier", "HLPrefixClassifier", "HLSuperclassClassifier", "HLAccessorClassifier"]
  598. }),
  599. globals.HLMethodClassifier);
  600. smalltalk.addClass('HLMethodGenerator', globals.Object, ['output'], 'Helios-Helpers');
  601. globals.HLMethodGenerator.comment="I am the abstract super class of the method generators.\x0a\x0aMy main method is `generate` which produce an `output` object";
  602. smalltalk.addMethod(
  603. smalltalk.method({
  604. selector: "class:",
  605. protocol: 'accessing',
  606. fn: function (aClass){
  607. var self=this;
  608. return smalltalk.withContext(function($ctx1) {
  609. _st(self["@output"])._targetClass_(aClass);
  610. return self}, function($ctx1) {$ctx1.fill(self,"class:",{aClass:aClass},globals.HLMethodGenerator)})},
  611. args: ["aClass"],
  612. source: "class: aClass\x0a\x09output targetClass: aClass",
  613. messageSends: ["targetClass:"],
  614. referencedClasses: []
  615. }),
  616. globals.HLMethodGenerator);
  617. smalltalk.addMethod(
  618. smalltalk.method({
  619. selector: "generate",
  620. protocol: 'protocol',
  621. fn: function (){
  622. var self=this;
  623. return smalltalk.withContext(function($ctx1) {
  624. var $1;
  625. $1=_st(self["@output"])._targetClass();
  626. if(($receiver = $1) == nil || $receiver == null){
  627. self._error_("class should not be nil");
  628. } else {
  629. $1;
  630. };
  631. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLMethodGenerator)})},
  632. args: [],
  633. source: "generate\x0a\x09output targetClass ifNil: [ self error: 'class should not be nil'].",
  634. messageSends: ["ifNil:", "targetClass", "error:"],
  635. referencedClasses: []
  636. }),
  637. globals.HLMethodGenerator);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "initialize",
  641. protocol: 'initialization',
  642. fn: function (){
  643. var self=this;
  644. function $HLGenerationOutput(){return globals.HLGenerationOutput||(typeof HLGenerationOutput=="undefined"?nil:HLGenerationOutput)}
  645. return smalltalk.withContext(function($ctx1) {
  646. globals.HLMethodGenerator.superclass.fn.prototype._initialize.apply(_st(self), []);
  647. self["@output"]=_st($HLGenerationOutput())._new();
  648. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLMethodGenerator)})},
  649. args: [],
  650. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09output := HLGenerationOutput new",
  651. messageSends: ["initialize", "new"],
  652. referencedClasses: ["HLGenerationOutput"]
  653. }),
  654. globals.HLMethodGenerator);
  655. smalltalk.addMethod(
  656. smalltalk.method({
  657. selector: "output",
  658. protocol: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. var $1;
  662. $1=self["@output"];
  663. return $1;
  664. },
  665. args: [],
  666. source: "output\x0a\x09^ output",
  667. messageSends: [],
  668. referencedClasses: []
  669. }),
  670. globals.HLMethodGenerator);
  671. smalltalk.addClass('HLAccessorsGenerator', globals.HLMethodGenerator, [], 'Helios-Helpers');
  672. globals.HLAccessorsGenerator.comment="I am a generator used to compile the getters/setters of a class";
  673. smalltalk.addMethod(
  674. smalltalk.method({
  675. selector: "accessorProtocolForObject",
  676. protocol: 'double-dispatch',
  677. fn: function (){
  678. var self=this;
  679. return smalltalk.withContext(function($ctx1) {
  680. _st(self["@output"])._protocol_("accessing");
  681. return self}, function($ctx1) {$ctx1.fill(self,"accessorProtocolForObject",{},globals.HLAccessorsGenerator)})},
  682. args: [],
  683. source: "accessorProtocolForObject\x0a\x09output protocol: 'accessing'",
  684. messageSends: ["protocol:"],
  685. referencedClasses: []
  686. }),
  687. globals.HLAccessorsGenerator);
  688. smalltalk.addMethod(
  689. smalltalk.method({
  690. selector: "accessorsForObject",
  691. protocol: 'double-dispatch',
  692. fn: function (){
  693. var self=this;
  694. var sources;
  695. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  696. return smalltalk.withContext(function($ctx1) {
  697. var $1,$2;
  698. sources=_st($OrderedCollection())._new();
  699. _st(_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted())._do_((function(each){
  700. return smalltalk.withContext(function($ctx2) {
  701. $1=sources;
  702. _st($1)._add_(self._getterFor_(each));
  703. $ctx2.sendIdx["add:"]=1;
  704. $2=_st($1)._add_(self._setterFor_(each));
  705. return $2;
  706. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  707. _st(self["@output"])._sourceCodes_(sources);
  708. return self}, function($ctx1) {$ctx1.fill(self,"accessorsForObject",{sources:sources},globals.HLAccessorsGenerator)})},
  709. args: [],
  710. 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",
  711. messageSends: ["new", "do:", "sorted", "instanceVariableNames", "targetClass", "add:", "getterFor:", "setterFor:", "sourceCodes:"],
  712. referencedClasses: ["OrderedCollection"]
  713. }),
  714. globals.HLAccessorsGenerator);
  715. smalltalk.addMethod(
  716. smalltalk.method({
  717. selector: "generate",
  718. protocol: 'protocol',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx1) {
  722. var $1,$2;
  723. globals.HLAccessorsGenerator.superclass.fn.prototype._generate.apply(_st(self), []);
  724. $1=_st(self["@output"])._targetClass();
  725. _st($1)._accessorsSourceCodesWith_(self);
  726. $2=_st($1)._accessorProtocolWith_(self);
  727. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLAccessorsGenerator)})},
  728. args: [],
  729. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09accessorsSourceCodesWith: self;\x0a\x09\x09accessorProtocolWith: self",
  730. messageSends: ["generate", "accessorsSourceCodesWith:", "targetClass", "accessorProtocolWith:"],
  731. referencedClasses: []
  732. }),
  733. globals.HLAccessorsGenerator);
  734. smalltalk.addMethod(
  735. smalltalk.method({
  736. selector: "getterFor:",
  737. protocol: 'private',
  738. fn: function (anInstanceVariable){
  739. var self=this;
  740. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  741. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  742. return smalltalk.withContext(function($ctx1) {
  743. var $2,$3,$1;
  744. $2=_st($HLMethodSourceCode())._new();
  745. _st($2)._selector_(anInstanceVariable);
  746. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  747. return smalltalk.withContext(function($ctx2) {
  748. _st(stream).__lt_lt(anInstanceVariable);
  749. $ctx2.sendIdx["<<"]=1;
  750. _st(_st(stream)._cr())._tab();
  751. return _st(_st(stream).__lt_lt("^ ")).__lt_lt(anInstanceVariable);
  752. $ctx2.sendIdx["<<"]=2;
  753. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  754. $1=$3;
  755. return $1;
  756. }, function($ctx1) {$ctx1.fill(self,"getterFor:",{anInstanceVariable:anInstanceVariable},globals.HLAccessorsGenerator)})},
  757. args: ["anInstanceVariable"],
  758. 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 ])",
  759. messageSends: ["selector:", "new", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  760. referencedClasses: ["HLMethodSourceCode", "String"]
  761. }),
  762. globals.HLAccessorsGenerator);
  763. smalltalk.addMethod(
  764. smalltalk.method({
  765. selector: "setterFor:",
  766. protocol: 'private',
  767. fn: function (anInstanceVariable){
  768. var self=this;
  769. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  770. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  771. return smalltalk.withContext(function($ctx1) {
  772. var $2,$4,$3,$1;
  773. $2=_st($HLMethodSourceCode())._new();
  774. _st($2)._selector_(_st(anInstanceVariable).__comma(":"));
  775. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  776. return smalltalk.withContext(function($ctx2) {
  777. $4=_st(stream).__lt_lt(anInstanceVariable);
  778. $ctx2.sendIdx["<<"]=2;
  779. _st($4).__lt_lt(": anObject");
  780. $ctx2.sendIdx["<<"]=1;
  781. _st(_st(stream)._cr())._tab();
  782. return _st(_st(stream).__lt_lt(anInstanceVariable)).__lt_lt(" := anObject");
  783. $ctx2.sendIdx["<<"]=3;
  784. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  785. $1=$3;
  786. return $1;
  787. }, function($ctx1) {$ctx1.fill(self,"setterFor:",{anInstanceVariable:anInstanceVariable},globals.HLAccessorsGenerator)})},
  788. args: ["anInstanceVariable"],
  789. 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' ])",
  790. messageSends: ["selector:", "new", ",", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  791. referencedClasses: ["HLMethodSourceCode", "String"]
  792. }),
  793. globals.HLAccessorsGenerator);
  794. smalltalk.addClass('HLInitializeGenerator', globals.HLMethodGenerator, [], 'Helios-Helpers');
  795. globals.HLInitializeGenerator.comment="I am used to double-dispatch the `initialize` method(s) generation.\x0a\x0aUsage:\x0a\x0a ^ HLInitializeGenerator new\x0a class: aClass;\x0a generate;\x0a output\x0a\x0aI am a disposable object";
  796. smalltalk.addMethod(
  797. smalltalk.method({
  798. selector: "generate",
  799. protocol: 'protocol',
  800. fn: function (){
  801. var self=this;
  802. return smalltalk.withContext(function($ctx1) {
  803. var $1,$2;
  804. globals.HLInitializeGenerator.superclass.fn.prototype._generate.apply(_st(self), []);
  805. $1=_st(self["@output"])._targetClass();
  806. _st($1)._initializeSourceCodesWith_(self);
  807. $2=_st($1)._initializeProtocolWith_(self);
  808. return self}, function($ctx1) {$ctx1.fill(self,"generate",{},globals.HLInitializeGenerator)})},
  809. args: [],
  810. source: "generate\x0a\x09super generate.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09initializeSourceCodesWith: self;\x0a\x09\x09initializeProtocolWith: self",
  811. messageSends: ["generate", "initializeSourceCodesWith:", "targetClass", "initializeProtocolWith:"],
  812. referencedClasses: []
  813. }),
  814. globals.HLInitializeGenerator);
  815. smalltalk.addMethod(
  816. smalltalk.method({
  817. selector: "generateInitializeCodeForObject",
  818. protocol: 'private',
  819. fn: function (){
  820. var self=this;
  821. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  822. return smalltalk.withContext(function($ctx1) {
  823. var $3,$2,$4,$5,$6,$7,$8,$1;
  824. $1=_st($String())._streamContents_((function(str){
  825. var instVars,size;
  826. return smalltalk.withContext(function($ctx2) {
  827. instVars=_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted();
  828. instVars;
  829. size=_st(instVars)._size();
  830. size;
  831. _st(str).__lt_lt("initialize");
  832. $ctx2.sendIdx["<<"]=1;
  833. $3=_st(str)._cr();
  834. $ctx2.sendIdx["cr"]=1;
  835. $2=_st($3)._tab();
  836. $ctx2.sendIdx["tab"]=1;
  837. _st($2).__lt_lt("super initialize.");
  838. $ctx2.sendIdx["<<"]=2;
  839. $4=_st($2)._cr();
  840. $ctx2.sendIdx["cr"]=2;
  841. $4;
  842. $5=_st(str)._cr();
  843. $ctx2.sendIdx["cr"]=3;
  844. _st($5)._tab();
  845. $ctx2.sendIdx["tab"]=2;
  846. return _st(instVars)._withIndexDo_((function(name,index){
  847. return smalltalk.withContext(function($ctx3) {
  848. $6=_st(index).__tild_eq((1));
  849. $ctx3.sendIdx["~="]=1;
  850. if(smalltalk.assert($6)){
  851. _st(_st(str)._cr())._tab();
  852. };
  853. $7=_st(str).__lt_lt(name);
  854. $ctx3.sendIdx["<<"]=4;
  855. _st($7).__lt_lt(" := nil");
  856. $ctx3.sendIdx["<<"]=3;
  857. $8=_st(index).__tild_eq(size);
  858. if(smalltalk.assert($8)){
  859. return _st(str).__lt_lt(".");
  860. };
  861. }, function($ctx3) {$ctx3.fillBlock({name:name,index:index},$ctx2,2)})}));
  862. }, function($ctx2) {$ctx2.fillBlock({str:str,instVars:instVars,size:size},$ctx1,1)})}));
  863. return $1;
  864. }, function($ctx1) {$ctx1.fill(self,"generateInitializeCodeForObject",{},globals.HLInitializeGenerator)})},
  865. args: [],
  866. 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 << '.' ] ] ].",
  867. messageSends: ["streamContents:", "sorted", "instanceVariableNames", "targetClass", "size", "<<", "tab", "cr", "withIndexDo:", "ifTrue:", "~="],
  868. referencedClasses: ["String"]
  869. }),
  870. globals.HLInitializeGenerator);
  871. smalltalk.addMethod(
  872. smalltalk.method({
  873. selector: "initializeForObject",
  874. protocol: 'double-dispatch',
  875. fn: function (){
  876. var self=this;
  877. return smalltalk.withContext(function($ctx1) {
  878. _st(self["@output"])._addSourceCode_(self._initializeMethodForObject());
  879. return self}, function($ctx1) {$ctx1.fill(self,"initializeForObject",{},globals.HLInitializeGenerator)})},
  880. args: [],
  881. source: "initializeForObject\x0a\x09output addSourceCode: self initializeMethodForObject",
  882. messageSends: ["addSourceCode:", "initializeMethodForObject"],
  883. referencedClasses: []
  884. }),
  885. globals.HLInitializeGenerator);
  886. smalltalk.addMethod(
  887. smalltalk.method({
  888. selector: "initializeMethodForObject",
  889. protocol: 'private',
  890. fn: function (){
  891. var self=this;
  892. function $HLMethodSourceCode(){return globals.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  893. return smalltalk.withContext(function($ctx1) {
  894. var $2,$3,$1;
  895. $2=_st($HLMethodSourceCode())._new();
  896. _st($2)._selector_("initialize");
  897. _st($2)._sourceCode_(self._generateInitializeCodeForObject());
  898. $3=_st($2)._yourself();
  899. $1=$3;
  900. return $1;
  901. }, function($ctx1) {$ctx1.fill(self,"initializeMethodForObject",{},globals.HLInitializeGenerator)})},
  902. args: [],
  903. source: "initializeMethodForObject\x09\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector: 'initialize';\x0a\x09\x09sourceCode: self generateInitializeCodeForObject;\x0a\x09\x09yourself",
  904. messageSends: ["selector:", "new", "sourceCode:", "generateInitializeCodeForObject", "yourself"],
  905. referencedClasses: ["HLMethodSourceCode"]
  906. }),
  907. globals.HLInitializeGenerator);
  908. smalltalk.addMethod(
  909. smalltalk.method({
  910. selector: "initializeProtocolForObject",
  911. protocol: 'double-dispatch',
  912. fn: function (){
  913. var self=this;
  914. return smalltalk.withContext(function($ctx1) {
  915. _st(self["@output"])._protocol_("initialization");
  916. return self}, function($ctx1) {$ctx1.fill(self,"initializeProtocolForObject",{},globals.HLInitializeGenerator)})},
  917. args: [],
  918. source: "initializeProtocolForObject\x0a\x09output protocol: 'initialization'",
  919. messageSends: ["protocol:"],
  920. referencedClasses: []
  921. }),
  922. globals.HLInitializeGenerator);
  923. smalltalk.addClass('HLMethodSourceCode', globals.Object, ['selector', 'sourceCode'], 'Helios-Helpers');
  924. 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";
  925. smalltalk.addMethod(
  926. smalltalk.method({
  927. selector: "selector",
  928. protocol: 'accessing',
  929. fn: function (){
  930. var self=this;
  931. var $1;
  932. $1=self["@selector"];
  933. return $1;
  934. },
  935. args: [],
  936. source: "selector\x0a\x09^ selector",
  937. messageSends: [],
  938. referencedClasses: []
  939. }),
  940. globals.HLMethodSourceCode);
  941. smalltalk.addMethod(
  942. smalltalk.method({
  943. selector: "selector:",
  944. protocol: 'accessing',
  945. fn: function (aSelector){
  946. var self=this;
  947. self["@selector"]=aSelector;
  948. return self},
  949. args: ["aSelector"],
  950. source: "selector: aSelector\x0a\x09selector := aSelector",
  951. messageSends: [],
  952. referencedClasses: []
  953. }),
  954. globals.HLMethodSourceCode);
  955. smalltalk.addMethod(
  956. smalltalk.method({
  957. selector: "sourceCode",
  958. protocol: 'accessing',
  959. fn: function (){
  960. var self=this;
  961. var $1;
  962. $1=self["@sourceCode"];
  963. return $1;
  964. },
  965. args: [],
  966. source: "sourceCode\x0a\x09^ sourceCode",
  967. messageSends: [],
  968. referencedClasses: []
  969. }),
  970. globals.HLMethodSourceCode);
  971. smalltalk.addMethod(
  972. smalltalk.method({
  973. selector: "sourceCode:",
  974. protocol: 'accessing',
  975. fn: function (aString){
  976. var self=this;
  977. self["@sourceCode"]=aString;
  978. return self},
  979. args: ["aString"],
  980. source: "sourceCode: aString\x0a\x09sourceCode := aString",
  981. messageSends: [],
  982. referencedClasses: []
  983. }),
  984. globals.HLMethodSourceCode);
  985. });