Cface__TypeMapper.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 06 Jul 2015 22:28:52 +0100
changeset 40 7d1e77b6115e
parent 39 5ff8fcdb5228
permissions -rw-r--r--
Renamed CUserDefinedTypeNode to CUnresolvedTypeNode. This is a preparation for new resolving code.

"{ Package: 'jv:cface' }"

"{ NameSpace: Cface }"

CNodeVisitor subclass:#TypeMapper
	instanceVariableNames:'mappings'
	classVariableNames:''
	poolDictionaries:''
	category:'Cface-Visitors'
!


!TypeMapper class methodsFor:'processing'!

process: cNode

    self error:'Use #process:using: instead'

    "Created: / 17-02-2008 / 20:56:59 / janfrog"
!

process: cNode using: mappings

    self new  mappings: mappings process: cNode

    "Created: / 17-02-2008 / 20:57:22 / janfrog"
    "Modified: / 18-02-2008 / 15:32:31 / janfrog"
! !

!TypeMapper methodsFor:'accessing'!

mappings
    ^ mappings

    "Created: / 17-02-2008 / 20:58:30 / janfrog"
!

mappings:aTypeMapping
    mappings := aTypeMapping.

    "Created: / 17-02-2008 / 20:58:30 / janfrog"
    "Modified: / 10-07-2008 / 08:01:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!TypeMapper methodsFor:'processing'!

process: definitions

    mappings ifNil:[^self error:'No mappings provided!!'].
    mappings definitions: definitions.
    super process: definitions

    "Created: / 18-02-2008 / 15:33:19 / janfrog"
    "Modified: / 22-02-2009 / 22:16:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

process: definitions using: givenMappings

    self mappings: givenMappings.
    self process: definitions

    "Created: / 18-02-2008 / 15:34:07 / janfrog"
! !

!TypeMapper methodsFor:'visiting'!

visitCEnumNode:cEnum

    cEnum shouldBeIgnored ifFalse:[
        cEnum
            smalltalkNamespace:(mappings smalltalkNamespaceForEnum: cEnum);
            smalltalkPackage:(mappings smalltalkPackage);
            smalltalkClassName:(mappings smalltalkClassNameForEnum:cEnum);
            smalltalkCategory: (mappings smalltalkCategoryForEnum: cEnum)
    ].
    super visitCEnumNode:cEnum.
    cEnum shouldBeIgnored ifFalse:
        [cEnum ignore: (mappings shouldIgnoreEnum: cEnum)].

    "Created: / 17-02-2008 / 20:58:53 / janfrog"
    "Modified: / 17-02-2008 / 22:24:58 / janfrog"
    "Modified: / 22-02-2009 / 22:14:09 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCEnumValueNode:cEnum 
    cEnum
        smalltalkName:(mappings smalltalkNameForEnumValue:cEnum).
    super visitCEnumValueNode:cEnum

    "Created: / 17-02-2008 / 21:02:21 / janfrog"
    "Modified: / 04-07-2008 / 11:33:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCFunctionNode:cFunction

    cFunction
            kind:(mappings kindForFunction:cFunction);
            smalltalkNamespace:(mappings smalltalkNamespaceForFunction: cFunction);
            smalltalkClassName:(mappings smalltalkClassNameForFunction:cFunction);
            smalltalkSelector:(mappings smalltalkSelectorForFunction:cFunction).
    super visitCFunctionNode:cFunction

    "Created: / 17-02-2008 / 22:10:44 / janfrog"
    "Modified: / 22-02-2009 / 22:14:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCStructFieldNode: cEnum

    cEnum
        smalltalkName: (mappings smalltalkNameForStructField: cEnum).
    super visitCStructFieldNode: cEnum

    "Created: / 17-02-2008 / 21:22:53 / janfrog"
!

visitCStructNode:cStruct


    cStruct shouldBeIgnored ifFalse:[
        cStruct
            smalltalkNamespace:(mappings smalltalkNamespaceForStruct: cStruct);
            smalltalkPackage:(mappings smalltalkPackage);
            smalltalkClassName:(mappings smalltalkClassNameForStruct:cStruct);
            smalltalkCategory: (mappings smalltalkCategoryForStruct: cStruct)
    ].
    super visitCStructNode:cStruct.
    cStruct shouldBeIgnored ifFalse:
        [cStruct ignore: (mappings shouldIgnoreStruct: cStruct)].

    "Created: / 17-02-2008 / 21:12:55 / janfrog"
    "Modified: / 17-02-2008 / 22:24:51 / janfrog"
    "Modified: / 22-02-2009 / 22:14:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

visitCTypedefNode:cTypedefNode

    cTypedefNode shouldBeIgnored ifFalse:[
        cTypedefNode
            smalltalkNamespace:(mappings smalltalkNamespaceForTypedef: cTypedefNode);
            smalltalkPackage:(mappings smalltalkPackage);
            smalltalkClassName:(mappings smalltalkClassNameForTypedef:cTypedefNode);
            smalltalkCategory: (mappings smalltalkCategoryForTypedef: cTypedefNode)
    ].
    super visitCTypedefNode:cTypedefNode.
    cTypedefNode shouldBeIgnored ifFalse:
        [cTypedefNode ignore: (mappings shouldIgnoreTypedef: cTypedefNode)].

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

visitCUnionNode:cUnion


    cUnion shouldBeIgnored ifFalse:[
        cUnion
            smalltalkNamespace:(mappings smalltalkNamespaceForUnion: cUnion);
            smalltalkPackage:  (mappings smalltalkPackage);
            smalltalkClassName:(mappings smalltalkClassNameForUnion:cUnion);
            smalltalkCategory: (mappings smalltalkCategoryForUnion: cUnion)
    ].
    super visitCUnionNode:cUnion.
    cUnion shouldBeIgnored ifFalse:
        [cUnion ignore: (mappings shouldIgnoreUnion: cUnion)].

    "Created: / 17-02-2008 / 22:25:27 / janfrog"
    "Modified: / 22-02-2009 / 22:14:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!TypeMapper class methodsFor:'documentation'!

version
    ^ '$Id$'
!

version_SVN
    ^ '$Id$'
! !