update
This commit is contained in:
parent
22aef3d6e3
commit
e8ca77f796
|
@ -129,4 +129,9 @@ var math=
|
|||
{
|
||||
return nasal_call_builtin_cpp_atan2(x,y);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
var time=func(begin_time)
|
||||
{
|
||||
return nasal_call_builtin_time(begin_time);
|
||||
}
|
|
@ -666,4 +666,19 @@ int nasal_runtime::builtin_atan2(int local_scope_addr)
|
|||
nasal_vm.gc_get(ret_addr).set_number(atan2(y,x));
|
||||
return ret_addr;
|
||||
}
|
||||
int nasal_runtime::builtin_time(int local_scope_addr)
|
||||
{
|
||||
int value_addr=in_builtin_find("begin_time");
|
||||
if(value_addr<0 || nasal_vm.gc_get(value_addr).get_type()!=vm_number)
|
||||
{
|
||||
std::cout<<">> [runtime] builtin_time: cannot find values or wrong value type(must be number)."<<std::endl;
|
||||
++error;
|
||||
return -1;
|
||||
}
|
||||
time_t begin_time=(time_t)nasal_vm.gc_get(value_addr).get_number();
|
||||
int ret_addr=nasal_vm.gc_alloc();
|
||||
nasal_vm.gc_get(ret_addr).set_type(vm_number);
|
||||
nasal_vm.gc_get(ret_addr).set_number((double)time(&begin_time));
|
||||
return ret_addr;
|
||||
}
|
||||
#endif
|
|
@ -10,7 +10,7 @@ enum runtime_returned_state
|
|||
rt_exit_without_error
|
||||
};
|
||||
|
||||
#define BUILTIN_FUNC_NUM 28
|
||||
#define BUILTIN_FUNC_NUM 29
|
||||
std::string builtin_func_name[BUILTIN_FUNC_NUM]=
|
||||
{
|
||||
"nasal_call_builtin_std_cout",
|
||||
|
@ -40,7 +40,8 @@ std::string builtin_func_name[BUILTIN_FUNC_NUM]=
|
|||
"nasal_call_builtin_exp",
|
||||
"nasal_call_builtin_cpp_math_ln",
|
||||
"nasal_call_builtin_cpp_math_sqrt",
|
||||
"nasal_call_builtin_cpp_atan2"
|
||||
"nasal_call_builtin_cpp_atan2",
|
||||
"nasal_call_builtin_time"
|
||||
};
|
||||
|
||||
class nasal_runtime
|
||||
|
@ -127,6 +128,7 @@ private:
|
|||
int builtin_ln(int);
|
||||
int builtin_sqrt(int);
|
||||
int builtin_atan2(int);
|
||||
int builtin_time(int);
|
||||
public:
|
||||
nasal_runtime();
|
||||
~nasal_runtime();
|
||||
|
@ -1146,6 +1148,7 @@ int nasal_runtime::call_builtin_function(nasal_ast& node,int local_scope_addr)
|
|||
case 25:ret_value_addr=builtin_ln(local_scope_addr);break;
|
||||
case 26:ret_value_addr=builtin_sqrt(local_scope_addr);break;
|
||||
case 27:ret_value_addr=builtin_atan2(local_scope_addr);break;
|
||||
case 28:ret_value_addr=builtin_time(local_scope_addr);break;
|
||||
}
|
||||
return ret_value_addr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue