#[repr(C)]pub struct MethodDefinition<'gc> {
pub metadata: NodeMetadata<'gc>,
pub key: &'gc Node<'gc>,
pub value: &'gc Node<'gc>,
pub kind: Cell<NodeLabel>,
pub computed: Cell<bool>,
pub static: Cell<bool>,
pub decorators: NodeList<'gc>,
}Expand description
The MethodDefinition AST node.
Fields§
§metadata: NodeMetadata<'gc>Source range, debug location, paren count, and node id.
key: &'gc Node<'gc>ESTree key property.
value: &'gc Node<'gc>ESTree value property.
kind: Cell<NodeLabel>ESTree kind property.
computed: Cell<bool>ESTree computed property.
static: Cell<bool>ESTree static property.
decorators: NodeList<'gc>ESTree decorators property.
Implementations§
Source§impl<'gc> MethodDefinition<'gc>
impl<'gc> MethodDefinition<'gc>
Sourcepub fn new(
metadata: NodeMetadata<'gc>,
key: &'gc Node<'gc>,
value: &'gc Node<'gc>,
kind: NodeLabel,
computed: bool,
static: bool,
decorators: NodeList<'gc>,
) -> Self
pub fn new( metadata: NodeMetadata<'gc>, key: &'gc Node<'gc>, value: &'gc Node<'gc>, kind: NodeLabel, computed: bool, static: bool, decorators: NodeList<'gc>, ) -> Self
Build MethodDefinition from its metadata and ESTree.def fields.
Sourcepub fn kind_str<'a>(&self, gc: &'a GCLock<'_, '_>) -> &'a str
pub fn kind_str<'a>(&self, gc: &'a GCLock<'_, '_>) -> &'a str
The kind label as UTF-8 text.
Label fields hold identifier names, operators, keyword-like kinds and raw source spans. An identifier cannot contain an unpaired surrogate — the lexer rejects one with a dedicated diagnostic — and the remaining labels are literal source text, so in practice the bytes are already valid UTF-8 and this borrows them directly, allocating nothing.
A label that is nevertheless unrepresentable, which realistically means
a hand-built AST rather than a parsed one, has each unpaired surrogate
rendered as a single U+FFFD instead of being reported. Only an unpaired
surrogate is affected: a WTF-8 surrogate pair is folded back into the
character it encodes, so a "😀" label comes out intact.
Use GCLock::bytes for the exact
bytes, or
GCLock::try_bytes_str to
detect the substitution. The returned &str borrows from gc, not from
self.