[Vm-dev] VM Maker: VMMaker-dtl.400.mcz

commits at source.squeak.org commits at source.squeak.org
Fri May 3 22:11:35 UTC 2019


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

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

Name: VMMaker-dtl.400
Author: dtl
Time: 3 May 2019, 6:11:26.389 pm
UUID: 0059fd36-12f0-441c-b743-56b947d9cae9
Ancestors: VMMaker-dtl.398

VMMaker 4.16.6 - Better error message when interpreter encounters an unsupported image format.

Instead of this:
This interpreter (vers. 0) cannot read image file (vers. 68021).
Press CR to quit...

Say this:
This interpreter supports image formats up to 6505, cannot read file format 68021

=============== Diff against VMMaker-dtl.398 ===============

Item was changed:
  ----- Method: ContextInterpreter>>checkImageVersionFrom:startingAt: (in category 'image save/restore') -----
  checkImageVersionFrom: f startingAt: imageOffset
  	"Read and verify the image file version number and return true if the the given image file needs to be byte-swapped. As a side effect, position the file stream just after the version number of the image header. This code prints a warning and does a hard-exit if it cannot find a valid version number."
  	"This code is based on C code by Ian Piumarta."
  
  	| firstVersion |
  	<var: #f type: 'sqImageFile '>
  	<var: #imageOffset type: 'squeakFileOffsetType '>
  
  	"check the version number"
  	self sqImageFile: f Seek: imageOffset.
  	imageFormatInitialVersion := firstVersion := self getLongFromFile: f swap: false.
  	(self readableFormat: imageFormatInitialVersion) ifTrue: [^ false].
  
  	"try with bytes reversed"
  	self sqImageFile: f Seek: imageOffset.
  	imageFormatInitialVersion := self getLongFromFile: f swap: true.
  	(self readableFormat: imageFormatInitialVersion) ifTrue: [^ true].
  
  	"Note: The following is only meaningful if not reading an embedded image"
  	imageOffset = 0 ifTrue:[
  		"try skipping the first 512 bytes (prepended by certain Mac file transfer utilities)"
  		self sqImageFile: f Seek: 512.
  		imageFormatInitialVersion := self getLongFromFile: f swap: false.
  		(self readableFormat: imageFormatInitialVersion) ifTrue: [^ false].
  
  		"try skipping the first 512 bytes with bytes reversed"
  		self sqImageFile: f Seek: 512.
  		imageFormatInitialVersion := self getLongFromFile: f swap: true.
  		(self readableFormat: imageFormatInitialVersion) ifTrue: [^ true]].
  
  	"hard failure; abort"
+ 	self printVersionWarning: firstVersion.
- 	self print: 'This interpreter (vers. '.
- 	self printNum: self imageFormatVersion.
- 	self print: ') cannot read image file (vers. '.
- 	self printNum: firstVersion.
- 	self print: ').'.
- 	self cr.
- 	self print: 'Press CR to quit...'.
- 	self getchar.
  	self ioExit.
  !

Item was removed:
- ----- Method: ContextInterpreter>>imageFormatBackwardCompatibilityVersion (in category 'image save/restore') -----
- imageFormatBackwardCompatibilityVersion
- 	"This VM is backwards-compatible with the immediately preceeding pre-closure version, and will allow loading images (or image segments) of that version."
- 
- 	objectMemory bytesPerWord == 4
- 		ifTrue: [^6502]
- 		ifFalse: [^68000]!

Item was added:
+ ----- Method: Interpreter>>imageFormatSupportableVersion (in category 'image save/restore') -----
+ imageFormatSupportableVersion
+ 	"Answer the most recent image format version that can be supported by this
+ 	interpreter.. The image may be saved as a different format. For example, format
+ 	6505 has different float byte ordering and can be loaded by the interpreter
+ 	for 32 bit images, but that same image will be stored in the 6504 format. Thus
+ 	a 6505 format image may be loaded and run, then saved in format 6504."
+ 
+ 	objectMemory bytesPerWord == 4
+ 		ifTrue: [^6505]
+ 		ifFalse: [^68003]!

Item was added:
+ ----- Method: Interpreter>>printVersionWarning: (in category 'image save/restore') -----
+ printVersionWarning: formatNumber
+ 	self print: 'This interpreter supports image formats up to '.
+ 	self printNum: self imageFormatSupportableVersion.
+ 	self print: ', cannot read file format '.
+ 	self printNum: formatNumber.
+ 	self cr.
+ 	self ioExit.
+ !

Item was changed:
  ----- Method: StackInterpreter>>checkImageVersionFrom:startingAt: (in category 'image save/restore') -----
  checkImageVersionFrom: f startingAt: imageOffset
  	"Read and verify the image file version number and return true if the the given image file needs to be byte-swapped. As a side effect, position the file stream just after the version number of the image header. This code prints a warning and does a hard-exit if it cannot find a valid version number."
  	"This code is based on C code by Ian Piumarta."
  
  	| version firstVersion |
  	<var: #f type: 'sqImageFile '>
  	<var: #imageOffset type: 'squeakFileOffsetType '>
  
  	"check the version number"
  	self sqImageFile: f Seek: imageOffset.
  	version := firstVersion := self getLongFromFile: f swap: false.
  	(self readableFormat: version) ifTrue: [^ false].
  
  	"try with bytes reversed"
  	self sqImageFile: f Seek: imageOffset.
  	version := self getLongFromFile: f swap: true.
  	(self readableFormat: version) ifTrue: [^ true].
  
  	"Note: The following is only meaningful if not reading an embedded image"
  	imageOffset = 0 ifTrue:[
  		"try skipping the first 512 bytes (prepended by certain Mac file transfer utilities)"
  		self sqImageFile: f Seek: 512.
  		version := self getLongFromFile: f swap: false.
  		(self readableFormat: version) ifTrue: [^ false].
  
  		"try skipping the first 512 bytes with bytes reversed"
  		self sqImageFile: f Seek: 512.
  		version := self getLongFromFile: f swap: true.
  		(self readableFormat: version) ifTrue: [^ true]].
  
  	"hard failure; abort"
+ 	self printVersionWarning: firstVersion.
- 	self print: 'This interpreter (vers. '.
- 	self printNum: self imageFormatVersion.
- 	self print: ') cannot read image file (vers. '.
- 	self printNum: firstVersion.
- 	self print: ').'.
- 	self cr.
- 	self print: 'Press CR to quit...'.
- 	self getchar.
  	self ioExitWithErrorCode: 1.
  	^false!

Item was changed:
  ----- Method: VMMaker class>>versionString (in category 'version testing') -----
  versionString
  
  	"VMMaker versionString"
  
+ 	^'4.16.6'!
- 	^'4.16.5'!



More information about the Vm-dev mailing list