[][src]Enum ggbasm::ast::Expr

pub enum Expr {
    Ident(String),
    Const(i64),
    Binary(Box<BinaryExpr>),
    Unary(Box<UnaryExpr>),
}

Assembly uses constant expressions to avoid copying magic numbers around. Expr represents these constant expressions.

The run method evaluates the constant expression. The get_2bytes, get_byte and get_bit_index evaluate the constant expression but also convert to a specific low level type needed by instructions.

Variants

Ident(String)Const(i64)Binary(Box<BinaryExpr>)Unary(Box<UnaryExpr>)

Methods

impl Expr[src]

pub fn binary(left: Expr, operator: BinaryOperator, right: Expr) -> Expr[src]

pub fn unary(expr: Expr, operator: UnaryOperator) -> Expr[src]

pub fn get_2bytes(
    &self,
    constants: &HashMap<String, i64>
) -> Result<[u8; 2], ExprRunError>
[src]

pub fn get_byte(
    &self,
    constants: &HashMap<String, i64>
) -> Result<u8, ExprRunError>
[src]

pub fn get_bit_index(
    &self,
    constants: &HashMap<String, i64>
) -> Result<u8, ExprRunError>
[src]

pub fn run(&self, constants: &HashMap<String, i64>) -> Result<i64, ExprRunError>[src]

Trait Implementations

impl PartialEq<Expr> for Expr[src]

impl Clone for Expr[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Expr[src]

Auto Trait Implementations

impl Sync for Expr

impl Send for Expr

impl Unpin for Expr

impl RefUnwindSafe for Expr

impl UnwindSafe for Expr

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.