Daily update on 20250420-041137 by Nitload Youmu. Additional Message : Change: pipeline nodes use port to connect instead of connctors, this make send to multi-ports and recieve from multi-ports possible.

Remove: Some types in Pipeline namepace removed sueto no need for connectors

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-04-20 04:11:37 +08:00
parent c29993fd84
commit b618fdf7b5
72 changed files with 1343 additions and 602 deletions
+12 -4
View File
@@ -39,7 +39,7 @@ using System.Threading.Tasks;
namespace StgSharp.Graphics namespace StgSharp.Graphics
{ {
public class TexturePipeline : PipeLineConnectorArgs public class TexturePipeline : IPipeLineConnectionPayload
{ {
private Image _value; private Image _value;
@@ -49,11 +49,19 @@ namespace StgSharp.Graphics
_value = i; _value = i;
} }
public new Image Value public object? ValueDefault => null;
public object Value
{ {
get => _value; get => _value;
set => _value = value ?? set
throw new ArgumentNullException( nameof( value ) ); {
ArgumentNullException.ThrowIfNull( value );
if( value is not Image image ) {
throw new ArgumentException( "Value must be of type Image" );
}
_value = image;
}
} }
} }
@@ -52,7 +52,7 @@ namespace StgSharp.PipeLine
MainExecution = startup; MainExecution = startup;
this.cycleCount = ( cycleCount > 1 ) ? this.cycleCount = ( cycleCount > 1 ) ?
cycleCount : throw new ArgumentException( cycleCount : throw new ArgumentException(
$"{$"The {typeof(CrossFrameOperation).Name} crosses only one cycle, "}{$"please use a {typeof(PipeLineNode).Name} instead."}" ); $"{$"The {typeof(CrossFrameOperation).Name} crosses only one cycle, "}{$"please use a {typeof(PipelineNode).Name} instead."}" );
this.cycleCount = cycleCount; this.cycleCount = cycleCount;
currentCount = cycleCount; currentCount = cycleCount;
} }
@@ -63,28 +63,30 @@ namespace StgSharp.PipeLine
private protected set => _mainExecution = value; private protected set => _mainExecution = value;
} }
public BlueprintNodeOperation Operation
{
get => ExecuteMain;
}
public IEnumerable<string> InputInterfacesName => _inputName; public IEnumerable<string> InputInterfacesName => _inputName;
public IEnumerable<string> OutputInterfacesName => _outputName; public IEnumerable<string> OutputInterfacesName => _outputName;
public void ExecuteMain( public PipelineNodeOperation Operation
in Dictionary<string, PipelineConnector> input, {
in Dictionary<string, PipelineConnector> output ) get => NodeMain;
}
public void NodeMain(
in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineNodeExport> output )
{
if( currentCount < cycleCount )
{ {
if( currentCount < cycleCount ) {
Interlocked.Increment( ref currentCount ); Interlocked.Increment( ref currentCount );
} else { } else
{
Interlocked.Exchange( ref currentCount, 0 ); Interlocked.Exchange( ref currentCount, 0 );
Task.Run( MainExecution ); Task.Run( MainExecution );
} }
//Console.WriteLine(currentCount); //Console.WriteLine(currentCount);
PipelineConnector.SkipAll( output ); PipelineNodeExport.SkipAll( output );
} }
} }
@@ -35,27 +35,22 @@ using System.Text;
namespace StgSharp.PipeLine namespace StgSharp.PipeLine
{ {
public delegate void BlueprintNodeOperation( public delegate void PipelineNodeOperation(
in Dictionary<string, PipelineConnector> input, in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineConnector> output ); in Dictionary<string, PipelineNodeExport> output );
public interface IConvertableToBlueprintNode public interface IConvertableToBlueprintNode
{ {
BlueprintNodeOperation Operation PipelineNodeOperation Operation { get; }
{
get;
}
public IEnumerable<string> InputInterfacesName public IEnumerable<string> InputInterfacesName { get; }
{
get;
}
public IEnumerable<string> OutputInterfacesName public IEnumerable<string> OutputInterfacesName { get; }
{
get; void NodeMain(
} in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineNodeExport> output );
} }
@@ -64,10 +59,10 @@ namespace StgSharp.PipeLine
private string[] _input; private string[] _input;
private string[] _output; private string[] _output;
private BlueprintNodeOperation _execution; private PipelineNodeOperation _execution;
public DefaultConvertableToBlueprintNode( public DefaultConvertableToBlueprintNode(
BlueprintNodeOperation execution, PipelineNodeOperation execution,
string[] input, string[] input,
string[] output ) string[] output )
{ {
@@ -76,11 +71,18 @@ namespace StgSharp.PipeLine
_execution = execution; _execution = execution;
} }
public BlueprintNodeOperation Operation => _execution; public PipelineNodeOperation Operation => _execution;
public IEnumerable<string> InputInterfacesName => _input; public IEnumerable<string> InputInterfacesName => _input;
public IEnumerable<string> OutputInterfacesName => _output; public IEnumerable<string> OutputInterfacesName => _output;
public void NodeMain(
in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineNodeExport> output )
{
_execution.Invoke( input, output );
}
} }
} }
+56 -41
View File
@@ -46,19 +46,17 @@ namespace StgSharp.PipeLine
public static class PipeLineRunner public static class PipeLineRunner
{ {
private static NodeRunner[] allAvailableTask = CreateBlueprintRunnerArray( private static NodeRunner[] allAvailableTask = CreateBlueprintRunnerArray();
); private static CancellationTokenSource cts = new CancellationTokenSource();
private static CancellationTokenSource cts = new CancellationTokenSource( private static ConcurrentStack<PipelineScheduler> blueprintInWaiting
); = new ConcurrentStack<PipelineScheduler>();
private static ConcurrentStack<BlueprintScheduler> blueprintInWaiting
= new ConcurrentStack<BlueprintScheduler>();
private static int _callingThread; private static int _callingThread;
private static SemaphoreSlim bpLock = new SemaphoreSlim( 0, 1 ); private static SemaphoreSlim bpLock = new SemaphoreSlim( 0, 1 );
/// <summary> /// <summary>
/// <para> Only the following occasions of calling are valid: </para> <para> 1. no bp is /// <para> Only the following occasions of calling are valid: </para> <para>1. no bp is
/// running or the only bp is quitting. </para><para> 2. calling from the main thread or a /// running or the only bp is quitting.</para><para>2. calling from the main thread or a
/// thread the current bp is running on.</para> /// thread the current bp is running on. </para>
/// </summary> /// </summary>
internal static bool IsValidCalling internal static bool IsValidCalling
{ {
@@ -66,18 +64,22 @@ namespace StgSharp.PipeLine
{ {
if( ( NodeRunner.CurrentBlueprint == null ) || //no bp running at all if( ( NodeRunner.CurrentBlueprint == null ) || //no bp running at all
( ( blueprintInWaiting.IsEmpty ) && ( NodeRunner.CurrentBlueprint.IsRunning == ( ( blueprintInWaiting.IsEmpty ) && ( NodeRunner.CurrentBlueprint.IsRunning ==
false ) ) ) { false ) ) )
{
// a bp is quitting // a bp is quitting
//in case no bp is running //in case no bp is running
return true; return true;
} }
int? id = Task.CurrentId; int? id = Task.CurrentId;
if( id is null ) { if( id is null )
{
// in case calling from main thread and current running bp // in case calling from main thread and current running bp
return _callingThread == Environment.CurrentManagedThreadId; return _callingThread == Environment.CurrentManagedThreadId;
} }
foreach( NodeRunner item in allAvailableTask ) { foreach( NodeRunner item in allAvailableTask )
if( item.Id == id ) { {
if( item.Id == id )
{
//if calling from any bp running task //if calling from any bp running task
return true; return true;
} }
@@ -86,25 +88,29 @@ namespace StgSharp.PipeLine
} }
} }
public static void Run( BlueprintScheduler blueprint ) public static void Run( PipelineScheduler blueprint )
{ {
//Console.WriteLine(); //Console.WriteLine();
if( blueprint == null ) { if( blueprint == null )
{
return; return;
} }
if( blueprint.IsRunning ) { if( blueprint.IsRunning ) {
throw new InvalidOperationException( throw new InvalidOperationException( "Attempt to run a blueprint instance twice." );
"Attempt to run a blueprint instance twice." );
} }
if( IsValidCalling ) { if( IsValidCalling )
{
//Console.WriteLine("valid and run"); //Console.WriteLine("valid and run");
if( InterruptAndRunNewBp( blueprint ) ) { if( InterruptAndRunNewBp( blueprint ) )
{
while( InterruptAndRunNewBp( NodeRunner.CurrentBlueprint ) ) { } while( InterruptAndRunNewBp( NodeRunner.CurrentBlueprint ) ) { }
; ;
} }
} else { } else
{
bpLock.Wait(); bpLock.Wait();
if( InterruptAndRunNewBp( blueprint ) ) { if( InterruptAndRunNewBp( blueprint ) )
{
while( InterruptAndRunNewBp( NodeRunner.CurrentBlueprint ) ) { } while( InterruptAndRunNewBp( NodeRunner.CurrentBlueprint ) ) { }
} }
@@ -118,8 +124,10 @@ namespace StgSharp.PipeLine
if( size < 1 ) { if( size < 1 ) {
size = 1; size = 1;
} }
if( allAvailableTask.Length >= size ) { if( allAvailableTask.Length >= size )
for( int i = size; i < allAvailableTask.Length; i++ ) { {
for( int i = size; i < allAvailableTask.Length; i++ )
{
if( allAvailableTask[ i ] != null ) { if( allAvailableTask[ i ] != null ) {
allAvailableTask[ i ].Cancel(); allAvailableTask[ i ].Cancel();
} }
@@ -135,44 +143,47 @@ namespace StgSharp.PipeLine
foreach( NodeRunner task in allAvailableTask ) { foreach( NodeRunner task in allAvailableTask ) {
task.Cts.Cancel(); task.Cts.Cancel();
} }
foreach( BlueprintScheduler bp in blueprintInWaiting ) { foreach( PipelineScheduler bp in blueprintInWaiting ) {
bp.Terminate(); bp.Terminate();
} }
blueprintInWaiting.Clear(); blueprintInWaiting.Clear();
} }
internal static bool InterruptAndRunNewBp( BlueprintScheduler newBp ) internal static bool InterruptAndRunNewBp( PipelineScheduler newBp )
{ {
Debug.Assert( newBp != null ); Debug.Assert( newBp != null );
if( ( newBp != NodeRunner.CurrentBlueprint ) && ( NodeRunner.CurrentBlueprint != if( ( newBp != NodeRunner.CurrentBlueprint ) && ( NodeRunner.CurrentBlueprint != null ) )
null ) ) { {
//if a running bp exists //if a running bp exists
blueprintInWaiting.Push( NodeRunner.CurrentBlueprint ); blueprintInWaiting.Push( NodeRunner.CurrentBlueprint );
} }
//load new bp to current bp //load new bp to current bp
Interlocked.Exchange( ref NodeRunner.CurrentBlueprint!, newBp ); Interlocked.Exchange( ref NodeRunner.CurrentBlueprint!, newBp );
Interlocked.Exchange( Interlocked.Exchange( ref _callingThread, Environment.CurrentManagedThreadId );
ref _callingThread, Environment.CurrentManagedThreadId );
//run beginning node to init it first. //run beginning node to init it first.
if( !NodeRunner.CurrentBlueprint.IsRunning ) { if( !NodeRunner.CurrentBlueprint.IsRunning )
( NodeRunner.CurrentBlueprint.BeginLayer as BeginningNode )!.Run( {
); ( NodeRunner.CurrentBlueprint.BeginLayer as BeginningNode )!.Run();
} }
//refresh all tasks //refresh all tasks
for( int i = 0; i < allAvailableTask.Length; i++ ) { for( int i = 0; i < allAvailableTask.Length; i++ )
{
NodeRunner item = allAvailableTask[ i ]; NodeRunner item = allAvailableTask[ i ];
if( ( item is null ) || item.IsCompleted ) { if( ( item is null ) || item.IsCompleted ) {
allAvailableTask[ i ] = NodeRunner.Run(); allAvailableTask[ i ] = NodeRunner.Run();
} }
} }
PipeLineNode node; PipelineNode node;
while( !cts.Token.IsCancellationRequested && NodeRunner.CurrentBlueprint while( !cts.Token.IsCancellationRequested && NodeRunner.CurrentBlueprint
.RequestNextNativeNode( out node ) ) { .RequestNextNativeNode(
out node ) )
{
node.Run(); node.Run();
if( !NodeRunner.CurrentBlueprint.IsRunning ) { if( !NodeRunner.CurrentBlueprint.IsRunning )
{
break; break;
} }
} }
@@ -191,7 +202,7 @@ namespace StgSharp.PipeLine
internal class NodeRunner : CancellableTask internal class NodeRunner : CancellableTask
{ {
private static BlueprintScheduler _current; private static PipelineScheduler _current;
internal NodeRunner() internal NodeRunner()
: base() : base()
@@ -199,14 +210,17 @@ namespace StgSharp.PipeLine
_startup = InternalRun; _startup = InternalRun;
} }
internal static ref BlueprintScheduler CurrentBlueprint internal static ref PipelineScheduler CurrentBlueprint
{ {
get => ref _current; get => ref _current;
} }
internal static NodeRunner Run() internal static NodeRunner Run()
{ {
NodeRunner ret = new NodeRunner { _startup = InternalRun }; NodeRunner ret = new NodeRunner
{
_startup = InternalRun
};
ret._internalTask = Task.Run( ret.InternalAction ); ret._internalTask = Task.Run( ret.InternalAction );
return ret; return ret;
} }
@@ -214,9 +228,10 @@ namespace StgSharp.PipeLine
private static void InternalRun( CancellationToken token ) private static void InternalRun( CancellationToken token )
{ {
//Console.WriteLine("Task Begin"); //Console.WriteLine("Task Begin");
PipeLineNode item; PipelineNode item;
while( ( CurrentBlueprint != null ) && CurrentBlueprint.IsRunning && !token.IsCancellationRequested && CurrentBlueprint.RequestNexGlobalNode( while( ( CurrentBlueprint != null ) && CurrentBlueprint.IsRunning && !token.IsCancellationRequested && CurrentBlueprint.RequestNexGlobalNode(
out item ) ) { out item ) )
{
//Console.WriteLine($"Get node of {item.Name}, going to run."); //Console.WriteLine($"Get node of {item.Name}, going to run.");
item.Run(); item.Run();
} }
@@ -0,0 +1,157 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="PipelineNodePort.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.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.PipeLine
{
public class PipelineNodeExport
{
private HashSet<PipelineNodeImport> _linkerSet = new HashSet<PipelineNodeImport>();
private SemaphoreSlim formerCompleteSemaphore;
public PipelineNodeExport( PipelineNode container, string name )
{
Container = container;
Name = name;
formerCompleteSemaphore = new SemaphoreSlim( initialCount: 0, maxCount: 1 );
}
public PipelineNode Container { get; init; }
public SemaphoreSlim Waiter { get; init; }
public string Name { get; init; }
public void Connect( PipelineNodeImport port )
{
ArgumentNullException.ThrowIfNull( port );
if( _linkerSet.Add( port ) ) {
Container.Next.Add( port.Container );
}
}
public static void SkipAll( Dictionary<string, PipelineNodeExport> ports )
{
if( ports is null ) {
return;
}
foreach( PipelineNodeExport port in ports.Values ) {
port.Waiter.Release();
}
}
public void TransmitValue( IPipeLineConnectionPayload value )
{
foreach( PipelineNodeImport item in _linkerSet ) { }
}
public void WaitAll( IEnumerable<PipelineNodeExport> ports )
{
if( ports is null ) {
return;
}
foreach( PipelineNodeExport port in ports ) {
port.Waiter.Wait();
}
}
}
public class PipelineNodeImport
{
private HashSet<PipelineNodeExport> _linkerSet = new HashSet<PipelineNodeExport>();
public PipelineNodeImport( PipelineNode container, string name )
{
Container = container;
Name = name;
}
public IEnumerable<PipelineNodeExport> LinkedPorts => _linkerSet;
public PipelineNode Container { get; init; }
public SemaphoreSlim Waiter { get; init; }
public string Name { get; init; }
public void Connect( PipelineNodeExport port )
{
ArgumentNullException.ThrowIfNull( port );
if( _linkerSet.Add( port ) ) {
Container.Previous.Add( port.Container );
}
}
public IEnumerator<PipelineNode> GetFormerNodes()
{
foreach( PipelineNodeExport port in _linkerSet ) {
yield return port.Container;
}
}
public void Wait()
{
foreach( PipelineNodeExport connector in _linkerSet ) {
connector.Waiter.Wait();
}
}
public static void WaitAll( IDictionary<string, PipelineNodeImport> ports )
{
if( ports is null ) {
return;
}
foreach( PipelineNodeImport port in ports.Values ) {
port.Wait();
}
}
public static void WaitAll( IEnumerable<PipelineNodeImport> ports )
{
if( ports is null ) {
return;
}
foreach( PipelineNodeImport port in ports ) {
port.Wait();
}
}
}
}
@@ -0,0 +1,60 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="PipelineScheduler.NodeCraeater.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.Text;
namespace StgSharp.PipeLine
{
public partial class PipelineScheduler
{
public PipelineNode CreateBlueprintNode(
string name,
PipelineNodeOperation operation,
string[] inputPort,
string[] outputPort,
bool isNative )
{
PipelineNode node = new PipelineNode( operation, name, isNative, inputPort,
outputPort );
if( isNative )
{
mainThreadNodeList.Add( node );
} else
{
globalNodeList.Add( node );
}
return node;
}
}
}
@@ -0,0 +1,230 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="PipelineScheduler.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 StgSharp.Stg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
namespace StgSharp.PipeLine
{
/// <summary>
/// A sets of complex logic designed for running in multi threads environment. Warning: do not
/// run a <see cref="PipelineScheduler" /> instance in multi threads more than once.
/// </summary>
public partial class PipelineScheduler : IConvertableToBlueprintNode
{
private BeginningNode _beginning;
private Dictionary<string, PipelineNode> allNode;
private EndingNode _ending;
private List<PipelineNode>
_concurrentNodes = new List<PipelineNode>(),
_mainThreadNodes = new List<PipelineNode>();
private List<PipelineNode> globalNodeList;
private List<PipelineNode> mainThreadNodeList;
private SemaphoreSlim runningStat;
internal int currentGlobalNodeIndex;
internal int currentNativeNodeIndex;
public PipelineScheduler()
{
allNode = new Dictionary<string, PipelineNode>();
globalNodeList = new List<PipelineNode>();
mainThreadNodeList = new List<PipelineNode>();
runningStat = new SemaphoreSlim( 1, 1 );
_beginning = new BeginningNode( this );
_ending = new EndingNode( this );
}
public bool IsRunning
{
get => runningStat.CurrentCount == 0;
}
public IEnumerable<string> InputInterfacesName
{
get { return _beginning.OutputPorts.Keys; }
}
public IEnumerable<string> OutputInterfacesName
{
get { return _beginning.OutputPorts.Keys; }
}
public PipelineNode BeginLayer => _beginning;
public PipelineNode EndLayer => _ending;
public PipelineNodeOperation Operation
{
get => ( this as IConvertableToBlueprintNode ).NodeMain;
}
/**/
internal SemaphoreSlim RunningStat
{
get => runningStat;
}
/**/
public void AddNode( PipelineNode node, bool isNative )
{
ArgumentNullException.ThrowIfNull( node );
node.IsNative = isNative;
allNode.Add( node.Name, node );
}
public void ArrangeNodeOrder()
{
LinkedList<PipelineNode> _cache = new LinkedList<PipelineNode>();
foreach( PipelineNode node in _beginning.Next )
{
if( node.IsNative )
{
_mainThreadNodes.Add( node );
} else
{
_concurrentNodes.Add( node );
}
foreach( PipelineNode item in node.Next )
{
item.Previous.Remove( node );
_cache.AddLast( item );
}
}
while( _cache.Count > 0 )
{
LinkedListNode<PipelineNode> begin = _cache.First!,current = begin,zero;
do
{
PipelineNode node = current.Value;
if( current.Value.Previous.Count == 0 )
{
zero = current;
current = current.Next!;
if( node.IsNative )
{
_mainThreadNodes.Add( node );
} else
{
_concurrentNodes.Add( node );
}
foreach( PipelineNode item in node.Next )
{
item.Previous.Remove( node );
_cache.AddLast( item );
}
_cache.Remove( zero );
} else
{
current = current.Next!;
}
} while (current.Next != begin);
}
}
public void Init()
{
foreach( KeyValuePair<string, PipelineNode> item in allNode )
{
if( item.Value.IsNative )
{
mainThreadNodeList.Add( item.Value );
} else
{
globalNodeList.Add( item.Value );
}
}
mainThreadNodeList.Sort();
globalNodeList.Sort();
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void SetInput( params (string name, IPipeLineConnectionPayload arg)[] parameters )
{
_beginning.SetInputData( parameters );
}
public void Terminate()
{
Interlocked.Exchange( ref currentGlobalNodeIndex, int.MaxValue );
Interlocked.Exchange( ref currentNativeNodeIndex, int.MaxValue );
}
internal bool RequestNexGlobalNode( out PipelineNode node )
{
if( currentGlobalNodeIndex < globalNodeList.Count )
{
node = globalNodeList[ currentGlobalNodeIndex ];
Interlocked.Increment( ref currentGlobalNodeIndex );
return true;
}
node = default!;
return false;
}
internal bool RequestNextNativeNode( out PipelineNode node )
{
if( currentNativeNodeIndex < mainThreadNodeList.Count )
{
node = mainThreadNodeList[ currentNativeNodeIndex ];
Interlocked.Increment( ref currentNativeNodeIndex );
return true;
}
node = default!;
return false;
}
void IConvertableToBlueprintNode.NodeMain(
in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineNodeExport> output )
{
PipeLineRunner.Run( this );
PipelineNodeExport.SkipAll( output );
}
~PipelineScheduler()
{
runningStat.Dispose();
}
}
}
+126
View File
@@ -0,0 +1,126 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="PortArgs.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.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Authentication.ExtendedProtection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.PipeLine
{
public class PipelineConnector
{
private protected IPipeLineConnectionPayload args;
private protected PipelineNodeExport input;
private protected PipelineNodeImport output;
private protected SemaphoreSlim formerCompleteSemaphore;
public PipelineConnector( PipelineNodeExport former, PipelineNodeImport after )
{
this.input = former;
this.output = after;
formerCompleteSemaphore = new SemaphoreSlim( initialCount: 0, maxCount: 1 );
}
public IPipeLineConnectionPayload Args
{
get => args;
set => args = value;
}
public PipelineNodeExport Input => input;
public PipelineNodeImport Output => output;
public static void SkipAll( Dictionary<string, PipelineConnector> ports )
{
if( ports == null ) {
return;
}
foreach( KeyValuePair<string, PipelineConnector> item in ports )
{
if( item.Value != null ) {
item.Value.CompleteAndSkip();
}
}
}
public static void WaitAll( Dictionary<string, PipelineConnector> ports )
{
if( ports == null ) {
return;
}
foreach( KeyValuePair<string, PipelineConnector> item in ports )
{
if( item.Value != null ) {
item.Value.WaitForStart();
}
}
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public virtual void WaitForStart()
{
//Console.WriteLine($"Waiting \t{input.ContextName}\t->\t{output.ContextName}");
formerCompleteSemaphore.Wait();
}
~PipelineConnector()
{
formerCompleteSemaphore.Dispose();
}
#region pipline op
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void CompleteAndSkip()
{
//Console.WriteLine($"Complete\t{input.Name}\t->\t{output.Name}");
formerCompleteSemaphore.Release();
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void CompleteAndWriteData( IPipeLineConnectionPayload args )
{
this.args = args;
CompleteAndSkip();
}
#endregion
}
public abstract class IPipeLineConnectionPayload { }
}
+17 -50
View File
@@ -33,93 +33,60 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Security.Principal;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.PipeLine namespace StgSharp.PipeLine
{ {
internal sealed class BeginningNode : PipeLineNode internal sealed class BeginningNode : PipelineNode
{ {
private BlueprintScheduler _bp; private PipelineScheduler _bp;
public BeginningNode( BlueprintScheduler bp ) public BeginningNode( PipelineScheduler bp )
: base( : base( DefaultOperation, name: "BeginningNode", true, ["default"], ["default"] )
DefaultOperation, name: "BeginningNode", true, ["default"],
["default"] )
{ {
_bp = bp; _bp = bp;
} }
internal (string name, PipeLineConnectorArgs arg)[] InputData
{
set
{
if( value == null ) {
return;
}
foreach( (string name, PipeLineConnectorArgs arg) parameter in value ) {
OutputInterfaces[ parameter.name ].Args = parameter.arg;
}
}
}
public override void Run() public override void Run()
{ {
_bp.RunningStat.Wait(); _bp.RunningStat.Wait();
PipelineConnector.SkipAll( _outputInterfaces ); PipelineNodeExport.SkipAll( _output );
} }
public new void SetCertainOutputPort( internal void SetInputData( IEnumerable<(string, IPipeLineConnectionPayload)> data )
string name,
PipelineConnector pipeline )
{ {
if( _outputInterfaces.ContainsKey( name ) ) { if( data is null ) {
_outputInterfaces[ name ] = pipeline; return;
}
foreach( (string, IPipeLineConnectionPayload) item in data ) {
OutputPorts[ item.Item1 ].TransmitValue( item.Item2 );
} }
_outputInterfaces.Add( name, pipeline );
} }
} }
internal sealed class EndingNode : PipeLineNode internal sealed class EndingNode : PipelineNode
{ {
private BlueprintScheduler _bp; private PipelineScheduler _bp;
public EndingNode( BlueprintScheduler bp ) public EndingNode( PipelineScheduler bp )
: base( : base( DefaultOperation, name: "EndingNode", true, ["default"], ["default"] )
DefaultOperation, name: "EndingNode", true, ["default"],
["default"] )
{ {
_bp = bp; _bp = bp;
} }
internal (string name, PipeLineConnectorArgs arg)[] OutputData
{
get { return InputInterfaces.Select(
key => (key.Key, key.Value.Args) )
.ToArray(); }
}
public override void Run() public override void Run()
{ {
PipelineConnector.WaitAll( _inputInterfaces ); PipelineNodeImport.WaitAll( _input );
Interlocked.Exchange( ref _bp.currentGlobalNodeIndex, 0 ); Interlocked.Exchange( ref _bp.currentGlobalNodeIndex, 0 );
Interlocked.Exchange( ref _bp.currentNativeNodeIndex, 0 ); Interlocked.Exchange( ref _bp.currentNativeNodeIndex, 0 );
_bp.RunningStat.Release(); _bp.RunningStat.Release();
} }
public new void SetCertainInputPort(
string name,
PipelineConnector pipeline )
{
if( _inputInterfaces.ContainsKey( name ) ) {
_inputInterfaces[ name ] = pipeline;
}
_inputInterfaces.Add( name, pipeline );
}
} }
} }
+3 -12
View File
@@ -39,10 +39,7 @@ namespace StgSharp
public interface IStateMachine<T> where T: Enum public interface IStateMachine<T> where T: Enum
{ {
public T LastStableState public T LastStableState { get; }
{
get;
}
public bool TryEnterState(); public bool TryEnterState();
@@ -56,15 +53,9 @@ namespace StgSharp
where TState: Enum where TState: Enum
{ {
public bool IsInStabelState public bool IsInStabelState { get; }
{
get;
}
public TState NextStableState public TState NextStableState { get; }
{
get;
}
public bool TrySwitchState(); public bool TrySwitchState();
-4
View File
@@ -83,10 +83,6 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Logic\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
</Target> </Target>
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
-1
View File
@@ -151,7 +151,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} {"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90/*"}}
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -1083,7 +1083,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Generator")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Generator")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Generator")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityInstanceNode.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 StgSharp.Modeling.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepEntityInstanceNode : ExpSyntaxNode
{
private int id;
private StepModel _model;
public StepEntityInstanceNode( Token source, StepModel model ) : base( source ) { }
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
private void GetInstance()
{
_model
}
}
}
+4
View File
@@ -12,4 +12,8 @@
<ProjectReference Include="..\StgSharp.Script\StgSharp.Script.csproj" /> <ProjectReference Include="..\StgSharp.Script\StgSharp.Script.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="STEP\SyntaxNode\" />
</ItemGroup>
</Project> </Project>
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -103,7 +102,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -176,7 +174,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
-1
View File
@@ -1274,7 +1274,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9457309c5ab188ce824a10ab60e572553986b6eb")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
+1 -2
View File
@@ -37,8 +37,7 @@ using System.Xml.Schema;
namespace StgSharp.Script namespace StgSharp.Script
{ {
public sealed class AbstractSyntaxTree<TNode, TType> public sealed class AbstractSyntaxTree<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
where TNode: IASTNode<TNode, TType>
where TType: ITypeSource<TType> where TType: ITypeSource<TType>
{ {
+1 -1
View File
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
namespace StgSharp.Script namespace StgSharp.Script
{ {
public partial class CompileStack<TNode, TType> where TNode: IASTNode<TNode, TType> public partial class CompileStack<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
where TType: ITypeSource<TType> where TType: ITypeSource<TType>
{ {
+69
View File
@@ -0,0 +1,69 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ISyntaxNode.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 StgSharp.Collections;
using StgSharp.Script.Express;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace StgSharp.Script
{
public interface ISyntaxNode<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
where TType: ITypeSource<TType>
{
long NodeFlag { get; }
string CodeConvertTemplate { get; }
TNode Previous { get; set; }
TNode Next { get; set; }
TNode Left { get; }
TNode Right { get; }
static abstract TNode Empty { get; }
Token Source { get; }
TType EqualityTypeConvert { get; }
void AppendNode( TNode nextToken );
void PrependNode( TNode previusNode );
}
}
@@ -65,9 +65,9 @@ namespace StgSharp.Script.Express
public abstract IEnumerator<ExpElementInstance> GetEnumerator(); public abstract IEnumerator<ExpElementInstance> GetEnumerator();
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
@@ -101,7 +101,7 @@ namespace StgSharp.Script.Express
public override string Name => ExpressCompile.PoolString( "ARRAY" ); public override string Name => ExpressCompile.PoolString( "ARRAY" );
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -126,7 +126,7 @@ namespace StgSharp.Script.Express
public override string Name => ExpressCompile.PoolString( "BAG" ); public override string Name => ExpressCompile.PoolString( "BAG" );
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -149,7 +149,7 @@ namespace StgSharp.Script.Express
public override string Name => ExpressCompile.PoolString( "LIST" ); public override string Name => ExpressCompile.PoolString( "LIST" );
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -180,7 +180,7 @@ namespace StgSharp.Script.Express
_collection.Add( token ); _collection.Add( token );
} }
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -34,7 +34,7 @@ using System.Text;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public abstract class ExpCollectionInstanceBase : ExpNode public abstract class ExpCollectionInstanceBase : ExpSyntaxNode
{ {
protected internal (int min, int max) _range; protected internal (int min, int max) _range;
@@ -42,19 +42,16 @@ namespace StgSharp.Script.Express
protected ExpCollectionInstanceBase( Token source ) : base( source ) { } protected ExpCollectionInstanceBase( Token source ) : base( source ) { }
public abstract ExpCollectionBase CollectionValue public abstract ExpCollectionBase CollectionValue { get; }
{
get;
}
public ExpElementType MemberType public ExpElementType MemberType
{ {
get => _memberType; get => _memberType;
} }
public override ExpNode Left => null!; public override ExpSyntaxNode Left => null!;
public override ExpNode Right => null!; public override ExpSyntaxNode Right => null!;
public int MinCapacity => _range.min; public int MinCapacity => _range.min;
+3 -3
View File
@@ -65,7 +65,7 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference( params object[] options )
{ {
if( options.Length == 0 || options[ 0 ] is not string str ) { if( options.Length == 0 || options[ 0 ] is not string str ) {
return null!; return null!;
@@ -84,14 +84,14 @@ namespace StgSharp.Script.Express
return _constants.TryGetValue( name, out instance ); return _constants.TryGetValue( name, out instance );
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
if( _constants.TryGetValue( name, out ExpElementInstance? node ) ) if( _constants.TryGetValue( name, out ExpElementInstance? node ) )
{ {
memberNode = node; memberNode = node;
return true; return true;
} }
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
+3 -3
View File
@@ -37,7 +37,7 @@ namespace StgSharp.Script.Express
public class ExpEntitySource : ExpInstantiableElement public class ExpEntitySource : ExpInstantiableElement
{ {
private AbstractSyntaxTree<ExpNode, IExpElementSource> _expressionTree; private AbstractSyntaxTree<ExpSyntaxNode, IExpElementSource> _expressionTree;
private ScriptSourceTransmitter _source; private ScriptSourceTransmitter _source;
private string _name; private string _name;
@@ -58,12 +58,12 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -70,12 +70,12 @@ namespace StgSharp.Script.Express
*/ */
} }
public override ExpNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference( params object[] options )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) ) if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) )
{ {
@@ -87,7 +87,7 @@ namespace StgSharp.Script.Express
memberNode = variable; memberNode = variable;
return true; return true;
} }
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
@@ -50,12 +50,12 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference( params object[] options )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
+5 -5
View File
@@ -48,9 +48,9 @@ namespace StgSharp.Script.Express
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException( public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
); );
public override ExpNode Left => throw new NotImplementedException(); public override ExpSyntaxNode Left => throw new NotImplementedException();
public override ExpNode Right => throw new NotImplementedException(); public override ExpSyntaxNode Right => throw new NotImplementedException();
public override string TypeName => _source.Name; public override string TypeName => _source.Name;
@@ -79,14 +79,14 @@ namespace StgSharp.Script.Express
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override ExpNode MakeReference( params object[] options ) public override ExpSyntaxNode MakeReference( params object[] options )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
+2 -2
View File
@@ -87,9 +87,9 @@ namespace StgSharp.Script.Express
return type == null || type == ExpVoidType.Only; return type == null || type == ExpVoidType.Only;
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
@@ -40,15 +40,15 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpBinaryOperatorNode : ExpNode public class ExpBinaryOperatorNode : ExpSyntaxNode
{ {
private ExpInstantiableElement _returnType; private ExpInstantiableElement _returnType;
private ExpNode _left; private ExpSyntaxNode _left;
private ExpNode _right; private ExpSyntaxNode _right;
private ExpBinaryOperatorNode( Token source, ExpNode left, ExpNode right ) private ExpBinaryOperatorNode( Token source, ExpSyntaxNode left, ExpSyntaxNode right )
: base( source ) : base( source )
{ {
_left = left; _left = left;
@@ -57,11 +57,14 @@ namespace StgSharp.Script.Express
public override ExpInstantiableElement EqualityTypeConvert => _returnType; public override ExpInstantiableElement EqualityTypeConvert => _returnType;
public override ExpNode Left => _left; public override ExpSyntaxNode Left => _left;
public override ExpNode Right => _right; public override ExpSyntaxNode Right => _right;
public static ExpBinaryOperatorNode Add( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode Add(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -77,7 +80,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Assign( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode Assign(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
@@ -93,8 +99,8 @@ namespace StgSharp.Script.Express
public static ExpBinaryOperatorNode CompareInstanceEqual( public static ExpBinaryOperatorNode CompareInstanceEqual(
Token source, Token source,
ExpNode left, ExpSyntaxNode left,
ExpNode right ) ExpSyntaxNode right )
{ {
return new ExpBinaryOperatorNode( source, left, right ) return new ExpBinaryOperatorNode( source, left, right )
{ {
@@ -106,8 +112,8 @@ namespace StgSharp.Script.Express
public static ExpBinaryOperatorNode CompareInstanceNotEqual( public static ExpBinaryOperatorNode CompareInstanceNotEqual(
Token nsource, Token nsource,
ExpNode left, ExpSyntaxNode left,
ExpNode right ) ExpSyntaxNode right )
{ {
return new ExpBinaryOperatorNode( nsource, left, right ) return new ExpBinaryOperatorNode( nsource, left, right )
{ {
@@ -119,8 +125,8 @@ namespace StgSharp.Script.Express
public static ExpBinaryOperatorNode ConvertElement( public static ExpBinaryOperatorNode ConvertElement(
Token source, Token source,
ExpNode left, ExpSyntaxNode left,
ExpNode right ) ExpSyntaxNode right )
{ {
if( right is not ExpMetaRefNode metaref ) { if( right is not ExpMetaRefNode metaref ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
@@ -138,7 +144,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Div( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode Div(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -154,7 +163,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode EqualTo( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode EqualTo(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
@@ -168,7 +180,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode GreaterThan( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode GreaterThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -181,7 +196,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode LessThan( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode LessThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -194,7 +212,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Mul( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode Mul(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -210,7 +231,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode NotEqualTo( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode NotEqualTo(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) { if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
@@ -224,7 +248,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode SmallerThan( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode SmallerThan(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -237,7 +264,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpBinaryOperatorNode Sub( Token source, ExpNode left, ExpNode right ) public static ExpBinaryOperatorNode Sub(
Token source,
ExpSyntaxNode left,
ExpSyntaxNode right )
{ {
if( !left.IsNumber && !right.IsNumber ) { if( !left.IsNumber && !right.IsNumber ) {
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name ); throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
@@ -36,17 +36,17 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpCollectionIndexNode : ExpNode public class ExpCollectionIndexNode : ExpSyntaxNode
{ {
private ExpCollectionInstanceBase _collection; private ExpCollectionInstanceBase _collection;
private ExpNode _indexExpression; private ExpSyntaxNode _indexExpression;
private ExpCollectionIndexNode( private ExpCollectionIndexNode(
Token source, Token source,
ExpCollectionInstanceBase instance, ExpCollectionInstanceBase instance,
ExpNode indexExpression ) ExpSyntaxNode indexExpression )
: base( source ) : base( source )
{ {
_collection = instance; _collection = instance;
@@ -54,23 +54,22 @@ namespace StgSharp.Script.Express
CodeConvertTemplate = @"{0}[{1}]"; CodeConvertTemplate = @"{0}[{1}]";
} }
public override ExpNode Left => _collection; public override ExpSyntaxNode Left => _collection;
public override ExpNode Right => _indexExpression; public override ExpSyntaxNode Right => _indexExpression;
public override IExpElementSource EqualityTypeConvert => _collection.EqualityTypeConvert; public override IExpElementSource EqualityTypeConvert => _collection.EqualityTypeConvert;
public static ExpCollectionIndexNode Create( public static ExpCollectionIndexNode Create(
Token source, Token source,
ExpCollectionInstanceBase instance, ExpCollectionInstanceBase instance,
ExpNode indexExpression ) ExpSyntaxNode indexExpression )
{ {
if( !indexExpression.IsNumber ) { if( !indexExpression.IsNumber ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException(
"Number", indexExpression.EqualityTypeConvert.Name ); "Number", indexExpression.EqualityTypeConvert.Name );
} }
return new ExpCollectionIndexNode( return new ExpCollectionIndexNode( source, instance, indexExpression );
source, instance, indexExpression );
} }
} }
@@ -36,25 +36,25 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpElementInitializingNode : ExpNode public class ExpElementInitializingNode : ExpSyntaxNode
{ {
private ExpMetaRefNode _type; private ExpMetaRefNode _type;
private ExpNode _init; private ExpSyntaxNode _init;
public ExpElementInitializingNode( public ExpElementInitializingNode(
Token source, Token source,
ExpMetaRefNode type, ExpMetaRefNode type,
ExpNode initParameter ) ExpSyntaxNode initParameter )
: base( source ) : base( source )
{ {
_type = type; _type = type;
_init = initParameter; _init = initParameter;
} }
public override ExpNode Left => _type; public override ExpSyntaxNode Left => _type;
public override ExpNode Right => _init; public override ExpSyntaxNode Right => _init;
public override IExpElementSource EqualityTypeConvert => _type.SourceRef; public override IExpElementSource EqualityTypeConvert => _type.SourceRef;
@@ -36,7 +36,7 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpElementMemberNameNode : ExpNode public class ExpElementMemberNameNode : ExpSyntaxNode
{ {
internal ExpElementMemberNameNode( Token source ) internal ExpElementMemberNameNode( Token source )
@@ -46,9 +46,9 @@ namespace StgSharp.Script.Express
CodeConvertTemplate = source.Value; CodeConvertTemplate = source.Value;
} }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => Empty; public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert public override IExpElementSource EqualityTypeConvert
{ {
@@ -36,31 +36,33 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpFunctionCallingNode : ExpNode public class ExpFunctionCallingNode : ExpSyntaxNode
{ {
private ExpFunctionSource _function; private ExpFunctionSource _function;
private ExpNode _parameter; private ExpSyntaxNode _parameter;
private ExpFunctionCallingNode( private ExpFunctionCallingNode(
Token source, Token source,
ExpFunctionSource function, ExpFunctionSource function,
ExpNode firstParameter ) ExpSyntaxNode firstParameter )
: base( source ) : base( source )
{ {
_function = function; _function = function;
_parameter = firstParameter; _parameter = firstParameter;
} }
public ExpFunctionSource FunctionCaller => _function;
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException( public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
); );
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => _parameter; public override ExpSyntaxNode Right => _parameter;
public void AppendParameter( ExpNode parameter ) public void AppendParameter( ExpSyntaxNode parameter )
{ {
_parameter.AppendNode( parameter ); _parameter.AppendNode( parameter );
} }
@@ -68,7 +70,7 @@ namespace StgSharp.Script.Express
public static ExpFunctionCallingNode CallFunction( public static ExpFunctionCallingNode CallFunction(
Token source, Token source,
ExpFunctionSource function, ExpFunctionSource function,
ExpNode param ) ExpSyntaxNode param )
{ {
return new ExpFunctionCallingNode( source, function, param ); return new ExpFunctionCallingNode( source, function, param );
} }
+12 -12
View File
@@ -36,14 +36,14 @@ using System.Text;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public sealed class ExpIfNode : ExpNode public sealed class ExpIfNode : ExpSyntaxNode
{ {
private ExpNode _falseOpBegin; private ExpSyntaxNode _falseOpBegin;
private ExpNode _rule; private ExpSyntaxNode _rule;
private ExpNode _trueOpBegin ; private ExpSyntaxNode _trueOpBegin ;
public ExpIfNode( Token source, ExpNode rule, ExpNode trueOpBegin ) public ExpIfNode( Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin )
: base( source ) : base( source )
{ {
_rule = rule; _rule = rule;
@@ -59,9 +59,9 @@ namespace StgSharp.Script.Express
public ExpIfNode( public ExpIfNode(
Token source, Token source,
ExpNode rule, ExpSyntaxNode rule,
ExpNode rootOperationIfTrue, ExpSyntaxNode rootOperationIfTrue,
ExpNode rootOperationIfFalse ) ExpSyntaxNode rootOperationIfFalse )
: base( source ) : base( source )
{ {
_rule = rule; _rule = rule;
@@ -78,18 +78,18 @@ namespace StgSharp.Script.Express
""" ); """ );
} }
public override ExpNode Left => _trueOpBegin; public override ExpSyntaxNode Left => _trueOpBegin;
public override ExpNode Right => _falseOpBegin; public override ExpSyntaxNode Right => _falseOpBegin;
public override IExpElementSource EqualityTypeConvert => null!; public override IExpElementSource EqualityTypeConvert => null!;
public void AppendFalseOperation( ExpNode expressionRoot ) public void AppendFalseOperation( ExpSyntaxNode expressionRoot )
{ {
_falseOpBegin.AppendNode( expressionRoot ); _falseOpBegin.AppendNode( expressionRoot );
} }
public void AppendTrueOperation( ExpNode expressionRoot ) public void AppendTrueOperation( ExpSyntaxNode expressionRoot )
{ {
_trueOpBegin.AppendNode( expressionRoot ); _trueOpBegin.AppendNode( expressionRoot );
} }
@@ -38,12 +38,12 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpInstanceMemberNode : ExpNode public class ExpInstanceMemberNode : ExpSyntaxNode
{ {
private ExpElementInstance _instance; private ExpElementInstance _instance;
private ExpElementMemberNameNode _memberName; private ExpElementMemberNameNode _memberName;
private ExpNode _member; private ExpSyntaxNode _member;
public ExpInstanceMemberNode( public ExpInstanceMemberNode(
Token source, Token source,
@@ -56,9 +56,9 @@ namespace StgSharp.Script.Express
_instance.TryGetMember( memberName.CodeConvertTemplate, out _member ); _instance.TryGetMember( memberName.CodeConvertTemplate, out _member );
} }
public override ExpNode Left => _instance; public override ExpSyntaxNode Left => _instance;
public override ExpNode Right => _memberName; public override ExpSyntaxNode Right => _memberName;
public override IExpElementSource EqualityTypeConvert => _member.EqualityTypeConvert; public override IExpElementSource EqualityTypeConvert => _member.EqualityTypeConvert;
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpInstanceReferenceNode : ExpNode public class ExpInstanceReferenceNode : ExpSyntaxNode
{ {
internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance ) internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance )
@@ -58,9 +58,9 @@ namespace StgSharp.Script.Express
public ExpElementInstance OriginObject { get ; private set; } public ExpElementInstance OriginObject { get ; private set; }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => Empty; public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => OriginObject.EqualityTypeConvert; public override IExpElementSource EqualityTypeConvert => OriginObject.EqualityTypeConvert;
@@ -38,26 +38,29 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpMetaRefNode : ExpNode public class ExpMetaRefNode : ExpSyntaxNode
{ {
internal ExpMetaRefNode( Token source, ExpInstantiableElement element ) : base( source ) internal ExpMetaRefNode( Token source, ExpInstantiableElement element )
: base( source )
{ {
SourceRef = element; SourceRef = element;
} }
public ExpInstantiableElement SourceRef { get; init; } public ExpInstantiableElement SourceRef { get; init; }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => Empty; public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void; public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
public static ExpMetaRefNode RefEntity( Token position, ExpEntitySource entity ) public static ExpMetaRefNode RefEntity( Token position, ExpEntitySource entity )
{ {
if( position.Value != entity.Name ) { if( position.Value != entity.Name ) {
throw new ExpCompileException( position, $"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" ); throw new ExpCompileException(
position,
$"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" );
} }
ExpMetaRefNode node = new ExpMetaRefNode( position, entity ) ExpMetaRefNode node = new ExpMetaRefNode( position, entity )
{ {
@@ -69,7 +72,9 @@ namespace StgSharp.Script.Express
public static ExpMetaRefNode RefType( Token position, ExpTypeSource type ) public static ExpMetaRefNode RefType( Token position, ExpTypeSource type )
{ {
if( position.Value != type.Name ) { if( position.Value != type.Name ) {
throw new ExpCompileException( position, $"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" ); throw new ExpCompileException(
position,
$"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" );
} }
ExpMetaRefNode node = new ExpMetaRefNode( position, type ) ExpMetaRefNode node = new ExpMetaRefNode( position, type )
{ {
@@ -37,30 +37,33 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpProcedureCallingNode : ExpNode public class ExpProcedureCallingNode : ExpSyntaxNode
{ {
private ExpNode _params; private ExpSyntaxNode _params;
public ExpProcedureCallingNode( Token source, ExpProcedureSource caller, ExpNode param ) public ExpProcedureCallingNode(
Token source,
ExpProcedureSource caller,
ExpSyntaxNode param )
: base( source ) : base( source )
{ {
_params = param; _params = param;
CalledProcedure = caller; CalledProcedure = caller;
} }
public override ExpNode Left => Empty;
public override ExpNode Right => _params;
public ExpProcedureSource CalledProcedure { get; init; } public ExpProcedureSource CalledProcedure { get; init; }
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => _params;
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void; public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
public static ExpProcedureCallingNode CallProcedure( public static ExpProcedureCallingNode CallProcedure(
Token postion, Token postion,
ExpProcedureSource caller, ExpProcedureSource caller,
ExpNode input ) ExpSyntaxNode input )
{ {
ExpProcedureCallingNode node = new ExpProcedureCallingNode( postion, caller, input ) ExpProcedureCallingNode node = new ExpProcedureCallingNode( postion, caller, input )
{ {
@@ -40,20 +40,20 @@ using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpProcedureControlNode : ExpNode public class ExpProcedureControlNode : ExpSyntaxNode
{ {
private ExpNode _additional; private ExpSyntaxNode _additional;
internal ExpProcedureControlNode( Token source ) : base( source ) { } internal ExpProcedureControlNode( Token source ) : base( source ) { }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => _additional; public override ExpSyntaxNode Right => _additional;
public override IExpElementSource EqualityTypeConvert => ExpTypeSource.Void; public override IExpElementSource EqualityTypeConvert => ExpTypeSource.Void;
public static ExpProcedureControlNode Return( Token t, ExpNode valueToReturn ) public static ExpProcedureControlNode Return( Token t, ExpSyntaxNode valueToReturn )
{ {
if( t.Value != ExpKeyword.Return ) { if( t.Value != ExpKeyword.Return ) {
throw new InvalidCastException(); throw new InvalidCastException();
@@ -37,21 +37,21 @@ using System.Threading.Channels;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpRepeatNode : ExpNode public class ExpRepeatNode : ExpSyntaxNode
{ {
private ExpElementInstance _variable; private ExpElementInstance _variable;
private ExpNode _begin, _end, _increment, _operationBegin,_untilRule,_whileRule; private ExpSyntaxNode _begin, _end, _increment, _operationBegin,_untilRule,_whileRule;
internal ExpRepeatNode( internal ExpRepeatNode(
Token source, Token source,
ExpElementInstance variable, ExpElementInstance variable,
ExpNode begin, ExpSyntaxNode begin,
ExpNode end, ExpSyntaxNode end,
ExpNode increment, ExpSyntaxNode increment,
ExpNode operationBegin, ExpSyntaxNode operationBegin,
ExpNode untilRule, ExpSyntaxNode untilRule,
ExpNode whileRule ) ExpSyntaxNode whileRule )
: base( source ) : base( source )
{ {
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag != end.NodeFlag || ( increment != if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag != end.NodeFlag || ( increment !=
@@ -90,13 +90,13 @@ namespace StgSharp.Script.Express
_whileRule = whileRule; _whileRule = whileRule;
} }
public override ExpNode Left => throw new NotImplementedException(); public override ExpSyntaxNode Left => throw new NotImplementedException();
public override ExpNode Right => _operationBegin; public override ExpSyntaxNode Right => _operationBegin;
public override IExpElementSource EqualityTypeConvert => null!; public override IExpElementSource EqualityTypeConvert => null!;
public void AppendRepeatedOperation( ExpNode node ) public void AppendRepeatedOperation( ExpSyntaxNode node )
{ {
_operationBegin.AppendNode( node ); _operationBegin.AppendNode( node );
} }
@@ -126,12 +126,12 @@ namespace StgSharp.Script.Express
public static ExpRepeatNode Create( public static ExpRepeatNode Create(
Token t, Token t,
ExpInstanceReferenceNode repeatVariable, ExpInstanceReferenceNode repeatVariable,
ExpNode begin, ExpSyntaxNode begin,
ExpNode end, ExpSyntaxNode end,
ExpNode increment, ExpSyntaxNode increment,
ExpNode whileRule, ExpSyntaxNode whileRule,
ExpNode untilRule, ExpSyntaxNode untilRule,
ExpNode body ) ExpSyntaxNode body )
{ {
untilRule = ExpBoolNode.False( null ); untilRule = ExpBoolNode.False( null );
whileRule = ExpBoolNode.True( null ); whileRule = ExpBoolNode.True( null );
@@ -163,12 +163,12 @@ namespace StgSharp.Script.Express
public static ExpRepeatNode Create( public static ExpRepeatNode Create(
Token t, Token t,
ExpElementInstance repeatVariable, ExpElementInstance repeatVariable,
ExpNode begin, ExpSyntaxNode begin,
ExpNode end, ExpSyntaxNode end,
ExpNode increment, ExpSyntaxNode increment,
ExpNode whileRule, ExpSyntaxNode whileRule,
ExpNode untilRule, ExpSyntaxNode untilRule,
ExpNode body ) ExpSyntaxNode body )
{ {
whileRule = IsNullOrEmpty( whileRule ) ? ExpBoolNode.True( t ) : whileRule; whileRule = IsNullOrEmpty( whileRule ) ? ExpBoolNode.True( t ) : whileRule;
untilRule = IsNullOrEmpty( untilRule ) ? ExpBoolNode.False( t ) : untilRule; untilRule = IsNullOrEmpty( untilRule ) ? ExpBoolNode.False( t ) : untilRule;
@@ -35,25 +35,26 @@ using System.Text;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpSwitchNode : ExpNode public class ExpSwitchNode : ExpSyntaxNode
{ {
private ExpNode _default; private ExpSyntaxNode _default;
private ExpNode _target; private ExpSyntaxNode _target;
private FrozenDictionary<ExpNode, ExpNode> _cases; private FrozenDictionary<ExpSyntaxNode, ExpSyntaxNode> _cases;
public ExpSwitchNode( public ExpSwitchNode(
Token source, Token source,
ExpNode target, ExpSyntaxNode target,
ExpNode defaultCase, ExpSyntaxNode defaultCase,
params (ExpNode label, ExpNode op)[] cases ) params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases )
: base( source ) : base( source )
{ {
_target = target; _target = target;
_default = defaultCase; _default = defaultCase;
Dictionary<ExpNode, ExpNode> casesDic = new Dictionary<ExpNode, ExpNode>(); Dictionary<ExpSyntaxNode, ExpSyntaxNode> casesDic = new Dictionary<ExpSyntaxNode, ExpSyntaxNode>(
foreach( (ExpNode label, ExpNode op ) item in cases ) );
foreach( (ExpSyntaxNode label, ExpSyntaxNode op ) item in cases )
{ {
if( item.op == null ) if( item.op == null )
{ {
@@ -84,9 +85,9 @@ namespace StgSharp.Script.Express
public ExpSwitchNode( public ExpSwitchNode(
Token source, Token source,
ExpNode target, ExpSyntaxNode target,
ExpNode defaultCase, ExpSyntaxNode defaultCase,
IDictionary<ExpNode, ExpNode> cases ) IDictionary<ExpSyntaxNode, ExpSyntaxNode> cases )
: base( source ) : base( source )
{ {
_target = target; _target = target;
@@ -109,24 +110,24 @@ namespace StgSharp.Script.Express
CodeConvertTemplate = codeFormatBuilder.ToString(); CodeConvertTemplate = codeFormatBuilder.ToString();
} }
public ExpNode this[ ExpNode index ] public ExpSyntaxNode this[ ExpSyntaxNode index ]
{ {
get get
{ {
if( _cases.TryGetValue( index, out ExpNode? ret ) ) { if( _cases.TryGetValue( index, out ExpSyntaxNode? ret ) ) {
return ret; return ret;
} }
return _default; return _default;
} }
} }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => Empty; public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => null!; public override IExpElementSource EqualityTypeConvert => null!;
public bool ContainsCase( ExpNode token ) public bool ContainsCase( ExpSyntaxNode token )
{ {
return _cases.ContainsKey( token ); return _cases.ContainsKey( token );
} }
@@ -36,35 +36,29 @@ using System.Threading.Tasks;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public class ExpUnaryOperatorNode : ExpNode public class ExpUnaryOperatorNode : ExpSyntaxNode
{ {
private ExpNode _operand; private ExpSyntaxNode _operand;
private ExpUnaryOperatorNode( Token source ) : base( source ) { } private ExpUnaryOperatorNode( Token source ) : base( source ) { }
public ExpUnaryOperatorNode( public ExpUnaryOperatorNode( Token source, ExpSyntaxNode operand, ExpSchema context )
Token source,
ExpNode operand,
ExpSchema context )
: base( source ) : base( source )
{ {
_operand = operand; _operand = operand;
} }
public override ExpNode Left => null!; public override ExpSyntaxNode Left => null!;
public override ExpNode Right => _operand; public override ExpSyntaxNode Right => _operand;
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert; public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
public static ExpUnaryOperatorNode UnaryMinus( public static ExpUnaryOperatorNode UnaryMinus( Token source, ExpSyntaxNode operand )
Token source,
ExpNode operand )
{ {
if( !operand.IsNumber ) { if( !operand.IsNumber ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException( "Number", operand.EqualityTypeConvert.Name );
"Number", operand.EqualityTypeConvert.Name );
} }
bool isFloat = bool isFloat =
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; ( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
@@ -75,9 +69,7 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpUnaryOperatorNode UnaryNot( public static ExpUnaryOperatorNode UnaryNot( Token source, ExpSyntaxNode operand )
Token source,
ExpNode operand )
{ {
if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) == if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) ==
0 ) { 0 ) {
@@ -91,13 +83,10 @@ namespace StgSharp.Script.Express
}; };
} }
public static ExpUnaryOperatorNode UnaryPlus( public static ExpUnaryOperatorNode UnaryPlus( Token source, ExpSyntaxNode operand )
Token source,
ExpNode operand )
{ {
if( !operand.IsNumber ) { if( !operand.IsNumber ) {
throw new ExpInvalidTypeException( throw new ExpInvalidTypeException( "Number", operand.EqualityTypeConvert.Name );
"Number", operand.EqualityTypeConvert.Name );
} }
bool isFloat = bool isFloat =
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0; ( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
+16 -16
View File
@@ -39,13 +39,13 @@ using System.Text;
namespace StgSharp.Script.Express namespace StgSharp.Script.Express
{ {
public abstract class ExpNode : IASTNode<ExpNode, IExpElementSource> public abstract class ExpSyntaxNode : ISyntaxNode<ExpSyntaxNode, IExpElementSource>
{ {
protected internal ExpNodeFlag _nodeFlag; protected internal ExpNodeFlag _nodeFlag;
protected internal Token _source; protected internal Token _source;
protected ExpNode( Token source ) protected ExpSyntaxNode( Token source )
{ {
_source = source; _source = source;
Next = this; Next = this;
@@ -57,18 +57,18 @@ namespace StgSharp.Script.Express
get { return ( _nodeFlag | ExpNodeFlag.BuiltinType_Number ) != 0; } get { return ( _nodeFlag | ExpNodeFlag.BuiltinType_Number ) != 0; }
} }
public abstract ExpNode Left { get; } public abstract ExpSyntaxNode Left { get; }
public static ExpNode Empty public static ExpSyntaxNode Empty
{ {
get => ExpEmptyNode._only; get => ExpEmptyNode._only;
} }
public ExpNode Next { get; set; } public ExpSyntaxNode Next { get; set; }
public abstract ExpNode Right { get; } public abstract ExpSyntaxNode Right { get; }
public ExpNode Previous { get; set; } public ExpSyntaxNode Previous { get; set; }
public abstract IExpElementSource EqualityTypeConvert { get; } public abstract IExpElementSource EqualityTypeConvert { get; }
@@ -85,7 +85,7 @@ namespace StgSharp.Script.Express
get => _source; get => _source;
} }
public void AppendNode( ExpNode nextNode ) public void AppendNode( ExpSyntaxNode nextNode )
{ {
Next.Previous = nextNode; Next.Previous = nextNode;
nextNode.Next = Next; nextNode.Next = Next;
@@ -93,24 +93,24 @@ namespace StgSharp.Script.Express
Next.Previous = this; Next.Previous = this;
} }
public static bool IsNullOrEmpty( [AllowNull]ExpNode node ) public static bool IsNullOrEmpty( [AllowNull]ExpSyntaxNode node )
{ {
return node == ExpEmptyNode._only || node == null; return node == ExpEmptyNode._only || node == null;
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpNode NonOperation( Token source ) public static ExpSyntaxNode NonOperation( Token source )
{ {
return new ExpEmptyNode( source.Line, source.Column ); return new ExpEmptyNode( source.Line, source.Column );
} }
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpNode NonOperation( int line, int column ) public static ExpSyntaxNode NonOperation( int line, int column )
{ {
return new ExpEmptyNode( line, column ); return new ExpEmptyNode( line, column );
} }
public void PrependNode( ExpNode previousNode ) public void PrependNode( ExpSyntaxNode previousNode )
{ {
Previous.Next = previousNode; Previous.Next = previousNode;
previousNode.Previous = Previous; previousNode.Previous = Previous;
@@ -118,7 +118,7 @@ namespace StgSharp.Script.Express
previousNode.Next = this; previousNode.Next = this;
} }
public static bool VerifyTypeConvertable( ExpNode left, ExpNode right ) public static bool VerifyTypeConvertable( ExpSyntaxNode left, ExpSyntaxNode right )
{ {
IExpElementSource tLeft = left.EqualityTypeConvert, IExpElementSource tLeft = left.EqualityTypeConvert,
tRight = right.EqualityTypeConvert; tRight = right.EqualityTypeConvert;
@@ -132,7 +132,7 @@ namespace StgSharp.Script.Express
return tLeft.IsConvertable( tRight ); return tLeft.IsConvertable( tRight );
} }
private class ExpEmptyNode : ExpNode private class ExpEmptyNode : ExpSyntaxNode
{ {
internal static readonly ExpEmptyNode _only = new(); internal static readonly ExpEmptyNode _only = new();
@@ -144,9 +144,9 @@ namespace StgSharp.Script.Express
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void; public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;
public override ExpNode Left => _only; public override ExpSyntaxNode Left => _only;
public override ExpNode Right => _only; public override ExpSyntaxNode Right => _only;
} }
@@ -53,7 +53,7 @@ namespace StgSharp.Script.Express
} }
public abstract class ExpElementInstance : ExpNode public abstract class ExpElementInstance : ExpSyntaxNode
{ {
protected ExpElementInstance( Token source ) protected ExpElementInstance( Token source )
@@ -66,9 +66,9 @@ namespace StgSharp.Script.Express
public ExpElementType ElementType { get; } public ExpElementType ElementType { get; }
public override ExpNode Left => Empty; public override ExpSyntaxNode Left => Empty;
public override ExpNode Right => Empty; public override ExpSyntaxNode Right => Empty;
public abstract string TypeName { get; } public abstract string TypeName { get; }
@@ -124,7 +124,7 @@ namespace StgSharp.Script.Express
return false; return false;
} }
public bool TryGetMember( string name, out ExpNode node ) public bool TryGetMember( string name, out ExpSyntaxNode node )
{ {
return EqualityTypeConvert.TryGetMember( name, out node ); return EqualityTypeConvert.TryGetMember( name, out node );
} }
+12 -12
View File
@@ -45,11 +45,11 @@ namespace StgSharp.Script.Express
string Name { get; } string Name { get; }
public void AddMember( string name, ExpNode memberNode ); public void AddMember( string name, ExpSyntaxNode memberNode );
public void Analyse(); public void Analyse();
public bool TryGetMember( string name, out ExpNode memberNode ); public bool TryGetMember( string name, out ExpSyntaxNode memberNode );
} }
@@ -70,14 +70,14 @@ namespace StgSharp.Script.Express
public abstract string Name { get; } public abstract string Name { get; }
public void AddMember( string name, ExpNode memberNode ) public void AddMember( string name, ExpSyntaxNode memberNode )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public abstract void Analyse(); public abstract void Analyse();
public abstract ExpNode CreateInstanceNode( Token t ); public abstract ExpSyntaxNode CreateInstanceNode( Token t );
public bool IsConvertable( IExpElementSource targetType ) public bool IsConvertable( IExpElementSource targetType )
{ {
@@ -92,7 +92,7 @@ namespace StgSharp.Script.Express
return element == null || element == ExpVoidElement.Only; return element == null || element == ExpVoidElement.Only;
} }
public abstract bool TryGetMember( string name, out ExpNode memberNode ); public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode );
private sealed class ExpVoidElement : ExpInstantiableElement private sealed class ExpVoidElement : ExpInstantiableElement
{ {
@@ -112,14 +112,14 @@ namespace StgSharp.Script.Express
return; return;
} }
public override ExpNode CreateInstanceNode( Token t ) public override ExpSyntaxNode CreateInstanceNode( Token t )
{ {
return ExpNode.Empty; return ExpSyntaxNode.Empty;
} }
public override bool TryGetMember( string name, out ExpNode memberNode ) public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
{ {
memberNode = ExpNode.Empty; memberNode = ExpSyntaxNode.Empty;
return false; return false;
} }
@@ -136,7 +136,7 @@ namespace StgSharp.Script.Express
public abstract string Name { get; } public abstract string Name { get; }
public void AddMember( string name, ExpNode memberNode ) public void AddMember( string name, ExpSyntaxNode memberNode )
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -148,9 +148,9 @@ namespace StgSharp.Script.Express
return false; return false;
} }
public abstract ExpNode MakeReference( params object[] options ); public abstract ExpSyntaxNode MakeReference( params object[] options );
public abstract bool TryGetMember( string name, out ExpNode memberNode ); public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode );
} }
} }
+1 -1
View File
@@ -112,7 +112,7 @@ namespace StgSharp.Script.Express
public class ExpCaseNotFoundException : ArgumentOutOfRangeException public class ExpCaseNotFoundException : ArgumentOutOfRangeException
{ {
public ExpCaseNotFoundException( ExpSwitchNode token, ExpNode label ) public ExpCaseNotFoundException( ExpSwitchNode token, ExpSyntaxNode label )
: base( : base(
$"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})" ) { } $"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})" ) { }
@@ -33,6 +33,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
@@ -43,26 +44,40 @@ namespace StgSharp.Script.Express
public static class ExpNodeNextEnumeratorExtensions public static class ExpNodeNextEnumeratorExtensions
{ {
public static ExpNodeNextEnumerator AsCollectionEnumerator( this ExpSyntaxNode token )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( token );
enumerator.AssertEnumeratorCount( count );
IExpElementSource type = token.EqualityTypeConvert;
while( enumerator.MoveNext() )
{
if( enumerator. Current != type ) {
throw new InvalidCastException();
}
}
return enumerator;
}
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl( MethodImplOptions.AggressiveInlining )]
public static ExpNodeNextEnumerator AsEnumerator( this ExpNode token ) public static ExpNodeNextEnumerator ToEnumerator( this ExpSyntaxNode token )
{ {
return new ExpNodeNextEnumerator( token ); return new ExpNodeNextEnumerator( token );
} }
} }
public class ExpNodeNextEnumerator : IEnumerator<ExpNode> public class ExpNodeNextEnumerator : IEnumerator<ExpSyntaxNode>
{ {
private ExpNode _current; private ExpSyntaxNode _current;
private List<ExpNode> _begin = new List<ExpNode>(); private List<ExpSyntaxNode> _begin = new List<ExpSyntaxNode>();
public ExpNodeNextEnumerator( ExpNode token ) public ExpNodeNextEnumerator( ExpSyntaxNode token )
{ {
_begin[ 0 ] = token; _begin[ 0 ] = token;
_current = token; _current = token;
ExpNode t = token; ExpSyntaxNode t = token;
while( !ReferenceEquals( t.Next, token ) && t.Next != null ) while( !ReferenceEquals( t.Next, token ) && t.Next != null )
{ {
t = t.Next; t = t.Next;
@@ -70,7 +85,7 @@ namespace StgSharp.Script.Express
} }
} }
public ExpNode this[ int index ] public ExpSyntaxNode this[ int index ]
{ {
get get
{ {
@@ -80,7 +95,9 @@ namespace StgSharp.Script.Express
} }
} }
public List<ExpNode> Values => _begin; public ExpSyntaxNode Current => _current;
public List<ExpSyntaxNode> Values => _begin;
public void AssertEnumeratorCount( int count ) public void AssertEnumeratorCount( int count )
{ {
@@ -90,14 +107,9 @@ namespace StgSharp.Script.Express
} }
} }
void IDisposable.Dispose() public bool MoveNext()
{ {
return; ExpSyntaxNode next = _current.Next;
}
bool IEnumerator.MoveNext()
{
ExpNode next = _current.Next;
if( ReferenceEquals( next, _begin ) || next == null ) { if( ReferenceEquals( next, _begin ) || next == null ) {
return false; return false;
} }
@@ -105,6 +117,11 @@ namespace StgSharp.Script.Express
return true; return true;
} }
void IDisposable.Dispose()
{
return;
}
void IEnumerator.Reset() void IEnumerator.Reset()
{ {
_current = _begin[ 0 ]; _current = _begin[ 0 ];
@@ -112,7 +129,5 @@ namespace StgSharp.Script.Express
object IEnumerator.Current => _current; object IEnumerator.Current => _current;
ExpNode IEnumerator<ExpNode>.Current => _current;
} }
} }
+168 -141
View File
@@ -50,7 +50,9 @@ namespace StgSharp.Script.Express
private int _current, _lineNum; private int _current, _lineNum;
private IScriptSourceProvider _provider; private IScriptSourceProvider _provider;
private Regex _nextWordTokenPattern = GetNextWordTokenPattern(), private Regex
_nextHashtagSymbolPattern = GetHashtagSymbolPattern() ,
_nextWordTokenPattern = GetNextWordTokenPattern(),
_nextStringLiteralPattern = GetStringLiteralPattern(), _nextStringLiteralPattern = GetStringLiteralPattern(),
_nextNumberLiteralPattern = GetNumberLiteralPattern(), _nextNumberLiteralPattern = GetNumberLiteralPattern(),
_nextStringLiteralPatternWithSingle = GetStringLiteralPatternWithSingle(), _nextStringLiteralPatternWithSingle = GetStringLiteralPatternWithSingle(),
@@ -59,7 +61,7 @@ namespace StgSharp.Script.Express
private string _lineCache; private string _lineCache;
private Token _last; private Token _last;
public ExpSourceReader(IScriptSourceProvider provider) public ExpSourceReader( IScriptSourceProvider provider )
{ {
_provider = provider; _provider = provider;
_current = 0; _current = 0;
@@ -69,7 +71,7 @@ namespace StgSharp.Script.Express
public bool IsEmpty public bool IsEmpty
{ {
get => ((string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length)) && _provider.IsEmpty; get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length ) ) && _provider.IsEmpty;
} }
public int LineNumber public int LineNumber
@@ -79,42 +81,39 @@ namespace StgSharp.Script.Express
public unsafe ReadOnlySpan<char> ReadLine() public unsafe ReadOnlySpan<char> ReadLine()
{ {
bool lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length; bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
while (lineOver || _isReadingMultiLineComment) while( lineOver || _isReadingMultiLineComment )
{
if (IsEmpty)
{ {
if( IsEmpty ) {
return ReadOnlySpan<char>.Empty; return ReadOnlySpan<char>.Empty;
} }
if (lineOver) if( lineOver )
{ {
do do
{ {
_lineCache = _provider.ReadLine(out _lineNum); _lineCache = _provider.ReadLine( out _lineNum );
} while (string.IsNullOrEmpty(_lineCache)); } while (string.IsNullOrEmpty( _lineCache ));
_current = 0; _current = 0;
} }
if (_isReadingMultiLineComment) if( _isReadingMultiLineComment )
{ {
int index; int index;
fixed (char* cPtr = _lineCache.AsSpan(_current)) fixed( char* cPtr = _lineCache.AsSpan( _current ) ) {
{
index = UnsafeCompute.IndexOfCharPair( index = UnsafeCompute.IndexOfCharPair(
cPtr, MultiLineEnd, _lineCache.Length); cPtr, MultiLineEnd, _lineCache.Length );
} }
if (index == -1) if( index == -1 )
{ {
_lineCache = string.Empty; _lineCache = string.Empty;
} } else
else
{ {
_isReadingMultiLineComment = false; _isReadingMultiLineComment = false;
_current += index + 2; _current += index + 2;
} }
} }
lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length; lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
} }
return _lineCache.AsSpan().Slice(_current); return _lineCache.AsSpan().Slice( _current );
} }
public unsafe Token ReadToken() public unsafe Token ReadToken()
@@ -122,84 +121,117 @@ namespace StgSharp.Script.Express
int begin, end, rest; int begin, end, rest;
readLine: readLine:
ReadOnlySpan<char> source; ReadOnlySpan<char> source;
if (!TryReadLine(out source)) if( !TryReadLine( out source ) ) {
{
return Token.Empty; return Token.Empty;
} }
char c = source[0]; char c = source[ 0 ];
if (char.IsLetter(c)) if( char.IsLetter( c ) )
{ {
Match match = _nextWordTokenPattern.Match(_lineCache, _current); Match match = _nextWordTokenPattern.Match( _lineCache, _current );
if (match.Success) if( match.Success )
{ {
begin = match.Groups[TokenMark].Index; begin = match.Groups[ TokenMark ].Index;
end = match.Groups[EndMark].Index; end = match.Groups[ EndMark ].Index;
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
_last = new( _last = new(
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, begin, ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum, begin,
TokenFlag.Member); TokenFlag.Member );
return _last; return _last;
} } else
else
{ {
throw new ExpInvalidCharException(_current); throw new ExpInvalidCharException( _current );
} }
} else if( char.IsPunctuation( c ) || char.IsSymbol( c ) )
{
Match match;
switch( c )
{
case '#':
match = _nextHashtagSymbolPattern.Match( _lineCache, _current );
if( match.Success )
{
begin = match.Groups[ "token" ].Index;
end = match.Groups[ "end" ].Index;
rest = match.Groups[ "rest" ].Index;
_current = rest;
_last = new(
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
begin, TokenFlag.Member );
return _last;
} else
{
throw new ExpInvalidCharException( '#' );
} }
else if (char.IsPunctuation(c) || char.IsSymbol(c))
{
switch (c)
{
case '\'': case '\'':
char cNext = source[ 1 ];
case '"': if( cNext == '\'' ) //empty string
char cNext = source[1];
if (cNext == '\"') //empty string
{ {
begin = _current; begin = _current;
_current += 2; _current += 2;
return new(string.Empty, _lineNum, begin, TokenFlag.String); return new( string.Empty, _lineNum, begin, TokenFlag.String );
} }
Match match = _nextStringLiteralPattern.Match(_lineCache, _current); match = _nextStringLiteralPatternWithSingle.Match( _lineCache, _current );
if (match.Success) if( match.Success )
{ {
begin = match.Groups["token"].Index; begin = match.Groups[ "token" ].Index;
end = match.Groups["end"].Index; end = match.Groups[ "end" ].Index;
rest = match.Groups["rest"].Index; rest = match.Groups[ "rest" ].Index;
_current = rest; _current = rest;
_last = new( _last = new(
ExpressCompile.PoolString(source[1..(end - begin)]), _lineNum, ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
begin, TokenFlag.String); begin, TokenFlag.String );
return _last; return _last;
} } else
else
{ {
throw new ExpInvalidCharException('\"'); throw new ExpInvalidCharException( '\"' );
}
case '"':
cNext = source[ 1 ];
if( cNext == '\"' ) //empty string
{
begin = _current;
_current += 2;
return new( string.Empty, _lineNum, begin, TokenFlag.String );
}
match = _nextStringLiteralPattern.Match( _lineCache, _current );
if( match.Success )
{
begin = match.Groups[ "token" ].Index;
end = match.Groups[ "end" ].Index;
rest = match.Groups[ "rest" ].Index;
_current = rest;
_last = new(
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
begin, TokenFlag.String );
return _last;
} else
{
throw new ExpInvalidCharException( '\"' );
} }
case '(': case '(':
cNext = source[1]; cNext = source[ 1 ];
if (cNext == '*') if( cNext == '*' )
{ {
_isReadingMultiLineComment = true; _isReadingMultiLineComment = true;
_current += 2; _current += 2;
goto readLine; goto readLine;
} } else
else
{ {
begin = _current; begin = _current;
_current++; _current++;
_last = new( _last = new(
ExpressCompile.PoolString(source[..1]), _lineNum, begin, ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
TokenFlag.Separator_Left); TokenFlag.Separator_Left );
return _last; return _last;
} }
case ')' or '}': case ')' or '}':
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.PoolString(source[..1]), _lineNum, begin, ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
TokenFlag.Separator_Right); TokenFlag.Separator_Right );
return _last; return _last;
case '-': case '-':
@@ -207,47 +239,43 @@ namespace StgSharp.Script.Express
// 2. -- comment // 2. -- comment
// 3. - number type param(UNARY) // 3. - number type param(UNARY)
// 4. param - param(BINARY) // 4. param - param(BINARY)
cNext = source[1]; cNext = source[ 1 ];
if (char.IsNumber(cNext)) if( char.IsNumber( cNext ) )
{ {
match = _nextNumberLiteralPattern.Match(_lineCache, _current); match = _nextNumberLiteralPattern.Match( _lineCache, _current );
if (match.Success) if( match.Success )
{ {
begin = match.Groups[TokenMark].Index; begin = match.Groups[ TokenMark ].Index;
end = match.Groups[EndMark].Index; end = match.Groups[ EndMark ].Index;
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
return new( return new(
ExpressCompile.PoolString(source[..(end - begin)]), ExpressCompile.PoolString( source[ ..( end - begin ) ] ),
_lineNum, begin, TokenFlag.Number); _lineNum, begin, TokenFlag.Number );
} } else
else
{ {
throw new ExpInvalidCharException(_current); throw new ExpInvalidCharException( _current );
} }
} } else if( cNext == '-' )
else if (cNext == '-')
{ {
_lineCache = string.Empty; _lineCache = string.Empty;
_current = 0; _current = 0;
goto readLine; goto readLine;
} } else
else
{ {
begin = _current; begin = _current;
_current++; _current++;
if (_last.Flag == TokenFlag.Member || _last.Flag == if( _last.Flag == TokenFlag.Member || _last.Flag ==
TokenFlag.Index_Right || _last.Flag == TokenFlag.Separator_Right) TokenFlag.Index_Right || _last.Flag == TokenFlag.Separator_Right )
{ {
_last = new( _last = new(
ExpressCompile.PoolString(source[..1]), _lineNum, begin, ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
TokenFlag.Symbol_Binary); TokenFlag.Symbol_Binary );
} } else
else
{ {
_last = new( _last = new(
ExpressCompile.PoolString(source[..1]), _lineNum, begin, ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
TokenFlag.Symbol_Unary); TokenFlag.Symbol_Unary );
} }
return _last; return _last;
} }
@@ -255,145 +283,144 @@ namespace StgSharp.Script.Express
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.PoolString("{"), _lineNum, begin, ExpressCompile.PoolString( "{" ), _lineNum, begin,
TokenFlag.Separator_Left); TokenFlag.Separator_Left );
return _last; return _last;
case '[': case '[':
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.PoolString("["), _lineNum, begin, ExpressCompile.PoolString( "[" ), _lineNum, begin,
TokenFlag.Index_Left); TokenFlag.Index_Left );
return _last; return _last;
case ']': case ']':
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.PoolString("]"), _lineNum, begin, ExpressCompile.PoolString( "]" ), _lineNum, begin,
TokenFlag.Index_Right); TokenFlag.Index_Right );
return _last; return _last;
case ';' or ',': case ';' or ',':
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.PoolString(source[..1]), _lineNum, begin, ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
TokenFlag.Separator_Middle); TokenFlag.Separator_Middle );
return _last; return _last;
case ':': case ':':
match = _nextSymbolPattern.Match(_lineCache, _current); match = _nextSymbolPattern.Match( _lineCache, _current );
begin = match.Groups[TokenMark].Index; begin = match.Groups[ TokenMark ].Index;
end = match.Groups[EndMark].Index; end = match.Groups[ EndMark ].Index;
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
if (end - begin == 1) if( end - begin == 1 )
{ {
_last = new Token( _last = new Token(
ExpressCompile.Keyword.Colon, _lineNum, begin, ExpressCompile.Keyword.Colon, _lineNum, begin,
TokenFlag.Separator_Middle); TokenFlag.Separator_Middle );
} } else
else
{ {
_last = new Token( _last = new Token(
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum,
begin, TokenFlag.Symbol_Binary); begin, TokenFlag.Symbol_Binary );
} }
return _last; return _last;
case '+' or '/' or '\\' or '*' or '.': case '+' or '/' or '\\' or '*' or '.':
match = _nextSymbolPattern.Match(_lineCache, _current); match = _nextSymbolPattern.Match( _lineCache, _current );
begin = match.Groups[TokenMark].Index; begin = match.Groups[ TokenMark ].Index;
end = match.Groups[EndMark].Index; end = match.Groups[ EndMark ].Index;
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
_last = new Token( _last = new Token(
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum,
begin, TokenFlag.Symbol_Binary); begin, TokenFlag.Symbol_Binary );
return _last; return _last;
case '=': case '=':
begin = _current; begin = _current;
_current++; _current++;
_last = new Token( _last = new Token(
ExpressCompile.Keyword.Equal, _lineNum, begin, ExpressCompile.Keyword.Equal, _lineNum, begin,
TokenFlag.Symbol_Binary); TokenFlag.Symbol_Binary );
return _last; return _last;
default: default:
throw new ExpInvalidCharException(c); throw new ExpInvalidCharException( c );
} }
} } else if( char.IsNumber( c ) )
else if (char.IsNumber(c))
{ {
Match match = _nextNumberLiteralPattern.Match(_lineCache, _current); Match match = _nextNumberLiteralPattern.Match( _lineCache, _current );
if (match.Success) if( match.Success )
{ {
begin = match.Groups[TokenMark].Index; begin = match.Groups[ TokenMark ].Index;
end = match.Groups[EndMark].Index; end = match.Groups[ EndMark ].Index;
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
string str = ExpressCompile.PoolString(source[..(end - begin)]); string str = ExpressCompile.PoolString( source[ ..( end - begin ) ] );
return new(str, _lineNum, begin, TokenFlag.Number); return new( str, _lineNum, begin, TokenFlag.Number );
} } else
else
{ {
throw new ExpInvalidCharException(_current); throw new ExpInvalidCharException( _current );
} }
} } else if( char.IsWhiteSpace( c ) )
else if (char.IsWhiteSpace(c))
{ {
Match match = _skipBlankPattern.Match(_lineCache, _current); Match match = _skipBlankPattern.Match( _lineCache, _current );
if (match.Success) if( match.Success )
{ {
rest = match.Groups[RestMark].Index; rest = match.Groups[ RestMark ].Index;
_current = rest; _current = rest;
goto readLine; goto readLine;
} } else
else
{ {
throw new ExpInvalidCharException(_current); throw new ExpInvalidCharException( _current );
} }
} } else
else
{ {
throw new ExpInvalidCharException(c); throw new ExpInvalidCharException( c );
} }
} }
public bool TryReadLine(out ReadOnlySpan<char> line) public bool TryReadLine( out ReadOnlySpan<char> line )
{ {
line = ReadLine(); line = ReadLine();
return line != ReadOnlySpan<char>.Empty; return line != ReadOnlySpan<char>.Empty;
} }
public bool TryReadToken(out Token t) public bool TryReadToken( out Token t )
{ {
t = ReadToken(); t = ReadToken();
return !IsEmpty; return !IsEmpty;
} }
[GeneratedRegex(
@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)",
RegexOptions.Singleline )]
private static partial Regex GetHashtagSymbolPattern();
[GeneratedRegex( [GeneratedRegex(
@"(?<token>[a-zA-Z][a-zA-Z0-9_]*)(?<end>\s*?)(?<rest>\S|$)", @"(?<token>[a-zA-Z][a-zA-Z0-9_]*)(?<end>\s*?)(?<rest>\S|$)",
RegexOptions.Singleline)] RegexOptions.Singleline )]
private static partial Regex GetNextWordTokenPattern(); private static partial Regex GetNextWordTokenPattern();
[GeneratedRegex( [GeneratedRegex(
@"(?<token>-?\s*?[0-9]+(?:\.[0-9]*)?E?(?:[+-]?[0-9]+)?)(?<end>\s*?)(?<rest>\S|$)", @"(?<token>-?\s*?[0-9]+(?:\.[0-9]*)?E?(?:[+-]?[0-9]+)?)(?<end>\s*?)(?<rest>\S|$)",
RegexOptions.Singleline)] RegexOptions.Singleline )]
private static partial Regex GetNumberLiteralPattern(); private static partial Regex GetNumberLiteralPattern();
[GeneratedRegex(@"(?:\s+?)(?<rest>\S|$)", RegexOptions.Singleline)] [GeneratedRegex( @"(?:\s+?)(?<rest>\S|$)", RegexOptions.Singleline )]
private static partial Regex GetSkipBlankPattern(); private static partial Regex GetSkipBlankPattern();
[GeneratedRegex( [GeneratedRegex(
@"(?<token>"")(?>\\\\|\\""|(?!')[^""])*(?<end>""|$)\s*?(?<rest>\S|$)", @"(?<token>"")(?>\\\\|\\""|(?!')[^""])*(?<end>""|$)\s*?(?<rest>\S|$)",
RegexOptions.Singleline)] RegexOptions.Singleline )]
private static partial Regex GetStringLiteralPattern(); private static partial Regex GetStringLiteralPattern();
[GeneratedRegex( [GeneratedRegex(
@"(?<token>')(?>\\\\|\\'|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)", @"(?<token>')(?>\\\\|\\'|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)",
RegexOptions.Singleline)] RegexOptions.Singleline )]
private static partial Regex GetStringLiteralPatternWithSingle(); private static partial Regex GetStringLiteralPatternWithSingle();
[GeneratedRegex( [GeneratedRegex(
@"(?<token>[:<>=+\-*\/]+)(?<end>\s?)\s*?(?<rest>\S|$)", @"(?<token>[:<>=+\-*\/]+)(?<end>\s?)\s*?(?<rest>\S|$)",
RegexOptions.Singleline)] RegexOptions.Singleline )]
private static partial Regex GetSymbolPattern(); private static partial Regex GetSymbolPattern();
} }
@@ -45,7 +45,7 @@ namespace StgSharp.Script.Express
private bool AppendToken_CaseOf( Token t ) private bool AppendToken_CaseOf( Token t )
{ {
Token op; Token op;
ExpNode root; ExpSyntaxNode root;
switch( t.Value ) switch( t.Value )
{ {
case ExpKeyword.Case: case ExpKeyword.Case:
@@ -108,19 +108,20 @@ namespace StgSharp.Script.Express
Begin = t; Begin = t;
} }
public Dictionary<ExpNode, ExpNode> Cases { get; } = new Dictionary<ExpNode, ExpNode>(); public Dictionary<ExpSyntaxNode, ExpSyntaxNode> Cases { get; } = new Dictionary<ExpSyntaxNode, ExpSyntaxNode>(
);
public ExpNode CaseExpression { get; set; } public ExpSyntaxNode CaseExpression { get; set; }
public ExpNode DefaultCase { get; set; } public ExpSyntaxNode DefaultCase { get; set; }
public ExpNode CurrentCase { get; set; } public ExpSyntaxNode CurrentCase { get; set; }
public string CurrentState { get; set; } public string CurrentState { get; set; }
public Token Begin { get; init; } public Token Begin { get; init; }
public void CloseCurrentCase( ExpNode root ) public void CloseCurrentCase( ExpSyntaxNode root )
{ {
Cases.Add( CurrentCase, root ); Cases.Add( CurrentCase, root );
} }
@@ -62,7 +62,7 @@ namespace StgSharp.Script.Express
if( t.Flag != TokenFlag.Index_Left ) { if( t.Flag != TokenFlag.Index_Left ) {
return false; return false;
} }
if( _cache.TryPeekOperand( out bool isNode, out _, out ExpNode? node ) ) if( _cache.TryPeekOperand( out bool isNode, out _, out ExpSyntaxNode? node ) )
{ {
if( node.EqualityTypeConvert is not ExpCollectionBase ) { if( node.EqualityTypeConvert is not ExpCollectionBase ) {
ExpInvalidSyntaxException.ThrowNonCollectionIndex( t ); ExpInvalidSyntaxException.ThrowNonCollectionIndex( t );
@@ -83,8 +83,8 @@ namespace StgSharp.Script.Express
ClosePrefixReverse( t ); ClosePrefixReverse( t );
//make index node //make index node
_cache.PopOperand( out _, out ExpNode? expNode ); _cache.PopOperand( out _, out ExpSyntaxNode? expNode );
if( !_cache.PopOperand( out Token colleToken, out ExpNode? colleNode ) ) { } if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { }
_cache.PushOperand( _cache.PushOperand(
ExpCollectionIndexNode.Create( ExpCollectionIndexNode.Create(
t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) ); t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) );
@@ -126,7 +126,7 @@ namespace StgSharp.Script.Express
while( _cache.OperatorAheadOfDepth > 0 ) while( _cache.OperatorAheadOfDepth > 0 )
{ {
_cache.TryPopOperator( out Token op ); _cache.TryPopOperator( out Token op );
ExpNode node = ConvertAndPushOneOperator( op ); ExpSyntaxNode node = ConvertAndPushOneOperator( op );
} }
switch( _cache.OperandAheadOfDepth ) switch( _cache.OperandAheadOfDepth )
{ {
@@ -134,10 +134,10 @@ namespace StgSharp.Script.Express
if( t.Value == ";" ) { if( t.Value == ";" ) {
return true; return true;
} }
_cache.StatementsInDepth.Push( ExpNode.Empty ); _cache.StatementsInDepth.Push( ExpSyntaxNode.Empty );
goto case 1; goto case 1;
case 1: case 1:
_cache.PopOperand( out _, out ExpNode? statement ); _cache.PopOperand( out _, out ExpSyntaxNode? statement );
_cache.StatementsInDepth.Push( statement ); _cache.StatementsInDepth.Push( statement );
return true; return true;
default: default:
@@ -189,7 +189,7 @@ namespace StgSharp.Script.Express
if( cmp >= 0 ) if( cmp >= 0 )
{ {
_cache.PopOperator(); _cache.PopOperator();
ExpNode node = ConvertAndPushOneOperator( tmp ); ExpSyntaxNode node = ConvertAndPushOneOperator( tmp );
goto processPrecedence; goto processPrecedence;
} }
} }
@@ -249,7 +249,7 @@ namespace StgSharp.Script.Express
private bool TryParseInstance( Token t ) private bool TryParseInstance( Token t )
{ {
if( _local.TryGetMember( t.Value, if( _local.TryGetMember( t.Value,
out ExpNode? node ) && node is ExpElementInstance instance ) out ExpSyntaxNode? node ) && node is ExpElementInstance instance )
{ {
_cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) ); _cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) );
return true; return true;
@@ -260,7 +260,7 @@ namespace StgSharp.Script.Express
} else if( _cache.IsLastAddedOperator ) } else if( _cache.IsLastAddedOperator )
{ {
if( _cache.PeekOperand( out _, if( _cache.PeekOperand( out _,
out ExpNode? typenode ) && typenode is ExpMetaRefNode typeRef ) out ExpSyntaxNode? typenode ) && typenode is ExpMetaRefNode typeRef )
{ {
_cache.PopOperand( out _, out _ ); _cache.PopOperand( out _, out _ );
_local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) ); _local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) );
@@ -58,7 +58,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? node ); _cache.PopOperand( out _, out ExpSyntaxNode? node );
state.CurrentState = t.Value; state.CurrentState = t.Value;
state.BoolExpression = node; state.BoolExpression = node;
} else } else
@@ -71,7 +71,7 @@ namespace StgSharp.Script.Express
state = _cache.StateOfCurrentDepth<IfBranchStateCache>(); state = _cache.StateOfCurrentDepth<IfBranchStateCache>();
if( state.CurrentState == ExpKeyword.Then ) if( state.CurrentState == ExpKeyword.Then )
{ {
ExpNode node = _cache.PackAllStatements(); ExpSyntaxNode node = _cache.PackAllStatements();
state.CurrentState = t.Value; state.CurrentState = t.Value;
state.ExpressionIfTrue = node; state.ExpressionIfTrue = node;
} else } else
@@ -85,13 +85,13 @@ namespace StgSharp.Script.Express
state = _cache.StateOfCurrentDepth<IfBranchStateCache>(); state = _cache.StateOfCurrentDepth<IfBranchStateCache>();
if( state.CurrentState == ExpKeyword.Then ) if( state.CurrentState == ExpKeyword.Then )
{ {
ExpNode trueNode = _cache.PackAllStatements(); ExpSyntaxNode trueNode = _cache.PackAllStatements();
state.CurrentState = t.Value; state.CurrentState = t.Value;
state.ExpressionIfTrue = trueNode; state.ExpressionIfTrue = trueNode;
state.ExpressionIfFalse = ExpNode.Empty; state.ExpressionIfFalse = ExpSyntaxNode.Empty;
} else if( state.CurrentState == ExpKeyword.Else ) } else if( state.CurrentState == ExpKeyword.Else )
{ {
ExpNode falseNode = _cache.PackAllStatements(); ExpSyntaxNode falseNode = _cache.PackAllStatements();
state.CurrentState = t.Value; state.CurrentState = t.Value;
state.ExpressionIfFalse = falseNode; state.ExpressionIfFalse = falseNode;
} else } else
@@ -115,11 +115,11 @@ namespace StgSharp.Script.Express
private class IfBranchStateCache : ICompileDepthState private class IfBranchStateCache : ICompileDepthState
{ {
public ExpNode BoolExpression { get; set; } public ExpSyntaxNode BoolExpression { get; set; }
public ExpNode ExpressionIfTrue { get; set; } public ExpSyntaxNode ExpressionIfTrue { get; set; }
public ExpNode ExpressionIfFalse { get; set; } public ExpSyntaxNode ExpressionIfFalse { get; set; }
public string CurrentState { get; set; } public string CurrentState { get; set; }
@@ -48,9 +48,9 @@ namespace StgSharp.Script.Express
return leftPrecedence - rightPrecedence; return leftPrecedence - rightPrecedence;
} }
public bool TryGenerateUnaryNode( Token t, out ExpNode node ) public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node )
{ {
ExpNode operand = GetNextOperandCache(); ExpSyntaxNode operand = GetNextOperandCache();
switch( t.Value ) switch( t.Value )
{ {
case ExpKeyword.UnaryPlus: case ExpKeyword.UnaryPlus:
@@ -63,7 +63,7 @@ namespace StgSharp.Script.Express
node = ExpUnaryOperatorNode.UnaryNot( t, operand ); node = ExpUnaryOperatorNode.UnaryNot( t, operand );
return true; return true;
default: default:
node = ExpNode.Empty; node = ExpSyntaxNode.Empty;
return false; return false;
} }
} }
@@ -72,12 +72,12 @@ namespace StgSharp.Script.Express
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING /// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS. /// SYMBOLS.
/// </summary> /// </summary>
private ExpNode ConvertAndPushOneOperator( Token op ) private ExpSyntaxNode ConvertAndPushOneOperator( Token op )
{ {
switch( op.Flag ) switch( op.Flag )
{ {
case TokenFlag.Symbol_Unary: case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( op, out ExpNode? node ); TryGenerateUnaryNode( op, out ExpSyntaxNode? node );
_cache.PushOperand( node ); _cache.PushOperand( node );
return node; return node;
case TokenFlag.Symbol_Binary: case TokenFlag.Symbol_Binary:
@@ -87,7 +87,7 @@ namespace StgSharp.Script.Express
case TokenFlag.Member: case TokenFlag.Member:
if( _context.TryGetFunction( op.Value, out ExpFunctionSource? f ) ) if( _context.TryGetFunction( op.Value, out ExpFunctionSource? f ) )
{ {
if( !_cache.PopOperand( out Token t, out ExpNode? p ) ) if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? p ) )
{ {
node = ExpFunctionCallingNode.CallFunction( op, f, p ); node = ExpFunctionCallingNode.CallFunction( op, f, p );
return node; return node;
@@ -99,7 +99,7 @@ namespace StgSharp.Script.Express
} }
} else if( _context.TryGetProcedure( op.Value, out ExpProcedureSource? p ) ) } else if( _context.TryGetProcedure( op.Value, out ExpProcedureSource? p ) )
{ {
if( !_cache.PopOperand( out Token t, out ExpNode? param ) ) if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) )
{ {
node = ExpProcedureCallingNode.CallProcedure( op, p, param ); node = ExpProcedureCallingNode.CallProcedure( op, p, param );
return node; return node;
@@ -111,7 +111,7 @@ namespace StgSharp.Script.Express
} }
} else if( ExpSchema.BuiltinSchema.TryGetFunction( op.Value, out f ) ) } else if( ExpSchema.BuiltinSchema.TryGetFunction( op.Value, out f ) )
{ {
if( !_cache.PopOperand( out Token t, out ExpNode? param ) ) if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) )
{ {
node = ExpFunctionCallingNode.CallFunction( op, f, param ); node = ExpFunctionCallingNode.CallFunction( op, f, param );
return node; return node;
@@ -132,10 +132,10 @@ namespace StgSharp.Script.Express
} }
} }
private bool TryGenerateBinaryNode( Token t, out ExpNode node ) private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node )
{ {
ExpNode right = GetNextOperandCache(); ExpSyntaxNode right = GetNextOperandCache();
ExpNode left = GetNextOperandCache(); ExpSyntaxNode left = GetNextOperandCache();
switch( t.Value ) switch( t.Value )
{ {
case ExpKeyword.Add: case ExpKeyword.Add:
@@ -172,7 +172,7 @@ namespace StgSharp.Script.Express
node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right ); node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right );
return true; return true;
default: default:
node = ExpNode.Empty; node = ExpSyntaxNode.Empty;
return false; return false;
} }
} }
@@ -45,12 +45,12 @@ namespace StgSharp.Script.Express
private void ClosePrefixReverse( Token rightSeparator ) private void ClosePrefixReverse( Token rightSeparator )
{ {
Token op; Token op;
ExpNode root; ExpSyntaxNode root;
if( _cache.OperatorAheadOfDepth == 0 ) if( _cache.OperatorAheadOfDepth == 0 )
{ {
if( _cache.OperandAheadOfDepth == 1 ) if( _cache.OperandAheadOfDepth == 1 )
{ {
_cache.PopOperand( out _, out ExpNode? statement ); _cache.PopOperand( out _, out ExpSyntaxNode? statement );
_cache.StatementsInDepth.Push( statement ); _cache.StatementsInDepth.Push( statement );
} else } else
{ {
@@ -84,7 +84,7 @@ namespace StgSharp.Script.Express
AppendToken_common( t ); AppendToken_common( t );
return false; return false;
} }
ExpNode root = _cache.PackAllStatements(); ExpSyntaxNode root = _cache.PackAllStatements();
state.Body = root; state.Body = root;
_cache.DecreaseDepth(); _cache.DecreaseDepth();
if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) ) if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) )
@@ -114,7 +114,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? root ); _cache.PopOperand( out _, out ExpSyntaxNode? root );
state.Begin = root; state.Begin = root;
return true; return true;
default: default:
@@ -143,7 +143,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? root ); _cache.PopOperand( out _, out ExpSyntaxNode? root );
state.End = root; state.End = root;
return true; return true;
} }
@@ -168,7 +168,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? root ); _cache.PopOperand( out _, out ExpSyntaxNode? root );
state.StepIncrement = root; state.StepIncrement = root;
return true; return true;
} }
@@ -187,7 +187,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? root ); _cache.PopOperand( out _, out ExpSyntaxNode? root );
state.UntilExpression = root; state.UntilExpression = root;
return true; return true;
} }
@@ -210,7 +210,7 @@ namespace StgSharp.Script.Express
if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) ) if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) )
{ {
if( ( _local.TryGetMember( t.Value, if( ( _local.TryGetMember( t.Value,
out ExpNode? node ) && node is ExpElementInstance instance ) || _tempVariableInLoops.TryGetValue( out ExpSyntaxNode? node ) && node is ExpElementInstance instance ) || _tempVariableInLoops.TryGetValue(
t.Value, out instance ) ) t.Value, out instance ) )
{ {
state.IncrementVariable = ExpInstanceReferenceNode.MakeReferenceFrom( state.IncrementVariable = ExpInstanceReferenceNode.MakeReferenceFrom(
@@ -247,7 +247,7 @@ namespace StgSharp.Script.Express
while( _cache.TryPopOperator( out Token op ) ) { while( _cache.TryPopOperator( out Token op ) ) {
ConvertAndPushOneOperator( op ); ConvertAndPushOneOperator( op );
} }
_cache.PopOperand( out _, out ExpNode? root ); _cache.PopOperand( out _, out ExpSyntaxNode? root );
state.WhileExpression = root; state.WhileExpression = root;
return true; return true;
} }
@@ -258,23 +258,23 @@ namespace StgSharp.Script.Express
public RepeatLoopState( Token t ) public RepeatLoopState( Token t )
{ {
Position = t; Position = t;
UntilExpression = ExpNode.Empty; UntilExpression = ExpSyntaxNode.Empty;
WhileExpression = ExpNode.Empty; WhileExpression = ExpSyntaxNode.Empty;
} }
public ExpInstanceReferenceNode IncrementVariable { get; set; } public ExpInstanceReferenceNode IncrementVariable { get; set; }
public ExpNode StepIncrement { get; set; } public ExpSyntaxNode StepIncrement { get; set; }
public ExpNode Begin { get; set; } public ExpSyntaxNode Begin { get; set; }
public ExpNode End { get; set; } public ExpSyntaxNode End { get; set; }
public ExpNode UntilExpression { get; set; } public ExpSyntaxNode UntilExpression { get; set; }
public ExpNode WhileExpression { get; set; } public ExpSyntaxNode WhileExpression { get; set; }
public ExpNode Body { get; set; } public ExpSyntaxNode Body { get; set; }
public ExpTypeSource IncrementVariableType { get; set; } public ExpTypeSource IncrementVariableType { get; set; }
+6 -6
View File
@@ -51,19 +51,19 @@ namespace StgSharp.Script.Express
private const int TokenGenerated = 0; private const int TokenGenerated = 0;
private const int TokenTypeNotMatch = -1; private const int TokenTypeNotMatch = -1;
private CompileStack<ExpNode, IExpElementSource> _cache; private CompileStack<ExpSyntaxNode, IExpElementSource> _cache;
private ExpNode _lastStatement;
private ExpSchema _context; private ExpSchema _context;
private ExpSyntaxNode _lastStatement;
private IExpElementSource _local; private IExpElementSource _local;
public ExpSyntaxAnalyzer() public ExpSyntaxAnalyzer()
{ {
_cache = new CompileStack<ExpNode, IExpElementSource>(); _cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
} }
public ExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local ) public ExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local )
{ {
_cache = new CompileStack<ExpNode, IExpElementSource>(); _cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
ArgumentNullException.ThrowIfNull( context ); ArgumentNullException.ThrowIfNull( context );
if( context is not ExpSchema_Builtin ) if( context is not ExpSchema_Builtin )
{ {
@@ -95,9 +95,9 @@ namespace StgSharp.Script.Express
} }
} }
public ExpNode GetNextOperandCache() public ExpSyntaxNode GetNextOperandCache()
{ {
if( _cache.PopOperand( out Token t, out ExpNode? n ) ) if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) )
{ {
return n; return n;
} else } else
+1 -1
View File
@@ -39,7 +39,7 @@ namespace StgSharp.Script.Express
public interface IExpMarshalType<TSelf> public interface IExpMarshalType<TSelf>
{ {
static abstract TSelf Create( string name, ExpNode node ); static abstract TSelf Create( string name, ExpSyntaxNode node );
} }
} }
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -103,7 +102,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
-1
View File
@@ -1255,7 +1255,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9457309c5ab188ce824a10ab60e572553986b6eb")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} {"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90/*"}}
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -414,7 +414,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.TerminalDialogue")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.TerminalDialogue")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+148b0fed4a1abaaeaa3a28e7c7b088590805ebef")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.TerminalDialogue")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.TerminalDialogue")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.TerminalDialogue")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.TerminalDialogue")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -27,7 +27,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -103,7 +102,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -176,7 +174,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -256,7 +253,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
-1
View File
@@ -1294,7 +1294,6 @@
"sources": { "sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {}, "C:\\Program Files\\dotnet\\library-packs": {},
"D:\\Programmer\\NugetLocal": {},
"https://api.nuget.org/v3/index.json": {} "https://api.nuget.org/v3/index.json": {}
}, },
"frameworks": { "frameworks": {
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]