VM Maker: VMMaker.oscog-VB.2382.mcz

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

VM Maker: VMMaker.oscog-VB.2382.mcz

commits-2
 
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!

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-VB.2382.mcz

Eliot Miranda-2
 
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, [hidden email] 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!
>
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-VB.2382.mcz

Vincent.Blondeau
 
Hi Eliot,

Indeed, it is a better approach! I wasn't aware of it. I made the changes in the FilePlugin to use these methods

Thanks!

Vincent

-----Original Message-----
From: Vm-dev [mailto:[hidden email]] On Behalf Of Eliot Miranda
Sent: Saturday, May 12, 2018 9:06
To: [hidden email]
Subject: Re: [Vm-dev] VM Maker: VMMaker.oscog-VB.2382.mcz

 
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, [hidden email] wrote:
>
>
> VincentBlondeau uploaded a new version of VMMaker to project VM Maker:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__source.squeak.org_
> VMMaker_VMMaker.oscog-2DVB.2382.mcz&d=DwIGaQ&c=RWI7EqL8K9lqtga8KxgfzvO
> Yoob76EZWE0yAO85PVMQ&r=kIZIYXBAA3fhM7P5HOuTC5w6mnEApTfXPTq3lR34ZiY&m=d
> Zqlj98PpFJXlE-y8z3Ggo2qH8yMwMhBLjkuMFacpho&s=08aBosQ43JbmvHuVOsUnTbtfk
> 2saGfkZks5h2ciKiLc&e=
>
> ==================== 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!
>