Add Function and some Function methods
This commit is contained in:
parent
3c81157ede
commit
c76096bbcb
5 changed files with 40 additions and 2 deletions
19
newbinding/src/Function.py
Normal file
19
newbinding/src/Function.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from GlobalValue import GlobalValue
|
||||
from Constant import Constant
|
||||
from Type import Type
|
||||
from DerivedTypes import FunctionType
|
||||
from LLVMContext import LLVMContext
|
||||
|
||||
@llvm.Class(GlobalValue)
|
||||
class Function:
|
||||
_include_ = 'llvm/Function.h'
|
||||
_downcast_ = GlobalValue, Constant
|
||||
|
||||
getReturnType = Method(ptr(Type))
|
||||
getFunctionType = Method(ptr(FunctionType))
|
||||
getContext = Method(ref(LLVMContext))
|
||||
isVarArg = Method(cast(Bool, bool))
|
||||
getIntrinsicID = Method(cast(Unsigned, int))
|
||||
isIntrinsic = Method(cast(Bool, bool))
|
||||
8
newbinding/src/GlobalValue.py
Normal file
8
newbinding/src/GlobalValue.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from Constant import Constant
|
||||
|
||||
@llvm.Class(Constant)
|
||||
class GlobalValue:
|
||||
_include_ = 'llvm/GlobalValue.h'
|
||||
|
||||
|
|
@ -3,6 +3,7 @@ from namespace import llvm
|
|||
from LLVMContext import LLVMContext
|
||||
from StringRef import StringRef
|
||||
from Constant import Constant
|
||||
from Function import Function
|
||||
from DerivedTypes import FunctionType
|
||||
from raw_ostream import raw_ostream
|
||||
from AssemblyAnnotationWriter import AssemblyAnnotationWriter
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ class Value:
|
|||
getName = Method(cast(StringRef, str))
|
||||
setName = Method(Void, cast(str, StringRef))
|
||||
|
||||
replaceAllUsesWith = Method(Void, ptr(Value))
|
||||
replaceAllUsesWith = Method(Void, ptr(Value))
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ os = extra.make_raw_ostream_for_printing()
|
|||
fnty.print_(os)
|
||||
print os.str()
|
||||
|
||||
fn = m.getOrInsertFunction("foo", fnty)
|
||||
const = m.getOrInsertFunction("foo", fnty)
|
||||
fn = extra.downcast(const, api.Function)
|
||||
os = extra.make_raw_ostream_for_printing()
|
||||
fn.print_(os, None)
|
||||
print os.str()
|
||||
|
|
@ -45,3 +46,12 @@ assert fn.hasName()
|
|||
assert 'foo' == fn.getName()
|
||||
fn.setName('bar')
|
||||
assert 'bar' == fn.getName()
|
||||
|
||||
os = extra.make_raw_ostream_for_printing()
|
||||
assert fn.getReturnType() is int1ty
|
||||
|
||||
assert fnty is fn.getFunctionType()
|
||||
|
||||
assert fn.isVarArg() == False
|
||||
assert fn.getIntrinsicID() == 0
|
||||
assert not fn.isIntrinsic()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue