|
1 " |
|
2 Copyright (C) 2015-now Jan Vrany |
|
3 |
|
4 This code is not an open-source (yet). You may use this code |
|
5 for your own experiments and projects, given that: |
|
6 |
|
7 * all modification to the code will be sent to the |
|
8 original author for inclusion in future releases |
|
9 * this is not used in any commercial software |
|
10 |
|
11 This license is provisional and may (will) change in |
|
12 a future. |
|
13 " |
|
14 "{ Package: 'jv:llvm_s' }" |
|
15 |
|
16 "{ NameSpace: Smalltalk }" |
|
17 |
|
18 LLVMType subclass:#LLVMTypeStruct |
|
19 instanceVariableNames:'' |
|
20 classVariableNames:'' |
|
21 poolDictionaries:'' |
|
22 category:'LLVM-S-Core-Types' |
|
23 ! |
|
24 |
|
25 !LLVMTypeStruct class methodsFor:'documentation'! |
|
26 |
|
27 copyright |
|
28 " |
|
29 Copyright (C) 2015-now Jan Vrany |
|
30 |
|
31 This code is not an open-source (yet). You may use this code |
|
32 for your own experiments and projects, given that: |
|
33 |
|
34 * all modification to the code will be sent to the |
|
35 original author for inclusion in future releases |
|
36 * this is not used in any commercial software |
|
37 |
|
38 This license is provisional and may (will) change in |
|
39 a future. |
|
40 " |
|
41 ! ! |
|
42 |
|
43 !LLVMTypeStruct methodsFor:'accessing'! |
|
44 |
|
45 elementTypeAt: n |
|
46 "Return types of `n`th member of the structure. Index starts at 1 as |
|
47 customary in Smalltalk. |
|
48 |
|
49 Uses term `element` instead of `member` to be in sync |
|
50 with LLVM naming." |
|
51 |
|
52 (n between: 1 and: self numElements) ifTrue:[ |
|
53 ^ LLVM StructGetTypeAtIndex: self _: n - 1. |
|
54 ]. |
|
55 LLVMTypeError new signal: 'index out of bounds'. |
|
56 |
|
57 "Created: / 14-08-2015 / 05:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
58 ! |
|
59 |
|
60 elementTypes |
|
61 "Return types of members of this structure. |
|
62 |
|
63 Uses term `element` instead of `member` to be in sync |
|
64 with LLVM naming." |
|
65 |
|
66 | numElements elementTypePointers elementTypes | |
|
67 |
|
68 numElements := self numElements. |
|
69 numElements == 0 ifTrue:[ ^ #() ]. |
|
70 elementTypePointers := LLVMObjectArray new: numElements. |
|
71 elementTypes := Array new: numElements. |
|
72 LLVM GetStructElementTypes: self _: elementTypePointers. |
|
73 1 to: numElements do:[:i | elementTypes at: i put: (LLVMType newAddress: (elementTypePointers at: i)) ]. |
|
74 ^ elementTypes |
|
75 |
|
76 "Created: / 14-08-2015 / 05:54:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
77 ! |
|
78 |
|
79 numElements |
|
80 "Return a number of members of this structure" |
|
81 |
|
82 ^ LLVM CountStructElementTypes: self |
|
83 |
|
84 "Created: / 14-08-2015 / 05:53:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 ! ! |
|
86 |
|
87 !LLVMTypeStruct methodsFor:'testing'! |
|
88 |
|
89 isOpaque |
|
90 ^ LLVM IsOpaqueStruct: self |
|
91 |
|
92 "Created: / 14-08-2015 / 06:11:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
93 ! |
|
94 |
|
95 isPacked |
|
96 ^ LLVM IsPackedStruct: self |
|
97 |
|
98 "Created: / 14-08-2015 / 06:11:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
99 ! |
|
100 |
|
101 isStructType |
|
102 ^ true |
|
103 |
|
104 "Created: / 13-08-2015 / 16:52:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
105 ! ! |
|
106 |