Helios-Helpers.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. define("amber_core/Helios-Helpers", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Helios-Helpers');
  3. smalltalk.packages["Helios-Helpers"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('HLClassifierLink', smalltalk.Object, ['next'], 'Helios-Helpers');
  5. smalltalk.addClass('HLGenerationOutput', smalltalk.Object, ['sourceCodes', 'protocol', 'targetClass'], 'Helios-Helpers');
  6. smalltalk.HLGenerationOutput.comment="I am a simple data object used to store the result of a generation process";
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "addSourceCode:",
  10. protocol: 'protocol',
  11. fn: function (aString){
  12. var self=this;
  13. return smalltalk.withContext(function($ctx1) {
  14. _st(self["@sourceCodes"])._add_(aString);
  15. return self}, function($ctx1) {$ctx1.fill(self,"addSourceCode:",{aString:aString},smalltalk.HLGenerationOutput)})},
  16. args: ["aString"],
  17. source: "addSourceCode: aString\x0a\x09sourceCodes add: aString",
  18. messageSends: ["add:"],
  19. referencedClasses: []
  20. }),
  21. smalltalk.HLGenerationOutput);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "initialize",
  25. protocol: 'initialization',
  26. fn: function (){
  27. var self=this;
  28. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  29. return smalltalk.withContext(function($ctx1) {
  30. smalltalk.HLGenerationOutput.superclass.fn.prototype._initialize.apply(_st(self), []);
  31. self["@sourceCodes"]=_st($OrderedCollection())._new();
  32. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLGenerationOutput)})},
  33. args: [],
  34. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09sourceCodes := OrderedCollection new",
  35. messageSends: ["initialize", "new"],
  36. referencedClasses: ["OrderedCollection"]
  37. }),
  38. smalltalk.HLGenerationOutput);
  39. smalltalk.addMethod(
  40. smalltalk.method({
  41. selector: "protocol",
  42. protocol: 'accessing',
  43. fn: function (){
  44. var self=this;
  45. return smalltalk.withContext(function($ctx1) {
  46. var $1;
  47. $1=self["@protocol"];
  48. return $1;
  49. }, function($ctx1) {$ctx1.fill(self,"protocol",{},smalltalk.HLGenerationOutput)})},
  50. args: [],
  51. source: "protocol\x0a\x09^ protocol",
  52. messageSends: [],
  53. referencedClasses: []
  54. }),
  55. smalltalk.HLGenerationOutput);
  56. smalltalk.addMethod(
  57. smalltalk.method({
  58. selector: "protocol:",
  59. protocol: 'accessing',
  60. fn: function (aString){
  61. var self=this;
  62. return smalltalk.withContext(function($ctx1) {
  63. self["@protocol"]=aString;
  64. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString},smalltalk.HLGenerationOutput)})},
  65. args: ["aString"],
  66. source: "protocol: aString\x0a\x09protocol := aString",
  67. messageSends: [],
  68. referencedClasses: []
  69. }),
  70. smalltalk.HLGenerationOutput);
  71. smalltalk.addMethod(
  72. smalltalk.method({
  73. selector: "serialize",
  74. protocol: 'protocol',
  75. fn: function (){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) {
  78. var $1;
  79. _st(self["@sourceCodes"])._do_((function(methodSourceCode){
  80. return smalltalk.withContext(function($ctx2) {
  81. $1=_st(self["@targetClass"])._includesSelector_(_st(methodSourceCode)._selector());
  82. if(! smalltalk.assert($1)){
  83. return _st(self["@targetClass"])._compile_protocol_(_st(methodSourceCode)._sourceCode(),self["@protocol"]);
  84. };
  85. }, function($ctx2) {$ctx2.fillBlock({methodSourceCode:methodSourceCode},$ctx1,1)})}));
  86. return self}, function($ctx1) {$ctx1.fill(self,"serialize",{},smalltalk.HLGenerationOutput)})},
  87. args: [],
  88. source: "serialize\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 ] ]",
  89. messageSends: ["do:", "ifFalse:", "includesSelector:", "selector", "compile:protocol:", "sourceCode"],
  90. referencedClasses: []
  91. }),
  92. smalltalk.HLGenerationOutput);
  93. smalltalk.addMethod(
  94. smalltalk.method({
  95. selector: "sourceCodes",
  96. protocol: 'accessing',
  97. fn: function (){
  98. var self=this;
  99. return smalltalk.withContext(function($ctx1) {
  100. var $1;
  101. $1=self["@sourceCodes"];
  102. return $1;
  103. }, function($ctx1) {$ctx1.fill(self,"sourceCodes",{},smalltalk.HLGenerationOutput)})},
  104. args: [],
  105. source: "sourceCodes\x0a\x09^ sourceCodes",
  106. messageSends: [],
  107. referencedClasses: []
  108. }),
  109. smalltalk.HLGenerationOutput);
  110. smalltalk.addMethod(
  111. smalltalk.method({
  112. selector: "sourceCodes:",
  113. protocol: 'accessing',
  114. fn: function (aCollection){
  115. var self=this;
  116. return smalltalk.withContext(function($ctx1) {
  117. self["@sourceCodes"]=aCollection;
  118. return self}, function($ctx1) {$ctx1.fill(self,"sourceCodes:",{aCollection:aCollection},smalltalk.HLGenerationOutput)})},
  119. args: ["aCollection"],
  120. source: "sourceCodes: aCollection\x0a\x09sourceCodes := aCollection",
  121. messageSends: [],
  122. referencedClasses: []
  123. }),
  124. smalltalk.HLGenerationOutput);
  125. smalltalk.addMethod(
  126. smalltalk.method({
  127. selector: "targetClass",
  128. protocol: 'accessing',
  129. fn: function (){
  130. var self=this;
  131. return smalltalk.withContext(function($ctx1) {
  132. var $1;
  133. $1=self["@targetClass"];
  134. return $1;
  135. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.HLGenerationOutput)})},
  136. args: [],
  137. source: "targetClass\x0a\x09^ targetClass",
  138. messageSends: [],
  139. referencedClasses: []
  140. }),
  141. smalltalk.HLGenerationOutput);
  142. smalltalk.addMethod(
  143. smalltalk.method({
  144. selector: "targetClass:",
  145. protocol: 'accessing',
  146. fn: function (aClass){
  147. var self=this;
  148. return smalltalk.withContext(function($ctx1) {
  149. self["@targetClass"]=aClass;
  150. return self}, function($ctx1) {$ctx1.fill(self,"targetClass:",{aClass:aClass},smalltalk.HLGenerationOutput)})},
  151. args: ["aClass"],
  152. source: "targetClass: aClass\x0a\x09targetClass := aClass",
  153. messageSends: [],
  154. referencedClasses: []
  155. }),
  156. smalltalk.HLGenerationOutput);
  157. smalltalk.addClass('HLGenerationOutputWithIndex', smalltalk.HLGenerationOutput, ['index'], 'Helios-Helpers');
  158. smalltalk.HLGenerationOutputWithIndex.comment="I am a simple data object used to store the result of a generation process.\x0a\x0aIn addition of my super class, I have an index where to put the cursor at the end of the process for the first method created (aka. the first in `sourceCodes`)";
  159. smalltalk.addMethod(
  160. smalltalk.method({
  161. selector: "index",
  162. protocol: 'accessing',
  163. fn: function (){
  164. var self=this;
  165. return smalltalk.withContext(function($ctx1) {
  166. var $1;
  167. $1=self["@index"];
  168. return $1;
  169. }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.HLGenerationOutputWithIndex)})},
  170. args: [],
  171. source: "index\x0a\x09^ index",
  172. messageSends: [],
  173. referencedClasses: []
  174. }),
  175. smalltalk.HLGenerationOutputWithIndex);
  176. smalltalk.addMethod(
  177. smalltalk.method({
  178. selector: "index:",
  179. protocol: 'accessing',
  180. fn: function (anIndex){
  181. var self=this;
  182. return smalltalk.withContext(function($ctx1) {
  183. self["@index"]=anIndex;
  184. return self}, function($ctx1) {$ctx1.fill(self,"index:",{anIndex:anIndex},smalltalk.HLGenerationOutputWithIndex)})},
  185. args: ["anIndex"],
  186. source: "index: anIndex\x0a\x09index := anIndex",
  187. messageSends: [],
  188. referencedClasses: []
  189. }),
  190. smalltalk.HLGenerationOutputWithIndex);
  191. smalltalk.addClass('HLGenerator', smalltalk.Object, ['output'], 'Helios-Helpers');
  192. smalltalk.HLGenerator.comment="I am the abstract super class of the generators.\x0a\x0aMy main method is `generate` which produce an `output` object";
  193. smalltalk.addMethod(
  194. smalltalk.method({
  195. selector: "class:",
  196. protocol: 'accessing',
  197. fn: function (aClass){
  198. var self=this;
  199. return smalltalk.withContext(function($ctx1) {
  200. _st(self["@output"])._targetClass_(aClass);
  201. return self}, function($ctx1) {$ctx1.fill(self,"class:",{aClass:aClass},smalltalk.HLGenerator)})},
  202. args: ["aClass"],
  203. source: "class: aClass\x0a\x09output targetClass: aClass",
  204. messageSends: ["targetClass:"],
  205. referencedClasses: []
  206. }),
  207. smalltalk.HLGenerator);
  208. smalltalk.addMethod(
  209. smalltalk.method({
  210. selector: "compile",
  211. protocol: 'protocol',
  212. fn: function (){
  213. var self=this;
  214. return smalltalk.withContext(function($ctx1) {
  215. var $1;
  216. $1=_st(self["@output"])._targetClass();
  217. if(($receiver = $1) == nil || $receiver == null){
  218. self._error_("class should not be nil");
  219. } else {
  220. $1;
  221. };
  222. return self}, function($ctx1) {$ctx1.fill(self,"compile",{},smalltalk.HLGenerator)})},
  223. args: [],
  224. source: "compile\x0a\x0a\x09output targetClass ifNil: [ self error: 'class should not be nil'].",
  225. messageSends: ["ifNil:", "targetClass", "error:"],
  226. referencedClasses: []
  227. }),
  228. smalltalk.HLGenerator);
  229. smalltalk.addMethod(
  230. smalltalk.method({
  231. selector: "initialize",
  232. protocol: 'initialization',
  233. fn: function (){
  234. var self=this;
  235. function $HLGenerationOutput(){return smalltalk.HLGenerationOutput||(typeof HLGenerationOutput=="undefined"?nil:HLGenerationOutput)}
  236. return smalltalk.withContext(function($ctx1) {
  237. smalltalk.HLGenerator.superclass.fn.prototype._initialize.apply(_st(self), []);
  238. self["@output"]=_st($HLGenerationOutput())._new();
  239. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLGenerator)})},
  240. args: [],
  241. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09output := HLGenerationOutput new",
  242. messageSends: ["initialize", "new"],
  243. referencedClasses: ["HLGenerationOutput"]
  244. }),
  245. smalltalk.HLGenerator);
  246. smalltalk.addMethod(
  247. smalltalk.method({
  248. selector: "output",
  249. protocol: 'accessing',
  250. fn: function (){
  251. var self=this;
  252. return smalltalk.withContext(function($ctx1) {
  253. var $1;
  254. $1=self["@output"];
  255. return $1;
  256. }, function($ctx1) {$ctx1.fill(self,"output",{},smalltalk.HLGenerator)})},
  257. args: [],
  258. source: "output\x0a\x09^ output",
  259. messageSends: [],
  260. referencedClasses: []
  261. }),
  262. smalltalk.HLGenerator);
  263. smalltalk.addClass('HLAccessorsGenerator', smalltalk.HLGenerator, [], 'Helios-Helpers');
  264. smalltalk.HLAccessorsGenerator.comment="I am a generator used to compile the getters/setters of a class";
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "accessorProtocolForObject",
  268. protocol: 'double-dispatch',
  269. fn: function (){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) {
  272. _st(self["@output"])._protocol_("accessing");
  273. return self}, function($ctx1) {$ctx1.fill(self,"accessorProtocolForObject",{},smalltalk.HLAccessorsGenerator)})},
  274. args: [],
  275. source: "accessorProtocolForObject\x0a\x09output protocol: 'accessing'",
  276. messageSends: ["protocol:"],
  277. referencedClasses: []
  278. }),
  279. smalltalk.HLAccessorsGenerator);
  280. smalltalk.addMethod(
  281. smalltalk.method({
  282. selector: "accessorsSourceCodesForObject",
  283. protocol: 'double-dispatch',
  284. fn: function (){
  285. var self=this;
  286. var sources;
  287. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  288. return smalltalk.withContext(function($ctx1) {
  289. var $1,$2;
  290. sources=_st($OrderedCollection())._new();
  291. _st(_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted())._do_((function(each){
  292. return smalltalk.withContext(function($ctx2) {
  293. $1=sources;
  294. _st($1)._add_(self._getterFor_(each));
  295. $ctx2.sendIdx["add:"]=1;
  296. $2=_st($1)._add_(self._setterFor_(each));
  297. return $2;
  298. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  299. _st(self["@output"])._sourceCodes_(sources);
  300. return self}, function($ctx1) {$ctx1.fill(self,"accessorsSourceCodesForObject",{sources:sources},smalltalk.HLAccessorsGenerator)})},
  301. args: [],
  302. source: "accessorsSourceCodesForObject\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",
  303. messageSends: ["new", "do:", "sorted", "instanceVariableNames", "targetClass", "add:", "getterFor:", "setterFor:", "sourceCodes:"],
  304. referencedClasses: ["OrderedCollection"]
  305. }),
  306. smalltalk.HLAccessorsGenerator);
  307. smalltalk.addMethod(
  308. smalltalk.method({
  309. selector: "compile",
  310. protocol: 'protocol',
  311. fn: function (){
  312. var self=this;
  313. return smalltalk.withContext(function($ctx1) {
  314. var $1,$2;
  315. smalltalk.HLAccessorsGenerator.superclass.fn.prototype._compile.apply(_st(self), []);
  316. $1=_st(self["@output"])._targetClass();
  317. _st($1)._accessorsSourceCodesWith_(self);
  318. $2=_st($1)._accessorProtocolWith_(self);
  319. return self}, function($ctx1) {$ctx1.fill(self,"compile",{},smalltalk.HLAccessorsGenerator)})},
  320. args: [],
  321. source: "compile\x0a\x09super compile.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09accessorsSourceCodesWith: self;\x0a\x09\x09accessorProtocolWith: self",
  322. messageSends: ["compile", "accessorsSourceCodesWith:", "targetClass", "accessorProtocolWith:"],
  323. referencedClasses: []
  324. }),
  325. smalltalk.HLAccessorsGenerator);
  326. smalltalk.addMethod(
  327. smalltalk.method({
  328. selector: "getterFor:",
  329. protocol: 'private',
  330. fn: function (anInstanceVariable){
  331. var self=this;
  332. function $HLMethodSourceCode(){return smalltalk.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  333. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  334. return smalltalk.withContext(function($ctx1) {
  335. var $2,$3,$1;
  336. $2=_st($HLMethodSourceCode())._new();
  337. _st($2)._selector_(anInstanceVariable);
  338. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  339. return smalltalk.withContext(function($ctx2) {
  340. _st(stream).__lt_lt(anInstanceVariable);
  341. $ctx2.sendIdx["<<"]=1;
  342. _st(_st(stream)._cr())._tab();
  343. return _st(_st(stream).__lt_lt("^ ")).__lt_lt(anInstanceVariable);
  344. $ctx2.sendIdx["<<"]=2;
  345. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  346. $1=$3;
  347. return $1;
  348. }, function($ctx1) {$ctx1.fill(self,"getterFor:",{anInstanceVariable:anInstanceVariable},smalltalk.HLAccessorsGenerator)})},
  349. args: ["anInstanceVariable"],
  350. 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 ])",
  351. messageSends: ["selector:", "new", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  352. referencedClasses: ["HLMethodSourceCode", "String"]
  353. }),
  354. smalltalk.HLAccessorsGenerator);
  355. smalltalk.addMethod(
  356. smalltalk.method({
  357. selector: "setterFor:",
  358. protocol: 'private',
  359. fn: function (anInstanceVariable){
  360. var self=this;
  361. function $HLMethodSourceCode(){return smalltalk.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  362. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  363. return smalltalk.withContext(function($ctx1) {
  364. var $2,$4,$3,$1;
  365. $2=_st($HLMethodSourceCode())._new();
  366. _st($2)._selector_(_st(anInstanceVariable).__comma(":"));
  367. $3=_st($2)._sourceCode_(_st($String())._streamContents_((function(stream){
  368. return smalltalk.withContext(function($ctx2) {
  369. $4=_st(stream).__lt_lt(anInstanceVariable);
  370. $ctx2.sendIdx["<<"]=2;
  371. _st($4).__lt_lt(": anObject");
  372. $ctx2.sendIdx["<<"]=1;
  373. _st(_st(stream)._cr())._tab();
  374. return _st(_st(stream).__lt_lt(anInstanceVariable)).__lt_lt(" := anObject");
  375. $ctx2.sendIdx["<<"]=3;
  376. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})})));
  377. $1=$3;
  378. return $1;
  379. }, function($ctx1) {$ctx1.fill(self,"setterFor:",{anInstanceVariable:anInstanceVariable},smalltalk.HLAccessorsGenerator)})},
  380. args: ["anInstanceVariable"],
  381. 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' ])",
  382. messageSends: ["selector:", "new", ",", "sourceCode:", "streamContents:", "<<", "tab", "cr"],
  383. referencedClasses: ["HLMethodSourceCode", "String"]
  384. }),
  385. smalltalk.HLAccessorsGenerator);
  386. smalltalk.addClass('HLInitializeGenerator', smalltalk.HLGenerator, [], 'Helios-Helpers');
  387. smalltalk.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";
  388. smalltalk.addMethod(
  389. smalltalk.method({
  390. selector: "compile",
  391. protocol: 'protocol',
  392. fn: function (){
  393. var self=this;
  394. return smalltalk.withContext(function($ctx1) {
  395. var $1,$2;
  396. smalltalk.HLInitializeGenerator.superclass.fn.prototype._compile.apply(_st(self), []);
  397. $1=_st(self["@output"])._targetClass();
  398. _st($1)._initializeSourceCodesWith_(self);
  399. _st($1)._initializeIndexWith_(self);
  400. $2=_st($1)._initializeProtocolWith_(self);
  401. return self}, function($ctx1) {$ctx1.fill(self,"compile",{},smalltalk.HLInitializeGenerator)})},
  402. args: [],
  403. source: "compile\x0a\x09super compile.\x0a\x09\x0a\x09output targetClass \x0a\x09\x09initializeSourceCodesWith: self;\x0a\x09\x09initializeIndexWith: self;\x0a\x09\x09initializeProtocolWith: self",
  404. messageSends: ["compile", "initializeSourceCodesWith:", "targetClass", "initializeIndexWith:", "initializeProtocolWith:"],
  405. referencedClasses: []
  406. }),
  407. smalltalk.HLInitializeGenerator);
  408. smalltalk.addMethod(
  409. smalltalk.method({
  410. selector: "computeIndexForObject",
  411. protocol: 'private',
  412. fn: function (){
  413. var self=this;
  414. var instVars,headerSize,firstInstVarSize;
  415. return smalltalk.withContext(function($ctx1) {
  416. var $1;
  417. headerSize=(32);
  418. instVars=_st(_st(self["@output"])._targetClass())._instanceVariableNames();
  419. firstInstVarSize=_st(_st(instVars)._sorted())._ifEmpty_ifNotEmpty_((function(){
  420. return smalltalk.withContext(function($ctx2) {
  421. return (0);
  422. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  423. return smalltalk.withContext(function($ctx2) {
  424. return _st(_st(_st(instVars)._first())._size()).__plus((4));
  425. $ctx2.sendIdx["+"]=1;
  426. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  427. $1=_st(headerSize).__plus(firstInstVarSize);
  428. return $1;
  429. }, function($ctx1) {$ctx1.fill(self,"computeIndexForObject",{instVars:instVars,headerSize:headerSize,firstInstVarSize:firstInstVarSize},smalltalk.HLInitializeGenerator)})},
  430. args: [],
  431. source: "computeIndexForObject\x0a\x09| instVars headerSize firstInstVarSize |\x0a\x09\x0a\x09\x2232 is the size of the `initiliaze super initialize` part\x22\x0a\x09headerSize := 32.\x0a\x09instVars := output targetClass instanceVariableNames.\x0a\x09firstInstVarSize := instVars sorted\x0a\x09\x09ifEmpty: [ 0 ]\x0a\x09\x09ifNotEmpty:[ instVars first size + 4 ].\x0a\x09^ headerSize + firstInstVarSize",
  432. messageSends: ["instanceVariableNames", "targetClass", "ifEmpty:ifNotEmpty:", "sorted", "+", "size", "first"],
  433. referencedClasses: []
  434. }),
  435. smalltalk.HLInitializeGenerator);
  436. smalltalk.addMethod(
  437. smalltalk.method({
  438. selector: "generateInitializeCodeForObject",
  439. protocol: 'private',
  440. fn: function (){
  441. var self=this;
  442. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  443. return smalltalk.withContext(function($ctx1) {
  444. var $3,$2,$4,$5,$6,$7,$8,$1;
  445. $1=_st($String())._streamContents_((function(str){
  446. var instVars,size;
  447. return smalltalk.withContext(function($ctx2) {
  448. instVars=_st(_st(_st(self["@output"])._targetClass())._instanceVariableNames())._sorted();
  449. instVars;
  450. size=_st(instVars)._size();
  451. size;
  452. _st(str).__lt_lt("initialize");
  453. $ctx2.sendIdx["<<"]=1;
  454. $3=_st(str)._cr();
  455. $ctx2.sendIdx["cr"]=1;
  456. $2=_st($3)._tab();
  457. $ctx2.sendIdx["tab"]=1;
  458. _st($2).__lt_lt("super initialize.");
  459. $ctx2.sendIdx["<<"]=2;
  460. $4=_st($2)._cr();
  461. $ctx2.sendIdx["cr"]=2;
  462. $4;
  463. $5=_st(str)._cr();
  464. $ctx2.sendIdx["cr"]=3;
  465. _st($5)._tab();
  466. $ctx2.sendIdx["tab"]=2;
  467. return _st(instVars)._withIndexDo_((function(name,index){
  468. return smalltalk.withContext(function($ctx3) {
  469. $6=_st(index).__tild_eq((1));
  470. $ctx3.sendIdx["~="]=1;
  471. if(smalltalk.assert($6)){
  472. _st(_st(str)._cr())._tab();
  473. };
  474. $7=_st(str).__lt_lt(name);
  475. $ctx3.sendIdx["<<"]=4;
  476. _st($7).__lt_lt(" := nil");
  477. $ctx3.sendIdx["<<"]=3;
  478. $8=_st(index).__tild_eq(size);
  479. if(smalltalk.assert($8)){
  480. return _st(str).__lt_lt(".");
  481. };
  482. }, function($ctx3) {$ctx3.fillBlock({name:name,index:index},$ctx2,2)})}));
  483. }, function($ctx2) {$ctx2.fillBlock({str:str,instVars:instVars,size:size},$ctx1,1)})}));
  484. return $1;
  485. }, function($ctx1) {$ctx1.fill(self,"generateInitializeCodeForObject",{},smalltalk.HLInitializeGenerator)})},
  486. args: [],
  487. 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 << '.' ] ] ].",
  488. messageSends: ["streamContents:", "sorted", "instanceVariableNames", "targetClass", "size", "<<", "tab", "cr", "withIndexDo:", "ifTrue:", "~="],
  489. referencedClasses: ["String"]
  490. }),
  491. smalltalk.HLInitializeGenerator);
  492. smalltalk.addMethod(
  493. smalltalk.method({
  494. selector: "initialize",
  495. protocol: 'initialization',
  496. fn: function (){
  497. var self=this;
  498. function $HLGenerationOutputWithIndex(){return smalltalk.HLGenerationOutputWithIndex||(typeof HLGenerationOutputWithIndex=="undefined"?nil:HLGenerationOutputWithIndex)}
  499. return smalltalk.withContext(function($ctx1) {
  500. smalltalk.HLInitializeGenerator.superclass.fn.prototype._initialize.apply(_st(self), []);
  501. self["@output"]=_st($HLGenerationOutputWithIndex())._new();
  502. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLInitializeGenerator)})},
  503. args: [],
  504. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09output := HLGenerationOutputWithIndex new",
  505. messageSends: ["initialize", "new"],
  506. referencedClasses: ["HLGenerationOutputWithIndex"]
  507. }),
  508. smalltalk.HLInitializeGenerator);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "initializeCodeForObject",
  512. protocol: 'private',
  513. fn: function (){
  514. var self=this;
  515. function $HLMethodSourceCode(){return smalltalk.HLMethodSourceCode||(typeof HLMethodSourceCode=="undefined"?nil:HLMethodSourceCode)}
  516. return smalltalk.withContext(function($ctx1) {
  517. var $2,$3,$1;
  518. $2=_st($HLMethodSourceCode())._new();
  519. _st($2)._selector_("initialize");
  520. _st($2)._sourceCode_(self._generateInitializeCodeForObject());
  521. $3=_st($2)._yourself();
  522. $1=$3;
  523. return $1;
  524. }, function($ctx1) {$ctx1.fill(self,"initializeCodeForObject",{},smalltalk.HLInitializeGenerator)})},
  525. args: [],
  526. source: "initializeCodeForObject\x09\x0a\x09^ HLMethodSourceCode new\x0a\x09\x09selector: 'initialize';\x0a\x09\x09sourceCode: self generateInitializeCodeForObject;\x0a\x09\x09yourself",
  527. messageSends: ["selector:", "new", "sourceCode:", "generateInitializeCodeForObject", "yourself"],
  528. referencedClasses: ["HLMethodSourceCode"]
  529. }),
  530. smalltalk.HLInitializeGenerator);
  531. smalltalk.addMethod(
  532. smalltalk.method({
  533. selector: "initializeForObject",
  534. protocol: 'double-dispatch',
  535. fn: function (){
  536. var self=this;
  537. return smalltalk.withContext(function($ctx1) {
  538. _st(self["@output"])._addSourceCode_(self._initializeCodeForObject());
  539. return self}, function($ctx1) {$ctx1.fill(self,"initializeForObject",{},smalltalk.HLInitializeGenerator)})},
  540. args: [],
  541. source: "initializeForObject\x0a\x09output addSourceCode: self initializeCodeForObject",
  542. messageSends: ["addSourceCode:", "initializeCodeForObject"],
  543. referencedClasses: []
  544. }),
  545. smalltalk.HLInitializeGenerator);
  546. smalltalk.addMethod(
  547. smalltalk.method({
  548. selector: "initializeIndexForObject",
  549. protocol: 'double-dispatch',
  550. fn: function (){
  551. var self=this;
  552. return smalltalk.withContext(function($ctx1) {
  553. _st(self["@output"])._index_(self._computeIndexForObject());
  554. return self}, function($ctx1) {$ctx1.fill(self,"initializeIndexForObject",{},smalltalk.HLInitializeGenerator)})},
  555. args: [],
  556. source: "initializeIndexForObject\x0a\x09output index: self computeIndexForObject",
  557. messageSends: ["index:", "computeIndexForObject"],
  558. referencedClasses: []
  559. }),
  560. smalltalk.HLInitializeGenerator);
  561. smalltalk.addMethod(
  562. smalltalk.method({
  563. selector: "initializeProtocolForObject",
  564. protocol: 'double-dispatch',
  565. fn: function (){
  566. var self=this;
  567. return smalltalk.withContext(function($ctx1) {
  568. _st(self["@output"])._protocol_(self._retrieveProtocolForObject());
  569. return self}, function($ctx1) {$ctx1.fill(self,"initializeProtocolForObject",{},smalltalk.HLInitializeGenerator)})},
  570. args: [],
  571. source: "initializeProtocolForObject\x0a\x09output protocol: self retrieveProtocolForObject",
  572. messageSends: ["protocol:", "retrieveProtocolForObject"],
  573. referencedClasses: []
  574. }),
  575. smalltalk.HLInitializeGenerator);
  576. smalltalk.addMethod(
  577. smalltalk.method({
  578. selector: "retrieveProtocolForObject",
  579. protocol: 'private',
  580. fn: function (){
  581. var self=this;
  582. return smalltalk.withContext(function($ctx1) {
  583. return "initialization";
  584. }, function($ctx1) {$ctx1.fill(self,"retrieveProtocolForObject",{},smalltalk.HLInitializeGenerator)})},
  585. args: [],
  586. source: "retrieveProtocolForObject\x0a\x09^ 'initialization'",
  587. messageSends: [],
  588. referencedClasses: []
  589. }),
  590. smalltalk.HLInitializeGenerator);
  591. smalltalk.addClass('HLMethodClassifier', smalltalk.Object, ['prefixMapping'], 'Helios-Helpers');
  592. smalltalk.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?";
  593. smalltalk.addMethod(
  594. smalltalk.method({
  595. selector: "buildPrefixDictionary",
  596. protocol: 'initialization',
  597. fn: function (){
  598. var self=this;
  599. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  600. return smalltalk.withContext(function($ctx1) {
  601. var $1,$2;
  602. self["@prefixMapping"]=_st($Dictionary())._new();
  603. $1=self["@prefixMapping"];
  604. _st($1)._at_put_("test","tests");
  605. $ctx1.sendIdx["at:put:"]=1;
  606. _st($1)._at_put_("bench","benchmarking");
  607. $ctx1.sendIdx["at:put:"]=2;
  608. _st($1)._at_put_("copy","copying");
  609. $ctx1.sendIdx["at:put:"]=3;
  610. _st($1)._at_put_("initialize","initialization");
  611. $ctx1.sendIdx["at:put:"]=4;
  612. _st($1)._at_put_("accept","visitor");
  613. $ctx1.sendIdx["at:put:"]=5;
  614. _st($1)._at_put_("visit","visitor");
  615. $ctx1.sendIdx["at:put:"]=6;
  616. _st($1)._at_put_("signal","signalling");
  617. $ctx1.sendIdx["at:put:"]=7;
  618. _st($1)._at_put_("parse","parsing");
  619. $ctx1.sendIdx["at:put:"]=8;
  620. _st($1)._at_put_("add","adding");
  621. $ctx1.sendIdx["at:put:"]=9;
  622. _st($1)._at_put_("is","testing");
  623. $ctx1.sendIdx["at:put:"]=10;
  624. _st($1)._at_put_("as","converting");
  625. $ctx1.sendIdx["at:put:"]=11;
  626. $2=_st($1)._at_put_("new","instance creation");
  627. return self}, function($ctx1) {$ctx1.fill(self,"buildPrefixDictionary",{},smalltalk.HLMethodClassifier)})},
  628. args: [],
  629. 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'.",
  630. messageSends: ["new", "at:put:"],
  631. referencedClasses: ["Dictionary"]
  632. }),
  633. smalltalk.HLMethodClassifier);
  634. smalltalk.addMethod(
  635. smalltalk.method({
  636. selector: "classify:",
  637. protocol: 'protocol',
  638. fn: function (aMethod){
  639. var self=this;
  640. return smalltalk.withContext(function($ctx1) {
  641. var $1,$2,$3,$4,$5,$6,$7,$8;
  642. $1=self._classifyAccessor_(aMethod);
  643. if(smalltalk.assert($1)){
  644. $2=_st(aMethod)._category();
  645. $ctx1.sendIdx["category"]=1;
  646. return $2;
  647. };
  648. $3=self._classifyInSuperclassProtocol_(aMethod);
  649. if(smalltalk.assert($3)){
  650. $4=_st(aMethod)._category();
  651. $ctx1.sendIdx["category"]=2;
  652. return $4;
  653. };
  654. $5=self._classifyByKnownPrefix_(aMethod);
  655. if(smalltalk.assert($5)){
  656. $6=_st(aMethod)._category();
  657. $ctx1.sendIdx["category"]=3;
  658. return $6;
  659. };
  660. $7=self._classifyByOtherImplementors_(aMethod);
  661. if(smalltalk.assert($7)){
  662. $8=_st(aMethod)._category();
  663. return $8;
  664. };
  665. return self}, function($ctx1) {$ctx1.fill(self,"classify:",{aMethod:aMethod},smalltalk.HLMethodClassifier)})},
  666. args: ["aMethod"],
  667. source: "classify: aMethod\x0a\x09(self classifyAccessor: aMethod)\x0a\x09\x09ifTrue: [ ^ aMethod category ].\x0a\x09(self classifyInSuperclassProtocol: aMethod)\x0a\x09\x09ifTrue: [ ^ aMethod category ].\x0a\x09(self classifyByKnownPrefix: aMethod)\x0a\x09\x09ifTrue: [ ^ aMethod category ].\x0a\x09(self classifyByOtherImplementors: aMethod)\x0a\x09\x09ifTrue: [ ^ aMethod category ].",
  668. messageSends: ["ifTrue:", "classifyAccessor:", "category", "classifyInSuperclassProtocol:", "classifyByKnownPrefix:", "classifyByOtherImplementors:"],
  669. referencedClasses: []
  670. }),
  671. smalltalk.HLMethodClassifier);
  672. smalltalk.addMethod(
  673. smalltalk.method({
  674. selector: "classifyAccessor:",
  675. protocol: 'private',
  676. fn: function (aMethod){
  677. var self=this;
  678. var names,selector;
  679. return smalltalk.withContext(function($ctx1) {
  680. var $1,$2;
  681. names=_st(_st(aMethod)._methodClass())._allInstanceVariableNames();
  682. selector=_st(aMethod)._selector();
  683. $1=_st(_st(selector)._last()).__eq(":");
  684. if(smalltalk.assert($1)){
  685. selector=_st(selector)._allButLast();
  686. selector;
  687. };
  688. $2=_st(names)._includes_(selector);
  689. if(! smalltalk.assert($2)){
  690. return false;
  691. };
  692. _st(aMethod)._protocol_("accessing");
  693. return true;
  694. }, function($ctx1) {$ctx1.fill(self,"classifyAccessor:",{aMethod:aMethod,names:names,selector:selector},smalltalk.HLMethodClassifier)})},
  695. args: ["aMethod"],
  696. source: "classifyAccessor: aMethod\x0a\x09| names selector |\x0a\x09\x0a\x09names := aMethod methodClass allInstanceVariableNames.\x0a\x09selector := aMethod 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\x09aMethod protocol: 'accessing'.\x0a\x09^ true.",
  697. messageSends: ["allInstanceVariableNames", "methodClass", "selector", "ifTrue:", "=", "last", "allButLast", "ifFalse:", "includes:", "protocol:"],
  698. referencedClasses: []
  699. }),
  700. smalltalk.HLMethodClassifier);
  701. smalltalk.addMethod(
  702. smalltalk.method({
  703. selector: "classifyAll:",
  704. protocol: 'protocol',
  705. fn: function (aCollectionOfMethods){
  706. var self=this;
  707. return smalltalk.withContext(function($ctx1) {
  708. _st(aCollectionOfMethods)._do_((function(method){
  709. return smalltalk.withContext(function($ctx2) {
  710. return self._classify_(method);
  711. }, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)})}));
  712. return self}, function($ctx1) {$ctx1.fill(self,"classifyAll:",{aCollectionOfMethods:aCollectionOfMethods},smalltalk.HLMethodClassifier)})},
  713. args: ["aCollectionOfMethods"],
  714. source: "classifyAll: aCollectionOfMethods\x0a\x09aCollectionOfMethods do: [ :method |\x0a\x09\x09self classify: method ]",
  715. messageSends: ["do:", "classify:"],
  716. referencedClasses: []
  717. }),
  718. smalltalk.HLMethodClassifier);
  719. smalltalk.addMethod(
  720. smalltalk.method({
  721. selector: "classifyByKnownPrefix:",
  722. protocol: 'private',
  723. fn: function (aMethod){
  724. var self=this;
  725. return smalltalk.withContext(function($ctx1) {
  726. var $1;
  727. var $early={};
  728. try {
  729. _st(self["@prefixMapping"])._keysAndValuesDo_((function(prefix,protocol){
  730. return smalltalk.withContext(function($ctx2) {
  731. $1=_st(_st(aMethod)._selector())._beginsWith_(prefix);
  732. if(smalltalk.assert($1)){
  733. _st(aMethod)._protocol_(protocol);
  734. throw $early=[true];
  735. };
  736. }, function($ctx2) {$ctx2.fillBlock({prefix:prefix,protocol:protocol},$ctx1,1)})}));
  737. return false;
  738. }
  739. catch(e) {if(e===$early)return e[0]; throw e}
  740. }, function($ctx1) {$ctx1.fill(self,"classifyByKnownPrefix:",{aMethod:aMethod},smalltalk.HLMethodClassifier)})},
  741. args: ["aMethod"],
  742. source: "classifyByKnownPrefix: aMethod\x0a\x09prefixMapping keysAndValuesDo: [ :prefix :protocol |\x0a\x09\x09(aMethod selector beginsWith: prefix)\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09aMethod protocol: protocol.\x0a\x09\x09\x09\x09^ true ]].\x0a\x09^ false.",
  743. messageSends: ["keysAndValuesDo:", "ifTrue:", "beginsWith:", "selector", "protocol:"],
  744. referencedClasses: []
  745. }),
  746. smalltalk.HLMethodClassifier);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "classifyByOtherImplementors:",
  750. protocol: 'private',
  751. fn: function (aMethod){
  752. var self=this;
  753. var protocolBag,methods,protocolToUse,counter;
  754. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  755. function $HLReferencesModel(){return smalltalk.HLReferencesModel||(typeof HLReferencesModel=="undefined"?nil:HLReferencesModel)}
  756. return smalltalk.withContext(function($ctx1) {
  757. var $2,$1,$4,$3,$5;
  758. var $early={};
  759. try {
  760. protocolBag=_st($Dictionary())._new();
  761. $ctx1.sendIdx["new"]=1;
  762. methods=_st(_st($HLReferencesModel())._new())._implementorsOf_(_st(aMethod)._selector());
  763. _st(methods)._ifEmpty_ifNotEmpty_((function(){
  764. return smalltalk.withContext(function($ctx2) {
  765. throw $early=[false];
  766. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  767. return smalltalk.withContext(function($ctx2) {
  768. return _st(methods)._do_((function(method){
  769. var protocol;
  770. return smalltalk.withContext(function($ctx3) {
  771. protocol=_st(_st(method)._method())._protocol();
  772. protocol;
  773. $2=_st(aMethod)._methodClass();
  774. $ctx3.sendIdx["methodClass"]=1;
  775. $1=_st($2).__eq(_st(method)._methodClass());
  776. $ctx3.sendIdx["="]=1;
  777. if(! smalltalk.assert($1)){
  778. $4=_st(_st(protocol)._first()).__eq("*");
  779. $ctx3.sendIdx["="]=2;
  780. $3=_st($4)._or_((function(){
  781. return smalltalk.withContext(function($ctx4) {
  782. return _st(protocol).__eq(_st(aMethod)._defaultProtocol());
  783. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)})}));
  784. if(! smalltalk.assert($3)){
  785. return _st(protocolBag)._at_put_(protocol,_st(_st(protocolBag)._at_ifAbsent_(protocol,(function(){
  786. return smalltalk.withContext(function($ctx4) {
  787. return (0);
  788. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,7)})}))).__plus((1)));
  789. };
  790. };
  791. }, function($ctx3) {$ctx3.fillBlock({method:method,protocol:protocol},$ctx2,3)})}));
  792. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  793. _st(protocolBag)._ifEmpty_((function(){
  794. return smalltalk.withContext(function($ctx2) {
  795. throw $early=[false];
  796. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})}));
  797. protocolToUse=nil;
  798. counter=(0);
  799. _st(protocolBag)._keysAndValuesDo_((function(key,value){
  800. return smalltalk.withContext(function($ctx2) {
  801. $5=_st(value).__gt(counter);
  802. if(smalltalk.assert($5)){
  803. counter=value;
  804. counter;
  805. protocolToUse=key;
  806. return protocolToUse;
  807. };
  808. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,9)})}));
  809. _st(aMethod)._protocol_(protocolToUse);
  810. return true;
  811. }
  812. catch(e) {if(e===$early)return e[0]; throw e}
  813. }, function($ctx1) {$ctx1.fill(self,"classifyByOtherImplementors:",{aMethod:aMethod,protocolBag:protocolBag,methods:methods,protocolToUse:protocolToUse,counter:counter},smalltalk.HLMethodClassifier)})},
  814. args: ["aMethod"],
  815. source: "classifyByOtherImplementors: aMethod\x0a\x09| protocolBag methods protocolToUse counter |\x0a\x09\x0a\x09protocolBag := Dictionary new.\x0a\x09methods := HLReferencesModel new implementorsOf: aMethod selector.\x0a\x09methods\x0a\x09\x09ifEmpty: [ ^ false ]\x0a\x09\x09ifNotEmpty: [\x0a\x09\x09\x09methods \x0a\x09\x09\x09\x09do: [ :method || protocol |\x0a\x09\x09\x09\x09\x09protocol := method method protocol.\x0a\x09\x09\x09\x09\x09(aMethod methodClass = method methodClass)\x0a\x09\x09\x09\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09\x09\x09((protocol first = '*') or: [ protocol = aMethod 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\x09aMethod protocol: protocolToUse.\x0a\x09^ true",
  816. messageSends: ["new", "implementorsOf:", "selector", "ifEmpty:ifNotEmpty:", "do:", "protocol", "method", "ifFalse:", "=", "methodClass", "or:", "first", "defaultProtocol", "at:put:", "+", "at:ifAbsent:", "ifEmpty:", "keysAndValuesDo:", "ifTrue:", ">", "protocol:"],
  817. referencedClasses: ["Dictionary", "HLReferencesModel"]
  818. }),
  819. smalltalk.HLMethodClassifier);
  820. smalltalk.addMethod(
  821. smalltalk.method({
  822. selector: "classifyInSuperclassProtocol:",
  823. protocol: 'private',
  824. fn: function (aMethod){
  825. var self=this;
  826. var currentClass;
  827. return smalltalk.withContext(function($ctx1) {
  828. var $1,$3,$4,$2;
  829. var $early={};
  830. try {
  831. currentClass=_st(aMethod)._methodClass();
  832. _st((function(){
  833. return smalltalk.withContext(function($ctx2) {
  834. $1=_st(currentClass)._superclass();
  835. $ctx2.sendIdx["superclass"]=1;
  836. return _st($1)._isNil();
  837. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  838. return smalltalk.withContext(function($ctx2) {
  839. currentClass=_st(currentClass)._superclass();
  840. currentClass;
  841. $3=currentClass;
  842. $4=_st(aMethod)._selector();
  843. $ctx2.sendIdx["selector"]=1;
  844. $2=_st($3)._includesSelector_($4);
  845. if(smalltalk.assert($2)){
  846. _st(aMethod)._protocol_(_st(_st(currentClass).__gt_gt(_st(aMethod)._selector()))._protocol());
  847. throw $early=[true];
  848. };
  849. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  850. return false;
  851. }
  852. catch(e) {if(e===$early)return e[0]; throw e}
  853. }, function($ctx1) {$ctx1.fill(self,"classifyInSuperclassProtocol:",{aMethod:aMethod,currentClass:currentClass},smalltalk.HLMethodClassifier)})},
  854. args: ["aMethod"],
  855. source: "classifyInSuperclassProtocol: aMethod\x0a\x09| currentClass |\x0a\x09currentClass := aMethod methodClass.\x0a\x09\x0a\x09[ currentClass superclass isNil ] whileFalse: [\x0a\x09\x09currentClass := currentClass superclass.\x0a\x09\x09(currentClass includesSelector: aMethod selector)\x0a\x09\x09\x09ifTrue: [ \x0a\x09\x09\x09\x09aMethod protocol: (currentClass >> aMethod selector) protocol.\x0a\x09\x09\x09\x09^ true ]].\x0a\x09\x0a\x09^ false.",
  856. messageSends: ["methodClass", "whileFalse:", "isNil", "superclass", "ifTrue:", "includesSelector:", "selector", "protocol:", "protocol", ">>"],
  857. referencedClasses: []
  858. }),
  859. smalltalk.HLMethodClassifier);
  860. smalltalk.addMethod(
  861. smalltalk.method({
  862. selector: "initialize",
  863. protocol: 'initialization',
  864. fn: function (){
  865. var self=this;
  866. return smalltalk.withContext(function($ctx1) {
  867. smalltalk.HLMethodClassifier.superclass.fn.prototype._initialize.apply(_st(self), []);
  868. self._buildPrefixDictionary();
  869. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLMethodClassifier)})},
  870. args: [],
  871. source: "initialize\x0a\x09super initialize.\x0a\x09\x0a\x09self buildPrefixDictionary.",
  872. messageSends: ["initialize", "buildPrefixDictionary"],
  873. referencedClasses: []
  874. }),
  875. smalltalk.HLMethodClassifier);
  876. smalltalk.addClass('HLMethodSourceCode', smalltalk.Object, ['selector', 'sourceCode'], 'Helios-Helpers');
  877. smalltalk.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";
  878. smalltalk.addMethod(
  879. smalltalk.method({
  880. selector: "selector",
  881. protocol: 'accessing',
  882. fn: function (){
  883. var self=this;
  884. return smalltalk.withContext(function($ctx1) {
  885. var $1;
  886. $1=self["@selector"];
  887. return $1;
  888. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.HLMethodSourceCode)})},
  889. args: [],
  890. source: "selector\x0a\x09^ selector",
  891. messageSends: [],
  892. referencedClasses: []
  893. }),
  894. smalltalk.HLMethodSourceCode);
  895. smalltalk.addMethod(
  896. smalltalk.method({
  897. selector: "selector:",
  898. protocol: 'accessing',
  899. fn: function (aSelector){
  900. var self=this;
  901. return smalltalk.withContext(function($ctx1) {
  902. self["@selector"]=aSelector;
  903. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector},smalltalk.HLMethodSourceCode)})},
  904. args: ["aSelector"],
  905. source: "selector: aSelector\x0a\x09selector := aSelector",
  906. messageSends: [],
  907. referencedClasses: []
  908. }),
  909. smalltalk.HLMethodSourceCode);
  910. smalltalk.addMethod(
  911. smalltalk.method({
  912. selector: "sourceCode",
  913. protocol: 'accessing',
  914. fn: function (){
  915. var self=this;
  916. return smalltalk.withContext(function($ctx1) {
  917. var $1;
  918. $1=self["@sourceCode"];
  919. return $1;
  920. }, function($ctx1) {$ctx1.fill(self,"sourceCode",{},smalltalk.HLMethodSourceCode)})},
  921. args: [],
  922. source: "sourceCode\x0a\x09^ sourceCode",
  923. messageSends: [],
  924. referencedClasses: []
  925. }),
  926. smalltalk.HLMethodSourceCode);
  927. smalltalk.addMethod(
  928. smalltalk.method({
  929. selector: "sourceCode:",
  930. protocol: 'accessing',
  931. fn: function (aString){
  932. var self=this;
  933. return smalltalk.withContext(function($ctx1) {
  934. self["@sourceCode"]=aString;
  935. return self}, function($ctx1) {$ctx1.fill(self,"sourceCode:",{aString:aString},smalltalk.HLMethodSourceCode)})},
  936. args: ["aString"],
  937. source: "sourceCode: aString\x0a\x09sourceCode := aString",
  938. messageSends: [],
  939. referencedClasses: []
  940. }),
  941. smalltalk.HLMethodSourceCode);
  942. });