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:
parent
8e9d163e2b
commit
c10b1b58c3
10 changed files with 82 additions and 18 deletions
15
llvm/core.py
15
llvm/core.py
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue