Cface__LLVM_C.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 17 Sep 2015 07:36:40 +0100
changeset 49 307d55f736ec
parent 48 a5c898296427
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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'jv:cface' }"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Cface }"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
TypeMapping subclass:#LLVM_C
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Cface-Mappings'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
!LLVM_C class methodsFor:'documentation'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
documentation
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
    Mappings for LLVM C API. Used to generate C callouts
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    for jv:llvm_s project.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
    [author:]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
        Jan Vrany <jan.vrany@fit.cvut.cz>
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
    [instance variables:]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
    [class variables:]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
    [see also:]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
        https://bitbucket.org/janvrany/jv-llvm-s/
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
!LLVM_C class methodsFor:'generating'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
generate
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
    |llvmcDir llvmcDef|
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
    llvmcDir := (Smalltalk getPackageDirectoryForPackage: 'jv:cface') / 'resources'/'examples'/'llvm-c'.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    llvmcDef := llvmcDir / 'llvm-c.def'.  
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
    ^Cface::Platform theInstance generatorCommand
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
        definitions: llvmcDef asFilename;
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
        mappings: self new;
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
        process
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    "Created: / 06-07-2015 / 06:53:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    "Modified: / 12-08-2015 / 06:54:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
!LLVM_C methodsFor:'accessing'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
46
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    51
definitions:definitionFile
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    52
    super definitions:definitionFile.
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    53
48
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    54
    "/ A hack to map LLVMBool to #bool FFI type
46
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    55
    definitionFile definitions do:[:each | 
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    56
        (each isKindOf: CTypedefNode) ifTrue:[
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    57
            each cName = 'LLVMBool' ifTrue:[ 
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    58
                each type: CBoolNode new 
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    59
            ].                                           
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    60
        ]
48
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    61
    ].
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    62
    "/ A hack to change return type of all LLVMIsAXXX() functions
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    63
    "/ to bool (this avoids an extra allocation & nil test)
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    64
    definitionFile definitions do:[:each | 
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    65
        (each isKindOf: CFunctionNode) ifTrue:[
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    66
            (each cName startsWith: 'LLVMIsA') ifTrue:[
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    67
                each return: CBoolNode new
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    68
            ]
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    69
        ]
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    70
    ].
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    71
    "/ A hack to make all LLVMPrintXXXToString() to return
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    72
    "/ generic pointer. This is necessary as we need the pointer
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    73
    "/ in Smalltalk code to later invoke LLVMDisposeMessage()
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    74
    definitionFile definitions do:[:each | 
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    75
        (each isKindOf: CFunctionNode) ifTrue:[
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    76
            ((each cName startsWith: 'LLVMPrint') and:[each cName endsWith: 'ToString']) ifTrue:[
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    77
                each return: (CPointerNode new type: (CPointerNode new type: CVoidNode new))
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    78
            ]
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    79
        ]
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    80
    ].
46
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    81
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    82
    "Created: / 14-08-2015 / 11:13:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
48
a5c898296427 LLVM bindings: Updated LLVM_C mappings for LLVMIsAXXX() and LLVMPrintXXXToString() functions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    83
    "Modified: / 16-09-2015 / 06:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
46
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    84
!
cc6b765ad420 Fix in LLVM C API and C API Extensions mappings: map LLVMBool to #bool FFI type. Correctly map LLVMModuleRef to LLVMModule.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 44
diff changeset
    85
43
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
smalltalkPackage
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
    ^#'jv:llvm_s'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    "Created: / 03-07-2008 / 21:14:47 / Jan Vrany <vranyj1@fel.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    "Modified: / 12-08-2015 / 06:56:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
smalltalkSelectorForFunction: cFunction
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    ^String streamContents:
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
        [:s|
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
        | nm |
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
        nm := cFunction cName.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
        (nm startsWith:'LLVM') ifTrue:[ 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
            nm := nm copyFrom: 5.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
        ] ifFalse:[ 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
            nm := nm copy.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
        ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
        s nextPutAll:nm.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
        cFunction arguments notEmptyOrNil ifTrue:
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
            [s nextPut:$:].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
        cFunction arguments size > 1 ifTrue:
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
            [(cFunction arguments copyFrom:2) do:
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
                [:argument|
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
                s 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
                    nextPutAll: '_:']]]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
    "Created: / 17-02-2008 / 22:16:03 / janfrog"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    "Modified: / 18-02-2008 / 14:58:43 / janfrog"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    "Modified: / 04-07-2008 / 15:33:31 / Jan Vrany <vranyj1@fel.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    "Modified: / 01-07-2015 / 10:57:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
!LLVM_C methodsFor:'filtering'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
shouldIgnoreStruct: cStructNode
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    ^ (cStructNode cName startsWith: 'LLVMOpaque') or:[ super shouldIgnoreStruct: cStructNode  ]
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    "Created: / 06-07-2015 / 07:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
    "Modified: / 06-07-2015 / 23:12:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
!LLVM_C methodsFor:'mapping - categories'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
smalltalkCategoryForDerivedType:cType
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    | className class |
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
    className := cType smalltalkName asSymbol.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
    (className notNil and:[(class := Smalltalk at: className) notNil]) ifTrue:[
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
        ^class category
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
    ].
44
e698efa3708b Small fix in LLVM C and LLVM C Extensions library mappings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   139
    ^'LLVM-S-Core'
43
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    "Created: / 05-09-2012 / 11:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
    "Modified: / 30-06-2015 / 13:53:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
smalltalkCategoryForEnum:cType
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
    | className class |
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
    className := cType smalltalkName asSymbol.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    (className notNil and:[(class := Smalltalk at: className) notNil]) ifTrue:[
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
        ^class category
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
    ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
    ^'LLVM-Core-Constants'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
    "Created: / 07-07-2015 / 18:21:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
!LLVM_C methodsFor:'mapping - class names'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
smalltalkClassNameForDerivedType: type      
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    "Answers class which should contain function call"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    | baseName |
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
44
e698efa3708b Small fix in LLVM C and LLVM C Extensions library mappings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   164
    type cName = 'LLVMBuilderRef' ifTrue:[
e698efa3708b Small fix in LLVM C and LLVM C Extensions library mappings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   165
    	^'LLVMIRBuilder'
e698efa3708b Small fix in LLVM C and LLVM C Extensions library mappings
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   166
    ].
43
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    baseName := super smalltalkClassNameForDerivedType:type.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
    (baseName endsWith: 'Ref') ifTrue:[
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
        baseName := baseName copyTo: baseName size - 3
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
    ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    ^baseName
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    "Created: / 30-06-2015 / 13:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
    "Modified: / 01-07-2015 / 09:32:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
    "Modified (format): / 01-07-2015 / 16:23:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
smalltalkClassNameForFunction:cFunction 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
"/    | cFunctionName firstArgType returnType |
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
"/
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
"/    cFunctionName := cFunction cName.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
"/    cFunctionName = 'LLVMCreateMemoryBufferWithContentsOfFile' ifTrue:[ 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
"/        ^'LLVMMemoryBuffer'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
"/    ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
"/    cFunctionName = 'LLVMInitializeMCJITCompilerOptions' ifTrue:[ 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
"/        ^'LLVMMCJITCompilerOptions'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
"/    ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
"/
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
"/
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
"/    cFunction arguments notEmpty ifTrue:[
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
"/        firstArgType := cFunction arguments first type.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
"/        (firstArgType resolved isCPointerNode and:[ firstArgType resolved type resolved isCStructNode ]) 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
"/            ifTrue:[ ^ self smalltalkClassNameForDerivedType: firstArgType ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
"/    ].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
"/    returnType := cFunction return.
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
"/    (returnType resolved isCPointerNode and:[ returnType resolved type resolved isCStructNode ]) 
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
"/        ifTrue:[ ^ self smalltalkClassNameForDerivedType: returnType].
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
    ^ #LLVM
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
    "Created: / 01-07-2015 / 06:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    "Modified: / 01-07-2015 / 09:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
!LLVM_C class methodsFor:'documentation'!
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
version_HG
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
    ^ '$Changeset: <not expanded> $'
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
! !
9327987437ae Added mappings for LLVM C and LLVM C Extensions
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211