Appearance
ExpressionEvaluator Class
Definition
Default implementation of ISymbolResolver and the primary entry point for evaluating expressions against an AstNode syntax tree.
- Namespace:
JASE.Expressions - Assembly:
JASE.Expressions.dll
Constructors
Properties
| Name | Description |
|---|---|
AllowPrivateAccessors | Gets a value indicating whether non-public members may be included when |
CaseInsensitiveVariables | Gets a value indicating whether variable, function, and type names are |
CaseSensitiveStringComparison | |
ContainsDivision | |
DatabaseComparators | |
EvaluationOptions | Gets performance and caching options for this evaluator instance. |
Methods
| Name | Description |
|---|---|
bool AddMethod(string name, MethodInfo methodInfo, string ns = null) | Registers a static method as a global function (legacy API alias). |
bool AddType(Type type, string alias = null) | Registers a CLR type under an alias so static members can be referenced in expressions (for example, Zip.Compress(...) after AddType(typeof(Zip), "Zip")). |
void AddVariable(string name, object value) | Registers or replaces a variable (legacy API alias for SetVariable). |
void AddVariable(string name, object value, Type type) | Registers or replaces a variable with an explicit type (legacy API alias). |
void ClearExpressionCache() | Clears cached parsed expressions for this evaluator instance. |
ExpressionEvaluator CreateLegacy(bool caseSensitive = null, bool defaultTypes = null, bool defaultMethods = null, bool caseSensitiveStringComparison = null, bool databaseComparators = null) | Creates an evaluator using legacy constructor parameter ordering for migration parity. |
T Evaluate(AstNode node) | Parses and evaluates an expression and converts the result to T. |
T Evaluate(ParsedExpression parsed) | Evaluates a previously parsed expression and converts the result. |
T Evaluate(string expression) | Parses and evaluates an expression and converts the result to T. |
object Evaluate(AstNode node) | Evaluates a compiled abstract syntax tree (AST) rooted at the specified node. |
object Evaluate(ParsedExpression parsed) | Evaluates a previously parsed expression. |
object Evaluate(string expression) | |
void MarkContainsDivision() | |
string Normalize(string expression) | Normalizes an expression string into legacy-compatible parenthesized text. |
ParsedExpression Parse(string expression) | Parses an expression once so it can be evaluated repeatedly without re-tokenizing or re-parsing. |
void ResetEvaluationState() | |
SymbolKind ResolveSymbolKind(string identifier, string parent = null) | Determines how an identifier should be interpreted in the current context, e.g. as a variable, function, field, property, or type. |
void SetFunction(string name, Func<object[], object> function) | Registers or replaces a global function that can be called from an expression using its name (for example, MyFunc(1, 2)). |
void SetVariable(string name, object value) | Sets or replaces a variable in the current evaluation scope. The variable's runtime type is inferred from the value argument. |
void SetVariable(string name, object value, Type type) | Sets or replaces a variable in the current evaluation scope with an explicit type description used for reflection and type metadata. |
bool TryGetFunction(string name, out Func<object[], object> function) | Attempts to resolve a previously registered global function by name. |
bool TryGetTypeClass(string name, out TypeClass value) | Attempts to resolve or obtain type metadata for a known CLR type. Implementations may support both simple type names (for example, "Guid") and fully qualified names (for example, "System.Guid"). |
bool TryGetVariable(string name, out object value) | Attempts to resolve a previously registered variable by name. |
Remarks
ExpressionEvaluator maintains three primary symbol tables:
Variables: name -> Variable (value + type metadata)Functions: name -> Func<object[], object>Types: name -> TypeClass It also recognizes a small set of known system types (e.g. Guid, DateTime) that can be referenced directly in expressions (for example, Guid.Parse(...)).