Expression

References
[IoId("00000000-1369-45e5-9517-944544f770d8")] public sealed class Expression : IStorable
Represents an expression for a specific input output type.

Constructors

Expression

#
public Expression(IReader reader)
reader (IReader)

Properties

CompilerCode

#
public string CompilerCode { get; }
Gets the modified source code that was used to compile this expression.

Identity

#
public static Expression Identity { get; }
Gets an identity expression for a single variable 'x'.

NaN

#
public static Expression NaN { get; }
Gets an expression which always returns double.NaN.

Undeclareds

#
public IEnumerable<string> Undeclareds { get; }
Iterate over all global variables in this expression. This expression probably cannot be evaluated unless a Resolver is supplied which provides values for all these globals.

UserCode

#
public string UserCode { get; }
Gets the source code with which this expression is associated.

Zero

#
public static Expression Zero { get; }
Gets an expression which immediately returns zero.

Methods

Constant

#
public static Expression Constant(string code, object value)
Create an expression with a constant return value.
code (string)
value (object)

Evaluate

#
public object Evaluate()
Evaluate this expression. If the expression relies on external variables, you cannot use this overload.
The result of the expression.

Evaluate

#
public object Evaluate(Resolver resolver)
Evaluate this expression.
resolver (Resolver)Variable resolver. You only need a resolver if the expression contains undeclared variables.
The result of the expression.

EvaluateSafe

#
public object EvaluateSafe()
Evaluate this expression. Any exceptions thrown during evaluation will be returned as a string instead.
Result of expression or a string describing why it failed.

EvaluateSafe

#
public object EvaluateSafe(Resolver resolver)
Evaluate this expression. Any exceptions thrown during evaluation will be returned as a string instead.
resolver (Resolver)Variable resolver. You only need a resolver if the expression contains undeclared variables.
Result of expression or a string describing why it failed.

GetHashCode

#
public override int GetHashCode()
Gets a hash for this expression.
Explicit

IStorable.Store

#
void IStorable.Store(IWriter writer)
writer (IWriter)
Store

HasUndeclareds

#
public bool HasUndeclareds(params string[] ignoreList)
Test whether this expression has any undeclareds other than the provided list.
ignoreList (params string[])List of undeclared variable names to ignore.
True if there's at least one undeclared variable with a name not on the list.

ToString

#
public override string ToString()
Gets a string description of this expression.
Object.ToString

TryCreate

#
public static Expression TryCreate(string userCode, out string message)
Try and create an expression. This method doesn't throw.
userCode (string)Expression code.
message (out string)Message in case of failure.
Expression or null.

TryCreate

#
public static Expression TryCreate(string userCode)
Try and create an expression. This method doesn't throw.
userCode (string)Expression code.
Expression or null.

Variable

#
public static Expression Variable(string name)
Create an expression with a direct variable lookup.
name (string)