diff --git a/version3.0/nasal_gc.h b/version3.0/nasal_gc.h index 6999744..a0c30b4 100644 --- a/version3.0/nasal_gc.h +++ b/version3.0/nasal_gc.h @@ -22,6 +22,7 @@ public: ~nasal_vector(); void add_elem(int); int del_elem(int); + int size(); int get_value_address(int); int get_mem_address(int); void deepcopy(nasal_vector&); @@ -103,6 +104,8 @@ public: int nasal_scalar_mult(int,int); int nasal_scalar_div(int,int); int nasal_scalar_link(int,int); + int nasal_scalar_and(int,int); + int nasal_scalar_or(int,int); int nasal_scalar_unary_sub(int); int nasal_scalar_unary_not(int); int nasal_scalar_cmp_equal(int,int); @@ -182,6 +185,10 @@ int nasal_vector::del_elem(int index) elems.pop_back(); return ret; } +int nasal_vector::size() +{ + return this->elems.size(); +} int nasal_vector::get_value_address(int index) { int vec_size=elems.size(); @@ -723,6 +730,30 @@ int nasal_scalar::nasal_scalar_link(int a_scalar_addr,int b_scalar_addr) nasal_vm.gc_get(new_value_address).set_string(result); return new_value_address; } +int nasal_scalar::nasal_scalar_and(int a_scalar_addr,int b_scalar_addr) +{ + nasal_scalar& a_ref=nasal_vm.gc_get(a_scalar_addr); + nasal_scalar& b_ref=nasal_vm.gc_get(b_scalar_addr); + if(a_ref.type==vm_hash || a_ref.type==vm_vector || b_ref.type==vm_hash || b_ref.type==vm_vector) + { + std::cout<<">> [vm] scalar_and: hash and vector cannot take part in and calculation."<> [vm] scalar_or: hash and vector cannot take part in or calculation."<> [runtime] main_progress:cannot use break in main progress."<> [runtime] main_progress: cannot use break in main progress."<> [runtime] main_progress:cannot use continue in main progress."<> [runtime] main_progress: cannot use continue in main progress."<> [runtime] main_progress:error occurred when executing main progress."<> [runtime] main_progress: error occurred when executing main progress."<> [runtime] block_progress:error occurred when executing sub-progress."<> [runtime] block_progress: error occurred when executing sub-progress."<> [runtime] call_nasal_scalar:cannot find value named \'"<> [runtime] call_nasal_scalar: cannot find value named \'"<> [runtime] call_vector:incorrect value type,expected a vector/hash."<> [runtime] call_vector: incorrect value type,expected a vector/hash."< called_value_addrs; @@ -379,6 +379,11 @@ int nasal_runtime::call_vector(nasal_ast& node,int base_value_addr,int local_sco nasal_ast& subvec_node=node.get_children()[i]; int begin_value_addr=calculation(subvec_node.get_children()[0],local_scope_addr); int end_value_addr=calculation(subvec_node.get_children()[1],local_scope_addr); + int begin_index,end_index; + if(nasal_vm.gc_get(begin_value_addr).get_type()==vm_nil) + begin_index=0; + if(nasal_vm.gc_get(end_value_addr).get_type()==vm_nil) + end_index=reference_value.size()-1; ;// unfinished nasal_vm.del_reference(begin_value_addr); nasal_vm.del_reference(end_value_addr); @@ -397,7 +402,7 @@ int nasal_runtime::call_hash(nasal_ast& node,int base_value_addr,int local_scope int value_type=nasal_vm.gc_get(base_value_addr).get_type(); if(value_type!=vm_hash) { - std::cout<<">> [runtime] call_hash:incorrect value type,expected a hash."<> [runtime] call_hash: incorrect value type,expected a hash."<> [runtime] call_function:incorrect value type,expected a function."<> [runtime] call_function: incorrect value type,expected a function."<> [runtime] call_nasal_mem:cannot find value named \'"<> [runtime] call_nasal_mem: cannot find value named \'"<> [runtime] call_vector_mem:incorrect value type,expected a vector/hash."<> [runtime] call_vector_mem: incorrect value type,expected a vector/hash."< called_mem_addrs; @@ -482,7 +487,7 @@ int nasal_runtime::call_hash_mem(nasal_ast& node,int base_mem_addr,int local_sco int value_type=nasal_vm.gc_get(base_value_addr).get_type(); if(value_type!=vm_hash) { - std::cout<<">> [runtime] call_hash_mem:incorrect value type,expected a hash."<> [runtime] call_hash_mem: incorrect value type,expected a hash."<> [runtime] call_function_mem:incorrect value type,expected a function."<> [runtime] call_function_mem: incorrect value type,expected a function."<> [runtime] calculation:incorrect values are used in calculation."<> [runtime] calculation: incorrect values are used in calculation."<