forked from VSharp-team/VSharp
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b856193
commit 26d4819
Showing
91 changed files
with
4,395 additions
and
4,525 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System; | ||
namespace VSharp.CSharpUtils; | ||
|
||
namespace VSharp.CSharpUtils | ||
public static class Array | ||
{ | ||
public static class Array | ||
[Implements("System.Int32 System.Array.GetUpperBound(this, System.Int32)")] | ||
public static int GetUpperBound(System.Array array, int dimension) | ||
{ | ||
[Implements("System.Int32 System.Array.GetUpperBound(this, System.Int32)")] | ||
public static int GetUpperBound(System.Array array, int dimension) | ||
{ | ||
return array.GetLowerBound(dimension) + array.GetLength(dimension) - 1; | ||
} | ||
return array.GetLowerBound(dimension) + array.GetLength(dimension) - 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
namespace VSharp.CSharpUtils | ||
namespace VSharp.CSharpUtils; | ||
|
||
public class BlockChain | ||
{ | ||
public class BlockChain | ||
[Implements("System.Void NBlockchain.Models.BlockchainOptions.FillDefaults(this)")] | ||
public static void FillDefaults(object o) | ||
{ | ||
[Implements("System.Void NBlockchain.Models.BlockchainOptions.FillDefaults(this)")] | ||
public static void FillDefaults(object o) | ||
{ | ||
|
||
} | ||
|
||
[Implements("System.Void Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver..ctor(this)")] | ||
public static void CreateCallSiteRuntimeResolver(object o) | ||
{ | ||
} | ||
|
||
} | ||
[Implements("System.Void Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver..ctor(this)")] | ||
public static void CreateCallSiteRuntimeResolver(object o) | ||
{ | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
namespace VSharp.CSharpUtils | ||
namespace VSharp.CSharpUtils; | ||
|
||
public static class CLRConfig | ||
{ | ||
public static class CLRConfig | ||
[Implements("System.Boolean System.CLRConfig.GetConfigBoolValue(System.String, System.Boolean&)")] | ||
public static bool GetConfigBoolValue(object o, out bool exists) | ||
{ | ||
[Implements("System.Boolean System.CLRConfig.GetConfigBoolValue(System.String, System.Boolean&)")] | ||
public static bool GetConfigBoolValue(object o, out bool exists) | ||
{ | ||
exists = true; | ||
return false; | ||
} | ||
exists = true; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,63 @@ | ||
using System; | ||
|
||
namespace VSharp.CSharpUtils | ||
namespace VSharp.CSharpUtils; | ||
|
||
/// <summary> | ||
/// Calculates the result of applying unary or binary operator to objects with unknown types using 'dynamic's. | ||
/// Casts the result of each operation to a given type. | ||
/// </summary> | ||
public static class Calculator // TODO: use opcode emit for all concrete operations | ||
{ | ||
|
||
/// <summary> | ||
/// Calculates the result of applying unary or binary operator to objects with unknown types using 'dynamic's. | ||
/// Casts the result of each operation to a given type. | ||
/// Returns which power of two value <paramref name="x"/> is. | ||
/// </summary> | ||
public static class Calculator // TODO: use opcode emit for all concrete operations | ||
public static uint WhatPowerOf2(object x) | ||
{ | ||
|
||
/// <summary> | ||
/// Returns which power of two value <paramref name="x"/> is. | ||
/// </summary> | ||
public static uint WhatPowerOf2(object x) | ||
return x switch | ||
{ | ||
return x switch | ||
{ | ||
float s => (uint)Math.Log2(s), | ||
double d => (uint)Math.Log2(d), | ||
byte b => (uint)Math.Log2(b), | ||
sbyte s => (uint)Math.Log2(s), | ||
short i => (uint)Math.Log2(i), | ||
ushort i => (uint)Math.Log2(i), | ||
int i => (uint)Math.Log2(i), | ||
uint i => (uint)Math.Log2(i), | ||
long i => (uint)Math.Log2(i), | ||
ulong i => (uint)Math.Log2(i), | ||
char c => (uint)Math.Log2(c), | ||
IntPtr i => (uint)Math.Log2(i.ToInt64()), | ||
UIntPtr i => (uint)Math.Log2(i.ToUInt64()), | ||
Enum e => (uint)Math.Log2((double)Convert.ChangeType(e, typeof(double))), | ||
_ => throw new ArgumentException($"WhatPowerOf2: unexpected argument {x}") | ||
}; | ||
} | ||
float s => (uint)Math.Log2(s), | ||
double d => (uint)Math.Log2(d), | ||
byte b => (uint)Math.Log2(b), | ||
sbyte s => (uint)Math.Log2(s), | ||
short i => (uint)Math.Log2(i), | ||
ushort i => (uint)Math.Log2(i), | ||
int i => (uint)Math.Log2(i), | ||
uint i => (uint)Math.Log2(i), | ||
long i => (uint)Math.Log2(i), | ||
ulong i => (uint)Math.Log2(i), | ||
char c => (uint)Math.Log2(c), | ||
IntPtr i => (uint)Math.Log2(i.ToInt64()), | ||
UIntPtr i => (uint)Math.Log2(i.ToUInt64()), | ||
Enum e => (uint)Math.Log2((double)Convert.ChangeType(e, typeof(double))), | ||
_ => throw new ArgumentException($"WhatPowerOf2: unexpected argument {x}") | ||
}; | ||
} | ||
|
||
public static int GetDeterministicHashCode(this string str) | ||
public static int GetDeterministicHashCode(this string str) | ||
{ | ||
if (str == null) | ||
return 0; | ||
unchecked | ||
{ | ||
if (str == null) | ||
return 0; | ||
unchecked | ||
{ | ||
int hash1 = (5381 << 16) + 5381; | ||
int hash2 = hash1; | ||
int hash1 = (5381 << 16) + 5381; | ||
int hash2 = hash1; | ||
|
||
for (int i = 0; i < str.Length; i += 2) | ||
{ | ||
hash1 = ((hash1 << 5) + hash1) ^ str[i]; | ||
if (i == str.Length - 1) | ||
break; | ||
hash2 = ((hash2 << 5) + hash2) ^ str[i + 1]; | ||
} | ||
|
||
return hash1 + (hash2 * 1566083941); | ||
for (int i = 0; i < str.Length; i += 2) | ||
{ | ||
hash1 = ((hash1 << 5) + hash1) ^ str[i]; | ||
if (i == str.Length - 1) | ||
break; | ||
hash2 = ((hash2 << 5) + hash2) ^ str[i + 1]; | ||
} | ||
} | ||
|
||
public static int GetDeterministicHashCode(this Type typ) | ||
{ | ||
var method = typ.IsGenericParameter ? typ.DeclaringMethod?.ToString() : ""; | ||
return $"{typ.Assembly.FullName}###{typ.DeclaringType}###{method}###{typ.Name}".GetDeterministicHashCode(); | ||
return hash1 + (hash2 * 1566083941); | ||
} | ||
} | ||
|
||
public static int GetDeterministicHashCode(this Type typ) | ||
{ | ||
var method = typ.IsGenericParameter ? typ.DeclaringMethod?.ToString() : ""; | ||
return $"{typ.Assembly.FullName}###{typ.DeclaringType}###{method}###{typ.Name}".GetDeterministicHashCode(); | ||
} | ||
} |
Oops, something went wrong.