| IGLib 1.6.0 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties | Static Private Attributes | List of all members
IG.Lib.ExpressionEvaluatorJs Class Reference

JavaScript Evaluator with command-line interpreter. More...

Inheritance diagram for IG.Lib.ExpressionEvaluatorJs:
[legend]
Collaboration diagram for IG.Lib.ExpressionEvaluatorJs:
[legend]

## Public Member Functions
| ExpressionEvaluatorJs ()
| Initializes a new JavaScript evaluator. This includes compiling the JavaScript code where evaluation is plugged in. More...
override void | RepairCommand (ref string command)
| Repairs the specified command and returns the repaired command string. More...
void | Register ()
| Registers the current object. Subsequent calls (after the first one) have no effect. More...
bool | IsRegistered ()
| Returns true if the current object is registered, false if not. More...
void | Unregister ()
| Unregisters the current object if it is currently registered. Can be performed several times, in this case only the first call may have effect. More...
Public Member Functions inherited from IG.Lib.ExpressionEvaluatorCompiled
| ExpressionEvaluatorCompiled ()
| Initializes ID and calls the main initialization method (which will typically be overridden in every subclass). More...
virtual object | EvalToObject (string code)
| Evaluates JavaScript code and returns result as object. More...
virtual int | EvalToInteger (string code)
| Evaluates (interprets) JavaScript code and returns integer result of evaluation. Code must be such that result of evaluation can be interpreted as integer. More...
virtual double | EvalToDouble (string code)
| Evaluates (interprets) JavaScript code and returns double result of evaluation. Code must be such that result of evaluation can be interpreted as double. More...
virtual string | EvalToString (string code)
| Evaluates (interprets) JavaScript code and returns string result of evaluation. Code must be such that result of evaluation can be interpreted as string. More...
string | GetRepairedCommand (string command)
| Repairs the specified command and returns the repaired command string. More...
virtual string | Execute (string inputCode)
| Executes the specified code and returns the result. Throws exception if errors occur when interpreting code. After execution, the code is appended to the complete code that has been executed up to this point. More...
virtual string | Compile (string inputDefinitions)
| Recompiles the basic script where evaluatin is plugged in, with added definitions. Throws exceptions if errors occur when compiling code. After execution, user definitions are added to the base script if compilatin is successful, so that they can be used in subsequent evaluations of code. More...
void | Reset ()
| Resets the code evaluator (clears variable definitions, etc.). More...
virtual void | PrintHelpCommandLine ()
| Prints help for the command-line JavaScript interpreter to the standard output. More...
virtual void | PrintDefinitions ()
| Prints all definitions (preinstalled and user defined). More...
virtual void | PrintCompleteCode ()
| Prints the complete code that has been input up to now to the console. More...
virtual void | SaveCompleteCode (string filePath, bool append)
| Prints the complete code inserter up to this moment. More...
virtual void | UserSaveCompleteCode (bool append)
| Saves or appends the complete code evaluated up to now to a file specified by the user. User is promped for the file to which code is saved. More...
virtual void | SaveUserDefinitions (string filePath, bool append)
| Saves or appends to the specified file all valid user definitions added to the evaluator up to this point. More...
virtual void | UserSaveUserDefinitions (bool append)
| Saves or appends the all valid user definitions added to the evaluator up to this point. User is promped for the file to which definitions are saved. More...
virtual void | CommandLine ()
| Command-line utility where user can successively enter JavaScrit expressions or general portions of code, and evaluates them. Displays prompt to instruct the user, and result of operations. More...

## Static Public Member Functions
static void | ExampleCommandLine ()
| Launches command-line JavaScript interpreter. More...

## Protected Member Functions
override void | InitExpressionEvaluator ()
| Contains initializations for the particular class. More...
Protected Member Functions inherited from IG.Lib.ExpressionEvaluatorCompiled
virtual string | CompileBase ()
| Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects. More...
virtual string | CompileBase (string inputDefinitions)
| Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects. More...
virtual string | ExecuteUser (string command)
| Executes the code, prints results and reports eventual errors. Also appends the code to the complete valid code that has been interpreted up to now. More...
virtual string | CompileUser (string inputDefinitions)
| Compiles the specified new definitions. If compilation is successful, the definitions are added to existing definitinos and user is notified through console. Otherwise, error is reported on console. More...
virtual string | ExecuteUser (ref string inpDefinitions, ref string inpCode)
| Compiles definitions, if any specified, and executes code, if any specified. Eventual results and errors are reported in console. After execution, code and definitions are set to null. More...

## Protected Attributes
string | _baseDefinitionsJs
Protected Attributes inherited from IG.Lib.ExpressionEvaluatorCompiled
string | _language = "unknown"
string | _packageName = "Evaluator"
string | _className = "EvaluatorClass"
string | _evaluationFunctionName = "Eval"
string | _inputMark = "Calc> "
char | _multiLineCharacter = '\\'
string | _commandLineHead
string | _commandLineStopNote
string | _helpCommandLineHeading
string | _helpCommandLine

## Static Protected Attributes
static ExpressionEvaluatorJs | _evaluatorGlobal = null

## Properties
override string | ScriptBase`[get]`
| Container for compiled code that evaluates JavaScript expressions. More...
ObjectRegister < ExpressionEvaluatorJs > | ObjectRegister`[get]`
| Gets object register where the current object is registered. More...
static ExpressionEvaluatorJs | Global`[get, protected set]`
| Global JavaScript expression evaluator. Initialized on first use. More...
Properties inherited from IG.Lib.ExpressionEvaluatorCompiled
int | Id`[get]`
| Returns object's Id that is unique within a given type. More...
object | Lock`[get]`
| Used for locking internal fields. More...
virtual string | Language`[get, protected set]`
| Programming language in use. More...
virtual string | PackageName`[get, protected set]`
| Name of the JavaScript package in which evaluated code is executed. More...
virtual string | ClassName`[get, protected set]`
| Name of the JavaScript class that is compiled to execute the evaluated code. More...
virtual string | EvaluationFunctionName`[get, protected set]`
| Name of the function used for evaluation of expressions. More...
virtual string | BaseDefinitions`[get, protected set]`
| A set of pre-defined definitions that can be used in the evaluated code. More...
string | CompleteCode`[get, protected set]`
| All valid user code inserted up to this point. Only code that compiled and executed without errors is taken into account. More...
virtual string | UserDefinitions`[get, protected set]`
| A set of definitions inserted by users. More...
virtual string | NewUserDefinitions`[get, set]`
| New user definitions that are added temporarily for testing. More...
virtual string | Definitions`[get]`
| All definitions (pre-defined and user-defined) that can be used in the evaluated code. More...
abstract string | ScriptBase`[get]`
| Container for interpreted code. More...
virtual string | HelpCommandLine`[get]`
| Returns textual help for JavaScript command-line interpreter. More...
Properties inherited from IG.Lib.ILockable
object | Lock`[get]`
Properties inherited from IG.Lib.IIdentifiable
int | Id`[get]`
| Returns unique ID (in the scope of a given type) of the current object. More...
Properties inherited from IG.Lib.IRegisterable< T >
ObjectRegister< T > | ObjectRegister`[get]`
| Gets the object register where the current object can be registered. More...

## Static Private Attributes
static ObjectRegister < ExpressionEvaluatorJs > | _register
| Static object that providees object register and generates IDs for this class: More...
static object | _globalLock = new object()

## Detailed Description

JavaScript Evaluator with command-line interpreter.

$A Igor Aug10;

## Constructor & Destructor Documentation

IG.Lib.ExpressionEvaluatorJs.ExpressionEvaluatorJs | ( |  | ) |
| inline

Initializes a new JavaScript evaluator. This includes compiling the JavaScript code where evaluation is plugged in.

## Member Function Documentation

override void IG.Lib.ExpressionEvaluatorJs.InitExpressionEvaluator | ( |  | ) |
| inline protected virtual

Contains initializations for the particular class.

This method is called form base class' constructor.

Implements IG.Lib.ExpressionEvaluatorCompiled.

override void IG.Lib.ExpressionEvaluatorJs.RepairCommand | ( | ref string | command | ) |
| inline virtual

Repairs the specified command and returns the repaired command string.

Reparations serve for easier insertion of commands and for addition of syntactic cookies.

Parameters

  command | Command to be repaired.

Reimplemented from IG.Lib.ExpressionEvaluatorCompiled.

void IG.Lib.ExpressionEvaluatorJs.Register | ( |  | ) |
| inline

Registers the current object. Subsequent calls (after the first one) have no effect.

Implements IG.Lib.IRegisterable< T >.

bool IG.Lib.ExpressionEvaluatorJs.IsRegistered | ( |  | ) |
| inline

Returns true if the current object is registered, false if not.

Returns

Implements IG.Lib.IRegisterable< T >.

void IG.Lib.ExpressionEvaluatorJs.Unregister | ( |  | ) |
| inline

Unregisters the current object if it is currently registered. Can be performed several times, in this case only the first call may have effect.

Implements IG.Lib.IRegisterable< T >.

static void IG.Lib.ExpressionEvaluatorJs.ExampleCommandLine | ( |  | ) |
| inline static

Launches command-line JavaScript interpreter.

## Member Data Documentation

string IG.Lib.ExpressionEvaluatorJs._baseDefinitionsJs
| protected

ObjectRegister<ExpressionEvaluatorJs> IG.Lib.ExpressionEvaluatorJs._register
| static private

Initial value:
=
new ObjectRegister<ExpressionEvaluatorJs>(1 )

Static object that providees object register and generates IDs for this class:

ExpressionEvaluatorJs IG.Lib.ExpressionEvaluatorJs._evaluatorGlobal = null
| static protected

object IG.Lib.ExpressionEvaluatorJs._globalLock = new object()
| static private

## Property Documentation

override string IG.Lib.ExpressionEvaluatorJs.ScriptBase
| get protected

Container for compiled code that evaluates JavaScript expressions.

ObjectRegister<ExpressionEvaluatorJs> IG.Lib.ExpressionEvaluatorJs.ObjectRegister
| get

Gets object register where the current object is registered.

ExpressionEvaluatorJs IG.Lib.ExpressionEvaluatorJs.Global
| static get protected set

Global JavaScript expression evaluator. Initialized on first use.

In many applications you will not need more than one evaluator and you can just use this instance.

The documentation for this class was generated from the following file:

- igbase/interpreters/ExpressionEvaluatorJs.cs