From 22aef3d6e31e38957cf84fd20eca191522bf5283 Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Sat, 26 Sep 2020 03:08:07 -0700 Subject: [PATCH] update --- version3.0/lib.nas | 34 +++++++++++ version3.0/nasal_builtin.h | 113 +++++++++++++++++++++++++++++++++++++ version3.0/nasal_runtime.h | 25 +++++++- 3 files changed, 170 insertions(+), 2 deletions(-) diff --git a/version3.0/lib.nas b/version3.0/lib.nas index 612e1b9..0245a77 100644 --- a/version3.0/lib.nas +++ b/version3.0/lib.nas @@ -95,4 +95,38 @@ var bits= { return nasal_call_builtin_not(a); } +}; + +var math= +{ + e:2.7182818284590452354, + pi:3.14159265358979323846, + sin:func(x) + { + return nasal_call_builtin_sin(x); + }, + cos:func(x) + { + return nasal_call_builtin_cos(x); + }, + tan:func(x) + { + return nasal_call_builtin_tan(x); + }, + exp:func(x) + { + return nasal_call_builtin_exp(x); + }, + ln:func(x) + { + return nasal_call_builtin_cpp_math_ln(x); + }, + sqrt:func(x) + { + return nasal_call_builtin_cpp_math_sqrt(x); + }, + atan2:func(x,y) + { + return nasal_call_builtin_cpp_atan2(x,y); + }, }; \ No newline at end of file diff --git a/version3.0/nasal_builtin.h b/version3.0/nasal_builtin.h index 0b0b3c6..2a8e1f7 100644 --- a/version3.0/nasal_builtin.h +++ b/version3.0/nasal_builtin.h @@ -553,4 +553,117 @@ int nasal_runtime::builtin_not(int local_scope_addr) nasal_vm.gc_get(ret_addr).set_number((double)(~number)); return ret_addr; } +int nasal_runtime::builtin_sin(int local_scope_addr) +{ + int value_addr=in_builtin_find("x"); + if(value_addr<0 || nasal_vm.gc_get(value_addr).get_type()!=vm_number) + { + std::cout<<">> [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)."<