[Vm-dev] VM Maker: VMMaker.oscog-VB.2382.mcz

Eliot Miranda eliot.miranda at gmail.com
Sat May 12 16:05:50 UTC 2018


Hi Vincent,

    I recently added some additional interpreter proxy methods for returning from primitives, so instead of

    interpreterProxy pop: 2.
    interpreterProxy pushInteger: fileType

you can say

    interpreterProxy methodReturnInteger: fileType

Andreas added methodReturnValue: many years ago.  It avoids having to know the argumentCount and avoids an extra call for the pop.

The full suite is:
    methodReturnBool: aCBool
    methodReturnFloat: aCFloat
    methodReturnInteger: aCInteger
    methodReturnString: aCString
    methodReturnValue: anOop

Let's try and use these wherever possible.

_,,,^..^,,,_ (phone)

> On May 10, 2018, at 2:59 PM, commits at source.squeak.org wrote:
> 
> 
> VincentBlondeau uploaded a new version of VMMaker to project VM Maker:
> http://source.squeak.org/VMMaker/VMMaker.oscog-VB.2382.mcz
> 
> ==================== Summary ====================
> 
> Name: VMMaker.oscog-VB.2382
> Author: VB
> Time: 10 May 2018, 3:58:47.518905 pm
> UUID: da8a5d36-0cd4-b641-865f-a139b3914245
> Ancestors: VMMaker.oscog-eem.2381
> 
> change the primitive to return the file descriptor type instead of just 0 or 1
> 
> =============== Diff against VMMaker.oscog-eem.2381 ===============
> 
> Item was added:
> + ----- Method: FilePlugin>>primitiveFileDescriptorType (in category 'file primitives') -----
> + primitiveFileDescriptorType
> +    | fileType fd fdPointer |
> +    "Allow to test if the standard input/output files are from a console or not
> +    Return values:
> +    * -1 - Error
> +    * 0 - no console (windows only)
> +    * 1 - normal terminal (unix terminal / windows console)
> +    * 2 - pipe
> +    * 3 - file
> +    * 4 - cygwin terminal (windows only)"
> +    <var: 'fd' type: #int>
> +    <export: true>
> +    fdPointer := interpreterProxy stackValue: 0.
> +    (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].
> +    fileType := self
> +                cCode: 'sqFileDescriptorType(fd)'
> +                inSmalltalk: [1].
> +    interpreterProxy pop: 2.
> +    interpreterProxy pushInteger: fileType!
> 
> Item was removed:
> - ----- Method: FilePlugin>>primitiveIsFileDescriptorATTY (in category 'file primitives') -----
> - primitiveIsFileDescriptorATTY
> -    | isStdoutRedirected fd fdPointer |
> -    <var: 'fd' type: #int>
> -    <export: true>
> -    fdPointer := interpreterProxy stackValue: 0.
> -    (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].
> -    isStdoutRedirected := self
> -                cCode: 'sqIsFileDescriptorATTY(fd) '
> -                inSmalltalk: [true].
> -    interpreterProxy pop: 2.
> -    interpreterProxy pushBool: isStdoutRedirected!
> 


More information about the Vm-dev mailing list