diff --git a/version2.0/nasal_runtime.h b/version2.0/nasal_runtime.h index c11c9f6..481db2b 100644 --- a/version2.0/nasal_runtime.h +++ b/version2.0/nasal_runtime.h @@ -17,6 +17,7 @@ class nasal_runtime __incorrect_head_of_tree, __incorrect_head_of_func, __undefined_identifier, + __multi_assign_incorrect_value_number, __not_callable_vector, __not_callable_hash, __not_numerable_str, @@ -64,6 +65,8 @@ void nasal_runtime::error_interrupt(const int type,const int line) std::cout<<"called identifier is not a function."< >& local_scop } if(assigned_addrs.empty()) return -1; + if(child_node_type_2==__multi_scalar) + { + std::vector data_addrs; + for(std::list::iterator i=node.get_children().back().get_children().begin();i!=node.get_children().back().get_children().end();++i) + data_addrs.push_back(calculation(local_scope,*i)); + if(data_addrs.size()!=assigned_addrs.size()) + { + error_interrupt(__multi_assign_incorrect_value_number,node.get_children().back().get_node_line()); + return -1; + } + for(int i=0;i >& local_scop // ?: // this will return the first element if the condition is true // this will return the second element if the condition is null(0,nil,"0",'0',"",'',"0x0","0o0") - ; + int condition_addr=calculation(local_scope,node.get_children().front()); + int condition_type=nasal_gc.get_scalar(condition_addr).get_type(); + std::list::iterator ptr=node.get_children().begin(); + ++ptr; + if(condition_type==scalar_number && nasal_gc.get_scalar(condition_addr).get_number().get_number()==0) + { + ++ptr; + nasal_gc.reference_delete(condition_addr); + return calculation(local_scope,*ptr); + } + else if(condition_type==scalar_string + && check_numerable_string(nasal_gc.get_scalar(condition_addr).get_string().get_string()) + && trans_string_to_number(nasal_gc.get_scalar(condition_addr).get_string().get_string())==0) + { + ++ptr; + nasal_gc.reference_delete(condition_addr); + return calculation(local_scope,*ptr); + } + else + { + nasal_gc.reference_delete(condition_addr); + return calculation(local_scope,*ptr); + } + return -1; } return -1; } @@ -981,7 +1080,6 @@ int nasal_runtime::func_proc(std::list >& local_scope, int node_type=iter->get_node_type(); if(node_type==__number || node_type==__string) ; - // only number or string else if(node_type==__id) this->call_identifier(local_scope,*iter); else if(node_type==__vector)