Struct rustdb::expr::Block

source ·
pub struct Block<'a> {
    pub param_count: usize,
    pub return_type: DataType,
    pub local_typ: Vec<DataType>,
    pub ilist: Vec<Instruction>,
    pub break_id: usize,
    pub db: DB,
    pub from: Option<CTableExpression>,
    pub parse_only: bool,
    /* private fields */
}
Expand description

Compilation block ( body of function or batch section ).

Fields§

§param_count: usize

Number of function parameters.

§return_type: DataType

Function return type.

§local_typ: Vec<DataType>

Datatypes of paramaters and local variables.

§ilist: Vec<Instruction>

List of instructions.

§break_id: usize

Id of break.

§db: DB

Database.

§from: Option<CTableExpression>

Current table in scope by FROM clause( or UPDATE statment ).

§parse_only: bool

Only parse, no type checking or compilation.

Implementations§

source§

impl<'a> Block<'a>

source

pub fn new(db: DB) -> Self

Construct a new block.

source

pub fn resolve_jumps(&mut self)

Check labels are all defined and patch jump instructions.

source

pub fn add(&mut self, s: Instruction)

Add an instruction to the instruction list.

source

pub fn dop(&mut self, dop: DO)

Add a Data Operation (DO) to the instruction list.

source

pub fn check_types(&self, r: &Rc<Function>, pkinds: &[DataKind])

Check the parameter kinds match the function.

source

pub fn def_local(&mut self, name: &'a [u8], dt: DataType)

Define a local variable ( parameter or declared ).

source

pub fn get_local(&self, name: &[u8]) -> Option<&usize>

Get the number of a local variable from a name.

source

pub fn local_name(&self, num: usize) -> &[u8]

Get the name of a local variable from a number.

source

pub fn get_jump_id(&mut self) -> usize

Get a local jump id.

source

pub fn set_jump(&mut self, jump_id: usize)

Set instruction location of jump id.

source

pub fn get_loop_id(&mut self) -> usize

Get a local jump id to current location.

source

pub fn get_goto_label(&mut self, s: &'a [u8]) -> usize

Get a number for a local goto label.

source

pub fn set_goto_label(&mut self, s: &'a [u8])

Set the local for a local goto lable.

source

pub fn kind(&self, e: &mut Expr) -> DataKind

Get the DataKind of an expression.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Block<'a>

§

impl<'a> !Send for Block<'a>

§

impl<'a> !Sync for Block<'a>

§

impl<'a> Unpin for Block<'a>

§

impl<'a> !UnwindSafe for Block<'a>

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> 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>,

§

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>,

§

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.