diff --git a/version2.0/lib/base.nas b/version2.0/lib/base.nas index ec7bb08..cd39444 100644 --- a/version2.0/lib/base.nas +++ b/version2.0/lib/base.nas @@ -21,7 +21,7 @@ var append=func(vector,elements...) # If it is smaller, it is padded with nil entries.Returns the vector operated upon. var setsize=func(vector,__size) { - nasal_call_inline_push_null(vector,__size); + nasal_call_inline_set_size(vector,__size); return nil; } diff --git a/version2.0/nasal_runtime.h b/version2.0/nasal_runtime.h index 81662ab..25b4841 100644 --- a/version2.0/nasal_runtime.h +++ b/version2.0/nasal_runtime.h @@ -5,7 +5,7 @@ std::string inline_func_name[nas_lib_func_num]= { //base.nas "nasal_call_inline_push_back", - "nasal_call_inline_push_null", + "nasal_call_inline_set_size", "nasal_call_inline_subvec", "nasal_call_inline_contains", "nasal_call_inline_delete", @@ -4700,6 +4700,67 @@ int nasal_runtime::inline_function(std::list >& local_ ret_addr=nasal_gc.gc_alloc(); nasal_gc.get_scalar(ret_addr).set_type(scalar_nil); } + else if(func_name=="nasal_call_inline_set_size") + { + int vector_addr=-1; + int size_addr=-1; + for(std::list >::iterator i=local_scope.begin();i!=local_scope.end();++i) + { + if(i->find("vector")!=i->end()) + vector_addr=(*i)["vector"]; + if(i->find("__size")!=i->end()) + size_addr=(*i)["__size"]; + } + if(vector_addr<0 || size_addr<0) + return -1; + int vector_size=-1; + int aim_size=-1; + if(nasal_gc.get_scalar(vector_addr).get_type()!=scalar_vector) + { + std::cout<<">> [Runtime] setsize gets a variable that is not a vector."<> [Runtime] __size is not a numerable string."<> [Runtime] __size must be a number or numerable string."<> [Runtime] __size must be greater than 0."<aim_size) + for(int i=aim_size;i