Skip to main content

Fast

Enum Fast 

Source
#[non_exhaustive]
pub enum Fast {
Show 24 variants Concat, ConcatN, IntRem, NumPow, IntShl, IntShr, ScalarXor, LooseEq, LooseNe, StrictEq, StrictNe, Lt, Le, Gt, Ge, IntSpaceship, NumIdentity, IntBitNot, ToInt, ToFloat, ToStr, ToBool, ToArray, StrOffset,
}
Expand description

A guarded fast path: the operand kinds where an LSB sequence computes exactly the intrinsic’s result, tested at run time; outside that domain the intrinsic’s host function is called with the same operands.

Each variant states its domain (where the inline code runs) and what it computes there. The domains are chosen so that the inline result is PHP 8’s (Mox’s) result; a host function bound to the same intrinsic must agree with the fast path on its domain, and is free everywhere else. Kinds are LSB dynamic kinds (§2.2): nil, bool, int (i64), float (f64), str (bytes), map.

§Examples

use bcgen_lang::{Arity, Fast};

assert_eq!(Fast::LooseEq.arity(), Arity::exact(2));
assert_eq!(Fast::ConcatN.arity(), Arity::at_least(0));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Concat

Domain: both str. Result: the byte concatenation.

§

ConcatN

Domain: every operand str (any count, none included). Result: the byte concatenation in order ("" for none), one str_concat_n.

§

IntRem

Domain: both int. Result: the truncated remainder (the sign follows the dividend; MIN % -1 is 0); a zero divisor raises DivByZero (E0002) at the intrinsic.

§

NumPow

Domain: both numbers (int or float). Result: dpow with overflow = promote: an exact int power when it fits, else the nearest float; a negative integer exponent gives the float power; floats by the family’s ls_pow.

§

IntShl

Domain: both int. Result: shl with shift = saturate (an amount of 64 or more gives 0; a negative amount raises ShiftOutOfRange, E0003).

§

IntShr

Domain: both int. Result: arithmetic shr with shift = saturate (64 or more gives 0, or -1 for a negative value; a negative amount raises ShiftOutOfRange).

§

ScalarXor

Domain: both in nil, bool, int, float. Result: the exclusive or of their truthiness (nil, false, 0, ±0.0 are false; NaN is true), a bool.

§

LooseEq

Domain: the same kind in nil, bool, int, float (equality by value; IEEE for floats, so NaN equals nothing and -0.0 == 0.0), or two str with equal bytes (true). A bool.

§

LooseNe

The negation of LooseEq, on the same domain.

§

StrictEq

Domain: both in nil, bool, int, float, str. Result: true exactly when the kinds are equal and the values are (floats by IEEE, strings by bytes). A bool.

§

StrictNe

The negation of StrictEq, on the same domain.

§

Lt

Domain: two ints or two floats. Result: a < b (false with NaN).

§

Le

Domain: two ints or two floats. Result: a <= b.

§

Gt

Domain: two ints or two floats. Result: a > b.

§

Ge

Domain: two ints or two floats. Result: a >= b.

§

IntSpaceship

Domain: two ints. Result: -1, 0, or 1 as an int.

§

NumIdentity

Domain: an int or a float. Result: the operand.

§

IntBitNot

Domain: an int. Result: its bitwise complement.

§

ToInt

Domain: int (itself), bool (0 or 1), nil (0), and float by PHP 7/8’s zend_dval_to_lval on 64-bit platforms: truncated toward zero when in [-2^63, 2^63), NaN and infinities 0, and any other finite value taken modulo 2^64 into the signed range (1e19 is -8446744073709551616, -1e19 is 8446744073709551616). An int.

§

ToFloat

Domain: float (itself), int (the nearest float, ties to even), bool (0.0 or 1.0), nil (0.0). A float.

§

ToStr

Domain: str. Result: the operand.

§

ToBool

Domain: nil, bool, int, float. Result: the truthiness, a bool.

§

ToArray

Domain: map. Result: the operand.

§

StrOffset

Domain: a str and an int offset i with -len <= i < len. Result: the one-byte string at i (counted from the end when negative), PHP 7.1+’s $s[i]. Out-of-range offsets and every other operand kind go to the host function (PHP: a warning and "", or a TypeError for an offset that is not an integer).

Implementations§

Source§

impl Fast

Source

pub const fn arity(self) -> Arity

The operands the fast path takes.

§Examples
assert_eq!(bcgen_lang::Fast::ToInt.arity().min(), 1);

Trait Implementations§

Source§

impl Clone for Fast

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Fast

Source§

impl Debug for Fast

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Fast

Source§

impl Hash for Fast

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Fast

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Fast

Auto Trait Implementations§

§

impl Freeze for Fast

§

impl RefUnwindSafe for Fast

§

impl Send for Fast

§

impl Sync for Fast

§

impl Unpin for Fast

§

impl UnsafeUnpin for Fast

§

impl UnwindSafe for Fast

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.