LLVMObject.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 17 Sep 2015 17:17:56 +0100
changeset 42 23ae490859cd
parent 41 e4cbc8e75207
child 43 597181c496f0
permissions -rw-r--r--
Fixed LLVMExamples>>example7_factorial_with_debug_info Pass DIFile instead of DICompileUnit to #createTypeFunctionIn:parameterTypes: Fixed #createParameterVariable: - parameters are numbered starting with 1.

"
    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:'asserting'!

assertIsString:aString 
    <resource: #skipInDebuggersWalkBack>

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

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

!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>"
    "Modified: / 14-09-2015 / 11:08:53 / 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>"
    "Modified: / 14-09-2015 / 11:08: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>"
    "Modified: / 14-09-2015 / 11:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsDIBasicType: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIBasicType message: 'value is not of type DIBasicType'.
!

assertIsDICompileUnit: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDICompileUnit message: 'value is not of type DICompileUnit'.
!

assertIsDICompositeType: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDICompositeType message: 'value is not of type DICompositeType'.
!

assertIsDIDerivedType: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIDerivedType message: 'value is not of type DIDerivedType'.
!

assertIsDIEnumerator: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIEnumerator message: 'value is not of type DIEnumerator'.
!

assertIsDIExpression: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIExpression message: 'value is not of type DIExpression'.
!

assertIsDIFile: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIFile message: 'value is not of type DIFile'.
!

assertIsDIGlobalVariable: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIGlobalVariable message: 'value is not of type DIGlobalVariable'.
!

assertIsDIImportedEntity: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIImportedEntity message: 'value is not of type DIImportedEntity'.
!

assertIsDILexicalBlock: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDILexicalBlock message: 'value is not of type DILexicalBlock'.
!

assertIsDILexicalBlockFile: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDILexicalBlockFile message: 'value is not of type DILexicalBlockFile'.
!

assertIsDILocalScope: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDILocalScope message: 'value is not of type DILocalScope'.

    "Created: / 17-09-2015 / 17:00:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsDILocalVariable: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDILocalVariable message: 'value is not of type DILocalVariable'.
!

assertIsDILocation: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDILocation message: 'value is not of type DILocation'.
!

assertIsDINamespace: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDINamespace message: 'value is not of type DINamespace'.
!

assertIsDIObjCProperty: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIObjCProperty message: 'value is not of type DIObjCProperty'.
!

assertIsDIScope: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIScope message: 'value is not of type DILocalScope'.

    "Created: / 17-09-2015 / 17:04:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsDISubprogram: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDISubprogram message: 'value is not of type DISubprogram'.
!

assertIsDISubprogramType: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDISubprogramType message: 'value is not of type DISubprogramType'.
!

assertIsDISubrange: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDISubrange message: 'value is not of type DISubrange'.
!

assertIsDIType: value
    <resource: #skipInDebuggersWalkBack>

    self assert: value isLLVMMetadata message: 'value is not a LLVMMetadata'.
    self assert: value isDIType message: 'value is not of type DIType'.

    "Created: / 17-09-2015 / 17:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsDITypeArray: values
    <resource: #skipInDebuggersWalkBack>

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

    "Created: / 17-09-2015 / 17:02:03 / 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>"
    "Modified: / 14-09-2015 / 11:09:02 / 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>"
    "Modified: / 14-09-2015 / 11:09:05 / 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: / 14-09-2015 / 11:09:08 / 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>"
    "Modified: / 14-09-2015 / 11:09:10 / 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>"
    "Modified: / 14-09-2015 / 11:09:13 / 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>"
    "Modified: / 14-09-2015 / 11:09:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

assertIsString:aString 
    <resource: #skipInDebuggersWalkBack>

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

    "Created: / 07-08-2015 / 18:38:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-09-2015 / 11:09:22 / 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>"
    "Modified: / 14-09-2015 / 11:09:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (format): / 17-09-2015 / 16:51:34 / 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>"
    "Modified: / 14-09-2015 / 11:09:29 / 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>"
    "Modified: / 14-09-2015 / 11:09:31 / 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>"
    "Modified: / 14-09-2015 / 11:09:34 / 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>"
    "Modified: / 14-09-2015 / 11:09:36 / 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>"
    "Modified: / 14-09-2015 / 11:09:38 / 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: / 14-09-2015 / 11:09:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !