"
Copyright (C) 2015-now Jan Vrany
This code is not an open-source (yet). You may use this code
for your own experiments and projects, given that:
* all modification to the code will be sent to the
original author for inclusion in future releases
* this is not used in any commercial software
This license is provisional and may (will) change in
a future.
"
"{ Package: 'jv:llvm_s' }"
"{ NameSpace: Smalltalk }"
Object subclass:#LLVMConstant
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'LLVM-S-Core'
!
!LLVMConstant class methodsFor:'documentation'!
copyright
"
Copyright (C) 2015-now Jan Vrany
This code is not an open-source (yet). You may use this code
for your own experiments and projects, given that:
* all modification to the code will be sent to the
original author for inclusion in future releases
* this is not used in any commercial software
This license is provisional and may (will) change in
a future.
"
!
documentation
"
A simple factory for creating constant values.
LLVMConstant sint16: 10.
LLVMConstant string: 'Hello World!!'.
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
[class variables:]
[see also:]
"
! !
!LLVMConstant class methodsFor:'assertions'!
assertIsType: type
<resource: #skipInDebuggersWalkBack>
self assert: type isLLVMType message: 'value is not an LLVMType'.
"Created: / 10-08-2015 / 06:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 11:09:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 17-09-2015 / 16:51:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
assertIsValue: value
<resource: #skipInDebuggersWalkBack>
self assert: value isLLVMValue message: 'value is not an LLVMValue'.
"Created: / 08-08-2015 / 03:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 11:09:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
assertIsValue: value ofKind: kind
<resource: #skipInDebuggersWalkBack>
self assert: value isLLVMValue message: 'value is not an LLVMValue'.
self assert: value type kind = kind message: 'value has incorrect kind'
"Created: / 10-08-2015 / 17:40:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 11:09:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
assertIsValue: value ofType: type
<resource: #skipInDebuggersWalkBack>
self assert: value isLLVMValue message: 'value is not an LLVMValue'.
self assert: value type = type message: 'value has incorrect type'
"Created: / 08-08-2015 / 02:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-09-2015 / 11:09:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'constants - construction'!
bitcast: value to: type
self assertIsValue: value.
self assert: value type isPointerType description: 'Value is not a pointer type. Use #int:toPtr: to conver int to pointer'.
self assertIsType: type.
^ LLVM ConstBitCast: value _: type.
"Created: / 12-10-2015 / 16:11:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-06-2016 / 20:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
int: value toPtr: type
self assertIsValue: value.
self assert: value type isIntegerType description: 'Value is not an integer. Use #bitcast:to:'.
self assertIsType: type.
^ LLVM ConstIntToPtr: value _: type.
"Created: / 20-06-2016 / 20:32:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'constants - int - signed'!
sint16:value
^ self sint:value type:LLVMType int16
"Created: / 11-07-2015 / 16:43:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sint1:value
^ self sint:value type:LLVMType int1
"Created: / 11-07-2015 / 16:44:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sint32:value
^ self sint:value type:LLVMType int32
"Created: / 03-08-2015 / 15:59:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sint64:value
^ self sint:value type:LLVMType int64
"Created: / 03-08-2015 / 15:59:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sint8:value
^ self sint:value type:LLVMType int8
"Created: / 26-06-2016 / 06:50:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sint:value type:type
self assert:type isIntegerType.
self assert:value isInteger.
^ LLVM ConstInt:type _:value _:1
"Created: / 11-07-2015 / 16:41:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 03-08-2015 / 17:08:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sintptr:value
^ self sint:value type:LLVMType intptr
"Created: / 03-08-2015 / 15:59:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'constants - int - unsigned'!
uint16:value
^ self uint:value type:LLVMType int16
"Created: / 03-08-2015 / 16:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uint1:value
^ self uint:value type:LLVMType int1
"Created: / 03-08-2015 / 16:01:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uint32:value
^ self uint:value type:LLVMType int32
"Created: / 03-08-2015 / 16:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uint64:value
^ self uint:value type:LLVMType int64
"Created: / 03-08-2015 / 16:01:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uint8:value
^ self uint:value type:LLVMType int8
"Created: / 26-06-2016 / 06:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uint:value type:type
self assert:type isIntegerType.
self assert:value isInteger.
^ LLVM
ConstInt:type
_:value
_:0
"Created: / 11-07-2015 / 16:41:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
uintptr:value
^ self uint:value type:LLVMType intptr
"Created: / 03-08-2015 / 16:01:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'constants - pointer'!
null: type
^ self pointer: 0 type: type
"Created: / 19-06-2016 / 18:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
pointer: value type: type
self assert: value isInteger.
self assert: type isLLVMType.
self assert: type isPointerType.
^ self int: (self uintptr: value) toPtr: type
"Created: / 19-06-2016 / 18:06:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-06-2016 / 20:33:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'constants - strings'!
string:aString
^ self string:aString nullTerminate:true
"Created: / 03-08-2015 / 16:18:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
string:aString nullTerminate:nullTerminate
self assert:aString isSingleByteString.
^ LLVM
ConstString:aString
_:aString size
_:((nullTerminate == true) ifTrue:[ 1 ] ifFalse:[ 0 ])
"Created: / 03-08-2015 / 16:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMConstant class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !