Skip to content

Commit

Permalink
Merge pull request #130 from WSOFT-Project/fix
Browse files Browse the repository at this point in the history
Losetta v0.10.5
  • Loading branch information
taiseiue authored Feb 28, 2024
2 parents 9be6afe + c62743c commit 8d73c72
Show file tree
Hide file tree
Showing 65 changed files with 394 additions and 38 deletions.
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Console.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AliceScript.Binding;
using System;
using System.Runtime.Versioning;
using System.Text;

Expand Down
6 changes: 6 additions & 0 deletions Losetta.Runtime/Alice.Diagnostics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AliceScript.Binding;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

Expand Down Expand Up @@ -239,7 +241,11 @@ public void Kill()

public void Kill(bool entireProcessTree)
{
#if NETCOREAPP3_0_OR_GREATER
Process.Kill(entireProcessTree);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}

public void Reflesh()
Expand Down
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Environment.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AliceScript.Binding;
using AliceScript.Functions;
using System;

namespace AliceScript.NameSpaces
{
Expand Down
29 changes: 28 additions & 1 deletion Losetta.Runtime/Alice.IO.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using AliceScript.Binding;
using AliceScript.Extra;
using AliceScript.Parsing;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
Expand Down Expand Up @@ -29,7 +32,11 @@ public static void File_Move(string from, string to)
}
public static void File_Move(string from, string to, bool overwrite)
{
#if NETCOREAPP3_0_OR_GREATER
File.Move(from, to, overwrite);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static void File_Copy(string from, string to)
{
Expand Down Expand Up @@ -349,7 +356,11 @@ public static string Directory_Current(string path)
}
public static void Directory_Create_SymbolicLink(string path, string pathToTarget)
{
#if NET6_0
Directory.CreateSymbolicLink(path, pathToTarget);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static void Directory_Delete(string path)
{
Expand Down Expand Up @@ -461,7 +472,7 @@ public static string Path_ChageExtension(string filename, string extension)
}
public static bool Path_EndsInDirectorySeparator(string path)
{
return Path.EndsInDirectorySeparator(path);
return path.EndsWith(Path.DirectorySeparatorChar) || path.EndsWith(Path.AltDirectorySeparatorChar);
}
public static string Path_Get_DirectoryName(string path)
{
Expand All @@ -485,7 +496,11 @@ public static string Path_Get_FullPath(string path)
}
public static string Path_Get_RelativePath(string to, string path)
{
#if NETCOREAPP2_0_OR_GREATER
return Path.GetRelativePath(to, path);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static string Path_Get_PathRoot(string path)
{
Expand All @@ -509,23 +524,35 @@ public static bool Path_Has_Extension(string path)
}
public static bool Path_IsPathFullyQualified(string path)
{
#if NETCOREAPP2_1_OR_GREATER
return Path.IsPathFullyQualified(path);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static bool Path_IsPathRooted(string path)
{
return Path.IsPathRooted(path);
}
public static string Path_TrimEndingDirectorySeparator(string path)
{
#if NETCOREAPP3_0_OR_GREATER
return Path.TrimEndingDirectorySeparator(path);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static string Path_Combine(params string[] paths)
{
return Path.Combine(paths);
}
public static string Path_Join(params string[] paths)
{
#if NETCOREAPP3_0_OR_GREATER
return Path.Join(paths);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
#endregion
#region ZIPファイル操作
Expand Down
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Interop.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AliceScript.Binding;
using AliceScript.Interop;
using AliceScript.Objects;
using System;
using System.Reflection;

namespace AliceScript.NameSpaces
Expand Down
2 changes: 2 additions & 0 deletions Losetta.Runtime/Alice.Legacy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AliceScript.Functions;
using System;
using System.Collections.Generic;

namespace AliceScript.NameSpaces
{
Expand Down
74 changes: 70 additions & 4 deletions Losetta.Runtime/Alice.Math.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AliceScript.Binding;
using System;

namespace AliceScript.NameSpaces
{
Expand Down Expand Up @@ -62,15 +63,27 @@ public static bool Math_IsNegativeInfinity(double x)
}
public static bool Math_IsFinite(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return double.IsFinite(x);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static bool Math_IsNormal(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return double.IsNormal(x);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static bool Math_IsSubnormal(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return double.IsSubnormal(x);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static double Math_Pow(double x, double y)
{
Expand All @@ -86,27 +99,42 @@ public static double Math_Ceiling(double x)
}
public static double Math_Clamp(double x, double min, double max)
{
return Math.Clamp(x, min, max);
return double.IsNaN(x) ? double.NaN : x < min ? min : max < x ? max : x;
}
public static double Math_CopySign(double x, double y)
{
#if NETCOREAPP3_0_OR_GREATER
return Math.CopySign(x, y);

#else
int sign = Math.Sign(y);
sign = sign == 0 ? 1 : sign;
return Math.Abs(x) * sign;
#endif
}
public static double Math_Exp(double x)
{
return Math.Exp(x);
}
public static double Math_FusedMultiplyAdd(double x, double y, double z)
{
#if NETCOREAPP3_0_OR_GREATER
return Math.FusedMultiplyAdd(x, y, z);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static double Math_Sqrt(double x)
{
return Math.Sqrt(x);
}
public static double Math_Cbrt(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return Math.Cbrt(x);
#else
return Math.Pow(x,1/3);
#endif
}
public static double Math_Max(params double[] nums)
{
Expand Down Expand Up @@ -147,9 +175,9 @@ public static double Math_Factorial(uint n)
}

#region 数学定数
public static double Math_Tau => Math.Tau;
public static double Math_PI => Math.PI;
public static double Math_E => Math.E;
public static double Math_Tau => 6.2831853071795862;
public static double Math_PI => 3.1415926535897931;
public static double Math_E => 2.7182818284590451;

public static double Math_Infinity => double.PositiveInfinity;
public static double Math_NegativeInfinity => double.NegativeInfinity;
Expand All @@ -164,12 +192,20 @@ public static double Math_Factorial(uint n)
#region 端数処理
public static double Math_Round(double x, bool? roudingMode = null)
{
#if NETCOREAPP3_0_OR_GREATER
MidpointRounding mode = roudingMode.HasValue ? roudingMode.Value ? MidpointRounding.AwayFromZero : MidpointRounding.ToZero : MidpointRounding.ToEven;
#else
MidpointRounding mode = roudingMode.HasValue ? roudingMode.Value ? MidpointRounding.AwayFromZero : throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED) : MidpointRounding.ToEven;
#endif
return Math.Round(x, mode);
}
public static double Math_Round(double x, int digits, bool? roudingMode = null)
{
#if NETCOREAPP3_0_OR_GREATER
MidpointRounding mode = roudingMode.HasValue ? roudingMode.Value ? MidpointRounding.AwayFromZero : MidpointRounding.ToZero : MidpointRounding.ToEven;
#else
MidpointRounding mode = roudingMode.HasValue ? roudingMode.Value ? MidpointRounding.AwayFromZero : throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED) : MidpointRounding.ToEven;
#endif
return Math.Round(x, digits, mode);
}
public static double Math_Truncate(double x)
Expand All @@ -185,11 +221,19 @@ public static double Math_Floor(double x)
#region ビット加減算
public static double Math_BitIncrement(double x)
{
#if NETCOREAPP3_0_OR_GREATER
return Math.BitIncrement(x);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static double Math_BitDecrement(double x)
{
#if NETCOREAPP3_0_OR_GREATER
return Math.BitDecrement(x);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
#endregion
#region 三角関数
Expand Down Expand Up @@ -245,15 +289,33 @@ public static double Math_Tanh(double x)
#region 逆双曲線関数
public static double Math_Asinh(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return Math.Asinh(x);
#else
return Math.Log(x + Math.Sqrt(x * x + 1));
#endif
}
public static double Math_Acosh(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return Math.Acosh(x);
#else
return x < 1.0 || double.IsNaN(x)
? double.NaN
: Math.Log(x + Math.Sqrt((x * x) - 1));
#endif
}
public static double Math_Atanh(double x)
{
#if NETCOREAPP2_1_OR_GREATER
return Math.Atanh(x);
#else
if(Math.Abs(x) > 1 || double.IsNaN(x))
{
return double.NaN;
}
return 0.5 * Math.Log((1 + x) / (1 - x));
#endif
}
#endregion
#region 対数関数
Expand All @@ -271,7 +333,11 @@ public static double Math_Log(double a, double baseNum)

public static double Math_ReciprocalEstimate(double a)
{
#if NET6_0_OR_GREATER
return Math.ReciprocalEstimate(a);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
}

Expand Down
2 changes: 2 additions & 0 deletions Losetta.Runtime/Alice.Net.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AliceScript.Binding;
using System.Collections.Generic;
using System.Linq;
using System.Net;

namespace AliceScript.NameSpaces
Expand Down
15 changes: 14 additions & 1 deletion Losetta.Runtime/Alice.Random.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AliceScript.Binding;
using System;
using System.Security.Cryptography;

namespace AliceScript.NameSpaces
Expand Down Expand Up @@ -41,21 +42,33 @@ public static double Rand_Double()
#region 暗号学的乱数生成
public static int Random_Int()
{
#if NETCOREAPP3_0_OR_GREATER
return RandomNumberGenerator.GetInt32(int.MaxValue);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static int Random_Int(int max)
{
#if NETCOREAPP3_0_OR_GREATER
return RandomNumberGenerator.GetInt32(max);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static int Random_Int(int min, int max)
{
#if NETCOREAPP3_0_OR_GREATER
return RandomNumberGenerator.GetInt32(min, max);
#else
throw new ScriptException("この実装では操作がサポートされていません", Exceptions.NOT_IMPLEMENTED);
#endif
}
public static byte[] Random_Bytes(int length)
{
return RandomNumberGenerator.GetBytes(length);
}
#endregion
#endregion
#region GUID生成
public static string Guid_New_Text()
{
Expand Down
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Reflection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AliceScript.Binding;
using AliceScript.Functions;
using AliceScript.Parsing;
using System.Collections.Generic;

namespace AliceScript.NameSpaces
{
Expand Down
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Regex.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AliceScript.Binding;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AliceScript.NameSpaces
Expand Down
1 change: 1 addition & 0 deletions Losetta.Runtime/Alice.Runtime.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AliceScript.Interop;
using AliceScript.NameSpaces;
using System.Collections.Generic;

namespace AliceScript
{
Expand Down
Loading

0 comments on commit 8d73c72

Please sign in to comment.