[Vm-dev] VM Maker: VMMaker.oscog-eem.2347.mcz

Eliot Miranda eliot.miranda at gmail.com
Thu Mar 8 15:39:15 UTC 2018


Hi Levente,

> On Mar 7, 2018, at 3:44 PM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> 
>> On Wed, 7 Mar 2018, commits at source.squeak.org wrote:
>> 
>> Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
>> http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2347.mcz
>> 
> 
> snip
> 
>> 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 *'>
>> -    <var: 'cfile' type: 'void* '>
>>    <export: true>
>> +    writeFlag := interpreterProxy booleanValueOf: (interpreterProxy stackValue: 0).
>> -    writeFlag := interpreterProxy
>> -                booleanValueOf: (interpreterProxy stackValue: 0).
> 
> It should be checked here if the primitive has failed or not, shouldn't it?

Not necessarily.  All failures only set the failure code; they don't reset it.  So it is acceptable to gather a sequence of parameters and perform a single failure check.  The important thing is to check for failure before doing anything with the parameters.


> 
>>    cfileOop := interpreterProxy stackValue: 1.
>>    cfile := self pointerFrom: cfileOop.
>>    cfile ifNil:
>>        [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
>>    filePointer := self connectToFile: cfile write: writeFlag.
>>    interpreterProxy failed ifFalse: +        [interpreterProxy pop: 3 "rcvr, name, writeFlag"
>> +                            thenPush: filePointer]!
>> -        [^interpreterProxy pop: 3 "rcvr, name, writeFlag"
>> -                            thenPush: filePointer].
>> -    ^interpreterProxy primitiveFail.!
>> 
>> 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>
>> -    <var: 'fd' type: 'int'>
>>    <export: true>
>>    writeFlag := interpreterProxy
>>                booleanValueOf: (interpreterProxy stackValue: 0).
> 
> Same as above.
> 
> Levente
> 
>>    fdPointer := interpreterProxy stackValue: 1.
>>    (interpreterProxy isIntegerObject: fdPointer)
>>        ifFalse: [^ interpreterProxy primitiveFailFor: PrimErrBadArgument].
>>    fd := interpreterProxy integerValueOf: fdPointer.
>>    filePointer := self connectToFd: fd write: writeFlag.
>> +    interpreterProxy failed ifFalse:
>> +        [interpreterProxy pop: 3 "rcvr, name, writeFlag"
>> +                            thenPush: filePointer]!
>> -    interpreterProxy failed
>> -        ifFalse: [^interpreterProxy pop: 3 "rcvr, name, writeFlag"
>> -            thenPush: filePointer].
>> -    ^interpreterProxy primitiveFail.!


More information about the Vm-dev mailing list