LLVMObjectArray.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 17 Aug 2015 09:08:47 +0100
changeset 30 c789c1390911
parent 27 b26354bbff25
permissions -rw-r--r--
LLVM C API Extensions: added llvm-c-ext/DWARF.h with (some) DWARF constants required to generate debug info. Most importantly, DWARF encoding used when describing a variable to tell the debugger how to interpret the data (as float, signed/unsigned int, etc). More constants will be added as needed.

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

ExternalBytes subclass:#LLVMObjectArray
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'LLVM-S-Core'
!

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

!LLVMObjectArray class methodsFor:'instance creation'!

new: size
    ^ super new: size * ExternalAddress pointerSize

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

with: type1
    ^ (self new: 1)
        at: 1 put: type1;
        yourself

    "Created: / 07-07-2015 / 21:50:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

with: type1 with: type2
    ^ (self new: 2)
        at: 1 put: type1;
        at: 2 put: type2;
        yourself

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

with: type1 with: type2 with: type3
    ^ (self new: 3)
        at: 1 put: type1;
        at: 2 put: type2;
        at: 3 put: type3;
        yourself

    "Created: / 07-07-2015 / 21:50:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

with: type1 with: type2 with: type3 with: type4
    ^ (self new: 4)
        at: 1 put: type1;
        at: 2 put: type2;
        at: 3 put: type3;
        at: 4 put: type4;
        yourself

    "Created: / 07-07-2015 / 21:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

with: type1 with: type2 with: type3 with: type4 with: type5
    ^ (self new: 5)
        at: 1 put: type1;
        at: 2 put: type2;
        at: 3 put: type3;
        at: 4 put: type4;
        at: 5 put: type5;
        yourself

    "Created: / 07-07-2015 / 21:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LLVMObjectArray methodsFor:'accessing'!

at: index
    ExternalAddress pointerSize == 8 ifTrue:[ 
        ^ self longLongAt: ((index - 1) * 8) + 1.
    ].
    ExternalAddress pointerSize == 4 ifTrue:[ 
        ^ self longLongAt: ((index - 1) * 4) + 1.
    ].
    self error:'Funny pointerSize'

    "Created: / 07-07-2015 / 21:47:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 13-08-2015 / 17:15:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

at: index put: type
    self assert: (type isKindOf: LLVMObject).
    
    ExternalAddress pointerSize == 8 ifTrue:[ 
        self longLongAt: ((index - 1) * 8) + 1 put: type address.
        ^ type
    ].
    ExternalAddress pointerSize == 4 ifTrue:[ 
        self longAt: ((index - 1) * 4) + 1 put: type address.
        ^ type
    ].
    self error:'Funny pointerSize'

    "Created: / 07-07-2015 / 21:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 08-07-2015 / 22:54:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

size
    ^ size / ExternalAddress pointerSize

    "Created: / 07-07-2015 / 21:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !