LLVMMetadata.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 17 Sep 2015 17:09:43 +0100
changeset 41 e4cbc8e75207
parent 33 feabf14b6c1d
child 74 47bf2a306c14
permissions -rw-r--r--
Added testing and assestion methods to test metadata nodes for their type ...such as DIFile, DILocalVariable. These should be used by the Smalltalk API to make sure it passes valid data to the C library. Otherwise the behaviour is undefined :-) (except for Debug+Assert LLVM builds which calls abort(), not nice in Smalltalk context)

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