LLVMTypeArray.st
changeset 0 38af781b75ab
equal deleted inserted replaced
-1:000000000000 0:38af781b75ab
       
     1 "{ Package: 'jv:libllvms' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 ExternalBytes subclass:#LLVMTypeArray
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'LLVM-Core'
       
    10 !
       
    11 
       
    12 !LLVMTypeArray class methodsFor:'instance creation'!
       
    13 
       
    14 new: size
       
    15     ^ super new: size * ExternalAddress pointerSize
       
    16 
       
    17     "Created: / 07-07-2015 / 21:44:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    18 !
       
    19 
       
    20 with: type1
       
    21     ^ (self new: 1)
       
    22         at: 1 put: type1;
       
    23         yourself
       
    24 
       
    25     "Created: / 07-07-2015 / 21:50:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    26 !
       
    27 
       
    28 with: type1 with: type2
       
    29     ^ (self new: 2)
       
    30         at: 1 put: type1;
       
    31         at: 2 put: type2;
       
    32         yourself
       
    33 
       
    34     "Created: / 07-07-2015 / 21:50:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    35 !
       
    36 
       
    37 with: type1 with: type2 with: type3
       
    38     ^ (self new: 3)
       
    39         at: 1 put: type1;
       
    40         at: 2 put: type2;
       
    41         at: 3 put: type3;
       
    42         yourself
       
    43 
       
    44     "Created: / 07-07-2015 / 21:50:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    45 !
       
    46 
       
    47 with: type1 with: type2 with: type3 with: type4
       
    48     ^ (self new: 4)
       
    49         at: 1 put: type1;
       
    50         at: 2 put: type2;
       
    51         at: 3 put: type3;
       
    52         at: 4 put: type4;
       
    53         yourself
       
    54 
       
    55     "Created: / 07-07-2015 / 21:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    56 !
       
    57 
       
    58 with: type1 with: type2 with: type3 with: type4 with: type5
       
    59     ^ (self new: 5)
       
    60         at: 1 put: type1;
       
    61         at: 2 put: type2;
       
    62         at: 3 put: type3;
       
    63         at: 4 put: type4;
       
    64         at: 5 put: type5;
       
    65         yourself
       
    66 
       
    67     "Created: / 07-07-2015 / 21:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    68 ! !
       
    69 
       
    70 !LLVMTypeArray methodsFor:'accessing'!
       
    71 
       
    72 at: index
       
    73     ExternalAddress pointerSize == 8 ifTrue:[ 
       
    74         ^ LLVMType newAddress: (self longLongAt: ((index - 1) * 8) + 1).
       
    75     ].
       
    76     ExternalAddress pointerSize == 4 ifTrue:[ 
       
    77         ^ LLVMType newAddress: (self longLongAt: ((index - 1) * 4) + 1).
       
    78     ].
       
    79     self error:'Funny pointerSize'
       
    80 
       
    81     "Created: / 07-07-2015 / 21:47:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    82 !
       
    83 
       
    84 at: index put: type
       
    85     self assert: (type isKindOf: LLVMType).
       
    86     
       
    87     ExternalAddress pointerSize == 8 ifTrue:[ 
       
    88         self longLongAt: ((index - 1) * 8) + 1 put: type address.
       
    89         ^ type
       
    90     ].
       
    91     ExternalAddress pointerSize == 4 ifTrue:[ 
       
    92         self longAt: ((index - 1) * 4) + 1 put: type address.
       
    93         ^ type
       
    94     ].
       
    95     self error:'Funny pointerSize'
       
    96 
       
    97     "Created: / 07-07-2015 / 21:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    98 !
       
    99 
       
   100 size
       
   101     ^ size / ExternalAddress pointerSize
       
   102 
       
   103     "Created: / 07-07-2015 / 21:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   104 ! !
       
   105