1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! The dummy `VMExternRef` for when the `gc` cargo feature is disabled.
//!
//! To reduce `#[cfg(...)]`s, this provides all the same methods as the real
//! `VMExternRef` except for constructors.

#![allow(missing_docs)]

use crate::{ModuleInfoLookup, VMRuntimeLimits};
use std::any::Any;
use std::cmp;
use std::hash::Hasher;
use std::ops::Deref;

#[derive(Clone)]
enum Uninhabited {}

#[derive(Clone)]
pub struct VMExternRef(Uninhabited);

impl std::fmt::Pointer for VMExternRef {
    fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self.0 {}
    }
}

impl Drop for VMExternRef {
    fn drop(&mut self) {
        match self.0 {}
    }
}

impl VMExternRef {
    /// This method is only available when the `gc` cargo feature is *disabled*.
    pub fn assert_unreachable<T>(&self) -> T {
        match self.0 {}
    }

    pub fn as_raw(&self) -> *mut u8 {
        match self.0 {}
    }

    pub unsafe fn into_raw(self) -> *mut u8 {
        match self.0 {}
    }

    pub unsafe fn from_raw(ptr: *mut u8) -> Option<Self> {
        assert!(ptr.is_null());
        None
    }

    pub unsafe fn clone_from_raw(ptr: *mut u8) -> Option<Self> {
        assert!(ptr.is_null());
        None
    }

    pub fn strong_count(&self) -> usize {
        match self.0 {}
    }

    pub fn eq(a: &Self, _b: &Self) -> bool {
        match a.0 {}
    }

    pub fn hash<H>(externref: &Self, _hasher: &mut H)
    where
        H: Hasher,
    {
        match externref.0 {}
    }

    pub fn cmp(a: &Self, _b: &Self) -> cmp::Ordering {
        match a.0 {}
    }
}

impl Deref for VMExternRef {
    type Target = dyn Any;

    fn deref(&self) -> &dyn Any {
        match self.0 {}
    }
}

pub struct VMExternRefActivationsTable {
    _priv: (),
}

impl VMExternRefActivationsTable {
    pub fn new() -> Self {
        Self { _priv: () }
    }

    pub fn bump_capacity_remaining(&self) -> usize {
        usize::MAX
    }

    pub fn try_insert(&mut self, externref: VMExternRef) -> Result<(), VMExternRef> {
        match externref.0 {}
    }

    pub unsafe fn insert_with_gc(
        &mut self,
        _limits: *const VMRuntimeLimits,
        externref: VMExternRef,
        _module_info_lookup: &dyn ModuleInfoLookup,
    ) {
        match externref.0 {}
    }

    pub fn insert_without_gc(&mut self, externref: VMExternRef) {
        match externref.0 {}
    }

    pub fn set_gc_okay(&mut self, _okay: bool) -> bool {
        true
    }
}

pub unsafe fn gc(
    _limits: *const VMRuntimeLimits,
    _module_info_lookup: &dyn ModuleInfoLookup,
    _externref_activations_table: &mut VMExternRefActivationsTable,
) {
    // Nothing to do.
}