[squeak-dev] The Trunk: System-dtl.1373.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 24 04:27:36 UTC 2022


David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1373.mcz

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

Name: System-dtl.1373
Author: dtl
Time: 23 November 2022, 11:27:30.771886 pm
UUID: f3d54b26-e023-4d20-a023-c490f507a778
Ancestors: System-ct.1372

Categorize methods in DataStream for clarity. No changes to methods, category organization only.

=============== Diff against System-ct.1372 ===============

Item was changed:
+ ----- Method: DataStream>>atEnd (in category 'stream access') -----
- ----- Method: DataStream>>atEnd (in category 'other') -----
  atEnd
      "Answer true if the stream is at the end."
  
      ^ byteStream atEnd!

Item was changed:
+ ----- Method: DataStream>>beginInstance:size: (in category 'object storage') -----
- ----- Method: DataStream>>beginInstance:size: (in category 'write and read') -----
  beginInstance: aClass size: anInteger
  	"This is for use by storeDataOn: methods.
  	 Cf. Object>>storeDataOn:."
  
  		"Addition of 1 seems to make extra work, since readInstance
  		has to compensate.  Here for historical reasons dating back
  		to Kent Beck's original implementation in late 1988.
  
  		In ReferenceStream, class is just 5 bytes for shared symbol.
  
  		SmartRefStream puts out the names and number of class's instances variables for checking."
  
  	byteStream nextNumber: 4 put: anInteger + 1.
  
  	self nextPut: aClass name!

Item was changed:
+ ----- Method: DataStream>>beginReference: (in category 'object storage') -----
- ----- Method: DataStream>>beginReference: (in category 'write and read') -----
  beginReference: anObject
      "We're starting to read anObject. Remember it and its reference
       position (if we care; ReferenceStream cares). Answer the
       reference position."
  
      ^ 0!

Item was changed:
+ ----- Method: DataStream>>byteStream (in category 'accessing') -----
- ----- Method: DataStream>>byteStream (in category 'other') -----
  byteStream
  	^ byteStream!

Item was changed:
+ ----- Method: DataStream>>close (in category 'stream access') -----
- ----- Method: DataStream>>close (in category 'other') -----
  close
  	"Close the stream."
  
  	| bytes |
  	byteStream closed 
  		ifFalse: [
  			bytes := byteStream position.
  			byteStream close]
  		ifTrue: [bytes := 'unknown'].
  	^ bytes!

Item was changed:
+ ----- Method: DataStream>>contents (in category 'accessing') -----
- ----- Method: DataStream>>contents (in category 'other') -----
  contents
  	^byteStream contents!

Item was changed:
+ ----- Method: DataStream>>errorWriteReference: (in category 'private - write') -----
- ----- Method: DataStream>>errorWriteReference: (in category 'other') -----
  errorWriteReference: anInteger
      "PRIVATE -- Raise an error because this case of nextPut:'s perform:
       shouldn't be called. -- 11/15/92 jhm"
  
      self error: 'This should never be called'!

Item was changed:
+ ----- Method: DataStream>>flush (in category 'stream access') -----
- ----- Method: DataStream>>flush (in category 'other') -----
  flush
      "Guarantee that any writes to me are actually recorded on disk. -- 11/17/92 jhm"
  
      ^ byteStream flush!

Item was changed:
+ ----- Method: DataStream>>getCurrentReference (in category 'object storage') -----
- ----- Method: DataStream>>getCurrentReference (in category 'write and read') -----
  getCurrentReference
      "PRIVATE -- Return the currentReference posn.
       Overridden by ReferenceStream."
  
      ^ 0!

Item was changed:
+ ----- Method: DataStream>>insideASegment (in category 'object storage') -----
- ----- Method: DataStream>>insideASegment (in category 'write and read') -----
  insideASegment
  	^ false!

Item was changed:
+ ----- Method: DataStream>>maybeBeginReference: (in category 'private - read') -----
- ----- Method: DataStream>>maybeBeginReference: (in category 'write and read') -----
  maybeBeginReference: internalObject
  	"Do nothing.  See ReferenceStream|maybeBeginReference:"
  
  	^ internalObject!

Item was changed:
+ ----- Method: DataStream>>next (in category 'stream access') -----
- ----- Method: DataStream>>next (in category 'write and read') -----
  next
  	"Answer the next object in the stream."
  	| type selector anObject isARefType pos internalObject |
  
  	type := byteStream next.
  	type ifNil: [pos := byteStream position.	"absolute!!!!"
  		byteStream close.	"clean up"
  		byteStream position = 0 
  			ifTrue: [self error: 'The file did not exist in this directory'] 
  			ifFalse: [self error: 'Unexpected end of object file'].
  		pos.	"so can see it in debugger"
  		^ nil].
  	type = 0 ifTrue: [pos := byteStream position.	"absolute!!!!"
  		byteStream close.	"clean up"
  		self error: 'Expected start of object, but found 0'.
  		^ nil].
  	isARefType := self noteCurrentReference: type.
  	selector := #(readNil readTrue readFalse readInteger	"<-4"
  			readStringOld readSymbol readByteArray		"<-7"
  			readArray readInstance readReference readBitmap	"<-11"
  			readClass readUser readFloat readRectangle readShortInst 	"<-16"
  			readString readWordArray readWordArrayForSegment 	"<-19"
  			readWordLike readMethod "<-21") at: type ifAbsent: [
  				pos := byteStream position.	"absolute!!!!"
  				byteStream close. 
  				self error: 'file is more recent than this system'. ^ nil].
  	anObject := self perform: selector. "A method that recursively
  		calls next (readArray, readInstance, objectAt:) must save &
  		restore the current reference position."
  	isARefType ifTrue: [self beginReference: anObject].
  
  		"After reading the externalObject, internalize it.
  		 #readReference is a special case. Either:
  		   (1) We actually have to read the object, recursively calling
  			   next, which internalizes the object.
  		   (2) We just read a reference to an object already read and
  			   thus already interalized.
  		 Either way, we must not re-internalize the object here."
  	selector == #readReference ifTrue: [^ anObject].
  	internalObject := anObject comeFullyUpOnReload: self.
  	internalObject == String ifTrue:[
  		"This is a hack to figure out if we're loading a String class 
  		that really should be a ByteString. Note that these days this
  		will no longer be necessary since we use #withClassVersion:
  		for constructing the global thus using a different classVersion
  		will perfectly do the trick."
  		((anObject isKindOf: DiskProxy) 
  			and:[anObject globalObjectName == #String
  			and:[anObject constructorSelector == #yourself]]) ifTrue:[
  				internalObject := ByteString]].
  	^ self maybeBeginReference: internalObject!

Item was changed:
+ ----- Method: DataStream>>next: (in category 'stream access') -----
- ----- Method: DataStream>>next: (in category 'other') -----
  next: anInteger
      "Answer an Array of the next anInteger objects in the stream."
      | array |
  
      array := Array new: anInteger.
      1 to: anInteger do: [:i |
          array at: i put: self next].
      ^ array!

Item was changed:
+ ----- Method: DataStream>>nextAndClose (in category 'stream access') -----
- ----- Method: DataStream>>nextAndClose (in category 'other') -----
  nextAndClose
  	"Speedy way to grab one object.  Only use when we are inside an object binary file.  Do not use for the start of a SmartRefStream mixed code-and-object file."
  
  	| obj |
  	obj := self next.
  	self close.
  	^ obj!

Item was changed:
+ ----- Method: DataStream>>nextPut: (in category 'stream access') -----
- ----- Method: DataStream>>nextPut: (in category 'write and read') -----
  nextPut: anObject
  	"Write anObject to the receiver stream. Answer anObject."
  	| typeID selector objectToStore |
  
  	typeID := self typeIDFor: anObject.
  	(self tryToPutReference: anObject typeID: typeID)
  		ifTrue: [^ anObject].
  
  	objectToStore := (self objectIfBlocked: anObject) objectForDataStream: self.
  	objectToStore == anObject
  		ifFalse:
  			[typeID := self typeIDFor: objectToStore.
  			(self tryToPutReference: objectToStore typeID: typeID)
  				ifTrue: [^ anObject]].
  
  	byteStream nextPut: typeID.
  	selector := #(writeNil: writeTrue: writeFalse: writeInteger: 
  		writeStringOld: writeSymbol: writeByteArray:
  		writeArray: writeInstance: errorWriteReference: writeBitmap:
  		writeClass: writeUser: writeFloat: writeRectangle: == "<-16 short inst" 
  		writeString: writeBitmap: writeBitmap: writeWordLike: 
  		writeInstance: "CompiledMethod") at: typeID.
  	self perform: selector with: objectToStore.
  
  	^ anObject
  
  
  "NOTE: If anObject is a reference type (one that we write cross-references to) but its externalized form (result of objectForDataStream:) isn't (e.g. CompiledMethod and ViewState), then we should remember its externalized form
   but not add to 'references'. Putting that object again should just put its
   external form again. That's more compact and avoids seeks when reading.
   But we just do the simple thing here, allowing backward-references for
   non-reference types like nil. So objectAt: has to compensate. Objects that
   externalize nicely won't contain the likes of ViewStates, so this shouldn't
   hurt much.
  	 writeReference: -> errorWriteReference:."!

Item was changed:
+ ----- Method: DataStream>>nextPutAll: (in category 'stream access') -----
- ----- Method: DataStream>>nextPutAll: (in category 'write and read') -----
  nextPutAll: aCollection
      "Write each of the objects in aCollection to the
       receiver stream. Answer aCollection."
  
      ^ aCollection do: [:each | self nextPut: each]!

Item was changed:
+ ----- Method: DataStream>>noteCurrentReference: (in category 'private - read') -----
- ----- Method: DataStream>>noteCurrentReference: (in category 'write and read') -----
  noteCurrentReference: typeID
      "PRIVATE -- If we support references for type typeID, remember
       the current byteStream position so we can add the next object to
       the 'objects' dictionary, and return true. Else return false.
       This method is here to be overridden by ReferenceStream"
  
      ^ false!

Item was changed:
+ ----- Method: DataStream>>objectAt: (in category 'object storage') -----
- ----- Method: DataStream>>objectAt: (in category 'write and read') -----
  objectAt: anInteger
  	"PRIVATE -- Read & return the object at a given stream position.  anInteger is a relative file position. "
  	| savedPosn anObject refPosn |
  
  	savedPosn := byteStream position.	"absolute"
  	refPosn := self getCurrentReference.	"relative position"
  
  	byteStream position: anInteger + basePos.	"was relative"
  	anObject := self next.
  
  	self setCurrentReference: refPosn.	"relative position"
  	byteStream position: savedPosn.		"absolute"
  	^ anObject!

Item was changed:
+ ----- Method: DataStream>>objectIfBlocked: (in category 'private - write') -----
- ----- Method: DataStream>>objectIfBlocked: (in category 'write and read') -----
  objectIfBlocked: anObject
  	"We don't do any blocking"
  
  	^ anObject!

Item was changed:
+ ----- Method: DataStream>>outputReference: (in category 'private - write') -----
- ----- Method: DataStream>>outputReference: (in category 'write and read') -----
  outputReference: referencePosn
  	"PRIVATE -- Output a reference to the object at integer stream position referencePosn (relative to basePos). To output a weak reference to an object not yet written, supply (self vacantRef) for referencePosn."
  
  	byteStream nextPut: 10. "reference typeID"
  	byteStream nextNumber: 4 put: referencePosn	"relative position"!

Item was changed:
+ ----- Method: DataStream>>project (in category 'accessing') -----
- ----- Method: DataStream>>project (in category 'other') -----
  project
  	^nil!

Item was changed:
+ ----- Method: DataStream>>readArray (in category 'private - read') -----
- ----- Method: DataStream>>readArray (in category 'write and read') -----
  readArray
  	"PRIVATE -- Read the contents of an Array.
  	 We must do beginReference: here after instantiating the Array
  	 but before reading its contents, in case the contents reference
  	 the Array. beginReference: will be sent again when we return to
  	 next, but that's ok as long as we save and restore the current
  	 reference position over recursive calls to next."
  	| count array refPosn |
  
  	count := byteStream nextNumber: 4.
  
  	refPosn := self beginReference: (array := Array new: count).		"relative pos"
  	1 to: count do: [:i |
  		array at: i put: self next].
  	self setCurrentReference: refPosn.		"relative pos"
  	^ array!

Item was changed:
+ ----- Method: DataStream>>readBitmap (in category 'private - read') -----
- ----- Method: DataStream>>readBitmap (in category 'write and read') -----
  readBitmap
  	"PRIVATE -- Read the contents of a Bitmap."
  
  	^ Bitmap newFromStream: byteStream
  	"Note that the reader knows that the size is in long words, but the data is in bytes."!

Item was changed:
+ ----- Method: DataStream>>readBoolean (in category 'private - read') -----
- ----- Method: DataStream>>readBoolean (in category 'write and read') -----
  readBoolean
  	"PRIVATE -- Read the contents of a Boolean.
  	 This is here only for compatibility with old data files."
  
  	^ byteStream next ~= 0!

Item was changed:
+ ----- Method: DataStream>>readByteArray (in category 'private - read') -----
- ----- Method: DataStream>>readByteArray (in category 'write and read') -----
  readByteArray
  	"PRIVATE -- Read the contents of a ByteArray."
  
  	| count |
  	count := byteStream nextNumber: 4.
  	^ byteStream next: count  "assume stream is in binary mode"
  !

Item was changed:
+ ----- Method: DataStream>>readClass (in category 'private - read') -----
- ----- Method: DataStream>>readClass (in category 'write and read') -----
  readClass
  	"Should never be executed because a DiskProxy, not a clas comes in."
  
  	^ self error: 'Classes should be filed in'!

Item was changed:
+ ----- Method: DataStream>>readFalse (in category 'private - read') -----
- ----- Method: DataStream>>readFalse (in category 'write and read') -----
  readFalse
      "PRIVATE -- Read the contents of a False."
  
      ^ false!

Item was changed:
+ ----- Method: DataStream>>readFloat (in category 'private - read') -----
- ----- Method: DataStream>>readFloat (in category 'write and read') -----
  readFloat
  	"PRIVATE -- Read the contents of a Float.
  	 This is the fast way to read a Float.
  	 We support 8-byte Floats here.  Non-IEEE"
  
  	| new |
  	new := Float new: 2.		"To get an instance"
  	new at: 1 put: (byteStream nextNumber: 4).
  	new at: 2 put: (byteStream nextNumber: 4).
  	^ new!

Item was changed:
+ ----- Method: DataStream>>readFloatString (in category 'private - read') -----
- ----- Method: DataStream>>readFloatString (in category 'write and read') -----
  readFloatString
  	"PRIVATE -- Read the contents of a Float string.
  	 This is the slow way to read a Float--via its string rep'n.
  	 It's here for compatibility with old data files."
  
  	^ Float readFrom: (byteStream next: (byteStream nextNumber: 4))!

Item was changed:
+ ----- Method: DataStream>>readInstance (in category 'private - read') -----
- ----- 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.
  	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"
  			ifFalse: [newClass basicNew]
  			ifTrue: [newClass basicNew: instSize - (newClass instSize)].
  		anObject readDataFrom: self size: instSize].
  	self setCurrentReference: refPosn.  "before returning to next"
  	^ anObject!

Item was changed:
+ ----- Method: DataStream>>readInteger (in category 'private - read') -----
- ----- Method: DataStream>>readInteger (in category 'write and read') -----
  readInteger
      "PRIVATE -- Read the contents of a SmallInteger."
  
      ^ byteStream nextInt32	"signed!!!!!!"!

Item was changed:
+ ----- Method: DataStream>>readMethod (in category 'private - read') -----
- ----- Method: DataStream>>readMethod (in category 'write and read') -----
  readMethod
  	"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 refPosn newClass className xxHeader nLits byteCodeSizePlusTrailer newMethod lits |
  
  	instSize := (byteStream nextNumber: 4) - 1.
  	refPosn := self getCurrentReference.
  	className := self next.
  	newClass := Smalltalk at: className asSymbol.
  
  	xxHeader := self next.
  		"nArgs := (xxHeader >> 24) bitAnd: 16rF."
  		"nTemps := (xxHeader >> 18) bitAnd: 16r3F."
  		"largeBit := (xxHeader >> 17) bitAnd: 1."
  	nLits := xxHeader bitAnd: 16r7FFF.
  	byteCodeSizePlusTrailer := instSize - (newClass instSize "0") - (nLits + 1 * Smalltalk wordSize).
  
  	newMethod := newClass 
  						newMethod: byteCodeSizePlusTrailer
  						header: xxHeader.
  
  	self setCurrentReference: refPosn.  "before readDataFrom:size:"
  	self beginReference: newMethod.
  	lits := newMethod numLiterals + 1.	"counting header"
  	2 to: lits do:
  		[:ii | newMethod objectAt: ii put: self next].
  	lits*Smalltalk wordSize+1 to: newMethod basicSize do:
  		[:ii | newMethod basicAt: ii put: byteStream next].
  			"Get raw bytes directly from the file"
  	self setCurrentReference: refPosn.  "before returning to next"
  	^newMethod!

Item was changed:
+ ----- Method: DataStream>>readNil (in category 'private - read') -----
- ----- Method: DataStream>>readNil (in category 'write and read') -----
  readNil
      "PRIVATE -- Read the contents of an UndefinedObject."
  
      ^ nil!

Item was changed:
+ ----- Method: DataStream>>readRectangle (in category 'private - read') -----
- ----- Method: DataStream>>readRectangle (in category 'write and read') -----
  readRectangle
      "Read a compact Rectangle.  Rectangles with values outside +/- 2047 were stored as normal objects (type=9).  They will not come here.  17:22 tk"
  
  	"Encoding is four 12-bit signed numbers.  48 bits in next 6 bytes.  17:24 tk"
  	| acc left top right bottom |
  	acc := byteStream nextNumber: 3.
  	left := acc bitShift: -12.
  	(left bitAnd: 16r800) ~= 0 ifTrue: [left := left - 16r1000].	"sign"
  	top := acc bitAnd: 16rFFF.
  	(top bitAnd: 16r800) ~= 0 ifTrue: [top := top - 16r1000].	"sign"
  
  	acc := byteStream nextNumber: 3.
  	right := acc bitShift: -12.
  	(right bitAnd: 16r800) ~= 0 ifTrue: [right := right - 16r1000].	"sign"
  	bottom := acc bitAnd: 16rFFF.
  	(bottom bitAnd: 16r800) ~= 0 ifTrue: [bottom := bottom - 16r1000].	"sign"
  	
      ^ Rectangle left: left right: right top: top bottom: bottom
  !

Item was changed:
+ ----- Method: DataStream>>readReference (in category 'private - read') -----
- ----- Method: DataStream>>readReference (in category 'write and read') -----
  readReference
  	"Read the contents of an object reference. (Cf. outputReference:)  File is not now positioned at this object."
  	| referencePosition |
  
  	^ (referencePosition := (byteStream nextNumber: 4)) = self vacantRef	"relative"
  		ifTrue:  [nil]
  		ifFalse: [self objectAt: referencePosition]		"relative pos"!

Item was changed:
+ ----- Method: DataStream>>readShortInst (in category 'private - read') -----
- ----- Method: DataStream>>readShortInst (in category 'write and read') -----
  readShortInst
  	"Read the contents of an arbitrary instance that has a short header.
  	 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 next) - 1.	"one byte of size"
  	refPosn := self getCurrentReference.
  	aSymbol := self readShortRef.	"class symbol in two bytes of file pos"
  	newClass := Smalltalk at: aSymbol asSymbol.
  	anObject := newClass isVariable 	"Create object here"
  			ifFalse: [newClass basicNew]
  			ifTrue: [newClass basicNew: instSize - (newClass 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: DataStream>>readShortRef (in category 'private - read') -----
- ----- Method: DataStream>>readShortRef (in category 'write and read') -----
  readShortRef
  	"Read an object reference from two bytes only.  Original object must be in first 65536 bytes of the file.  Relative to start of data.  vacantRef not a possibility."
  
  	^ self objectAt: (byteStream nextNumber: 2)!

Item was changed:
+ ----- Method: DataStream>>readString (in category 'private - read') -----
- ----- Method: DataStream>>readString (in category 'write and read') -----
  readString
  	^byteStream nextString
  !

Item was changed:
+ ----- Method: DataStream>>readStringOld (in category 'private - read') -----
- ----- Method: DataStream>>readStringOld (in category 'write and read') -----
  readStringOld
  
     ^ byteStream nextStringOld!

Item was changed:
+ ----- Method: DataStream>>readSymbol (in category 'private - read') -----
- ----- Method: DataStream>>readSymbol (in category 'write and read') -----
  readSymbol
      "PRIVATE -- Read the contents of a Symbol."
  
      ^ self readString asSymbol!

Item was changed:
+ ----- Method: DataStream>>readTrue (in category 'private - read') -----
- ----- Method: DataStream>>readTrue (in category 'write and read') -----
  readTrue
      "PRIVATE -- Read the contents of a True."
  
      ^ true!

Item was changed:
+ ----- Method: DataStream>>readUser (in category 'private - read') -----
- ----- Method: DataStream>>readUser (in category 'write and read') -----
  readUser
  	"Reconstruct both the private class and the instance.  Still used??"
  
  	^ self readInstance.		"Will create new unique class"
  !

Item was changed:
+ ----- Method: DataStream>>readWordArray (in category 'private - read') -----
- ----- Method: DataStream>>readWordArray (in category 'write and read') -----
  readWordArray
  	"PRIVATE -- Read the contents of a WordArray."
  
  	^ WordArray newFromStream: byteStream
  	"Size is number of long words."!

Item was changed:
+ ----- Method: DataStream>>readWordArrayForSegment (in category 'private - read') -----
- ----- Method: DataStream>>readWordArrayForSegment (in category 'write and read') -----
  readWordArrayForSegment
  	"Read the contents of a WordArray ignoring endianness."
  
  	^ WordArrayForSegment newFromStream: byteStream
  	"Size is number of long words."!

Item was changed:
+ ----- Method: DataStream>>readWordLike (in category 'private - read') -----
- ----- Method: DataStream>>readWordLike (in category 'write and read') -----
  readWordLike
  	| refPosn aSymbol newClass anObject |
  	"Can be used by any class that is bits and not bytes (WordArray, Bitmap, SoundBuffer, etc)."
  
  	refPosn := self getCurrentReference.
  	aSymbol := self next.
  	newClass := Smalltalk at: aSymbol asSymbol.
  	anObject := newClass newFromStream: byteStream.
  	"Size is number of long words."
  	self setCurrentReference: refPosn.  "before returning to next"
  	^ anObject
  !

Item was changed:
+ ----- Method: DataStream>>replace:with: (in category 'object storage') -----
- ----- Method: DataStream>>replace:with: (in category 'write and read') -----
  replace: original with: proxy
  	"We may wish to remember that in some field, the original object is being replaced by the proxy.  For the hybred scheme that collects with a DummyStream and writes an ImageSegment, it needs to hold onto the originals so they will appear in outPointers, and be replaced."
  
  	"do nothing"!

Item was changed:
+ ----- Method: DataStream>>reset (in category 'stream access') -----
- ----- Method: DataStream>>reset (in category 'other') -----
  reset
      "Reset the stream."
  
      byteStream reset!

Item was changed:
+ ----- Method: DataStream>>rootObject (in category 'accessing') -----
- ----- Method: DataStream>>rootObject (in category 'other') -----
  rootObject
  	"Return the object at the root of the tree we are filing out.  "
  
  	^ topCall!

Item was changed:
+ ----- Method: DataStream>>rootObject: (in category 'accessing') -----
- ----- Method: DataStream>>rootObject: (in category 'other') -----
  rootObject: anObject
  	"Return the object at the root of the tree we are filing out.  "
  
  	topCall := anObject!

Item was changed:
+ ----- Method: DataStream>>setCurrentReference: (in category 'private - read') -----
- ----- Method: DataStream>>setCurrentReference: (in category 'write and read') -----
  setCurrentReference: refPosn
      "PRIVATE -- Set currentReference to refPosn.
       Noop here. Cf. ReferenceStream."!

Item was changed:
+ ----- Method: DataStream>>setStream: (in category 'initialize-release') -----
- ----- Method: DataStream>>setStream: (in category 'other') -----
  setStream: aStream
  	"PRIVATE -- Initialization method."
  
  	aStream binary.
  	basePos := aStream position.	"Remember where we start.  Earlier part of file contains a class or method file-in.  Allow that to be edited.  We don't deal in absolute file locations."
  	byteStream := aStream.!

Item was changed:
+ ----- Method: DataStream>>setStream:reading: (in category 'initialize-release') -----
- ----- Method: DataStream>>setStream:reading: (in category 'other') -----
  setStream: aStream reading: isReading
  	"PRIVATE -- Initialization method."
  
  	aStream binary.
  	basePos := aStream position.	"Remember where we start.  Earlier part of file contains a class or method file-in.  Allow that to be edited.  We don't deal in absolute file locations."
  	byteStream := aStream.!

Item was changed:
+ ----- Method: DataStream>>size (in category 'accessing') -----
- ----- Method: DataStream>>size (in category 'other') -----
  size
      "Answer the stream's size."
  
      ^ byteStream size!

Item was changed:
+ ----- Method: DataStream>>tryToPutReference:typeID: (in category 'private - write') -----
- ----- Method: DataStream>>tryToPutReference:typeID: (in category 'write and read') -----
  tryToPutReference: anObject typeID: typeID
      "PRIVATE -- If we support references for type typeID, and if
         anObject already appears in my output stream, then put a
         reference to the place where anObject already appears. If we
         support references for typeID but didn't already put anObject,
         then associate the current stream position with anObject in
         case one wants to nextPut: it again.
       Return true after putting a reference; false if the object still
         needs to be put.
       For DataStream this is trivial. ReferenceStream overrides this."
  
      ^ false!

Item was changed:
+ ----- Method: DataStream>>typeIDFor: (in category 'object storage') -----
- ----- Method: DataStream>>typeIDFor: (in category 'write and read') -----
  typeIDFor: anObject
  	"Return the typeID for anObject's class.  This is where the tangle of objects is clipped to stop everything from going out.  
  	Classes can control their instance variables by defining objectToStoreOnDataStream.
  	Any object in blockers is not written out.  See ReferenceStream.objectIfBlocked: and DataStream nextPut:.
  	Morphs do not write their owners.  See Morph.storeDataOn:   Each morph tells itself to 'prepareToBeSaved' before writing out."
  
  
  	anObject isFloat ifTrue: [^14]. "shortcut floats of any representation."
  	^ TypeMap at: anObject class ifAbsent: [9 "instance of any normal class"]	
  "See DataStream initialize.  nil=1. true=2. false=3. a SmallInteger=4. (a String was 5). a Symbol=6.  a ByteArray=7. an Array=8. other = 9.  a Bitmap=11. a Metaclass=12. a Float=14.  a Rectangle=15. any instance that can have a short header=16.  a String=17 (new format). a WordArray=18."!

Item was changed:
+ ----- Method: DataStream>>vacantRef (in category 'object storage') -----
- ----- Method: DataStream>>vacantRef (in category 'other') -----
  vacantRef
  	"Answer the magic 32-bit constant we use ***ON DISK*** as a stream 'reference
  	 position' to identify a reference that's not yet filled in. This must be a
  	 value that won't be used as an ordinary reference. Cf. outputReference: and
  	 readReference. -- 
  	 NOTE: We could use a different type ID for vacant-refs rather than writing
  		object-references with a magic value. (The type ID and value are
  		overwritten by ordinary object-references when weak refs are fullfilled.)"
  
  	^1073741823		"Hardcode former SmallInteger maxVal"!

Item was changed:
+ ----- Method: DataStream>>writeArray: (in category 'private - write') -----
- ----- Method: DataStream>>writeArray: (in category 'write and read') -----
  writeArray: anArray
  	"PRIVATE -- Write the contents of an Array."
  
  	byteStream nextNumber: 4 put: anArray size.
  	self nextPutAll: anArray.!

Item was changed:
+ ----- Method: DataStream>>writeBitmap: (in category 'private - write') -----
- ----- Method: DataStream>>writeBitmap: (in category 'write and read') -----
  writeBitmap: aBitmap
  	"PRIVATE -- Write the contents of a Bitmap."
  
  	aBitmap writeOn: byteStream
  	"Note that this calls (byteStream nextPutAll: aBitmap) which knows enough to put 4-byte quantities on the stream!!  Reader must know that size is in long words."!

Item was changed:
+ ----- Method: DataStream>>writeBoolean: (in category 'private - write') -----
- ----- Method: DataStream>>writeBoolean: (in category 'write and read') -----
  writeBoolean: aBoolean
      "PRIVATE -- Write the contents of a Boolean.
       This method is now obsolete."
  
      byteStream nextPut: (aBoolean ifTrue: [1] ifFalse: [0])!

Item was changed:
+ ----- Method: DataStream>>writeByteArray: (in category 'private - write') -----
- ----- Method: DataStream>>writeByteArray: (in category 'write and read') -----
  writeByteArray: aByteArray
  	"PRIVATE -- Write the contents of a ByteArray."
  
  	byteStream nextNumber: 4 put: aByteArray size.
  	"May have to convert types here..."
  	byteStream nextPutAll: aByteArray.!

Item was changed:
+ ----- Method: DataStream>>writeClass: (in category 'private - write') -----
- ----- Method: DataStream>>writeClass: (in category 'write and read') -----
  writeClass: aClass
  	"Write out a DiskProxy for the class.  It will look up the class's name in Smalltalk in the new sustem.  Never write classes or methodDictionaries as objects.  For novel classes, front part of file is a fileIn of the new class."
  
  	"This method never executed because objectToStoreOnDataStream returns a DiskProxy.  See DataStream.nextPut:"
      ^ self error: 'Write a DiskProxy instead'!

Item was changed:
+ ----- Method: DataStream>>writeFalse: (in category 'private - write') -----
- ----- Method: DataStream>>writeFalse: (in category 'write and read') -----
  writeFalse: aFalse
      "PRIVATE -- Write the contents of a False."!

Item was changed:
+ ----- Method: DataStream>>writeFloat: (in category 'private - write') -----
- ----- Method: DataStream>>writeFloat: (in category 'write and read') -----
  writeFloat: aFloat
  	"PRIVATE -- Write the contents of a Float.
  	  We support 8-byte Floats here."
  
  	byteStream nextNumber: 4 put: (aFloat at: 1).
  	byteStream nextNumber: 4 put: (aFloat at: 2).
  !

Item was changed:
+ ----- Method: DataStream>>writeFloatString: (in category 'private - write') -----
- ----- Method: DataStream>>writeFloatString: (in category 'write and read') -----
  writeFloatString: aFloat
      "PRIVATE -- Write the contents of a Float string.
       This is the slow way to write a Float--via its string rep'n."
  
      self writeByteArray: (aFloat printString)!

Item was changed:
+ ----- Method: DataStream>>writeInstance: (in category 'private - write') -----
- ----- Method: DataStream>>writeInstance: (in category 'write and read') -----
  writeInstance: anObject
      "PRIVATE -- Write the contents of an arbitrary instance."
  
      ^ anObject storeDataOn: self!

Item was changed:
+ ----- Method: DataStream>>writeInteger: (in category 'private - write') -----
- ----- Method: DataStream>>writeInteger: (in category 'write and read') -----
  writeInteger: anInteger
  	"PRIVATE -- Write the contents of a SmallInteger."
  
  	byteStream nextInt32Put: anInteger	"signed!!!!!!!!!!"!

Item was changed:
+ ----- Method: DataStream>>writeNil: (in category 'private - write') -----
- ----- Method: DataStream>>writeNil: (in category 'write and read') -----
  writeNil: anUndefinedObject
      "PRIVATE -- Write the contents of an UndefinedObject."!

Item was changed:
+ ----- Method: DataStream>>writeRectangle: (in category 'private - write') -----
- ----- Method: DataStream>>writeRectangle: (in category 'write and read') -----
  writeRectangle: anObject
      "Write the contents of a Rectangle.  See if it can be a compact Rectangle (type=15).  Rectangles with values outside +/- 2047 were stored as normal objects (type=9).  17:22 tk"
  
  	| ok right bottom top left acc |
  	ok := true.
  	(right := anObject right) > 2047 ifTrue: [ok := false].
  	right < -2048 ifTrue: [ok := false].
  	(bottom := anObject bottom) > 2047 ifTrue: [ok := false].
  	bottom < -2048 ifTrue: [ok := false].
  	(top := anObject top) > 2047 ifTrue: [ok := false].
  	top < -2048 ifTrue: [ok := false].
  	(left := anObject left) > 2047 ifTrue: [ok := false].
  	left < -2048 ifTrue: [ok := false].
  	ok := ok & left isInteger & right isInteger & top isInteger & bottom isInteger.
  
  	ok ifFalse: [
  		byteStream skip: -1; nextPut: 9; skip: 0. "rewrite type to be normal instance"
  	    ^ anObject storeDataOn: self].
  
  	acc := ((left bitAnd: 16rFFF) bitShift: 12) + (top bitAnd: 16rFFF).
  	byteStream nextNumber: 3 put: acc.
  	acc := ((right bitAnd: 16rFFF) bitShift: 12) + (bottom bitAnd: 16rFFF).
  	byteStream nextNumber: 3 put: acc.!

Item was changed:
+ ----- Method: DataStream>>writeString: (in category 'private - write') -----
- ----- Method: DataStream>>writeString: (in category 'write and read') -----
  writeString: aString
  	"PRIVATE -- Write the contents of a String."
  
  	byteStream nextStringPut: aString.!

Item was changed:
+ ----- Method: DataStream>>writeStringOld: (in category 'private - write') -----
- ----- Method: DataStream>>writeStringOld: (in category 'write and read') -----
  writeStringOld: aString
  	"PRIVATE -- Write the contents of a String."
  
  	| length |
  	aString size < 16384 
  		ifTrue: [
  			(length := aString size) < 192
  				ifTrue: [byteStream nextPut: length]
  				ifFalse: 
  					[byteStream nextPut: (length // 256 + 192).
  					byteStream nextPut: (length \\ 256)].
  			aString do: [:char | byteStream nextPut: char asciiValue]]
  		ifFalse: [self writeByteArray: aString].	"takes more space"!

Item was changed:
+ ----- Method: DataStream>>writeSymbol: (in category 'private - write') -----
- ----- Method: DataStream>>writeSymbol: (in category 'write and read') -----
  writeSymbol: aSymbol
      "PRIVATE -- Write the contents of a Symbol."
  
      self writeString: aSymbol!

Item was changed:
+ ----- Method: DataStream>>writeTrue: (in category 'private - write') -----
- ----- Method: DataStream>>writeTrue: (in category 'write and read') -----
  writeTrue: aTrue
      "PRIVATE -- Write the contents of a True."!

Item was changed:
+ ----- Method: DataStream>>writeUser: (in category 'private - write') -----
- ----- Method: DataStream>>writeUser: (in category 'write and read') -----
  writeUser: anObject
      "Write the contents of an arbitrary User instance (and its devoted class)."
      " 7/29/96 tk"
  
  	"If anObject is an instance of a unique user class, will lie and say it has a generic class"
      ^ anObject storeDataOn: self!

Item was changed:
+ ----- Method: DataStream>>writeWordLike: (in category 'private - write') -----
- ----- Method: DataStream>>writeWordLike: (in category 'write and read') -----
  writeWordLike: aWordArray
  	"Note that we put the class name before the size."
  
  	self nextPut: aWordArray class name.
  	aWordArray writeOn: byteStream
  	"Note that this calls (byteStream nextPutAll: aBitmap) which knows enough to put 4-byte quantities on the stream!!  Reader must know that size is in long words or double-bytes."!



More information about the Squeak-dev mailing list