1
0

LENに配列を対応させた,pure, nothrowを組み込み関数につけた

This commit is contained in:
otya128
2015-08-30 13:03:23 +09:00
parent 87e86b6219
commit 4c45325f3e
2 changed files with 27 additions and 26 deletions

View File

@@ -123,43 +123,43 @@ class BuiltinFunction
}*/ }*/
//static double function(double) ABS = &abs!double; //static double function(double) ABS = &abs!double;
//static double function(double) SGN = &sgn!double; //static double function(double) SGN = &sgn!double;
static double ABS(double arg1) static pure nothrow double ABS(double arg1)
{ {
return abs(arg1); return abs(arg1);
} }
static double SGN(double arg1) static pure nothrow double SGN(double arg1)
{ {
return sgn(arg1); return sgn(arg1);
} }
static double SIN(double arg1) static pure nothrow double SIN(double arg1)
{ {
return sin(arg1); return sin(arg1);
} }
static double ASIN(double arg1) static pure nothrow double ASIN(double arg1)
{ {
return asin(arg1); return asin(arg1);
} }
static double SINH(double arg1) static pure nothrow double SINH(double arg1)
{ {
return sinh(arg1); return sinh(arg1);
} }
static double COS(double arg1) static pure nothrow double COS(double arg1)
{ {
return cos(arg1); return cos(arg1);
} }
static double ACOS(double arg1) static pure nothrow double ACOS(double arg1)
{ {
return acos(arg1); return acos(arg1);
} }
static double COSH(double arg1) static pure nothrow double COSH(double arg1)
{ {
return cosh(arg1); return cosh(arg1);
} }
static double TAN(double arg1) static pure nothrow double TAN(double arg1)
{ {
return tan(arg1); return tan(arg1);
} }
static double ATAN(double arg1, DefaultValue!(double, false) arg2) static pure nothrow double ATAN(double arg1, DefaultValue!(double, false) arg2)
{ {
if(arg2.isDefault) if(arg2.isDefault)
{ {
@@ -167,19 +167,19 @@ class BuiltinFunction
} }
return atan2(arg1, cast(double)arg2); return atan2(arg1, cast(double)arg2);
} }
static double TANH(double arg1) static pure nothrow double TANH(double arg1)
{ {
return tanh(arg1); return tanh(arg1);
} }
static double RAD(double arg1) static pure nothrow double RAD(double arg1)
{ {
return arg1 * std.math.PI / 180; return arg1 * std.math.PI / 180;
} }
static double DEG(double arg1) static pure nothrow double DEG(double arg1)
{ {
return arg1 * 180 / std.math.PI; return arg1 * 180 / std.math.PI;
} }
static double PI() static pure nothrow double PI()
{ {
return std.math.PI; return std.math.PI;
} }
@@ -331,7 +331,7 @@ class BuiltinFunction
x = 0; x = 0;
y = 0; y = 0;
} }
static int RGB(int R, int G, int B, DefaultValue!(int, false) _) static pure nothrow int RGB(int R, int G, int B, DefaultValue!(int, false) _)
{ {
if(!_.isDefault) if(!_.isDefault)
{ {
@@ -362,10 +362,9 @@ class BuiltinFunction
formattedRead(v, "%d/%d/%d", &Y, &M, &D); formattedRead(v, "%d/%d/%d", &Y, &M, &D);
} }
} }
//hairetuha? static int LEN(Value ary)
static int LEN(wstring str)
{ {
return cast(int)str.length; return ary.length;
} }
static bool tryParse(Target, Source)(ref Source p, out Target result) static bool tryParse(Target, Source)(ref Source p, out Target result)
@@ -743,15 +742,15 @@ class BuiltinFunction
return 0;//toriaezu return 0;//toriaezu
} }
} }
static double FLOOR(double val) static nothrow double FLOOR(double val)
{ {
return val.floor; return val.floor;
} }
static double ROUND(double val) static nothrow double ROUND(double val)
{ {
return val.round; return val.round;
} }
static double CEIL(double val) static nothrow double CEIL(double val)
{ {
return val.ceil; return val.ceil;
} }
@@ -819,6 +818,8 @@ class BuiltinFunction
} }
static int ASC(wstring str) static int ASC(wstring str)
{ {
if(str.empty)
throw new IllegalFunctionCall("ASC");
return cast(int)str[0]; return cast(int)str[0];
} }
static wstring STR(int val) static wstring STR(int val)
@@ -1193,11 +1194,11 @@ class BuiltinFunction
{ {
return (cast(wchar)code).to!wstring; return (cast(wchar)code).to!wstring;
} }
static double POW(double a1, double a2) static pure nothrow double POW(double a1, double a2)
{ {
return a1 ^^ a2; return a1 ^^ a2;
} }
static double SQR(double a1) static pure nothrow double SQR(double a1)
{ {
return sqrt(a1); return sqrt(a1);
} }

View File

@@ -1336,7 +1336,7 @@ class PetitComputer
throw new Exception("unsuport enviroment"); throw new Exception("unsuport enviroment");
} }
//プチコンと違って[A,]R,G,Bじゃない //プチコンと違って[A,]R,G,Bじゃない
static void RGBRead(uint color, out ubyte r, out ubyte g, out ubyte b, out ubyte a) static pure nothrow void RGBRead(uint color, out ubyte r, out ubyte g, out ubyte b, out ubyte a)
{ {
//エンディアン関係ない //エンディアン関係ない
a = color >> 24; a = color >> 24;
@@ -1344,11 +1344,11 @@ class PetitComputer
g = color >> 8 & 0xFF; g = color >> 8 & 0xFF;
b = color& 0xFF; b = color& 0xFF;
} }
static uint RGB(ubyte r, ubyte g, ubyte b) static pure nothrow uint RGB(ubyte r, ubyte g, ubyte b)
{ {
return 0xFF000000 | r << 16 | g << 8 | b; return 0xFF000000 | r << 16 | g << 8 | b;
} }
static uint RGB(ubyte a, ubyte r, ubyte g, ubyte b) static pure nothrow uint RGB(ubyte a, ubyte r, ubyte g, ubyte b)
{ {
return a << 24 | r << 16 | g << 8 | b; return a << 24 | r << 16 | g << 8 | b;
} }