Allow to_native_object & to_native_assembly to receive an optional fileobj to write to.
This commit is contained in:
parent
e42dfd9abb
commit
bba30621f1
1 changed files with 21 additions and 7 deletions
28
llvm/core.py
28
llvm/core.py
|
|
@ -544,15 +544,29 @@ class Module(llvm.Ownable, llvm.Cacheable):
|
||||||
|
|
||||||
id = property(_get_id, _set_id)
|
id = property(_get_id, _set_id)
|
||||||
|
|
||||||
def to_native_object(self):
|
def to_native_object(self, fileobj=None):
|
||||||
'''returns byte string of the module as native object code
|
'''Outputs the byte string of the module as native object code
|
||||||
'''
|
|
||||||
return _core.LLVMGetNativeCodeFromModule(self.ptr, 0)
|
|
||||||
|
|
||||||
def to_native_assembly(self):
|
If a fileobj is given, the output is written to it;
|
||||||
'''returns byte string of the module as native assembly code
|
Otherwise, the output is returned
|
||||||
'''
|
'''
|
||||||
return _core.LLVMGetNativeCodeFromModule(self.ptr, 1)
|
data = _core.LLVMGetNativeCodeFromModule(self.ptr, 0)
|
||||||
|
if fileobj is not None:
|
||||||
|
fileobj.write(data)
|
||||||
|
else:
|
||||||
|
return data
|
||||||
|
|
||||||
|
def to_native_assembly(self, fileobj=None):
|
||||||
|
'''Outputs the byte string of the module as native assembly code
|
||||||
|
|
||||||
|
If a fileobj is given, the output is written to it;
|
||||||
|
Otherwise, the output is returned
|
||||||
|
'''
|
||||||
|
data = _core.LLVMGetNativeCodeFromModule(self.ptr, 1)
|
||||||
|
if fileobj is not None:
|
||||||
|
fileobj.write(data)
|
||||||
|
else:
|
||||||
|
return data
|
||||||
|
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
# Types
|
# Types
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue