LLVMObject.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 17 Aug 2015 08:53:26 +0100
changeset 33 feabf14b6c1d
parent 27 b26354bbff25
child 37 0933f973bc22
permissions -rw-r--r--
Initial support for generating (DWARF) debug info. The current API is really horrible and clumsy, but it's more or less 1-to-1 mapping to LLVM API. LLVMExamples>>example7_factorial_with_debug_info shows how to use it. The debug info API (at the Smalltalk level) will be refactored to provide easier-to-use interface.

"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
"{ Package: 'jv:llvm_s' }"

"{ NameSpace: Smalltalk }"

ExternalAddress subclass:#LLVMObject
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:'LLVMTypeKind'
	category:'LLVM-S-Internal'
!

!LLVMObject class methodsFor:'documentation'!

copyright
"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
! !

!LLVMObject class methodsFor:'queries'!

isAbstract
    "Return if this class is an abstract class.
     True is returned here for myself only; false for subclasses.
     Abstract subclasses must redefine again."

    ^ self == LLVMObject.
! !

!LLVMObject methodsFor:'assertions'!

assertIsBasicBlock: value 
    <resource: #skipInDebuggersWalkback>

    self assert:(value isKindOf: LLVMBasicBlock) message: 'value is not an LLVM basic block'

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

assertIsBasicBlockValue:value 
    <resource: #skipInDebuggersWalkback>

    self assert:value isLLVMValue.
    self assert:value isBasicBlockValue

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

assertIsBoolean: value
    <resource: #skipInDebuggersWalkback>

    self assert: value isBoolean message: 'value is not a boolean'.

    "Created: / 13-08-2015 / 06:52:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsFunctionValue: value
    <resource: #skipInDebuggersWalkback>

    self assert: value isLLVMFunction message: 'value is not an LLVMFunction'.

    "Created: / 10-08-2015 / 18:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsInteger64Unsigned:value 
    <resource: #skipInDebuggersWalkback>

    self assert: value isInteger message: 'value is not an integer'.
    self assert: (value between: 0 and: 16rFFFFFFFFFFFFFFFF) message: 'value out of range'

    "Created: / 14-08-2015 / 07:32:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsIntegerOrIntegerVectorValue:value 
    <resource: #skipInDebuggersWalkback>

    self assert:(value class == LLVMValue) message:'value is not an LLVMValue'.
    self assert:(value isIntegerOrIntegerVectorValue)

    "Modified (format): / 08-08-2015 / 02:41:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsIntegerUnsigned:value 
    <resource: #skipInDebuggersWalkback>

    self assert: value isInteger message: 'value is not an integer'.
    self assert: (value between: 0 and: 16rFFFFFFFF) message: 'value out of range'

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

assertIsMetadata: value
    <resource: #skipInDebuggersWalkback>

    self assert: value isLLVMMetadata message: 'value is not an LLVMMetadata'.

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

assertIsMetadataArray: values
    <resource: #skipInDebuggersWalkback>

    self assert: values isSequenceable message: 'values is not a sequenceable collection'.
    values do:[:value | 
        self assertIsMetadata: value.  
    ].

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

assertIsString:aString 
    <resource: #skipInDebuggersWalkback>

    self assert:(aString isSymbol or:[aString isSingleByteString]) description:'string is not a valid LLVM name (twine)'

    "Created: / 07-08-2015 / 18:38:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 13-08-2015 / 07:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsType: type
     <resource: #skipInDebuggersWalkback>

    self assert: type isLLVMType message: 'value is not an LLVMType'.

    "Created: / 10-08-2015 / 06:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsTypeArray: types
    <resource: #skipInDebuggersWalkback>

    self assert: types isSequenceable message: 'types is not a sequenceable collection'.
    types do:[:type | 
        self assertIsType: type.  
    ].

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

assertIsValue: value
    <resource: #skipInDebuggersWalkback>

    self assert: value isLLVMValue message: 'value is not an LLVMValue'.

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

assertIsValue: value ofKind: kind
    <resource: #skipInDebuggersWalkback>

    self assert: value isLLVMValue message: 'value is not an LLVMValue'.
    self assert: value type kind = kind message: 'value has incorrect kind'

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

assertIsValue: value ofType: type
    <resource: #skipInDebuggersWalkback>

    self assert: value isLLVMValue message: 'value is not an LLVMValue'.
    self assert: value type = type message: 'value has incorrect type'

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

assertIsValueArray: values
    <resource: #skipInDebuggersWalkback>

    self assert: values isSequenceable message: 'values is not a sequenceable collection'.
    values do:[:value | 
        self assertIsValue: value.  
    ].

    "Created: / 10-08-2015 / 18:56:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsValueOfSameType:value1 as:value2 
    <resource: #skipInDebuggersWalkback>

    self assert: value1 type = value2 type message:'types of values differ!!'

    "Created: / 07-08-2015 / 18:37:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 08-08-2015 / 02:57:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !