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

- Main Page
- Namespaces
- Classes
- Files
- Directories

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

Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes | Static Private Attributes

# IG::Lib::ExpressionEvaluatorCompiled Class Reference

Base class for expression evaluators that utilize the functionality of CodeDomProvider class. More...

Inheritance diagram for IG::Lib::ExpressionEvaluatorCompiled:
[legend]
Collaboration diagram for IG::Lib::ExpressionEvaluatorCompiled:
[legend]

List of all members.

## Public Member Functions
| ExpressionEvaluatorCompiled ()
| Initializes ID and calls the main initialization method (which will typically be overridden in every subclass).
virtual object | EvalToObject (string code)
| Evaluates JavaScript code and returns result as object.
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.
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.
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.
string | GetRepairedCommand (string command)
| Repairs the specified command and returns the repaired command string. Reparations serve for easier insertion of commands and for addition of syntactic cookies.
virtual void | RepairCommand (ref string command)
| Repairs the specified command and returns the repaired command string. Reparations serve for easier insertion of commands and for addition of syntactic cookies.
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.
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.
void | Reset ()
| Resets the code evaluator (clears variable definitions, etc.).
virtual void | PrintHelpCommandLine ()
| Prints help for the command-line JavaScript interpreter to the standard output.
virtual void | PrintDefinitions ()
| Prints all definitions (preinstalled and user defined).
virtual void | PrintCompleteCode ()
| Prints the complete code that has been input up to now to the console.
virtual void | SaveCompleteCode (string filePath, bool append)
| Prints the complete code inserter up to this moment.
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.
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.
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.
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.
## Protected Member Functions
abstract void | InitExpressionEvaluator ()
virtual string | CompileBase ()
| Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.
virtual string | CompileBase (string inputDefinitions)
| Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.
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.
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.
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.
## Protected Attributes
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
## Properties
int | Id`[get]`
| Returns object's Id that is unique within a given type.
object | Lock`[get]`
| Used for locking internal fields.
virtual string | Language`[get, set]`
| Programming language in use.
virtual string | PackageName`[get, set]`
| Name of the JavaScript package in which evaluated code is executed.
virtual string | ClassName`[get, set]`
| Name of the JavaScript class that is compiled to execute the evaluated code.
virtual string | EvaluationFunctionName`[get, set]`
| Name of the function used for evaluation of expressions.
virtual string | BaseDefinitions`[get, set]`
| A set of pre-defined definitions that can be used in the evaluated code.
string | CompleteCode`[get, set]`
| All valid user code inserted up to this point. Only code that compiled and executed without errors is taken into account.
virtual string | UserDefinitions`[get, set]`
| A set of definitions inserted by users.
virtual string | NewUserDefinitions`[get, set]`
| New user definitions that are added temporarily for testing.
virtual string | Definitions`[get]`
| All definitions (pre-defined and user-defined) that can be used in the evaluated code.
abstract string | ScriptBase`[get]`
| Container for interpreted code.
virtual string | HelpCommandLine`[get]`
| Returns textual help for JavaScript command-line interpreter.
## Private Attributes
int | _id = -1
object | _lock = new object()
string | _baseDefinitions = ""
string | _userDefinitions = ""
string | _newUserDefinitions = ""
string | _completeCode = ""
object | _evaluator = null
Type | _evaluatorType = null
string | _definitionsMark = "Def> "
string | _multilineMark = "Calc ml> "
string | _resultMark = " = "
string | _helpCommand = "?"
string | _printDefinitionsCommand = "/pd"
string | _printDefinitionsCommand1 = "/printdefinitions"
string | _printCodeCommand = "/pc"
string | _printCodeCommand1 = "/printcode"
string | _evaluationCommand = "/e"
string | _evaluationCommand1 = "/evaluate"
string | _definitionsCommand = "/d"
string | _definitionsCommand1 = "/def"
string | _multilineCommand = "/m"
string | _multilineCommand1 = "/multiline"
string | _saveCodeCommand = "/sc"
string | _appendCodeCommand = "/ac"
string | _saveDefinitionsComand = "/sd"
string | _appendDefinitionsComand = "/ad"
string | _resetCommand = "/reset"
string | _quitCommand = "/exit"
string | _quitCommand1 = "/q"
string | _quitCommand2 = "/quit"
char | _commandCharacter = '/'
## Static Private Attributes
static int | _lastId = 0
static object | _idLock = new object()

## Detailed Description

Base class for expression evaluators that utilize the functionality of CodeDomProvider class.

## Constructor & Destructor Documentation

IG::Lib::ExpressionEvaluatorCompiled::ExpressionEvaluatorCompiled | ( |  | ) | `[inline]`

Initializes ID and calls the main initialization method (which will typically be overridden in every subclass).

## Member Function Documentation

abstract void IG::Lib::ExpressionEvaluatorCompiled::InitExpressionEvaluator | ( |  | ) | `[protected, pure virtual]`

Implemented in IG::Lib::ExpressionEvaluatorJs.

virtual string IG::Lib::ExpressionEvaluatorCompiled::CompileBase | ( |  | ) | `[inline, protected, virtual]`

Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.

Returns:
  Eventual compilation results.

virtual string IG::Lib::ExpressionEvaluatorCompiled::CompileBase | ( | string | inputDefinitions | ) | `[inline, protected, virtual]`

Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.

Parameters:

  inputDefinitions | New definitions that are added to the base script and will not yet be part of permanent definitions (but will become part of them if compilation is successful).

virtual object IG::Lib::ExpressionEvaluatorCompiled::EvalToObject | ( | string | code | ) | `[inline, virtual]`

Evaluates JavaScript code and returns result as object.

Parameters:

  code | JavaScript code to be evaluated.

Returns:
  Object that is result of evaluaton of code.

virtual int IG::Lib::ExpressionEvaluatorCompiled::EvalToInteger | ( | string | code | ) | `[inline, virtual]`

Evaluates (interprets) JavaScript code and returns integer result of evaluation. Code must be such that result of evaluation can be interpreted as integer.

Parameters:

  code | Code that is evaluated.

Returns:

virtual double IG::Lib::ExpressionEvaluatorCompiled::EvalToDouble | ( | string | code | ) | `[inline, virtual]`

Evaluates (interprets) JavaScript code and returns double result of evaluation. Code must be such that result of evaluation can be interpreted as double.

Parameters:

  code | Code that is evaluated.

Returns:

virtual string IG::Lib::ExpressionEvaluatorCompiled::EvalToString | ( | string | code | ) | `[inline, virtual]`

Evaluates (interprets) JavaScript code and returns string result of evaluation. Code must be such that result of evaluation can be interpreted as string.

Parameters:

  code | Code that is evaluated.

Returns:

string IG::Lib::ExpressionEvaluatorCompiled::GetRepairedCommand | ( | string | command | ) | `[inline]`

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.

virtual void IG::Lib::ExpressionEvaluatorCompiled::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 in IG::Lib::ExpressionEvaluatorJs.

virtual string IG::Lib::ExpressionEvaluatorCompiled::Execute | ( | string | inputCode | ) | `[inline, virtual]`

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.

Parameters:

  code | Code that is exected by the JavaScript interpreter.

Returns:
  Result of code execution as string.

virtual string IG::Lib::ExpressionEvaluatorCompiled::Compile | ( | string | inputDefinitions | ) | `[inline, virtual]`

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.

Parameters:

  inputDefinitions | User definitions that are compiled and added to the code.

Returns:

void IG::Lib::ExpressionEvaluatorCompiled::Reset | ( |  | ) | `[inline]`

Resets the code evaluator (clears variable definitions, etc.).

virtual void IG::Lib::ExpressionEvaluatorCompiled::PrintHelpCommandLine | ( |  | ) | `[inline, virtual]`

Prints help for the command-line JavaScript interpreter to the standard output.

virtual void IG::Lib::ExpressionEvaluatorCompiled::PrintDefinitions | ( |  | ) | `[inline, virtual]`

Prints all definitions (preinstalled and user defined).

virtual void IG::Lib::ExpressionEvaluatorCompiled::PrintCompleteCode | ( |  | ) | `[inline, virtual]`

Prints the complete code that has been input up to now to the console.

virtual void IG::Lib::ExpressionEvaluatorCompiled::SaveCompleteCode | ( | string | filePath,
|  | bool | append
| ) |  | `[inline, virtual]`

Prints the complete code inserter up to this moment.

Parameters:

  filePath |
  append |

virtual void IG::Lib::ExpressionEvaluatorCompiled::UserSaveCompleteCode | ( | bool | append | ) | `[inline, virtual]`

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.

Parameters:

  append |

virtual void IG::Lib::ExpressionEvaluatorCompiled::SaveUserDefinitions | ( | string | filePath,
|  | bool | append
| ) |  | `[inline, virtual]`

Saves or appends to the specified file all valid user definitions added to the evaluator up to this point.

Parameters:

  filePath | Path to the file that definitions saved to.
  append | If true then definitions are appended to the file (old content is preserved).

virtual void IG::Lib::ExpressionEvaluatorCompiled::UserSaveUserDefinitions | ( | bool | append | ) | `[inline, virtual]`

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.

Parameters:

  append | If true then definitions are appended to the file (old content is preserved).

virtual string IG::Lib::ExpressionEvaluatorCompiled::ExecuteUser | ( | string | command | ) | `[inline, protected, virtual]`

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.

Parameters:

  command | Command to be executed.

Returns:

virtual string IG::Lib::ExpressionEvaluatorCompiled::CompileUser | ( | string | inputDefinitions | ) | `[inline, protected, virtual]`

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.

Parameters:

  inputDefinitions | User definitions to be added and compiled.

Returns:
  Eventual results of compilation.

virtual string IG::Lib::ExpressionEvaluatorCompiled::ExecuteUser | ( | ref string | inpDefinitions,
|  | ref string | inpCode
| ) |  | `[inline, protected, virtual]`

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.

Parameters:

  inpDefinitions | User definitions that must be added to existing definitions. If specified then the evaluation code is re-compiled.
  inpCode | User code that is evaluated.

Returns:
  Eventual results of evaluation.

virtual void IG::Lib::ExpressionEvaluatorCompiled::CommandLine | ( |  | ) | `[inline, virtual]`

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.

## Member Data Documentation

int IG::Lib::ExpressionEvaluatorCompiled::_lastId = 0`[static, private]`

object IG::Lib::ExpressionEvaluatorCompiled::_idLock = new object()`[static, private]`

int IG::Lib::ExpressionEvaluatorCompiled::_id = -1`[private]`

object IG::Lib::ExpressionEvaluatorCompiled::_lock = new object()`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_language = "unknown"`[protected]`

string IG::Lib::ExpressionEvaluatorCompiled::_packageName = "Evaluator"`[protected]`

string IG::Lib::ExpressionEvaluatorCompiled::_className = "EvaluatorClass"`[protected]`

string IG::Lib::ExpressionEvaluatorCompiled::_evaluationFunctionName = "Eval"`[protected]`

string IG::Lib::ExpressionEvaluatorCompiled::_baseDefinitions = ""`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_userDefinitions = ""`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_newUserDefinitions = ""`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_completeCode = ""`[private]`

object IG::Lib::ExpressionEvaluatorCompiled::_evaluator = null`[private]`

Type IG::Lib::ExpressionEvaluatorCompiled::_evaluatorType = null`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_inputMark = "Calc> "`[protected]`

string IG::Lib::ExpressionEvaluatorCompiled::_definitionsMark = "Def> "`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_multilineMark = "Calc ml> "`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_resultMark = " = "`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_helpCommand = "?"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_printDefinitionsCommand = "/pd"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_printDefinitionsCommand1 = "/printdefinitions"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_printCodeCommand = "/pc"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_printCodeCommand1 = "/printcode"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_evaluationCommand = "/e"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_evaluationCommand1 = "/evaluate"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_definitionsCommand = "/d"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_definitionsCommand1 = "/def"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_multilineCommand = "/m"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_multilineCommand1 = "/multiline"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_saveCodeCommand = "/sc"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_appendCodeCommand = "/ac"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_saveDefinitionsComand = "/sd"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_appendDefinitionsComand = "/ad"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_resetCommand = "/reset"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_quitCommand = "/exit"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_quitCommand1 = "/q"`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_quitCommand2 = "/quit"`[private]`

char IG::Lib::ExpressionEvaluatorCompiled::_multiLineCharacter = '\\'`[protected]`

char IG::Lib::ExpressionEvaluatorCompiled::_commandCharacter = '/'`[private]`

string IG::Lib::ExpressionEvaluatorCompiled::_commandLineHead`[protected]`

Initial value:

     @"

    Command-line Calculator:

    Insert expressions or commands!
    /m for multiline mode, /d for definitions, /e to evaluate, /q to exit!
    End line with '\\' to input multiline code, ? for help!

    "

string IG::Lib::ExpressionEvaluatorCompiled::_commandLineStopNote`[protected]`

Initial value:

     @"

    Command-line calculator stopped.

    "

string IG::Lib::ExpressionEvaluatorCompiled::_helpCommandLineHeading`[protected]`

Initial value:

     @"
    Command-line Expression Evaluator Help:
    Insert valid code or special commands one line after another!
    Quit with '\q' ."

string IG::Lib::ExpressionEvaluatorCompiled::_helpCommandLine`[protected]`

Initial value:

     @"
    Special commands must be inserted without leading spaces.
    End lines with '\\' in order to insert multiline code.
    List of commands:
      ? : prints this help
      /e or /evaluate : insertion and evaluation of code
      /m or /multiline : insertion and evaluation of multiple lines
      /d or /def : insertion of definitions (multiline)
      /pc or /printcode: prints the current code contained in the buffer
      /pd or /printdefinitions: prints definitions (user and predefined)
      /sc : saves the evaluated code to a file (file path prompted)
      /ac : appends the evaluated code to a file (file path prompted)
      /sd : saves all added definitions to a file (file path prompted)
      /ad : appends all added definitons to a file (file path prompted)
      /reset : resets the evaluator
      /q or /quit or /exit : exits command-line evaluator

    Syntactic specifics:
    Automatic variable declaration does not work.
        All variables must be declared with 'var'.
    Invalid code is ignored (with error report launched).
        This enables you to re-enter corrected code.
    The last valid result will be returned.
    The last expression does not need to (but it can) end with semicolon.
    "

## Property Documentation

int IG::Lib::ExpressionEvaluatorCompiled::Id`[get]`

Returns object's Id that is unique within a given type.

Implements IG::Lib::IIdentifiable.

object IG::Lib::ExpressionEvaluatorCompiled::Lock`[get]`

Used for locking internal fields.

Implements IG::Lib::ILockable.

virtual string IG::Lib::ExpressionEvaluatorCompiled::Language`[get, set]`

Programming language in use.

virtual string IG::Lib::ExpressionEvaluatorCompiled::PackageName`[get, set]`

Name of the JavaScript package in which evaluated code is executed.

virtual string IG::Lib::ExpressionEvaluatorCompiled::ClassName`[get, set]`

Name of the JavaScript class that is compiled to execute the evaluated code.

virtual string IG::Lib::ExpressionEvaluatorCompiled::EvaluationFunctionName`[get, set]`

Name of the function used for evaluation of expressions.

virtual string IG::Lib::ExpressionEvaluatorCompiled::BaseDefinitions`[get, set]`

A set of pre-defined definitions that can be used in the evaluated code.

string IG::Lib::ExpressionEvaluatorCompiled::CompleteCode`[get, set]`

All valid user code inserted up to this point. Only code that compiled and executed without errors is taken into account.

virtual string IG::Lib::ExpressionEvaluatorCompiled::UserDefinitions`[get, set]`

A set of definitions inserted by users.

virtual string IG::Lib::ExpressionEvaluatorCompiled::NewUserDefinitions`[get, set, protected]`

New user definitions that are added temporarily for testing.

virtual string IG::Lib::ExpressionEvaluatorCompiled::Definitions`[get]`

All definitions (pre-defined and user-defined) that can be used in the evaluated code.

abstract string IG::Lib::ExpressionEvaluatorCompiled::ScriptBase`[get, protected]`

Container for interpreted code.

When overridden in subclasses, this property will be dynamic (i.e. each get accessor will generate the value anew), and the value will depend on current values of the package, class and function name as well as additonal definitions input by user.

Reimplemented in IG::Lib::ExpressionEvaluatorJs.

virtual string IG::Lib::ExpressionEvaluatorCompiled::HelpCommandLine`[get]`

Returns textual help for JavaScript command-line interpreter.

Returns:

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

- ExpressionEvaluatorCompiled.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events