Added API for reading assembly (.ll) files

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@35 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2008-09-08 13:09:43 +00:00
commit c10b1b58c3
10 changed files with 82 additions and 18 deletions

View file

@ -751,6 +751,21 @@ class Module(llvm.Ownable):
else:
return Module(ret)
@staticmethod
def from_assembly(fileobj):
"""Create a Module instance from the contents of an LLVM
assembly (.ll) file."""
data = fileobj.read()
ret = _core.LLVMGetModuleFromAssembly(data)
if not ret:
raise llvm.LLVMException, \
"Unable to create module from assembly"
elif isinstance(ret, str):
raise llvm.LLVMException, ret
else:
return Module(ret)
def __init__(self, ptr):
"""DO NOT CALL DIRECTLY.