Add Linker and Assembly (IR) Parser
This commit is contained in:
parent
450c29e052
commit
c98a1274d9
3 changed files with 75 additions and 0 deletions
14
newbinding/src/Assembly/Parser.py
Normal file
14
newbinding/src/Assembly/Parser.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from binding import *
|
||||
from ..namespace import llvm
|
||||
from ..Module import Module
|
||||
from ..LLVMContext import LLVMContext
|
||||
from ..Support.SourceMgr import SMDiagnostic
|
||||
|
||||
llvm.includes.add('llvm/Assembly/Parser.h')
|
||||
|
||||
ParseAssemblyString = llvm.Function('ParseAssemblyString',
|
||||
ptr(Module),
|
||||
cast(str, ConstCharPtr),
|
||||
ptr(Module), # can be None
|
||||
ref(SMDiagnostic),
|
||||
ref(LLVMContext))
|
||||
51
newbinding/src/Linker.py
Normal file
51
newbinding/src/Linker.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from ADT.StringRef import StringRef
|
||||
from Module import Module
|
||||
from LLVMContext import LLVMContext
|
||||
|
||||
llvm.includes.add('llvm/Linker.h')
|
||||
|
||||
Linker = llvm.Class()
|
||||
|
||||
@Linker
|
||||
class Linker:
|
||||
ControlFlags = Enum('Verbose, QuietWarnings, QuietErrors')
|
||||
LinkerMode = Enum('DestroySource, PreserveSource')
|
||||
|
||||
_new_w_empty = Constructor(cast(str, StringRef),
|
||||
cast(str, StringRef),
|
||||
ref(LLVMContext),
|
||||
cast(int, Unsigned)).require_only(3)
|
||||
|
||||
_new_w_existing = Constructor(cast(str, StringRef),
|
||||
ptr(Module),
|
||||
cast(int, Unsigned)).require_only(2)
|
||||
|
||||
@CustomPythonStaticMethod
|
||||
def new(progname, module_or_name, *args):
|
||||
if isinstance(module_or_name, Module):
|
||||
return _new_w_existing(progname, module_or_name, *args)
|
||||
else:
|
||||
return _new_w_empty(progname, module_or_name, *args)
|
||||
|
||||
delete = Destructor()
|
||||
|
||||
getModule = Method(ptr(Module))
|
||||
releaseModule = Method(ptr(Module))
|
||||
getLastError = Method(cast(ConstStdString, str))
|
||||
|
||||
LinkInModule = CustomMethod('Linker_LinkInModule',
|
||||
PyObjectPtr, # boolean
|
||||
ptr(Module),
|
||||
PyObjectPtr, # errmsg
|
||||
)
|
||||
|
||||
LinkModules = CustomStaticMethod('Linker_LinkModules',
|
||||
PyObjectPtr, # boolean
|
||||
ptr(Module),
|
||||
ptr(Module),
|
||||
LinkerMode,
|
||||
PyObjectPtr, # errsg
|
||||
)
|
||||
|
||||
10
newbinding/src/Support/SourceMgr.py
Normal file
10
newbinding/src/Support/SourceMgr.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from binding import *
|
||||
from ..namespace import llvm
|
||||
|
||||
llvm.includes.add('llvm/Support/SourceMgr.h')
|
||||
|
||||
@llvm.Class()
|
||||
class SMDiagnostic:
|
||||
new = Constructor()
|
||||
delete = Destructor()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue