2
0

Kernel-Classes.st 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. Smalltalk current createPackage: 'Kernel-Classes'!
  2. Object subclass: #Behavior
  3. instanceVariableNames: ''
  4. package: 'Kernel-Classes'!
  5. !Behavior commentStamp!
  6. I am the superclass of all class objects.
  7. I define the protocol for creating instances of a class with `#basicNew` and `#new` (see `boot.js` for class constructors details).
  8. My instances know about the subclass/superclass relationships between classes, contain the description that instances are created from,
  9. and hold the method dictionary that's associated with each class.
  10. I also provides methods for compiling methods, examining the method dictionary, and iterating over the class hierarchy.!
  11. !Behavior methodsFor: 'accessing'!
  12. >> aString
  13. ^ self methodAt: aString
  14. !
  15. allInstanceVariableNames
  16. | result |
  17. result := self instanceVariableNames copy.
  18. self superclass ifNotNil: [
  19. result addAll: self superclass allInstanceVariableNames].
  20. ^result
  21. !
  22. allSelectors
  23. ^ self allSuperclasses
  24. inject: self selectors
  25. into: [ :acc :each | acc addAll: each selectors; yourself ]
  26. !
  27. allSubclasses
  28. "Answer an collection of the receiver's and the receiver's descendent's subclasses. "
  29. | subclasses index |
  30. subclasses := self subclasses.
  31. index := 1.
  32. [ index > subclasses size ]
  33. whileFalse: [ subclasses addAll: (subclasses at: index) subclasses.
  34. index := index + 1 ].
  35. ^ subclasses
  36. !
  37. allSuperclasses
  38. self superclass ifNil: [ ^ #() ].
  39. ^ (OrderedCollection with: self superclass)
  40. addAll: self superclass allSuperclasses;
  41. yourself
  42. !
  43. comment
  44. ^(self basicAt: 'comment') ifNil: ['']
  45. !
  46. comment: aString
  47. self basicAt: 'comment' put: aString.
  48. SystemAnnouncer current
  49. announce: (ClassCommentChanged new
  50. theClass: self;
  51. yourself)
  52. !
  53. commentStamp
  54. ^ClassCommentReader new
  55. class: self;
  56. yourself
  57. !
  58. commentStamp: aStamp prior: prior
  59. ^self commentStamp
  60. !
  61. definition
  62. ^ ''
  63. !
  64. instanceVariableNames
  65. <return self.iVarNames>
  66. !
  67. lookupSelector: selector
  68. "Look up the given selector in my methodDictionary.
  69. Return the corresponding method if found.
  70. Otherwise chase the superclass chain and try again.
  71. Return nil if no method is found."
  72. | lookupClass |
  73. lookupClass := self.
  74. [ lookupClass = nil ] whileFalse: [
  75. (lookupClass includesSelector: selector)
  76. ifTrue: [ ^ lookupClass methodAt: selector ].
  77. lookupClass := lookupClass superclass ].
  78. ^ nil
  79. !
  80. methodAt: aString
  81. ^ self methodDictionary at: aString
  82. !
  83. methodDictionary
  84. <var dict = smalltalk.HashedCollection._new();
  85. var methods = self.methods;
  86. for(var i in methods) {
  87. if(methods[i].selector) {
  88. dict._at_put_(methods[i].selector, methods[i]);
  89. }
  90. };
  91. return dict>
  92. !
  93. methods
  94. ^ self methodDictionary values
  95. !
  96. methodsFor: aString
  97. ^ClassCategoryReader new
  98. class: self category: aString;
  99. yourself
  100. !
  101. methodsFor: aString stamp: aStamp
  102. "Added for compatibility, right now ignores stamp."
  103. ^self methodsFor: aString
  104. !
  105. methodsInProtocol: aString
  106. ^ self methodDictionary values select: [ :each | each protocol = aString ]
  107. !
  108. name
  109. <return self.className || nil>
  110. !
  111. organization
  112. ^ self basicAt: 'organization'
  113. !
  114. protocols
  115. ^ self organization elements sorted
  116. !
  117. prototype
  118. <return self.fn.prototype>
  119. !
  120. selectors
  121. ^ self methodDictionary keys
  122. !
  123. subclasses
  124. self subclassResponsibility
  125. !
  126. superclass
  127. <return self.superclass || nil>
  128. !
  129. theMetaClass
  130. ^ self class
  131. !
  132. theNonMetaClass
  133. ^ self
  134. !
  135. withAllSubclasses
  136. ^(Array with: self) addAll: self allSubclasses; yourself
  137. ! !
  138. !Behavior methodsFor: 'compiling'!
  139. addCompiledMethod: aMethod
  140. | oldMethod announcement |
  141. oldMethod := self methodDictionary
  142. at: aMethod selector
  143. ifAbsent: [ nil ].
  144. (self protocols includes: aMethod protocol)
  145. ifFalse: [ self organization addElement: aMethod protocol ].
  146. self basicAddCompiledMethod: aMethod.
  147. announcement := oldMethod
  148. ifNil: [
  149. MethodAdded new
  150. method: aMethod;
  151. yourself ]
  152. ifNotNil: [
  153. MethodModified new
  154. oldMethod: oldMethod;
  155. method: aMethod;
  156. yourself ].
  157. SystemAnnouncer current
  158. announce: announcement
  159. !
  160. compile: aString
  161. ^ self compile: aString category: ''
  162. !
  163. compile: aString category: anotherString
  164. ^ Compiler new
  165. install: aString
  166. forClass: self
  167. category: anotherString
  168. !
  169. recompile
  170. ^ Compiler new recompile: self
  171. !
  172. removeCompiledMethod: aMethod
  173. self basicRemoveCompiledMethod: aMethod.
  174. self methods
  175. detect: [ :each | each protocol = aMethod protocol ]
  176. ifNone: [ self organization removeElement: aMethod protocol ].
  177. SystemAnnouncer current
  178. announce: (MethodRemoved new
  179. method: aMethod;
  180. yourself)
  181. ! !
  182. !Behavior methodsFor: 'enumerating'!
  183. allSubclassesDo: aBlock
  184. "Evaluate the argument, aBlock, for each of the receiver's subclasses."
  185. self allSubclasses do: [ :each |
  186. aBlock value: each ]
  187. !
  188. protocolsDo: aBlock
  189. "Execute aBlock for each method category with
  190. its collection of methods in the sort order of category name."
  191. | methodsByCategory |
  192. methodsByCategory := HashedCollection new.
  193. self methodDictionary values do: [:m |
  194. (methodsByCategory at: m category ifAbsentPut: [Array new])
  195. add: m].
  196. self protocols do: [:category |
  197. aBlock value: category value: (methodsByCategory at: category)]
  198. ! !
  199. !Behavior methodsFor: 'instance creation'!
  200. basicNew
  201. <return new self.fn()>
  202. !
  203. new
  204. ^self basicNew initialize
  205. ! !
  206. !Behavior methodsFor: 'private'!
  207. basicAddCompiledMethod: aMethod
  208. <smalltalk.addMethod(aMethod, self)>
  209. !
  210. basicRemoveCompiledMethod: aMethod
  211. <smalltalk.removeMethod(aMethod,self)>
  212. ! !
  213. !Behavior methodsFor: 'testing'!
  214. canUnderstand: aSelector
  215. ^(self methodDictionary keys includes: aSelector asString) or: [
  216. self superclass notNil and: [self superclass canUnderstand: aSelector]]
  217. !
  218. includesBehavior: aClass
  219. ^ self == aClass or: [
  220. self inheritsFrom: aClass ]
  221. !
  222. includesSelector: aString
  223. ^ self methodDictionary includesKey: aString
  224. !
  225. inheritsFrom: aClass
  226. self superclass ifNil: [ ^ false ].
  227. ^ aClass == self superclass or: [
  228. self superclass inheritsFrom: aClass ]
  229. !
  230. isBehavior
  231. ^ true
  232. ! !
  233. Behavior subclass: #Class
  234. instanceVariableNames: ''
  235. package: 'Kernel-Classes'!
  236. !Class commentStamp!
  237. I am __the__ class object.
  238. My instances are the classes of the system.
  239. Class creation is done throught a `ClassBuilder` instance.!
  240. !Class methodsFor: 'accessing'!
  241. category
  242. ^self package ifNil: ['Unclassified'] ifNotNil: [self package name]
  243. !
  244. definition
  245. ^ String streamContents: [ :stream |
  246. stream
  247. nextPutAll: self superclass asString;
  248. nextPutAll: ' subclass: #';
  249. nextPutAll: self name;
  250. nextPutAll: String lf, String tab;
  251. nextPutAll: 'instanceVariableNames: '''.
  252. self instanceVariableNames
  253. do: [ :each | stream nextPutAll: each ]
  254. separatedBy: [ stream nextPutAll: ' ' ].
  255. stream
  256. nextPutAll: '''', String lf, String tab;
  257. nextPutAll: 'package: ''';
  258. nextPutAll: self category;
  259. nextPutAll: '''' ]
  260. !
  261. package
  262. ^ self basicAt: 'pkg'
  263. !
  264. package: aPackage
  265. | oldPackage |
  266. self package = aPackage ifTrue: [ ^ self ].
  267. oldPackage := self package.
  268. self basicAt: 'pkg' put: aPackage.
  269. oldPackage organization removeElement: self.
  270. aPackage organization addElement: self.
  271. SystemAnnouncer current announce: (ClassMoved new
  272. theClass: self;
  273. oldPackage: oldPackage;
  274. yourself)
  275. !
  276. rename: aString
  277. ClassBuilder new renameClass: self to: aString
  278. !
  279. subclasses
  280. <return self.subclasses._copy()>
  281. ! !
  282. !Class methodsFor: 'class creation'!
  283. subclass: aString instanceVariableNames: anotherString
  284. "Kept for compatibility."
  285. ^self subclass: aString instanceVariableNames: anotherString package: nil
  286. !
  287. subclass: aString instanceVariableNames: aString2 category: aString3
  288. "Kept for compatibility."
  289. self deprecatedAPI.
  290. ^self subclass: aString instanceVariableNames: aString2 package: aString3
  291. !
  292. subclass: aString instanceVariableNames: aString2 classVariableNames: classVars poolDictionaries: pools category: aString3
  293. "Just ignore class variables and pools. Added for compatibility."
  294. ^self subclass: aString instanceVariableNames: aString2 package: aString3
  295. !
  296. subclass: aString instanceVariableNames: aString2 package: aString3
  297. ^ClassBuilder new
  298. superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3
  299. ! !
  300. !Class methodsFor: 'converting'!
  301. asJavascript
  302. ^ 'smalltalk.', self name
  303. ! !
  304. !Class methodsFor: 'printing'!
  305. printOn: aStream
  306. aStream nextPutAll: self name
  307. ! !
  308. !Class methodsFor: 'testing'!
  309. isClass
  310. ^true
  311. ! !
  312. Behavior subclass: #Metaclass
  313. instanceVariableNames: ''
  314. package: 'Kernel-Classes'!
  315. !Metaclass commentStamp!
  316. I am the root of the class hierarchy.
  317. My instances are metaclasses, one for each real class, and have a single instance, which they hold onto: the class that they are the metaclass of.!
  318. !Metaclass methodsFor: 'accessing'!
  319. definition
  320. ^ String streamContents: [ :stream |
  321. stream
  322. nextPutAll: self asString;
  323. nextPutAll: ' instanceVariableNames: '''.
  324. self instanceVariableNames
  325. do: [ :each | stream nextPutAll: each ]
  326. separatedBy: [ stream nextPutAll: ' ' ].
  327. stream nextPutAll: '''' ]
  328. !
  329. instanceClass
  330. <return self.instanceClass>
  331. !
  332. instanceVariableNames: aCollection
  333. ClassBuilder new
  334. class: self instanceVariableNames: aCollection
  335. !
  336. subclasses
  337. ^ (self instanceClass subclasses
  338. select: [ :each | each isMetaclass not ])
  339. collect: [ :each | each theMetaClass ]
  340. !
  341. theMetaClass
  342. ^ self
  343. !
  344. theNonMetaClass
  345. ^ self instanceClass
  346. ! !
  347. !Metaclass methodsFor: 'converting'!
  348. asJavascript
  349. ^ 'smalltalk.', self instanceClass name, '.klass'
  350. ! !
  351. !Metaclass methodsFor: 'printing'!
  352. printOn: aStream
  353. aStream
  354. nextPutAll: self instanceClass name;
  355. nextPutAll: ' class'
  356. ! !
  357. !Metaclass methodsFor: 'testing'!
  358. isMetaclass
  359. ^true
  360. ! !
  361. Object subclass: #ClassBuilder
  362. instanceVariableNames: ''
  363. package: 'Kernel-Classes'!
  364. !ClassBuilder commentStamp!
  365. I am responsible for compiling new classes or modifying existing classes in the system.
  366. Rather than using me directly to compile a class, use `Class >> subclass:instanceVariableNames:package:`.!
  367. !ClassBuilder methodsFor: 'accessing'!
  368. instanceVariableNamesFor: aString
  369. ^(aString tokenize: ' ') reject: [ :each | each isEmpty ]
  370. ! !
  371. !ClassBuilder methodsFor: 'class definition'!
  372. addSubclassOf: aClass named: className instanceVariableNames: aCollection package: packageName
  373. | theClass thePackage |
  374. theClass := Smalltalk current at: className.
  375. thePackage := self createPackageNamed: packageName.
  376. theClass ifNotNil: [
  377. theClass package: thePackage.
  378. theClass superclass == aClass ifFalse: [
  379. ^ self
  380. migrateClassNamed: className
  381. superclass: aClass
  382. instanceVariableNames: aCollection
  383. package: packageName ] ].
  384. ^ self
  385. basicAddSubclassOf: aClass
  386. named: className
  387. instanceVariableNames: aCollection
  388. package: packageName
  389. !
  390. class: aClass instanceVariableNames: ivarNames
  391. self basicClass: aClass instanceVariableNames: ivarNames.
  392. self setupClass: aClass.
  393. SystemAnnouncer current
  394. announce: (ClassDefinitionChanged new
  395. theClass: aClass;
  396. yourself)
  397. !
  398. superclass: aClass subclass: className
  399. ^self superclass: aClass subclass: className instanceVariableNames: '' package: nil
  400. !
  401. superclass: aClass subclass: className instanceVariableNames: ivarNames package: packageName
  402. | newClass |
  403. newClass := self addSubclassOf: aClass
  404. named: className instanceVariableNames: (self instanceVariableNamesFor: ivarNames)
  405. package: (packageName ifNil: ['unclassified']).
  406. self setupClass: newClass.
  407. SystemAnnouncer current
  408. announce: (ClassAdded new
  409. theClass: newClass;
  410. yourself).
  411. ^newClass
  412. ! !
  413. !ClassBuilder methodsFor: 'class migration'!
  414. migrateClass: aClass superclass: anotherClass
  415. ^ self
  416. migrateClassNamed: aClass name
  417. superclass: anotherClass
  418. instanceVariableNames: aClass instanceVariableNames
  419. package: aClass package name
  420. !
  421. migrateClassNamed: className superclass: aClass instanceVariableNames: aCollection package: packageName
  422. | oldClass newClass tmp |
  423. tmp := 'new*', className.
  424. oldClass := Smalltalk current at: className.
  425. newClass := self
  426. addSubclassOf: aClass
  427. named: tmp
  428. instanceVariableNames: aCollection
  429. package: packageName.
  430. self basicSwapClassNames: oldClass with: newClass.
  431. [ self copyClass: oldClass to: newClass ]
  432. on: Error
  433. do: [ :exception |
  434. self
  435. basicSwapClassNames: oldClass with: newClass;
  436. basicRemoveClass: newClass.
  437. exception signal ].
  438. self
  439. rawRenameClass: oldClass to: tmp;
  440. rawRenameClass: newClass to: className.
  441. oldClass subclasses
  442. do: [ :each | self migrateClass: each superclass: newClass ]
  443. displayingProgress: 'Recompiling ', newClass name, '...'.
  444. self basicRemoveClass: oldClass.
  445. SystemAnnouncer current announce: (ClassMigrated new
  446. theClass: newClass;
  447. oldClass: oldClass;
  448. yourself).
  449. ^newClass
  450. !
  451. renameClass: aClass to: className
  452. self basicRenameClass: aClass to: className.
  453. "Recompile the class to fix potential issues with super sends"
  454. aClass recompile.
  455. SystemAnnouncer current
  456. announce: (ClassRenamed new
  457. theClass: aClass;
  458. yourself)
  459. ! !
  460. !ClassBuilder methodsFor: 'copying'!
  461. copyClass: aClass named: className
  462. | newClass |
  463. newClass := self
  464. addSubclassOf: aClass superclass
  465. named: className
  466. instanceVariableNames: aClass instanceVariableNames
  467. package: aClass package name.
  468. self copyClass: aClass to: newClass.
  469. SystemAnnouncer current
  470. announce: (ClassAdded new
  471. theClass: newClass;
  472. yourself).
  473. ^newClass
  474. !
  475. copyClass: aClass to: anotherClass
  476. anotherClass comment: aClass comment.
  477. aClass methodDictionary values do: [ :each |
  478. Compiler new install: each source forClass: anotherClass category: each category ].
  479. self basicClass: anotherClass class instanceVariables: aClass class instanceVariableNames.
  480. aClass class methodDictionary values do: [ :each |
  481. Compiler new install: each source forClass: anotherClass class category: each category ].
  482. self setupClass: anotherClass
  483. ! !
  484. !ClassBuilder methodsFor: 'method definition'!
  485. installMethod: aCompiledMethod forClass: aBehavior category: aString
  486. aCompiledMethod category: aString.
  487. aBehavior addCompiledMethod: aCompiledMethod.
  488. self setupClass: aBehavior.
  489. ^aCompiledMethod
  490. ! !
  491. !ClassBuilder methodsFor: 'private'!
  492. basicAddSubclassOf: aClass named: aString instanceVariableNames: aCollection package: packageName
  493. <
  494. smalltalk.addClass(aString, aClass, aCollection, packageName);
  495. return smalltalk[aString]
  496. >
  497. !
  498. basicClass: aClass instanceVariableNames: aString
  499. self basicClass: aClass instanceVariables: (self instanceVariableNamesFor: aString)
  500. !
  501. basicClass: aClass instanceVariables: aCollection
  502. aClass isMetaclass ifFalse: [self error: aClass name, ' is not a metaclass'].
  503. aClass basicAt: 'iVarNames' put: aCollection
  504. !
  505. basicRemoveClass: aClass
  506. <smalltalk.removeClass(aClass)>
  507. !
  508. basicRenameClass: aClass to: aString
  509. <
  510. smalltalk[aString] = aClass;
  511. delete smalltalk[aClass.className];
  512. aClass.className = aString;
  513. >
  514. !
  515. basicSwapClassNames: aClass with: anotherClass
  516. <
  517. var tmp = aClass.className;
  518. aClass.className = anotherClass.className;
  519. anotherClass.className = tmp;
  520. >
  521. !
  522. createPackageNamed: aString
  523. ^ Package named: aString ifAbsent: [
  524. Smalltalk current createDefaultPackage: aString ]
  525. !
  526. rawRenameClass: aClass to: aString
  527. <
  528. smalltalk[aString] = aClass;
  529. >
  530. ! !
  531. !ClassBuilder methodsFor: 'public'!
  532. setupClass: aClass
  533. <smalltalk.init(aClass);>
  534. ! !
  535. Object subclass: #ClassCategoryReader
  536. instanceVariableNames: 'class category'
  537. package: 'Kernel-Classes'!
  538. !ClassCategoryReader commentStamp!
  539. I provide a mechanism for retrieving class descriptions stored on a file in the Smalltalk chunk format.!
  540. !ClassCategoryReader methodsFor: 'accessing'!
  541. class: aClass category: aString
  542. class := aClass.
  543. category := aString
  544. ! !
  545. !ClassCategoryReader methodsFor: 'fileIn'!
  546. scanFrom: aChunkParser
  547. | chunk |
  548. [chunk := aChunkParser nextChunk.
  549. chunk isEmpty] whileFalse: [
  550. self compileMethod: chunk].
  551. ClassBuilder new setupClass: class
  552. ! !
  553. !ClassCategoryReader methodsFor: 'initialization'!
  554. initialize
  555. super initialize.
  556. ! !
  557. !ClassCategoryReader methodsFor: 'private'!
  558. compileMethod: aString
  559. Compiler new install: aString forClass: class category: category
  560. ! !
  561. Object subclass: #ClassCommentReader
  562. instanceVariableNames: 'class'
  563. package: 'Kernel-Classes'!
  564. !ClassCommentReader commentStamp!
  565. I provide a mechanism for retrieving class comments stored on a file.
  566. See also `ClassCategoryReader`.!
  567. !ClassCommentReader methodsFor: 'accessing'!
  568. class: aClass
  569. class := aClass
  570. ! !
  571. !ClassCommentReader methodsFor: 'fileIn'!
  572. scanFrom: aChunkParser
  573. | chunk |
  574. chunk := aChunkParser nextChunk.
  575. chunk isEmpty ifFalse: [
  576. self setComment: chunk].
  577. ! !
  578. !ClassCommentReader methodsFor: 'initialization'!
  579. initialize
  580. super initialize.
  581. ! !
  582. !ClassCommentReader methodsFor: 'private'!
  583. setComment: aString
  584. class comment: aString
  585. ! !
  586. Object subclass: #ClassSorterNode
  587. instanceVariableNames: 'theClass level nodes'
  588. package: 'Kernel-Classes'!
  589. !ClassSorterNode commentStamp!
  590. I provide an algorithm for sorting classes alphabetically.
  591. See [Issue #143](https://github.com/amber-smalltalk/amber/issues/143) on GitHub.!
  592. !ClassSorterNode methodsFor: 'accessing'!
  593. getNodesFrom: aCollection
  594. | children others |
  595. children := #().
  596. others := #().
  597. aCollection do: [:each |
  598. (each superclass = self theClass)
  599. ifTrue: [children add: each]
  600. ifFalse: [others add: each]].
  601. nodes:= children collect: [:each |
  602. ClassSorterNode on: each classes: others level: self level + 1]
  603. !
  604. level
  605. ^level
  606. !
  607. level: anInteger
  608. level := anInteger
  609. !
  610. nodes
  611. ^nodes
  612. !
  613. theClass
  614. ^theClass
  615. !
  616. theClass: aClass
  617. theClass := aClass
  618. ! !
  619. !ClassSorterNode methodsFor: 'visiting'!
  620. traverseClassesWith: aCollection
  621. "sort classes alphabetically Issue #143"
  622. aCollection add: self theClass.
  623. (self nodes sorted: [:a :b | a theClass name <= b theClass name ]) do: [:aNode |
  624. aNode traverseClassesWith: aCollection ].
  625. ! !
  626. !ClassSorterNode class methodsFor: 'instance creation'!
  627. on: aClass classes: aCollection level: anInteger
  628. ^self new
  629. theClass: aClass;
  630. level: anInteger;
  631. getNodesFrom: aCollection;
  632. yourself
  633. ! !