Cface__TypeCollector.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 12 Aug 2015 07:32:13 +0100
changeset 43 9327987437ae
parent 41 edb5e4849b79
permissions -rw-r--r--
Added mappings for LLVM C and LLVM C Extensions These are used to generate C callouts for jv:llvm_s project.

"{ Package: 'jv:cface' }"

"{ NameSpace: Cface }"

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

!TypeCollector class methodsFor:'documentation'!

history

    "Created: / 12-11-2007 / 08:41:12 / haja"
    "Created: #typeMap / 12-11-2007 / 08:43:31 / haja"
    "Created: #typeMap: / 12-11-2007 / 08:43:31 / haja"
    "Created: #parseTree / 12-11-2007 / 08:43:31 / haja"
    "Created: #parseTree: / 12-11-2007 / 08:43:31 / haja"
    "Created: #visitSequenceableCollection:with: / 12-11-2007 / 08:44:18 / haja"
    "Created: #visitConstNode: / 12-11-2007 / 08:44:23 / haja"
    "Created: #visitArrayNode: / 12-11-2007 / 08:44:23 / haja"
    "Created: #visitEnumFieldNode: / 12-11-2007 / 08:44:23 / haja"
    "Created: #visitEnumNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitFileNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitFunctionNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitPointerNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitStructFieldNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitStructNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitTypeDefNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitUnionFieldNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitUnionNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitParseTree: / 12-11-2007 / 08:44:24 / haja"
    "Created: #visitIdNode: / 12-11-2007 / 08:44:24 / haja"
    "Created: #initialize / 12-11-2007 / 08:45:48 / haja"
    "Created: #new / 12-11-2007 / 08:45:48 / haja"
    "Created: #on: / 12-11-2007 / 08:46:02 / haja"
    "Created: #find: / 12-11-2007 / 09:08:54 / haja"
    "Modified: #find: / 19-11-2007 / 09:48:44 / haja"
! !

!TypeCollector class methodsFor:'instance creation'!

new
    ^ self basicNew initialize.

    "Created: / 12-11-2007 / 08:45:48 / haja"
! !

!TypeCollector methodsFor:'accessing'!

typeMap
    ^ typeMap

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

!TypeCollector methodsFor:'initialization'!

initialize

    super initialize.
    typeMap := Dictionary new

    "Created: / 12-02-2008 / 22:55:40 / janfrog"
! !

!TypeCollector methodsFor:'visiting'!

visitCDerivedTypeNode: node

    | oldNode |
    oldNode := typeMap at: node cName ifAbsent:nil.
    oldNode
        ifNil:
            [typeMap at: node cName put: node]
        ifNotNil:
            [node isForeign ifFalse:
                [typeMap at: node cName put: node]]

    "Created: / 09-07-2008 / 20:46:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCEnumNode: anObject

    self visitCDerivedTypeNode: anObject

    "Created: / 12-02-2008 / 23:44:04 / janfrog"
    "Modified: / 04-07-2008 / 15:02:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCStructNode: anObject

    self visitCDerivedTypeNode: anObject

    "Created: / 12-02-2008 / 23:44:14 / janfrog"
    "Modified: / 04-07-2008 / 15:02:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCTypedefNode: node

    | oldNode |
    node cName = node type cName ifTrue:[^self].
    oldNode := typeMap at: node cName ifAbsent:nil.
    oldNode
        ifNil:
            [typeMap at: node cName put: node]
        ifNotNil:
            [node isForeign ifFalse:
                    [typeMap at: node cName put: node]]

    "Created: / 12-02-2008 / 22:55:53 / janfrog"
    "Modified: / 10-07-2008 / 20:10:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 06-07-2015 / 22:52:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

visitCUnionNode: anObject

    self visitCDerivedTypeNode: anObject

    "Created: / 12-02-2008 / 23:44:09 / janfrog"
    "Modified: / 04-07-2008 / 15:02:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!TypeCollector class methodsFor:'documentation'!

version
    ^ '$Id$'
!

version_SVN
    ^ '$Id$'
! !