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>
impl<I: SemanticContextInstruction> SemanticStack<I>
Sourcepub fn push(&mut self, value: SemanticStackContext<I>)
pub fn push(&mut self, value: SemanticStackContext<I>)
Push Context data to the stack
Sourcepub fn get(self) -> Vec<SemanticStackContext<I>>
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>
impl<I: Clone + SemanticContextInstruction> Clone for SemanticStack<I>
Source§fn clone(&self) -> SemanticStack<I>
fn clone(&self) -> SemanticStack<I>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<I: Debug + SemanticContextInstruction> Debug for SemanticStack<I>
impl<I: Debug + SemanticContextInstruction> Debug for SemanticStack<I>
Source§impl<I: SemanticContextInstruction> Default for SemanticStack<I>
impl<I: SemanticContextInstruction> Default for SemanticStack<I>
Source§impl<I: SemanticContextInstruction> ExtendedSemanticContext<I> for SemanticStack<I>
impl<I: SemanticContextInstruction> ExtendedSemanticContext<I> for SemanticStack<I>
Source§fn extended_expression(&mut self, expr: &I)
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>
impl<I: SemanticContextInstruction> GlobalSemanticContext for SemanticStack<I>
Source§fn function_declaration(&mut self, fn_decl: FunctionStatement)
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)
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)
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>
impl<I: PartialEq + SemanticContextInstruction> PartialEq for SemanticStack<I>
Source§impl<I: SemanticContextInstruction> SemanticContext for SemanticStack<I>
impl<I: SemanticContextInstruction> SemanticContext for SemanticStack<I>
Source§fn expression_value(&mut self, expression: Value, register_number: u64)
fn expression_value(&mut self, expression: Value, register_number: u64)
Push Context to the stack as expression value data.
§Parameters
expression
- contains expression valueregister_number
- register to store result data
Source§fn expression_const(&mut self, expression: Constant, register_number: u64)
fn expression_const(&mut self, expression: Constant, register_number: u64)
Push Context to the stack as expression const data.
§Parameters
expression
- contains expression constantregister_number
- register to store result data
Source§fn expression_struct_value(
&mut self,
expression: Value,
index: u32,
register_number: u64,
)
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 specificStructure
attributeindex
- represent attribute index in theStructure
typeregister_number
- register to store result data
Source§fn expression_operation(
&mut self,
operation: ExpressionOperations,
left_value: ExpressionResult,
right_value: ExpressionResult,
register_number: u64,
)
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 operationleft_value
- left expression resultright_value
- right expression resultregister_number
- register to store result of expression operation
Source§fn call(
&mut self,
call: Function,
params: Vec<ExpressionResult>,
register_number: u64,
)
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 dataparams
- function parametersregister_number
- register to store result of function call
Source§fn let_binding(&mut self, let_decl: Value, expr_result: ExpressionResult)
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 declarationexpr_result
- expression result that will be bind to the value
Source§fn binding(&mut self, val: Value, expr_result: ExpressionResult)
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 declarationexpr_result
- expression result that will be bind to the value
Source§fn expression_function_return(&mut self, expr_result: ExpressionResult)
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,
)
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)
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)
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,
)
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 ofif-condition
for conditional instructionlabel_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,
)
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 resultright_result
- right expression resultcondition
- condition operationregister_number
- register to store result of expression operation
Source§fn jump_function_return(&mut self, expr_result: ExpressionResult)
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,
)
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 conditionright_register_result
- result of right conditionregister_number
- register to store instruction result
Source§fn if_condition_logic(
&mut self,
label_if_begin: LabelName,
label_if_end: LabelName,
result_register: u64,
)
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 ifresult_register
contains result with “true”label_if_end
- label for a jump ifresult_register
contains result with “false”. It can be not onlyif_end
but any kind (for exampleif_else
)result_register
- contains register of previous condition logic calculations.
Source§fn function_arg(&mut self, value: Value, func_arg: FunctionParameter)
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