Struct SemanticStack

Source
pub struct SemanticStack<I: SemanticContextInstruction>(/* private fields */);
Expand description

§Semantic stack

Semantic stack represent stack of Semantic Context results

Implementations§

Source§

impl<I: SemanticContextInstruction> SemanticStack<I>

Source

pub const fn new() -> Self

Init Semantic stack

Source

pub fn push(&mut self, value: SemanticStackContext<I>)

Push Context data to the stack

Source

pub fn get(self) -> Vec<SemanticStackContext<I>>

Get all context stack data as array data

Trait Implementations§

Source§

impl<I: Clone + SemanticContextInstruction> Clone for SemanticStack<I>

Source§

fn clone(&self) -> SemanticStack<I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + SemanticContextInstruction> Debug for SemanticStack<I>

Source§

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

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

impl<I: SemanticContextInstruction> Default for SemanticStack<I>

Source§

fn default() -> Self

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

impl<I: SemanticContextInstruction> ExtendedSemanticContext<I> for SemanticStack<I>

Source§

fn extended_expression(&mut self, expr: &I)

Extended Expression instruction. AS argument trait, that contains instruction method that returns instruction parameters.

Source§

impl<I: SemanticContextInstruction> GlobalSemanticContext for SemanticStack<I>

Source§

fn function_declaration(&mut self, fn_decl: FunctionStatement)

Push Context to the stack as function declaration data. Function declaration instruction.

§Parameters
  • fn_decl - function declaration parameters
Source§

fn constant(&mut self, const_decl: Constant)

Push Context to the stack as constant data. Constant declaration instruction.

§Parameters
  • const_decl - constant declaration parameters
Source§

fn types(&mut self, type_decl: StructTypes)

Push Context to the stack as types data. Types declaration instruction.

§Parameters
  • type_decl - type declaration parameters
Source§

impl<I: PartialEq + SemanticContextInstruction> PartialEq for SemanticStack<I>

Source§

fn eq(&self, other: &SemanticStack<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: SemanticContextInstruction> SemanticContext for SemanticStack<I>

Source§

fn expression_value(&mut self, expression: Value, register_number: u64)

Push Context to the stack as expression value data.

§Parameters
  • expression - contains expression value
  • register_number - register to store result data
Source§

fn expression_const(&mut self, expression: Constant, register_number: u64)

Push Context to the stack as expression const data.

§Parameters
  • expression - contains expression constant
  • register_number - register to store result data
Source§

fn expression_struct_value( &mut self, expression: Value, index: u32, register_number: u64, )

Push Context to the stack as expression struct value data.

§Parameters
  • expression - contains expression value for specific Structure attribute
  • index - represent attribute index in the Structure type
  • register_number - register to store result data
Source§

fn expression_operation( &mut self, operation: ExpressionOperations, left_value: ExpressionResult, right_value: ExpressionResult, register_number: u64, )

Push Context to the stack as expression operation data. expression_operation imply operation between left_value and right_value and store result to register_number.

§Parameters
  • operation - specific operation
  • left_value - left expression result
  • right_value - right expression result
  • register_number - register to store result of expression operation
Source§

fn call( &mut self, call: Function, params: Vec<ExpressionResult>, register_number: u64, )

Push Context to the stack as function call data. Function call instruction with parameters and result data.

§Parameters
  • call - function declaration data
  • params - function parameters
  • register_number - register to store result of function call
Source§

fn let_binding(&mut self, let_decl: Value, expr_result: ExpressionResult)

Push Context to the stack as let-binding data. Let binding instruction that “bind” expression result to the new value.

§Parameters
  • let_decl - value declaration
  • expr_result - expression result that will be bind to the value
Source§

fn binding(&mut self, val: Value, expr_result: ExpressionResult)

Push Context to the stack as binding data. Binding instruction that “bind” expression result to the old. previously init value.

§Parameters
  • val - value declaration
  • expr_result - expression result that will be bind to the value
Source§

fn expression_function_return(&mut self, expr_result: ExpressionResult)

Push Context to the stack as expression function return data. Return instruction, should be used in the end of functions. Alwats should be only once.

§Parameters
  • expr_result - result data for the return
Source§

fn expression_function_return_with_label( &mut self, expr_result: ExpressionResult, )

Push Context to the stack as expression function return with label data. Return instruction with additional logic. Most useful case when return previously was call from if-body or loop-body.. As additional behavior this expression_function_return_with_label should set return label. It will allow jump-to-return case. Also before return label Codegen, for normal instruction flow, must jump to return label anyway.

§Parameters
  • expr_result - result data for the return
Source§

fn set_label(&mut self, label: LabelName)

Push Context to the stack as set label data. Set label. Useful for any kind of jump operations and conditional flow.

§Parameters
  • label - label name
Source§

fn jump_to(&mut self, label: LabelName)

Push Context to the stack as jump to data. Unconditional direct jump to label.

§Parameters
  • label - label for the jump
Source§

fn if_condition_expression( &mut self, expr_result: ExpressionResult, label_if_begin: LabelName, label_if_end: LabelName, )

Push Context to the stack as if condition expression data. if-condition expression represent if-condition, when if expression is “true” jump to label_if_begin else label_if_end.

§Parameters
  • expr_result - expression result of if-condition for conditional instruction
  • label_if_begin - label for jump if expression is “true”
  • label_if_end - label for jump if expression is “false”
Source§

fn condition_expression( &mut self, left_result: ExpressionResult, right_result: ExpressionResult, condition: Condition, register_number: u64, )

Push Context to the stack as condition expression data. Condition expression between left and right condition calculation.

§Parameters
  • left_result - left expression result
  • right_result - right expression result
  • condition - condition operation
  • register_number - register to store result of expression operation
Source§

fn jump_function_return(&mut self, expr_result: ExpressionResult)

Push Context to the stack as jump function return data. Jump to function return with expression result data. Label for jumping to return position (always end of function) should be always the same and should be managed by Codegen.

§Parameters
  • expr_result - expression result for return condition
Source§

fn logic_condition( &mut self, logic_condition: LogicCondition, left_register_result: u64, right_register_result: u64, register_number: u64, )

Push Context to the stack as logic condition data. Operate with registers: left and right for specific logic condition. Result of calculation stored to register_number.

§Parameters
  • left_register_result - result of left condition
  • right_register_result - result of right condition
  • register_number - register to store instruction result
Source§

fn if_condition_logic( &mut self, label_if_begin: LabelName, label_if_end: LabelName, result_register: u64, )

Push Context to the stack as if condition logic data. if_condition_logic instruction read data from result_register and conditionally jump: if “true’ to label_if_begin or label_if_end if “false” (data contained as result after reading result_register).

§Parameters
  • label_if_begin - label for a jump if result_register contains result with “true”
  • label_if_end - label for a jump if result_register contains result with “false”. It can be not only if_end but any kind (for example if_else)
  • result_register - contains register of previous condition logic calculations.
Source§

fn function_arg(&mut self, value: Value, func_arg: FunctionParameter)

Push Context to the stack as function argument data. This instruction should allocate pointer (if argument type is not Ptr) and store argument value to the pointer.

§Parameters
  • func_arg - function parameter data
Source§

impl<I: SemanticContextInstruction> StructuralPartialEq for SemanticStack<I>

Auto Trait Implementations§

§

impl<I> Freeze for SemanticStack<I>

§

impl<I> RefUnwindSafe for SemanticStack<I>
where I: RefUnwindSafe,

§

impl<I> Send for SemanticStack<I>
where I: Send,

§

impl<I> Sync for SemanticStack<I>
where I: Sync,

§

impl<I> Unpin for SemanticStack<I>

§

impl<I> UnwindSafe for SemanticStack<I>
where I: UnwindSafe,

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 = 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.