4
|
1 |
"{ Package: 'jv:libllvms' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
LLVMValue subclass:#LLVMFunction
|
5
|
6 |
instanceVariableNames:'numArgs'
|
4
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'LLVM-Core'
|
|
10 |
!
|
|
11 |
|
|
12 |
!LLVMFunction methodsFor:'accessing'!
|
|
13 |
|
|
14 |
numArgs
|
5
|
15 |
| last current |
|
|
16 |
|
|
17 |
numArgs isNil ifTrue:[
|
|
18 |
numArgs := 0.
|
|
19 |
"/ current := LLVM GetFirstParam: self.
|
|
20 |
"/ last := LLVM GetLastParam: self.
|
|
21 |
"/ [ current ~= last ] whileTrue:[
|
|
22 |
"/ numArgs := numArgs + 1.
|
|
23 |
"/ current := LLVM GetNextFunction: current.
|
|
24 |
"/ self halt.
|
|
25 |
"/ ].
|
|
26 |
].
|
|
27 |
^ numArgs
|
4
|
28 |
|
|
29 |
"Created: / 11-07-2015 / 09:42:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
5
|
30 |
"Modified: / 11-07-2015 / 11:23:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
4
|
31 |
!
|
|
32 |
|
|
33 |
parameterAt: index
|
5
|
34 |
^ LLVM GetParam: self _: index - 1.
|
4
|
35 |
|
|
36 |
"Created: / 07-07-2015 / 22:49:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
5
|
37 |
"Modified: / 11-07-2015 / 10:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
4
|
38 |
! !
|
|
39 |
|
|
40 |
!LLVMFunction methodsFor:'functions-adding'!
|
|
41 |
|
|
42 |
addBasicBlockNamed: name
|
5
|
43 |
| bb |
|
|
44 |
|
4
|
45 |
self assert: name isSingleByteString.
|
5
|
46 |
bb := LLVM AppendBasicBlock: self _: name.
|
|
47 |
bb module: self.
|
|
48 |
^ bb
|
4
|
49 |
|
|
50 |
"Created: / 08-07-2015 / 23:09:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
5
|
51 |
"Modified: / 11-07-2015 / 12:55:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
4
|
52 |
! !
|
|
53 |
|
5
|
54 |
!LLVMFunction methodsFor:'initialization'!
|
|
55 |
|
|
56 |
initialize
|
|
57 |
super initialize.
|
|
58 |
self initializeArgumentsNames
|
|
59 |
|
|
60 |
"Created: / 11-07-2015 / 10:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
61 |
!
|
|
62 |
|
|
63 |
initializeArgumentsNames
|
|
64 |
1 to: self numArgs do:[:numArg |
|
|
65 |
(self parameterAt: numArg) name: 'arg', numArg printString
|
|
66 |
].
|
|
67 |
|
|
68 |
"Created: / 11-07-2015 / 10:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
69 |
! !
|
|
70 |
|