Daily update on 20250305-052510 by Nitload Youmu. Additional Message : message
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -83,8 +83,8 @@ namespace StgSharp.Script.Express
|
|||||||
Remove = "REMOVE",
|
Remove = "REMOVE",
|
||||||
ANDOR = "ANDOR",
|
ANDOR = "ANDOR",
|
||||||
GetIndex = "[",
|
GetIndex = "[",
|
||||||
UnaryAdd = "+",
|
UnaryPlus = "+",
|
||||||
UnarySub = "-",
|
UnaryMinus = "-",
|
||||||
Exp = "**";
|
Exp = "**";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
|
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
|
||||||
|
|
||||||
public static ExpUnaryOperatorNode UnaryNegation( ExpNode operand )
|
public static ExpUnaryOperatorNode UnaryMinus( ExpNode operand )
|
||||||
{
|
{
|
||||||
if( !operand.IsNumber ) {
|
if( !operand.IsNumber ) {
|
||||||
throw new ExpInvalidTypeException(
|
throw new ExpInvalidTypeException(
|
||||||
@@ -87,5 +87,20 @@ namespace StgSharp.Script.Express
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ExpUnaryOperatorNode UnaryPlus( ExpNode operand )
|
||||||
|
{
|
||||||
|
if( !operand.IsNumber ) {
|
||||||
|
throw new ExpInvalidTypeException(
|
||||||
|
"Number", operand.EqualityTypeConvert.Name );
|
||||||
|
}
|
||||||
|
bool isFloat =
|
||||||
|
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0;
|
||||||
|
return new ExpUnaryOperatorNode( ExpCompile.KeyWord.SUB )
|
||||||
|
{
|
||||||
|
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number,
|
||||||
|
CodeConvertTemplate = "+ {0}",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ using CommunityToolkit.HighPerformance.Buffers;
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
@@ -96,11 +97,11 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public string Name => _name;
|
public string Name => _name;
|
||||||
|
|
||||||
public virtual void AppendNode( ExpNode nextToken )
|
public void AppendNode( ExpNode nextNode )
|
||||||
{
|
{
|
||||||
Next.Previous = nextToken;
|
Next.Previous = nextNode;
|
||||||
nextToken.Next = Next;
|
nextNode.Next = Next;
|
||||||
Next = nextToken;
|
Next = nextNode;
|
||||||
Next.Previous = this;
|
Next.Previous = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +115,20 @@ namespace StgSharp.Script.Express
|
|||||||
return node == ExpEmptyNode._only || node == null;
|
return node == ExpEmptyNode._only || node == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||||
|
public static ExpNode NonOperation( string name )
|
||||||
|
{
|
||||||
|
return new ExpEmptyNode( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrependNode( ExpNode previousNode )
|
||||||
|
{
|
||||||
|
Previous.Next = previousNode;
|
||||||
|
previousNode.Previous = Previous;
|
||||||
|
Previous = previousNode;
|
||||||
|
previousNode.Next = this;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool VerifyTypeConvertable( ExpNode left, ExpNode right )
|
public static bool VerifyTypeConvertable( ExpNode left, ExpNode right )
|
||||||
{
|
{
|
||||||
IExpElementSource tLeft = left.EqualityTypeConvert,
|
IExpElementSource tLeft = left.EqualityTypeConvert,
|
||||||
@@ -131,6 +146,8 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public ExpEmptyNode() : base( string.Empty ) { }
|
public ExpEmptyNode() : base( string.Empty ) { }
|
||||||
|
|
||||||
|
public ExpEmptyNode( string name ) : base( name ) { }
|
||||||
|
|
||||||
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;
|
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;
|
||||||
|
|
||||||
public override ExpNode Left => _only;
|
public override ExpNode Left => _only;
|
||||||
|
|||||||
@@ -66,88 +66,55 @@ namespace StgSharp.Script.Express
|
|||||||
/// meets separators or operators.
|
/// meets separators or operators.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="expToken"></param>
|
/// <param name="expToken"></param>
|
||||||
public void AppendToken( Token expToken )
|
public ExpNode AppendToken( Token expToken )
|
||||||
{
|
{
|
||||||
switch( expToken.Flag ) {
|
switch( expToken.Flag ) {
|
||||||
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
|
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
|
||||||
|
|
||||||
_operandsToken.Push( expToken );
|
_operandsToken.Push( expToken );
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Number or TokenFlag.String or TokenFlag.Member:
|
case TokenFlag.Number or TokenFlag.String or TokenFlag.Member:
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Separator_Single:
|
case TokenFlag.Separator_Single: // a , ; found
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Separator_Left:
|
case TokenFlag.Separator_Left: //a ( [ { found
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Separator_Right:
|
case TokenFlag.Separator_Right: //a } ] ) found
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Index_Left:
|
case TokenFlag.Index_Left: // a [ found
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Index_Right:
|
case TokenFlag.Index_Right: // a ] found
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CacheNextOperandNode( ExpNode node )
|
public ExpNode GetNextOperandCache()
|
||||||
{
|
{
|
||||||
_operandsNode.Push( node );
|
if( _operandsNode.Count != 0 ) {
|
||||||
|
return _operandsNode.Pop();
|
||||||
|
}
|
||||||
|
if( _operandsToken.Count != 0 ) {
|
||||||
|
Token token = _operandsToken.Pop();
|
||||||
|
}
|
||||||
|
return ExpNode.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractSyntaxTree<ExpNode, IExpElementSource> CloseAndDispose()
|
//ConvertOneOperator not finish
|
||||||
|
private void ConvertOneOperator()
|
||||||
{
|
{
|
||||||
if( _operandsToken.Count != 0 ) {
|
Token @operator = _operators.Pop();
|
||||||
// convert rest to AST
|
switch( @operator.Flag ) {
|
||||||
}
|
|
||||||
return new AbstractSyntaxTree<ExpNode, IExpElementSource>();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public ExpNode GenerateNode( Token t )
|
|
||||||
{
|
|
||||||
switch( t.Flag ) {
|
|
||||||
case TokenFlag.Symbol_Unary:
|
case TokenFlag.Symbol_Unary:
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Symbol_Binary:
|
case TokenFlag.Symbol_Binary:
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Number:
|
|
||||||
break;
|
|
||||||
case TokenFlag.String:
|
|
||||||
break;
|
|
||||||
case TokenFlag.Member:
|
|
||||||
break;
|
|
||||||
case TokenFlag.Separator_Single:
|
|
||||||
break;
|
|
||||||
case TokenFlag.Separator_Left:
|
|
||||||
break;
|
|
||||||
case TokenFlag.Separator_Right:
|
|
||||||
break;
|
|
||||||
case TokenFlag.Index_Left:
|
case TokenFlag.Index_Left:
|
||||||
break;
|
break;
|
||||||
case TokenFlag.Index_Right:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**/
|
|
||||||
|
|
||||||
public int GetNextOperandCache( out Token? token, out ExpNode? node )
|
|
||||||
{
|
|
||||||
if( _operandsNode.Count != 0 ) {
|
|
||||||
node = _operandsNode.Pop();
|
|
||||||
token = null!;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if( _operandsToken.Count != 0 ) {
|
|
||||||
token = _operandsToken.Pop();
|
|
||||||
node = null!;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
token = null;
|
|
||||||
node = null!;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="FunctionCallingGenerator.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;
|
||||||
|
|
||||||
|
using static StgSharp.Script.Express.ExpCompile;
|
||||||
|
|
||||||
|
namespace StgSharp.Script.Express
|
||||||
|
{
|
||||||
|
public partial class ExpNodeGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
private bool _isCallingFunction = false;
|
||||||
|
private Stack<int> _callDepth = new Stack<int>();
|
||||||
|
|
||||||
|
private void EnterFunctionCalling( Token funcNameToken )
|
||||||
|
{
|
||||||
|
_isCallingFunction = true;
|
||||||
|
_callDepth.Push( _operandsToken.Count );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExitFunctionCalling()
|
||||||
|
{
|
||||||
|
_callDepth.Pop();
|
||||||
|
if( _callDepth.Count == 0 ) {
|
||||||
|
_isCallingFunction = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO cannot process occasion of void input or null at first
|
||||||
|
private void MergeFunctionCallingParameter()
|
||||||
|
{
|
||||||
|
if( _callDepth.Peek() == _operandsToken.Count ) {
|
||||||
|
_operandsNode.Peek()
|
||||||
|
.PrependNode(
|
||||||
|
ExpNode.NonOperation( PoolString( "FuncParam" ) ) );
|
||||||
|
} else {
|
||||||
|
//TODO compile the param expression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,21 +38,48 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
public partial class ExpNodeGenerator
|
public partial class ExpNodeGenerator
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
public ExpNode GenerateUnaryToken( Token t )
|
public bool TryGenerateBinaryNode( Token t, out ExpNode node )
|
||||||
{
|
{
|
||||||
|
ExpNode left = GetNextOperandCache();
|
||||||
|
ExpNode right = GetNextOperandCache();
|
||||||
switch( t.Value ) {
|
switch( t.Value ) {
|
||||||
case ExpCompile.KeyWord.UnaryAdd:
|
case ExpCompile.KeyWord.ADD:
|
||||||
break;
|
node = ExpBinaryOperatorNode.Add( left, right );
|
||||||
case ExpCompile.KeyWord.UnarySub:
|
return true;
|
||||||
break;
|
case ExpCompile.KeyWord.SUB:
|
||||||
case ExpCompile.KeyWord.NOT:
|
node = ExpBinaryOperatorNode.Sub( left, right );
|
||||||
break;
|
return true;
|
||||||
|
case ExpCompile.KeyWord.MUL:
|
||||||
|
node = ExpBinaryOperatorNode.Mul( left, right );
|
||||||
|
return true;
|
||||||
|
case ExpCompile.KeyWord.DIV:
|
||||||
|
node = ExpBinaryOperatorNode.Div( left, right );
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
node = ExpNode.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGenerateUnaryNode( Token t, out ExpNode node )
|
||||||
|
{
|
||||||
|
ExpNode operand = GetNextOperandCache();
|
||||||
|
switch( t.Value ) {
|
||||||
|
case ExpCompile.KeyWord.UnaryPlus:
|
||||||
|
node = ExpUnaryOperatorNode.UnaryPlus( operand );
|
||||||
|
return true;
|
||||||
|
case ExpCompile.KeyWord.UnaryMinus:
|
||||||
|
node = ExpUnaryOperatorNode.UnaryMinus( operand );
|
||||||
|
return true;
|
||||||
|
case ExpCompile.KeyWord.NOT:
|
||||||
|
node = ExpUnaryOperatorNode.UnaryNot( operand );
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
node = ExpNode.Empty;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,5 +86,7 @@ namespace StgSharp.Script
|
|||||||
|
|
||||||
void AppendNode( TNode nextToken );
|
void AppendNode( TNode nextToken );
|
||||||
|
|
||||||
|
void PrependNode( TNode previusNode );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+825e68853cd1738287eecc8a4390ee9c78550308")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5d4f516a2836a307ab61298b3d96c20a81324634")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user