AbtCLangParser mishandles enum declarations

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

AbtCLangParser mishandles enum declarations

Richard Sargent
Administrator
AbtCLangParser thinks enums are pointers rather than integer types.

Parsing the following declarations yields a platform function of <c: pointer 'xyzzy':GciFloatKind double>.

typedef enum {
            GCI_FLOAT_KIND_INVALID,
            GCI_FLOAT_KIND_NORMAL,
            GCI_FLOAT_KIND_SUB_NORMAL,
            GCI_FLOAT_KIND_INFINITY,
            GCI_FLOAT_KIND_ZERO,
            GCI_FLOAT_KIND_QUIET_NAN,
            GCI_FLOAT_KIND_SIGNALLING_NAN
        } GciFloatKindEType;
GciFloatKindEType GciFloatKind(double aReal);


It appears AbtCEnumDeclarationTemplate should override some of its inherited methods. ... In particular, AbtCLangDeclarationTemplate>>#buildBasicAlignedTo:, where the following line of code are written:

                                    rsltType := (self is16Bit)
                                        ifTrue: [#AbtC16ThunkedPointerField] ifFalse: [#AbtCPointerField].


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: AbtCLangParser mishandles enum declarations

Richard Sargent
Administrator
The following changes appear to provide the correct outcome.


!AbtCLangDeclarationTemplate privateMethods !
buildBasicAlignedTo: anAlignmentBoundary
    "Private - Build a basic definition"    
    "04.13.93 twm"

    | rsltType |
     ^(instanceOfTypeDef == true )
                    ifTrue: [self buildNewInstanceOfTypeDefAlignedTo: anAlignmentBoundary ]
                    ifFalse: [
                            (baseType notNil)
                                ifTrue: [
                                    rsltType := ((baseType = #AbtCIntField) and: [self is16Bit])
                                        ifTrue: [#AbtCInt16Field] ifFalse: [baseType].
                                    rsltType := ((baseType = #AbtCPointerField) and: [self is16Bit])
                                        ifTrue: [#AbtC16ThunkedPointerField] ifFalse: [rsltType].
                                    rsltType := ((baseType = #AbtCUIntField) and: [self is16Bit])
                                        ifTrue: [#AbtCUInt16Field] ifFalse: [rsltType].

                                    (Smalltalk classAt: rsltType asSymbol ) new.
                                ]
                                ifFalse: [
                                    rsltType := self defaultResultType.
                                    (Smalltalk classAt: rsltType asSymbol ) new.
                                ]
                    ]
                   
! !

!AbtCLangDeclarationTemplate privateMethods !
defaultResultType
    "Private - Answer the result type when there is no explicit declaration"

     ^self is16Bit
        ifTrue: [#AbtC16ThunkedPointerField]
        ifFalse: [#AbtCPointerField].
! !

!AbtCEnumDeclarationTemplate privateMethods !
defaultResultType
    "Private - Answer the result type when there is no explicit declaration"

     ^self is16Bit
        ifTrue: [#AbtCInt16Field]
        ifFalse: [#AbtCIntField].
! !


On Wednesday, December 11, 2013 11:25:15 AM UTC-8, Richard Sargent wrote:
AbtCLangParser thinks enums are pointers rather than integer types.

Parsing the following declarations yields a platform function of <c: pointer 'xyzzy':GciFloatKind double>.

typedef enum {
            GCI_FLOAT_KIND_INVALID,
            GCI_FLOAT_KIND_NORMAL,
            GCI_FLOAT_KIND_SUB_NORMAL,
            GCI_FLOAT_KIND_INFINITY,
            GCI_FLOAT_KIND_ZERO,
            GCI_FLOAT_KIND_QUIET_NAN,
            GCI_FLOAT_KIND_SIGNALLING_NAN
        } GciFloatKindEType;
GciFloatKindEType GciFloatKind(double aReal);


It appears AbtCEnumDeclarationTemplate should override some of its inherited methods. ... In particular, AbtCLangDeclarationTemplate>>#buildBasicAlignedTo:, where the following line of code are written:

                                    rsltType := (self is16Bit)
                                        ifTrue: [#AbtC16ThunkedPointerField] ifFalse: [#AbtCPointerField].


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: AbtCLangParser mishandles enum declarations

dmacq
created case 53133

On Wednesday, December 11, 2013 2:42:54 PM UTC-5, Richard Sargent wrote:
The following changes appear to provide the correct outcome.


!AbtCLangDeclarationTemplate privateMethods !
buildBasicAlignedTo: anAlignmentBoundary
    "Private - Build a basic definition"    
    "04.13.93 twm"

    | rsltType |
     ^(instanceOfTypeDef == true )
                    ifTrue: [self buildNewInstanceOfTypeDefAlignedTo: anAlignmentBoundary ]
                    ifFalse: [
                            (baseType notNil)
                                ifTrue: [
                                    rsltType := ((baseType = #AbtCIntField) and: [self is16Bit])
                                        ifTrue: [#AbtCInt16Field] ifFalse: [baseType].
                                    rsltType := ((baseType = #AbtCPointerField) and: [self is16Bit])
                                        ifTrue: [#AbtC16ThunkedPointerField] ifFalse: [rsltType].
                                    rsltType := ((baseType = #AbtCUIntField) and: [self is16Bit])
                                        ifTrue: [#AbtCUInt16Field] ifFalse: [rsltType].

                                    (Smalltalk classAt: rsltType asSymbol ) new.
                                ]
                                ifFalse: [
                                    rsltType := self defaultResultType.
                                    (Smalltalk classAt: rsltType asSymbol ) new.
                                ]
                    ]
                   
! !

!AbtCLangDeclarationTemplate privateMethods !
defaultResultType
    "Private - Answer the result type when there is no explicit declaration"

     ^self is16Bit
        ifTrue: [#AbtC16ThunkedPointerField]
        ifFalse: [#AbtCPointerField].
! !

!AbtCEnumDeclarationTemplate privateMethods !
defaultResultType
    "Private - Answer the result type when there is no explicit declaration"

     ^self is16Bit
        ifTrue: [#AbtCInt16Field]
        ifFalse: [#AbtCIntField].
! !


On Wednesday, December 11, 2013 11:25:15 AM UTC-8, Richard Sargent wrote:
AbtCLangParser thinks enums are pointers rather than integer types.

Parsing the following declarations yields a platform function of <c: pointer 'xyzzy':GciFloatKind double>.

typedef enum {
            GCI_FLOAT_KIND_INVALID,
            GCI_FLOAT_KIND_NORMAL,
            GCI_FLOAT_KIND_SUB_NORMAL,
            GCI_FLOAT_KIND_INFINITY,
            GCI_FLOAT_KIND_ZERO,
            GCI_FLOAT_KIND_QUIET_NAN,
            GCI_FLOAT_KIND_SIGNALLING_NAN
        } GciFloatKindEType;
GciFloatKindEType GciFloatKind(double aReal);


It appears AbtCEnumDeclarationTemplate should override some of its inherited methods. ... In particular, AbtCLangDeclarationTemplate>>#buildBasicAlignedTo:, where the following line of code are written:

                                    rsltType := (self is16Bit)
                                        ifTrue: [#AbtC16ThunkedPointerField] ifFalse: [#AbtCPointerField].


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.