Add CustonPythonMethod and CustonPythonStaticMethod.
This commit is contained in:
parent
7aa9487f2f
commit
895d114730
5 changed files with 66 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from Value import Function, BasicBlock
|
||||
from Instruction import Instruction, TerminatorInst
|
||||
from LLVMContext import LLVMContext
|
||||
from StringRef import StringRef
|
||||
|
||||
|
|
@ -12,6 +13,8 @@ class BasicBlock:
|
|||
ptr(BasicBlock))
|
||||
|
||||
getParent = Method(ptr(Function))
|
||||
getTerminator = Method(ptr(TerminatorInst))
|
||||
|
||||
empty = Method(cast(Bool, bool))
|
||||
dropAllReferences = Method()
|
||||
isLandingPad = Method(cast(Bool, bool))
|
||||
|
|
|
|||
|
|
@ -9,8 +9,23 @@ FunctionType = llvm.Class(Type)
|
|||
@FunctionType
|
||||
class FunctionType:
|
||||
_include_ = 'llvm/DerivedTypes.h'
|
||||
get = StaticMethod(ptr(FunctionType), ptr(Type), cast(bool, Bool))
|
||||
get |= StaticMethod(ptr(FunctionType), ptr(Type), ref(SmallVector_Type), cast(bool, Bool))
|
||||
|
||||
_get = StaticMethod(ptr(FunctionType), ptr(Type), cast(bool, Bool))
|
||||
_get |= StaticMethod(ptr(FunctionType), ptr(Type), ref(SmallVector_Type),
|
||||
cast(bool, Bool))
|
||||
_get.realname = 'get'
|
||||
|
||||
@CustomPythonStaticMethod
|
||||
def get(*args):
|
||||
import extra
|
||||
if len(args) == 3:
|
||||
typelist = args[1]
|
||||
sv = extra.make_small_vector_from_types(*typelist)
|
||||
return FunctionType._get(args[0], sv, args[2])
|
||||
else:
|
||||
return FunctionType._get(*args)
|
||||
|
||||
|
||||
isVarArg = Method(cast(Bool, bool))
|
||||
getReturnType = Method(ptr(Type))
|
||||
getParamType = Method(ptr(Type), cast(int, Unsigned))
|
||||
|
|
|
|||
|
|
@ -37,3 +37,10 @@ class Value:
|
|||
hasOneUse = Method(cast(Bool, bool))
|
||||
hasNUses = Method(cast(Bool, bool), cast(int, Unsigned))
|
||||
isUsedInBasicBlock = Method(cast(Bool, bool), BasicBlock)
|
||||
|
||||
@CustomPythonMethod
|
||||
def __str__(self):
|
||||
import extra
|
||||
os = extra.make_raw_ostream_for_printing()
|
||||
self.print_(os, None)
|
||||
return os.str()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue