[Vm-dev] VM Maker: VMMaker.oscog-akg.2355.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Mar 11 14:58:00 UTC 2018


Alistair Grant uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-akg.2355.mcz

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

Name: VMMaker.oscog-akg.2355
Author: akg
Time: 11 March 2018, 11:57:52.862772 am
UUID: d1662a93-b149-43b7-93a8-066836b2239c
Ancestors: VMMaker.oscog-ul.2354

FilePlugin status checks and type declaration

Tidy up FilePlugin error checking and use of symbols for declaring variable types in:

- #fileValueOf:
- #pointerFrom:
- #primitiveConnectToFile
- #primitiveConnectToFileDescriptor

Note that some of these methods are still not simulator friendly.  Tidying up these is still on my ToDo list (after learning how to run the simulator).

=============== Diff against VMMaker.oscog-ul.2354 ===============

Item was changed:
  ----- Method: FilePlugin>>fileValueOf: (in category 'file primitives') -----
  fileValueOf: objectPointer
  	"Return a pointer to the first byte of of the file record within the given Smalltalk object, or nil if objectPointer is not a file record."
+ 	<returnTypeC: #'SQFile *'>
- 	<returnTypeC: 'SQFile *'>
  	<static: false>
  	(((interpreterProxy isBytes: objectPointer) and:
  		 [(interpreterProxy byteSizeOf: objectPointer) = self fileRecordSize]))
  			ifFalse:[interpreterProxy primitiveFail. ^nil].
  	^interpreterProxy firstIndexableField: objectPointer!

Item was changed:
  ----- Method: FilePlugin>>pointerFrom: (in category 'private') -----
  pointerFrom: pointerByteArray
  	"Answer the machine address contained in anExternalAddressOop."
  
  	| ptr addressUnion idx |
+ 	<returnTypeC: #'void *'>
+ 	<var: 'ptr' type: #'unsigned char *'>
+ 	<var: 'addressUnion' type: #'union {void *address; unsigned char bytes[sizeof(void *)];}'>
- 	<returnTypeC: 'void *'>
- 	<var: 'ptr' type: 'unsigned char *'>
- 	<var: 'addressUnion' type: 'union {void *address; unsigned char bytes[sizeof(void *)];}'>
  	((interpreterProxy is: pointerByteArray KindOf: 'ByteArray') and:
  		[(interpreterProxy stSizeOf: pointerByteArray) = self sizeOfPointer])
+ 		ifFalse: [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
- 		ifFalse: [^ nil].
  	ptr := interpreterProxy arrayValueOf: pointerByteArray.
+ 	interpreterProxy failed ifTrue: [^nil].
  	idx := 0.
  	[idx < self sizeOfPointer] whileTrue:
  		[self cCode: 'addressUnion.bytes[idx] = ptr[idx]'.
  		idx := idx + 1].
  	^ self cCode: 'addressUnion.address' inSmalltalk: [addressUnion]
  !

Item was changed:
  ----- Method: FilePlugin>>primitiveConnectToFile (in category 'file primitives') -----
  primitiveConnectToFile
  	"Connect to the file with the supplied FILE* and writeFlag.
  	FILE* must be supplied in a byte object (ByteArray) with the platform address size.
  	writeFlag must be a boolean and compatible with the existing file access."
  	| writeFlag cfileOop cfile filePointer |
  	<var: 'cfile' type: #'void *'>
  	<export: true>
  	writeFlag := interpreterProxy booleanValueOf: (interpreterProxy stackValue: 0).
  	cfileOop := interpreterProxy stackValue: 1.
  	cfile := self pointerFrom: cfileOop.
+ 	interpreterProxy failed ifTrue: [
+ 		"Ensure that the appropriate failure code has been set"
+ 		^interpreterProxy primitiveFailFor: PrimErrBadArgument].
- 	cfile ifNil:
- 		[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	filePointer := self connectToFile: cfile write: writeFlag.
  	interpreterProxy failed ifFalse: 
  		[interpreterProxy pop: 3 "rcvr, name, writeFlag"
  							thenPush: filePointer]!

Item was changed:
  ----- Method: FilePlugin>>primitiveConnectToFileDescriptor (in category 'file primitives') -----
  primitiveConnectToFileDescriptor
  	"Connect to the existing file identified by fileDescriptor.
  	fileDescriptor must be an integer.
  	writeFlag is aboolean indicating whether to open in read or write mode and must be compatible with the existing file access."
  	| writeFlag fdPointer fd filePointer |
  	<var: 'fd' type: #int>
  	<export: true>
+ 	writeFlag := interpreterProxy booleanValueOf: (interpreterProxy stackValue: 0).
- 	writeFlag := interpreterProxy
- 				booleanValueOf: (interpreterProxy stackValue: 0).
  	fdPointer := interpreterProxy stackValue: 1.
  	(interpreterProxy isIntegerObject: fdPointer)
  		ifFalse: [^ interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	fd := interpreterProxy integerValueOf: fdPointer.
+ 	interpreterProxy failed ifTrue: [
+ 		"Ensure that the appropriate failure code has been set"
+ 		^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	filePointer := self connectToFd: fd write: writeFlag.
  	interpreterProxy failed ifFalse:
  		[interpreterProxy pop: 3 "rcvr, name, writeFlag"
  							thenPush: filePointer]!



More information about the Vm-dev mailing list