#[non_exhaustive]pub enum ClassOp {
New,
InstanceOf,
Clone,
}Expand description
A class operation: compiled inline against the classes the unit declares, with a host function for whatever the unit does not declare.
§Examples
use bcgen_lang::{Arity, ClassOp};
assert_eq!(ClassOp::InstanceOf.arity(), Arity::range(1, 2));
assert_eq!(ClassOp::New.arity(), Arity::at_least(0));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
New
new C(args): the class is the intrinsic’s type argument
(mox.new<C>(args)), else operand 1, and the rest are the
constructor’s arguments (spread and named ones included, through an
extern call). A class of the unit (a path, C::class,
self::class, parent::class) is instantiated inline: a new struct,
its property defaults, then the constructor, with the arguments
bound by the constructor’s parameter list. static::class and a
class value only known at run time (a string name, an object) are
looked up among the unit’s classes at run time; a name the unit does
not declare goes to the host function with the name and the
arguments (positional only).
InstanceOf
x instanceof C: the class or interface is the type argument
(mox.instanceof<I>(x), the only way HIR can name an interface in
an expression), else operand 2. Inline for the unit’s classes
(is_type) and interfaces (a marker method); a class value only
known at run time is looked up the same way; anything else goes to
the host function.
Clone
clone x: an instance of a unit class is copied (dup, a new
identity; array properties copy on write) and the clone method
(Options::clone_method) is called
on the copy when its class has one; every other value goes to the
host function.