Daily update on 20251020-041041 by Nitload Youmu. Additional Message : Code cleanup and new design of parallel (maybe THE THENTH VERSION? Tough work!).

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-10-20 04:10:41 +08:00
parent 1927f4fdf3
commit 547ba80a01
141 changed files with 5475 additions and 6175 deletions
+72 -75
View File
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepUncertainEntity.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="StepUncertainEntity"
// 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:
// 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.
//
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
@@ -60,13 +57,13 @@ namespace StgSharp.Model.Step
private ExpSyntaxNode _data;
internal StepUninitializedEntity( StepModel model, int id )
internal StepUninitializedEntity(StepModel model, int id)
{
Context = model;
Id = id;
}
internal StepUninitializedEntity( StepModel model, StepEntityLabel label )
internal StepUninitializedEntity(StepModel model, StepEntityLabel label)
{
Context = model;
Label = label;
@@ -76,12 +73,12 @@ namespace StgSharp.Model.Step
StepModel model,
int id,
ExpSyntaxNode initialization,
IEnumerable<int> dependency )
IEnumerable<int> dependency)
{
Context = model;
Id = id;
_data = initialization;
if( dependency == null )
if (dependency == null)
{
Dependencies = [];
} else
@@ -112,38 +109,38 @@ namespace StgSharp.Model.Step
}
return null;
/**/
if( _data is ExpFunctionCallingNode initNode )
if (_data is ExpFunctionCallingNode initNode)
{
string name = initNode.FunctionCaller.Name;
StepEntityBase? entity = ConvertSimpleEntity( Context, initNode );
if( entity is null )
StepEntityBase? entity = ConvertSimpleEntity(Context, initNode);
if (entity is null)
{
UnsupportedItemTypes.Add( name );
UnsupportedItemTypes.Add(name);
return null;
}
return entity;
} else if( _data is StepComplexEntityNode complex )
} else if (_data is StepComplexEntityNode complex)
{
/**/
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( complex.Right, true );
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(complex.Right, true);
StepRepresentationItem entity = null!;
while( enumerator.MoveNext() )
while (enumerator.MoveNext())
{
if( enumerator.Current is not ExpFunctionCallingNode init ) {
if (enumerator.Current is not ExpFunctionCallingNode init) {
throw new InvalidCastException();
}
StepRepresentationItem? e = ConvertSimpleEntity( Context, init );
if( e is null )
StepRepresentationItem? e = ConvertSimpleEntity(Context, init);
if (e is null)
{
//throw new NotImplementedException( $"Unknown entity type in sequence {Id}" );
// throw new NotImplementedException( $"Unknown entity type in sequence {Id}" );
return null;
}
if( entity is null )
if (entity is null)
{
entity = e;
} else
{
entity = StepDataParser.Implement( entity, e );
entity = StepDataParser.Implement(entity, e);
}
}
return entity;
@@ -151,54 +148,54 @@ namespace StgSharp.Model.Step
return null;
} else
{
throw new ExpInvalidSyntaxException( "Name of entity is required." );
throw new ExpInvalidSyntaxException("Name of entity is required.");
}
}
internal void FromSequence( StepEntityDefineSequence sequence )
internal void FromSequence(StepEntityDefineSequence sequence)
{
ExpSyntaxNode node = sequence.Expression;
if( node is not ExpBinaryOperatorNode assign ) {
throw new ExpInvalidSyntaxException( "Not an assign expression " );
if (node is not ExpBinaryOperatorNode assign) {
throw new ExpInvalidSyntaxException("Not an assign expression ");
}
StepEntityInstanceNode? idNode = assign.Left as StepEntityInstanceNode;
if( idNode!.Id != this.Id ) {
if (idNode!.Id != this.Id) {
throw new InvalidOperationException();
}
FromSequenceUnsafe( sequence );
FromSequenceUnsafe(sequence);
}
internal void FromSequenceUnsafe( StepEntityDefineSequence sequence )
internal void FromSequenceUnsafe(StepEntityDefineSequence sequence)
{
ExpSyntaxNode assign = ( sequence.Expression as ExpBinaryOperatorNode )!;
ExpSyntaxNode assign = (sequence.Expression as ExpBinaryOperatorNode)!;
ExpSyntaxNode initNode;
if( ( assign.Right is ExpFunctionCallingNode f ) )
if ((assign.Right is ExpFunctionCallingNode f))
{
initNode = assign.Right;
ExpEntityTypeName = f.FunctionCaller.Name;
} else if( ( assign.Right is StepComplexEntityNode c ) )
} else if ((assign.Right is StepComplexEntityNode c))
{
initNode = assign.Right;
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator( c.Right, false );
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(c.Right, false);
StringBuilder sb = new StringBuilder();
sb.Append( "Complex entity initialization: " );
sb.Append("Complex entity initialization: ");
int count = 0;
while( enumerator.MoveNext() )
while (enumerator.MoveNext())
{
if( count > 0 ) {
sb.Append( " <-> " );
if (count > 0) {
sb.Append(" <-> ");
}
f = ( enumerator.Current as ExpFunctionCallingNode )!;
sb.Append( $"{f.FunctionCaller.Name}" );
f = (enumerator.Current as ExpFunctionCallingNode)!;
sb.Append($"{f.FunctionCaller.Name}");
count++;
}
ExpEntityTypeName = sb.ToString();
} else
{
throw new ExpInvalidSyntaxException(
"Entity init or complex entity define is required." );
"Entity init or complex entity define is required.");
}
if( _data is not null ) {
if (_data is not null) {
return;
}
_data = initNode!;
@@ -207,32 +204,32 @@ namespace StgSharp.Model.Step
void IConvertableToPipelineNode.NodeMain(
in Dictionary<string, PipelineNodeInPort> input,
in Dictionary<string, PipelineNodeOutPort> output )
in Dictionary<string, PipelineNodeOutPort> output)
{
try
{
StepEntityBase? entity = ConvertToAccurate();
if( entity is not null )
if (entity is not null)
{
entity.FromInstance( this );
Context.ReplaceEntity( this, entity );
entity.FromInstance(this);
Context.ReplaceEntity(this, entity);
}
}
catch( StepEntityUnsupportedException ) { }
catch( Exception ex )
catch (StepEntityUnsupportedException) { }
catch (Exception ex)
{
throw new Exception( $"Step decoder crashed when building entity {Id}", ex );
throw new Exception($"Step decoder crashed when building entity {Id}", ex);
}
//Context.ReplaceEntity( this, entity );
PipelineNodeOutPort.SkipAll( output );
// Context.ReplaceEntity( this, entity );
PipelineNodeOutPort.SkipAll(output);
}
IEnumerable<string> IConvertableToPipelineNode.InputPortName => [InName];
IEnumerable<string> IConvertableToPipelineNode.InputPortName => [ InName ];
PipelineNodeOperation IConvertableToPipelineNode.Operation => ( this as IConvertableToPipelineNode ).NodeMain;
PipelineNodeOperation IConvertableToPipelineNode.Operation => (this as IConvertableToPipelineNode).NodeMain;
IEnumerable<string> IConvertableToPipelineNode.OutputPortName => [OutName];
IEnumerable<string> IConvertableToPipelineNode.OutputPortName => [ OutName ];
}
}