Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class StgSharp
|
||||
public static unsafe partial class World
|
||||
{
|
||||
|
||||
private static byte leastUnusedArea;
|
||||
|
||||
@@ -39,9 +39,9 @@ using System.Threading.Tasks;
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// An independent storage area, used as the only folder type in root folder. Contains several
|
||||
/// <see cref="SSD" /> files reference as virtual disc. Data is actually stored in <see
|
||||
/// cref="SSD" />s in certain RAID mode.
|
||||
/// An independent storage area, used as the only folder type in root folder. Contains several
|
||||
/// <see cref="SSD" /> files reference as virtual disc. Data is actually stored in <see
|
||||
/// cref="SSD" />s in certain RAID mode.
|
||||
/// </summary>
|
||||
public partial class Area { }
|
||||
}
|
||||
|
||||
@@ -66,7 +66,8 @@ namespace StgSharp.Internal
|
||||
public unsafe byte[] GetBytes()
|
||||
{
|
||||
byte[] ret = new byte[16];
|
||||
fixed( M128* vptr = &data ) {
|
||||
fixed( M128* vptr = &data )
|
||||
{
|
||||
byte* bptr = ( byte* )vptr;
|
||||
for( int i = 0; i < 15; i++ ) {
|
||||
ret[ i ] = *bptr;
|
||||
|
||||
@@ -44,12 +44,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
[StructLayout( LayoutKind.Explicit, Size = StgSharp.ssdSegmentLength * 16 )]
|
||||
[StructLayout( LayoutKind.Explicit, Size = World.ssdSegmentLength * 16 )]
|
||||
public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment>
|
||||
{
|
||||
|
||||
[FieldOffset( 16 )] public fixed byte Data[
|
||||
16 * ( StgSharp.ssdSegmentLength - 1 ) ];
|
||||
[FieldOffset( 16 )] public fixed byte Data[ 16 * ( World.ssdSegmentLength - 1 ) ];
|
||||
[FieldOffset( 12 )] public int DataHash;
|
||||
[FieldOffset( 8 )] public int PreviousHash;
|
||||
[FieldOffset( 0 * 16 )] public SSDSegmentHead Head;
|
||||
@@ -63,7 +62,7 @@ namespace StgSharp.Internal
|
||||
{
|
||||
get
|
||||
{
|
||||
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) {
|
||||
if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return Data[ index ];
|
||||
@@ -71,7 +70,7 @@ namespace StgSharp.Internal
|
||||
|
||||
set
|
||||
{
|
||||
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) {
|
||||
if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
Data[ index ] = value;
|
||||
@@ -98,15 +97,15 @@ namespace StgSharp.Internal
|
||||
|
||||
public static SSDSegment FromStream( byte[] stream )
|
||||
{
|
||||
if( stream.Length != 16 * StgSharp.ssdSegmentLength ) {
|
||||
if( stream.Length != 16 * World.ssdSegmentLength ) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
SSDSegment ret = new SSDSegment();
|
||||
fixed( byte* bptr = stream ) {
|
||||
fixed( byte* bptr = stream )
|
||||
{
|
||||
ret.Head.data = *( M128* )bptr;
|
||||
for( int i = 1; i < StgSharp.ssdSegmentLength; i++ ) {
|
||||
ret.WriteData<M128>(
|
||||
i - 1, *( M128* )( bptr + ( 16 * i ) ) );
|
||||
for( int i = 1; i < World.ssdSegmentLength; i++ ) {
|
||||
ret.WriteData<M128>( i - 1, *( M128* )( bptr + ( 16 * i ) ) );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -114,9 +113,11 @@ namespace StgSharp.Internal
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] ret = new byte[16 * StgSharp.ssdSegmentLength];
|
||||
fixed( M128* mptr = &Head.data ) {
|
||||
fixed( byte* aptr = ret ) {
|
||||
byte[] ret = new byte[16 * World.ssdSegmentLength];
|
||||
fixed( M128* mptr = &Head.data )
|
||||
{
|
||||
fixed( byte* aptr = ret )
|
||||
{
|
||||
Vector4* vsptr = ( Vector4* )mptr;
|
||||
Vector4* vtptr = ( Vector4* )aptr;
|
||||
for( int i = 0; i < 18; i++ ) {
|
||||
@@ -131,9 +132,10 @@ namespace StgSharp.Internal
|
||||
public int GetDataHash()
|
||||
{
|
||||
Vector4 v = Vector4.One;
|
||||
fixed( M128* mptr = &Head.data ) {
|
||||
fixed( M128* mptr = &Head.data )
|
||||
{
|
||||
Vector4* vptr = ( Vector4* )mptr;
|
||||
for( int i = 0; i < StgSharp.ssdSegmentLength - 1; i += 1 ) {
|
||||
for( int i = 0; i < World.ssdSegmentLength - 1; i += 1 ) {
|
||||
v += ( *vptr ) * 31;
|
||||
}
|
||||
}
|
||||
@@ -145,9 +147,10 @@ namespace StgSharp.Internal
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int ret = 17;
|
||||
fixed( M128* mptr = &Head.data ) {
|
||||
fixed( M128* mptr = &Head.data )
|
||||
{
|
||||
Vector4* vptr = ( Vector4* )mptr;
|
||||
for( int i = 0; i < StgSharp.ssdSegmentLength; i++ ) {
|
||||
for( int i = 0; i < World.ssdSegmentLength; i++ ) {
|
||||
ret = ( ret + ( *vptr ).GetHashCode() ) * 31;
|
||||
}
|
||||
}
|
||||
@@ -156,7 +159,8 @@ namespace StgSharp.Internal
|
||||
|
||||
public unsafe T ReadData<T>( int index ) where T: struct
|
||||
{
|
||||
fixed( byte* bptr = Data ) {
|
||||
fixed( byte* bptr = Data )
|
||||
{
|
||||
T* tptr = ( T* )bptr;
|
||||
return *( tptr + index );
|
||||
}
|
||||
@@ -164,7 +168,8 @@ namespace StgSharp.Internal
|
||||
|
||||
public unsafe void WriteData<T>( int index, T value ) where T: struct
|
||||
{
|
||||
fixed( byte* bptr = Data ) {
|
||||
fixed( byte* bptr = Data )
|
||||
{
|
||||
T* tptr = ( T* )bptr;
|
||||
*( tptr + index ) = value;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ namespace StgSharp.Internal
|
||||
|
||||
public static SSD FromFile( string fileRoute )
|
||||
{
|
||||
return new SSD(
|
||||
new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
|
||||
return new SSD( new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,17 +60,9 @@ namespace StgSharp.Internal.FileIO
|
||||
streamSource.Read( data.AsSpan() );
|
||||
}
|
||||
|
||||
public SSDrawHead Head
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public SSDrawHead Head { get; set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ using System.Text;
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A class contains a sets of methods to serialize several types
|
||||
/// A class contains a sets of methods to serialize several types
|
||||
/// </summary>
|
||||
public static partial class Serializer { }
|
||||
}
|
||||
|
||||
@@ -39,10 +39,7 @@ namespace StgSharp.Internal
|
||||
public interface ISSDSerializable
|
||||
{
|
||||
|
||||
public SerializableTypeCode SSDTypeCode
|
||||
{
|
||||
get;
|
||||
}
|
||||
public SerializableTypeCode SSDTypeCode { get; }
|
||||
|
||||
public byte[] GetBytes();
|
||||
|
||||
@@ -68,8 +65,7 @@ namespace StgSharp.Internal
|
||||
public static partial class Serializer
|
||||
{
|
||||
|
||||
public static T Deserialize<T>( byte[] stream )
|
||||
where T: ISSDSerializable
|
||||
public static T Deserialize<T>( byte[] stream ) where T: ISSDSerializable
|
||||
{
|
||||
T serializableObject = Activator.CreateInstance<T>();
|
||||
serializableObject.FromBytes( stream );
|
||||
@@ -78,7 +74,8 @@ namespace StgSharp.Internal
|
||||
|
||||
public static string GetNameTail( SerializableTypeCode typeCode )
|
||||
{
|
||||
switch( typeCode ) {
|
||||
switch( typeCode )
|
||||
{
|
||||
case SerializableTypeCode.IndexTable:
|
||||
return "_idt";
|
||||
case SerializableTypeCode.PixelImage:
|
||||
|
||||
@@ -41,13 +41,9 @@ namespace StgSharp.Data
|
||||
public interface IValueBox
|
||||
{
|
||||
|
||||
ref object ValueReference
|
||||
{
|
||||
get;
|
||||
}
|
||||
ref object ValueReference { get; }
|
||||
|
||||
static virtual IValueBox<T> AsGeneric<T>( IValueBox box )
|
||||
where T: struct
|
||||
static virtual IValueBox<T> AsGeneric<T>( IValueBox box ) where T: struct
|
||||
{
|
||||
if( box is not IValueBox<T> genericBox ) {
|
||||
return null;
|
||||
@@ -65,19 +61,17 @@ namespace StgSharp.Data
|
||||
public interface IValueBox<T> where T: struct
|
||||
{
|
||||
|
||||
T Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
T Value { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class attempt to reduce cost of boxing, though still a bit slower than direct access to
|
||||
/// _origin value type instance.
|
||||
/// A class attempt to reduce cost of boxing, though still a bit slower than direct access to
|
||||
/// _origin value type instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> Type of instance to be boxed. </typeparam>
|
||||
/// <typeparam name="T">
|
||||
/// Type of instance to be boxed.
|
||||
/// </typeparam>
|
||||
public class ValueBox<T> : IValueBox, IValueBox<T> where T: struct
|
||||
{
|
||||
|
||||
@@ -88,8 +82,7 @@ namespace StgSharp.Data
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public ref object ValueReference => ref Unsafe.As<T, object>(
|
||||
ref _value );
|
||||
public ref object ValueReference => ref Unsafe.As<T, object>( ref _value );
|
||||
|
||||
public T Value
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user