2
0

Kernel-Classes.js 40 KB

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