pub struct CallShape {
pub args: Vec<ArgKind>,
}Expand description
The argument layout of a dcall_shape call site: one entry per window
register (dst+1 ..= dst+len), saying whether that argument is
positional, named, or spread. Shapes live in a per-function table and
are named by a ShapeId.
§Examples
use bytecode_lang::{ArgKind, CallShape, StrId};
// f($a, ...$rest, flag: true)
let shape = CallShape::new(vec![ArgKind::Positional, ArgKind::Spread, ArgKind::Named(StrId(2))]);
assert!(shape.validate().is_ok());
assert_eq!(shape.to_string(), "(_, ..., s2:)");Fields§
§args: Vec<ArgKind>The arguments, in window order.
Implementations§
Source§impl CallShape
impl CallShape
Sourcepub fn new(args: Vec<ArgKind>) -> Self
pub fn new(args: Vec<ArgKind>) -> Self
A shape of these arguments.
§Examples
use bytecode_lang::{ArgKind, CallShape};
assert_eq!(CallShape::new(vec![ArgKind::Positional]).args.len(), 1);Sourcepub fn validate(&self) -> Result<(), ShapeError>
pub fn validate(&self) -> Result<(), ShapeError>
Checks the shape: at most 255 arguments, no positional argument or spread after a named argument or named spread, no repeated name.
§Errors
The first rule broken, as a ShapeError.
§Examples
use bytecode_lang::{ArgKind, CallShape, ShapeError, StrId};
let twice = CallShape::new(vec![ArgKind::Named(StrId(1)), ArgKind::Named(StrId(1))]);
assert_eq!(twice.validate(), Err(ShapeError::DuplicateName { index: 1 }));Trait Implementations§
impl Eq for CallShape
Source§impl Ord for CallShape
impl Ord for CallShape
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for CallShape
impl PartialOrd for CallShape
impl StructuralPartialEq for CallShape
Auto Trait Implementations§
impl Freeze for CallShape
impl RefUnwindSafe for CallShape
impl Send for CallShape
impl Sync for CallShape
impl Unpin for CallShape
impl UnsafeUnpin for CallShape
impl UnwindSafe for CallShape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more