[Pkg] The Trunk: System-bf.915.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 9 12:09:33 UTC 2016


Bert Freudenberg uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-bf.915.mcz

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

Name: System-bf.915
Author: bf
Time: 9 September 2016, 2:04:28.571597 pm
UUID: ffcf5f50-0963-46e9-906e-a389fac9c172
Ancestors: System-bf.914

DataStream: properly support reading immediate class instances (supersedes hacks in System-bf.914). Only used for Characters, because SmallIntegers and Floats are special-cased anyways.

=============== Diff against System-bf.914 ===============

Item was added:
+ ----- Method: Character class>>readImmediateFrom:size: (in category '*system-object storage') -----
+ readImmediateFrom: aDataStream size: varsOnDisk
+ 	"Read an instance of self based on the contents of aDataStream.  Return it.
+ 	 Read in the value as written by Character>>storeDataOn:.
+ 	 NOTE: This method must send beginReference: before reading any objects from aDataStream that might reference it. Because we need to read the value before creating the object, we need to reset the current reference position."
+ 	| refPosn instance |
+ 	refPosn := aDataStream getCurrentReference.
+ 	instance := self value: aDataStream next.
+ 	aDataStream setCurrentReference: refPosn.
+ 	aDataStream beginReference: instance.
+ 	^instance!

Item was removed:
- ----- Method: DataStream>>readCharacterOfSize: (in category 'write and read') -----
- readCharacterOfSize: instSize
- 	"Character changed to an immediate class in Spur"
- 	| refPosn val |
- 	self assert: instSize = 1.
- 	refPosn := self getCurrentReference.
- 	self setCurrentReference: refPosn.  "before recursion - not really needed for integer"
- 	val := self next.
- 	self assert: val isInteger.
- 	self setCurrentReference: refPosn.  "before returning to next"
- 	^ Character value: val.
- !

Item was changed:
  ----- Method: DataStream>>readInstance (in category 'write and read') -----
  readInstance
  	"PRIVATE -- Read the contents of an arbitrary instance.
  	 ASSUMES: readDataFrom:size: sends me beginReference: after it
  	   instantiates the new object but before reading nested objects.
  	 NOTE: We must restore the current reference position after
  	   recursive calls to next.
  	Let the instance, not the class read the data.  "
  	| instSize aSymbol refPosn anObject newClass |
  
  	instSize := (byteStream nextNumber: 4) - 1.
  	refPosn := self getCurrentReference.
  	aSymbol := self next.
- 	(aSymbol == #Character or: [aSymbol isCharacter "hack - why does this happen?"])
- 		ifTrue: [^ self readCharacterOfSize:  instSize].
  	newClass := Smalltalk at: aSymbol asSymbol.
+ 	self setCurrentReference: refPosn.  "before readDataFrom:size:"
+ 	anObject := newClass isImmediateClass
+ 		ifTrue: [newClass readImmediateFrom: self size: instSize]
+ 		ifFalse: [anObject := newClass isVariable 	"Create object here"
- 	anObject := newClass isVariable 	"Create object here"
  			ifFalse: [newClass basicNew]
  			ifTrue: [newClass basicNew: instSize - (newClass instSize)].
+ 		anObject readDataFrom: self size: instSize].
- 	self setCurrentReference: refPosn.  "before readDataFrom:size:"
- 	anObject := anObject readDataFrom: self size: instSize.
  	self setCurrentReference: refPosn.  "before returning to next"
  	^ anObject!

Item was changed:
  ----- Method: SmartRefStream>>readInstanceSize:clsname:refPosn: (in category 'read write') -----
  readInstanceSize: instSize clsname: className refPosn: refPosn
  	"The common code to read the contents of an arbitrary instance.
  	 ASSUMES: readDataFrom:size: sends me beginReference: after it
  	   instantiates the new object but before reading nested objects.
  	 NOTE: We must restore the current reference position after
  	   recursive calls to next.
  Three cases for files from older versions of the system:
  1) Class has not changed shape, read it straight.
  2) Class has changed instance variables (or needs fixup).  Call a particular method to do it.
  3) There is a new class instead.  Find it, call a particular method to read.
  	All classes used to construct the structures dictionary *itself* need to be in 'steady' and they must not change!!  See setStream:"
  	| anObject newName newClass dict oldInstVars isMultiSymbol |
  
  	self flag: #bobconv.	
  
  	self setCurrentReference: refPosn.  "remember pos before readDataFrom:size:"
  	newName := renamed at: className ifAbsent: [className].
- 	newName == #Character
- 		ifTrue: [^ self readCharacterOfSize:  instSize].
  	isMultiSymbol := newName = #MultiSymbol or: [newName = #WideSymbol].
  	"isMultiSymbol ifTrue: [self halt]."
  	newClass := Smalltalk at: newName asSymbol.
  	(steady includes: newClass) & (newName == className) ifTrue: [
+ 		anObject := newClass isImmediateClass
+ 			ifTrue: [newClass readImmediateFrom: self size: instSize]
+ 			ifFalse: [anObject := newClass isVariable 	"Create object here"
+ 					ifFalse: [newClass basicNew]
+ 					ifTrue: [newClass basicNew: instSize - (newClass instSize)].
+ 				anObject readDataFrom: self size: instSize].
+ 		
- 	 	anObject := newClass isVariable "Create it here"
- 			ifFalse: [newClass basicNew]
- 			ifTrue: [newClass basicNew: instSize - (newClass instSize)].
- 
- 		anObject := anObject readDataFrom: self size: instSize.
  		self setCurrentReference: refPosn.  "before returning to next"
  		isMultiSymbol ifTrue: [^ Symbol intern: anObject asString].
  		^ anObject].
  	oldInstVars := structures at: className ifAbsent: [
  			self error: 'class is not in structures list'].	"Missing in object file"
  	anObject := newClass createFrom: self size: instSize version: oldInstVars.
  		"only create the instance"
  	self beginReference: anObject.
  	dict := self catalogValues: oldInstVars size: instSize.
  		"indexed vars as (1 -> val) etc."
  	dict at: #ClassName put: className.	"so conversion method can know it"
  
  	"Give each superclass a chance to make its changes"
  	self storeInstVarsIn: anObject from: dict.	"ones with the same names"
  
  	anObject := self applyConversionMethodsTo: anObject className: className varMap: dict.
  
  	self setCurrentReference: refPosn.  "before returning to next"
  	isMultiSymbol ifTrue: [^ Symbol intern: anObject asString].
  	^ anObject!



More information about the Packages mailing list