From 4c45325f3ec1c75084f6e8be87e7762401e62be1 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sun, 30 Aug 2015 13:03:23 +0900 Subject: [PATCH] =?UTF-8?q?LEN=E3=81=AB=E9=85=8D=E5=88=97=E3=82=92?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=95=E3=81=9B=E3=81=9F,pure,=20nothrow?= =?UTF-8?q?=E3=82=92=E7=B5=84=E3=81=BF=E8=BE=BC=E3=81=BF=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AB=E3=81=A4=E3=81=91=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SMILEBASIC/builtinfunctions.d | 47 ++++++++++++++++++----------------- SMILEBASIC/petitcomputer.d | 6 ++--- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index e0bdd97..c28729c 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -123,43 +123,43 @@ class BuiltinFunction }*/ //static double function(double) ABS = &abs!double; //static double function(double) SGN = &sgn!double; - static double ABS(double arg1) + static pure nothrow double ABS(double arg1) { return abs(arg1); } - static double SGN(double arg1) + static pure nothrow double SGN(double arg1) { return sgn(arg1); } - static double SIN(double arg1) + static pure nothrow double SIN(double arg1) { return sin(arg1); } - static double ASIN(double arg1) + static pure nothrow double ASIN(double arg1) { return asin(arg1); } - static double SINH(double arg1) + static pure nothrow double SINH(double arg1) { return sinh(arg1); } - static double COS(double arg1) + static pure nothrow double COS(double arg1) { return cos(arg1); } - static double ACOS(double arg1) + static pure nothrow double ACOS(double arg1) { return acos(arg1); } - static double COSH(double arg1) + static pure nothrow double COSH(double arg1) { return cosh(arg1); } - static double TAN(double arg1) + static pure nothrow double TAN(double 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) { @@ -167,19 +167,19 @@ class BuiltinFunction } return atan2(arg1, cast(double)arg2); } - static double TANH(double arg1) + static pure nothrow double TANH(double arg1) { return tanh(arg1); } - static double RAD(double arg1) + static pure nothrow double RAD(double arg1) { return arg1 * std.math.PI / 180; } - static double DEG(double arg1) + static pure nothrow double DEG(double arg1) { return arg1 * 180 / std.math.PI; } - static double PI() + static pure nothrow double PI() { return std.math.PI; } @@ -331,7 +331,7 @@ class BuiltinFunction x = 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) { @@ -362,10 +362,9 @@ class BuiltinFunction formattedRead(v, "%d/%d/%d", &Y, &M, &D); } } - //hairetuha? - static int LEN(wstring str) + static int LEN(Value ary) { - return cast(int)str.length; + return ary.length; } static bool tryParse(Target, Source)(ref Source p, out Target result) @@ -743,15 +742,15 @@ class BuiltinFunction return 0;//toriaezu } } - static double FLOOR(double val) + static nothrow double FLOOR(double val) { return val.floor; } - static double ROUND(double val) + static nothrow double ROUND(double val) { return val.round; } - static double CEIL(double val) + static nothrow double CEIL(double val) { return val.ceil; } @@ -819,6 +818,8 @@ class BuiltinFunction } static int ASC(wstring str) { + if(str.empty) + throw new IllegalFunctionCall("ASC"); return cast(int)str[0]; } static wstring STR(int val) @@ -1193,11 +1194,11 @@ class BuiltinFunction { 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; } - static double SQR(double a1) + static pure nothrow double SQR(double a1) { return sqrt(a1); } diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 5e0a094..4e3c927 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -1336,7 +1336,7 @@ class PetitComputer throw new Exception("unsuport enviroment"); } //プチコンと違って[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; @@ -1344,11 +1344,11 @@ class PetitComputer g = color >> 8 & 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; } - 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; }