Kernel-Classes.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  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. var compiler=nil;
  168. var method=nil;
  169. (compiler=smalltalk.send((smalltalk.Compiler || Compiler), "_new", []));
  170. (method=smalltalk.send(compiler, "_install_forClass_category_", [aString, self, anotherString]));
  171. smalltalk.send(compiler, "_setupClass_", [self]);
  172. return smalltalk.send(method, "_selector", []);
  173. return self;},
  174. args: ["aString", "anotherString"],
  175. source: "compile: aString category: anotherString\x0a\x09| compiler method |\x0a\x09compiler := Compiler new.\x0a\x09method := compiler install: aString forClass: self category: anotherString.\x0a\x09compiler setupClass: self.\x0a\x09^ method selector",
  176. messageSends: ["new", "install:forClass:category:", "setupClass:", "selector"],
  177. referencedClasses: ["Compiler"]
  178. }),
  179. smalltalk.Behavior);
  180. smalltalk.addMethod(
  181. "_inheritsFrom_",
  182. smalltalk.method({
  183. selector: "inheritsFrom:",
  184. category: 'testing',
  185. fn: function (aClass){
  186. var self=this;
  187. return smalltalk.send(smalltalk.send(aClass, "_allSubclasses", []), "_includes_", [self]);
  188. return self;},
  189. args: ["aClass"],
  190. source: "inheritsFrom: aClass\x0a\x09^aClass allSubclasses includes: self",
  191. messageSends: ["includes:", "allSubclasses"],
  192. referencedClasses: []
  193. }),
  194. smalltalk.Behavior);
  195. smalltalk.addMethod(
  196. "_instanceVariableNames",
  197. smalltalk.method({
  198. selector: "instanceVariableNames",
  199. category: 'accessing',
  200. fn: function (){
  201. var self=this;
  202. return self.iVarNames;
  203. return self;},
  204. args: [],
  205. source: "instanceVariableNames\x0a\x09<return self.iVarNames>",
  206. messageSends: [],
  207. referencedClasses: []
  208. }),
  209. smalltalk.Behavior);
  210. smalltalk.addMethod(
  211. "_methodAt_",
  212. smalltalk.method({
  213. selector: "methodAt:",
  214. category: 'accessing',
  215. fn: function (aString){
  216. var self=this;
  217. return smalltalk.methods(self)[aString];
  218. return self;},
  219. args: ["aString"],
  220. source: "methodAt: aString\x0a\x09<return smalltalk.methods(self)[aString]>",
  221. messageSends: [],
  222. referencedClasses: []
  223. }),
  224. smalltalk.Behavior);
  225. smalltalk.addMethod(
  226. "_methodDictionary",
  227. smalltalk.method({
  228. selector: "methodDictionary",
  229. category: 'accessing',
  230. fn: function (){
  231. var self=this;
  232. var dict = smalltalk.HashedCollection._new();
  233. var methods = self.fn.prototype.methods;
  234. for(var i in methods) {
  235. if(methods[i].selector) {
  236. dict._at_put_(methods[i].selector, methods[i]);
  237. }
  238. };
  239. return dict;
  240. return self;},
  241. args: [],
  242. 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>",
  243. messageSends: [],
  244. referencedClasses: []
  245. }),
  246. smalltalk.Behavior);
  247. smalltalk.addMethod(
  248. "_methodsFor_",
  249. smalltalk.method({
  250. selector: "methodsFor:",
  251. category: 'accessing',
  252. fn: function (aString){
  253. var self=this;
  254. return (function($rec){smalltalk.send($rec, "_class_category_", [self, aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.ClassCategoryReader || ClassCategoryReader), "_new", []));
  255. return self;},
  256. args: ["aString"],
  257. source: "methodsFor: aString\x0a\x09^ClassCategoryReader new\x0a\x09 class: self category: aString;\x0a\x09 yourself",
  258. messageSends: ["class:category:", "yourself", "new"],
  259. referencedClasses: ["ClassCategoryReader"]
  260. }),
  261. smalltalk.Behavior);
  262. smalltalk.addMethod(
  263. "_methodsFor_stamp_",
  264. smalltalk.method({
  265. selector: "methodsFor:stamp:",
  266. category: 'accessing',
  267. fn: function (aString, aStamp){
  268. var self=this;
  269. return smalltalk.send(self, "_methodsFor_", [aString]);
  270. return self;},
  271. args: ["aString", "aStamp"],
  272. source: "methodsFor: aString stamp: aStamp\x0a\x09\x22Added for compatibility, right now ignores stamp.\x22\x0a\x09^self methodsFor: aString",
  273. messageSends: ["methodsFor:"],
  274. referencedClasses: []
  275. }),
  276. smalltalk.Behavior);
  277. smalltalk.addMethod(
  278. "_name",
  279. smalltalk.method({
  280. selector: "name",
  281. category: 'accessing',
  282. fn: function (){
  283. var self=this;
  284. return self.className || nil;
  285. return self;},
  286. args: [],
  287. source: "name\x0a\x09<return self.className || nil>",
  288. messageSends: [],
  289. referencedClasses: []
  290. }),
  291. smalltalk.Behavior);
  292. smalltalk.addMethod(
  293. "_new",
  294. smalltalk.method({
  295. selector: "new",
  296. category: 'instance creation',
  297. fn: function (){
  298. var self=this;
  299. return smalltalk.send(smalltalk.send(self, "_basicNew", []), "_initialize", []);
  300. return self;},
  301. args: [],
  302. source: "new\x0a\x09^self basicNew initialize",
  303. messageSends: ["initialize", "basicNew"],
  304. referencedClasses: []
  305. }),
  306. smalltalk.Behavior);
  307. smalltalk.addMethod(
  308. "_protocols",
  309. smalltalk.method({
  310. selector: "protocols",
  311. category: 'accessing',
  312. fn: function (){
  313. var self=this;
  314. var protocols=nil;
  315. (protocols=smalltalk.send((smalltalk.Array || Array), "_new", []));
  316. 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", [])]);})]));})]);
  317. return smalltalk.send(protocols, "_sort", []);
  318. return self;},
  319. args: [],
  320. 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",
  321. messageSends: ["new", "do:", "methodDictionary", "ifFalse:", "includes:", "category", "add:", "sort"],
  322. referencedClasses: ["Array"]
  323. }),
  324. smalltalk.Behavior);
  325. smalltalk.addMethod(
  326. "_protocolsDo_",
  327. smalltalk.method({
  328. selector: "protocolsDo:",
  329. category: 'accessing',
  330. fn: function (aBlock){
  331. var self=this;
  332. var methodsByCategory=nil;
  333. (methodsByCategory=smalltalk.send((smalltalk.HashedCollection || HashedCollection), "_new", []));
  334. 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]);})]);
  335. smalltalk.send(smalltalk.send(self, "_protocols", []), "_do_", [(function(category){return smalltalk.send(aBlock, "_value_value_", [category, smalltalk.send(methodsByCategory, "_at_", [category])]);})]);
  336. return self;},
  337. args: ["aBlock"],
  338. 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)]",
  339. messageSends: ["new", "do:", "values", "methodDictionary", "add:", "at:ifAbsentPut:", "category", "protocols", "value:value:", "at:"],
  340. referencedClasses: ["HashedCollection", "Array"]
  341. }),
  342. smalltalk.Behavior);
  343. smalltalk.addMethod(
  344. "_prototype",
  345. smalltalk.method({
  346. selector: "prototype",
  347. category: 'accessing',
  348. fn: function (){
  349. var self=this;
  350. return self.fn.prototype;
  351. return self;},
  352. args: [],
  353. source: "prototype\x0a\x09<return self.fn.prototype>",
  354. messageSends: [],
  355. referencedClasses: []
  356. }),
  357. smalltalk.Behavior);
  358. smalltalk.addMethod(
  359. "_removeCompiledMethod_",
  360. smalltalk.method({
  361. selector: "removeCompiledMethod:",
  362. category: 'compiling',
  363. fn: function (aMethod){
  364. var self=this;
  365. delete self.fn.prototype[aMethod.selector._asSelector()];
  366. delete self.fn.prototype.methods[aMethod.selector];
  367. smalltalk.init(self);;
  368. return self;},
  369. args: ["aMethod"],
  370. source: "removeCompiledMethod: aMethod\x0a\x09<delete self.fn.prototype[aMethod.selector._asSelector()];\x0a\x09delete self.fn.prototype.methods[aMethod.selector];\x0a\x09smalltalk.init(self);>",
  371. messageSends: [],
  372. referencedClasses: []
  373. }),
  374. smalltalk.Behavior);
  375. smalltalk.addMethod(
  376. "_removeSelector_",
  377. smalltalk.method({
  378. selector: "removeSelector:",
  379. category: 'compiling',
  380. fn: function (aString){
  381. var self=this;
  382. smalltalk.send(self, "_removeCompiledMethod_", [smalltalk.send(self, "_methodAt_", [aString])]);
  383. return self;},
  384. args: ["aString"],
  385. source: "removeSelector: aString\x0a\x09self removeCompiledMethod: (self methodAt: aString)",
  386. messageSends: ["removeCompiledMethod:", "methodAt:"],
  387. referencedClasses: []
  388. }),
  389. smalltalk.Behavior);
  390. smalltalk.addMethod(
  391. "_subclasses",
  392. smalltalk.method({
  393. selector: "subclasses",
  394. category: 'accessing',
  395. fn: function (){
  396. var self=this;
  397. return smalltalk.subclasses(self);
  398. return self;},
  399. args: [],
  400. source: "subclasses\x0a\x09<return smalltalk.subclasses(self)>",
  401. messageSends: [],
  402. referencedClasses: []
  403. }),
  404. smalltalk.Behavior);
  405. smalltalk.addMethod(
  406. "_superclass",
  407. smalltalk.method({
  408. selector: "superclass",
  409. category: 'accessing',
  410. fn: function (){
  411. var self=this;
  412. return self.superclass || nil;
  413. return self;},
  414. args: [],
  415. source: "superclass\x0a\x09<return self.superclass || nil>",
  416. messageSends: [],
  417. referencedClasses: []
  418. }),
  419. smalltalk.Behavior);
  420. smalltalk.addMethod(
  421. "_withAllSubclasses",
  422. smalltalk.method({
  423. selector: "withAllSubclasses",
  424. category: 'accessing',
  425. fn: function (){
  426. var self=this;
  427. return (function($rec){smalltalk.send($rec, "_addAll_", [smalltalk.send(self, "_allSubclasses", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Array || Array), "_with_", [self]));
  428. return self;},
  429. args: [],
  430. source: "withAllSubclasses\x0a\x09^(Array with: self) addAll: self allSubclasses; yourself",
  431. messageSends: ["addAll:", "allSubclasses", "yourself", "with:"],
  432. referencedClasses: ["Array"]
  433. }),
  434. smalltalk.Behavior);
  435. smalltalk.addClass('Class', smalltalk.Behavior, [], 'Kernel-Classes');
  436. smalltalk.Class.comment="Class is __the__ class object. \x0a\x0aInstances are the classes of the system.\x0aClass creation is done throught a `ClassBuilder`"
  437. smalltalk.addMethod(
  438. "_category",
  439. smalltalk.method({
  440. selector: "category",
  441. category: 'accessing',
  442. fn: function (){
  443. var self=this;
  444. return (($receiver = smalltalk.send(self, "_package", [])) == nil || $receiver == undefined) ? (function(){return "Unclassified";})() : (function(){return smalltalk.send(smalltalk.send(self, "_package", []), "_name", []);})();
  445. return self;},
  446. args: [],
  447. source: "category\x0a\x09^self package ifNil: ['Unclassified'] ifNotNil: [self package name]",
  448. messageSends: ["ifNil:ifNotNil:", "package", "name"],
  449. referencedClasses: []
  450. }),
  451. smalltalk.Class);
  452. smalltalk.addMethod(
  453. "_definition",
  454. smalltalk.method({
  455. selector: "definition",
  456. category: 'accessing',
  457. fn: function (){
  458. var self=this;
  459. var stream=nil;
  460. (stream=smalltalk.send("", "_writeStream", []));
  461. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_asString", [])]);smalltalk.send($rec, "_nextPutAll_", [" subclass: #"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send((smalltalk.String || String), "_lf", []), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);return smalltalk.send($rec, "_nextPutAll_", ["instanceVariableNames: '"]);})(stream);
  462. smalltalk.send(smalltalk.send(self, "_instanceVariableNames", []), "_do_separatedBy_", [(function(each){return smalltalk.send(stream, "_nextPutAll_", [each]);}), (function(){return smalltalk.send(stream, "_nextPutAll_", [" "]);})]);
  463. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("'", "__comma", [smalltalk.send((smalltalk.String || String), "_lf", [])]), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);smalltalk.send($rec, "_nextPutAll_", ["package: '"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_category", [])]);return smalltalk.send($rec, "_nextPutAll_", ["'"]);})(stream);
  464. return smalltalk.send(stream, "_contents", []);
  465. return self;},
  466. args: [],
  467. source: "definition\x0a\x09| stream |\x0a\x09stream := '' writeStream.\x0a\x09stream \x0a\x09 nextPutAll: self superclass asString;\x0a\x09 nextPutAll: ' subclass: #';\x0a\x09 nextPutAll: self name;\x0a\x09 nextPutAll: String lf, String tab;\x0a\x09 nextPutAll: 'instanceVariableNames: '''.\x0a\x09self instanceVariableNames \x0a\x09 do: [:each | stream nextPutAll: each] \x0a\x09 separatedBy: [stream nextPutAll: ' '].\x0a\x09stream\x0a\x09 nextPutAll: '''', String lf, String tab;\x0a\x09 nextPutAll: 'package: ''';\x0a\x09 nextPutAll: self category;\x0a\x09 nextPutAll: ''''.\x0a\x09^stream contents",
  468. messageSends: ["writeStream", "nextPutAll:", "asString", "superclass", "name", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "contents"],
  469. referencedClasses: ["String"]
  470. }),
  471. smalltalk.Class);
  472. smalltalk.addMethod(
  473. "_isClass",
  474. smalltalk.method({
  475. selector: "isClass",
  476. category: 'testing',
  477. fn: function (){
  478. var self=this;
  479. return true;
  480. return self;},
  481. args: [],
  482. source: "isClass\x0a\x09^true",
  483. messageSends: [],
  484. referencedClasses: []
  485. }),
  486. smalltalk.Class);
  487. smalltalk.addMethod(
  488. "_package",
  489. smalltalk.method({
  490. selector: "package",
  491. category: 'accessing',
  492. fn: function (){
  493. var self=this;
  494. return self.pkg;
  495. return self;},
  496. args: [],
  497. source: "package\x0a\x09<return self.pkg>",
  498. messageSends: [],
  499. referencedClasses: []
  500. }),
  501. smalltalk.Class);
  502. smalltalk.addMethod(
  503. "_package_",
  504. smalltalk.method({
  505. selector: "package:",
  506. category: 'accessing',
  507. fn: function (aPackage){
  508. var self=this;
  509. self.pkg = aPackage;
  510. return self;},
  511. args: ["aPackage"],
  512. source: "package: aPackage\x0a\x09<self.pkg = aPackage>",
  513. messageSends: [],
  514. referencedClasses: []
  515. }),
  516. smalltalk.Class);
  517. smalltalk.addMethod(
  518. "_printString",
  519. smalltalk.method({
  520. selector: "printString",
  521. category: 'printing',
  522. fn: function (){
  523. var self=this;
  524. return smalltalk.send(self, "_name", []);
  525. return self;},
  526. args: [],
  527. source: "printString\x0a\x09^self name",
  528. messageSends: ["name"],
  529. referencedClasses: []
  530. }),
  531. smalltalk.Class);
  532. smalltalk.addMethod(
  533. "_rename_",
  534. smalltalk.method({
  535. selector: "rename:",
  536. category: 'accessing',
  537. fn: function (aString){
  538. var self=this;
  539. smalltalk[aString] = self;
  540. delete smalltalk[self.className];
  541. self.className = aString;
  542. ;
  543. return self;},
  544. args: ["aString"],
  545. source: "rename: aString\x0a\x09<\x0a\x09\x09smalltalk[aString] = self;\x0a\x09\x09delete smalltalk[self.className];\x0a\x09\x09self.className = aString;\x0a\x09>",
  546. messageSends: [],
  547. referencedClasses: []
  548. }),
  549. smalltalk.Class);
  550. smalltalk.addMethod(
  551. "_subclass_instanceVariableNames_",
  552. smalltalk.method({
  553. selector: "subclass:instanceVariableNames:",
  554. category: 'class creation',
  555. fn: function (aString, anotherString){
  556. var self=this;
  557. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, anotherString, nil]);
  558. return self;},
  559. args: ["aString", "anotherString"],
  560. source: "subclass: aString instanceVariableNames: anotherString\x0a\x09\x22Kept for compatibility.\x22\x0a\x09^self subclass: aString instanceVariableNames: anotherString package: nil",
  561. messageSends: ["subclass:instanceVariableNames:package:"],
  562. referencedClasses: []
  563. }),
  564. smalltalk.Class);
  565. smalltalk.addMethod(
  566. "_subclass_instanceVariableNames_category_",
  567. smalltalk.method({
  568. selector: "subclass:instanceVariableNames:category:",
  569. category: 'class creation',
  570. fn: function (aString, aString2, aString3){
  571. var self=this;
  572. smalltalk.send(self, "_deprecatedAPI", []);
  573. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
  574. return self;},
  575. args: ["aString", "aString2", "aString3"],
  576. 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",
  577. messageSends: ["deprecatedAPI", "subclass:instanceVariableNames:package:"],
  578. referencedClasses: []
  579. }),
  580. smalltalk.Class);
  581. smalltalk.addMethod(
  582. "_subclass_instanceVariableNames_classVariableNames_poolDictionaries_category_",
  583. smalltalk.method({
  584. selector: "subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:",
  585. category: 'class creation',
  586. fn: function (aString, aString2, classVars, pools, aString3){
  587. var self=this;
  588. return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
  589. return self;},
  590. args: ["aString", "aString2", "classVars", "pools", "aString3"],
  591. 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",
  592. messageSends: ["subclass:instanceVariableNames:package:"],
  593. referencedClasses: []
  594. }),
  595. smalltalk.Class);
  596. smalltalk.addMethod(
  597. "_subclass_instanceVariableNames_package_",
  598. smalltalk.method({
  599. selector: "subclass:instanceVariableNames:package:",
  600. category: 'class creation',
  601. fn: function (aString, aString2, aString3){
  602. var self=this;
  603. return smalltalk.send(smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []), "_superclass_subclass_instanceVariableNames_package_", [self, smalltalk.send(aString, "_asString", []), aString2, aString3]);
  604. return self;},
  605. args: ["aString", "aString2", "aString3"],
  606. source: "subclass: aString instanceVariableNames: aString2 package: aString3\x0a\x09^ClassBuilder new\x0a\x09 superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3",
  607. messageSends: ["superclass:subclass:instanceVariableNames:package:", "new", "asString"],
  608. referencedClasses: ["ClassBuilder"]
  609. }),
  610. smalltalk.Class);
  611. smalltalk.addClass('Metaclass', smalltalk.Behavior, [], 'Kernel-Classes');
  612. 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."
  613. smalltalk.addMethod(
  614. "_definition",
  615. smalltalk.method({
  616. selector: "definition",
  617. category: 'accessing',
  618. fn: function (){
  619. var self=this;
  620. var stream=nil;
  621. (stream=smalltalk.send("", "_writeStream", []));
  622. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_asString", [])]);return smalltalk.send($rec, "_nextPutAll_", [" instanceVariableNames: '"]);})(stream);
  623. smalltalk.send(smalltalk.send(self, "_instanceVariableNames", []), "_do_separatedBy_", [(function(each){return smalltalk.send(stream, "_nextPutAll_", [each]);}), (function(){return smalltalk.send(stream, "_nextPutAll_", [" "]);})]);
  624. smalltalk.send(stream, "_nextPutAll_", ["'"]);
  625. return smalltalk.send(stream, "_contents", []);
  626. return self;},
  627. args: [],
  628. source: "definition\x0a\x09 | stream |\x0a\x09stream := '' writeStream.\x0a\x09stream \x0a\x09 nextPutAll: self asString;\x0a\x09 nextPutAll: ' instanceVariableNames: '''.\x0a\x09self instanceVariableNames\x0a\x09 do: [:each | stream nextPutAll: each]\x0a\x09 separatedBy: [stream nextPutAll: ' '].\x0a\x09stream nextPutAll: ''''.\x0a ^stream contents",
  629. messageSends: ["writeStream", "nextPutAll:", "asString", "do:separatedBy:", "instanceVariableNames", "contents"],
  630. referencedClasses: []
  631. }),
  632. smalltalk.Metaclass);
  633. smalltalk.addMethod(
  634. "_instanceClass",
  635. smalltalk.method({
  636. selector: "instanceClass",
  637. category: 'accessing',
  638. fn: function (){
  639. var self=this;
  640. return self.instanceClass;
  641. return self;},
  642. args: [],
  643. source: "instanceClass\x0a\x09<return self.instanceClass>",
  644. messageSends: [],
  645. referencedClasses: []
  646. }),
  647. smalltalk.Metaclass);
  648. smalltalk.addMethod(
  649. "_instanceVariableNames_",
  650. smalltalk.method({
  651. selector: "instanceVariableNames:",
  652. category: 'accessing',
  653. fn: function (aCollection){
  654. var self=this;
  655. smalltalk.send(smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []), "_class_instanceVariableNames_", [self, aCollection]);
  656. return self;},
  657. args: ["aCollection"],
  658. source: "instanceVariableNames: aCollection\x0a\x09ClassBuilder new\x0a\x09 class: self instanceVariableNames: aCollection",
  659. messageSends: ["class:instanceVariableNames:", "new"],
  660. referencedClasses: ["ClassBuilder"]
  661. }),
  662. smalltalk.Metaclass);
  663. smalltalk.addMethod(
  664. "_isMetaclass",
  665. smalltalk.method({
  666. selector: "isMetaclass",
  667. category: 'testing',
  668. fn: function (){
  669. var self=this;
  670. return true;
  671. return self;},
  672. args: [],
  673. source: "isMetaclass\x0a\x09^true",
  674. messageSends: [],
  675. referencedClasses: []
  676. }),
  677. smalltalk.Metaclass);
  678. smalltalk.addMethod(
  679. "_printString",
  680. smalltalk.method({
  681. selector: "printString",
  682. category: 'printing',
  683. fn: function (){
  684. var self=this;
  685. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_instanceClass", []), "_name", []), "__comma", [" class"]);
  686. return self;},
  687. args: [],
  688. source: "printString\x0a\x09^self instanceClass name, ' class'",
  689. messageSends: [",", "name", "instanceClass"],
  690. referencedClasses: []
  691. }),
  692. smalltalk.Metaclass);
  693. smalltalk.addClass('ClassBuilder', smalltalk.Object, [], 'Kernel-Classes');
  694. 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:`."
  695. smalltalk.addMethod(
  696. "_addSubclassOf_named_instanceVariableNames_",
  697. smalltalk.method({
  698. selector: "addSubclassOf:named:instanceVariableNames:",
  699. category: 'private',
  700. fn: function (aClass, aString, aCollection){
  701. var self=this;
  702. smalltalk.addClass(aString, aClass, aCollection);
  703. return smalltalk[aString];
  704. return self;},
  705. args: ["aClass", "aString", "aCollection"],
  706. source: "addSubclassOf: aClass named: aString instanceVariableNames: aCollection\x0a\x09<smalltalk.addClass(aString, aClass, aCollection);\x0a\x09 return smalltalk[aString]>",
  707. messageSends: [],
  708. referencedClasses: []
  709. }),
  710. smalltalk.ClassBuilder);
  711. smalltalk.addMethod(
  712. "_addSubclassOf_named_instanceVariableNames_package_",
  713. smalltalk.method({
  714. selector: "addSubclassOf:named:instanceVariableNames:package:",
  715. category: 'private',
  716. fn: function (aClass, aString, aCollection, packageName){
  717. var self=this;
  718. smalltalk.addClass(aString, aClass, aCollection, packageName);
  719. return smalltalk[aString];
  720. return self;},
  721. args: ["aClass", "aString", "aCollection", "packageName"],
  722. source: "addSubclassOf: aClass named: aString instanceVariableNames: aCollection package: packageName\x0a\x09<smalltalk.addClass(aString, aClass, aCollection, packageName);\x0a\x09 return smalltalk[aString]>",
  723. messageSends: [],
  724. referencedClasses: []
  725. }),
  726. smalltalk.ClassBuilder);
  727. smalltalk.addMethod(
  728. "_class_instanceVariableNames_",
  729. smalltalk.method({
  730. selector: "class:instanceVariableNames:",
  731. category: 'class creation',
  732. fn: function (aClass, aString){
  733. var self=this;
  734. ((($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"])]);})]));
  735. smalltalk.send(aClass, "_basicAt_put_", ["iVarNames", smalltalk.send(self, "_instanceVariableNamesFor_", [aString])]);
  736. smalltalk.send(self, "_setupClass_", [aClass]);
  737. return self;},
  738. args: ["aClass", "aString"],
  739. 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",
  740. messageSends: ["ifFalse:", "isMetaclass", "error:", ",", "name", "basicAt:put:", "instanceVariableNamesFor:", "setupClass:"],
  741. referencedClasses: []
  742. }),
  743. smalltalk.ClassBuilder);
  744. smalltalk.addMethod(
  745. "_copyClass_named_",
  746. smalltalk.method({
  747. selector: "copyClass:named:",
  748. category: 'private',
  749. fn: function (aClass, aString){
  750. var self=this;
  751. var newClass=nil;
  752. (newClass=smalltalk.send(self, "_addSubclassOf_named_instanceVariableNames_package_", [smalltalk.send(aClass, "_superclass", []), aString, smalltalk.send(aClass, "_instanceVariableNames", []), smalltalk.send(smalltalk.send(aClass, "_package", []), "_name", [])]));
  753. smalltalk.send(self, "_setupClass_", [newClass]);
  754. 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", [])]);})]);
  755. 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", [])]);})]);
  756. smalltalk.send(self, "_setupClass_", [newClass]);
  757. return newClass;
  758. return self;},
  759. args: ["aClass", "aString"],
  760. 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",
  761. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "superclass", "instanceVariableNames", "name", "package", "setupClass:", "do:", "values", "methodDictionary", "install:forClass:category:", "new", "source", "category", "class"],
  762. referencedClasses: ["Compiler"]
  763. }),
  764. smalltalk.ClassBuilder);
  765. smalltalk.addMethod(
  766. "_instanceVariableNamesFor_",
  767. smalltalk.method({
  768. selector: "instanceVariableNamesFor:",
  769. category: 'private',
  770. fn: function (aString){
  771. var self=this;
  772. return smalltalk.send(smalltalk.send(aString, "_tokenize_", [" "]), "_reject_", [(function(each){return smalltalk.send(each, "_isEmpty", []);})]);
  773. return self;},
  774. args: ["aString"],
  775. source: "instanceVariableNamesFor: aString\x0a\x09^(aString tokenize: ' ') reject: [:each | each isEmpty]",
  776. messageSends: ["reject:", "tokenize:", "isEmpty"],
  777. referencedClasses: []
  778. }),
  779. smalltalk.ClassBuilder);
  780. smalltalk.addMethod(
  781. "_setupClass_",
  782. smalltalk.method({
  783. selector: "setupClass:",
  784. category: 'private',
  785. fn: function (aClass){
  786. var self=this;
  787. smalltalk.init(aClass);;
  788. return self;},
  789. args: ["aClass"],
  790. source: "setupClass: aClass\x0a\x09<smalltalk.init(aClass);>",
  791. messageSends: [],
  792. referencedClasses: []
  793. }),
  794. smalltalk.ClassBuilder);
  795. smalltalk.addMethod(
  796. "_superclass_subclass_",
  797. smalltalk.method({
  798. selector: "superclass:subclass:",
  799. category: 'class creation',
  800. fn: function (aClass, aString){
  801. var self=this;
  802. return smalltalk.send(self, "_superclass_subclass_instanceVariableNames_package_", [aClass, aString, "", nil]);
  803. return self;},
  804. args: ["aClass", "aString"],
  805. source: "superclass: aClass subclass: aString\x0a\x09^self superclass: aClass subclass: aString instanceVariableNames: '' package: nil",
  806. messageSends: ["superclass:subclass:instanceVariableNames:package:"],
  807. referencedClasses: []
  808. }),
  809. smalltalk.ClassBuilder);
  810. smalltalk.addMethod(
  811. "_superclass_subclass_instanceVariableNames_package_",
  812. smalltalk.method({
  813. selector: "superclass:subclass:instanceVariableNames:package:",
  814. category: 'class creation',
  815. fn: function (aClass, aString, aString2, aString3){
  816. var self=this;
  817. var newClass=nil;
  818. (newClass=smalltalk.send(self, "_addSubclassOf_named_instanceVariableNames_package_", [aClass, aString, smalltalk.send(self, "_instanceVariableNamesFor_", [aString2]), (($receiver = aString3) == nil || $receiver == undefined) ? (function(){return "unclassified";})() : $receiver]));
  819. smalltalk.send(self, "_setupClass_", [newClass]);
  820. return newClass;
  821. return self;},
  822. args: ["aClass", "aString", "aString2", "aString3"],
  823. 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",
  824. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "instanceVariableNamesFor:", "ifNil:", "setupClass:"],
  825. referencedClasses: []
  826. }),
  827. smalltalk.ClassBuilder);
  828. smalltalk.addClass('ClassCategoryReader', smalltalk.Object, ['class', 'category', 'chunkParser'], 'Kernel-Classes');
  829. smalltalk.ClassCategoryReader.comment="ClassCategoryReader represents a mechanism for retrieving class descriptions stored on a file."
  830. smalltalk.addMethod(
  831. "_class_category_",
  832. smalltalk.method({
  833. selector: "class:category:",
  834. category: 'accessing',
  835. fn: function (aClass, aString){
  836. var self=this;
  837. (self['@class']=aClass);
  838. (self['@category']=aString);
  839. return self;},
  840. args: ["aClass", "aString"],
  841. source: "class: aClass category: aString\x0a\x09class := aClass.\x0a\x09category := aString",
  842. messageSends: [],
  843. referencedClasses: []
  844. }),
  845. smalltalk.ClassCategoryReader);
  846. smalltalk.addMethod(
  847. "_compileMethod_",
  848. smalltalk.method({
  849. selector: "compileMethod:",
  850. category: 'private',
  851. fn: function (aString){
  852. var self=this;
  853. smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_install_forClass_category_", [aString, self['@class'], self['@category']]);
  854. return self;},
  855. args: ["aString"],
  856. source: "compileMethod: aString\x0a\x09Compiler new install: aString forClass: class category: category",
  857. messageSends: ["install:forClass:category:", "new"],
  858. referencedClasses: ["Compiler"]
  859. }),
  860. smalltalk.ClassCategoryReader);
  861. smalltalk.addMethod(
  862. "_initialize",
  863. smalltalk.method({
  864. selector: "initialize",
  865. category: 'initialization',
  866. fn: function (){
  867. var self=this;
  868. smalltalk.send(self, "_initialize", [], smalltalk.ClassCategoryReader.superclass || nil);
  869. (self['@chunkParser']=smalltalk.send((smalltalk.ChunkParser || ChunkParser), "_new", []));
  870. return self;},
  871. args: [],
  872. source: "initialize\x0a\x09super initialize.\x0a\x09chunkParser := ChunkParser new.",
  873. messageSends: ["initialize", "new"],
  874. referencedClasses: ["ChunkParser"]
  875. }),
  876. smalltalk.ClassCategoryReader);
  877. smalltalk.addMethod(
  878. "_scanFrom_",
  879. smalltalk.method({
  880. selector: "scanFrom:",
  881. category: 'fileIn',
  882. fn: function (aChunkParser){
  883. var self=this;
  884. var chunk=nil;
  885. (function(){while(!(function(){(chunk=smalltalk.send(aChunkParser, "_nextChunk", []));return smalltalk.send(chunk, "_isEmpty", []);})()) {(function(){return smalltalk.send(self, "_compileMethod_", [chunk]);})()}})();
  886. smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_setupClass_", [self['@class']]);
  887. return self;},
  888. args: ["aChunkParser"],
  889. 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",
  890. messageSends: ["whileFalse:", "nextChunk", "isEmpty", "compileMethod:", "setupClass:", "new"],
  891. referencedClasses: ["Compiler"]
  892. }),
  893. smalltalk.ClassCategoryReader);
  894. smalltalk.addClass('ClassCommentReader', smalltalk.Object, ['class', 'chunkParser'], 'Kernel-Classes');
  895. smalltalk.ClassCommentReader.comment="ClassCommentReader represents a mechanism for retrieving class descriptions stored on a file.\x0aSee `ClassCategoryReader` too."
  896. smalltalk.addMethod(
  897. "_class_",
  898. smalltalk.method({
  899. selector: "class:",
  900. category: 'accessing',
  901. fn: function (aClass){
  902. var self=this;
  903. (self['@class']=aClass);
  904. return self;},
  905. args: ["aClass"],
  906. source: "class: aClass\x0a\x09class := aClass",
  907. messageSends: [],
  908. referencedClasses: []
  909. }),
  910. smalltalk.ClassCommentReader);
  911. smalltalk.addMethod(
  912. "_initialize",
  913. smalltalk.method({
  914. selector: "initialize",
  915. category: 'initialization',
  916. fn: function (){
  917. var self=this;
  918. smalltalk.send(self, "_initialize", [], smalltalk.ClassCommentReader.superclass || nil);
  919. (self['@chunkParser']=smalltalk.send((smalltalk.ChunkParser || ChunkParser), "_new", []));
  920. return self;},
  921. args: [],
  922. source: "initialize\x0a\x09super initialize.\x0a\x09chunkParser := ChunkParser new.",
  923. messageSends: ["initialize", "new"],
  924. referencedClasses: ["ChunkParser"]
  925. }),
  926. smalltalk.ClassCommentReader);
  927. smalltalk.addMethod(
  928. "_scanFrom_",
  929. smalltalk.method({
  930. selector: "scanFrom:",
  931. category: 'fileIn',
  932. fn: function (aChunkParser){
  933. var self=this;
  934. var chunk=nil;
  935. (chunk=smalltalk.send(aChunkParser, "_nextChunk", []));
  936. ((($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]);})]));
  937. return self;},
  938. args: ["aChunkParser"],
  939. source: "scanFrom: aChunkParser\x0a\x09| chunk |\x0a\x09chunk := aChunkParser nextChunk.\x0a\x09chunk isEmpty ifFalse: [\x0a\x09 self setComment: chunk].",
  940. messageSends: ["nextChunk", "ifFalse:", "isEmpty", "setComment:"],
  941. referencedClasses: []
  942. }),
  943. smalltalk.ClassCommentReader);
  944. smalltalk.addMethod(
  945. "_setComment_",
  946. smalltalk.method({
  947. selector: "setComment:",
  948. category: 'private',
  949. fn: function (aString){
  950. var self=this;
  951. smalltalk.send(self['@class'], "_comment_", [aString]);
  952. return self;},
  953. args: ["aString"],
  954. source: "setComment: aString\x0a class comment: aString",
  955. messageSends: ["comment:"],
  956. referencedClasses: []
  957. }),
  958. smalltalk.ClassCommentReader);
  959. smalltalk.addClass('ClassSorterNode', smalltalk.Object, ['theClass', 'level', 'nodes'], 'Kernel-Classes');
  960. smalltalk.addMethod(
  961. "_getNodesFrom_",
  962. smalltalk.method({
  963. selector: "getNodesFrom:",
  964. category: 'accessing',
  965. fn: function (aCollection){
  966. var self=this;
  967. var children=nil;
  968. var others=nil;
  969. (children=[]);
  970. (others=[]);
  971. 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]);})]));})]);
  972. (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)]))]);})]));
  973. return self;},
  974. args: ["aCollection"],
  975. 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]",
  976. messageSends: ["do:", "ifTrue:ifFalse:", "=", "superclass", "theClass", "add:", "collect:", "on:classes:level:", "+", "level"],
  977. referencedClasses: ["ClassSorterNode"]
  978. }),
  979. smalltalk.ClassSorterNode);
  980. smalltalk.addMethod(
  981. "_level",
  982. smalltalk.method({
  983. selector: "level",
  984. category: 'accessing',
  985. fn: function (){
  986. var self=this;
  987. return self['@level'];
  988. return self;},
  989. args: [],
  990. source: "level\x0a\x09^level",
  991. messageSends: [],
  992. referencedClasses: []
  993. }),
  994. smalltalk.ClassSorterNode);
  995. smalltalk.addMethod(
  996. "_level_",
  997. smalltalk.method({
  998. selector: "level:",
  999. category: 'accessing',
  1000. fn: function (anInteger){
  1001. var self=this;
  1002. (self['@level']=anInteger);
  1003. return self;},
  1004. args: ["anInteger"],
  1005. source: "level: anInteger\x0a\x09level := anInteger",
  1006. messageSends: [],
  1007. referencedClasses: []
  1008. }),
  1009. smalltalk.ClassSorterNode);
  1010. smalltalk.addMethod(
  1011. "_nodes",
  1012. smalltalk.method({
  1013. selector: "nodes",
  1014. category: 'accessing',
  1015. fn: function (){
  1016. var self=this;
  1017. return self['@nodes'];
  1018. return self;},
  1019. args: [],
  1020. source: "nodes\x0a\x09^nodes",
  1021. messageSends: [],
  1022. referencedClasses: []
  1023. }),
  1024. smalltalk.ClassSorterNode);
  1025. smalltalk.addMethod(
  1026. "_theClass",
  1027. smalltalk.method({
  1028. selector: "theClass",
  1029. category: 'accessing',
  1030. fn: function (){
  1031. var self=this;
  1032. return self['@theClass'];
  1033. return self;},
  1034. args: [],
  1035. source: "theClass\x0a\x09^theClass",
  1036. messageSends: [],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.ClassSorterNode);
  1040. smalltalk.addMethod(
  1041. "_theClass_",
  1042. smalltalk.method({
  1043. selector: "theClass:",
  1044. category: 'accessing',
  1045. fn: function (aClass){
  1046. var self=this;
  1047. (self['@theClass']=aClass);
  1048. return self;},
  1049. args: ["aClass"],
  1050. source: "theClass: aClass\x0a\x09theClass := aClass",
  1051. messageSends: [],
  1052. referencedClasses: []
  1053. }),
  1054. smalltalk.ClassSorterNode);
  1055. smalltalk.addMethod(
  1056. "_traverseClassesWith_",
  1057. smalltalk.method({
  1058. selector: "traverseClassesWith:",
  1059. category: 'visiting',
  1060. fn: function (aCollection){
  1061. var self=this;
  1062. smalltalk.send(aCollection, "_add_", [smalltalk.send(self, "_theClass", [])]);
  1063. 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]);})]);
  1064. return self;},
  1065. args: ["aCollection"],
  1066. 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 ].",
  1067. messageSends: ["add:", "theClass", "do:", "sorted:", "nodes", "<=", "name", "traverseClassesWith:"],
  1068. referencedClasses: []
  1069. }),
  1070. smalltalk.ClassSorterNode);
  1071. smalltalk.addMethod(
  1072. "_on_classes_level_",
  1073. smalltalk.method({
  1074. selector: "on:classes:level:",
  1075. category: 'instance creation',
  1076. fn: function (aClass, aCollection, anInteger){
  1077. var self=this;
  1078. 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", []));
  1079. return self;},
  1080. args: ["aClass", "aCollection", "anInteger"],
  1081. 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",
  1082. messageSends: ["theClass:", "level:", "getNodesFrom:", "yourself", "new"],
  1083. referencedClasses: []
  1084. }),
  1085. smalltalk.ClassSorterNode.klass);