[Pkg] SystemEditor: SystemEditor-mtf.104.mcz

squeaksource-noreply at iam.unibe.ch squeaksource-noreply at iam.unibe.ch
Tue Jul 8 20:19:50 UTC 2008


A new version of SystemEditor was added to project SystemEditor:
http://www.squeaksource.com/SystemEditor/SystemEditor-mtf.104.mcz

==================== Summary ====================

Name: SystemEditor-mtf.104
Author: mtf
Time: 8 July 2008, 1:20:02 pm
UUID: 7dd78ae2-ffc9-4a5f-9016-dd5f114c80e1
Ancestors: SystemEditor-mtf.103

Completely refactored class format handling. New features
- byte, word, weak, and compiledMethod class formats are now supported
- Compact classes are now supported
- Format validation is now both more centrallized, and more thourough

=============== Diff against SystemEditor-mtf.103 ===============

Item was added:
+ ----- Method: ClassFormat>>validateAgainstSuper: (in category 'validating') -----
+ validateAgainstSuper: superFormat
+ "Raise an error if a class with my format cannot inherit from a class with superFormat. Adapted from the various checks in the public ClassBuilder methods"
+ 
+ 	self instSize < superFormat instSize ifTrue: [self error: 'A subclass lost instance variables'].
+ 	superFormat isFixed ifTrue: [^ self]. "Any format can inherit from #normal"
+ 	superFormat isVariable ~~ self isVariable ifTrue: [self error: 'Cannot derive a fixed class from a variable one'].
+ 	superFormat isBits ~~ self isBits ifTrue: [self error: 'Bit and Pointer classes cannot inherit from one another'].
+ 	superFormat isBytes ~~ self isBytes ifTrue: [self error: 'Byte and Word classes cannot inherit from one another'].
+ 	!

Item was added:
+ ----- Method: ClassFormat>>validateAgainstOld: (in category 'validating') -----
+ validateAgainstOld: oldFormat
+ "Raise an error if a class with my format cannot replace a class with oldFormat. Adapted from ClassBuilder >> validateSubclass:canKeepLayoutFrom:forSubclassFormat:"
+ 
+ 	oldFormat ifNil: [^ self]. "This class is new, so anything works"
+ 	(self isWeak and: [oldFormat isVariable]) ifTrue: [^ self].
+ 	self typeOfClass ~~ oldFormat typeOfClass
+ 		ifTrue: [self error: 'The new class format is incompatable with the old']!

Item was added:
+ ----- Method: ClassFormat class>>compiledMethodSpec (in category 'storage specifications') -----
+ compiledMethodSpec
+ 	^ 12!

Item was changed:
  ----- Method: ClassEditor>>edClassFormat (in category 'building') -----
  edClassFormat
+ 	^ ClassFormat
+ 		size: self instSize
+ 		type: self typeOfClass
+ 		index: self indexIfCompact!
- 	| superFormat |
- 	superFormat := self edSuperEditor ifNil: [ClassFormat named]
- 		ifNotNil: [ClassFormat fromBits: self edSuperEditor format].
- 	^ self typeOfClass = #normal
- 		ifTrue: [superFormat namedSubclass: self instVarNames size]
- 		ifFalse: [superFormat indexedSubclass: self instVarNames size]!

Item was added:
+ ----- Method: ClassEditor>>indexIfCompact (in category 'reflecting') -----
+ indexIfCompact
+ 	self subject ifNotNil: [^ self subject indexIfCompact].
+ 	^ 0!

Item was added:
+ ----- Method: ClassFormat>>validate (in category 'validating') -----
+ validate
+ "Raise  an error if I am an invalid format"
+ 
+ 	instSize > 254 ifTrue: [self error: 'Too many instance variables (', instSize printString,')'].
+ 	(self isBits and: [instSize > 0]) ifTrue: [self error: 'Only pointer formats can have named variables'].
+ 	!

Item was changed:
  ----- Method: ClassEditor>>validateFormat (in category 'validating') -----
  validateFormat
+ 	self edClassFormat
+ 		validate;
+ 		validateAgainstSuper: self edSuperFormat;
+ 		validateAgainstOld: self edOldFormat!
- 	(self instSize >= 255) ifTrue: [InvalidClassFormat signal].
- 	(self isBits and: [self instSize >= 1]) ifTrue: [InvalidClassFormat signal].
- 	!

Item was added:
+ ----- Method: ClassFormat class>>size:type:index: (in category 'instance creation') -----
+ size: instSize type: aSymbol index: cClassIndex
+ 	^ self size: instSize spec: (self specFromType: aSymbol size: instSize) index: cClassIndex!

Item was changed:
  Object subclass: #ClassFormat
  	instanceVariableNames: 'instSize instSpec cClassIndex'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'SystemEditor-Editors'!
  
+ !ClassFormat commentStamp: 'mtf 7/7/2008 23:18' prior: 0!
- !ClassFormat commentStamp: 'cwp 9/25/2004 16:07' prior: 0!
  I am an expert on the way the Squeak VM encodes class formats. My instance variable, 'bits', is identical in format to the 'format' instance variable of Behavior. I have methods for interpreting those bits. The class format integer is 18 bits in length. The instSize field is split into two parts for backwards compatibility.
  
  <2 bits=instSize//64> <5 bits=cClass> <4 bits=instSpec> <6 bits=instSize\\64> <1 bit=0>
  
  - instSize: the number of named instance variables
  - cClass: the index into the compact class table
  - instSpec: values indicating how instances are organized
  	0 - no state
  	1 - named instance variables only
  	2 - variable number of object pointers
  	3 - named instance variables, variable number of object pointers
  	4 - variable number of weak object pointers
  	6 - variable number of words
+ 	8 - variable number of bytes
+ 	12 - compiled method format: variable number of object pointers, variable number of bytes!
- 	8 - variable number of bytes!

Item was added:
+ ----- Method: ClassFormat>>typeOfClass (in category 'accessing') -----
+ typeOfClass
+ 	"Answer a symbol uniquely describing the type of the receiver"
+ 	self instSpec = self class compiledMethodSpec ifTrue:[^#compiledMethod]. "Very special!!"
+ 	self isBytes ifTrue:[^#bytes].
+ 	(self isWords and:[self isPointers not]) ifTrue:[^#words].
+ 	self isWeak ifTrue:[^#weak].
+ 	self isVariable ifTrue:[^#variable].
+ 	^#normal.!

Item was added:
+ ----- Method: ClassFormat class>>specFromType:size: (in category 'storage specifications') -----
+ specFromType: aSymbol size: size
+ 	^ aSymbol caseOf: {
+ 		[#normal] -> [size > 0 ifTrue: [self namedSpec] ifFalse: [self noStateSpec]].
+ 		[#variable] -> [self indexedSpec: size].
+ 		[#bytes] -> [self bytesSpec].
+ 		[#words] -> [self wordsSpec].
+ 		[#weak] -> [self weakSpec].
+ 		[#compiledMethod] -> [self compiledMethodSpec].
+ 	} otherwise: [self error: 'Unknown class type: ', aSymbol]
+ 	!

Item was added:
+ ----- Method: ClassEditor>>edOldFormat (in category 'building') -----
+ edOldFormat
+ 	^ subject ifNotNil: [ClassFormat fromBits: subject format]!

Item was added:
+ ----- Method: ClassEditor>>edSuperFormat (in category 'building') -----
+ edSuperFormat
+ 	^ self edSuperEditor
+ 		ifNotNilDo: [:ed | ClassFormat fromBits: ed format]
+ 		ifNil: [ClassFormat named]!

Item was changed:
  ----- Method: ClassEditor>>typeOfClass (in category 'reflecting') -----
  typeOfClass
+ 	type ifNotNil: [^ type].
+ 	subject ifNotNil: [^ subject typeOfClass].
+ 	^ self edSuperFormat typeOfClass.!
- 	^ type ifNil: [type := subject typeOfClass]!



More information about the Packages mailing list