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

commits at source.squeak.org commits at source.squeak.org
Mon Jul 11 09:07:11 UTC 2011


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

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

Name: System-bf.446
Author: bf
Time: 11 July 2011, 11:06:25.328 am
UUID: e0bb3739-1ffb-4552-b95d-75e95f6033bf
Ancestors: System-ul.445

- provide methods to read image format from image file
- warn about saving in a different format

=============== Diff against System-ul.445 ===============

Item was changed:
  ----- Method: SmalltalkImage>>imageFormatVersion (in category 'image') -----
  imageFormatVersion
+ 	"Answer an integer identifying the type of image in memory. The image version number may
- 	"Answer an integer identifying the type of image. The image version number may
  	identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
  	of the image (e.g. block closure support required). This invokes an optional primitive
  	that may not be available on all virtual machines."
  
  	"Smalltalk image imageFormatVersion"
  
  	<primitive: 'primitiveImageFormatVersion'>
  	self notify: 'This virtual machine does not support the optional primitive #primitiveImageFormatVersion' translated.
  	^''!

Item was added:
+ ----- Method: SmalltalkImage>>imageFormatVersionFromFile (in category 'image') -----
+ imageFormatVersionFromFile
+ 	"Answer an integer identifying the type of image on file. The image version number may
+ 	identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
+ 	of the image (e.g. block closure support required)"
+ 
+ 	"Smalltalk image imageFormatVersionFromFile"
+ 
+ 	| format |
+ 	format := self imageFormatVersionFromFileAsIs.
+ 	^format <= 16r00FFFFFF
+ 		ifTrue: [  "same endianness as VM"
+ 			format ]
+ 		ifFalse: [ "convert endianness"
+ 			((format bitAnd: 16rFF000000) >> 24)
+ 			+ ((format bitAnd: 16r00FF0000) >> 8)
+ 			+ ((format bitAnd: 16r0000FF00) << 8)
+ 			+ ((format bitAnd: 16r000000FF) << 16)]!

Item was added:
+ ----- Method: SmalltalkImage>>imageFormatVersionFromFileAsIs (in category 'image') -----
+ imageFormatVersionFromFileAsIs
+ 	"Answer an integer identifying the type of image on file. The image version number may
+ 	identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
+ 	of the image (e.g. block closure support required). If the image file has a different
+ 	endianness than the VM, the format version will appear byte-swapped."
+ 
+ 	"Smalltalk image imageFormatVersionFromFileAsIs"
+ 
+ 	^(FileStream readOnlyFileNamed: Smalltalk imageName do: [ :file | file binary; next: 4 ])
+ 		unsignedLongAt: 1 bigEndian: Smalltalk isBigEndian!

Item was added:
+ ----- Method: SmalltalkImage>>okayToSave (in category 'snapshot and quit') -----
+ okayToSave
+ 	| wasCog isCog |
+ 	[wasCog := self imageFormatVersionFromFile allMask: 1]
+ 		on: Error do: [:ignore | "probably save-as to non-existing file" ^ true ].
+ 	isCog := Smalltalk isRunningCog.
+ 	^wasCog = isCog or: [
+ 		self confirm: 'Images saved under Cog cannot be opened on an interpreter again!!
+ Really save?']
+ !

Item was changed:
  ----- Method: SmalltalkImage>>saveAs: (in category 'sources, changes log') -----
  saveAs: newName
  	"Save the image  under that new name."
  	newName ifNil:[^ self].
+ 	self okayToSave ifFalse: [^self].
  	(SourceFiles at: 2) ifNotNil:
  		[self closeSourceFiles; "so copying the changes file will always work"
  			 saveChangesInFileNamed: (self fullNameForChangesNamed: newName)].
  	self saveImageInFileNamed: (self fullNameForImageNamed: newName)!

Item was changed:
  ----- Method: SmalltalkImage>>saveAsNewVersion (in category 'sources, changes log') -----
  saveAsNewVersion
  	"Save the image/changes using the next available version number."
  	"SmalltalkImage current saveAsNewVersion"
  	
  	| newName changesName aName anIndex |
+ 	self okayToSave ifFalse: [^self].
  	aName := FileDirectory baseNameFor: (FileDirectory default localNameFor: self imageName).
  	anIndex := aName lastIndexOf: FileDirectory dot asCharacter ifAbsent: [nil].
  	(anIndex notNil and: [(aName copyFrom: anIndex + 1 to: aName size) isAllDigits])
  		ifTrue:
  			[aName := aName copyFrom: 1 to: anIndex - 1].
  
  	newName := FileDirectory default nextNameFor: aName extension: FileDirectory imageSuffix.
  	changesName := self fullNameForChangesNamed: newName.
  
  	"Check to see if there is a .changes file that would cause a problem if we saved a new .image file with the new version number"
  	(FileDirectory default fileOrDirectoryExists: changesName)
  		ifTrue:
  			[^ self inform:
  'There is already .changes file of the desired name,
  ', newName, '
  curiously already present, even though there is
  no corresponding .image file.   Please remedy
  manually and then repeat your request.'].
  
  	(SourceFiles at: 2) ifNotNil:
  		[self closeSourceFiles; "so copying the changes file will always work"
  			saveChangesInFileNamed: (self fullNameForChangesNamed: newName)].
  	self saveImageInFileNamed: (self fullNameForImageNamed: newName)
  
  
  !

Item was changed:
  ----- Method: SmalltalkImage>>snapshot:andQuit: (in category 'snapshot and quit') -----
  snapshot: save andQuit: quit
+ 	(save and: [self okayToSave not]) ifTrue: [^self].
  	^self snapshot: save andQuit: quit embedded: false!



More information about the Packages mailing list