Cface__TypeResolver.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 17 Sep 2015 07:36:40 +0100
changeset 49 307d55f736ec
parent 41 edb5e4849b79
permissions -rw-r--r--
LLVM bindings: allow to specify path to llvm-config ..by setting LLVM_CONFIG variable when generating definitions for LLVM bindings. Example: make LVM_CONFIG=~/Projects/LLVM/sources1/build/Debug+Asserts/bin/llvm-config

"{ Package: 'jv:cface' }"

"{ NameSpace: Cface }"

CNodeVisitor subclass:#TypeResolver
	instanceVariableNames:'typeMap'
	classVariableNames:''
	poolDictionaries:''
	category:'Cface-Visitors'
!


!TypeResolver methodsFor:'accessing'!

typeMap
    ^ typeMap

    "Created: / 12-02-2008 / 23:44:35 / janfrog"
!

typeMap:something
    typeMap := something.

    "Created: / 12-02-2008 / 23:44:35 / janfrog"
! !

!TypeResolver methodsFor:'private'!

resolve: node
    node type isUnresolved ifTrue:[ 
        | type |

        type := typeMap at: node type cName ifAbsent:[ CPointerNode new type: CIntNode new ].
        node type: type
    ].

    "Created: / 06-07-2015 / 22:33:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TypeResolver methodsFor:'processing'!

process: aCNode

    typeMap := TypeCollector new
                    process: aCNode;
                    typeMap.
    ^super process: aCNode

    "Created: / 12-02-2008 / 23:48:03 / janfrog"
! !

!TypeResolver methodsFor:'visiting'!

visitCArgumentNode:anObject
    super visitCArgumentNode: anObject.
    self resolve: anObject.

    "Created: / 06-07-2015 / 22:33:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCArrayNode:anObject 
    super visitCArrayNode:anObject.
    self resolve: anObject

    "Created: / 06-07-2015 / 22:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCConstNode:anObject
    self visit: anObject type.
    self resolve: anObject

    "Created: / 06-07-2015 / 22:38:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCFunctionNode:anObject 
    super visitCFunctionNode:anObject.
    anObject return isUnresolved ifTrue:[ 
        | type |

        type := typeMap at: anObject return cName ifAbsent:[ CPointerNode new type: CIntNode new ].
        anObject return: type
    ].

    "Created: / 06-07-2015 / 22:49:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCFunctionTypeNode:anObject 
    super visitCFunctionTypeNode:anObject.
    anObject return isUnresolved ifTrue:[ 
        | type |

        type := typeMap at: anObject return cName ifAbsent:[ CPointerNode new type: CIntNode new ].
        anObject return: type
    ].

    "Created: / 06-07-2015 / 22:48:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCLongNode:anObject
    self assert: anObject type isUnresolved not.
    super visitCLongNode: anObject

    "Created: / 06-07-2015 / 22:37:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCPointerNode:anObject 
    super visitCPointerNode:anObject.
    self resolve: anObject

    "Created: / 06-07-2015 / 22:34:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCShortNode:anObject
    self assert: anObject type isUnresolved not.
    super visitCShortNode:anObject.

    "Created: / 06-07-2015 / 22:37:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCStructFieldNode:anObject 
    super visitCStructFieldNode:anObject.
    self resolve: anObject

    "Created: / 06-07-2015 / 22:39:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCTypedefNode: anObject
    super visitCTypedefNode: anObject.
    self resolve: anObject.

    "Created: / 05-09-2012 / 11:37:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 06-07-2015 / 22:46:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCUnsignedNode:anObject 
    self assert: anObject type isUnresolved not.
    super visitCUnsignedNode: anObject

    "Created: / 06-07-2015 / 22:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!TypeResolver class methodsFor:'documentation'!

version
    ^ '$Id$'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '$Id$'
! !