pub struct Code {
pub name: Option<Name>,
pub consts: Box<[Value]>,
pub code: Box<[u8]>,
pub kw_params: Box<[Name]>,
pub n_params: u32,
pub req_params: u32,
pub flags: u32,
pub doc: Option<String>,
}
Expand description
Represents a compiled bytecode function or expression.
Fields§
§name: Option<Name>
Code object name, if present; top-level expressions and lambda code values do not have a name.
consts: Box<[Value]>
Const values referenced in bytecode
code: Box<[u8]>
Function body bytecode
kw_params: Box<[Name]>
Names of keyword parameters accepted in the order in which they are expected.
n_params: u32
Number of positional parameters accepted; this includes optional
parameters, but excludes keyword and rest parameters, if accepted.
Optional parameter values may be Unbound
.
req_params: u32
Number of positional parameters which must not be Unbound
.
flags: u32
Miscellaneous flags; see code_flags
for bit flag values.
doc: Option<String>
Optional documentation string
Implementations§
Source§impl Code
impl Code
Sourcepub fn has_rest_params(&self) -> bool
pub fn has_rest_params(&self) -> bool
Returns whether the function accepts a rest parameter.
Sourcepub fn has_kw_params(&self) -> bool
pub fn has_kw_params(&self) -> bool
Returns whether the function accepts one or more keyword parameters.
Sourcepub fn is_trivial(&self) -> bool
pub fn is_trivial(&self) -> bool
Returns whether all bytecode instructions can be executed without side effects.
Such a code object typically results from compilation of compile-time operators.