IGLib
1.5
The IGLib base library for development of numerical, technical and business applications.
|
Base class for expression evaluators that utilize the functionality of CodeDomProvider class. More...
Public Member Functions | |
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 void | RepairCommand (ref 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... | |
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. 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 | _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. 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... | |
![]() | |
object | Lock [get] |
![]() | |
int | Id [get] |
Returns unique ID (in the scope of a given type) of the current object. More... | |
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() |
Base class for expression evaluators that utilize the functionality of CodeDomProvider class.
|
inline |
Initializes ID and calls the main initialization method (which will typically be overridden in every subclass).
|
protectedpure virtual |
Implemented in IG.Lib.ExpressionEvaluatorJs.
|
inlineprotectedvirtual |
Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.
|
inlineprotectedvirtual |
Compiles the base script where evaluation is plugged in, and loads the generated assembly and necessary objects.
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). |
|
inlinevirtual |
Evaluates JavaScript code and returns result as object.
code | JavaScript code to be evaluated. |
|
inlinevirtual |
Evaluates (interprets) JavaScript code and returns integer result of evaluation. Code must be such that result of evaluation can be interpreted as integer.
code | Code that is evaluated. |
|
inlinevirtual |
Evaluates (interprets) JavaScript code and returns double result of evaluation. Code must be such that result of evaluation can be interpreted as double.
code | Code that is evaluated. |
|
inlinevirtual |
Evaluates (interprets) JavaScript code and returns string result of evaluation. Code must be such that result of evaluation can be interpreted as string.
code | Code that is evaluated. |
|
inline |
Repairs the specified command and returns the repaired command string.
Reparations serve for easier insertion of commands and for addition of syntactic cookies.
command | Command to be repaired. |
|
inlinevirtual |
Repairs the specified command and returns the repaired command string.
Reparations serve for easier insertion of commands and for addition of syntactic cookies.
command | Command to be repaired. |
Reimplemented in IG.Lib.ExpressionEvaluatorJs.
|
inlinevirtual |
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.
code | Code that is exected by the JavaScript interpreter. |
|
inlinevirtual |
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.
inputDefinitions | User definitions that are compiled and added to the code. |
|
inline |
Resets the code evaluator (clears variable definitions, etc.).
|
inlinevirtual |
Prints help for the command-line JavaScript interpreter to the standard output.
|
inlinevirtual |
Prints all definitions (preinstalled and user defined).
|
inlinevirtual |
Prints the complete code that has been input up to now to the console.
|
inlinevirtual |
Prints the complete code inserter up to this moment.
filePath | |
append |
|
inlinevirtual |
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.
append |
|
inlinevirtual |
Saves or appends to the specified file all valid user definitions added to the evaluator up to this point.
filePath | Path to the file that definitions saved to. |
append | If true then definitions are appended to the file (old content is preserved). |
|
inlinevirtual |
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.
append | If true then definitions are appended to the file (old content is preserved). |
|
inlineprotectedvirtual |
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.
command | Command to be executed. |
|
inlineprotectedvirtual |
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.
inputDefinitions | User definitions to be added and compiled. |
|
inlineprotectedvirtual |
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.
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. |
|
inlinevirtual |
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.
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
get |
Returns object's Id that is unique within a given type.
|
get |
Used for locking internal fields.
|
getprotected set |
Programming language in use.
|
getprotected set |
Name of the JavaScript package in which evaluated code is executed.
|
getprotected set |
Name of the JavaScript class that is compiled to execute the evaluated code.
|
getprotected set |
Name of the function used for evaluation of expressions.
|
getprotected set |
A set of pre-defined definitions that can be used in the evaluated code.
|
getprotected set |
All valid user code inserted up to this point. Only code that compiled and executed without errors is taken into account.
|
getprotected set |
A set of definitions inserted by users.
|
getsetprotected |
New user definitions that are added temporarily for testing.
|
get |
All definitions (pre-defined and user-defined) that can be used in the evaluated code.
|
getprotected |
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.
|
get |
Returns textual help for JavaScript command-line interpreter.