Struct CompileContext

Source
pub struct CompileContext {
    pub variables: HashMap<String, AnyExpr>,
    pub flags: FlagSet,
    pub rules: RefCell<Vec<UnrolledRule>>,
    /* private fields */
}
Expand description

The context of unroll process.

Fields§

§variables: HashMap<String, AnyExpr>

Variables. AnyExpr is expected to be the variable variant.

§flags: FlagSet

Flags

§rules: RefCell<Vec<UnrolledRule>>

Unrolled rules

Implementations§

Source§

impl CompileContext

Source

pub fn new() -> Self

Create a new context.

Source

pub fn push_error(&self, err: Error)

Push an error.

Source

pub fn ok<T>(&self, res: Result<T, Error>) -> Option<T>

Turn a Result into an Option while pushing the error if present.

Source

pub fn take_errors(&mut self) -> Vec<Error>

Take the context’s errors.

Source

pub fn extend_errors<I: IntoIterator<Item = Error>>(&self, iter: I)

Extend the context’s errors

Source

pub fn valid(&self) -> bool

Whether the unroll step finished with no errors.

Source

pub fn push_rule(&self, rule: UnrolledRule)

Push a rule.

Source

pub fn take_rules(&mut self) -> Vec<UnrolledRule>

Take the context’s rules.

Source§

impl CompileContext

Everything related to circles.

Source

pub fn point_on_circle( &mut self, lhs: &Expr<Point>, rhs: &Expr<Circle>, weight: ProcNum, )

A point lies on circle rule.

Source

pub fn point_on_line( &mut self, lhs: &Expr<Point>, rhs: &Expr<Line>, weight: ProcNum, )

A point lies on line rule.

Source§

impl CompileContext

Source

pub fn expr_with<T: Displayed>( &self, content: T, display: Properties, nodes: Vec<Box<dyn Node>>, ) -> Expr<T>
where T::Node: FromExpr<T>,

Create an expression with properties and nodes.

Source

pub fn average_p_display( &self, points: Vec<Expr<Point>>, display: Properties, ) -> Expr<Point>

An average pointe expression with display options.

Source

pub fn average_p(&self, points: Vec<Expr<Point>>) -> Expr<Point>

Average point expression with no properties.

Source

pub fn average_s_display( &self, values: Vec<Expr<Number>>, display: Properties, ) -> Expr<Number>

Average scalar expression with display options.

Source

pub fn average_s(&self, points: Vec<Expr<Number>>) -> Expr<Number>

Average scalar expression with no properties.

Source

pub fn set_unit_display( &self, v: Expr<Number>, unit: ComplexUnit, display: Properties, ) -> Expr<Number>

Set unit expression with properties.

Source

pub fn set_unit(&self, v: Expr<Number>, unit: ComplexUnit) -> Expr<Number>

Set unit expression with no properties.

Source

pub fn free_point_display(&self, display: Properties) -> Expr<Point>

Free point expression with properties.

Source

pub fn free_point(&self) -> Expr<Point>

Free point expression with no properties.

Source

pub fn free_scalar_display(&self, display: Properties) -> Expr<Number>

Free scalar expression with properties.

Source

pub fn free_scalar(&self) -> Expr<Number>

Free scalar expression with no properties.

Source

pub fn intersection_display( &self, k: Expr<Line>, l: Expr<Line>, display: Properties, ) -> Expr<Point>

Source

pub fn intersection(&self, k: Expr<Line>, l: Expr<Line>) -> Expr<Point>

Source

pub fn distance_pp_display( &self, p: Expr<Point>, q: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn distance_pp(&self, p: Expr<Point>, q: Expr<Point>) -> Expr<Number>

Source

pub fn distance_pl_display( &self, p: Expr<Point>, k: Expr<Line>, display: Properties, ) -> Expr<Number>

Source

pub fn distance_pl(&self, p: Expr<Point>, k: Expr<Line>) -> Expr<Number>

Source

pub fn circle_center_display( &self, c: Expr<Circle>, display: Properties, ) -> Expr<Point>

Source

pub fn circle_center(&self, c: Expr<Circle>) -> Expr<Point>

Source

pub fn circle_radius_display( &self, c: Expr<Circle>, display: Properties, ) -> Expr<Number>

Source

pub fn circle_radius(&self, c: Expr<Circle>) -> Expr<Number>

Source

pub fn line_display( &self, a: Expr<Point>, b: Expr<Point>, display: Properties, ) -> Expr<Line>

Source

pub fn line(&self, a: Expr<Point>, b: Expr<Point>) -> Expr<Line>

Source

pub fn angle_ppp_display( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn angle_ppp( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, ) -> Expr<Number>

Source

pub fn angle_dir_display( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn angle_dir( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, ) -> Expr<Number>

Source

pub fn angle_ll_display( &self, k: Expr<Line>, l: Expr<Line>, display: Properties, ) -> Expr<Number>

Source

pub fn angle_ll(&self, k: Expr<Line>, l: Expr<Line>) -> Expr<Number>

Source

pub fn bisector_ppp_display( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, display: Properties, ) -> Expr<Line>

Source

pub fn bisector_ppp( &self, a: Expr<Point>, b: Expr<Point>, c: Expr<Point>, ) -> Expr<Line>

Source

pub fn perpendicular_through_display( &self, line: Expr<Line>, point: Expr<Point>, display: Properties, ) -> Expr<Line>

Source

pub fn perpendicular_through( &self, line: Expr<Line>, point: Expr<Point>, ) -> Expr<Line>

Source

pub fn parallel_through_display( &self, line: Expr<Line>, point: Expr<Point>, display: Properties, ) -> Expr<Line>

Source

pub fn parallel_through( &self, line: Expr<Line>, point: Expr<Point>, ) -> Expr<Line>

Source

pub fn circle_display( &self, center: Expr<Point>, radius: Expr<Number>, display: Properties, ) -> Expr<Circle>

Source

pub fn circle(&self, center: Expr<Point>, radius: Expr<Number>) -> Expr<Circle>

Source

pub fn add_display( &self, a: Expr<Number>, b: Expr<Number>, display: Properties, ) -> Expr<Number>

Source

pub fn add(&self, a: Expr<Number>, b: Expr<Number>) -> Expr<Number>

Source

pub fn sub_display( &self, a: Expr<Number>, b: Expr<Number>, display: Properties, ) -> Expr<Number>

Source

pub fn sub(&self, a: Expr<Number>, b: Expr<Number>) -> Expr<Number>

Source

pub fn real_display(&self, v: Expr<Number>, display: Properties) -> Expr<Number>

Source

pub fn real(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn imaginary_display( &self, v: Expr<Number>, display: Properties, ) -> Expr<Number>

Source

pub fn imaginary(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn to_complex_display( &self, p: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn to_complex(&self, p: Expr<Point>) -> Expr<Number>

Source

pub fn to_point_display( &self, v: Expr<Number>, display: Properties, ) -> Expr<Point>

Source

pub fn to_point(&self, v: Expr<Number>) -> Expr<Point>

Source

pub fn sin_display(&self, v: Expr<Number>, display: Properties) -> Expr<Number>

Source

pub fn sin(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn cos_display(&self, v: Expr<Number>, display: Properties) -> Expr<Number>

Source

pub fn cos(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn log_display(&self, v: Expr<Number>, display: Properties) -> Expr<Number>

Source

pub fn log(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn direction_display( &self, k: Expr<Line>, display: Properties, ) -> Expr<Number>

Source

pub fn direction(&self, k: Expr<Line>) -> Expr<Number>

Source

pub fn neg_display(&self, v: Expr<Number>, display: Properties) -> Expr<Number>

Source

pub fn neg(&self, v: Expr<Number>) -> Expr<Number>

Source

pub fn point_vector_display( &self, p: Expr<Point>, v: Expr<Number>, display: Properties, ) -> Expr<Line>

Source

pub fn point_vector(&self, p: Expr<Point>, v: Expr<Number>) -> Expr<Line>

Source

pub fn point_x_display( &self, p: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn point_x(&self, p: Expr<Point>) -> Expr<Number>

Source

pub fn point_y_display( &self, p: Expr<Point>, display: Properties, ) -> Expr<Number>

Source

pub fn point_y(&self, p: Expr<Point>) -> Expr<Number>

Source

pub fn mult_display( &self, a: Expr<Number>, b: Expr<Number>, display: Properties, ) -> Expr<Number>

Source

pub fn mult(&self, a: Expr<Number>, b: Expr<Number>) -> Expr<Number>

Source

pub fn pow_display( &self, v: Expr<Number>, exponent: Ratio<i64>, display: Properties, ) -> Expr<Number>

Source

pub fn pow(&self, v: Expr<Number>, exponent: Ratio<i64>) -> Expr<Number>

Source

pub fn div_display( &self, a: Expr<Number>, b: Expr<Number>, display: Properties, ) -> Expr<Number>

Source

pub fn div(&self, a: Expr<Number>, b: Expr<Number>) -> Expr<Number>

Source§

impl CompileContext

Source

pub fn scalar_eq_display( &mut self, lhs: Expr<Number>, rhs: Expr<Number>, inverted: bool, display: Properties, ) -> Box<dyn Node>

Source

pub fn scalar_eq( &mut self, lhs: Expr<Number>, rhs: Expr<Number>, inverted: bool, ) -> Box<dyn Node>

Source

pub fn point_eq_display( &mut self, lhs: Expr<Point>, rhs: Expr<Point>, inverted: bool, display: Properties, ) -> Box<dyn Node>

Source

pub fn point_eq( &mut self, lhs: Expr<Point>, rhs: Expr<Point>, inverted: bool, ) -> Box<dyn Node>

Source

pub fn gt_display( &mut self, lhs: Expr<Number>, rhs: Expr<Number>, inverted: bool, display: Properties, ) -> Box<dyn Node>

Source

pub fn gt( &mut self, lhs: Expr<Number>, rhs: Expr<Number>, inverted: bool, ) -> Box<dyn Node>

Trait Implementations§

Source§

impl Debug for CompileContext

Source§

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

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

impl Default for CompileContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Convert for T

Source§

fn convert<U>(self, context: &CompileContext) -> Expr<U>
where U: ConvertFrom<T>,

Convert self into a specific type. Read more
Source§

fn can_convert<U>(&self) -> bool
where U: ConvertFrom<T>,

Check if self can be converted into a specific type. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.