daily update on 20250210 by nitload youmu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51")]
|
||||||
[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")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
@@ -17,14 +17,14 @@ int index_pair_sse(short const *str, uint32_t target, int length)
|
|||||||
com = _mm_cmpeq_epi16(vec, s_even);
|
com = _mm_cmpeq_epi16(vec, s_even);
|
||||||
result = _mm_movemask_epi8(com);
|
result = _mm_movemask_epi8(com);
|
||||||
if (result) {
|
if (result) {
|
||||||
for (size_t i = 0; i < 12; i++) {
|
for (size_t i = 0; i < 7; i++) {
|
||||||
result >>= 2;
|
|
||||||
if (((result & 0xF) == 0xF)) {
|
if (((result & 0xF) == 0xF)) {
|
||||||
return index + i;
|
return index + i;
|
||||||
}
|
}
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
result >>= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index += 1;
|
index += 1;
|
||||||
@@ -32,14 +32,14 @@ int index_pair_sse(short const *str, uint32_t target, int length)
|
|||||||
com = _mm_cmpeq_epi16(vec, s_even);
|
com = _mm_cmpeq_epi16(vec, s_even);
|
||||||
result = _mm_movemask_epi8(com);
|
result = _mm_movemask_epi8(com);
|
||||||
if (result) {
|
if (result) {
|
||||||
for (size_t i = 0; i < 12; i++) {
|
for (size_t i = 0; i < 7; i++) {
|
||||||
result >>= 2;
|
|
||||||
if (((result & 0xF) == 0xF)) {
|
if (((result & 0xF) == 0xF)) {
|
||||||
return index + i;
|
return index + i;
|
||||||
}
|
}
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
result >>= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index += 7;
|
index += 7;
|
||||||
|
|||||||
@@ -39,23 +39,23 @@ namespace StgSharp.Commom.Collections
|
|||||||
internal class CapacityFixedList<T> : IList<T>
|
internal class CapacityFixedList<T> : IList<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
private T[] values;
|
private T[] _values;
|
||||||
private int capacity, _index;
|
private int capacity, _index;
|
||||||
|
|
||||||
public CapacityFixedList( int size )
|
public CapacityFixedList( int size )
|
||||||
{
|
{
|
||||||
values = new T[size];
|
_values = new T[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
public T this[ int index ]
|
public T this[ int index ]
|
||||||
{
|
{
|
||||||
get => index < _index ?
|
get => index < _index ?
|
||||||
values[ index ] : throw new ArgumentOutOfRangeException(
|
_values[ index ] : throw new ArgumentOutOfRangeException(
|
||||||
nameof( index ) );
|
nameof( index ) );
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if( index < _index ) {
|
if( index < _index ) {
|
||||||
values[ index ] = value;
|
_values[ index ] = value;
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentOutOfRangeException( nameof( index ) );
|
throw new ArgumentOutOfRangeException( nameof( index ) );
|
||||||
}
|
}
|
||||||
@@ -76,14 +76,14 @@ namespace StgSharp.Commom.Collections
|
|||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
values = new T[capacity];
|
_values = new T[capacity];
|
||||||
_index = 0;
|
_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains( T item )
|
public bool Contains( T item )
|
||||||
{
|
{
|
||||||
for( int i = 0; i <= _index; i++ ) {
|
for( int i = 0; i <= _index; i++ ) {
|
||||||
if( item.Equals( values[ i ] ) ) {
|
if( item.Equals( _values[ i ] ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,13 +92,13 @@ namespace StgSharp.Commom.Collections
|
|||||||
|
|
||||||
public void CopyTo( T[] array, int arrayIndex )
|
public void CopyTo( T[] array, int arrayIndex )
|
||||||
{
|
{
|
||||||
values.CopyTo( array, arrayIndex );
|
_values.CopyTo( array, arrayIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
for( int i = 0; i <= _index; i++ ) {
|
for( int i = 0; i <= _index; i++ ) {
|
||||||
yield return values[ i ];
|
yield return _values[ i ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ namespace StgSharp.Commom.Collections
|
|||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
for( int i = 0; i <= _index; i++ ) {
|
for( int i = 0; i <= _index; i++ ) {
|
||||||
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
|
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,8 +117,8 @@ namespace StgSharp.Commom.Collections
|
|||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
for( int i = 0; i <= _index; i++ ) {
|
for( int i = 0; i <= _index; i++ ) {
|
||||||
if( ( v = values[ i ] ) != null && v.Equals( item ) ) {
|
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
|
||||||
values[ i ] = values[ _index ];
|
_values[ i ] = _values[ _index ];
|
||||||
_index--;
|
_index--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -129,8 +129,8 @@ namespace StgSharp.Commom.Collections
|
|||||||
public void RemoveAll( Predicate<T> predicate )
|
public void RemoveAll( Predicate<T> predicate )
|
||||||
{
|
{
|
||||||
for( int i = _index; i > 0; i-- ) {
|
for( int i = _index; i > 0; i-- ) {
|
||||||
if( predicate( values[ i ] ) ) {
|
if( predicate( _values[ i ] ) ) {
|
||||||
values[ i ] = values[ _index ];
|
_values[ i ] = _values[ _index ];
|
||||||
_index--;
|
_index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,14 +139,14 @@ namespace StgSharp.Commom.Collections
|
|||||||
public void RemoveAt( int index )
|
public void RemoveAt( int index )
|
||||||
{
|
{
|
||||||
if( index <= _index ) {
|
if( index <= _index ) {
|
||||||
values[ index ] = values[ _index ];
|
_values[ index ] = _values[ _index ];
|
||||||
_index--;
|
_index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resize( int newSize )
|
public void Resize( int newSize )
|
||||||
{
|
{
|
||||||
Array.Resize( ref values, newSize );
|
Array.Resize( ref _values, newSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp.Collections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Part of a collection. This contains a direct reference to origin collection,
|
||||||
|
/// so all change to origin collection will be reflected in this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public class ReferencedSlicedCollection<T> : ICollection<T>
|
||||||
|
{
|
||||||
|
private ICollection<T> _collection;
|
||||||
|
private int _begin;
|
||||||
|
private int _length;
|
||||||
|
|
||||||
|
internal ReferencedSlicedCollection()
|
||||||
|
{
|
||||||
|
_collection = Array.Empty<T>();
|
||||||
|
_begin = 0;
|
||||||
|
_length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferencedSlicedCollection(ICollection<T> collection, int begin, int length)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(collection);
|
||||||
|
ArgumentOutOfRangeException.ThrowIfLessThan(begin, 0);
|
||||||
|
ArgumentOutOfRangeException.ThrowIfLessThan(length, 0);
|
||||||
|
ArgumentOutOfRangeException.ThrowIfLessThan(begin + length, collection.Count);
|
||||||
|
_collection = collection;
|
||||||
|
_begin = begin;
|
||||||
|
_length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count => _length;
|
||||||
|
|
||||||
|
public bool IsReadOnly => true;
|
||||||
|
|
||||||
|
void ICollection<T>.Add(T item)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(T item)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(T[] array, int arrayIndex)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<T> GetEnumerator()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(T item)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,16 @@ namespace StgSharp.Intrinsic
|
|||||||
return InternalIO.Intrinsic.index_pair(source, pairValue, length);
|
return InternalIO.Intrinsic.index_pair(source, pairValue, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static unsafe int CityHashSimplify(char* span, int length)
|
||||||
|
{
|
||||||
|
return InternalIO.Intrinsic.city_hash_simplify(span,length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static unsafe int CityHashSimplify(char* span, int begin, int length)
|
||||||
|
{
|
||||||
|
return InternalIO.Intrinsic.city_hash_simplify(span + begin, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="CancellableTask.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.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp.Threading
|
||||||
|
{
|
||||||
|
public class CancellableTask:IDisposable
|
||||||
|
{
|
||||||
|
private protected Action<CancellationToken> _startup;
|
||||||
|
private protected Task _internalTask;
|
||||||
|
private CancellationTokenSource cts;
|
||||||
|
private bool disposedValue;
|
||||||
|
|
||||||
|
private protected CancellableTask()
|
||||||
|
{
|
||||||
|
cts = new CancellationTokenSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
private protected CancellableTask( Action<CancellationToken> action )
|
||||||
|
{
|
||||||
|
_internalTask = new Task( InternalAction );
|
||||||
|
cts = new CancellationTokenSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsCompleted
|
||||||
|
{
|
||||||
|
get => _internalTask.IsCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CancellationTokenSource Cts
|
||||||
|
{
|
||||||
|
get => cts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get => _internalTask.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
Cts.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelAndWait()
|
||||||
|
{
|
||||||
|
Cts.Cancel();
|
||||||
|
_internalTask.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CancellableTask Run( Action<CancellationToken> startup )
|
||||||
|
{
|
||||||
|
CancellableTask ret = new CancellableTask { _startup = startup };
|
||||||
|
ret._internalTask = Task.Run( ret.InternalAction );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Wait()
|
||||||
|
{
|
||||||
|
_internalTask.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WaitAll( IEnumerable<CancellableTask> tasks )
|
||||||
|
{
|
||||||
|
IEnumerable<Task> convertedTasks = tasks.Select<CancellableTask, Task>(
|
||||||
|
ct => ct._internalTask );
|
||||||
|
Task.WaitAll( convertedTasks.ToArray() );
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||||
|
internal void InternalAction()
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"Task {Task.CurrentId} is running.");
|
||||||
|
_startup( Cts.Token );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Task( CancellableTask task )
|
||||||
|
{
|
||||||
|
return task._internalTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
~CancellableTask()
|
||||||
|
{
|
||||||
|
Cts.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (IsCompleted)
|
||||||
|
{
|
||||||
|
cts.Dispose();
|
||||||
|
_internalTask.Dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Cannot dispose a cancellable task before completed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ~CancellableTask()
|
||||||
|
// {
|
||||||
|
// Dispose(disposing: false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="EmptyThread.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.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp.Threading
|
||||||
|
{
|
||||||
|
public static partial class ThreadHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
private static readonly Thread _emptyThreadCache = new Thread(
|
||||||
|
() => { } );
|
||||||
|
|
||||||
|
static ThreadHelper()
|
||||||
|
{
|
||||||
|
_emptyThreadCache.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An individual thread doing nothing, and its <see cref="Thread.IsAlive" /> <see
|
||||||
|
/// langword="property" /> always returns false.
|
||||||
|
/// </summary>
|
||||||
|
public static Thread EmptyThread
|
||||||
|
{
|
||||||
|
get => _emptyThreadCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="MainThreadAssert.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.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp.Threading
|
||||||
|
{
|
||||||
|
public static partial class ThreadHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
private static readonly int mainThreadId = Environment.CurrentManagedThreadId;
|
||||||
|
private static readonly ThreadLocal<bool> isNotMainThread = new ThreadLocal<bool>(
|
||||||
|
() => Environment.CurrentManagedThreadId != mainThreadId );
|
||||||
|
|
||||||
|
[Conditional( "DEBUG" )]
|
||||||
|
internal static void MainThreadAssert()
|
||||||
|
{
|
||||||
|
if( isNotMainThread.Value ) {
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Attempt to call sensitive operation which can be only called from main thread "
|
||||||
|
+ $"from thread {Environment.CurrentManagedThreadId}." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51")]
|
||||||
[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/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
@@ -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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51")]
|
||||||
[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 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
@@ -66,7 +66,7 @@ namespace StgSharp.Script
|
|||||||
|
|
||||||
public void MakeCache()
|
public void MakeCache()
|
||||||
{
|
{
|
||||||
Root.TryGetNextLevel(out var nextLevel);
|
Root.TryGetNextLevel( out ICollection<IExpressionToken>? nextLevel );
|
||||||
foreach( TToken node in nextLevel ) { }
|
foreach( TToken node in nextLevel ) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,34 @@
|
|||||||
using System;
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="CodeLineHelper.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.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -6,62 +36,73 @@ namespace StgSharp.Script
|
|||||||
{
|
{
|
||||||
public static class CodeLineHelper
|
public static class CodeLineHelper
|
||||||
{
|
{
|
||||||
public static string SliceAndTrim(this string line, int startIndex, int length)
|
|
||||||
|
public static string SliceAndTrim( this string line, int startIndex )
|
||||||
{
|
{
|
||||||
if (line == null) throw new ArgumentNullException(nameof(line));
|
if( line == null ) {
|
||||||
if (startIndex < 0 || startIndex >= line.Length)
|
throw new ArgumentNullException( nameof( line ) );
|
||||||
throw new ArgumentOutOfRangeException(nameof(startIndex));
|
}
|
||||||
if (length < 0 || startIndex + length > line.Length)
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(length));
|
if( startIndex < 0 || startIndex >= line.Length ) {
|
||||||
|
throw new ArgumentOutOfRangeException( nameof( startIndex ) );
|
||||||
|
}
|
||||||
|
|
||||||
ReadOnlySpan<char> sourceSpan = line.AsSpan();
|
ReadOnlySpan<char> sourceSpan = line.AsSpan();
|
||||||
ReadOnlySpan<char> subSpan = sourceSpan.Slice(startIndex, length);
|
ReadOnlySpan<char> subSpan = sourceSpan.Slice( startIndex );
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start]))
|
while( start < subSpan.Length && char.IsWhiteSpace(
|
||||||
{
|
subSpan[ start ] ) ) {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
int end = subSpan.Length - 1;
|
int end = subSpan.Length - 1;
|
||||||
while (end >= start && char.IsWhiteSpace(subSpan[end]))
|
while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) {
|
||||||
{
|
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
if (start > end)
|
if( start > end ) {
|
||||||
{
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
int finalLength = end - start + 1;
|
int finalLength = end - start + 1;
|
||||||
|
|
||||||
return new string(subSpan.Slice(start, finalLength));
|
return new string( subSpan.Slice( start, finalLength ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SliceAndTrim(this string line, int startIndex)
|
public static string SliceAndTrim(
|
||||||
|
this string line,
|
||||||
|
int startIndex,
|
||||||
|
int length )
|
||||||
{
|
{
|
||||||
if (line == null) throw new ArgumentNullException(nameof(line));
|
if( line == null ) {
|
||||||
if (startIndex < 0 || startIndex >= line.Length)
|
throw new ArgumentNullException( nameof( line ) );
|
||||||
throw new ArgumentOutOfRangeException(nameof(startIndex));
|
}
|
||||||
|
|
||||||
|
if( startIndex < 0 || startIndex >= line.Length ) {
|
||||||
|
throw new ArgumentOutOfRangeException( nameof( startIndex ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( length < 0 || startIndex + length > line.Length ) {
|
||||||
|
throw new ArgumentOutOfRangeException( nameof( length ) );
|
||||||
|
}
|
||||||
|
|
||||||
ReadOnlySpan<char> sourceSpan = line.AsSpan();
|
ReadOnlySpan<char> sourceSpan = line.AsSpan();
|
||||||
ReadOnlySpan<char> subSpan = sourceSpan.Slice(startIndex);
|
ReadOnlySpan<char> subSpan = sourceSpan.Slice( startIndex, length );
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
while (start < subSpan.Length && char.IsWhiteSpace(subSpan[start]))
|
while( start < subSpan.Length && char.IsWhiteSpace(
|
||||||
{
|
subSpan[ start ] ) ) {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
int end = subSpan.Length - 1;
|
int end = subSpan.Length - 1;
|
||||||
while (end >= start && char.IsWhiteSpace(subSpan[end]))
|
while( end >= start && char.IsWhiteSpace( subSpan[ end ] ) ) {
|
||||||
{
|
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
if (start > end)
|
if( start > end ) {
|
||||||
{
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
int finalLength = end - start + 1;
|
int finalLength = end - start + 1;
|
||||||
|
|
||||||
return new string(subSpan.Slice(start, finalLength));
|
return new string( subSpan.Slice( start, finalLength ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpBuiltinConstant<T> : ExpLiteralToken<T>
|
public class ExpBuiltinConstant<T> : ExpLiteralToken<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
internal ExpBuiltinConstant( string name, T value )
|
internal ExpBuiltinConstant( string name, T value )
|
||||||
: base( name, null!, value )
|
: base( name, null!, value ) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// file="BuiltinType.cs"
|
// file="ExpBuiltinType.cs"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// AuthorGroup: Nitload Space
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// Copyright (c) Nitload Space. All rights reserved.
|
||||||
|
|||||||
@@ -39,26 +39,30 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public abstract class ExpCollectionBase : IExpElementSource, IEnumerable<ExpElementInstanceBase>
|
public abstract class ExpCollectionBase : IExpElementSource, IEnumerable<ExpElementInstanceBase>
|
||||||
{
|
{
|
||||||
|
|
||||||
protected internal string _accurateType;
|
protected internal string _accurateType;
|
||||||
|
|
||||||
protected ExpCollectionBase(
|
protected ExpCollectionBase( string accurateType )
|
||||||
string accurateType )
|
|
||||||
{
|
{
|
||||||
_accurateType = accurateType;
|
_accurateType = accurateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExpElementType ElementType => ExpElementType.Collection;
|
||||||
|
|
||||||
|
public abstract int Count
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
public string MemberType
|
public string MemberType
|
||||||
{
|
{
|
||||||
get => _accurateType;
|
get => _accurateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int Count { get; }
|
public abstract string Name
|
||||||
|
{
|
||||||
public ExpElementType ElementType => ExpElementType.Collection;
|
get;
|
||||||
|
}
|
||||||
IScriptSourceProvider IExpElementSource.SourceProvider => null!;
|
|
||||||
|
|
||||||
public abstract string Name { get; }
|
|
||||||
|
|
||||||
public void Analyse()
|
public void Analyse()
|
||||||
{
|
{
|
||||||
@@ -72,6 +76,8 @@ namespace StgSharp.Script.Express
|
|||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IScriptSourceProvider IExpElementSource.SourceProvider => null!;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpArray : ExpCollectionBase
|
public class ExpArray : ExpCollectionBase
|
||||||
@@ -79,8 +85,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
private ExpElementInstanceBase[] _collection;
|
private ExpElementInstanceBase[] _collection;
|
||||||
|
|
||||||
public ExpArray( string accurateType )
|
public ExpArray( string accurateType ) : base( accurateType ) { }
|
||||||
: base( accurateType ) { }
|
|
||||||
|
|
||||||
public ExpElementInstanceBase this[ int index ]
|
public ExpElementInstanceBase this[ int index ]
|
||||||
{
|
{
|
||||||
@@ -97,12 +102,12 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override int Count => _collection.Length;
|
public override int Count => _collection.Length;
|
||||||
|
|
||||||
public override string Name => ExpCompile.AddOrGetString("ARRAY");
|
public override string Name => ExpCompile.AddOrGetString( "ARRAY" );
|
||||||
|
|
||||||
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
||||||
{
|
{
|
||||||
return ( ( IEnumerable<ExpElementInstanceBase> )_collection )
|
return ( ( IEnumerable<ExpElementInstanceBase> )_collection )
|
||||||
.GetEnumerator( );
|
.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -113,12 +118,11 @@ namespace StgSharp.Script.Express
|
|||||||
private ConcurrentBag<ExpElementInstanceBase> _collection = new ConcurrentBag<ExpElementInstanceBase>(
|
private ConcurrentBag<ExpElementInstanceBase> _collection = new ConcurrentBag<ExpElementInstanceBase>(
|
||||||
);
|
);
|
||||||
|
|
||||||
public ExpBag( string accurateType )
|
public ExpBag( string accurateType ) : base( accurateType ) { }
|
||||||
: base( accurateType ) { }
|
|
||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
public override string Name => ExpCompile.AddOrGetString("BAG");
|
public override string Name => ExpCompile.AddOrGetString( "BAG" );
|
||||||
|
|
||||||
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
||||||
{
|
{
|
||||||
@@ -126,23 +130,24 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ExpList : ExpCollectionBase
|
public sealed class ExpList : ExpCollectionBase
|
||||||
{
|
{
|
||||||
public ExpList(string accurateType ):base(accurateType)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
private List<ExpElementInstanceBase> _collection = new List<ExpElementInstanceBase>(
|
||||||
|
);
|
||||||
|
|
||||||
private List<ExpElementInstanceBase> _collection = new List<ExpElementInstanceBase>();
|
public ExpList( string accurateType ) : base( accurateType ) { }
|
||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
public override string Name => ExpCompile.AddOrGetString("LIST");
|
public override string Name => ExpCompile.AddOrGetString( "LIST" );
|
||||||
|
|
||||||
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
public override IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
||||||
{
|
{
|
||||||
return _collection.GetEnumerator();
|
return _collection.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpSet : ExpCollectionBase
|
public class ExpSet : ExpCollectionBase
|
||||||
@@ -150,8 +155,11 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
private HashSet<ExpElementInstanceBase> _collection = new();
|
private HashSet<ExpElementInstanceBase> _collection = new();
|
||||||
|
|
||||||
public ExpSet( string accurateType )
|
public ExpSet( string accurateType ) : base( accurateType ) { }
|
||||||
: base( accurateType ) { }
|
|
||||||
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
|
public override string Name => ExpCompile.AddOrGetString( "SET" );
|
||||||
|
|
||||||
public void Add( ExpElementInstanceBase token )
|
public void Add( ExpElementInstanceBase token )
|
||||||
{
|
{
|
||||||
@@ -162,16 +170,12 @@ namespace StgSharp.Script.Express
|
|||||||
_collection.Add( token );
|
_collection.Add( token );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override sealed IEnumerator<ExpElementInstanceBase> GetEnumerator(
|
||||||
|
)
|
||||||
public override string Name => ExpCompile.AddOrGetString("SET");
|
|
||||||
|
|
||||||
public override sealed IEnumerator<ExpElementInstanceBase> GetEnumerator()
|
|
||||||
{
|
{
|
||||||
return ( ( IEnumerable<ExpElementInstanceBase> )_collection )
|
return ( ( IEnumerable<ExpElementInstanceBase> )_collection )
|
||||||
.GetEnumerator( );
|
.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,28 +38,24 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpConstantCollectionSource : IExpImmutableElement
|
public class ExpConstantCollectionSource : IExpImmutableElement
|
||||||
{
|
{
|
||||||
private IScriptSourceProvider _sourceProvider;
|
|
||||||
private Dictionary<string, ExpElementInstanceBase> _constants;
|
private Dictionary<string, ExpElementInstanceBase> _constants;
|
||||||
|
private IScriptSourceProvider _sourceProvider;
|
||||||
|
|
||||||
public ExpConstantCollectionSource(
|
public ExpConstantCollectionSource(
|
||||||
IScriptSourceProvider sourceProvider )
|
IScriptSourceProvider sourceProvider )
|
||||||
{
|
{
|
||||||
_sourceProvider = sourceProvider;
|
_sourceProvider = sourceProvider;
|
||||||
_constants = new Dictionary<string, ExpElementInstanceBase>(
|
_constants = new Dictionary<string, ExpElementInstanceBase>(
|
||||||
ExpCompile.Multiplexer);
|
ExpCompile.Multiplexer );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddConstant(string name, ExpElementInstanceBase value)
|
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => ExpCompile.BuiltinConst;
|
||||||
{
|
|
||||||
_constants.Add(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpElementType ElementType => ExpElementType.Const;
|
public ExpElementType ElementType => ExpElementType.Const;
|
||||||
|
|
||||||
public IScriptSourceProvider SourceProvider => _sourceProvider;
|
public IScriptSourceProvider SourceProvider => _sourceProvider;
|
||||||
|
|
||||||
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => ExpCompile.BuiltinConst;
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => ExpCompile.KeyWord.Constant;
|
get => ExpCompile.KeyWord.Constant;
|
||||||
@@ -70,26 +66,32 @@ namespace StgSharp.Script.Express
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpToken MakeReference(params object[] options)
|
public ExpToken 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!;
|
||||||
}
|
}
|
||||||
if (_constants.Count == 0)
|
if( _constants.Count == 0 ) {
|
||||||
{
|
|
||||||
return null!;
|
return null!;
|
||||||
}
|
}
|
||||||
if (_constants.TryGetValue(str, out var token))
|
if( _constants.TryGetValue( str,
|
||||||
{
|
out ExpElementInstanceBase? token ) ) {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
return null!;
|
return null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetConstant(string name, out ExpElementInstanceBase instance)
|
public bool TryGetConstant(
|
||||||
|
string name,
|
||||||
|
out ExpElementInstanceBase instance )
|
||||||
{
|
{
|
||||||
return _constants.TryGetValue(name, out instance);
|
return _constants.TryGetValue( name, out instance );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void AddConstant( string name, ExpElementInstanceBase value )
|
||||||
|
{
|
||||||
|
_constants.Add( name, value );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,8 @@ namespace StgSharp.Script.Express
|
|||||||
public class ExpEntity : ExpToken
|
public class ExpEntity : ExpToken
|
||||||
{
|
{
|
||||||
|
|
||||||
public ExpEntity( string name ,ExpSchema context):
|
public ExpEntity( string name, ExpSchema context )
|
||||||
base(name, context)
|
: base( name, context ) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,5 +70,6 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,14 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpFunction : ExpToken
|
public class ExpFunction : ExpToken
|
||||||
{
|
{
|
||||||
|
|
||||||
private ExpFunctionSource _source;
|
private ExpFunctionSource _source;
|
||||||
private readonly ExpToken _return;
|
private readonly ExpToken _return;
|
||||||
private readonly List<KeyValuePair<string, ExpToken>> _parameterList
|
private readonly List<KeyValuePair<string, ExpToken>> _parameterList
|
||||||
= new List<KeyValuePair<string, ExpToken>>();
|
= new List<KeyValuePair<string, ExpToken>>();
|
||||||
|
|
||||||
public ExpFunction(string name, ExpSchema context) : base(name, context)
|
public ExpFunction( string name, ExpSchema context )
|
||||||
{ }
|
: base( name, context ) { }
|
||||||
|
|
||||||
public ExpElementType ElementType => ExpElementType.Function;
|
public ExpElementType ElementType => ExpElementType.Function;
|
||||||
|
|
||||||
@@ -75,9 +76,10 @@ namespace StgSharp.Script.Express
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpToken MakeReference(params object[] options)
|
public ExpToken MakeReference( params object[] options )
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,15 +37,16 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpRule : ExpElementInstanceBase
|
public class ExpRule : ExpElementInstanceBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private ExpRuleSource _source;
|
private ExpRuleSource _source;
|
||||||
|
|
||||||
public ExpRule(string name, ExpSchema context) : base(name,context)
|
public ExpRule( string name, ExpSchema context )
|
||||||
{
|
: base( name, context ) { }
|
||||||
}
|
|
||||||
|
|
||||||
public object? value => throw new NotImplementedException();
|
public object? value => throw new NotImplementedException();
|
||||||
|
|
||||||
public override string TypeName => _source.Name;
|
public override string TypeName => _source.Name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpRuleSource : IExpImmutableElement
|
public class ExpRuleSource : IExpImmutableElement
|
||||||
@@ -71,9 +72,10 @@ namespace StgSharp.Script.Express
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpToken MakeReference(params object[] options)
|
public ExpToken MakeReference( params object[] options )
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,14 +37,12 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpType : ExpElementInstanceBase
|
public class ExpType : ExpElementInstanceBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public ExpType( string name, ExpSchema context )
|
||||||
|
: base( name, context ) { }
|
||||||
|
|
||||||
public override string TypeName => throw new NotImplementedException();
|
public override string TypeName => throw new NotImplementedException();
|
||||||
|
|
||||||
public ExpType(string name, ExpSchema context) : base(name, context)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpTypeSource : IExpElementSource
|
public class ExpTypeSource : IExpElementSource
|
||||||
|
|||||||
@@ -46,30 +46,28 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public class ExpInvalidCharException : Exception
|
public class ExpInvalidCharException : Exception
|
||||||
{
|
{
|
||||||
public ExpInvalidCharException(char c) :
|
|
||||||
base($"An unknown char {c} occurred.")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public ExpInvalidCharException( char c )
|
||||||
|
: base( $"An unknown char {c} occurred." ) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpInvalidTokenException : Exception
|
public class ExpInvalidTokenException : Exception
|
||||||
{
|
{
|
||||||
public ExpInvalidTokenException(int index) :
|
|
||||||
base($"Cannot read a token from line at {index}")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public ExpInvalidTokenException( int index )
|
||||||
|
: base( $"Cannot read a token from line at {index}" ) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExpInvalidTypeDeclareEndingExceptions : Exception
|
public class ExpInvalidTypeDeclareEndingExceptions : Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
public ExpInvalidTypeDeclareEndingExceptions(
|
public ExpInvalidTypeDeclareEndingExceptions(
|
||||||
string declaredName,
|
string declaredName,
|
||||||
string endedName )
|
string endedName )
|
||||||
: base(
|
: base(
|
||||||
$"The datatype is declared with name {declaredName} " +
|
$"The datatype is declared with name {declaredName} " + $"but ended with {endedName}" ) { }
|
||||||
$"but ended with {endedName}" ) { }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpIfToken.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.Script.Express;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
public sealed class ExpIfToken : ExpToken
|
||||||
|
{
|
||||||
|
|
||||||
|
private ExpToken _rule;
|
||||||
|
private List<ExpToken> _falseOp;
|
||||||
|
private List<ExpToken> _trueOp;
|
||||||
|
|
||||||
|
public ExpIfToken(
|
||||||
|
string name,
|
||||||
|
ExpSchema context,
|
||||||
|
ExpToken rule,
|
||||||
|
IEnumerable<ExpToken> operationIfTrue,
|
||||||
|
IEnumerable<ExpToken> operationIfFalse )
|
||||||
|
: base( name, context )
|
||||||
|
{
|
||||||
|
_rule = rule;
|
||||||
|
if( operationIfFalse == null ) {
|
||||||
|
_trueOp = new List<ExpToken>();
|
||||||
|
} else {
|
||||||
|
_trueOp = new List<ExpToken>( operationIfFalse );
|
||||||
|
}
|
||||||
|
if( operationIfFalse == null ) {
|
||||||
|
_falseOp = new List<ExpToken>();
|
||||||
|
} else {
|
||||||
|
_falseOp = new List<ExpToken>( operationIfFalse );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddFalseOperation( ExpToken expressionRoot )
|
||||||
|
{
|
||||||
|
AssertSchemaInclude( expressionRoot );
|
||||||
|
_falseOp.Add( expressionRoot );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTrueOperation( ExpToken expressionRoot )
|
||||||
|
{
|
||||||
|
AssertSchemaInclude( expressionRoot );
|
||||||
|
_trueOp.Add( expressionRoot );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpLiteralToken.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;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
public class ExpLiteralToken<T> : ExpElementInstanceBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ExpBuiltinType _type;
|
||||||
|
private readonly T _value;
|
||||||
|
|
||||||
|
public ExpLiteralToken( string name, ExpSchema context, T value )
|
||||||
|
: base( name, context )
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
switch( value ) {
|
||||||
|
case float f:
|
||||||
|
ExpCompile.TryGetBuiltinType(
|
||||||
|
ExpCompile.KeyWord.Real, out ExpTypeSource? type );
|
||||||
|
_type = ( type as ExpBuiltinType )!;
|
||||||
|
_tokenType = ExpTokenFlag.BuiltinType_Float | ExpTokenFlag.Element_Const;
|
||||||
|
break;
|
||||||
|
case int i:
|
||||||
|
ExpCompile.TryGetBuiltinType(
|
||||||
|
ExpCompile.KeyWord.Int, out type );
|
||||||
|
_type = ( type as ExpBuiltinType )!;
|
||||||
|
_tokenType = ExpTokenFlag.BuiltinType_Int | ExpTokenFlag.Element_Const;
|
||||||
|
break;
|
||||||
|
case BitArray b:
|
||||||
|
ExpCompile.TryGetBuiltinType(
|
||||||
|
ExpCompile.KeyWord.Binary, out type );
|
||||||
|
_type = ( type as ExpBuiltinType )!;
|
||||||
|
_tokenType = ExpTokenFlag.BuiltinType_Binary | ExpTokenFlag.Element_Const;
|
||||||
|
break;
|
||||||
|
case string s:
|
||||||
|
ExpCompile.TryGetBuiltinType(
|
||||||
|
ExpCompile.KeyWord.String, out type );
|
||||||
|
_type = ( type as ExpBuiltinType )!;
|
||||||
|
_tokenType = ExpTokenFlag.BuiltinType_Int | ExpTokenFlag.Element_Const;
|
||||||
|
break;
|
||||||
|
case ExpLogic l:
|
||||||
|
ExpCompile.TryGetBuiltinType(
|
||||||
|
ExpCompile.KeyWord.Logic, out type );
|
||||||
|
_type = ( type as ExpBuiltinType )!;
|
||||||
|
_tokenType = ExpTokenFlag.BuiltinType_Int | ExpTokenFlag.Element_Const;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ExpInvalidTypeException(
|
||||||
|
"Builtin Type", value!.GetType().Name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string TypeName => _type.Name;
|
||||||
|
|
||||||
|
public T value => _value;
|
||||||
|
|
||||||
|
public override bool TryGetNextLevel(
|
||||||
|
out ICollection<IExpressionToken> nextLevel )
|
||||||
|
{
|
||||||
|
nextLevel = null!;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpRepeat.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.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
public class ExpRepeat : ExpToken
|
||||||
|
{
|
||||||
|
|
||||||
|
public ExpRepeat( string name, ExpSchema context )
|
||||||
|
: base( name, context ) { }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExpRepeatRule : ExpToken
|
||||||
|
{
|
||||||
|
|
||||||
|
private ExpElementInstanceBase _variable, _begin, _end, _increment;
|
||||||
|
private List<ExpToken> _token = new List<ExpToken>();
|
||||||
|
|
||||||
|
public ExpRepeatRule(
|
||||||
|
string name,
|
||||||
|
ExpSchema context,
|
||||||
|
IEnumerable<ExpToken> operation,
|
||||||
|
ExpElementInstanceBase variable,
|
||||||
|
ExpElementInstanceBase begin,
|
||||||
|
ExpElementInstanceBase end,
|
||||||
|
ExpElementInstanceBase increment )
|
||||||
|
: base( name, context )
|
||||||
|
{
|
||||||
|
if( variable.TokenTypeCode != begin.TokenTypeCode || begin.TokenTypeCode !=
|
||||||
|
end.TokenTypeCode || ( increment != null && end.TokenTypeCode !=
|
||||||
|
increment.TokenTypeCode ) ) {
|
||||||
|
throw new InvalidCastException();
|
||||||
|
}
|
||||||
|
if( increment == null ) {
|
||||||
|
switch( ( ExpTokenFlag )variable.TokenTypeCode | ExpTokenFlag.BuiltinType_Any ) {
|
||||||
|
case ExpTokenFlag.BuiltinType_Float:
|
||||||
|
increment = new ExpLiteralToken<float>(
|
||||||
|
$"{name}_defaultincrement", context, 1.0f );
|
||||||
|
break;
|
||||||
|
case ExpTokenFlag.BuiltinType_Int:
|
||||||
|
increment = new ExpLiteralToken<int>(
|
||||||
|
$"{name}_defaultincrement", context, 1 );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ExpInvalidTypeException(
|
||||||
|
"Int or Real", "otherwise" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_begin = begin;
|
||||||
|
_variable = variable;
|
||||||
|
_end = end;
|
||||||
|
_increment = increment;
|
||||||
|
_tokenType = ExpTokenFlag.Branch_Repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryGetNextLevel(
|
||||||
|
out ICollection<IExpressionToken> nextLevel )
|
||||||
|
{
|
||||||
|
nextLevel = ( _token.ToList() as ICollection<IExpressionToken> )!;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpSwitchToken.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.Script.Express
|
||||||
|
{
|
||||||
|
public class ExpSwitchToken : ExpToken
|
||||||
|
{
|
||||||
|
|
||||||
|
private Dictionary<ExpToken, List<ExpToken>> _cases;
|
||||||
|
private ExpToken _target;
|
||||||
|
private List<ExpToken> _default;
|
||||||
|
|
||||||
|
public ExpSwitchToken(
|
||||||
|
string name,
|
||||||
|
ExpSchema context,
|
||||||
|
ExpToken target,
|
||||||
|
IEnumerable<ExpToken> @default,
|
||||||
|
params (ExpToken label, IEnumerable<ExpToken> op)[] cases )
|
||||||
|
: base( name, context )
|
||||||
|
{
|
||||||
|
_target = target;
|
||||||
|
if( @default == null ) {
|
||||||
|
_default = new List<ExpToken>();
|
||||||
|
} else {
|
||||||
|
_default = new List<ExpToken>( @default );
|
||||||
|
}
|
||||||
|
_cases = new Dictionary<ExpToken, List<ExpToken>>();
|
||||||
|
foreach( (ExpToken label, IEnumerable<ExpToken> op) item in cases ) {
|
||||||
|
if( item.op == null ) {
|
||||||
|
_cases.Add( item.label, new List<ExpToken>() );
|
||||||
|
} else {
|
||||||
|
_cases.Add( item.label, new List<ExpToken>( item.op ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExpToken> this[ ExpToken index ]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if( _cases.TryGetValue( index, out List<ExpToken>? ret ) ) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return _default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an expression to certain <see langword="case" />. The added expression will be run
|
||||||
|
/// at last.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="label"> Label of case to add operation </param>
|
||||||
|
/// <param name="expressionRoot"> Root token of the expression to be added. </param>
|
||||||
|
/// <exception cref="ExpCaseNotFoundException"> Cannot fine the case label in current witch expression. </exception>
|
||||||
|
public void AddOperationToCase(
|
||||||
|
ExpToken label,
|
||||||
|
ExpToken expressionRoot )
|
||||||
|
{
|
||||||
|
AssertSchemaInclude( expressionRoot );
|
||||||
|
if( _cases.TryGetValue( label, out List<ExpToken>? op ) ) {
|
||||||
|
op.Add( expressionRoot );
|
||||||
|
} else {
|
||||||
|
throw new ExpCaseNotFoundException( this, label );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddOperationToDefault( ExpToken expressionRoot )
|
||||||
|
{
|
||||||
|
if( expressionRoot != null ) {
|
||||||
|
_default.Add( expressionRoot );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsCase( ExpToken token )
|
||||||
|
{
|
||||||
|
return _cases.ContainsKey( token );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpToken.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 CommunityToolkit.HighPerformance.Buffers;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum ExpTokenFlag : long
|
||||||
|
{
|
||||||
|
|
||||||
|
None = 0,
|
||||||
|
Name_Element = 1,
|
||||||
|
Name_Param = 2,
|
||||||
|
Name_Block = 4,
|
||||||
|
Name_Keyword = 8,
|
||||||
|
Name_Any = Name_Block | Name_Element | Name_Keyword | Name_Param,
|
||||||
|
Collection_Set = 16,
|
||||||
|
Collection_Bag = 32,
|
||||||
|
Collection_Array = 64,
|
||||||
|
Collection_List = 128,
|
||||||
|
Collection_Any = Collection_Set | Collection_Bag | Collection_Array | Collection_List,
|
||||||
|
Element_Const = 256,
|
||||||
|
Element_Entity = 512,
|
||||||
|
Element_type = 1024,
|
||||||
|
Element_Rule = 2048,
|
||||||
|
Element_Function = 4096,
|
||||||
|
Element_Any = Element_Entity | Element_Const | Element_Function | Element_Rule | Element_type,
|
||||||
|
BuiltinType_Int = 8192,
|
||||||
|
BuiltinType_Float = 16384,
|
||||||
|
BuiltinType_String = 32768,
|
||||||
|
BuiltinType_Boolean = 65536,
|
||||||
|
BuiltinType_Binary = 0x2000,
|
||||||
|
BuiltinType_Logic = 0x4000,
|
||||||
|
BuiltinType_Any = BuiltinType_Int | BuiltinType_Float | BuiltinType_String | BuiltinType_Boolean | BuiltinType_Binary | BuiltinType_Logic,
|
||||||
|
Branch_If = 0x8000,
|
||||||
|
Branch_Switch = 0x1_0000,
|
||||||
|
Branch_Repeat = 0x2_0000,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref struct ExpTokenSource
|
||||||
|
{
|
||||||
|
public ReadOnlySpan<char> Value;
|
||||||
|
public readonly int Line;
|
||||||
|
public readonly int Column;
|
||||||
|
|
||||||
|
public ExpTokenSource(ReadOnlySpan<char> chars, int lineNumber, int columnNumber)
|
||||||
|
{
|
||||||
|
Value = chars; Line = lineNumber; Column = columnNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class ExpToken : IExpressionToken
|
||||||
|
{
|
||||||
|
|
||||||
|
protected internal ExpToken _previousToken;
|
||||||
|
protected internal ExpTokenFlag _tokenType;
|
||||||
|
protected internal List<ExpToken> _nextLevelTokens
|
||||||
|
= new List<ExpToken>();
|
||||||
|
protected internal string _name;
|
||||||
|
|
||||||
|
protected ExpToken( string name, ExpSchema context )
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpSchema Context
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long TokenTypeCode => ( long )_tokenType;
|
||||||
|
|
||||||
|
public string Name => _name;
|
||||||
|
|
||||||
|
public virtual bool TryGetNextLevel(
|
||||||
|
out ICollection<IExpressionToken> nextLevel )
|
||||||
|
{
|
||||||
|
nextLevel = ( _nextLevelTokens as ICollection<IExpressionToken> )!;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AssertSchemaInclude( ExpToken expressionRoot )
|
||||||
|
{
|
||||||
|
if( expressionRoot.Context != Context && Context.HasSchemaInclude(
|
||||||
|
expressionRoot.Context ) ) {
|
||||||
|
throw new ExpInvalidSchemaIncludeException(
|
||||||
|
Context, expressionRoot.Context );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,13 +41,12 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public static partial class ExpCompile
|
public static partial class ExpCompile
|
||||||
{
|
{
|
||||||
|
|
||||||
private static ConcurrentStringHashMultiplexer _multiplexer;
|
private static ConcurrentStringHashMultiplexer _multiplexer;
|
||||||
private static Dictionary<string, ExpElementInstanceBase> _builtinConst;
|
private static Dictionary<string, ExpElementInstanceBase> _builtinConst;
|
||||||
private static Dictionary<string, ExpTypeSource> _builtinType;
|
private static Dictionary<string, ExpTypeSource> _builtinType;
|
||||||
private static StringPool _compileStringCache;
|
private static StringPool _compileStringCache;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => _builtinConst;
|
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => _builtinConst;
|
||||||
|
|
||||||
internal static ConcurrentStringHashMultiplexer Multiplexer
|
internal static ConcurrentStringHashMultiplexer Multiplexer
|
||||||
@@ -71,9 +70,13 @@ namespace StgSharp.Script.Express
|
|||||||
_compileStringCache.Reset();
|
_compileStringCache.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SkipComment(IScriptSourceProvider source)
|
public static void DeinitCompile()
|
||||||
{
|
{
|
||||||
|
_compileStringCache.Reset();
|
||||||
|
_compileStringCache = null;
|
||||||
|
|
||||||
|
_multiplexer.Dispose();
|
||||||
|
_multiplexer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitCompile()
|
public static void InitCompile()
|
||||||
@@ -83,17 +86,27 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
_builtinType = new Dictionary<string, ExpTypeSource>( _multiplexer ) {
|
_builtinType = new Dictionary<string, ExpTypeSource>( _multiplexer ) {
|
||||||
{ AddOrGetString( KeyWord.Int ), new ExpBuiltinType(
|
{ AddOrGetString( KeyWord.Int ), new ExpBuiltinType(
|
||||||
AddOrGetString( KeyWord.Int ),typeof( int ) ) },
|
AddOrGetString( KeyWord.Int ),
|
||||||
{ AddOrGetString( KeyWord.Real ), new ExpBuiltinType(
|
typeof( int ) ) }, { AddOrGetString( KeyWord.Real ), new ExpBuiltinType(
|
||||||
AddOrGetString( KeyWord.Real ), typeof( float ) ) },
|
AddOrGetString( KeyWord.Real ),
|
||||||
{ AddOrGetString(KeyWord.Bool ), new ExpBuiltinType(
|
typeof( float ) ) }, { AddOrGetString(
|
||||||
AddOrGetString(KeyWord.Bool ), typeof( bool ) ) },
|
KeyWord.Bool ), new ExpBuiltinType(
|
||||||
{ AddOrGetString(KeyWord.Binary ), new ExpBuiltinType(
|
AddOrGetString(
|
||||||
AddOrGetString(KeyWord.Binary ),typeof( bool ) ) },
|
KeyWord.Bool ),
|
||||||
{ AddOrGetString(KeyWord.String ), new ExpBuiltinType(
|
typeof( bool ) ) }, { AddOrGetString(
|
||||||
AddOrGetString(KeyWord.String ),typeof( string ) ) },
|
KeyWord.Binary ), new ExpBuiltinType(
|
||||||
{ AddOrGetString(KeyWord.Logic ), new ExpBuiltinType(
|
AddOrGetString(
|
||||||
AddOrGetString(KeyWord.Logic ), typeof( Logic ) ) } };
|
KeyWord.Binary ),
|
||||||
|
typeof( bool ) ) }, { AddOrGetString(
|
||||||
|
KeyWord.String ), new ExpBuiltinType(
|
||||||
|
AddOrGetString(
|
||||||
|
KeyWord.String ),
|
||||||
|
typeof( string ) ) }, { AddOrGetString(
|
||||||
|
KeyWord.Logic ), new ExpBuiltinType(
|
||||||
|
AddOrGetString(
|
||||||
|
KeyWord.Logic ),
|
||||||
|
typeof( ExpLogic ) ) }
|
||||||
|
};
|
||||||
|
|
||||||
_builtinConst = new Dictionary<string, ExpElementInstanceBase>(
|
_builtinConst = new Dictionary<string, ExpElementInstanceBase>(
|
||||||
_multiplexer ) {
|
_multiplexer ) {
|
||||||
@@ -104,14 +117,7 @@ namespace StgSharp.Script.Express
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeinitCompile()
|
public static void SkipComment( IScriptSourceProvider source ) { }
|
||||||
{
|
|
||||||
_compileStringCache.Reset();
|
|
||||||
_compileStringCache = null;
|
|
||||||
|
|
||||||
_multiplexer.Dispose();
|
|
||||||
_multiplexer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryGetBuiltinConst(
|
public static bool TryGetBuiltinConst(
|
||||||
string constName,
|
string constName,
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public interface IExpImmutableElement : IExpElementSource
|
public interface IExpImmutableElement : IExpElementSource
|
||||||
{
|
{
|
||||||
public abstract ExpToken MakeReference(params object[] options);
|
|
||||||
|
public abstract ExpToken MakeReference( params object[] options );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,12 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpExpressionTree : AbstractSyntaxTree<ExpToken>
|
public class ExpExpressionTree : AbstractSyntaxTree<ExpToken>
|
||||||
{
|
{
|
||||||
public ExpToken RootToken { get; private set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
public ExpToken RootToken
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,73 @@
|
|||||||
using System;
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpLogic.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.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public enum Logic
|
public enum ExpLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
False = 1,
|
False = 1,
|
||||||
True = 2,
|
True = 2,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LogicConverter
|
||||||
|
{
|
||||||
|
public static bool? AsNullableBool(this ExpLogic l)
|
||||||
|
{
|
||||||
|
switch (l)
|
||||||
|
{
|
||||||
|
case ExpLogic.Unknown:
|
||||||
|
return null;
|
||||||
|
case ExpLogic.False:
|
||||||
|
return false;
|
||||||
|
case ExpLogic.True:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpLogic AsNullableInt(this bool? b)
|
||||||
|
{
|
||||||
|
return b switch
|
||||||
|
{
|
||||||
|
null => ExpLogic.Unknown,
|
||||||
|
true => ExpLogic.True,
|
||||||
|
false => ExpLogic.False,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public class ExpSchema
|
public class ExpSchema
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly ConcurrentStringHashMultiplexer _multiplexer = ExpCompile.Multiplexer;
|
private readonly ConcurrentStringHashMultiplexer _multiplexer = ExpCompile.Multiplexer;
|
||||||
private Dictionary<string, ExpConstantCollectionSource> _constDict;
|
private Dictionary<string, ExpConstantCollectionSource> _constDict;
|
||||||
private Dictionary<string, ExpEntitySource> _entityDict;
|
private Dictionary<string, ExpEntitySource> _entityDict;
|
||||||
@@ -50,12 +51,18 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public ExpSchema()
|
public ExpSchema()
|
||||||
{
|
{
|
||||||
_constDict = new Dictionary<string, ExpConstantCollectionSource>(ExpCompile.Multiplexer);
|
_constDict = new Dictionary<string, ExpConstantCollectionSource>(
|
||||||
_entityDict = new Dictionary<string, ExpEntitySource>(ExpCompile.Multiplexer);
|
ExpCompile.Multiplexer );
|
||||||
_functionDict = new Dictionary<string, ExpFunctionSource>(ExpCompile.Multiplexer);
|
_entityDict = new Dictionary<string, ExpEntitySource>(
|
||||||
_ruleDict = new Dictionary<string, ExpRuleSource>(ExpCompile.Multiplexer);
|
ExpCompile.Multiplexer );
|
||||||
_schemaInclude = new Dictionary<string, ExpSchema>(ExpCompile.Multiplexer);
|
_functionDict = new Dictionary<string, ExpFunctionSource>(
|
||||||
_typeDict = new Dictionary<string, ExpTypeSource>(ExpCompile.Multiplexer);
|
ExpCompile.Multiplexer );
|
||||||
|
_ruleDict = new Dictionary<string, ExpRuleSource>(
|
||||||
|
ExpCompile.Multiplexer );
|
||||||
|
_schemaInclude = new Dictionary<string, ExpSchema>(
|
||||||
|
ExpCompile.Multiplexer );
|
||||||
|
_typeDict = new Dictionary<string, ExpTypeSource>(
|
||||||
|
ExpCompile.Multiplexer );
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@@ -66,8 +73,8 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public ExpTypeSource GetExpType( string typeName )
|
public ExpTypeSource GetExpType( string typeName )
|
||||||
{
|
{
|
||||||
if( ExpCompile.TryGetBuiltinType(
|
if( ExpCompile.TryGetBuiltinType( typeName,
|
||||||
typeName, out ExpTypeSource? ret ) ) {
|
out ExpTypeSource? ret ) ) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if( _typeDict.TryGetValue( typeName, out ret ) ) {
|
if( _typeDict.TryGetValue( typeName, out ret ) ) {
|
||||||
@@ -86,20 +93,21 @@ namespace StgSharp.Script.Express
|
|||||||
return _schemaInclude.ContainsKey( schema.Name );
|
return _schemaInclude.ContainsKey( schema.Name );
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetConstant(string name, out ExpElementInstanceBase constInstance)
|
public bool TryGetConstant(
|
||||||
|
string name,
|
||||||
|
out ExpElementInstanceBase constInstance )
|
||||||
{
|
{
|
||||||
if (ExpCompile.BuiltinConst.TryGetValue(name, out constInstance))
|
if( ExpCompile.BuiltinConst.TryGetValue( name,
|
||||||
{
|
out constInstance ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
foreach (var item in _constDict.Values)
|
foreach( ExpConstantCollectionSource item in _constDict.Values ) {
|
||||||
{
|
if( item.TryGetConstant( name, out constInstance ) ) {
|
||||||
if (item.TryGetConstant(name, out constInstance))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// file="ExpSchema.cs"
|
// file="ExpSchemaSource.cs"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// AuthorGroup: Nitload Space
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// Copyright (c) Nitload Space. All rights reserved.
|
||||||
@@ -43,39 +43,6 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public partial class ExpSchemaSource
|
public partial class ExpSchemaSource
|
||||||
{
|
{
|
||||||
[GeneratedRegex(@"\s*END_CONSTANT;")]
|
|
||||||
private static partial Regex GetConstDefineEnd();
|
|
||||||
|
|
||||||
private static Regex
|
|
||||||
_constDefineBegin = GetConstDefineBegin(),
|
|
||||||
_constDefineEnd = GetConstDefineEnd(),
|
|
||||||
_schemaBegin = GetSchemaBegin(),
|
|
||||||
_schemaEnd = new Regex(
|
|
||||||
@"END_SCHEMA;\s*--\s*(?<namespace>[A-Za-z0-9_]+)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_entityDefineBegin = new Regex(
|
|
||||||
@"\s*ENTITY\s*(?<TypeName>[A-Za-z0-9_]+)\s*", RegexOptions.Compiled ),
|
|
||||||
_entityDefineEnd = new Regex(
|
|
||||||
@"\s*END_ENTITY;\s*--\s*(?<TypeName>[A-Za-z0-9_]+)\s*",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_typeDefineBegin = new Regex(
|
|
||||||
@"\s*TYPE\s+(?<TypeName>[A-Za-z0-9_]+)\s*=\s*(?<Remaining>[A-Z]+)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_typeDefineEnd = new Regex(
|
|
||||||
@"\s*END_TYPE\s*;\s*--\s*(?<TypeName>[a-zA-Z0-9_]+)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_functionDefineBegin = new Regex(
|
|
||||||
@"\s*FUNCTION\s*\s*(?<FunctionName>[a-zA-Z0-9_]+)\s*(?<Remaining>.*)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_functionDefineEnd = new Regex(
|
|
||||||
@"\s*END_FUNCTION\s*;\s*--\s*(?<FunctionName>[a-zA-Z0-9_]+)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_ruleDefineBegin = new Regex(
|
|
||||||
@"\s*RULE\s*(?<RuleName>[a-zA-Z0-9_]+)\s*FOR\s*\((?<Target>[a-zA-Z0-9_]*(\s*\)\s*;)?)",
|
|
||||||
RegexOptions.Compiled ),
|
|
||||||
_ruleDefineEnd = new Regex(
|
|
||||||
@"\s*END_RULE\s*;\s*--\s*(?<RuleName>[A-Za-z0-9_]+)",
|
|
||||||
RegexOptions.Compiled );
|
|
||||||
|
|
||||||
private Dictionary<string, IExpElementSource> _sourceCache = new();
|
private Dictionary<string, IExpElementSource> _sourceCache = new();
|
||||||
|
|
||||||
@@ -83,16 +50,14 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
|
public ExpSchemaSource() { }
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => _compileResult.Name;
|
get => _compileResult.Name;
|
||||||
internal set => _compileResult.Name = value;
|
internal set => _compileResult.Name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ExpSchemaSource() { }
|
|
||||||
|
|
||||||
public void ReadSchema( ExpFileSource reader )
|
public void ReadSchema( ExpFileSource reader )
|
||||||
{
|
{
|
||||||
string line = reader.ReadLine();
|
string line = reader.ReadLine();
|
||||||
@@ -159,6 +124,15 @@ namespace StgSharp.Script.Express
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex( @"\s*CONSTANT" )]
|
||||||
|
private static partial Regex GetConstDefineBegin();
|
||||||
|
|
||||||
|
[GeneratedRegex( @"\s*END_CONSTANT;" )]
|
||||||
|
private static partial Regex GetConstDefineEnd();
|
||||||
|
|
||||||
|
[GeneratedRegex( @"\s*SCHEMA\s*(?<namespace>[A-Za-z0-9_]+)\s?;" )]
|
||||||
|
private static partial Regex GetSchemaBegin();
|
||||||
|
|
||||||
private bool TryReadConst(
|
private bool TryReadConst(
|
||||||
string firstLine,
|
string firstLine,
|
||||||
ExpFileSource reader,
|
ExpFileSource reader,
|
||||||
@@ -167,7 +141,7 @@ namespace StgSharp.Script.Express
|
|||||||
Match match = _constDefineBegin.Match( firstLine );
|
Match match = _constDefineBegin.Match( firstLine );
|
||||||
if( match.Success ) {
|
if( match.Success ) {
|
||||||
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
||||||
"END_CONSTANT",reader.Location );
|
"END_CONSTANT", reader.Location );
|
||||||
ExpConstantCollectionSource _source = new ExpConstantCollectionSource(
|
ExpConstantCollectionSource _source = new ExpConstantCollectionSource(
|
||||||
transmitter );
|
transmitter );
|
||||||
string line = reader.ReadLine();
|
string line = reader.ReadLine();
|
||||||
@@ -191,7 +165,7 @@ namespace StgSharp.Script.Express
|
|||||||
Match match = _entityDefineBegin.Match( firstLine );
|
Match match = _entityDefineBegin.Match( firstLine );
|
||||||
if( match.Success ) {
|
if( match.Success ) {
|
||||||
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
||||||
"END_ENTITY", reader.Location);
|
"END_ENTITY", reader.Location );
|
||||||
ExpEntitySource _source = new ExpEntitySource(
|
ExpEntitySource _source = new ExpEntitySource(
|
||||||
match.Groups[ "TypeName" ].ToString(), transmitter );
|
match.Groups[ "TypeName" ].ToString(), transmitter );
|
||||||
string line = reader.ReadLine();
|
string line = reader.ReadLine();
|
||||||
@@ -222,7 +196,7 @@ namespace StgSharp.Script.Express
|
|||||||
Match match = _functionDefineBegin.Match( firstLine );
|
Match match = _functionDefineBegin.Match( firstLine );
|
||||||
if( match.Success ) {
|
if( match.Success ) {
|
||||||
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
||||||
"END_FUNCTION", reader.Location);
|
"END_FUNCTION", reader.Location );
|
||||||
ExpFunctionSource _source = new ExpFunctionSource(
|
ExpFunctionSource _source = new ExpFunctionSource(
|
||||||
match.Groups[ "FunctionName" ].ToString(), transmitter );
|
match.Groups[ "FunctionName" ].ToString(), transmitter );
|
||||||
transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() );
|
transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() );
|
||||||
@@ -254,7 +228,7 @@ namespace StgSharp.Script.Express
|
|||||||
Match match = _ruleDefineBegin.Match( firstLine );
|
Match match = _ruleDefineBegin.Match( firstLine );
|
||||||
if( match.Success ) {
|
if( match.Success ) {
|
||||||
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
||||||
"END_RULE", reader.Location);
|
"END_RULE", reader.Location );
|
||||||
ExpRuleSource _source = new ExpRuleSource(
|
ExpRuleSource _source = new ExpRuleSource(
|
||||||
match.Groups[ "RuleName" ].ToString(), transmitter );
|
match.Groups[ "RuleName" ].ToString(), transmitter );
|
||||||
string target = match.Groups[ "Target" ].ToString();
|
string target = match.Groups[ "Target" ].ToString();
|
||||||
@@ -289,7 +263,7 @@ namespace StgSharp.Script.Express
|
|||||||
Match match = _typeDefineBegin.Match( firstLine );
|
Match match = _typeDefineBegin.Match( firstLine );
|
||||||
if( match.Success ) {
|
if( match.Success ) {
|
||||||
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter(
|
||||||
"END_ENTITY", reader.Location);
|
"END_ENTITY", reader.Location );
|
||||||
ExpTypeSource _source = new ExpTypeSource(
|
ExpTypeSource _source = new ExpTypeSource(
|
||||||
match.Groups[ "TypeName" ].ToString(), transmitter );
|
match.Groups[ "TypeName" ].ToString(), transmitter );
|
||||||
transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() );
|
transmitter.WriteLine( match.Groups[ "Remaining" ].ToString() );
|
||||||
@@ -313,11 +287,37 @@ namespace StgSharp.Script.Express
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[GeneratedRegex(@"\s*CONSTANT")]
|
private static Regex
|
||||||
private static partial Regex GetConstDefineBegin();
|
_constDefineBegin = GetConstDefineBegin(),
|
||||||
|
_constDefineEnd = GetConstDefineEnd(),
|
||||||
|
_schemaBegin = GetSchemaBegin(),
|
||||||
|
_schemaEnd = new Regex(
|
||||||
|
@"END_SCHEMA;\s*--\s*(?<namespace>[A-Za-z0-9_]+)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_entityDefineBegin = new Regex(
|
||||||
|
@"\s*ENTITY\s*(?<TypeName>[A-Za-z0-9_]+)\s*",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_entityDefineEnd = new Regex(
|
||||||
|
@"\s*END_ENTITY;\s*--\s*(?<TypeName>[A-Za-z0-9_]+)\s*",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_typeDefineBegin = new Regex(
|
||||||
|
@"\s*TYPE\s+(?<TypeName>[A-Za-z0-9_]+)\s*=\s*(?<Remaining>[A-Z]+)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_typeDefineEnd = new Regex(
|
||||||
|
@"\s*END_TYPE\s*;\s*--\s*(?<TypeName>[a-zA-Z0-9_]+)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_functionDefineBegin = new Regex(
|
||||||
|
@"\s*FUNCTION\s*\s*(?<FunctionName>[a-zA-Z0-9_]+)\s*(?<Remaining>.*)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_functionDefineEnd = new Regex(
|
||||||
|
@"\s*END_FUNCTION\s*;\s*--\s*(?<FunctionName>[a-zA-Z0-9_]+)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_ruleDefineBegin = new Regex(
|
||||||
|
@"\s*RULE\s*(?<RuleName>[a-zA-Z0-9_]+)\s*FOR\s*\((?<Target>[a-zA-Z0-9_]*(\s*\)\s*;)?)",
|
||||||
|
RegexOptions.Compiled ),
|
||||||
|
_ruleDefineEnd = new Regex(
|
||||||
|
@"\s*END_RULE\s*;\s*--\s*(?<RuleName>[A-Za-z0-9_]+)",
|
||||||
|
RegexOptions.Compiled );
|
||||||
|
|
||||||
[GeneratedRegex(@"\s*SCHEMA\s*(?<namespace>[A-Za-z0-9_]+)\s?;")]
|
|
||||||
private static partial Regex GetSchemaBegin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// file="ExpReader.cs"
|
// file="ExpSource.cs"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// AuthorGroup: Nitload Space
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// Copyright (c) Nitload Space. All rights reserved.
|
||||||
@@ -64,10 +64,10 @@ namespace StgSharp.Script.Express
|
|||||||
_memoryReader = new StreamReader( _expMemoryMappedStream );
|
_memoryReader = new StreamReader( _expMemoryMappedStream );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Location => _location;
|
|
||||||
|
|
||||||
public bool IsEmpty => _memoryReader.EndOfStream;
|
public bool IsEmpty => _memoryReader.EndOfStream;
|
||||||
|
|
||||||
|
public int Location => _location;
|
||||||
|
|
||||||
// ~ExpFileSource()
|
// ~ExpFileSource()
|
||||||
// {
|
// {
|
||||||
// Dispose(disposing: false);
|
// Dispose(disposing: false);
|
||||||
@@ -79,10 +79,14 @@ namespace StgSharp.Script.Express
|
|||||||
GC.SuppressFinalize( this );
|
GC.SuppressFinalize( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EndWriting()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadLine()
|
public string ReadLine()
|
||||||
{
|
{
|
||||||
readLineSemaphore.Wait();
|
readLineSemaphore.Wait();
|
||||||
string line = _memoryReader.ReadLine();
|
string line = _memoryReader.ReadLine()!;
|
||||||
_location++;
|
_location++;
|
||||||
readLineSemaphore.Release();
|
readLineSemaphore.Release();
|
||||||
return line;
|
return line;
|
||||||
@@ -96,6 +100,11 @@ namespace StgSharp.Script.Express
|
|||||||
readLineSemaphore.Release();
|
readLineSemaphore.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IScriptSourceProvider Slice(int location, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Dispose( bool disposing )
|
protected virtual void Dispose( bool disposing )
|
||||||
{
|
{
|
||||||
if( !disposedValue ) {
|
if( !disposedValue ) {
|
||||||
|
|||||||
@@ -63,50 +63,50 @@ namespace StgSharp.Script.Express
|
|||||||
_isReadingMultiLineComment = false;
|
_isReadingMultiLineComment = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int LineNumber
|
||||||
|
{
|
||||||
|
get => _provider.Location;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsEmpty
|
public bool IsEmpty
|
||||||
{
|
{
|
||||||
get => (( string.IsNullOrEmpty( _lineCache ) ||
|
get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >=
|
||||||
_current >= _lineCache.Length )) && _provider.IsEmpty;
|
_lineCache.Length ) ) && _provider.IsEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Read code until end of a line. Lines in multi-line comment will be ignored. Line
|
/// <para> Read code until end of a line. Lines in multi-line comment will be ignored. Line
|
||||||
/// begins with part of multi-line comment will automatically remove the comment part, but
|
/// begins with part of multi-line comment will automatically remove the comment part, but
|
||||||
/// beginning with a full multi-line comment will not causing removing.</para> <para> (*Just
|
/// beginning with a full multi-line comment will not causing removing. </para> <para>(*Just
|
||||||
/// Like The Comment Here*) Will Not Be Removed </para>
|
/// Like The Comment Here*) Will Not Be Removed</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public unsafe ReadOnlySpan<char> ReadLine()
|
public unsafe ReadOnlySpan<char> ReadLine()
|
||||||
{
|
{
|
||||||
bool lineOver = string.IsNullOrEmpty(_lineCache) || _current >=
|
bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >=
|
||||||
_lineCache.Length;
|
_lineCache.Length;
|
||||||
while( lineOver || _isReadingMultiLineComment ) {
|
while( lineOver || _isReadingMultiLineComment ) {
|
||||||
if (lineOver)
|
if( lineOver ) {
|
||||||
{
|
do {
|
||||||
do
|
|
||||||
{
|
|
||||||
_lineCache = _provider.ReadLine();
|
_lineCache = _provider.ReadLine();
|
||||||
} 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 >=
|
lineOver = string.IsNullOrEmpty( _lineCache ) || _current >=
|
||||||
_lineCache.Length;
|
_lineCache.Length;
|
||||||
}
|
}
|
||||||
return _lineCache.AsSpan().Slice( _current );
|
return _lineCache.AsSpan().Slice( _current );
|
||||||
}
|
}
|
||||||
@@ -118,99 +118,96 @@ namespace StgSharp.Script.Express
|
|||||||
ReadOnlySpan<char> source = ReadLine();
|
ReadOnlySpan<char> source = ReadLine();
|
||||||
char c = source[ 0 ];
|
char c = source[ 0 ];
|
||||||
|
|
||||||
if (char.IsLetter(c)) {
|
if( char.IsLetter( c ) ) {
|
||||||
Match match = _nextWordTokenPattern.Match(
|
Match match = _nextWordTokenPattern.Match(
|
||||||
_lineCache, _current);
|
_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;
|
||||||
return source.Slice(0, end - begin);
|
return source.Slice( 0, end - begin );
|
||||||
} else {
|
} else {
|
||||||
throw new ExpInvalidTokenException(_current);
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else if (char.IsPunctuation(c) || char.IsSymbol(c)) {
|
} else if( char.IsPunctuation( c ) || char.IsSymbol( c ) ) {
|
||||||
switch (c) {
|
switch( c ) {
|
||||||
case '"':
|
case '"':
|
||||||
Match match = _nextStringLiteralPattern.Match(
|
Match match = _nextStringLiteralPattern.Match(
|
||||||
_lineCache, _current);
|
_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;
|
||||||
return source[..(end - begin)];
|
return source[ ..( end - begin ) ];
|
||||||
} else {
|
} else {
|
||||||
throw new ExpInvalidCharException('\"');
|
throw new ExpInvalidCharException( '\"' );
|
||||||
}
|
}
|
||||||
case '(':
|
case '(':
|
||||||
char cNext = source[1];
|
char cNext = source[ 1 ];
|
||||||
if (cNext == '*') {
|
if( cNext == '*' ) {
|
||||||
_isReadingMultiLineComment = true;
|
_isReadingMultiLineComment = true;
|
||||||
_current += 2;
|
_current += 2;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
} else {
|
} else {
|
||||||
return source[..1];
|
return source[ ..1 ];
|
||||||
}
|
}
|
||||||
case '-':
|
case '-':
|
||||||
|
|
||||||
// 1. -number
|
// 1. -number
|
||||||
// 2. -- comment
|
// 2. -- comment
|
||||||
// 3. - number type param
|
// 3. - number type param
|
||||||
cNext = source[1];
|
cNext = source[ 1 ];
|
||||||
if (char.IsNumber(cNext)) {
|
if( char.IsNumber( cNext ) ) {
|
||||||
match = _nextNumberLiteralPattern.Match(
|
match = _nextNumberLiteralPattern.Match(
|
||||||
_lineCache, _current);
|
_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;
|
||||||
return source[..(end - begin)];
|
return source[ ..( end - begin ) ];
|
||||||
} else {
|
} else {
|
||||||
throw new ExpInvalidTokenException(_current);
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else if (cNext == '-') {
|
} else if( cNext == '-' ) {
|
||||||
_lineCache = string.Empty;
|
_lineCache = string.Empty;
|
||||||
_current = 0;
|
_current = 0;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
} else {
|
} else {
|
||||||
_current++;
|
_current++;
|
||||||
return source[..1];
|
return source[ ..1 ];
|
||||||
}
|
}
|
||||||
case ')' or '[' or ']' or '{' or '}' or
|
case ')' or '[' or ']' or '{' or '}' or ':' or ';' or
|
||||||
'+' or '/' or '\\' or '*' or '.' or ',':
|
'+' or '/' or '\\' or '*' or '.' or ',':
|
||||||
_current++;
|
_current++;
|
||||||
return source[..1];
|
return source[ ..1 ];
|
||||||
default:
|
default:
|
||||||
throw new ExpInvalidCharException(c);
|
throw new ExpInvalidCharException( c );
|
||||||
}
|
}
|
||||||
} else if (char.IsNumber(c)) {
|
} else if( char.IsNumber( c ) ) {
|
||||||
Match match = _nextNumberLiteralPattern.Match(
|
Match match = _nextNumberLiteralPattern.Match(
|
||||||
_lineCache, _current);
|
_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;
|
||||||
return source[..(end - begin)];
|
return source[ ..( end - begin ) ];
|
||||||
} else {
|
} else {
|
||||||
throw new ExpInvalidTokenException(_current);
|
throw new ExpInvalidTokenException( _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[ Rest ].Index;
|
||||||
rest = match.Groups[Rest].Index;
|
|
||||||
_current = rest;
|
_current = rest;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
|
} else {
|
||||||
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
throw new ExpInvalidTokenException(_current);
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
throw new ExpInvalidCharException( c );
|
throw new ExpInvalidCharException( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using StgSharp.Script.Express;
|
||||||
|
using StgSharp.Threading;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
public class ExpTokenGenerator
|
||||||
|
{
|
||||||
|
private ExpExpressionTree _context;
|
||||||
|
private IScriptSourceProvider _provider;
|
||||||
|
private List<ExpToken> _contextLevelList;
|
||||||
|
|
||||||
|
public ExpTokenGenerator(IScriptSourceProvider sourceProvider)
|
||||||
|
{
|
||||||
|
_provider = sourceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AnalyseLine()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@ namespace StgSharp.Script
|
|||||||
{
|
{
|
||||||
public interface IExpressionToken
|
public interface IExpressionToken
|
||||||
{
|
{
|
||||||
|
|
||||||
long TokenTypeCode
|
long TokenTypeCode
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -49,6 +50,7 @@ namespace StgSharp.Script
|
|||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TryGetNextLevel(out ICollection<IExpressionToken> nextLevel);
|
bool TryGetNextLevel( out ICollection<IExpressionToken> nextLevel );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,14 +37,24 @@ namespace StgSharp.Script
|
|||||||
public interface IScriptSourceProvider
|
public interface IScriptSourceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool IsEmpty
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
int Location
|
int Location
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEmpty { get; }
|
void EndWriting();
|
||||||
|
|
||||||
string ReadLine();
|
string ReadLine();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return part of current provider.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="count">Count of lines to be sliced</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IScriptSourceProvider Slice(int location, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,28 +37,71 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace StgSharp.Script
|
namespace StgSharp.Script
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Transmit a continuous part of script code to interpreter or compiler.
|
||||||
|
/// This transmitter is designed for single-thread-write and single-thread
|
||||||
|
/// read. Any multi thread operation will cause undefined behaviour.
|
||||||
|
/// </summary>
|
||||||
public class ScriptSourceTransmitter : IScriptSourceProvider
|
public class ScriptSourceTransmitter : IScriptSourceProvider
|
||||||
{
|
{
|
||||||
private bool _isWriting = true;
|
private bool _isWriting = true;
|
||||||
private ConcurrentQueue<string> cache = new ConcurrentQueue<string>();
|
private List<string> _cache;
|
||||||
private int _location;
|
private string[] _buffer;
|
||||||
|
private int _begin, _index;
|
||||||
private readonly string _completeMark;
|
private readonly string _completeMark;
|
||||||
|
|
||||||
public ScriptSourceTransmitter( string endMark, int location )
|
public ScriptSourceTransmitter( string endMark, int start )
|
||||||
{
|
{
|
||||||
|
_cache = new List<string>();
|
||||||
_completeMark = endMark;
|
_completeMark = endMark;
|
||||||
_location = location;
|
_begin = start;
|
||||||
|
_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Location => _location;
|
public ScriptSourceTransmitter(string endMark, int start, int capacity)
|
||||||
|
{
|
||||||
|
_cache = new List<string>(capacity);
|
||||||
|
_completeMark = endMark;
|
||||||
|
_begin = start;
|
||||||
|
_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsEmpty => cache.IsEmpty;
|
internal ScriptSourceTransmitter(string[] buffer, int start)
|
||||||
|
{
|
||||||
|
_buffer = buffer;
|
||||||
|
_begin = start;
|
||||||
|
_isWriting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty => _isWriting ?
|
||||||
|
(_cache.Count == 0) :
|
||||||
|
(_buffer.Length == 0) || (_index >= _buffer.Length - 1);
|
||||||
|
|
||||||
|
public int Location => _begin + _index;
|
||||||
|
|
||||||
|
public bool IsFrozen => !_isWriting;
|
||||||
|
|
||||||
public string ReadLine()
|
public string ReadLine()
|
||||||
{
|
{
|
||||||
cache.TryDequeue( out string line );
|
if (_isWriting)
|
||||||
_location++;
|
{
|
||||||
return line;
|
throw new InvalidOperationException("Cannot read before all writing operation.");
|
||||||
|
}
|
||||||
|
var str = _buffer[_index];
|
||||||
|
_index++;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ReadLine(out int position)
|
||||||
|
{
|
||||||
|
if (_isWriting)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Cannot read before all writing operation.");
|
||||||
|
}
|
||||||
|
position = _begin + _index;
|
||||||
|
var str = _buffer[_index];
|
||||||
|
_index++;
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteLine( string line )
|
public void WriteLine( string line )
|
||||||
@@ -67,11 +110,31 @@ namespace StgSharp.Script
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( string.Equals( _completeMark, line ) ) {
|
if( string.Equals( _completeMark, line ) ) {
|
||||||
_isWriting = false;
|
EndWriting();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
cache.Enqueue( line );
|
_cache.Add( line );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EndWriting()
|
||||||
|
{
|
||||||
|
if (!_isWriting)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_isWriting = false;
|
||||||
|
_buffer = _cache.ToArray();
|
||||||
|
_cache = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IScriptSourceProvider Slice(int location, int count)
|
||||||
|
{
|
||||||
|
ArgumentOutOfRangeException.ThrowIfLessThan(location, _begin);
|
||||||
|
ArgumentOutOfRangeException.ThrowIfGreaterThan(
|
||||||
|
location + count,_begin + _buffer.Length);
|
||||||
|
return new ScriptSourceTransmitter(
|
||||||
|
_buffer.AsSpan().Slice( location, count ).ToArray(),
|
||||||
|
location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-1
@@ -1,4 +1,36 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file=".NETCoreApp,Version=v8.0.AssemblyAttributes.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.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
// <autogenerated />
|
// <autogenerated />
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(
|
||||||
|
".NETCoreApp,Version=v8.0",
|
||||||
|
FrameworkDisplayName = ".NET 8.0" )]
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="StgSharp.Script.AssemblyInfo.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.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// 此代码由工具生成。
|
// 此代码由工具生成。
|
||||||
@@ -11,13 +41,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute(
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
"1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51" )]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyProductAttribute( "StgSharp.Script" )]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyTitleAttribute( "StgSharp.Script" )]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute( "1.0.0.0" )]
|
||||||
|
|
||||||
// 由 MSBuild WriteCodeFragment 类生成。
|
// 由 MSBuild WriteCodeFragment 类生成。
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
+1
-1
@@ -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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51")]
|
||||||
[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")]
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
@@ -101,12 +101,11 @@ namespace StgSharp
|
|||||||
{
|
{
|
||||||
Console.Write(Environment.NewLine);
|
Console.Write(Environment.NewLine);
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
if (cache.Count > 32)
|
var slice = st.Slice(5,2);
|
||||||
{
|
while (!slice.IsEmpty)
|
||||||
Console.WriteLine("?");
|
{
|
||||||
}
|
Console.WriteLine(st.ReadLine());
|
||||||
/**/
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -135,10 +134,12 @@ namespace StgSharp
|
|||||||
/**/
|
/**/
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
|
throw;
|
||||||
/*
|
/*
|
||||||
StgSharp.WriteLog($"{ex}", LogType.Error);
|
StgSharp.WriteLog($"{ex}", LogType.Error);
|
||||||
if( true ) { }
|
if( true ) { }
|
||||||
Dialogue.PostError( ex );
|
Dialogue.PostError( ex );
|
||||||
|
/**/
|
||||||
Environment.Exit(-1);
|
Environment.Exit(-1);
|
||||||
/**/
|
/**/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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+7d0470d50b970b6493b9fca12bce74b01444ca46")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae94c265ae77870ea6498b624b6f71b78fb94e51")]
|
||||||
[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")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7d0470d50b970b6493b9fca12bce74b01444ca46/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/ae94c265ae77870ea6498b624b6f71b78fb94e51/*"}}
|
||||||
Reference in New Issue
Block a user