Cface__CPointerNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 10 Jul 2008 20:56:08 +0000
changeset 6 ae25dce94003
parent 5 c110eef5b9ef
child 9 03c7a764d2be
permissions -rw-r--r--
Added SVNMapping. Now it is able to parse libsvn.def

"{ Package: 'cvut:fel/cface' }"

"{ NameSpace: Cface }"

CTypeNode subclass:#CPointerNode
	instanceVariableNames:'type'
	classVariableNames:''
	poolDictionaries:''
	category:'Cface-C AST'
!

!CPointerNode class methodsFor:'documentation'!

history

    "Created: / 25-10-2007 / 16:58:14 / haja"
    "Created: #id / 25-10-2007 / 16:58:17 / haja"
    "Created: #id: / 25-10-2007 / 16:58:44 / haja"
    "Created: #acceptVisitor: / 02-11-2007 / 10:44:49 / haja"
    "Created: #acceptVisitorName: / 05-11-2007 / 17:30:59 / haja"
    "Created: #acceptNameVisitor: / 05-11-2007 / 17:32:41 / haja"
    "Deleted: #acceptVisitorName: / 05-11-2007 / 17:32:44 / haja"
    "Deleted: #acceptNameVisitor: / 12-11-2007 / 09:47:00 / haja"
    "Created: #buildTypeCheckFor:on: / 19-12-2007 / 15:06:43 / haja"
    "Created: #buildObjectCreationOn: / 19-12-2007 / 16:21:13 / haja"
    "Created: #buildValueExtractionFor:on: / 19-12-2007 / 17:08:44 / haja"
    "Created: #buildObjectCreationFor:on: / 19-12-2007 / 17:44:34 / haja"
    "Deleted: #buildObjectCreationOn: / 19-12-2007 / 17:44:36 / haja"
    "Created: #buildCTypeOn: / 19-12-2007 / 18:18:04 / haja"
    "Created: #buildTypeDEscriptionOn: / 20-12-2007 / 12:06:45 / haja"
    "Created: #buildTypeDescriptionOn: / 20-12-2007 / 12:06:49 / haja"
    "Deleted: #buildTypeDEscriptionOn: / 20-12-2007 / 12:06:51 / haja"
! !

!CPointerNode class methodsFor:'instance creation'!

id:anId

    | defPointerNode |

    defPointerNode := self new.
    defPointerNode id:anId.

    ^defPointerNode

    "Created: / 25-10-2007 / 16:58:44 / haja"
! !

!CPointerNode methodsFor:'accessing'!

cByteSize

    "
        Cface::CPointerNode new cByteSize       
    "

    %{
        return __MKSMALLINT(sizeof(void*));
    %}.
    ^4

    "Created: / 09-07-2008 / 19:36:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

ffiTypeSymbol
    "Superclass Cface::CTypeNode says that I am responsible to implement this method"
    
    (type isCCharNode) 
        ifTrue:[^#charPointer].
    ((type isCStructNode) 
        and:[type isAnonymous not
            and:[type isForeign not]])
                ifTrue:[^type smalltalkClassNameWithNamespace].

    ^#pointer

    "Created: / 03-07-2008 / 22:54:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 04-07-2008 / 11:43:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

smalltalkxValueExtractionSelector

    ^#doubleWordAt:

    "Created: / 09-07-2008 / 22:22:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

type
    ^ type

    "Created: / 10-02-2008 / 19:21:38 / janfrog"
!

type:something
    type := something.

    "Created: / 10-02-2008 / 19:21:38 / janfrog"
! !

!CPointerNode methodsFor:'builder'!

buildCTypeOn:aBuilder

    aBuilder pointerTo:[
        id buildCTypeOn:aBuilder.
    ].

    "Modified: / 19-12-2007 / 18:19:01 / haja"
!

buildObjectCreationFor:aVariable on:aBuilder

    (id references:IdNode) ifTrue:[
      (id names last = 'char') ifTrue:[
        ^aBuilder buildStringCreationFor:aVariable.
      ].
    ].

    (id references:CConstNode) ifTrue:[
      (id id references:IdNode) ifTrue:[
        (id id names last = 'char') ifTrue:[
          ^aBuilder buildStringCreationFor:aVariable.
        ].
      ].
    ].

    ^aBuilder buildPointerCreationFor:aVariable.

    "Created: / 19-12-2007 / 17:44:34 / haja"
    "Modified: / 10-02-2008 / 10:48:44 / janfrog"
!

buildTypeCheckFor:aVariable on:aBuilder

    (id references:IdNode) ifTrue:[
      (id names last = 'char') ifTrue:[
        ^aBuilder buildStringCheckFor:aVariable.
      ].
    ].

    (id references:CConstNode) ifTrue:[
      (id id references:IdNode) ifTrue:[
        (id id names last = 'char') ifTrue:[
          ^aBuilder buildStringCheckFor:aVariable.
        ].
      ].
    ].

    ^aBuilder buildPointerCheckFor:aVariable.

    "Created: / 19-12-2007 / 15:06:43 / haja"
    "Modified: / 10-02-2008 / 10:50:26 / janfrog"
!

buildTypeDescriptionOn:aBuilder

    aBuilder buildPointerTo:[
      id buildTypeDescriptionOn:aBuilder.
    ].

    "Created: / 20-12-2007 / 12:06:49 / haja"
!

buildValueExtractionFor:aVariable on:aBuilder

    (id references:IdNode) ifTrue:[
      (id names last = 'char') ifTrue:[
        ^aBuilder buildStringValueExtractionFor:aVariable.
      ].
    ].

    (id references:CConstNode) ifTrue:[
      (id id references:IdNode) ifTrue:[
        (id id names last = 'char') ifTrue:[
          ^aBuilder buildStringValueExtractionFor:aVariable.
        ].
      ].
    ].

    ^aBuilder buildPointerValueExtractionFor:aVariable.

    "Created: / 19-12-2007 / 17:08:44 / haja"
    "Modified: / 10-02-2008 / 10:50:31 / janfrog"
! !

!CPointerNode methodsFor:'printing'!

printOn: stream indent: indent

    stream 
        nextPutAll:'(pointer-to '; 
        cr;
        next: indent + 1 put: Character tab.

    type printOn: stream indent: indent + 1.
    stream nextPut:$)

    "Created: / 04-03-2008 / 10:57:12 / janfrog"
    "Modified: / 27-05-2008 / 12:15:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CPointerNode methodsFor:'testing'!

isCPointerNode
    ^ true

    "Created: / 17-02-2008 / 21:52:45 / janfrog"
!

isCPointerToCStructure

    ^type isCStructNode

    "Created: / 04-07-2008 / 15:11:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

isCPointerToChar

    ^type isCCharNode

    "Created: / 09-07-2008 / 21:37:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CPointerNode methodsFor:'visiting'!

acceptVisitor:aVisitor 
    "Double dispatch back to the visitor, passing my type encoded in
     the selector (visitor pattern)"
    "stub code automatically generated - please change if required"
    
    ^ aVisitor visitCPointerNode:self

    "Created: / 02-11-2007 / 10:44:49 / haja"
    "Modified: / 10-02-2008 / 10:45:24 / janfrog"
! !

!CPointerNode class methodsFor:'documentation'!

version
    ^ '$Header: /opt/data/cvs/cvut-fel/cface/Cface__CPointerNode.st,v 1.1 2008/02/26 15:58:16 vranyj1 Exp $'
! !