[Vm-dev] VM Maker: ImageFormat-dtl.50.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jan 10 20:38:14 UTC 2021


David T. Lewis uploaded a new version of ImageFormat to project VM Maker:
http://source.squeak.org/VMMaker/ImageFormat-dtl.50.mcz

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

Name: ImageFormat-dtl.50
Author: dtl
Time: 10 January 2021, 3:38:11.803376 pm
UUID: 13859148-5b61-4b2a-8b6b-7cf0cfdb74fe
Ancestors: ImageFormat-dtl.49

Provide ImageFileHeader class>>headerAndFlagsFrom: to read header from an image file and remember the endianness flag used during the read. Intended to enable ImageSnapshot to be instantiated from an image file as well as directly from a VM primitive.

=============== Diff against ImageFormat-dtl.49 ===============

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom: (in category 'instance creation') -----
+ headerAndFlagFrom: aStream
+ 	"Answer an array with new image file header and with boolean, true if
+ 	the image file in aStream was saved from a littleEndian machine."
+ 
+ 	^self headerAndFlagFrom: aStream startingAt: 0!

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom:startingAt: (in category 'instance creation') -----
+ headerAndFlagFrom: aStream startingAt: imageOffset
+ 	"Answer an array with new image file header and with boolean, true if
+ 	the image file in aStream was saved from a littleEndian machine."
+ 
+ 	^self headerAndFlagFrom: aStream startingAt: imageOffset into: OrderedCollection new!

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom:startingAt:into: (in category 'private') -----
+ headerAndFlagFrom: aStream startingAt: imageOffset into: aCollection
+ 	"Answer an array with new image file header and with boolean, true if
+ 	the image file in aStream was saved from a littleEndian machine."
+ 
+ 	| formatInfo imageFormat cls hdr remainder bytesRead |
+ 	formatInfo := self readImageVersionFrom: aStream startingAt: imageOffset.
+ 	imageFormat := formatInfo first.
+ 	aCollection add: imageFormat asInteger.
+ 	cls := self concreteClass: imageFormat.
+ 	hdr := cls new imageFormat: imageFormat.
+ 	bytesRead := hdr readFieldsFrom: aStream littleEndian: formatInfo second into: aCollection.
+ 	remainder := hdr headerSize - bytesRead.
+ 	self assert: remainder >= 0. "n.b. Mantis 7455 bug in original 64 bit image due to VMM error"
+ 	aStream next: (hdr headerSize - bytesRead).
+ 	^{ hdr fromEntryStream: aCollection readStream . formatInfo second }
+ !

Item was changed:
  ----- Method: ImageFileHeader class>>readFrom:startingAt:into: (in category 'private') -----
  readFrom: aStream startingAt: imageOffset into: aCollection
  
+ 	^(self headerAndFlagFrom: aStream startingAt: imageOffset into: aCollection) first
- 	| formatInfo imageFormat cls hdr remainder bytesRead |
- 	formatInfo := self readImageVersionFrom: aStream startingAt: imageOffset.
- 	imageFormat := formatInfo first.
- 	aCollection add: imageFormat asInteger.
- 	cls := self concreteClass: imageFormat.
- 	hdr := cls new imageFormat: imageFormat.
- 	bytesRead := hdr readFieldsFrom: aStream littleEndian: formatInfo second into: aCollection.
- 	remainder := hdr headerSize - bytesRead.
- 	self assert: remainder >= 0. "n.b. Mantis 7455 bug in original 64 bit image due to VMM error"
- 	aStream next: (hdr headerSize - bytesRead).
- 	^hdr fromEntryStream: aCollection readStream.
  !



More information about the Vm-dev mailing list