Cface__CFunctionNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 03 Jul 2008 22:00:07 +0000
changeset 2 cfd2c393abfe
parent 1 b6c0180314d1
child 5 c110eef5b9ef
permissions -rw-r--r--
Smalltalk/X generator improvements: - generate C enums as SharedPools with accessors - generate externa function calls using FFI. Not yet finished! - CairoMappings improved.

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

"{ NameSpace: Cface }"

CDefinitionNode subclass:#CFunctionNode
	instanceVariableNames:'smalltalkClass smalltalkNamespace arguments return kind'
	classVariableNames:''
	poolDictionaries:''
	category:'Cface-C AST'
!

!CFunctionNode class methodsFor:'documentation'!

history

    "Created: / 25-10-2007 / 14:39:30 / haja"
    "Created: #name / 25-10-2007 / 14:39:35 / haja"
    "Created: #name: / 25-10-2007 / 14:39:35 / haja"
    "Created: #arguments / 25-10-2007 / 14:39:35 / haja"
    "Created: #arguments: / 25-10-2007 / 14:39:35 / haja"
    "Created: #return / 25-10-2007 / 14:39:35 / haja"
    "Created: #return: / 25-10-2007 / 14:39:35 / haja"
    "Created: #name:arguments:return: / 25-10-2007 / 14:41:52 / haja"
    "Created: #acceptVisitor: / 02-11-2007 / 10:44:22 / haja"
    "Created: #acceptNameVisitor: / 05-11-2007 / 17:41:59 / haja"
    "Deleted: #acceptNameVisitor: / 12-11-2007 / 09:46:47 / haja"
! !

!CFunctionNode methodsFor:'accessing'!

arguments
    ^ arguments

    "Created: / 25-10-2007 / 14:39:35 / haja"
!

arguments:something
    arguments := something.

    "Created: / 25-10-2007 / 14:39:35 / haja"
!

kind
    ^ kind ? #static

    "Created: / 01-03-2008 / 20:30:22 / janfrog"
    "Modified: / 04-03-2008 / 10:57:12 / janfrog"
!

kind:aSymbol

    self 
        assert:(#(static method) includes: aSymbol)
        message:'kind must be one of #static or #method'.
    
    kind := aSymbol.

    "Created: / 01-03-2008 / 20:30:22 / janfrog"
    "Modified: / 04-03-2008 / 10:57:12 / janfrog"
    "Modified: / 03-07-2008 / 22:06:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

priority

    ^25

    "Created: / 17-02-2008 / 18:00:13 / janfrog"
!

return
    ^ return

    "Created: / 25-10-2007 / 14:39:35 / haja"
!

return:something
    return := something.

    "Created: / 25-10-2007 / 14:39:35 / haja"
!

smalltalkClass
    ^ smalltalkClass

    "Created: / 17-02-2008 / 20:54:34 / janfrog"
!

smalltalkClass:something
    smalltalkClass := something.

    "Created: / 17-02-2008 / 20:54:34 / janfrog"
!

smalltalkClassNameWithNamespace

    ^self smalltalkNamespace isNilOrEmptyCollection
        ifTrue:[self smalltalkClass]
        ifFalse:[self smalltalkNamespace , '::' , (self smalltalkClass ? #ExternalFunctions)]

    "Created: / 03-07-2008 / 21:27:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 03-07-2008 / 22:57:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

smalltalkNamespace
    ^ smalltalkNamespace

    "Created: / 17-02-2008 / 20:54:34 / janfrog"
!

smalltalkNamespace:something
    smalltalkNamespace := something.

    "Created: / 17-02-2008 / 20:54:34 / janfrog"
!

smalltalkSelector

    ^smalltalkName

    "Created: / 17-02-2008 / 22:12:23 / janfrog"
!

smalltalkSelector:aSymbol
    smalltalkName := aSymbol

    "Created: / 17-02-2008 / 22:12:14 / janfrog"
! !

!CFunctionNode methodsFor:'printing'!

printOn: stream indent: level

    self smalltalkNamespace ifNotNil:
        [stream nextPutAll:';; Namespace: '; nextPutAll: self smalltalkNamespace; cr; next: level put: Character tab].
    self smalltalkClass ifNotNil:
        [stream nextPutAll:';; Class: '; nextPutAll: self smalltalkClass; cr; next: level put: Character tab].
    self smalltalkClass ifNotNil:
        [stream nextPutAll:';; Selector: '; nextPutAll: self smalltalkSelector; cr; next: level put: Character tab].
    self smalltalkClass ifNotNil:
        [stream nextPutAll:';; Kind: '; nextPutAll: self kind; cr; next: level put: Character tab].


    stream 
        nextPutAll:'(function '; nextPutAll:self cName; cr;
        next: level + 1 put: Character tab.

    arguments do:
        [:argNode|argNode printOn: stream indent: level + 1.
        stream cr; next: level + 1 put: Character tab].

    stream
        next: level + 1 put: Character tab.
    return printOn: stream indent: level + 1.

    stream nextPut:$); cr.

    "Created: / 18-02-2008 / 14:27:37 / janfrog"
    "Modified: / 04-03-2008 / 10:57:11 / janfrog"
    "Modified: / 03-07-2008 / 22:10:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CFunctionNode methodsFor:'testing'!

isCFunctionNode
    ^ true

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

!CFunctionNode 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 visitCFunctionNode:self

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

!CFunctionNode class methodsFor:'documentation'!

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