Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #388 from alendit/custom_context
Allow creation of other contexts besides the global one
- Loading branch information
Showing
10 changed files
with
115 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Context | ||
============ | ||
|
||
LLVMContext is an opaque context reference used to group modules into logical groups. | ||
For example, the type names are unique within a context, the name collisions | ||
are resolved by LLVM automatically. | ||
|
||
LLVMContextRef | ||
-------------- | ||
|
||
A wrapper around LLVMContext. Should not be instantiated directly, use the | ||
following methods: | ||
|
||
.. class:: LLVMContextRef | ||
|
||
* .. function:: create_context(): | ||
|
||
Create a new LLVMContext instance. | ||
|
||
* .. function:: get_global_context(): | ||
|
||
Get the reference to the global context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
from .value import * | ||
from .analysis import * | ||
from .object_file import * | ||
from .context import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import print_function, absolute_import | ||
|
||
from . import ffi | ||
|
||
|
||
def create_context(): | ||
return ContextRef(ffi.lib.LLVMPY_ContextCreate()) | ||
|
||
|
||
def get_global_context(): | ||
return GlobalContextRef(ffi.lib.LLVMPY_GetGlobalContext()) | ||
|
||
|
||
class ContextRef(ffi.ObjectRef): | ||
def __init__(self, context_ptr): | ||
super(ContextRef, self).__init__(context_ptr) | ||
|
||
def _dispose(self): | ||
ffi.lib.LLVMPY_ContextDispose(self) | ||
|
||
class GlobalContextRef(ContextRef): | ||
def _dispose(self): | ||
pass | ||
|
||
|
||
ffi.lib.LLVMPY_GetGlobalContext.restype = ffi.LLVMContextRef | ||
|
||
ffi.lib.LLVMPY_ContextCreate.restype = ffi.LLVMContextRef | ||
|
||
ffi.lib.LLVMPY_ContextDispose.argtypes = [ffi.LLVMContextRef] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters