VM Maker: ImageFormat-dtl.21.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: ImageFormat-dtl.21.mcz

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

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

Name: ImageFormat-dtl.21
Author: dtl
Time: 11 April 2017, 7:58:26.661 am
UUID: 898bee4c-3f69-4c5b-8ad8-37ba97c2f0d1
Ancestors: ImageFormat-dtl.20

Add ImageFormat class>>unixMagiFileEntries to answer a string that can be appended to /etc/magic on a Unix system to support the file(1) utility. Based on magic decode by K K Subbu on vm-dev.

=============== Diff against ImageFormat-dtl.20 ===============

Item was added:
+ ----- Method: ImageFormat class>>unixMagicFileEntries (in category 'unix magic file entries') -----
+ unixMagicFileEntries
+ "Answer a string that can be appended to /etc/magic on a Unix system to support the file(1) utility"
+
+ "ImageFormat unixMagicFileEntries"
+
+ " | fs |
+ fs := FileStream newFileNamed: 'magic'.
+ [ fs nextPutAll: ImageFormat unixMagicFileEntries ]
+ ensure: [ fs close ] "
+
+ ^String streamContents: [:s |
+ s nextPutAll: '# Smalltalk image file formats'; lf.
+ KnownVersionNumbers do: [ :num | | fmt |
+ #( 'le' 'be' ) do: [ :endian |
+ fmt := self fromInteger: num.
+ (fmt is64Bit and: [ endian = 'be' ])
+ ifTrue: [ s nextPut: $4 ]
+ ifFalse: [ s nextPut: $0 ].
+ s tab;
+ nextPutAll: endian;
+ nextPutAll: 'long';
+ tab;
+ nextPutAll: num asString;
+ tab;
+ nextPutAll: 'Smalltalk '.
+ fmt printTerseDescriptionOn: s.
+ s lf
+ ]
+ ].
+ s lf.
+ ]!

Item was changed:
  ----- Method: ImageFormat>>printDescriptionOn: (in category 'printing') -----
  printDescriptionOn: stream
 
+ stream nextPutAll: 'a ';
+ nextPutAll: (wordSize * 8) asString;
+ nextPutAll: '-bit ';
+ nextPutAll: (self requiresSpurSupport
+ ifTrue: [ 'Spur' ]
+ ifFalse: [ 'V3' ]);
+ nextPutAll: ' image with '.
+ self requiresClosureSupport ifFalse: [stream nextPutAll: 'no '].
+ stream nextPutAll: 'closure support and '.
+ self requiresNativeFloatWordOrder
+ ifTrue: [stream nextPutAll: 'float words stored in native platform order']
+ ifFalse: [stream nextPutAll: 'no native platform float word order requirement'].
+ self requiresSpurSupport
+ ifTrue: [stream nextPutAll: ' using Spur object format'.
+ (self is64Bit and: [self requiresNewSpur64TagAssignment not])
+ ifTrue: [stream nextPutAll: ' (obsolete)']].
+ stream nextPutAll: ' (';
+ nextPutAll: self asInteger asString;
+ nextPut: $).
+ ^ stream
- stream nextPutAll: 'a ';
- nextPutAll: (wordSize * 8) asString;
- nextPutAll: '-bit image with '.
- self requiresClosureSupport ifFalse: [stream nextPutAll: 'no '].
- stream nextPutAll: 'closure support and '.
- self requiresNativeFloatWordOrder
- ifTrue: [stream nextPutAll: 'float words stored in native platform order']
- ifFalse: [stream nextPutAll: 'no native platform float word order requirement'].
- self requiresSpurSupport
- ifTrue: [stream nextPutAll: ' using Spur object format'.
- (self is64Bit and: [self requiresNewSpur64TagAssignment not])
- ifTrue: [stream nextPutAll: ' (obsolete)']].
- stream nextPutAll: ' (';
- nextPutAll: self asInteger asString;
- nextPut: $).
- ^ stream
  !

Item was added:
+ ----- Method: ImageFormat>>printTerseDescriptionOn: (in category 'printing') -----
+ printTerseDescriptionOn: stream
+ "Shortened description as may be required for unix magic file entries"
+
+ stream
+ nextPutAll: 'image ';
+ nextPutAll: (self requiresSpurSupport
+ ifTrue: [ 'Spur ' ]
+ ifFalse: [ 'V3 ' ]);
+ nextPutAll: (wordSize * 8) asString;
+ nextPutAll: '-bit '.
+ self requiresClosureSupport ifFalse: [stream nextPutAll: 'no '].
+ stream nextPutAll: 'closure '.
+ self requiresNativeFloatWordOrder
+ ifTrue: [stream nextPutAll: 'native float']
+ ifFalse: [stream nextPutAll: 'no native float'].
+ stream nextPutAll: ' (';
+ nextPutAll: self asInteger asString;
+ nextPut: $).
+ ^ stream
+ !