LLVMMetadata.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 23 Aug 2016 23:37:31 +0100
changeset 74 47bf2a306c14
parent 41 e4cbc8e75207
child 77 67e1328d58c9
permissions -rw-r--r--
Show metadata kind in LLVMMetadata print string ...i.e., DILocation@12345678 rather then generic LLVMMetadata@12345678

"
    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 }"

LLVMObject subclass:#LLVMMetadata
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:'LLVMMetadataKind'
	category:'LLVM-S-Core'
!

!LLVMMetadata 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.
"
! !

!LLVMMetadata methodsFor:'accessing'!

kind
    ^ LLVMCEXT GetMedadataKind: self

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

!LLVMMetadata methodsFor:'converting'!

asLLVMMetadata
    ^ self

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

asLLVMValue
    ^ LLVMCEXT MetadataAsValue: self.

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

!LLVMMetadata methodsFor:'printing & storing'!

printOn:aStream
    | kind |

    kind := self kind.

    MDTupleKind == kind ifTrue:[ aStream nextPutAll:'MDTuple'].
    DILocationKind == kind ifTrue:[ aStream nextPutAll:'DILocation'].
    GenericDINodeKind == kind ifTrue:[ aStream nextPutAll:'GenericDINode'].
    DISubrangeKind == kind ifTrue:[ aStream nextPutAll:'DISubrange'].
    DIEnumeratorKind == kind ifTrue:[ aStream nextPutAll:'DIEnumerator'].
    DIBasicTypeKind == kind ifTrue:[ aStream nextPutAll:'DIBasicType'].
    DIDerivedTypeKind == kind ifTrue:[ aStream nextPutAll:'DIDerivedType'].
    DICompositeTypeKind == kind ifTrue:[ aStream nextPutAll:'DICompositeType'].
    DISubroutineTypeKind == kind ifTrue:[ aStream nextPutAll:'DISubroutineType'].
    DIFileKind == kind ifTrue:[ aStream nextPutAll:'DIFile'].
    DICompileUnitKind == kind ifTrue:[ aStream nextPutAll:'DICompileUnit'].
    DISubprogramKind == kind ifTrue:[ aStream nextPutAll:'DISubprogram'].
    DILexicalBlockKind == kind ifTrue:[ aStream nextPutAll:'DILexicalBlock'].
    DILexicalBlockFileKind == kind ifTrue:[ aStream nextPutAll:'DILexicalBlockFile'].
    DINamespaceKind == kind ifTrue:[ aStream nextPutAll:'DINamespace'].
    DIModuleKind == kind ifTrue:[ aStream nextPutAll:'DIModule'].
    DITemplateTypeParameterKind == kind ifTrue:[ aStream nextPutAll:'DITemplateTypeParameter'].
    DITemplateValueParameterKind == kind ifTrue:[ aStream nextPutAll:'DITemplateValueParameter'].
    DIGlobalVariableKind == kind ifTrue:[ aStream nextPutAll:'DIGlobalVariable'].
    DILocalVariableKind == kind ifTrue:[ aStream nextPutAll:'DILocalVariable'].
    DIExpressionKind == kind ifTrue:[ aStream nextPutAll:'DIExpression'].
    DIObjCPropertyKind == kind ifTrue:[ aStream nextPutAll:'DIObjCProperty'].
    DIImportedEntityKind == kind ifTrue:[ aStream nextPutAll:'DIImportedEntity'].
    ConstantAsMetadataKind == kind ifTrue:[ aStream nextPutAll:'ConstantAsMetadata'].
    LocalAsMetadataKind == kind ifTrue:[ aStream nextPutAll:'LocalAsMetadata'].
    MDStringKind == kind ifTrue:[ aStream nextPutAll:'MDString'].

    aStream nextPutAll:'@'.
    self address printOn:aStream base:16.

    "Created: / 23-08-2016 / 23:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LLVMMetadata methodsFor:'testing'!

isDIBasicType
    ^ self kind == DIBasicTypeKind

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

isDICompileUnit
    ^ self kind == DICompileUnitKind

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

isDICompositeType
    ^ self kind == DICompositeTypeKind

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

isDIDerivedType
    ^ self kind == DIDerivedTypeKind

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

isDIEnumerator
    ^ self kind == DIEnumeratorKind

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

isDIExpression
    ^ self kind == DIExpressionKind

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

isDIFile
    ^ self kind == DIFileKind

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

isDIGlobalVariable
    ^ self kind == DIGlobalVariableKind

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

isDIImportedEntity
    ^ self kind == DIImportedEntityKind

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

isDILexicalBlock
    ^ self kind == DILexicalBlockKind

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

isDILexicalBlockFile
    ^ self kind == DILexicalBlockFileKind

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

isDILocalScope
    ^ { DILexicalBlockKind . DILexicalBlockFileKind . DISubprogramKind } includes: self kind.

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

isDILocalVariable
    ^ self kind == DILocalVariableKind

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

isDILocation
    ^ self kind == DILocationKind

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

isDINamespace
    ^ self kind == DINamespaceKind

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

isDIObjCProperty
    ^ self kind == DIObjCPropertyKind

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

isDIScope
    ^ { DILexicalBlockKind . DILexicalBlockFileKind . DISubprogramKind .
        DICompileUnitKind . DIFileKind . DINamespaceKind } includes: self kind.

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

isDISubprogram
    ^ self kind == DISubprogramKind

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

isDISubprogramType
    ^ self kind == DISubroutineTypeKind

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

isDISubrange
    ^ self kind == DISubrangeKind

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

isDIType
    ^ { DIBasicTypeKind . DIDerivedTypeKind . DICompositeTypeKind . DISubroutineTypeKind } includes: self kind.

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

isLLVMMetadata
    ^ true

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

!LLVMMetadata class methodsFor:'documentation'!

version_HG

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