Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/ast/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ pub struct Imports {
pub(crate) __promiseAll: Ref,
pub(crate) __MEMO_CACHE_SENTINEL: Ref,
pub(crate) __EARLY_RETURN_SENTINEL: Ref,
pub(crate) __superGet: Ref,
pub(crate) __superSet: Ref,
pub(crate) __superWrapper: Ref,
pub(crate) __superDelete: Ref,
}

impl Imports {
pub const ALL: [&'static [u8]; 27] = [
pub const ALL: [&'static [u8]; 31] = [
b"__name",
b"__require",
b"__export",
Expand Down Expand Up @@ -206,12 +210,16 @@ impl Imports {
b"__promiseAll",
b"__MEMO_CACHE_SENTINEL",
b"__EARLY_RETURN_SENTINEL",
b"__superGet",
b"__superSet",
b"__superWrapper",
b"__superDelete",
];

/// Rust stable cannot sort in `const`; precomputed here and verified by
/// the test in `tests` below.
#[cfg_attr(not(test), allow(dead_code))]
const ALL_SORTED: [&'static [u8]; 27] = [
const ALL_SORTED: [&'static [u8]; 31] = [
b"$$typeof",
b"__EARLY_RETURN_SENTINEL",
b"__MEMO_CACHE_SENTINEL",
Expand All @@ -238,12 +246,16 @@ impl Imports {
b"__reExport",
b"__require",
b"__runInitializers",
b"__superDelete",
b"__superGet",
b"__superSet",
b"__superWrapper",
b"__using",
];

/// When generating the list of runtime imports, we sort it for determinism.
/// This is a lookup table so we don't need to resort the strings each time
pub const ALL_SORTED_INDEX: [usize; 27] = [
pub const ALL_SORTED_INDEX: [usize; 31] = [
15, // __name
24, // __require
7, // __export
Expand All @@ -265,12 +277,16 @@ impl Imports {
25, // __runInitializers
4, // __decorateElement
0, // $$typeof
26, // __using
30, // __using
3, // __callDispose
10, // __jsonParse
21, // __promiseAll
2, // __MEMO_CACHE_SENTINEL
1, // __EARLY_RETURN_SENTINEL
27, // __superGet
28, // __superSet
29, // __superWrapper
26, // __superDelete
];

pub const NAME: &'static [u8] = b"bun:wrap";
Expand Down Expand Up @@ -306,6 +322,10 @@ impl Imports {
24 => self.__promiseAll,
25 => self.__MEMO_CACHE_SENTINEL,
26 => self.__EARLY_RETURN_SENTINEL,
27 => self.__superGet,
28 => self.__superSet,
29 => self.__superWrapper,
30 => self.__superDelete,
_ => return None,
};
r.to_nullable()
Expand Down Expand Up @@ -341,6 +361,10 @@ impl Imports {
24 => Some(&mut self.__promiseAll),
25 => Some(&mut self.__MEMO_CACHE_SENTINEL),
26 => Some(&mut self.__EARLY_RETURN_SENTINEL),
27 => Some(&mut self.__superGet),
28 => Some(&mut self.__superSet),
29 => Some(&mut self.__superWrapper),
30 => Some(&mut self.__superDelete),
_ => None,
}
}
Expand Down
Loading