#ifndef __NASAL_BUILTIN_H__ #define __NASAL_BUILTIN_H__ #define in_builtin_find(value_name_string) (local_scope_addr>=0?nasal_vm.gc_get(local_scope_addr).get_closure().get_value_address(value_name_string):-1) #define in_builtin_check(value_addr,value_type) (nasal_vm.gc_get(value_addr).get_type()==(value_type)) int nasal_runtime::builtin_print(int local_scope_addr) { // get arguments int vector_value_addr=in_builtin_find("elements"); if(vector_value_addr<0 || nasal_vm.gc_get(vector_value_addr).get_type()!=vm_vector) { std::cout<<">> [runtime] builtin_print: cannot find values or wrong value type."<> [runtime] builtin_append: cannot find values or wrong value type."<> [runtime] builtin_append: cannot find values or wrong value type."<> [runtime] builtin_setsize: cannot find values or wrong value type."<> [runtime] builtin_setsize: cannot find values or wrong value type."<> [runtime] builtin_setsize: size is not a number."<> [runtime] builtin_setsize: size is not a numerable string."<> [runtime] builtin_setsize: size must be greater than -1."<=0) nasal_vm.del_reference(addr); } else if(number>vec_size) for(int i=vec_size;i> [runtime] builtin_system: cannot find values or wrong value type(must be string)."<>str; nasal_vm.gc_get(ret_addr).set_string(str); return ret_addr; } int nasal_runtime::builtin_sleep(int local_scope_addr) { int value_addr=in_builtin_find("duration"); if(value_addr<0 || (nasal_vm.gc_get(value_addr).get_type()!=vm_string && nasal_vm.gc_get(value_addr).get_type()!=vm_number)) { std::cout<<">> [runtime] builtin_sleep: cannot find values or wrong value type(must be string or numebr)."<> [runtime] builtin_sleep: this is not a numerable string."<> [runtime] builtin_finput: cannot find values or wrong value type(must be string)."<> [runtime] builtin_foutput: cannot find values or wrong value type(filename must be string)."<> [runtime] builtin_foutput: cannot find values or wrong value type(file's content must be string)."<> [runtime] builtin_split: cannot find values or wrong value type(must be string)."<> [runtime] builtin_split: cannot find values or wrong value type(must be string)."<> [runtime] builtin_split: delimeter's length must be greater than 0."<=source_len || source[i+j]!=delimeter[j]) break; if(j==delimeter_len-1) check_delimeter=true; } if(check_delimeter) { int str_addr=nasal_vm.gc_alloc(); nasal_vm.gc_get(str_addr).set_type(vm_string); nasal_vm.gc_get(str_addr).set_string(tmp); ref_vec.add_elem(str_addr); tmp=""; i+=delimeter_len-1; } else tmp+=source[i]; } if(tmp.length()) { int str_addr=nasal_vm.gc_alloc(); nasal_vm.gc_get(str_addr).set_type(vm_string); nasal_vm.gc_get(str_addr).set_string(tmp); ref_vec.add_elem(str_addr); tmp=""; } return ret_addr; } int nasal_runtime::builtin_rand(int local_scope_addr) { int value_addr=in_builtin_find("seed"); if(value_addr<0 || (nasal_vm.gc_get(value_addr).get_type()!=vm_number && nasal_vm.gc_get(value_addr).get_type()!=vm_nil)) { std::cout<<">> [runtime] builtin_rand: cannot find values or wrong value type(must be nil or number)."<> [runtime] builtin_id: cannot find this value."<> [runtime] builtin_int: cannot find this value or wrong value type(must be number)."<> [runtime] builtin_num: cannot find this value or wrong value type(must be string)."<> [runtime] builtin_num: this is not a numerable string."<> [runtime] builtin_pop: cannot find this value or wrong value type(must be vector)."<> [runtime] builtin_str: cannot find values or wrong value type(must be number)."<> [runtime] builtin_size: cannot find values."<> [runtime] builtin_xor: cannot find values or wrong value type(must be number)."<> [runtime] builtin_xor: cannot find values or wrong value type(must be number)."<> [runtime] builtin_and: cannot find values or wrong value type(must be number)."<> [runtime] builtin_and: cannot find values or wrong value type(must be number)."<> [runtime] builtin_or: cannot find values or wrong value type(must be number)."<> [runtime] builtin_or: cannot find values or wrong value type(must be number)."<> [runtime] builtin_nand: cannot find values or wrong value type(must be number)."<> [runtime] builtin_nand: cannot find values or wrong value type(must be number)."<> [runtime] builtin_not: cannot find values or wrong value type(must be number)."<> [runtime] builtin_sin: cannot find values or wrong value type(must be number)."<> [runtime] builtin_cos: cannot find values or wrong value type(must be number)."<> [runtime] builtin_tan: cannot find values or wrong value type(must be number)."<> [runtime] builtin_exp: cannot find values or wrong value type(must be number)."<> [runtime] builtin_ln: cannot find values or wrong value type(must be number)."<> [runtime] builtin_sqrt: cannot find values or wrong value type(must be number)."<> [runtime] builtin_atan2: cannot find values or wrong value type(must be number)."<> [runtime] builtin_atan2: cannot find values or wrong value type(must be number)."<> [runtime] builtin_time: cannot find values or wrong value type(must be number)."<> [runtime] builtin_contains: cannot find value named \'hash\' or wrong type(must be hash)."<> [runtime] builtin_contains: cannot find value named \'key\' or wrong type(must be string)."<> [runtime] builtin_delete: cannot find value named \'hash\' or wrong type(must be hash)."<> [runtime] builtin_delete: cannot find value named \'key\' or wrong type(must be string)."<> [runtime] builtin_delete: cannot find value named \'hash\' or wrong type(must be hash)."<