Daily update on 20250313-044921 by Nitload Youmu. Additional Message : Parser to TokenFlag.Member, improvement of exiting StgSharp platform
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -68,6 +68,12 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract IEnumerator<ExpElementInstanceBase> GetEnumerator();
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
|
||||
@@ -33,6 +33,7 @@ using System.Collections;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -88,6 +89,17 @@ namespace StgSharp.Script.Express
|
||||
return _constants.TryGetValue( name, out instance );
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
if( _constants.TryGetValue( name,
|
||||
out ExpElementInstanceBase? node ) ) {
|
||||
memberNode = node;
|
||||
return true;
|
||||
}
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void AddConstant( string name, ExpElementInstanceBase value )
|
||||
{
|
||||
_constants.Add( name, value );
|
||||
|
||||
@@ -63,5 +63,10 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,5 +75,11 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,5 +84,11 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ExpNode CreateInstanceNode()
|
||||
public override ExpElementInstanceNode CreateInstanceNode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -87,6 +87,12 @@ namespace StgSharp.Script.Express
|
||||
return type == null || type == ExpVoidType.Only;
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ExpVoidType : ExpTypeSource
|
||||
{
|
||||
|
||||
|
||||
@@ -39,7 +39,12 @@ namespace StgSharp.Script.Express
|
||||
public class ExpElementMemberNameNode : ExpNode
|
||||
{
|
||||
|
||||
public ExpElementMemberNameNode( Token source ) : base( source ) { }
|
||||
public ExpElementMemberNameNode( Token source )
|
||||
: base( source )
|
||||
{
|
||||
_nodeFlag = ExpNodeFlag.Name_Operator;
|
||||
CodeConvertTemplate = source.Value;
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ExpInstanceMemberNode.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.Helpers;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpInstanceMemberNode : ExpNode
|
||||
{
|
||||
|
||||
private ExpElementInstanceBase _instance;
|
||||
private ExpElementMemberNameNode _memberName;
|
||||
private ExpNode _member;
|
||||
|
||||
public ExpInstanceMemberNode(
|
||||
Token source,
|
||||
ExpElementInstanceBase instance,
|
||||
ExpElementMemberNameNode memberName )
|
||||
: base( source )
|
||||
{
|
||||
_instance = instance;
|
||||
_memberName = memberName;
|
||||
_instance.TryGetMember(
|
||||
memberName.CodeConvertTemplate, out _member );
|
||||
}
|
||||
|
||||
public override ExpNode Left => _instance;
|
||||
|
||||
public override ExpNode Right => _memberName;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _member.EqualityTypeConvert;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,22 @@ namespace StgSharp.Script.Express
|
||||
public class ExpInstanceReferenceNode : ExpNode
|
||||
{
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
private ExpElementInstanceBase _instance;
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
public ExpInstanceReferenceNode(
|
||||
Token source,
|
||||
ExpElementInstanceBase instance )
|
||||
: base( source )
|
||||
{
|
||||
_instance = instance;
|
||||
_nodeFlag = ( _instance._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) );
|
||||
}
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _instance.EqualityTypeConvert;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,5 +87,15 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
public ExpInstanceReferenceNode MakeReference( Token t )
|
||||
{
|
||||
return new ExpInstanceReferenceNode( t, this );
|
||||
}
|
||||
|
||||
public bool TryGetMember( string name, out ExpNode node )
|
||||
{
|
||||
return EqualityTypeConvert.TryGetMember( name, out node );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public void Analyse();
|
||||
|
||||
public bool TryGetMember( string name, out ExpNode memberNode );
|
||||
|
||||
}
|
||||
|
||||
public abstract class ExpInstantiableElement : IExpElementSource
|
||||
@@ -102,6 +104,8 @@ namespace StgSharp.Script.Express
|
||||
return element == null || element == ExpVoidElement.Only;
|
||||
}
|
||||
|
||||
public abstract bool TryGetMember( string name, out ExpNode memberNode );
|
||||
|
||||
private sealed class ExpVoidElement : ExpInstantiableElement
|
||||
{
|
||||
|
||||
@@ -125,6 +129,14 @@ namespace StgSharp.Script.Express
|
||||
return default!;
|
||||
}
|
||||
|
||||
public override bool TryGetMember(
|
||||
string name,
|
||||
out ExpNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,5 +168,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract ExpNode MakeReference( params object[] options );
|
||||
|
||||
public abstract bool TryGetMember( string name, out ExpNode memberNode );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace StgSharp.Script.Express
|
||||
break;
|
||||
case TokenFlag.Member:
|
||||
|
||||
// case1: name of a instance, make ref copy
|
||||
// case1: name of a _instance, make ref copy
|
||||
// case2: name of a function, make a function call
|
||||
// case3: unknown, make a instance member node, check while link
|
||||
// case3: unknown, make a _instance member node, check while link
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -37,6 +37,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ExpKeyWord = StgSharp.Script.Express.ExpCompile.KeyWord;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public partial class ExpNodeGenerator
|
||||
@@ -58,6 +60,8 @@ namespace StgSharp.Script.Express
|
||||
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
/// <summary>
|
||||
/// Append a token to top of cache. This method will automatically convert token to node if
|
||||
/// meets separators or operators.
|
||||
@@ -65,6 +69,7 @@ namespace StgSharp.Script.Express
|
||||
public void AppendToken( Token expToken )
|
||||
{
|
||||
switch( expToken.Flag ) {
|
||||
// operand, check precedence and push
|
||||
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
|
||||
int cmp = -1;
|
||||
processPrecedence:
|
||||
@@ -76,17 +81,37 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
_cache.PushOperand( expToken );
|
||||
break;
|
||||
|
||||
// literal, construxt and ppush
|
||||
case TokenFlag.Number or TokenFlag.String:
|
||||
_cache.PushOperand( expToken );
|
||||
break;
|
||||
|
||||
// instance ref, make ref and push
|
||||
// function call, push as operator
|
||||
// keyword, call TryParseKeyWord method to process
|
||||
// name of member in instance, parse as MemberNameNode
|
||||
case TokenFlag.Member:
|
||||
if( _context.TryGetFunction( expToken.Value, out _ ) ) {
|
||||
_cache.PushOperator( expToken );
|
||||
} else { }
|
||||
} else if( _local.TryGetMember(
|
||||
expToken.Value, out ExpNode? node ) ) {
|
||||
if( node is ExpElementInstanceBase instance ) {
|
||||
_cache.PushOperand(
|
||||
instance.MakeReference( expToken ) );
|
||||
return; // ref of an instance
|
||||
}
|
||||
} else if( TryParseKeyWord( expToken ) ) {
|
||||
return;
|
||||
} else {
|
||||
_cache.PushOperand(
|
||||
new ExpElementMemberNameNode( expToken ) );
|
||||
}
|
||||
break;
|
||||
case TokenFlag.Separator_Single: //a , ; found
|
||||
// if operator stack is not empty, convert all operators to node until meet a same separator
|
||||
// or OperandAheadOfSeparator property is less than certain value
|
||||
_cache.PushOperator( expToken );
|
||||
break;
|
||||
case TokenFlag.Separator_Left: //a ( [ { found
|
||||
// check if the last token is a function name, loop block or branch
|
||||
@@ -110,6 +135,8 @@ namespace StgSharp.Script.Express
|
||||
if( _cache.PopOperand( out Token t, out ExpNode? n ) ) {
|
||||
return n;
|
||||
} else { }
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,5 +161,20 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryParseKeyWord( Token t )
|
||||
{
|
||||
if( t.Value == ExpKeyWord.True ) {
|
||||
_cache.PushOperand( new ExpBoolNode( t, true ) );
|
||||
return true;
|
||||
} else if( t.Value == ExpKeyWord.False ) {
|
||||
_cache.PushOperand( new ExpBoolNode( t, false ) );
|
||||
return true;
|
||||
} else if( true ) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace StgSharp.Script.Express
|
||||
case ExpressCompileOption.Translate:
|
||||
return Compile_Translate( option );
|
||||
case ExpressCompileOption.Compile:
|
||||
throw new NotImplementedException();
|
||||
throw new NotSupportedException();
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
@@ -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+16b813646d8a2326551f05c69f727a292a719222")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9647c2c68a768a1d0a5a05cc1279d046403c4641")]
|
||||
[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/16b813646d8a2326551f05c69f727a292a719222/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/9647c2c68a768a1d0a5a05cc1279d046403c4641/*"}}
|
||||
Reference in New Issue
Block a user