extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 30 Aug 2016 16:57:29 +0100
changeset 78 7a4c769a9fea
parent 61 c2e287d54de5
permissions -rw-r--r--
llvm_c_ext: Improved `LLVMSetMetadata2()` to support also function values ...in addition to instruction values. This is handy to attach data to functions, such as debugging information. Added Smalltalk API for setting metadata nodes on instructions and functions.

"{ Package: 'jv:llvm_s' }"!

!Object methodsFor:'converting'!

asLLVMBasicBlock
    "Return representation of the receiver as LLVMBasicBlock"

    "Raise an error - arbitrary object cannot be represented
     as LLVM value"
    self error: 'cannot be converted to an LLVM basic block'

    "Created: / 21-04-2016 / 22:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'converting'!

asLLVMMetadata
    "Return representation of the receiver as LLVMMetadata."

    "Raise an error - arbitrary object cannot be represented
     as LLVM metadata"
    self error: 'cannot be converted to an LLVM metadata'

    "Created: / 15-08-2015 / 06:43:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'converting'!

asLLVMValue
    "Return representation of the receiver as LLVMValue."

    "Raise an error - arbitrary object cannot be represented
     as LLVM value"
    self error: 'cannot be converted to an LLVM value'

    "Created: / 08-08-2015 / 02:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'converting'!

asLLVMValueOfType: anLLVMType
    "Return representation of the receiver as LLVMValue with given LLVMType. 
     If the object cannot be converted to the balue of requested type, 
     raise an error."

    self error: 'cannot be converted to an LLVM value'

    "Created: / 08-08-2015 / 02:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'testing'!

isLLVMFunction
    "Return true, if receiver represents an LLVM value representing a function"

    ^ false

    "Created: / 10-08-2015 / 19:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'testing'!

isLLVMType
    "Return true, if receiver represents an LLVM type"

    ^ false

    "Created: / 08-08-2015 / 02:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Object methodsFor:'testing'!

isLLVMValue
    "Return true, if receiver represents an LLVM value"

    ^ false

    "Created: / 08-08-2015 / 02:21:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SequenceableCollection methodsFor:'converting'!

asLLVMObjectArray
    | array size | 

    size := self size.
    size == 0 ifTrue:[ 
        ^ nil
    ].
    array := LLVMObjectArray new: size.
    array replaceFrom: 1 count: size with: self.
    ^array

    "Created: / 08-07-2015 / 22:58:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 03-08-2015 / 17:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_llvm_s class methodsFor:'documentation'!

extensionsVersion_HG

    ^ '$Changeset: <not expanded> $'
! !