LLVMObjectArray.st
changeset 1 e3dcb6272f0b
child 12 f98e97fd02ef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LLVMObjectArray.st	Thu Jul 09 09:05:55 2015 +0100
@@ -0,0 +1,106 @@
+"{ Package: 'jv:libllvms' }"
+
+"{ NameSpace: Smalltalk }"
+
+ExternalBytes subclass:#LLVMObjectArray
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'LLVM-Core'
+!
+
+!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:[ 
+        ^ LLVMType newAddress: (self longLongAt: ((index - 1) * 8) + 1).
+    ].
+    ExternalAddress pointerSize == 4 ifTrue:[ 
+        ^ LLVMType newAddress: (self longLongAt: ((index - 1) * 4) + 1).
+    ].
+    self error:'Funny pointerSize'
+
+    "Created: / 07-07-2015 / 21:47:48 / 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>"
+! !
+