use swc_atoms::Atom;
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, Default)]
pub struct Context: u8 {
const IgnoreError = 1 << 0;
const Module = 1 << 1;
const Strict = 1 << 2;
}
}
impl Context {
#[cfg_attr(not(feature = "verify"), inline(always))]
pub fn is_reserved_word(self, word: &Atom) -> bool {
if !cfg!(feature = "verify") {
return false;
}
match &**word {
"let" => self.contains(Context::Strict),
"await" => self.contains(Context::Module),
"yield" => self.contains(Context::Strict),
"null" | "true" | "false" | "break" | "case" | "catch" | "continue" | "debugger"
| "default" | "do" | "export" | "else" | "finally" | "for" | "function" | "if"
| "return" | "switch" | "throw" | "try" | "var" | "const" | "while" | "with"
| "new" | "this" | "super" | "class" | "extends" | "import" | "in" | "instanceof"
| "typeof" | "void" | "delete" => true,
"enum" => true,
"implements" | "package" | "protected" | "interface" | "private" | "public"
if self.contains(Context::Strict) =>
{
true
}
_ => false,
}
}
}