重写脚本解释器的实现,提高其可读性。

This commit is contained in:
fengjiayi
2025-07-13 17:34:03 +08:00
parent 6141d2c1c1
commit 01ab905155
42 changed files with 1747 additions and 715 deletions

View File

@@ -22,7 +22,7 @@ namespace Serein.Script.Node
/// </summary>
public ASTNode Value { get; }
public AssignmentNode(ASTNode targetObject, ASTNode value) => (Target, Value) = (targetObject, value);
public AssignmentNode(ASTNode target, ASTNode value) => (Target, Value) = (target, value);
}

View File

@@ -22,8 +22,28 @@ namespace Serein.Script.Node
/// <summary>
/// 字段名称及字段类型
/// </summary>
[Obsolete("此属性已经过时将会改为Dictionary<string, string>", false)]
public Dictionary<string, Type> Fields { get; }
/// <summary>
/// 字段名称及字段类型(Kvp[fididName:fidleTypeName])
/// </summary>
public Dictionary<string, string> FieldInfos { get; }
public ClassTypeDefinitionNode(Dictionary<string, string> fields, string className)
{
this.FieldInfos = fields;
this.ClassName = className;
}
[Obsolete("此构造方法已经过时,可能在下一个版本中移除", false)]
public ClassTypeDefinitionNode(Dictionary<string, Type> fields, string className)
{
this.Fields = fields;
this.ClassName = className;
}
[Obsolete("此构造方法已经过时,可能在下一个版本中移除", false)]
public ClassTypeDefinitionNode(Dictionary<string, Type> fields, string className, bool isOverlay)
{
this.Fields = fields;

View File

@@ -20,10 +20,33 @@ namespace Serein.Script.Node
/// 索引来源
/// </summary>
public ASTNode Index { get; }
public CollectionIndexNode(ASTNode TargetValue,ASTNode indexValue)
public CollectionIndexNode(ASTNode Collection, ASTNode indexValue)
{
this.Collection = TargetValue;
this.Collection = Collection;
this.Index = indexValue;
}
}
/// <summary>
/// 集合赋值节点
/// </summary>
public class CollectionAssignmentNode : ASTNode
{
/// <summary>
/// 集合来源
/// </summary>
public CollectionIndexNode Collection { get; }
/// <summary>
/// 索引来源
/// </summary>
public ASTNode Value { get; }
public CollectionAssignmentNode(CollectionIndexNode collection, ASTNode value)
{
this.Collection = collection;
this.Value = value;
}
}
}

View File

@@ -1,13 +1,13 @@
namespace Serein.Script.Node
{
public class ObjectMemberExpressionNode : ASTNode
public class ExpressionNode : ASTNode
{
/// <summary>
/// 对象成员(嵌套获取)
/// </summary>
public ASTNode Value { get; }
public ObjectMemberExpressionNode(ASTNode value)
public ExpressionNode(ASTNode value)
{
this.Value = value;
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Script.Node
namespace Serein.Script.Node.FlowControl
{
/// <summary>
/// 条件节点

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Script.Node
namespace Serein.Script.Node.FlowControl
{
/// <summary>
/// 程序入口

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Script.Node
namespace Serein.Script.Node.FlowControl
{
/// <summary>
/// 返回值

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Script.Node
namespace Serein.Script.Node.FlowControl
{
/// <summary>
/// 循环条件节点