use alloc::vec::Vec; use core::fmt; use core::result::Result;
/// A single type rule. #[derive(Clone)] pubstruct Rule { pub arguments: Vec<TypeResolution>, pub conclusion: Conclusion,
}
/// The result type of a [`Rule`]. /// /// A `Conclusion` value represents the return type of some operation /// in the builtin function database. /// /// This is very similar to [`TypeInner`], except that it represents /// predeclared types using [`PredeclaredType`], so that overload /// resolution can delegate registering predeclared types to its users. /// /// [`TypeInner`]: ir::TypeInner /// [`PredeclaredType`]: ir::PredeclaredType #[derive(Clone, Debug)] pubenum Conclusion { /// A type that can be entirely characterized by a [`TypeInner`] value. /// /// [`TypeInner`]: ir::TypeInner
Value(ir::TypeInner),
/// A type that should be registered in the module's /// [`SpecialTypes::predeclared_types`] table. /// /// This is used for operations like [`Frexp`] and [`Modf`]. /// /// [`SpecialTypes::predeclared_types`]: ir::SpecialTypes::predeclared_types /// [`Frexp`]: crate::ir::MathFunction::Frexp /// [`Modf`]: crate::ir::MathFunction::Modf
Predeclared(ir::PredeclaredType),
}
impl Conclusion { pubfn for_frexp_modf(
function: ir::MathFunction,
size: ConstructorSize,
scalar: ir::Scalar,
) -> Self { use ir::MathFunction as Mf; use ir::PredeclaredType as Pt;
let size = match size {
ConstructorSize::Scalar => None,
ConstructorSize::Vector(size) => Some(size),
ConstructorSize::Matrix { .. } => {
unreachable!("FrexpModf only supports scalars and vectors");
}
};
let predeclared = match function {
Mf::Frexp => Pt::FrexpResult { size, scalar },
Mf::Modf => Pt::ModfResult { size, scalar },
_ => {
unreachable!("FrexpModf only supports Frexp and Modf");
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.