[comp.lang.smalltalk] Adding a new instance variable to class Process

paul@pplace.COM (Paul Alderman) (06/23/88)

This message is in response to Colin Kendall's question about adding a new 
instance variable to a Process.  I thought I would post this for others who might be interested.


To add a new instance variable to Process, fileIn the following, replacing 
'*newInstVarName*' with the instance variable name of your choice.

----------cut----------here----------

"Define a couple methods temporarily."!
!Behavior methodsFor: 'accessing'!

methodDictionary
	^ methodDict! !

!ClassDescription methodsFor: 'organization'!

organization: aClassOrganizer
	organization _ aClassOrganizer! !


"Rename existing class."
Process rename: #OldProcess.!

"Create the new class."
Link subclass: #Process
	instanceVariableNames: 'suspendedContext priority myList *newInstVarName* '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Kernel-Processes'.!

"Copy methods and method organizations."
Process methodDictionary: OldProcess methodDictionary copy.!
Process organization: OldProcess organization copy.!
Process class methodDictionary: OldProcess class methodDictionary copy.!
Process class organization: OldProcess class organization copy.!

"Remove temporary methods."
Behavior removeSelector: #methodDictionary.!
ClassDescription removeSelector: #organization:.!

"Swap References."
( Smalltalk associationAt: #OldProcess )
	become: ( Smalltalk associationAt: #Process )!

"Rehash the System Dictionary."
Smalltalk rehash.!

"Recompile in the new class."
Process compileAll.!
Process class compileAll.!

"Finish the transformation."
[
	"Mutate old processes into new processes."
	Process updateInstancesFrom: OldProcess.

	"Remove old class."
	OldProcess removeFromSystem.
	SystemOrganization removeElement: #OldProcess.

] forkAt: Processor highIOPriority.!

"Reset the display."
Cursor normal show.
ScheduledControllers searchForActiveController.!


----------cut----------here----------

Paul Alderman
ParcPlace Systems
support@ParcPlace.com
...!sun!pplace!support