diff options
author | Rodrigo Kumpera <kumpera@gmail.com> | 2009-09-18 23:00:02 +0400 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2009-09-18 23:00:02 +0400 |
commit | 44883fe0f20cd7a79731e9933b0fdcf29a7db263 (patch) | |
tree | 0b8edd16129087bbb31f429ded16e9f4875beabd /mcs/class/Mono.Simd | |
parent | 3314a5b4084e9fa8f341bab5170ce8666f0ebfce (diff) |
2009-09-18 Rodrigo Kumpera <rkumpera@novell.com>
* SimdRuntime.cs: Raise an exception if the method been queried
for acceleration is not found. Methods taking an array now are
variadic.
svn path=/trunk/mcs/; revision=142220
Diffstat (limited to 'mcs/class/Mono.Simd')
-rw-r--r-- | mcs/class/Mono.Simd/Mono.Simd/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/Mono.Simd/Mono.Simd/SimdRuntime.cs | 27 |
2 files changed, 27 insertions, 6 deletions
diff --git a/mcs/class/Mono.Simd/Mono.Simd/ChangeLog b/mcs/class/Mono.Simd/Mono.Simd/ChangeLog index d243260098d..8ab1729a9e2 100644 --- a/mcs/class/Mono.Simd/Mono.Simd/ChangeLog +++ b/mcs/class/Mono.Simd/Mono.Simd/ChangeLog @@ -1,3 +1,9 @@ +2009-09-18 Rodrigo Kumpera <rkumpera@novell.com> + + * SimdRuntime.cs: Raise an exception if the method been queried + for acceleration is not found. Methods taking an array now are + variadic. + 2009-07-14 Zoltan Varga <vargaz@gmail.com> * Changelog: Rename this to ChangeLog. diff --git a/mcs/class/Mono.Simd/Mono.Simd/SimdRuntime.cs b/mcs/class/Mono.Simd/Mono.Simd/SimdRuntime.cs index ba0d5620291..a96ed289d83 100644 --- a/mcs/class/Mono.Simd/Mono.Simd/SimdRuntime.cs +++ b/mcs/class/Mono.Simd/Mono.Simd/SimdRuntime.cs @@ -27,7 +27,7 @@ using System; using System.Reflection; - +using System.Text; namespace Mono.Simd { @@ -48,7 +48,7 @@ namespace Mono.Simd public static AccelMode MethodAccelerationMode (MethodInfo method) { if (method == null) - return AccelMode.None; + throw new ArgumentNullException ("method"); object[] attr = method.GetCustomAttributes (typeof (AccelerationAttribute), false); if (attr.Length == 0) return AccelMode.None; @@ -60,19 +60,34 @@ namespace Mono.Simd return MethodAccelerationMode (type, method, null); } - public static AccelMode MethodAccelerationMode (Type type, String method, Type[] signature) + public static AccelMode MethodAccelerationMode (Type type, String method, params Type[] signature) { MethodInfo mi = signature == null ? type.GetMethod (method) : type.GetMethod (method, signature); + if (mi == null) { + if (signature == null) { + throw new ArgumentException ("method", String.Format ("Type {0} doesn't have a method '{1}'", type, method)); + } else { + StringBuilder sb = new StringBuilder (); + for (int i = 0; i < signature.Length; ++i) { + if (i > 0) + sb.Append (", "); + sb.Append (signature[i]); + } + throw new ArgumentException ("method", String.Format ("Type {0} doesn't have a method '{1}' with signature {2}", type, method, sb)); + } + } + return MethodAccelerationMode (mi); } public static bool IsMethodAccelerated (Type type, String method) - { + { return (MethodAccelerationMode (type, method, null) & AccelMode) != 0; } - public static bool IsMethodAccelerated (Type type, String method, Type[] signature) - { + public static bool IsMethodAccelerated (Type type, String method, params Type[] signature) + { + return (MethodAccelerationMode (type, method, signature) & AccelMode) != 0; } } |