|
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:#LLVMTypeFunction |
|
19 instanceVariableNames:'' |
|
20 classVariableNames:'' |
|
21 poolDictionaries:'' |
|
22 category:'LLVM-S-Core-Types' |
|
23 ! |
|
24 |
|
25 !LLVMTypeFunction 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 !LLVMTypeFunction methodsFor:'accessing'! |
|
44 |
|
45 numArgs |
|
46 "Return a number of arguments this function takes (excluding variadic, if any) |
|
47 |
|
48 Same as numParams, defined here to match Smalltalk/X naming which uses #numArgs" |
|
49 |
|
50 ^ self numArgs |
|
51 |
|
52 "Created: / 13-08-2015 / 17:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
53 ! |
|
54 |
|
55 numParams |
|
56 "Return a number of arguments this function takes (excluding variadic, if any)" |
|
57 |
|
58 ^ LLVM CountParamTypes: self. |
|
59 |
|
60 "Created: / 13-08-2015 / 17:07:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
61 ! |
|
62 |
|
63 parameterTypeAt: index |
|
64 | numParams parameterTypePointers | |
|
65 |
|
66 numParams := self numParams. |
|
67 (index between: 1 and: numParams) ifTrue:[ |
|
68 parameterTypePointers := LLVMObjectArray new: numParams. |
|
69 LLVM GetParamTypes: self _: parameterTypePointers. |
|
70 ^ (LLVMType newAddress: (parameterTypePointers at: index)) |
|
71 ]. |
|
72 LLVMTypeError new signal: 'index out of bounds' |
|
73 |
|
74 "Created: / 13-08-2015 / 17:16:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
75 "Modified: / 14-08-2015 / 06:15:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 ! |
|
77 |
|
78 parameterTypes |
|
79 | numParams parameterTypePointers parameterTypes | |
|
80 |
|
81 numParams := self numParams. |
|
82 numParams == 0 ifTrue:[ ^ #() ]. |
|
83 parameterTypePointers := LLVMObjectArray new: numParams. |
|
84 parameterTypes := Array new: numParams. |
|
85 LLVM GetParamTypes: self _: parameterTypePointers. |
|
86 1 to: numParams do:[:i | parameterTypes at: i put: (LLVMType newAddress: (parameterTypePointers at: i)) ]. |
|
87 ^ parameterTypes |
|
88 |
|
89 "Created: / 13-08-2015 / 17:16:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
90 ! |
|
91 |
|
92 returnType |
|
93 ^ LLVM GetReturnType: self. |
|
94 |
|
95 "Created: / 13-08-2015 / 17:11:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
96 ! ! |
|
97 |
|
98 !LLVMTypeFunction methodsFor:'testing'! |
|
99 |
|
100 isFunctionType |
|
101 ^ true |
|
102 |
|
103 "Created: / 13-08-2015 / 16:51:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
104 ! |
|
105 |
|
106 isVarArg |
|
107 "Return true if the function type designates a variadic function" |
|
108 |
|
109 ^ LLVM IsFunctionVarArg: self |
|
110 |
|
111 "Created: / 13-08-2015 / 17:05:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
112 ! ! |
|
113 |