diff options
| author | Fabian Freyer <fabian.freyer@physik.tu-berlin.de> | 2022-01-31 06:24:07 +0100 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2022-02-14 18:45:09 -0500 |
| commit | 181ad567199e5685578ecf7ad400257098c2e175 (patch) | |
| tree | 9e45c986cc8157dfe0fd6f5a8e80898d4a128309 /rust/src/basicblock.rs | |
| parent | ae7ae4f63f931342e155d77bb4cf6d75289682bf (diff) | |
rust: add ArrayGuard and for non-owned arrays
To make use of shard functionality, we split the CoreOwnedArrayProvider
into CoreArrayProvider and CoreOwnedArrayProvider. Array makes use of
the CoreOwnedArrayProvider, which depends on CoreArrayProvider, while
the new ArrayGuard only requires CoreArrayProvider and represents
a non-owned array.
Diffstat (limited to 'rust/src/basicblock.rs')
| -rw-r--r-- | rust/src/basicblock.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/rust/src/basicblock.rs b/rust/src/basicblock.rs index 0bd32af3..a1a2e244 100644 --- a/rust/src/basicblock.rs +++ b/rust/src/basicblock.rs @@ -65,16 +65,18 @@ pub struct EdgeContext<'a, C: 'a + BlockContext> { orig_block: &'a BasicBlock<C>, } -unsafe impl<'a, C: 'a + BlockContext> CoreOwnedArrayProvider for Edge<'a, C> { +impl<'a, C: 'a + BlockContext> CoreArrayProvider for Edge<'a, C> { type Raw = BNBasicBlockEdge; type Context = EdgeContext<'a, C>; +} +unsafe impl<'a, C: 'a + BlockContext> CoreOwnedArrayProvider for Edge<'a, C> { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeBasicBlockEdgeList(raw, count); } } -unsafe impl<'a, C: 'a + BlockContext> CoreOwnedArrayWrapper<'a> for Edge<'a, C> { +unsafe impl<'a, C: 'a + BlockContext> CoreArrayWrapper<'a> for Edge<'a, C> { type Wrapped = Edge<'a, C>; unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Edge<'a, C> { @@ -296,16 +298,18 @@ unsafe impl<C: BlockContext> RefCountable for BasicBlock<C> { } } -unsafe impl<C: BlockContext> CoreOwnedArrayProvider for BasicBlock<C> { +impl<C: BlockContext> CoreArrayProvider for BasicBlock<C> { type Raw = *mut BNBasicBlock; type Context = C; +} +unsafe impl<C: BlockContext> CoreOwnedArrayProvider for BasicBlock<C> { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeBasicBlockList(raw, count); } } -unsafe impl<'a, C: 'a + BlockContext> CoreOwnedArrayWrapper<'a> for BasicBlock<C> { +unsafe impl<'a, C: 'a + BlockContext> CoreArrayWrapper<'a> for BasicBlock<C> { type Wrapped = Guard<'a, BasicBlock<C>>; unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { |
