Commits

Ryan Macnak committed 7539e6e

Initial implementation of source printing for Kernel`Mixin

  • Participants
  • Parent commits ffeb37c

Comments (0)

Files changed (1)

 	enclosingMixin <Mixin> "must be slot 4; known to VM"
 |)
 ('as yet unclassified'
+compiledMethodAt: selector <Symbol> ^<CompiledMethod> = (
+	^ self methodDictionary at: selector
+)
 definingClass = (
 	^self
 )
 classVarNames = (
 	^{}
 )
+compiledMethodAt: selector <Symbol> ^<CompiledMethod> = (
+	^ self methodDictionary at: selector
+)
 constructorName = (
 	^cachedConstructorName
 )
 	
 )
 printClassOn: stm = (
-	stm nextPutAll: 'Kernel`Mixin printClassOn: unimplemented'
+
+	stm nextPutAll: 'class '.
+	stm nextPutAll: cachedHeaderSource.
+
+	stm cr; nextPut: $(.
+	nestedMixins values do: [:ea | stm cr. ea printClassOn: stm].
+	writeOrganizationOf: self on: stm.
+	stm nextPut: $).
+
+	stm nextPutAll: ' : ('; cr.
+	writeOrganizationOf: classMixin on: stm.
+	stm nextPut: $).
 )
 printOn: stm = (
 	stm nextPutAll: name , ' mixin'
 traitComposition = (
 	^{}
 )
+writeOrganizationOf: mxn on: aStream = (
+	| org <ClassOrganizer> |
+	org:: mxn organization.
+
+	(org elementArray isEmpty and:
+		[ (org categories copyWithout: org class nullCategory) isEmpty]) ifTrue: [^self].
+
+	org categories do:
+		[ :cat | | sels |
+		aStream  nextPut:$'; nextPutAll: cat;  nextPut:$'; cr.
+		sels:: org listAtCategoryNamed: cat.
+		sels do: [ :sel | aStream nextPutAll: (mxn compiledMethodAt: sel) getSource; cr; cr ]]
+)
 |> superclass <Class> ^<Class> = (
 	^self apply: superclass withName: (self simpleName, 'mixin |>', superclass name)
 ))