修复一些错误并更新README

This commit is contained in:
2025-10-09 14:40:58 +08:00
parent a09b3c1eb1
commit 63f09b6196
13 changed files with 83 additions and 60 deletions

View File

@@ -8,7 +8,9 @@ using System;
namespace Flee.ExpressionElements.Base namespace Flee.ExpressionElements.Base
{ {
[Obsolete("Base class for expression elements that operate on two child elements")] /// <summary>
/// 操作两个子元素的表达式元素的基类
/// </summary>
internal abstract class BinaryExpressionElement : ExpressionElement internal abstract class BinaryExpressionElement : ExpressionElement
{ {

View File

@@ -6,7 +6,9 @@ using Flee.InternalTypes;
namespace Flee.ExpressionElements.MemberElements namespace Flee.ExpressionElements.MemberElements
{ {
[Obsolete("Encapsulates an argument list")] /// <summary>
/// 封装参数列表的类
/// </summary>
internal class ArgumentList internal class ArgumentList
{ {
private readonly IList<ExpressionElement> _myElements; private readonly IList<ExpressionElement> _myElements;

View File

@@ -10,7 +10,9 @@ using Flee.PublicTypes;
namespace Flee.ExpressionElements.MemberElements namespace Flee.ExpressionElements.MemberElements
{ {
[Obsolete("Represents a function call")] /// <summary>
/// 表示函数调用的表达式元素
/// </summary>
internal class FunctionCallElement : MemberElement internal class FunctionCallElement : MemberElement
{ {
private readonly ArgumentList _myArguments; private readonly ArgumentList _myArguments;

View File

@@ -15,7 +15,9 @@ using System;
namespace Flee.ExpressionElements.MemberElements namespace Flee.ExpressionElements.MemberElements
{ {
[Obsolete("Represents an identifier")] /// <summary>
/// 表示标识符的表达式元素
/// </summary>
internal class IdentifierElement : MemberElement internal class IdentifierElement : MemberElement
{ {
private FieldInfo _myField; private FieldInfo _myField;

View File

@@ -9,7 +9,9 @@ using Flee.PublicTypes;
namespace Flee.ExpressionElements.MemberElements namespace Flee.ExpressionElements.MemberElements
{ {
[Obsolete("Element representing an array index")] /// <summary>
/// 表示数组索引的表达式元素
/// </summary>
internal class IndexerElement : MemberElement internal class IndexerElement : MemberElement
{ {
private ExpressionElement _myIndexerElement; private ExpressionElement _myIndexerElement;

View File

@@ -4,7 +4,9 @@ using System.Reflection.Emit;
namespace Flee.InternalTypes namespace Flee.InternalTypes
{ {
[Obsolete("Manages branch information and allows us to determine if we should emit a short or long branch")] /// <summary>
/// 管理分支信息,允许我们确定是否应该发出短分支或长分支
/// </summary>
internal class BranchManager internal class BranchManager
{ {
private readonly IList<BranchInfo> MyBranchInfos; private readonly IList<BranchInfo> MyBranchInfos;
@@ -143,7 +145,9 @@ namespace Flee.InternalTypes
} }
} }
[Obsolete("Represents a location in an IL stream")] /// <summary>
/// 表示IL流中的位置
/// </summary>
internal class ILLocation : IEquatable<ILLocation>, IComparable<ILLocation> internal class ILLocation : IEquatable<ILLocation>, IComparable<ILLocation>
{ {
private int _myPosition; private int _myPosition;
@@ -214,7 +218,9 @@ namespace Flee.InternalTypes
} }
} }
[Obsolete("Represents a branch from a start location to an end location")] /// <summary>
/// 表示从起始位置到结束位置的分支
/// </summary>
internal class BranchInfo internal class BranchInfo
{ {
private readonly ILLocation _myStart; private readonly ILLocation _myStart;

View File

@@ -160,7 +160,9 @@ namespace Flee.InternalTypes
public static object Instance => OurInstance; public static object Instance => OurInstance;
} }
[Obsolete("Helper class to resolve overloads")] /// <summary>
/// 用于解析重载的辅助类
/// </summary>
internal class CustomMethodInfo : IComparable<CustomMethodInfo>, IEquatable<CustomMethodInfo> internal class CustomMethodInfo : IComparable<CustomMethodInfo>, IEquatable<CustomMethodInfo>
{ {
/// <summary> /// <summary>
@@ -494,7 +496,9 @@ namespace Flee.InternalTypes
} }
} }
[Obsolete("Wraps an expression element so that it is loaded from a local slot")] /// <summary>
/// 包装表达式元素,使其从本地槽位加载
/// </summary>
internal class LocalBasedElement : ExpressionElement internal class LocalBasedElement : ExpressionElement
{ {
private readonly int _myIndex; private readonly int _myIndex;
@@ -514,7 +518,9 @@ namespace Flee.InternalTypes
public override System.Type ResultType => _myTarget.ResultType; public override System.Type ResultType => _myTarget.ResultType;
} }
[Obsolete("Helper class for storing strongly-typed properties")] /// <summary>
/// 用于存储强类型属性的辅助类
/// </summary>
internal class PropertyDictionary internal class PropertyDictionary
{ {
private readonly Dictionary<string, object> _myProperties; private readonly Dictionary<string, object> _myProperties;

View File

@@ -6,7 +6,9 @@ using System.Reflection.Emit;
namespace Flee.InternalTypes namespace Flee.InternalTypes
{ {
[Obsolete("Holds various shared utility methods")] /// <summary>
/// 包含各种共享实用方法的工具类
/// </summary>
internal class Utility internal class Utility
{ {
private Utility() private Utility()

View File

@@ -3,7 +3,9 @@ using System.Collections;
namespace Flee.Parsing namespace Flee.Parsing
{ {
[Obsolete("Creates a new parse tree analyzer.")] /// <summary>
/// 创建新的解析树分析器
/// </summary>
internal class Analyzer internal class Analyzer
{ {
public Analyzer() public Analyzer()

View File

@@ -5,8 +5,9 @@ using System.Text;
namespace Flee.Parsing namespace Flee.Parsing
{ {
/// <summary>
[Obsolete(" A base parser class. This class provides the standard parser interface, as well as token handling.")] /// 基础解析器类。此类提供标准解析器接口以及令牌处理功能
/// </summary>
internal abstract class Parser internal abstract class Parser
{ {
private bool _initialized; private bool _initialized;

View File

@@ -8,6 +8,9 @@ using Flee.Parsing;
namespace Flee.PublicTypes namespace Flee.PublicTypes
{ {
/// <summary>
/// 表达式上下文类,提供表达式编译和执行的环境
/// </summary>
public sealed class ExpressionContext public sealed class ExpressionContext
{ {
@@ -186,11 +189,22 @@ namespace Flee.PublicTypes
return this.CloneInternal(true); return this.CloneInternal(true);
} }
/// <summary>
/// 编译动态表达式,返回类型在运行时确定
/// </summary>
/// <param name="expression">要编译的表达式字符串</param>
/// <returns>编译后的动态表达式</returns>
public IDynamicExpression CompileDynamic(string expression) public IDynamicExpression CompileDynamic(string expression)
{ {
return new Flee.InternalTypes.Expression<object>(expression, this, false); return new Flee.InternalTypes.Expression<object>(expression, this, false);
} }
/// <summary>
/// 编译泛型表达式,返回指定类型的结果
/// </summary>
/// <typeparam name="TResultType">表达式结果的类型</typeparam>
/// <param name="expression">要编译的表达式字符串</param>
/// <returns>编译后的泛型表达式</returns>
public IGenericExpression<TResultType> CompileGeneric<TResultType>(string expression) public IGenericExpression<TResultType> CompileGeneric<TResultType>(string expression)
{ {
return new Flee.InternalTypes.Expression<TResultType>(expression, this, true); return new Flee.InternalTypes.Expression<TResultType>(expression, this, true);

View File

@@ -7,7 +7,7 @@ using System.Reflection;
namespace Flee.PublicTypes namespace Flee.PublicTypes
{ {
/// <summary> /// <summary>
/// /// 变量集合类,用于管理表达式中使用的变量
/// </summary> /// </summary>
public sealed class VariableCollection : IDictionary<string, object> public sealed class VariableCollection : IDictionary<string, object>
{ {

View File

@@ -1,48 +1,30 @@
# Flee (Supports Net6.0, Net5.0, Netstandard2.1, Netstandard2.0) # FLEE
Fast Lightweight Expression Evaluator. 快速轻量级表达式求值器。
Convert this project vb.net to c#.
## Project Description ## 项目描述
Flee is an expression parser and evaluator for the .NET framework. It allows you to compute the value of string expressions such as sqrt(a^2 + b^2) at runtime. It uses a custom compiler, strongly-typed expression language, and lightweight codegen to compile expressions directly to IL. This means that expression evaluation is extremely fast and efficient. FLEE 是一个用于 .NET 框架的表达式解析器和求值器。它允许您在运行时计算字符串表达式的值,例如 sqrt(a^2 + b^2)。它使用自定义编译器、强类型表达式语言和轻量级代码生成器将表达式直接编译为 IL。这意味着表达式求值极其快速和高效。
## Features ## 功能特性
* Fast and efficient expression evaluation * 快速高效的表达式求值
* Small, lightweight library * 小巧轻量的库
* Compiles expressions to IL using a custom compiler, lightweight codegen, and the DynamicMethod class * 使用自定义编译器、轻量级代码生成器和 DynamicMethod 类将表达式编译为 IL
* Expressions (and the IL generated for them) are garbage-collected when no longer used * 表达式(及其生成的 IL在不再使用时会被垃圾回收
* Does not create any dynamic assemblies that stay in memory * 不会创建任何保留在内存中的动态程序集
* Backed by a comprehensive suite of unit tests * 由全面的单元测试套件支持
* Culture-sensitive decimal point * 支持区域敏感的小数点
* Fine-grained control of what types an expression can use * 对表达式可使用的类型进行细粒度控制
* Supports all arithmetic operations including the power (^) operator * 支持所有算术运算,包括幂运算符 (^)
* Supports string, char, boolean, and floating-point literals * 支持字符串、字符、布尔值和浮点数字面量
* Supports 32/64 bit, signed/unsigned, and hex integer literals * 支持 32/64 位、有符号/无符号和十六进制整数字面量
* Features a true conditional operator * 具有真正的条件运算符
* Supports short-circuited logical operations * 支持短路逻辑运算
* Supports arithmetic, comparison, implicit, and explicit overloaded operators * 支持算术、比较、隐式和显式重载运算符
* Variables of any type can be dynamically defined and used in expressions * 可以动态定义任何类型的变量并在表达式中使用
* CalculationEngine: Reference other expressions in an expression and recalculate in natural order * 计算引擎:在表达式中引用其他表达式并按自然顺序重新计算
* Expressions can index arrays and collections, access fields and properties, and call functions on various types * 表达式可以索引数组和集合、访问字段和属性,以及调用各种类型的函数
* Generated IL can be saved to an assembly and viewed with a disassembler * 生成的 IL 可以保存到程序集中并使用反汇编器查看
### Installing Flee ## 许可
本FLEE是从原Flee发布者处未经许可更改与改进得来, 用于源码编译
You should install [Flee with NuGet](https://www.nuget.org/packages/Flee): 原Flee发布者发布的Flee 使用 LGPL 许可证。这意味着只要您动态链接(即添加引用)到官方发布的程序集,就可以在商业和非商业应用程序中使用它。
Install-Package Flee
Or via the .NET Core command line interface:
dotnet add package Flee
## NuGet Packages
| Name | NuGet |
| :--- | :--- |
| [Flee](https://www.nuget.org/packages/Flee) | [![Flee](https://img.shields.io/badge/nuget-v2.0.0-blue.svg)](https://www.nuget.org/packages/Flee)
## More information
* [Examples](https://github.com/mparlak/Flee/wiki/Examples) to learn how to create and evaluate expressions.
## License
Flee is licensed under the LGPL. This means that as long as you dynamically link (ie: add a reference) to the officially released assemblies, you can use it in commercial and non-commercial applications.