diff --git a/newbinding/src/Function.py b/newbinding/src/Function.py new file mode 100644 index 0000000..7077d3a --- /dev/null +++ b/newbinding/src/Function.py @@ -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)) \ No newline at end of file diff --git a/newbinding/src/GlobalValue.py b/newbinding/src/GlobalValue.py new file mode 100644 index 0000000..f1a6827 --- /dev/null +++ b/newbinding/src/GlobalValue.py @@ -0,0 +1,8 @@ +from binding import * +from namespace import llvm +from Constant import Constant + +@llvm.Class(Constant) +class GlobalValue: + _include_ = 'llvm/GlobalValue.h' + diff --git a/newbinding/src/Module.py b/newbinding/src/Module.py index 6a6a806..730b757 100644 --- a/newbinding/src/Module.py +++ b/newbinding/src/Module.py @@ -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 diff --git a/newbinding/src/Value.py b/newbinding/src/Value.py index 9d1a2dd..30b3f37 100644 --- a/newbinding/src/Value.py +++ b/newbinding/src/Value.py @@ -24,4 +24,4 @@ class Value: getName = Method(cast(StringRef, str)) setName = Method(Void, cast(str, StringRef)) - replaceAllUsesWith = Method(Void, ptr(Value)) \ No newline at end of file + replaceAllUsesWith = Method(Void, ptr(Value)) diff --git a/newbinding/test2.py b/newbinding/test2.py index afb3608..3429f10 100644 --- a/newbinding/test2.py +++ b/newbinding/test2.py @@ -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()