Cface__LLVM_C.st
changeset 48 a5c898296427
parent 46 cc6b765ad420
equal deleted inserted replaced
47:35c51ba4e4a7 48:a5c898296427
    49 !LLVM_C methodsFor:'accessing'!
    49 !LLVM_C methodsFor:'accessing'!
    50 
    50 
    51 definitions:definitionFile
    51 definitions:definitionFile
    52     super definitions:definitionFile.
    52     super definitions:definitionFile.
    53 
    53 
    54     "/ A hack to map LLVMBool to #bool FFIT type
    54     "/ A hack to map LLVMBool to #bool FFI type
    55 
       
    56     definitionFile definitions do:[:each | 
    55     definitionFile definitions do:[:each | 
    57         (each isKindOf: CTypedefNode) ifTrue:[
    56         (each isKindOf: CTypedefNode) ifTrue:[
    58             each cName = 'LLVMBool' ifTrue:[ 
    57             each cName = 'LLVMBool' ifTrue:[ 
    59                 each type: CBoolNode new 
    58                 each type: CBoolNode new 
    60             ].                                           
    59             ].                                           
    61         ]
    60         ]
    62     ]
    61     ].
       
    62     "/ A hack to change return type of all LLVMIsAXXX() functions
       
    63     "/ to bool (this avoids an extra allocation & nil test)
       
    64     definitionFile definitions do:[:each | 
       
    65         (each isKindOf: CFunctionNode) ifTrue:[
       
    66             (each cName startsWith: 'LLVMIsA') ifTrue:[
       
    67                 each return: CBoolNode new
       
    68             ]
       
    69         ]
       
    70     ].
       
    71     "/ A hack to make all LLVMPrintXXXToString() to return
       
    72     "/ generic pointer. This is necessary as we need the pointer
       
    73     "/ in Smalltalk code to later invoke LLVMDisposeMessage()
       
    74     definitionFile definitions do:[:each | 
       
    75         (each isKindOf: CFunctionNode) ifTrue:[
       
    76             ((each cName startsWith: 'LLVMPrint') and:[each cName endsWith: 'ToString']) ifTrue:[
       
    77                 each return: (CPointerNode new type: (CPointerNode new type: CVoidNode new))
       
    78             ]
       
    79         ]
       
    80     ].
    63 
    81 
    64     "Created: / 14-08-2015 / 11:13:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    82     "Created: / 14-08-2015 / 11:13:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    83     "Modified: / 16-09-2015 / 06:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    65 !
    84 !
    66 
    85 
    67 smalltalkPackage
    86 smalltalkPackage
    68 
    87 
    69     ^#'jv:llvm_s'
    88     ^#'jv:llvm_s'