Upgrade to nasal 1.0 test candidate
This commit is contained in:
+14
-13
@@ -7,55 +7,55 @@
|
||||
|
||||
#include "nasal.h"
|
||||
|
||||
static naRef f_sin(naContext c, naRef args)
|
||||
static naRef f_sin(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
if(naIsNil(a))
|
||||
naRuntimeError(c, "non numeric argument to sin()");
|
||||
a.num = sin(a.num);
|
||||
return a;
|
||||
}
|
||||
|
||||
static naRef f_cos(naContext c, naRef args)
|
||||
static naRef f_cos(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
if(naIsNil(a))
|
||||
naRuntimeError(c, "non numeric argument to cos()");
|
||||
a.num = cos(a.num);
|
||||
return a;
|
||||
}
|
||||
|
||||
static naRef f_exp(naContext c, naRef args)
|
||||
static naRef f_exp(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
if(naIsNil(a))
|
||||
naRuntimeError(c, "non numeric argument to exp()");
|
||||
a.num = exp(a.num);
|
||||
return a;
|
||||
}
|
||||
|
||||
static naRef f_ln(naContext c, naRef args)
|
||||
static naRef f_ln(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
if(naIsNil(a))
|
||||
naRuntimeError(c, "non numeric argument to ln()");
|
||||
a.num = log(a.num);
|
||||
return a;
|
||||
}
|
||||
|
||||
static naRef f_sqrt(naContext c, naRef args)
|
||||
static naRef f_sqrt(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
if(naIsNil(a))
|
||||
naRuntimeError(c, "non numeric argument to sqrt()");
|
||||
a.num = sqrt(a.num);
|
||||
return a;
|
||||
}
|
||||
|
||||
static naRef f_atan2(naContext c, naRef args)
|
||||
static naRef f_atan2(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
naRef a = naNumValue(naVec_get(args, 0));
|
||||
naRef b = naNumValue(naVec_get(args, 1));
|
||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||
naRef b = naNumValue(argc > 1 ? args[1] : naNil());
|
||||
if(naIsNil(a) || naIsNil(b))
|
||||
naRuntimeError(c, "non numeric argument to atan2()");
|
||||
a.num = atan2(a.num, b.num);
|
||||
@@ -87,6 +87,7 @@ naRef naMathLib(naContext c)
|
||||
naHash_set(namespace, name, naNum(M_PI));
|
||||
|
||||
name = naStr_fromdata(naNewString(c), "e", 1);
|
||||
name = naInternSymbol(name);
|
||||
naHash_set(namespace, name, naNum(M_E));
|
||||
|
||||
return namespace;
|
||||
|
||||
Reference in New Issue
Block a user