Daily update on 20250304-070522 by Nitload Youmu. Additional Message : None
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -32,11 +32,20 @@ using System;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpBuiltinConstant<T> : ExpLiteralGenericNode<T>
|
||||
internal partial class ExpSchema_Nitload
|
||||
{
|
||||
|
||||
internal ExpBuiltinConstant( string name, T value )
|
||||
: base( name, null!, value ) { }
|
||||
public ExpTypeSource IntType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ExpTypeSource FloatType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,12 +68,6 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract IEnumerator<ExpElementInstanceBase> GetEnumerator();
|
||||
|
||||
public override sealed bool IsConvertable(
|
||||
ExpInstantiableElement targetType )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace StgSharp.Script.Express
|
||||
protected internal (int min, int max) _range;
|
||||
protected internal ExpElementType _memberType;
|
||||
|
||||
protected ExpCollectionInstanceBase( string name, ExpSchema context )
|
||||
: base( name ) { }
|
||||
protected ExpCollectionInstanceBase( string name ) : base( name ) { }
|
||||
|
||||
public abstract ExpCollectionBase CollectionValue
|
||||
{
|
||||
|
||||
@@ -34,40 +34,84 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public enum ExpLogic
|
||||
public enum ExpLogicValue
|
||||
{
|
||||
|
||||
Unknown = 0,
|
||||
False = 1,
|
||||
True = 2,
|
||||
True,
|
||||
False,
|
||||
Unknown
|
||||
|
||||
}
|
||||
|
||||
public static class LogicConverter
|
||||
public struct ExpLogic
|
||||
{
|
||||
public static bool? AsNullableBool(this ExpLogic l)
|
||||
|
||||
public static readonly ExpLogic False = new ExpLogic(
|
||||
ExpLogicValue.False );
|
||||
|
||||
public static readonly ExpLogic True = new ExpLogic(
|
||||
ExpLogicValue.True );
|
||||
public static readonly ExpLogic Unknown = new ExpLogic(
|
||||
ExpLogicValue.Unknown );
|
||||
|
||||
private readonly ExpLogicValue _value;
|
||||
|
||||
public ExpLogic( ExpLogicValue value )
|
||||
{
|
||||
switch (l)
|
||||
{
|
||||
case ExpLogic.Unknown:
|
||||
return null;
|
||||
case ExpLogic.False:
|
||||
return false;
|
||||
case ExpLogic.True:
|
||||
return true;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public static ExpLogic AsNullableInt(this bool? b)
|
||||
public bool IsTrue => _value == ExpLogicValue.True;
|
||||
|
||||
public bool IsFalse => _value == ExpLogicValue.False;
|
||||
|
||||
public bool IsUnknown => _value == ExpLogicValue.Unknown;
|
||||
|
||||
public override string ToString() => _value.ToString();
|
||||
|
||||
// NOT !
|
||||
public static ExpLogic operator !( ExpLogic a )
|
||||
{
|
||||
return b switch
|
||||
{
|
||||
null => ExpLogic.Unknown,
|
||||
true => ExpLogic.True,
|
||||
false => ExpLogic.False,
|
||||
};
|
||||
return a.IsTrue ? False : a.IsFalse ? True : Unknown;
|
||||
}
|
||||
|
||||
// AND &
|
||||
public static ExpLogic operator &( ExpLogic a, ExpLogic b )
|
||||
{
|
||||
if( a.IsFalse || b.IsFalse ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if( a.IsUnknown || b.IsUnknown ) {
|
||||
return Unknown;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
// XOR ^
|
||||
public static ExpLogic operator ^( ExpLogic a, ExpLogic b )
|
||||
{
|
||||
if( a.IsUnknown || b.IsUnknown ) {
|
||||
return Unknown;
|
||||
}
|
||||
|
||||
return ( a.IsTrue ^ b.IsTrue ) ? True : False;
|
||||
}
|
||||
|
||||
// OR |
|
||||
public static ExpLogic operator |( ExpLogic a, ExpLogic b )
|
||||
{
|
||||
if( a.IsTrue || b.IsTrue ) {
|
||||
return True;
|
||||
}
|
||||
|
||||
if( a.IsUnknown || b.IsUnknown ) {
|
||||
return Unknown;
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ using System.Collections;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
using static StgSharp.Script.Express.ExpCompile;
|
||||
|
||||
@@ -80,7 +77,7 @@ namespace StgSharp.Script.Express
|
||||
string name,
|
||||
out ExpFunctionSource f )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return FunctionDict.TryGetValue( name, out f! );
|
||||
}
|
||||
|
||||
public override bool TryGetRule( string name, out ExpRuleSource r )
|
||||
@@ -131,9 +128,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
ConstDict = new Dictionary<string, ExpElementInstanceBase>(
|
||||
Multiplexer ) {
|
||||
{ PoolString( "PI" ), new ExpBuiltinConstant<float>(
|
||||
{ PoolString( "PI" ), new ExpLiteralGenericNode<float>(
|
||||
PoolString( "PI" ), MathF.PI ) },
|
||||
{ PoolString( "E" ), new ExpBuiltinConstant<float>(
|
||||
{ PoolString( "E" ), new ExpLiteralGenericNode<float>(
|
||||
PoolString( "E" ), MathF.E ) },
|
||||
}.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ExpElementInstanceNode.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpElementInstanceNode : ExpNode
|
||||
{
|
||||
|
||||
private ExpInstantiableElement _element;
|
||||
|
||||
public ExpElementInstanceNode(
|
||||
string varName,
|
||||
ExpInstantiableElement element )
|
||||
: base( varName )
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => _element;
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,10 +43,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpNode _indexExpression;
|
||||
|
||||
public ExpIndexOfNode(
|
||||
ExpSchema context,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
private ExpIndexOfNode(
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
: base( ExpCompile.PoolString( "[" ) )
|
||||
{
|
||||
_collection = instance;
|
||||
@@ -60,5 +59,16 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _collection.EqualityTypeConvert;
|
||||
|
||||
public static ExpIndexOfNode Create(
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
{
|
||||
if( !indexExpression.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", indexExpression.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpIndexOfNode( instance, indexExpression );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace StgSharp.Script.Express
|
||||
private readonly ExpBuiltinType _type;
|
||||
private readonly T _value;
|
||||
|
||||
public ExpLiteralGenericNode( string name, ExpSchema context, T value )
|
||||
public ExpLiteralGenericNode( string name, T value )
|
||||
: base( name )
|
||||
{
|
||||
_value = value;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryNotNegation( ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryNegation( ExpNode operand )
|
||||
{
|
||||
if( !operand.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
@@ -73,5 +73,19 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryNot( ExpNode operand )
|
||||
{
|
||||
if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) ==
|
||||
0 ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Bool or Logic", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpUnaryOperatorNode( ExpCompile.KeyWord.NOT )
|
||||
{
|
||||
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Logic,
|
||||
CodeConvertTemplate = "! {0}",
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
|
||||
/// <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
|
||||
/// beginning with a full multi-line comment will not causing removing.</para> <para> (*Just
|
||||
/// Like The Comment Here*) Will Not Be Removed </para>
|
||||
/// beginning with a full multi-line comment will not causing removing. </para> <para>(*Just
|
||||
/// Like The Comment Here*) Will Not Be Removed</para>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public unsafe ReadOnlySpan<char> ReadLine()
|
||||
@@ -185,7 +185,7 @@ namespace StgSharp.Script.Express
|
||||
return _last;
|
||||
case '-':
|
||||
|
||||
// 1. -number
|
||||
// 1. - number
|
||||
// 2. -- comment
|
||||
// 3. - number type param(UNARY)
|
||||
// 4. param - param(BINARY)
|
||||
|
||||
@@ -95,15 +95,14 @@ namespace StgSharp.Script.Express
|
||||
_operandsNode.Push( node );
|
||||
}
|
||||
|
||||
public AbstractSyntaxTree<ExpNode, IExpElementSource> CloseAndDispose(
|
||||
)
|
||||
public AbstractSyntaxTree<ExpNode, IExpElementSource> CloseAndDispose()
|
||||
{
|
||||
if( _operandsToken.Count != 0 ) {
|
||||
// convert rest to AST
|
||||
}
|
||||
return new AbstractSyntaxTree<ExpNode, IExpElementSource>();
|
||||
}
|
||||
|
||||
/*
|
||||
public ExpNode GenerateNode( Token t )
|
||||
{
|
||||
switch( t.Flag ) {
|
||||
@@ -131,10 +130,9 @@ namespace StgSharp.Script.Express
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**/
|
||||
|
||||
public int GetNextOperandCache(
|
||||
out Token? token,
|
||||
out ExpNode? node )
|
||||
public int GetNextOperandCache( out Token? token, out ExpNode? node )
|
||||
{
|
||||
if( _operandsNode.Count != 0 ) {
|
||||
node = _operandsNode.Pop();
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace StgSharp.Script.Express
|
||||
{
|
||||
public partial class ExpNodeGenerator
|
||||
{
|
||||
|
||||
/*
|
||||
public ExpNode GenerateUnaryToken( Token t )
|
||||
{
|
||||
switch( t.Value ) {
|
||||
@@ -52,6 +52,7 @@ namespace StgSharp.Script.Express
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d12bbbd873ec13306fdfa5255965188674ed417c")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+825e68853cd1738287eecc8a4390ee9c78550308")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
||||
[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/ccef0de6f686f94da655b0e7d854d0acaf907d04/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/825e68853cd1738287eecc8a4390ee9c78550308/*"}}
|
||||
Reference in New Issue
Block a user