Daily update on 20260125-013900 by Nitload Youmu. Additional Message : start working on state machine and regular analysis

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2026-01-25 01:39:00 +08:00
parent cb62bd48f3
commit 22baa6c5b0
9 changed files with 194 additions and 24 deletions
@@ -1,9 +1,9 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ElementType" // file="ElementType"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload // AuthorGroup: Nitload Space
// Copyright (c) Nitload. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@@ -25,12 +25,6 @@
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric namespace StgSharp.Mathematics.Numeric
{ {
public enum MatrixElementType : int public enum MatrixElementType : int
@@ -1,9 +1,9 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IState" // file="ISimpleStateMachine"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload // AuthorGroup: Nitload Space
// Copyright (c) Nitload. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@@ -33,5 +33,19 @@ using System.Threading.Tasks;
namespace StgSharp.State namespace StgSharp.State
{ {
public interface IState { } public interface ISimpleStateMachine<TStateNode, TStateLabel, TStateContext>
where TStateNode: ISimpleStateMachineNode<TStateLabel, TStateContext>
where TStateLabel: unmanaged, Enum
where TStateContext: StateContext
{
ref readonly TStateNode this[TStateLabel label] { get; }
ref readonly TStateNode GetCurrentStateNode();
void Reset();
bool TryMoveNext(TStateContext ctx);
}
} }
@@ -1,9 +1,9 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IStateMachine" // file="ISimpleStateMachineNode"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload // AuthorGroup: Nitload Space
// Copyright (c) Nitload. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@@ -33,14 +33,13 @@ using System.Threading.Tasks;
namespace StgSharp.State namespace StgSharp.State
{ {
public interface IStateMachine<TState, TLabel, TInput> where TState: IState public interface ISimpleStateMachineNode<TLabel, TStateContext> where TLabel: unmanaged, Enum
where TStateContext: StateContext
{ {
TState CurrentState { get; set; } public ICollection<TLabel> AvailableStateLabels { get; }
TState RootState { get; } bool TryGetNextStateLabel(TLabel label, TStateContext context, out TLabel nextLabel);
void GotoNextState(TInput input);
} }
} }
+40
View File
@@ -0,0 +1,40 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StateContext.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.State
{
public abstract class StateContext { }
}
+3 -3
View File
@@ -1,4 +1,4 @@
#include "sn_target.h" #include "sn_target.h"
#if SN_IS_ARCH(SN_ARCH_X86_64) #if SN_IS_ARCH(SN_ARCH_X86_64)
@@ -96,7 +96,7 @@ DECLARE_KER_PROC_LEFT_RIGHT_ANS_SCALAR(float, sse, , try_plu)
__m128 _t = _mm_shuffle_ps(_p, _p, _MM_SHUFFLE(2, 3, 0, 1)); \ __m128 _t = _mm_shuffle_ps(_p, _p, _MM_SHUFFLE(2, 3, 0, 1)); \
_p = _mm_add_ps(_p, _t); \ _p = _mm_add_ps(_p, _t); \
_t = _mm_movehl_ps(_t, _p); \ _t = _mm_movehl_ps(_t, _p); \
ans = _mm_cvt_ss(_mm_add_ss(_p, _t)); \ ans = _mm_cvtss_f32(_mm_add_ss(_p, _t)); \
} while (0) } while (0)
#define FIND_MAX_F32_SSE(a, b) \ #define FIND_MAX_F32_SSE(a, b) \
@@ -143,7 +143,7 @@ DECLARE_KER_PROC_RIGHT_ANS(float, sse, , quality)
register __m128 min0 = _mm_min_ps(col_shuff_2, col_shuff_3); register __m128 min0 = _mm_min_ps(col_shuff_2, col_shuff_3);
min = _mm_min_ps(min, min0); min = _mm_min_ps(min, min0);
float quality = _mm_cvt_ss(_mm_div_ps(min, _mm_add_ps(max, tiny))); float quality = _mm_cvtss_f32(_mm_div_ps(min, _mm_add_ps(max, tiny)));
ans->f32_x[0].m128_f32[0] = quality; ans->f32_x[0].m128_f32[0] = quality;
if (quality < quality_threshold) { if (quality < quality_threshold) {
return; return;
@@ -0,0 +1,62 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="RegularExpression.StateMachine"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.State;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.RegularAnalysis
{
public partial class RegularExpression
{
private readonly RegularExpressionState _state;
private class RegularExpressionState : ISimpleStateMachine<, RegularExpressionCases, RegularExpressionStateContext> { }
private enum RegularExpressionCases { }
private class RegularExpressionStateContext : StateContext
{
public int Begin { get; set; }
public int Position { get; set; }
public ReadOnlySpan<char> CurrentCharSpan => Source.AsSpan()[Begin..Position];
public string Source { get; init; }
}
}
}
@@ -0,0 +1,34 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="RegularExpression.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
namespace StgSharp.RegularAnalysis
{
public class RegularExpression { }
}
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StgSharp.Common\StgSharp.Common.csproj" />
</ItemGroup>
</Project>
+14
View File
@@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Model", "StgSharp.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.Mathematics", "StgSharp.Mathematics\StgSharp.Mathematics.csproj", "{9946599F-4D34-440F-840D-F9443D5AEFAA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.Mathematics", "StgSharp.Mathematics\StgSharp.Mathematics.csproj", "{9946599F-4D34-440F-840D-F9443D5AEFAA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.RegularAnalysis", "StgSharp.RegularAnalysis\StgSharp.RegularAnalysis.csproj", "{46339874-C6B8-4361-997E-2E30387E51F9}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64 Debug|ARM64 = Debug|ARM64
@@ -123,6 +125,18 @@ Global
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|ARM64.Build.0 = Release|ARM64 {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|ARM64.Build.0 = Release|ARM64
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.ActiveCfg = Release|x64 {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.ActiveCfg = Release|x64
{9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.Build.0 = Release|x64 {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.Build.0 = Release|x64
{46339874-C6B8-4361-997E-2E30387E51F9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Debug|ARM64.Build.0 = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Debug|x64.ActiveCfg = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Debug|x64.Build.0 = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|ARM64.ActiveCfg = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|ARM64.Build.0 = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|x64.ActiveCfg = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|x64.Build.0 = Debug|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Release|ARM64.ActiveCfg = Release|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Release|ARM64.Build.0 = Release|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Release|x64.ActiveCfg = Release|Any CPU
{46339874-C6B8-4361-997E-2E30387E51F9}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE