From 17ec1602f55b1e00e9b10057f5359491c07aac2c Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Mon, 7 Sep 2020 22:20:45 -0700 Subject: [PATCH] update --- version3.0/nasal_runtime.h | 116 +++++++++++++++++++++++++++++++++---- 1 file changed, 104 insertions(+), 12 deletions(-) diff --git a/version3.0/nasal_runtime.h b/version3.0/nasal_runtime.h index b42e745..91ebdb8 100644 --- a/version3.0/nasal_runtime.h +++ b/version3.0/nasal_runtime.h @@ -42,6 +42,8 @@ private: // function/loop/conditional expression block running process int block_progress(nasal_ast&,int,bool); // run loop + int before_for_loop(nasal_ast&,int); + int after_each_for_loop(nasal_ast&,int); int loop_progress(nasal_ast&,int,bool); // run conditional bool check_condition(int); @@ -320,6 +322,58 @@ int nasal_runtime::block_progress(nasal_ast& node,int local_scope_addr,bool allo nasal_vm.del_reference(local_scope_addr); return ret_state; } +int nasal_runtime::before_for_loop(nasal_ast& node,int local_scope_addr) +{ + int before_loop_node_type=node.get_type(); + switch(before_loop_node_type) + { + case ast_definition: + definition(node,local_scope_addr); + break; + case ast_multi_assign: + multi_assignment(node,local_scope_addr); + break; + case ast_number:case ast_string:case ast_identifier:break; + case ast_call: + case ast_add_equal:case ast_sub_equal:case ast_mult_equal:case ast_div_equal:case ast_link_equal: + case ast_unary_sub:case ast_unary_not: + case ast_add:case ast_sub:case ast_mult:case ast_div:case ast_link: + case ast_trinocular: + nasal_vm.del_reference(calculation(node,local_scope_addr)); + break; + default: + std::cout<<">> [runtime] before_for_loop: cannot use this expression before for-loop."<> [runtime] after_each_for_loop: cannot use this expression after each for-loop."<> [runtime] calculation: this expression cannot be calculated."<> [runtime] calculation: incorrect values are used in calculation."<