Class Class
back
addNewClass: aClass
| oldClass |
"Check if a class with the same name exist."
oldClass := classes select: [:each | each name = aClass name].
(oldClass size = 1)
ifTrue: [oldClass := oldClass at: 1]
ifFalse: [oldClass := nil].
"We adapt the previous class if necessary"
oldClass isNil ifFalse: [
oldClass superclass: aClass superclass.
oldClass variables: aClass variables.
oldClass class variables: aClass class variables.
oldClass size: aClass size.
oldClass class size: aClass class size.
^ self].
"The class is added"
classes := ((classes add: aClass)
asOrdered: [:a :b | a name < b name]) asArray.
^ aClass