Skip to content

Commit

Permalink
[style] fixed style
Browse files Browse the repository at this point in the history
  • Loading branch information
MchKosticyn committed Dec 18, 2023
1 parent b856193 commit 26d4819
Show file tree
Hide file tree
Showing 91 changed files with 4,395 additions and 4,525 deletions.
925 changes: 462 additions & 463 deletions VSharp.API/VSharp.cs

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions VSharp.CSharpUtils/ArrayUtils.cs
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;
}
}
23 changes: 11 additions & 12 deletions VSharp.CSharpUtils/BlockChain.cs
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)
{

}
}

}
15 changes: 7 additions & 8 deletions VSharp.CSharpUtils/CLRConfig.cs
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;
}
}
97 changes: 48 additions & 49 deletions VSharp.CSharpUtils/Calculator.cs
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();
}
}
Loading

0 comments on commit 26d4819

Please sign in to comment.