1
0

Kernel-Classes.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. smalltalk.addPackage('Kernel-Classes', {});
  2. smalltalk.addClass('Behavior', smalltalk.Object, [], 'Kernel-Classes');
  3. smalltalk.Behavior.comment="Behavior is the superclass of all class objects. \x0a\x0aIt defines the protocol for creating instances of a class with `#basicNew` and `#new` (see `boot.js` for class constructors details).\x0aInstances know about the subclass/superclass relationships between classes, contain the description that instances are created from, \x0aand hold the method dictionary that's associated with each class.\x0a\x0aBehavior also provides methods for compiling methods, examining the method dictionary, and iterating over the class hierarchy."
  4. smalltalk.addMethod(
  5. "_addCompiledMethod_",
  6. smalltalk.method({
  7. selector: "addCompiledMethod:",
  8. category: 'compiling',
  9. fn: function (aMethod){
  10. var self=this;
  11. smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self);
  12. return self;},
  13. args: ["aMethod"],
  14. source: "addCompiledMethod: aMethod\x0a\x09<smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self)>",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. smalltalk.Behavior);
  19. smalltalk.addMethod(
  20. "_allInstanceVariableNames",
  21. smalltalk.method({
  22. selector: "allInstanceVariableNames",
  23. category: 'accessing',
  24. fn: function (){
  25. var self=this;
  26. var result=nil;
  27. (result=smalltalk.send(smalltalk.send(self, "_instanceVariableNames", []), "_copy", []));
  28. (($receiver = smalltalk.send(self, "_superclass", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(result, "_addAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_allInstanceVariableNames", [])]);})() : nil;
  29. return result;
  30. return self;},
  31. args: [],
  32. source: "allInstanceVariableNames\x0a\x09| result |\x0a\x09result := self instanceVariableNames copy.\x0a\x09self superclass ifNotNil: [\x0a\x09 result addAll: self superclass allInstanceVariableNames].\x0a\x09^result",
  33. messageSends: ["copy", "instanceVariableNames", "ifNotNil:", "superclass", "addAll:", "allInstanceVariableNames"],
  34. referencedClasses: []
  35. }),
  36. smalltalk.Behavior);
  37. smalltalk.addMethod(
  38. "_allSubclasses",
  39. smalltalk.method({
  40. selector: "allSubclasses",
  41. category: 'accessing',
  42. fn: function (){
  43. var self=this;
  44. var result=nil;
  45. (result=smalltalk.send(self, "_subclasses", []));
  46. smalltalk.send(smalltalk.send(self, "_subclasses", []), "_do_", [(function(each){return smalltalk.send(result, "_addAll_", [smalltalk.send(each, "_allSubclasses", [])]);})]);
  47. return result;
  48. return self;},
  49. args: [],
  50. source: "allSubclasses\x0a\x09| result |\x0a\x09result := self subclasses.\x0a\x09self subclasses do: [:each |\x0a\x09 result addAll: each allSubclasses].\x0a\x09^result",
  51. messageSends: ["subclasses", "do:", "addAll:", "allSubclasses"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.Behavior);
  55. smalltalk.addMethod(
  56. "_basicNew",
  57. smalltalk.method({
  58. selector: "basicNew",
  59. category: 'instance creation',
  60. fn: function (){
  61. var self=this;
  62. return new self.fn();
  63. return self;},
  64. args: [],
  65. source: "basicNew\x0a\x09<return new self.fn()>",
  66. messageSends: [],
  67. referencedClasses: []
  68. }),
  69. smalltalk.Behavior);
  70. smalltalk.addMethod(
  71. "_canUnderstand_",
  72. smalltalk.method({
  73. selector: "canUnderstand:",
  74. category: 'testing',
  75. fn: function (aSelector){
  76. var self=this;
  77. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_includes_", [smalltalk.send(aSelector, "_asString", [])]), "_or_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(self, "_superclass", []), "_notNil", []), "_and_", [(function(){return smalltalk.send(smalltalk.send(self, "_superclass", []), "_canUnderstand_", [aSelector]);})]);})]);
  78. return self;},
  79. args: ["aSelector"],
  80. source: "canUnderstand: aSelector\x0a\x09^(self methodDictionary keys includes: aSelector asString) or: [\x0a\x09\x09self superclass notNil and: [self superclass canUnderstand: aSelector]]",
  81. messageSends: ["or:", "includes:", "keys", "methodDictionary", "asString", "and:", "notNil", "superclass", "canUnderstand:"],
  82. referencedClasses: []
  83. }),
  84. smalltalk.Behavior);
  85. smalltalk.addMethod(
  86. "_comment",
  87. smalltalk.method({
  88. selector: "comment",
  89. category: 'accessing',
  90. fn: function (){
  91. var self=this;
  92. return (($receiver = smalltalk.send(self, "_basicAt_", ["comment"])) == nil || $receiver == undefined) ? (function(){return "";})() : $receiver;
  93. return self;},
  94. args: [],
  95. source: "comment\x0a ^(self basicAt: 'comment') ifNil: ['']",
  96. messageSends: ["ifNil:", "basicAt:"],
  97. referencedClasses: []
  98. }),
  99. smalltalk.Behavior);
  100. smalltalk.addMethod(
  101. "_comment_",
  102. smalltalk.method({
  103. selector: "comment:",
  104. category: 'accessing',
  105. fn: function (aString){
  106. var self=this;
  107. smalltalk.send(self, "_basicAt_put_", ["comment", aString]);
  108. return self;},
  109. args: ["aString"],
  110. source: "comment: aString\x0a self basicAt: 'comment' put: aString",
  111. messageSends: ["basicAt:put:"],
  112. referencedClasses: []
  113. }),
  114. smalltalk.Behavior);
  115. smalltalk.addMethod(
  116. "_commentStamp",
  117. smalltalk.method({
  118. selector: "commentStamp",
  119. category: 'accessing',
  120. fn: function (){
  121. var self=this;
  122. return (function($rec){smalltalk.send($rec, "_class_", [self]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.ClassCommentReader || ClassCommentReader), "_new", []));
  123. return self;},
  124. args: [],
  125. source: "commentStamp\x0a ^ClassCommentReader new\x0a\x09class: self;\x0a\x09yourself",
  126. messageSends: ["class:", "yourself", "new"],
  127. referencedClasses: ["ClassCommentReader"]
  128. }),
  129. smalltalk.Behavior);
  130. smalltalk.addMethod(
  131. "_commentStamp_prior_",
  132. smalltalk.method({
  133. selector: "commentStamp:prior:",
  134. category: 'accessing',
  135. fn: function (aStamp, prior){
  136. var self=this;
  137. return smalltalk.send(self, "_commentStamp", []);
  138. return self;},
  139. args: ["aStamp", "prior"],
  140. source: "commentStamp: aStamp prior: prior\x0a ^self commentStamp",
  141. messageSends: ["commentStamp"],
  142. referencedClasses: []
  143. }),
  144. smalltalk.Behavior);
  145. smalltalk.addMethod(
  146. "_compile_",
  147. smalltalk.method({
  148. selector: "compile:",
  149. category: 'compiling',
  150. fn: function (aString){
  151. var self=this;
  152. smalltalk.send(self, "_compile_category_", [aString, ""]);
  153. return self;},
  154. args: ["aString"],
  155. source: "compile: aString\x0a\x09self compile: aString category: ''",
  156. messageSends: ["compile:category:"],
  157. referencedClasses: []
  158. }),
  159. smalltalk.Behavior);
  160. smalltalk.addMethod(
  161. "_compile_category_",
  162. smalltalk.method({
  163. selector: "compile:category:",
  164. category: 'compiling',
  165. fn: function (aString, anotherString){
  166. var self=this;
  167. (function($rec){smalltalk.send($rec, "_install_forClass_category_", [aString, self, anotherString]);return smalltalk.send($rec, "_setupClass_", [self]);})(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []));
  168. return self;},
  169. args: ["aString", "anotherString"],
  170. source: "compile: aString category: anotherString\x0a\x09Compiler new\x0a\x09\x09install: aString forClass: self category: anotherString;\x0a\x09\x09setupClass: self",
  171. messageSends: ["install:forClass:category:", "setupClass:", "new"],
  172. referencedClasses: ["Compiler"]
  173. }),
  174. smalltalk.Behavior);
  175. smalltalk.addMethod(
  176. "_inheritsFrom_",
  177. smalltalk.method({
  178. selector: "inheritsFrom:",
  179. category: 'testing',
  180. fn: function (aClass){
  181. var self=this;
  182. return smalltalk.send(smalltalk.send(aClass, "_allSubclasses", []), "_includes_", [self]);
  183. return self;},
  184. args: ["aClass"],
  185. source: "inheritsFrom: aClass\x0a\x09^aClass allSubclasses includes: self",
  186. messageSends: ["includes:", "allSubclasses"],
  187. referencedClasses: []
  188. }),
  189. smalltalk.Behavior);
  190. smalltalk.addMethod(
  191. "_instanceVariableNames",
  192. smalltalk.method({
  193. selector: "instanceVariableNames",
  194. category: 'accessing',
  195. fn: function (){
  196. var self=this;
  197. return self.iVarNames;
  198. return self;},
  199. args: [],
  200. source: "instanceVariableNames\x0a\x09<return self.iVarNames>",
  201. messageSends: [],
  202. referencedClasses: []
  203. }),
  204. smalltalk.Behavior);
  205. smalltalk.addMethod(
  206. "_methodAt_",
  207. smalltalk.method({
  208. selector: "methodAt:",
  209. category: 'accessing',
  210. fn: function (aString){
  211. var self=this;
  212. return smalltalk.methods(self)[aString];
  213. return self;},
  214. args: ["aString"],
  215. source: "methodAt: aString\x0a\x09<return smalltalk.methods(self)[aString]>",
  216. messageSends: [],
  217. referencedClasses: []
  218. }),
  219. smalltalk.Behavior);
  220. smalltalk.addMethod(
  221. "_methodDictionary",
  222. smalltalk.method({
  223. selector: "methodDictionary",
  224. category: 'accessing',
  225. fn: function (){
  226. var self=this;
  227. var dict = smalltalk.HashedCollection._new();
  228. var methods = self.fn.prototype.methods;
  229. for(var i in methods) {
  230. if(methods[i].selector) {
  231. dict._at_put_(methods[i].selector, methods[i]);
  232. }
  233. };
  234. return dict;
  235. return self;},
  236. args: [],
  237. source: "methodDictionary\x0a\x09<var dict = smalltalk.HashedCollection._new();\x0a\x09var methods = self.fn.prototype.methods;\x0a\x09for(var i in methods) {\x0a\x09\x09if(methods[i].selector) {\x0a\x09\x09\x09dict._at_put_(methods[i].selector, methods[i]);\x0a\x09\x09}\x0a\x09};\x0a\x09return dict>",
  238. messageSends: [],
  239. referencedClasses: []
  240. }),
  241. smalltalk.Behavior);
  242. smalltalk.addMethod(
  243. "_methodsFor_",
  244. smalltalk.method({
  245. selector: "methodsFor:",
  246. category: 'accessing',
  247. fn: function (aString){
  248. var self=this;
  249. return (function($rec){smalltalk.send($rec, "_class_category_", [self, aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.ClassCategoryReader || ClassCategoryReader), "_new", []));
  250. return self;},
  251. args: ["aString"],
  252. source: "methodsFor: aString\x0a\x09^ClassCategoryReader new\x0a\x09 class: self category: aString;\x0a\x09 yourself",
  253. messageSends: ["class:category:", "yourself", "new"],
  254. referencedClasses: ["ClassCategoryReader"]
  255. }),
  256. smalltalk.Behavior);
  257. smalltalk.addMethod(
  258. "_methodsFor_stamp_",
  259. smalltalk.method({
  260. selector: "methodsFor:stamp:",
  261. category: 'accessing',
  262. fn: function (aString, aStamp){
  263. var self=this;
  264. return smalltalk.send(self, "_methodsFor_", [aString]);
  265. return self;},
  266. args: ["aString", "aStamp"],
  267. source: "methodsFor: aString stamp: aStamp\x0a\x09\x22Added for compatibility, right now ignores stamp.\x22\x0a\x09^self methodsFor: aString",
  268. messageSends: ["methodsFor:"],
  269. referencedClasses: []
  270. }),
  271. smalltalk.Behavior);
  272. smalltalk.addMethod(
  273. "_name",
  274. smalltalk.method({
  275. selector: "name",
  276. category: 'accessing',
  277. fn: function (){
  278. var self=this;
  279. return self.className || nil;
  280. return self;},
  281. args: [],
  282. source: "name\x0a\x09<return self.className || nil>",
  283. messageSends: [],
  284. referencedClasses: []
  285. }),
  286. smalltalk.Behavior);
  287. smalltalk.addMethod(
  288. "_new",
  289. smalltalk.method({
  290. selector: "new",
  291. category: 'instance creation',
  292. fn: function (){
  293. var self=this;
  294. return smalltalk.send(smalltalk.send(self, "_basicNew", []), "_initialize", []);
  295. return self;},
  296. args: [],
  297. source: "new\x0a\x09^self basicNew initialize",
  298. messageSends: ["initialize", "basicNew"],
  299. referencedClasses: []
  300. }),
  301. smalltalk.Behavior);
  302. smalltalk.addMethod(
  303. "_protocols",
  304. smalltalk.method({
  305. selector: "protocols",
  306. category: 'accessing',
  307. fn: function (){
  308. var self=this;
  309. var protocols=nil;
  310. (protocols=smalltalk.send((smalltalk.Array || Array), "_new", []));
  311. smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_do_", [(function(each){return ((($receiver = smalltalk.send(protocols, "_includes_", [smalltalk.send(each, "_category", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(protocols, "_add_", [smalltalk.send(each, "_category", [])]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(protocols, "_add_", [smalltalk.send(each, "_category", [])]);})]));})]);
  312. return smalltalk.send(protocols, "_sort", []);
  313. return self;},
  314. args: [],
  315. source: "protocols\x0a | protocols |\x0a protocols := Array new.\x0a self methodDictionary do: [:each |\x0a\x09 (protocols includes: each category) ifFalse: [\x0a\x09\x09protocols add: each category]].\x0a ^protocols sort",
  316. messageSends: ["new", "do:", "methodDictionary", "ifFalse:", "includes:", "category", "add:", "sort"],
  317. referencedClasses: ["Array"]
  318. }),
  319. smalltalk.Behavior);
  320. smalltalk.addMethod(
  321. "_protocolsDo_",
  322. smalltalk.method({
  323. selector: "protocolsDo:",
  324. category: 'accessing',
  325. fn: function (aBlock){
  326. var self=this;
  327. var methodsByCategory=nil;
  328. (methodsByCategory=smalltalk.send((smalltalk.HashedCollection || HashedCollection), "_new", []));
  329. smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_values", []), "_do_", [(function(m){return smalltalk.send(smalltalk.send(methodsByCategory, "_at_ifAbsentPut_", [smalltalk.send(m, "_category", []), (function(){return smalltalk.send((smalltalk.Array || Array), "_new", []);})]), "_add_", [m]);})]);
  330. smalltalk.send(smalltalk.send(self, "_protocols", []), "_do_", [(function(category){return smalltalk.send(aBlock, "_value_value_", [category, smalltalk.send(methodsByCategory, "_at_", [category])]);})]);
  331. return self;},
  332. args: ["aBlock"],
  333. source: "protocolsDo: aBlock\x0a\x09\x22Execute aBlock for each method category with\x0a\x09its collection of methods in the sort order of category name.\x22\x0a\x0a\x09| methodsByCategory |\x0a\x09methodsByCategory := HashedCollection new.\x0a\x09self methodDictionary values do: [:m |\x0a\x09\x09(methodsByCategory at: m category ifAbsentPut: [Array new])\x0a \x09\x09\x09add: m]. \x0a\x09self protocols do: [:category |\x0a\x09\x09aBlock value: category value: (methodsByCategory at: category)]",
  334. messageSends: ["new", "do:", "values", "methodDictionary", "add:", "at:ifAbsentPut:", "category", "protocols", "value:value:", "at:"],
  335. referencedClasses: ["HashedCollection", "Array"]
  336. }),
  337. smalltalk.Behavior);
  338. smalltalk.addMethod(
  339. "_prototype",
  340. smalltalk.method({
  341. selector: "prototype",
  342. category: 'accessing',
  343. fn: function (){
  344. var self=this;
  345. return self.fn.prototype;
  346. return self;},
  347. args: [],
  348. source: "prototype\x0a\x09<return self.fn.prototype>",
  349. messageSends: [],
  350. referencedClasses: []
  351. }),
  352. smalltalk.Behavior);
  353. smalltalk.addMethod(
  354. "_removeCompiledMethod_",
  355. smalltalk.method({
  356. selector: "removeCompiledMethod:",
  357. category: 'compiling',
  358. fn: function (aMethod){
  359. var self=this;
  360. delete self.fn.prototype[aMethod.selector._asSelector()];
  361. delete self.fn.prototype.methods[aMethod.selector];
  362. smalltalk.init(self);;
  363. return self;},
  364. args: ["aMethod"],
  365. source: "removeCompiledMethod: aMethod\x0a\x09<delete self.fn.prototype[aMethod.selector._asSelector()];\x0a\x09delete self.fn.prototype.methods[aMethod.selector];\x0a\x09smalltalk.init(self);>",
  366. messageSends: [],
  367. referencedClasses: []
  368. }),
  369. smalltalk.Behavior);
  370. smalltalk.addMethod(
  371. "_subclasses",
  372. smalltalk.method({
  373. selector: "subclasses",
  374. category: 'accessing',
  375. fn: function (){
  376. var self=this;
  377. return smalltalk.subclasses(self);
  378. return self;},
  379. args: [],
  380. source: "subclasses\x0a\x09<return smalltalk.subclasses(self)>",
  381. messageSends: [],
  382. referencedClasses: []
  383. }),
  384. smalltalk.Behavior);
  385. smalltalk.addMethod(
  386. "_superclass",
  387. smalltalk.method({
  388. selector: "superclass",
  389. category: 'accessing',
  390. fn: function (){
  391. var self=this;
  392. return self.superclass || nil;
  393. return self;},
  394. args: [],
  395. source: "superclass\x0a\x09<return self.superclass || nil>",
  396. messageSends: [],
  397. referencedClasses: []
  398. }),
  399. smalltalk.Behavior);
  400. smalltalk.addMethod(
  401. "_withAllSubclasses",
  402. smalltalk.method({
  403. selector: "withAllSubclasses",
  404. category: 'accessing',
  405. fn: function (){
  406. var self=this;
  407. return (function($rec){smalltalk.send($rec, "_addAll_", [smalltalk.send(self, "_allSubclasses", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Array || Array), "_with_", [self]));
  408. return self;},
  409. args: [],
  410. source: "withAllSubclasses\x0a\x09^(Array with: self) addAll: self allSubclasses; yourself",
  411. messageSends: ["addAll:", "allSubclasses", "yourself", "with:"],
  412. referencedClasses: ["Array"]
  413. }),
  414. smalltalk.Behavior);
  415. smalltalk.addClass('Class', smalltalk.Behavior, [], 'Kernel-Classes');
  416. smalltalk.Class.comment="Class is __the__ class object. \x0a\x0aInstances are the classes of the system.\x0aClass creation is done throught a `ClassBuilder`"
  417. smalltalk.addMethod(
  418. "_category",
  419. smalltalk.method({
  420. selector: "category",
  421. category: 'accessing',
  422. fn: function (){
  423. var self=this;
  424. return (($receiver = smalltalk.send(self, "_package", [])) == nil || $receiver == undefined) ? (function(){return "Unclassified";})() : (function(){return smalltalk.send(smalltalk.send(self, "_package", []), "_name", []);})();
  425. return self;},
  426. args: [],
  427. source: "category\x0a\x09^self package ifNil: ['Unclassified'] ifNotNil: [self package name]",
  428. messageSends: ["ifNil:ifNotNil:", "package", "name"],
  429. referencedClasses: []
  430. }),
  431. smalltalk.Class);
  432. smalltalk.addMethod(
  433. "_isClass",
  434. smalltalk.method({
  435. selector: "isClass",
  436. category: 'testing',
  437. fn: function (){
  438. var self=this;
  439. return true;
  440. return self;},
  441. args: [],
  442. source: "isClass\x0a\x09^true",
  443. messageSends: [],
  444. referencedClasses: []
  445. }),
  446. smalltalk.Class);
  447. smalltalk.addMethod(
  448. "_package",
  449. smalltalk.method({
  450. selector: "package",
  451. category: 'accessing',
  452. fn: function (){
  453. var self=this;
  454. return self.pkg;
  455. return self;},
  456. args: [],
  457. source: "package\x0a\x09<return self.pkg>",
  458. messageSends: [],
  459. referencedClasses: []
  460. }),
  461. smalltalk.Class);
  462. smalltalk.addMethod(
  463. "_package_",
  464. smalltalk.method({
  465. selector: "package:",
  466. category: 'accessing',
  467. fn: function (aPackage){
  468. var self=this;
  469. self.pkg = aPackage;
  470. return self;},
  471. args: ["aPackage"],
  472. source: "package: aPackage\x0a\x09<self.pkg = aPackage>",
  473. messageSends: [],
  474. referencedClasses: []
  475. }),
  476. smalltalk.Class);
  477. smalltalk.addMethod(
  478. "_printString",
  479. smalltalk.method({
  480. selector: "printString",
  481. category: 'printing',
  482. fn: function (){
  483. var self=this;
  484. return smalltalk.send(self, "_name", []);
  485. return self;},
  486. args: [],
  487. source: "printString\x0a\x09^self name",
  488. messageSends: ["name"],
  489. referencedClasses: []
  490. }),
  491. smalltalk.Class);
  492. smalltalk.addMethod(
  493. "_rename_",
  494. smalltalk.method({
  495. selector: "rename:",
  496. category: 'accessing',
  497. fn: function (aString){
  498. var self=this;
  499. smalltalk[aString] = self;
  500. delete smalltalk[self.className];
  501. self.className = aString;
  502. ;
  503. return self;},
  504. args: ["aString"],
  505. source: "rename: aString\x0a\x09<\x0a\x09\x09smalltalk[aString] = self;\x0a\x09\x09delete smalltalk[self.className];\x0a\x09\x09self.className = aString;\x0a\x09>",
  506. messageSends: [],
  507. referencedClasses: []
  508. }),
  509. smalltalk.Class);
  510. smalltalk.addMethod(
  511. "_subclass_instanceVariableNames_",
  512. smalltalk.method({
  513. selector: "subclass:instanceVariableNames:",
  514. category: 'class creation',
  515. fn: function (aString, anotherString){
  516. var self=this;
  517. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, anotherString, nil]);
  518. return self;},
  519. args: ["aString", "anotherString"],
  520. source: "subclass: aString instanceVariableNames: anotherString\x0a\x09\x22Kept for compatibility.\x22\x0a\x09^self subclass: aString instanceVariableNames: anotherString package: nil",
  521. messageSends: ["subclass:instanceVariableNames:package:"],
  522. referencedClasses: []
  523. }),
  524. smalltalk.Class);
  525. smalltalk.addMethod(
  526. "_subclass_instanceVariableNames_category_",
  527. smalltalk.method({
  528. selector: "subclass:instanceVariableNames:category:",
  529. category: 'class creation',
  530. fn: function (aString, aString2, aString3){
  531. var self=this;
  532. smalltalk.send(self, "_deprecatedAPI", []);
  533. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
  534. return self;},
  535. args: ["aString", "aString2", "aString3"],
  536. source: "subclass: aString instanceVariableNames: aString2 category: aString3\x0a\x09\x22Kept for compatibility.\x22\x0a\x09self deprecatedAPI.\x0a\x09^self subclass: aString instanceVariableNames: aString2 package: aString3",
  537. messageSends: ["deprecatedAPI", "subclass:instanceVariableNames:package:"],
  538. referencedClasses: []
  539. }),
  540. smalltalk.Class);
  541. smalltalk.addMethod(
  542. "_subclass_instanceVariableNames_classVariableNames_poolDictionaries_category_",
  543. smalltalk.method({
  544. selector: "subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:",
  545. category: 'class creation',
  546. fn: function (aString, aString2, classVars, pools, aString3){
  547. var self=this;
  548. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
  549. return self;},
  550. args: ["aString", "aString2", "classVars", "pools", "aString3"],
  551. source: "subclass: aString instanceVariableNames: aString2 classVariableNames: classVars poolDictionaries: pools category: aString3\x0a\x09\x22Just ignore class variables and pools. Added for compatibility.\x22\x0a\x09^self subclass: aString instanceVariableNames: aString2 package: aString3",
  552. messageSends: ["subclass:instanceVariableNames:package:"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.Class);
  556. smalltalk.addMethod(
  557. "_subclass_instanceVariableNames_package_",
  558. smalltalk.method({
  559. selector: "subclass:instanceVariableNames:package:",
  560. category: 'class creation',
  561. fn: function (aString, aString2, aString3){
  562. var self=this;
  563. return smalltalk.send(smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []), "_superclass_subclass_instanceVariableNames_package_", [self, smalltalk.send(aString, "_asString", []), aString2, aString3]);
  564. return self;},
  565. args: ["aString", "aString2", "aString3"],
  566. source: "subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09^ClassBuilder new\x0a\x09 superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3",
  567. messageSends: ["superclass:subclass:instanceVariableNames:package:", "new", "asString"],
  568. referencedClasses: ["ClassBuilder"]
  569. }),
  570. smalltalk.Class);
  571. smalltalk.addClass('Metaclass', smalltalk.Behavior, [], 'Kernel-Classes');
  572. smalltalk.Metaclass.comment="Metaclass is the root of the class hierarchy.\x0a\x0aMetaclass instances are metaclasses, one for each real class. \x0aMetaclass instances have a single instance, which they hold onto, which is the class that they are the metaclass of."
  573. smalltalk.addMethod(
  574. "_instanceClass",
  575. smalltalk.method({
  576. selector: "instanceClass",
  577. category: 'accessing',
  578. fn: function (){
  579. var self=this;
  580. return self.instanceClass;
  581. return self;},
  582. args: [],
  583. source: "instanceClass\x0a\x09<return self.instanceClass>",
  584. messageSends: [],
  585. referencedClasses: []
  586. }),
  587. smalltalk.Metaclass);
  588. smalltalk.addMethod(
  589. "_instanceVariableNames_",
  590. smalltalk.method({
  591. selector: "instanceVariableNames:",
  592. category: 'accessing',
  593. fn: function (aCollection){
  594. var self=this;
  595. smalltalk.send(smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []), "_class_instanceVariableNames_", [self, aCollection]);
  596. return self;},
  597. args: ["aCollection"],
  598. source: "instanceVariableNames: aCollection\x0a\x09ClassBuilder new\x0a\x09 class: self instanceVariableNames: aCollection",
  599. messageSends: ["class:instanceVariableNames:", "new"],
  600. referencedClasses: ["ClassBuilder"]
  601. }),
  602. smalltalk.Metaclass);
  603. smalltalk.addMethod(
  604. "_isMetaclass",
  605. smalltalk.method({
  606. selector: "isMetaclass",
  607. category: 'testing',
  608. fn: function (){
  609. var self=this;
  610. return true;
  611. return self;},
  612. args: [],
  613. source: "isMetaclass\x0a\x09^true",
  614. messageSends: [],
  615. referencedClasses: []
  616. }),
  617. smalltalk.Metaclass);
  618. smalltalk.addMethod(
  619. "_printString",
  620. smalltalk.method({
  621. selector: "printString",
  622. category: 'printing',
  623. fn: function (){
  624. var self=this;
  625. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_instanceClass", []), "_name", []), "__comma", [" class"]);
  626. return self;},
  627. args: [],
  628. source: "printString\x0a\x09^self instanceClass name, ' class'",
  629. messageSends: [",", "name", "instanceClass"],
  630. referencedClasses: []
  631. }),
  632. smalltalk.Metaclass);
  633. smalltalk.addClass('ClassBuilder', smalltalk.Object, [], 'Kernel-Classes');
  634. smalltalk.ClassBuilder.comment="ClassBuilder is responsible for compiling new classes or modifying existing classes in the system.\x0a\x0aRather than using ClassBuilder directly to compile a class, use `Class >> subclass:instanceVariableNames:package:`."
  635. smalltalk.addMethod(
  636. "_addSubclassOf_named_instanceVariableNames_",
  637. smalltalk.method({
  638. selector: "addSubclassOf:named:instanceVariableNames:",
  639. category: 'private',
  640. fn: function (aClass, aString, aCollection){
  641. var self=this;
  642. smalltalk.addClass(aString, aClass, aCollection);
  643. return smalltalk[aString];
  644. return self;},
  645. args: ["aClass", "aString", "aCollection"],
  646. source: "addSubclassOf: aClass named: aString instanceVariableNames: aCollection\x0a\x09<smalltalk.addClass(aString, aClass, aCollection);\x0a\x09 return smalltalk[aString]>",
  647. messageSends: [],
  648. referencedClasses: []
  649. }),
  650. smalltalk.ClassBuilder);
  651. smalltalk.addMethod(
  652. "_addSubclassOf_named_instanceVariableNames_package_",
  653. smalltalk.method({
  654. selector: "addSubclassOf:named:instanceVariableNames:package:",
  655. category: 'private',
  656. fn: function (aClass, aString, aCollection, packageName){
  657. var self=this;
  658. smalltalk.addClass(aString, aClass, aCollection, packageName);
  659. return smalltalk[aString];
  660. return self;},
  661. args: ["aClass", "aString", "aCollection", "packageName"],
  662. source: "addSubclassOf: aClass named: aString instanceVariableNames: aCollection package: packageName\x0a\x09<smalltalk.addClass(aString, aClass, aCollection, packageName);\x0a\x09 return smalltalk[aString]>",
  663. messageSends: [],
  664. referencedClasses: []
  665. }),
  666. smalltalk.ClassBuilder);
  667. smalltalk.addMethod(
  668. "_class_instanceVariableNames_",
  669. smalltalk.method({
  670. selector: "class:instanceVariableNames:",
  671. category: 'class creation',
  672. fn: function (aClass, aString){
  673. var self=this;
  674. ((($receiver = smalltalk.send(aClass, "_isMetaclass", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self, "_error_", [smalltalk.send(smalltalk.send(aClass, "_name", []), "__comma", [" is not a metaclass"])]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self, "_error_", [smalltalk.send(smalltalk.send(aClass, "_name", []), "__comma", [" is not a metaclass"])]);})]));
  675. smalltalk.send(aClass, "_basicAt_put_", ["iVarNames", smalltalk.send(self, "_instanceVariableNamesFor_", [aString])]);
  676. smalltalk.send(self, "_setupClass_", [aClass]);
  677. return self;},
  678. args: ["aClass", "aString"],
  679. source: "class: aClass instanceVariableNames: aString\x0a\x09aClass isMetaclass ifFalse: [self error: aClass name, ' is not a metaclass'].\x0a\x09aClass basicAt: 'iVarNames' put: (self instanceVariableNamesFor: aString).\x0a\x09self setupClass: aClass",
  680. messageSends: ["ifFalse:", "isMetaclass", "error:", ",", "name", "basicAt:put:", "instanceVariableNamesFor:", "setupClass:"],
  681. referencedClasses: []
  682. }),
  683. smalltalk.ClassBuilder);
  684. smalltalk.addMethod(
  685. "_copyClass_named_",
  686. smalltalk.method({
  687. selector: "copyClass:named:",
  688. category: 'private',
  689. fn: function (aClass, aString){
  690. var self=this;
  691. var newClass=nil;
  692. (newClass=smalltalk.send(self, "_addSubclassOf_named_instanceVariableNames_package_", [smalltalk.send(aClass, "_superclass", []), aString, smalltalk.send(aClass, "_instanceVariableNames", []), smalltalk.send(smalltalk.send(aClass, "_package", []), "_name", [])]));
  693. smalltalk.send(self, "_setupClass_", [newClass]);
  694. smalltalk.send(smalltalk.send(smalltalk.send(aClass, "_methodDictionary", []), "_values", []), "_do_", [(function(each){return smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_install_forClass_category_", [smalltalk.send(each, "_source", []), newClass, smalltalk.send(each, "_category", [])]);})]);
  695. smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aClass, "_class", []), "_methodDictionary", []), "_values", []), "_do_", [(function(each){return smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_install_forClass_category_", [smalltalk.send(each, "_source", []), smalltalk.send(newClass, "_class", []), smalltalk.send(each, "_category", [])]);})]);
  696. smalltalk.send(self, "_setupClass_", [newClass]);
  697. return newClass;
  698. return self;},
  699. args: ["aClass", "aString"],
  700. source: "copyClass: aClass named: aString\x0a\x09| newClass |\x0a\x0a\x09newClass := self \x0a\x09\x09addSubclassOf: aClass superclass\x0a\x09\x09named: aString \x0a\x09\x09instanceVariableNames: aClass instanceVariableNames \x0a\x09\x09package: aClass package name.\x0a\x0a\x09self setupClass: newClass.\x0a\x0a\x09aClass methodDictionary values do: [:each |\x0a\x09\x09Compiler new install: each source forClass: newClass category: each category].\x0a\x0a\x09aClass class methodDictionary values do: [:each |\x0a\x09\x09Compiler new install: each source forClass: newClass class category: each category].\x0a\x0a\x09self setupClass: newClass.\x0a\x09^newClass",
  701. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "superclass", "instanceVariableNames", "name", "package", "setupClass:", "do:", "values", "methodDictionary", "install:forClass:category:", "new", "source", "category", "class"],
  702. referencedClasses: ["Compiler"]
  703. }),
  704. smalltalk.ClassBuilder);
  705. smalltalk.addMethod(
  706. "_instanceVariableNamesFor_",
  707. smalltalk.method({
  708. selector: "instanceVariableNamesFor:",
  709. category: 'private',
  710. fn: function (aString){
  711. var self=this;
  712. return smalltalk.send(smalltalk.send(aString, "_tokenize_", [" "]), "_reject_", [(function(each){return smalltalk.send(each, "_isEmpty", []);})]);
  713. return self;},
  714. args: ["aString"],
  715. source: "instanceVariableNamesFor: aString\x0a\x09^(aString tokenize: ' ') reject: [:each | each isEmpty]",
  716. messageSends: ["reject:", "tokenize:", "isEmpty"],
  717. referencedClasses: []
  718. }),
  719. smalltalk.ClassBuilder);
  720. smalltalk.addMethod(
  721. "_setupClass_",
  722. smalltalk.method({
  723. selector: "setupClass:",
  724. category: 'private',
  725. fn: function (aClass){
  726. var self=this;
  727. smalltalk.init(aClass);;
  728. return self;},
  729. args: ["aClass"],
  730. source: "setupClass: aClass\x0a\x09<smalltalk.init(aClass);>",
  731. messageSends: [],
  732. referencedClasses: []
  733. }),
  734. smalltalk.ClassBuilder);
  735. smalltalk.addMethod(
  736. "_superclass_subclass_",
  737. smalltalk.method({
  738. selector: "superclass:subclass:",
  739. category: 'class creation',
  740. fn: function (aClass, aString){
  741. var self=this;
  742. return smalltalk.send(self, "_superclass_subclass_instanceVariableNames_package_", [aClass, aString, "", nil]);
  743. return self;},
  744. args: ["aClass", "aString"],
  745. source: "superclass: aClass subclass: aString\x0a\x09^self superclass: aClass subclass: aString instanceVariableNames: '' package: nil",
  746. messageSends: ["superclass:subclass:instanceVariableNames:package:"],
  747. referencedClasses: []
  748. }),
  749. smalltalk.ClassBuilder);
  750. smalltalk.addMethod(
  751. "_superclass_subclass_instanceVariableNames_package_",
  752. smalltalk.method({
  753. selector: "superclass:subclass:instanceVariableNames:package:",
  754. category: 'class creation',
  755. fn: function (aClass, aString, aString2, aString3){
  756. var self=this;
  757. var newClass=nil;
  758. (newClass=smalltalk.send(self, "_addSubclassOf_named_instanceVariableNames_package_", [aClass, aString, smalltalk.send(self, "_instanceVariableNamesFor_", [aString2]), (($receiver = aString3) == nil || $receiver == undefined) ? (function(){return "unclassified";})() : $receiver]));
  759. smalltalk.send(self, "_setupClass_", [newClass]);
  760. return newClass;
  761. return self;},
  762. args: ["aClass", "aString", "aString2", "aString3"],
  763. source: "superclass: aClass subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09| newClass |\x0a\x09newClass := self addSubclassOf: aClass\x0a\x09\x09\x09\x09named: aString instanceVariableNames: (self instanceVariableNamesFor: aString2)\x0a\x09\x09\x09\x09package: (aString3 ifNil: ['unclassified']).\x0a\x09self setupClass: newClass.\x0a\x09^newClass",
  764. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "instanceVariableNamesFor:", "ifNil:", "setupClass:"],
  765. referencedClasses: []
  766. }),
  767. smalltalk.ClassBuilder);
  768. smalltalk.addClass('ClassCategoryReader', smalltalk.Object, ['class', 'category', 'chunkParser'], 'Kernel-Classes');
  769. smalltalk.ClassCategoryReader.comment="ClassCategoryReader represents a mechanism for retrieving class descriptions stored on a file."
  770. smalltalk.addMethod(
  771. "_class_category_",
  772. smalltalk.method({
  773. selector: "class:category:",
  774. category: 'accessing',
  775. fn: function (aClass, aString){
  776. var self=this;
  777. (self['@class']=aClass);
  778. (self['@category']=aString);
  779. return self;},
  780. args: ["aClass", "aString"],
  781. source: "class: aClass category: aString\x0a\x09class := aClass.\x0a\x09category := aString",
  782. messageSends: [],
  783. referencedClasses: []
  784. }),
  785. smalltalk.ClassCategoryReader);
  786. smalltalk.addMethod(
  787. "_compileMethod_",
  788. smalltalk.method({
  789. selector: "compileMethod:",
  790. category: 'private',
  791. fn: function (aString){
  792. var self=this;
  793. smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_install_forClass_category_", [aString, self['@class'], self['@category']]);
  794. return self;},
  795. args: ["aString"],
  796. source: "compileMethod: aString\x0a\x09Compiler new install: aString forClass: class category: category",
  797. messageSends: ["install:forClass:category:", "new"],
  798. referencedClasses: ["Compiler"]
  799. }),
  800. smalltalk.ClassCategoryReader);
  801. smalltalk.addMethod(
  802. "_initialize",
  803. smalltalk.method({
  804. selector: "initialize",
  805. category: 'initialization',
  806. fn: function (){
  807. var self=this;
  808. smalltalk.send(self, "_initialize", [], smalltalk.ClassCategoryReader.superclass || nil);
  809. (self['@chunkParser']=smalltalk.send((smalltalk.ChunkParser || ChunkParser), "_new", []));
  810. return self;},
  811. args: [],
  812. source: "initialize\x0a\x09super initialize.\x0a\x09chunkParser := ChunkParser new.",
  813. messageSends: ["initialize", "new"],
  814. referencedClasses: ["ChunkParser"]
  815. }),
  816. smalltalk.ClassCategoryReader);
  817. smalltalk.addMethod(
  818. "_scanFrom_",
  819. smalltalk.method({
  820. selector: "scanFrom:",
  821. category: 'fileIn',
  822. fn: function (aChunkParser){
  823. var self=this;
  824. var chunk=nil;
  825. (function(){while(!(function(){(chunk=smalltalk.send(aChunkParser, "_nextChunk", []));return smalltalk.send(chunk, "_isEmpty", []);})()) {(function(){return smalltalk.send(self, "_compileMethod_", [chunk]);})()}})();
  826. smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_setupClass_", [self['@class']]);
  827. return self;},
  828. args: ["aChunkParser"],
  829. source: "scanFrom: aChunkParser\x0a\x09| chunk |\x0a\x09[chunk := aChunkParser nextChunk.\x0a\x09chunk isEmpty] whileFalse: [\x0a\x09 self compileMethod: chunk].\x0a\x09Compiler new setupClass: class",
  830. messageSends: ["whileFalse:", "nextChunk", "isEmpty", "compileMethod:", "setupClass:", "new"],
  831. referencedClasses: ["Compiler"]
  832. }),
  833. smalltalk.ClassCategoryReader);
  834. smalltalk.addClass('ClassCommentReader', smalltalk.Object, ['class', 'chunkParser'], 'Kernel-Classes');
  835. smalltalk.ClassCommentReader.comment="ClassCommentReader represents a mechanism for retrieving class descriptions stored on a file.\x0aSee `ClassCategoryReader` too."
  836. smalltalk.addMethod(
  837. "_class_",
  838. smalltalk.method({
  839. selector: "class:",
  840. category: 'accessing',
  841. fn: function (aClass){
  842. var self=this;
  843. (self['@class']=aClass);
  844. return self;},
  845. args: ["aClass"],
  846. source: "class: aClass\x0a\x09class := aClass",
  847. messageSends: [],
  848. referencedClasses: []
  849. }),
  850. smalltalk.ClassCommentReader);
  851. smalltalk.addMethod(
  852. "_initialize",
  853. smalltalk.method({
  854. selector: "initialize",
  855. category: 'initialization',
  856. fn: function (){
  857. var self=this;
  858. smalltalk.send(self, "_initialize", [], smalltalk.ClassCommentReader.superclass || nil);
  859. (self['@chunkParser']=smalltalk.send((smalltalk.ChunkParser || ChunkParser), "_new", []));
  860. return self;},
  861. args: [],
  862. source: "initialize\x0a\x09super initialize.\x0a\x09chunkParser := ChunkParser new.",
  863. messageSends: ["initialize", "new"],
  864. referencedClasses: ["ChunkParser"]
  865. }),
  866. smalltalk.ClassCommentReader);
  867. smalltalk.addMethod(
  868. "_scanFrom_",
  869. smalltalk.method({
  870. selector: "scanFrom:",
  871. category: 'fileIn',
  872. fn: function (aChunkParser){
  873. var self=this;
  874. var chunk=nil;
  875. (chunk=smalltalk.send(aChunkParser, "_nextChunk", []));
  876. ((($receiver = smalltalk.send(chunk, "_isEmpty", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self, "_setComment_", [chunk]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self, "_setComment_", [chunk]);})]));
  877. return self;},
  878. args: ["aChunkParser"],
  879. source: "scanFrom: aChunkParser\x0a\x09| chunk |\x0a\x09chunk := aChunkParser nextChunk.\x0a\x09chunk isEmpty ifFalse: [\x0a\x09 self setComment: chunk].",
  880. messageSends: ["nextChunk", "ifFalse:", "isEmpty", "setComment:"],
  881. referencedClasses: []
  882. }),
  883. smalltalk.ClassCommentReader);
  884. smalltalk.addMethod(
  885. "_setComment_",
  886. smalltalk.method({
  887. selector: "setComment:",
  888. category: 'private',
  889. fn: function (aString){
  890. var self=this;
  891. smalltalk.send(self['@class'], "_comment_", [aString]);
  892. return self;},
  893. args: ["aString"],
  894. source: "setComment: aString\x0a class comment: aString",
  895. messageSends: ["comment:"],
  896. referencedClasses: []
  897. }),
  898. smalltalk.ClassCommentReader);
  899. smalltalk.addClass('ClassSorterNode', smalltalk.Object, ['theClass', 'level', 'nodes'], 'Kernel-Classes');
  900. smalltalk.addMethod(
  901. "_getNodesFrom_",
  902. smalltalk.method({
  903. selector: "getNodesFrom:",
  904. category: 'accessing',
  905. fn: function (aCollection){
  906. var self=this;
  907. var children=nil;
  908. var others=nil;
  909. (children=[]);
  910. (others=[]);
  911. smalltalk.send(aCollection, "_do_", [(function(each){return ((($receiver = smalltalk.send(smalltalk.send(each, "_superclass", []), "__eq", [smalltalk.send(self, "_theClass", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(children, "_add_", [each]);})() : (function(){return smalltalk.send(others, "_add_", [each]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(children, "_add_", [each]);}), (function(){return smalltalk.send(others, "_add_", [each]);})]));})]);
  912. (self['@nodes']=smalltalk.send(children, "_collect_", [(function(each){return smalltalk.send((smalltalk.ClassSorterNode || ClassSorterNode), "_on_classes_level_", [each, others, ((($receiver = smalltalk.send(self, "_level", [])).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]))]);})]));
  913. return self;},
  914. args: ["aCollection"],
  915. source: "getNodesFrom: aCollection\x0a\x09| children others |\x0a\x09children := #().\x0a\x09others := #().\x0a\x09aCollection do: [:each |\x0a\x09\x09(each superclass = self theClass)\x0a\x09\x09\x09ifTrue: [children add: each]\x0a\x09\x09\x09ifFalse: [others add: each]].\x0a\x09nodes:= children collect: [:each |\x0a\x09\x09ClassSorterNode on: each classes: others level: self level + 1]",
  916. messageSends: ["do:", "ifTrue:ifFalse:", "=", "superclass", "theClass", "add:", "collect:", "on:classes:level:", "+", "level"],
  917. referencedClasses: ["ClassSorterNode"]
  918. }),
  919. smalltalk.ClassSorterNode);
  920. smalltalk.addMethod(
  921. "_level",
  922. smalltalk.method({
  923. selector: "level",
  924. category: 'accessing',
  925. fn: function (){
  926. var self=this;
  927. return self['@level'];
  928. return self;},
  929. args: [],
  930. source: "level\x0a\x09^level",
  931. messageSends: [],
  932. referencedClasses: []
  933. }),
  934. smalltalk.ClassSorterNode);
  935. smalltalk.addMethod(
  936. "_level_",
  937. smalltalk.method({
  938. selector: "level:",
  939. category: 'accessing',
  940. fn: function (anInteger){
  941. var self=this;
  942. (self['@level']=anInteger);
  943. return self;},
  944. args: ["anInteger"],
  945. source: "level: anInteger\x0a\x09level := anInteger",
  946. messageSends: [],
  947. referencedClasses: []
  948. }),
  949. smalltalk.ClassSorterNode);
  950. smalltalk.addMethod(
  951. "_nodes",
  952. smalltalk.method({
  953. selector: "nodes",
  954. category: 'accessing',
  955. fn: function (){
  956. var self=this;
  957. return self['@nodes'];
  958. return self;},
  959. args: [],
  960. source: "nodes\x0a\x09^nodes",
  961. messageSends: [],
  962. referencedClasses: []
  963. }),
  964. smalltalk.ClassSorterNode);
  965. smalltalk.addMethod(
  966. "_theClass",
  967. smalltalk.method({
  968. selector: "theClass",
  969. category: 'accessing',
  970. fn: function (){
  971. var self=this;
  972. return self['@theClass'];
  973. return self;},
  974. args: [],
  975. source: "theClass\x0a\x09^theClass",
  976. messageSends: [],
  977. referencedClasses: []
  978. }),
  979. smalltalk.ClassSorterNode);
  980. smalltalk.addMethod(
  981. "_theClass_",
  982. smalltalk.method({
  983. selector: "theClass:",
  984. category: 'accessing',
  985. fn: function (aClass){
  986. var self=this;
  987. (self['@theClass']=aClass);
  988. return self;},
  989. args: ["aClass"],
  990. source: "theClass: aClass\x0a\x09theClass := aClass",
  991. messageSends: [],
  992. referencedClasses: []
  993. }),
  994. smalltalk.ClassSorterNode);
  995. smalltalk.addMethod(
  996. "_traverseClassesWith_",
  997. smalltalk.method({
  998. selector: "traverseClassesWith:",
  999. category: 'visiting',
  1000. fn: function (aCollection){
  1001. var self=this;
  1002. smalltalk.send(aCollection, "_add_", [smalltalk.send(self, "_theClass", [])]);
  1003. smalltalk.send(smalltalk.send(smalltalk.send(self, "_nodes", []), "_sorted_", [(function(a, b){return ((($receiver = smalltalk.send(smalltalk.send(a, "_theClass", []), "_name", [])).klass === smalltalk.Number) ? $receiver <=smalltalk.send(smalltalk.send(b, "_theClass", []), "_name", []) : smalltalk.send($receiver, "__lt_eq", [smalltalk.send(smalltalk.send(b, "_theClass", []), "_name", [])]));})]), "_do_", [(function(aNode){return smalltalk.send(aNode, "_traverseClassesWith_", [aCollection]);})]);
  1004. return self;},
  1005. args: ["aCollection"],
  1006. source: "traverseClassesWith: aCollection\x0a\x09\x22sort classes alphabetically Issue #143\x22\x0a\x0a\x09aCollection add: self theClass.\x0a\x09(self nodes sorted: [:a :b | a theClass name <= b theClass name ]) do: [:aNode |\x0a\x09\x09aNode traverseClassesWith: aCollection ].",
  1007. messageSends: ["add:", "theClass", "do:", "sorted:", "nodes", "<=", "name", "traverseClassesWith:"],
  1008. referencedClasses: []
  1009. }),
  1010. smalltalk.ClassSorterNode);
  1011. smalltalk.addMethod(
  1012. "_on_classes_level_",
  1013. smalltalk.method({
  1014. selector: "on:classes:level:",
  1015. category: 'instance creation',
  1016. fn: function (aClass, aCollection, anInteger){
  1017. var self=this;
  1018. return (function($rec){smalltalk.send($rec, "_theClass_", [aClass]);smalltalk.send($rec, "_level_", [anInteger]);smalltalk.send($rec, "_getNodesFrom_", [aCollection]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  1019. return self;},
  1020. args: ["aClass", "aCollection", "anInteger"],
  1021. source: "on: aClass classes: aCollection level: anInteger\x0a\x09^self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09level: anInteger;\x0a\x09\x09getNodesFrom: aCollection;\x0a\x09\x09yourself",
  1022. messageSends: ["theClass:", "level:", "getNodesFrom:", "yourself", "new"],
  1023. referencedClasses: []
  1024. }),
  1025. smalltalk.ClassSorterNode.klass);