Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 22 additions & 4 deletions src/ast/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ 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,
}

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

/// 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]; 30] = [
b"$$typeof",
b"__EARLY_RETURN_SENTINEL",
b"__MEMO_CACHE_SENTINEL",
Expand All @@ -238,12 +244,15 @@ impl Imports {
b"__reExport",
b"__require",
b"__runInitializers",
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; 30] = [
15, // __name
24, // __require
7, // __export
Expand All @@ -265,12 +274,15 @@ impl Imports {
25, // __runInitializers
4, // __decorateElement
0, // $$typeof
26, // __using
29, // __using
3, // __callDispose
10, // __jsonParse
21, // __promiseAll
2, // __MEMO_CACHE_SENTINEL
1, // __EARLY_RETURN_SENTINEL
26, // __superGet
27, // __superSet
28, // __superWrapper
];

pub const NAME: &'static [u8] = b"bun:wrap";
Expand Down Expand Up @@ -306,6 +318,9 @@ impl Imports {
24 => self.__promiseAll,
25 => self.__MEMO_CACHE_SENTINEL,
26 => self.__EARLY_RETURN_SENTINEL,
27 => self.__superGet,
28 => self.__superSet,
29 => self.__superWrapper,
_ => return None,
};
r.to_nullable()
Expand Down Expand Up @@ -341,6 +356,9 @@ 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),
_ => None,
}
}
Expand Down
Loading