NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
Procedure Class Reference

This class implements the logic to evaluate complex procedures, which may be called recursively. More...

#include <procedure.hpp>

Inheritance diagram for Procedure:
Collaboration diagram for Procedure:

Public Member Functions

 Procedure ()
 Default constructor. More...
 
 Procedure (const Procedure &_procedure)
 Custom constructor using the presets from the passed procedure instance. Used as a recursion functionality. More...
 
 ~Procedure ()
 Destructor ensuring that the procedure output file stream will be closed, if it is still open. More...
 
Returnvalue execute (std::string sProc, std::string sVarList, mu::Parser &_parser, FunctionDefinitionManager &_functions, MemoryManager &_data, Settings &_option, Output &_out, PlotData &_pData, Script &_script, unsigned int nth_procedure=0)
 This member function is central in the execution of the currently selected procedure as it handles all the logic. More...
 
virtual FlowCtrl::ProcedureInterfaceRetVal procedureInterface (std::string &sLine, mu::Parser &_parser, FunctionDefinitionManager &_functions, MemoryManager &_data, Output &_out, PlotData &_pData, Script &_script, Settings &_option, int nth_command=0) override
 This member function handles the calls for procedures and plugins, resolves them and executes the called procedures by constructing a new instance of this class on the heap. More...
 
bool writeProcedure (std::string sProcedureLine)
 This member function handles the procedure installation process by governing the file stream and passing the corresponding procedure linewards to the stream. More...
 
virtual int isInline (const std::string &sProc) override
 This virtual member function checks, whether the procedures in the current line are declared as inline and whether they are inlinable. More...
 
virtual int evalDebuggerBreakPoint (mu::Parser &_parser, Settings &_option) override
 This virtual member function handles the gathering of all relevant information for the debugger for the currently found breakpoint. More...
 
virtual int getErrorInformationForDebugger () override
 This virtual member function handles the gathering of all relevant information for the debugger for the currently found error. More...
 
virtual int catchExceptionForTest (std::exception_ptr e_ptr, bool bSupressAnswer_back, int nLine) override
 This virtual member function is inserted in some automatically catchable locations to convert an error into a warning to avoid that the calculation is aborted. This will only get active, if the corresponding procedure is flagged as "test". More...
 
void setPredefinedFuncs (const std::string &sPredefined)
 
std::string getCurrentProcedureName () const
 
unsigned int GetCurrentLine () const
 This member function will return the current line number depending on whether a flow control statement is evaluated or not. More...
 
int getReturnType () const
 
bool is_writing () const
 
int getProcedureFlags () const
 
int & getDebuggerCode ()
 
size_t replaceReturnVal (std::string &sLine, mu::Parser &_parser, const Returnvalue &_return, unsigned int nPos, unsigned int nPos2, const std::string &sReplaceName)
 This member function replaces the procedure occurence between the both passed positions using akronymed version of the called procedure. It also declares the numerical return value as a vector to the parser. More...
 
- Public Member Functions inherited from FlowCtrl
 FlowCtrl ()
 Default constructor. More...
 
virtual ~FlowCtrl ()
 Destructor. Cleanes the memory, if necessary. More...
 
int getCurrentBlockDepth () const
 Returns the current block depth while reading a flow control statement to memory. More...
 
std::string getCurrentBlock () const
 
Returnvalue getReturnValue () const
 
bool getReturnSignal () const
 
void setCommand (std::string &__sCmd, int nCurrentLine)
 This member function is used to set a command line from the outside into the flow control statement class. The internal flow control command buffer grows as needed. More...
 
void eval ()
 This member function prepares the command array by pre-evaluating all constant stuff or function calls whereever possible. More...
 
void reset ()
 This function clears the memory of this FlowCtrl object and sets everything back to its original state. More...
 
int getCurrentLineNumber () const
 This member function returns the current line number as enumerated during passing the commands via "setCommand()". More...
 
std::string getCurrentCommand () const
 This member function returns the current command line, which will or has been evaluated in the current line. More...
 
- Public Member Functions inherited from PackageManager
 PackageManager ()
 PluginManager default constructor. More...
 
 PackageManager (const PackageManager &_manager)
 PluginManager copy constructor. More...
 
 ~PackageManager ()
 PluginManager destructor. Will close the internal file stream if it is still open. More...
 
PackageManageroperator= (const PackageManager &_manager)
 This is the overload for the assignment operator. More...
 
bool loadPlugins ()
 This member function will read the plugin definitions from the definitions file and create the internal representations. More...
 
bool evalPluginCmd (std::string &sCmd)
 This member function converts the call to a plugin in the passed command line into a call to the corresponding plugin main procedure. More...
 
bool declareNewPackage (const std::string &sInstallInfoString)
 This member function declares a new plugin from the passed install information string. More...
 
bool isPluginCmd (const std::string &sCmd) const
 This member function determines, whether the passed command line contains a plugin command. More...
 
std::string deletePackage (const std::string &sPackage)
 This member function deletes the plugin with the passed name from the internal set of definitions and returns the stored documentation index IDs. More...
 
std::map< std::string, std::string > getMenuMap () const
 Returns the menu map connecting menu entry names with their corresponding procedure, which shall be called. More...
 
unsigned int getPackageCount () const
 Returns the number of installed plugins. More...
 
std::string getPluginInfoPath ()
 This member function simply returns the plugin definition file path. More...
 
void addHelpIndex (const std::string &_sPluginName, std::string _sHelpId)
 This member function adds the passed documentation index ID to the plugin definition. More...
 
const std::vector< Package > & getPackages () const
 Returns a const reference to the currently installed packages. More...
 
std::string getPluginNames () const
 Returns the names of the installed plugins. More...
 
std::string getPluginProcName () const
 Returns the current plugin's procedure name. More...
 
std::string getPluginVarList () const
 Returns the current plugin's procedure argument list. More...
 
std::string getPluginCommand (unsigned int i=0) const
 Returns the plugin command of the ith plugin. More...
 
std::string getPluginCommandSignature (unsigned int i=0) const
 Returns the plugin command signature of the ith plugin. More...
 
std::string getPackageName (unsigned int i=0) const
 Returns the plugin name of the ith plugin. More...
 
std::string getPackageVersion (unsigned int i=0) const
 Returns the version number string of the ith plugin. More...
 
std::string getPackageAuthor (unsigned int i=0) const
 Returns the author of the ith plugin. More...
 
std::string getPackageDescription (unsigned int i=0) const
 Returns the description of the ith plugin. More...
 
std::string getPackageLicense (unsigned int i=0) const
 Returns the license information of the ith plugin. More...
 
std::string getPluginMenuEntry (unsigned int i=0) const
 Returns the menu entry of the ith plugin. More...
 
- Public Member Functions inherited from FileSystem
 FileSystem ()
 Default constructor. More...
 
FileSystemassign (const FileSystem &_fSys)
 Assignment member function to copy the settings from another FileSystem instance. More...
 
std::string ValidFileName (std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
 This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension. More...
 
std::string ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
 This member function evaluates, whether the passed foldername is a valid foldername. More...
 
std::string ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const
 This member function validizes the passed file name and creates the needed folders on-the-fly. More...
 
int setPath (std::string _sPath, bool bMkDir, std::string _sExePath)
 This member function may be used to set the preferred file path of the current FileSystem instance. More...
 
void createRevisionsFolder ()
 This member function creates the hidden revisions folders for the version control system. More...
 
std::string getPath () const
 Returns the default path of this FileSystem instance. More...
 
std::vector< std::string > getFileParts (const std::string &sFilePath) const
 This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More...
 
FileInfo getFileInfo (const std::string &sFilePath) const
 Return the file information about the passed file path. More...
 
void setTokens (std::string _sTokens)
 This member function may be used to update the path placeholders of the current FileSystem instance. More...
 
bool isFile (const std::string &_sPath) const
 This function determines, whether a path name indicates a file or a folder. More...
 
void initializeFromKernel ()
 Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More...
 
void setProgramPath (std::string _sExePath)
 
std::string getProgramPath () const
 
void declareFileType (const std::string &sFileType)
 

Static Public Member Functions

static std::string mangleName (std::string sProcedureName)
 Mangles a procedure name to be used as a usual variable. More...
 
- Static Public Member Functions inherited from FlowCtrl
static bool isFlowCtrlStatement (const std::string &sCmd)
 This static member function returns whether the passed command is a flow control statement. More...
 
static bool isAnyFlowCtrlStatement (const std::string &sCmd)
 This static member function returns whether the passed command is any of the known flow control statements (not only their headers). More...
 

Private Member Functions

void init ()
 Private initializing member function. Sets all variables to a reasonable default value. More...
 
Returnvalue ProcCalc (std::string sLine, std::string sCurrentCommand, int &nByteCode, mu::Parser &_parser, FunctionDefinitionManager &_functions, MemoryManager &_data, Settings &_option, Output &_out, PlotData &_pData, Script &_script)
 This member function does the evaluation stuff regarding strings and numerical expressions for the current procedure. More...
 
bool setProcName (const std::string &sProc, bool bInstallFileName=false)
 This member function is used to obtain the procedure file name from the selected procedure. It handles the "thisfile" namespace directly. More...
 
void resetProcedure (mu::Parser &_parser, bool bSupressAnswer)
 This member function sets the current procedure object to its original state. It will be called at the end of the executed procedure. More...
 
void extractCurrentNamespace (const std::string &sProc)
 This member function extracts the namespace of the currently executed procedure. More...
 
bool handleVariableDefinitions (std::string &sProcCommandLine, const std::string &sCommand)
 This method handles the definitions of local variables. More...
 
int handleIncludeSyntax (std::string &sProcCommandLine, std::ifstream &fInclude, bool bReadingFromInclude)
 This member function handles the script include syntax, which one may use in other procedures. More...
 
void extractProcedureInformation (const std::string &sCmdLine, size_t nPos, std::string &sProcName, std::string &sArgList, std::string &sFileName)
 This private member function extracts procedure name, argument list and the corresponding file name from the passed position in the command line. More...
 
virtual int procedureCmdInterface (std::string &sLine) override
 Virtual member function allowing to identify and evaluate some special procedure commands. Currently it is only used for the namespace command. More...
 
virtual std::vector< std::string > expandInlineProcedures (std::string &sLine) override
 This virtual private member function expands all procedures in the current command line, which were declared as "inline" and which are inlinable, into a vector of command lines, which will be inserted in the flow control command array before the current command line. More...
 
int isInlineable (const std::string &sProc, const std::string &sFileName, int *nInlineFlag=nullptr)
 This private member function evaluates, whether the current procedure is inlineable, i.e. whether it fulfills the internal inlining rules. More...
 
int applyInliningRuleset (const std::string &sCommandLine, const std::string &sArgumentList)
 This private member function applies the internal inlining rule set for a single procedure command line and returns the corresponding enumeration flags. More...
 
size_t countProceduresInLine (const std::string &sCommandLine)
 This private member function simply counts the number of procedures, which may be found in the current command line. More...
 
std::vector< std::string > getInlined (const std::string &sProc, const std::string &sArgumentList, const std::string &sFileName, size_t nProcedures)
 This virtual private member function returns the inlined representation of the selected procedure as a vector containing the single commands. More...
 

Private Attributes

std::fstream fProcedure
 
std::string sProcNames
 
std::string sCurrentProcedureName
 
int nCurrentLine
 
std::string sNameSpace
 
std::string sCallingNameSpace
 
std::string sThisNameSpace
 
std::string sLastWrittenProcedureFile
 
std::string sProcCommandLine
 
bool bProcSupressAnswer
 
bool bWritingTofile
 
int nFlags
 
int nthBlock
 
ProcedureVarFactory_varFactory
 
FunctionDefinitionManager _localDef
 

Friends

class NumeReDebugger
 
class ProcedureVarFactory
 

Additional Inherited Members

- Protected Types inherited from FlowCtrl
enum  CalculationType {
  CALCTYPE_NONE = 0x0 , CALCTYPE_COMMAND = 0x1 , CALCTYPE_NUMERICAL = 0x2 , CALCTYPE_STRING = 0x4 ,
  CALCTYPE_DATAACCESS = 0x8 , CALCTYPE_PROGRESS = 0x10 , CALCTYPE_COMPOSE = 0x20 , CALCTYPE_DEFINITION = 0x40 ,
  CALCTYPE_RETURNCOMMAND = 0x80 , CALCTYPE_THROWCOMMAND = 0x100 , CALCTYPE_DEBUGBREAKPOINT = 0x200 , CALCTYPE_EXPLICIT = 0x400 ,
  CALCTYPE_TOCOMMAND = 0x800 , CALCTYPE_PROCEDURECMDINTERFACE = 0x1000 , CALCTYPE_CONTINUECMD = 0x2000 , CALCTYPE_BREAKCMD = 0x4000 ,
  CALCTYPE_PROMPT = 0x8000 , CALCTYPE_RECURSIVEEXPRESSION = 0x10000 , CALCTYPE_SUPPRESSANSWER = 0x20000 , CALCTYPE_ASSERT = 0x40000
}
 
enum  ProcedureInterfaceRetVal { INTERFACE_EMPTY = -2 , INTERFACE_ERROR = -1 , INTERFACE_NONE = 1 , INTERFACE_VALUE = 2 }
 
enum  FlowCtrlStatement {
  FC_FOR , FC_IF , FC_WHILE , FC_SWITCH ,
  FC_TRY , FC_COUNT
}
 
typedef int(FlowCtrl::* FlowCtrlFunction) (int, int)
 Definition of a generic FlowCtrl entry point. More...
 
- Protected Member Functions inherited from FlowCtrl
int for_loop (int nth_Cmd=0, int nth_Loop=0)
 This member function realizes the FOR control flow statement. The return value is either an error value or the end of the current flow control statement. More...
 
int range_based_for_loop (int nth_Cmd=0, int nth_Loop=0)
 This member function realizes the FOR control flow statement for range based indices. The return value is either an error value or the end of the current flow control statement. More...
 
int while_loop (int nth_Cmd=0, int nth_Loop=0)
 This member function realizes the WHILE control flow statement. The return value is either an error value or the end of the current flow control statement. More...
 
int if_fork (int nth_Cmd=0, int nth_Loop=-1)
 This member function realizes the IF-ELSE control flow statement. The return value is either an error value or the end of the current flow control statement. More...
 
int switch_fork (int nth_Cmd=0, int nth_Loop=-1)
 This member function realizes the SWITCH-CASE control flow statement. The return value is either an error value or the end of the current flow control statement. More...
 
int try_catch (int nth_Cmd=0, int nth_Loop=-1)
 Implements a try-catch block. More...
 
int compile (std::string sLine, int nthCmd)
 This member function does the hard work and compiles the numerical and std::string results for the current command line to provide the bytecode for the usual calculation function. More...
 
int calc (StringView sLine, int nthCmd)
 This member function does the hard work and calculates the numerical and std::string results for the current command line. It will use the previously determined bytecode whereever possible. More...
 
value_typeevalHeader (int &nNum, std::string &sHeadExpression, bool bIsForHead, int nth_Cmd, const std::string &sHeadCommand)
 This member function abstracts the evaluation of all flow control headers. It will return an array of evaluated return values, although only the first (one/two) are used here. More...
 
NumeRe::Cluster evalRangeBasedHeader (std::string &sHeadExpression, int nth_Cmd, const std::string &sHeadCommand)
 This member function handles the evaluation of the range-based flow control headers. It will return a cluster of the evaluated return values. More...
 
int evalForkFlowCommands (int __j, int nth_loop)
 This member function handles the evaluation of flow control statements from the viewpoint of an if-else control flow. More...
 
void replaceLocalVars (std::string &sLine)
 This member function is used to replace variable occurences with their (auto-determined) internal name. More...
 
void replaceLocalVars (const std::string &sOldVar, const std::string &sNewVar, size_t from=0, size_t to=std::string::npos)
 Replaces all occurences of the selected variable in the range of the selected lines with the new name. More...
 
bool checkFlowControlArgument (const std::string &sFlowControlArgument, bool isForLoop=false)
 This member function checks, whether the passed flow control argument is valid or not. More...
 
bool checkCaseValue (const std::string &sCaseDefinition)
 This member function checks, whether the entered case definition is valid or not. More...
 
std::string extractFlagsAndIndexVariables ()
 Read the flow control statements only and extract the index variables and the flow control flags. More...
 
void fillJumpTableAndExpandRecursives ()
 Go again through the whole command set and fill the jump table with the corresponding block ends and pre-evaluate the recursive expressions. Furthermore, determine, whether the loop parsing mode is reasonable. More...
 
void prepareSwitchExpression (int nSwitchStart)
 This member function will prepare the single logical switch expression. More...
 
void checkParsingModeAndExpandDefinitions ()
 If the loop parsing mode is active, ensure that only inline procedures are used in this case. Otherwise turn it off again. Additionally check for "to_cmd()" function, which will also turn the loop parsing mode off. If no function definition commands are found in the command block, replace the definitions with their expanded form. More...
 
void prepareLocalVarsAndReplace (std::string &sVars)
 This method prepares the local variables including their names and replaces them in the command lines in the current command block. More...
 
void updateTestStats ()
 Updates the test statistics with the total test statistics. More...
 
virtual int procedureCmdInterface (std::string &sLine)
 Dummy implementation. More...
 
virtual ProcedureInterfaceRetVal procedureInterface (std::string &sLine, Parser &_parser, FunctionDefinitionManager &_functions, MemoryManager &_data, Output &_out, PlotData &_pData, Script &_script, Settings &_option, int nth_command)
 Dummy implementation. More...
 
virtual int isInline (const std::string &sProc)
 Dummy implementation. More...
 
virtual int evalDebuggerBreakPoint (Parser &_parser, Settings &_option)
 Dummy implementation. More...
 
virtual int getErrorInformationForDebugger ()
 Dummy implementation. More...
 
virtual std::vector< std::string > expandInlineProcedures (std::string &sLine)
 Dummy implementation. More...
 
virtual int catchExceptionForTest (std::exception_ptr e_ptr, bool bSupressAnswer_back, int nLine)
 Dummy implementation. More...
 
- Protected Member Functions inherited from FileSystem
int createFolders (const std::string &_sPath) const
 This member function creates all missing directories in the passed path. More...
 
- Protected Attributes inherited from FlowCtrl
std::vector< FlowCtrlCommandvCmdArray
 
std::vector< value_typevVarArray
 
std::vector< std::string > sVarArray
 
varmap_type vVars
 
std::vector< std::vector< int > > nJumpTable
 
std::vector< int > nCalcType
 
std::string sLoopNames
 
int nFlowCtrlStatements [FC_COUNT]
 
int nCurrentCommand
 
Returnvalue ReturnVal
 
bool bUseLoopParsingMode
 
bool bLockedPauseMode
 
bool bFunctionsReplaced
 
std::string sLoopPlotCompose
 
std::map< std::string, std::string > mVarMap
 
std::set< std::string > inlineClusters
 
bool bSilent
 
bool bMask
 
bool bPrintedStatus
 
bool bEvaluatingFlowControlStatements
 
int nLoopSafety
 
int nDebuggerCode
 
AssertionStats baseline
 
std::string sTestClusterName
 
int nthRecursion
 
int nReturnType
 
bool bReturnSignal
 
- Protected Attributes inherited from FileSystem
std::string sPath
 
std::string sExecutablePath
 
std::string sTokens [7][2]
 
std::string sValidExtensions
 

Detailed Description

This class implements the logic to evaluate complex procedures, which may be called recursively.

Definition at line 55 of file procedure.hpp.

Constructor & Destructor Documentation

◆ Procedure() [1/2]

Procedure::Procedure ( )

Default constructor.

Definition at line 34 of file procedure.cpp.

References init().

Referenced by procedureInterface().

Here is the call graph for this function:

◆ Procedure() [2/2]

Procedure::Procedure ( const Procedure _procedure)

Custom constructor using the presets from the passed procedure instance. Used as a recursion functionality.

Parameters
_procedureconst Procedure&

Definition at line 49 of file procedure.cpp.

References _localDef, NumeReKernel::DEBUGGER_LEAVE, NumeReKernel::DEBUGGER_STEPOVER, FunctionDefinitionManager::getPredefinedFuncs(), init(), FlowCtrl::nDebuggerCode, sCallingNameSpace, FunctionDefinitionManager::setPredefinedFuncs(), FileSystem::sExecutablePath, FileSystem::sPath, sProcNames, and FileSystem::sTokens.

Here is the call graph for this function:

◆ ~Procedure()

Procedure::~Procedure ( )

Destructor ensuring that the procedure output file stream will be closed, if it is still open.

Definition at line 78 of file procedure.cpp.

References _varFactory, and fProcedure.

Member Function Documentation

◆ applyInliningRuleset()

int Procedure::applyInliningRuleset ( const std::string &  sCommandLine,
const std::string &  sArgumentList 
)
private

This private member function applies the internal inlining rule set for a single procedure command line and returns the corresponding enumeration flags.

Parameters
sCommandLineconst string&
sArgumentListconst string&
Returns
int one of ProcedureCommendLine::Inlineable values

Definition at line 2185 of file procedure.cpp.

References findCommand(), ProcedureCommandLine::INLINING_IMPOSSIBLE, ProcedureCommandLine::INLINING_POSSIBLE, and Match::sString.

Referenced by isInlineable().

Here is the call graph for this function:

◆ catchExceptionForTest()

int Procedure::catchExceptionForTest ( std::exception_ptr  e_ptr,
bool  bSupressAnswer_back,
int  nLine 
)
overridevirtual

This virtual member function is inserted in some automatically catchable locations to convert an error into a warning to avoid that the calculation is aborted. This will only get active, if the corresponding procedure is flagged as "test".

Parameters
e_ptrexception_ptr
bSupressAnswer_backbool
nLineint
Returns
int

Reimplemented from FlowCtrl.

Definition at line 2495 of file procedure.cpp.

References NumeReKernel::failMessage(), NumeReDebugger::finalizeCatched(), ProcedureCommandLine::FLAG_TEST, NumeReKernel::getDebugger(), mu::ParserError::GetExpr(), NumeReKernel::getInstance(), SyntaxError::LOOP_THROW, nFlags, SyntaxError::PROCEDURE_THROW, SyntaxError::PROCESS_ABORTED_BY_USER, resetProcedure(), and toString().

Referenced by execute().

Here is the call graph for this function:

◆ countProceduresInLine()

size_t Procedure::countProceduresInLine ( const std::string &  sCommandLine)
private

This private member function simply counts the number of procedures, which may be found in the current command line.

Parameters
sCommandLineconst string&
Returns
size_t

Definition at line 2224 of file procedure.cpp.

References isInQuotes().

Referenced by expandInlineProcedures().

Here is the call graph for this function:

◆ evalDebuggerBreakPoint()

int Procedure::evalDebuggerBreakPoint ( mu::Parser _parser,
Settings _option 
)
overridevirtual

This virtual member function handles the gathering of all relevant information for the debugger for the currently found breakpoint.

Parameters
_parserParser&
_optionSettings&
Returns
int

Reimplemented from FlowCtrl.

Definition at line 2437 of file procedure.cpp.

References _varFactory, NumeReKernel::evalDebuggerBreakPoint(), NumeReDebugger::gatherInformations(), GetCurrentLine(), NumeReKernel::getDebugger(), NumeReKernel::getInstance(), sCurrentProcedureName, and NumeReDebugger::showBreakPoint().

Referenced by execute().

Here is the call graph for this function:

◆ execute()

Returnvalue Procedure::execute ( std::string  sProc,
std::string  sVarList,
mu::Parser _parser,
FunctionDefinitionManager _functions,
MemoryManager _data,
Settings _option,
Output _out,
PlotData _pData,
Script _script,
unsigned int  nth_procedure = 0 
)

This member function is central in the execution of the currently selected procedure as it handles all the logic.

Parameters
sProcstring
sVarListstring
_parserParser&
_functionsDefine&
_dataDatafile&
_optionSettings&
_outOutput&
_pDataPlotData&
_scriptScript&
nth_procedureunsigned int
Returns
Returnvalue

Definition at line 614 of file procedure.cpp.

References _assertionHandler, _localDef, _varFactory, date::abs(), FlowCtrl::baseline, NumeReKernel::baseStackPosition, bProcSupressAnswer, FlowCtrl::bReturnSignal, NumeReKernel::bSupressAnswer, ProcedureCommandLine::BYTECODE_EXPLICIT, ProcedureCommandLine::BYTECODE_FLOWCTRLSTATEMENT, ProcedureCommandLine::BYTECODE_NAMESPACE, ProcedureCommandLine::BYTECODE_NOT_PARSED, ProcedureCommandLine::BYTECODE_PROCEDUREINTERFACE, ProcedureCommandLine::BYTECODE_RETURNCOMMAND, ProcedureCommandLine::BYTECODE_THROWCOMMAND, ProcedureCommandLine::BYTECODE_VARDEF, FunctionDefinitionManager::call(), catchExceptionForTest(), ProcedureVarFactory::createProcedureArguments(), ProcedureVarFactory::createTestStatsCluster(), NumeReKernel::DEBUGGER_LEAVE, NumeReKernel::DEBUGGER_STEP, decodeNameSpace(), FunctionDefinitionManager::defineFunc(), Returnvalue::delayDelete, ProcedureVarFactory::delayDeletionOfReturnedTable(), Settings::enableSystemPrints(), NumeRe::StringParser::evalAndFormat(), evalDebuggerBreakPoint(), extractCurrentNamespace(), findCommand(), ProcedureCommandLine::FLAG_INLINE, ProcedureCommandLine::FLAG_MASK, ProcedureCommandLine::FLAG_PRIVATE, ProcedureCommandLine::FLAG_TEST, g_logger, NumeReDebugger::gatherInformations(), getAllSemiColonSeparatedTokens(), ProcedureCommandLine::getArgumentList(), NumeReDebugger::getBreakpointManager(), FlowCtrl::getCurrentBlockDepth(), GetCurrentLine(), ProcedureElement::getCurrentLine(), NumeReKernel::getDebugger(), NumeReKernel::getInstance(), ProcedureElement::getNextLine(), ProcedureLibrary::getProcedureContents(), FlowCtrl::getReturnSignal(), FlowCtrl::getReturnValue(), Assertion::getStats(), NumeReKernel::getStringParser(), NumeRe::StringVarFactory::getStringValues(), ProcedureElement::gotoProcedure(), handleVariableDefinitions(), SyntaxError::IF_OR_LOOP_SEEMS_NOT_TO_BE_CLOSED, DetachedLogger::info(), SyntaxError::INLINE_PROCEDURE_IS_NOT_INLINE, FlowCtrl::INTERFACE_EMPTY, FlowCtrl::INTERFACE_ERROR, FlowCtrl::INTERFACE_VALUE, SyntaxError::invalid_position, SyntaxError::INVALID_PROCEDURE_NAME, BreakpointManager::isBreakpoint(), FlowCtrl::isFlowCtrlStatement(), ProcedureElement::isLastLine(), NumeRe::StringParser::isStringExpression(), MemoryManager::isTable(), mangleName(), MAX_PROCEDURE_STACK_SIZE, FlowCtrl::mVarMap, mu::ParserBase::mVarMapPntr, nCurrentLine, FlowCtrl::nDebuggerCode, nFlags, FlowCtrl::nReturnType, FlowCtrl::nthRecursion, NumeReDebugger::popStackItem(), SyntaxError::PRIVATE_PROCEDURE_CALLED, ProcCalc(), SyntaxError::PROCEDURE_NOT_FOUND, SyntaxError::PROCEDURE_STACK_OVERFLOW, SyntaxError::PROCEDURE_THROW, procedureInterface(), ProcedureVarFactory, NumeReKernel::ProcLibrary, NumeReDebugger::pushStackItem(), Assertion::reset(), resetProcedure(), ProcedureVarFactory::resolveVariables(), sCallingNameSpace, sCurrentProcedureName, sErrorToken, ProcedureElement::setByteCode(), setProcName(), NumeReDebugger::showError(), sNameSpace, sProcCommandLine, Returnvalue::sReturnedTable, Match::sString, FlowCtrl::sTestClusterName, sThisNameSpace, StripSpaces(), Settings::systemPrints(), NumeReDebugger::throwException(), toString(), ProcedureCommandLine::TYPE_PROCEDURE_FOOT, ProcedureCommandLine::TYPE_PROCEDURE_HEAD, FlowCtrl::updateTestStats(), Settings::useDebugger(), Returnvalue::vNumVal, Returnvalue::vStringVal, and SyntaxError::WRONG_ARG_NAME.

Referenced by NumeReKernel::evaluateProcedureCalls(), and NumeReKernel::executePlugins().

◆ expandInlineProcedures()

vector< string > Procedure::expandInlineProcedures ( std::string &  sLine)
overrideprivatevirtual

This virtual private member function expands all procedures in the current command line, which were declared as "inline" and which are inlinable, into a vector of command lines, which will be inserted in the flow control command array before the current command line.

Parameters
sProcstring&
Returns
vector<string>

Reimplemented from FlowCtrl.

Definition at line 2026 of file procedure.cpp.

References countProceduresInLine(), expandInlineProcedures(), extractProcedureInformation(), getInlined(), getMatchingParenthesis(), isInlineable(), and isInQuotes().

Referenced by expandInlineProcedures().

Here is the call graph for this function:

◆ extractCurrentNamespace()

void Procedure::extractCurrentNamespace ( const std::string &  sProc)
private

This member function extracts the namespace of the currently executed procedure.

Parameters
sProcconst string&
Returns
void

Definition at line 2728 of file procedure.cpp.

References sCallingNameSpace, and sThisNameSpace.

Referenced by execute().

◆ extractProcedureInformation()

void Procedure::extractProcedureInformation ( const std::string &  sCmdLine,
size_t  nPos,
std::string &  sProcName,
std::string &  sArgList,
std::string &  sFileName 
)
private

This private member function extracts procedure name, argument list and the corresponding file name from the passed position in the command line.

Parameters
sCmdLineconst string&
nPossize_t
sProcNamestring&
sArgListstring&
sFileNamestring&
Returns
void

Definition at line 1880 of file procedure.cpp.

References getMatchingParenthesis(), SyntaxError::invalid_position, SyntaxError::PRIVATE_PROCEDURE_CALLED, sNameSpace, sProcNames, sThisNameSpace, and FileSystem::ValidFileName().

Referenced by expandInlineProcedures(), and isInline().

Here is the call graph for this function:

◆ GetCurrentLine()

unsigned int Procedure::GetCurrentLine ( ) const

◆ getCurrentProcedureName()

◆ getDebuggerCode()

int & Procedure::getDebuggerCode ( )
inline

Definition at line 122 of file procedure.hpp.

References FlowCtrl::nDebuggerCode.

Referenced by NumeReKernel::MainLoop().

◆ getErrorInformationForDebugger()

int Procedure::getErrorInformationForDebugger ( )
overridevirtual

This virtual member function handles the gathering of all relevant information for the debugger for the currently found error.

Returns
int

Reimplemented from FlowCtrl.

Definition at line 2464 of file procedure.cpp.

References _varFactory, NumeReDebugger::gatherInformations(), GetCurrentLine(), NumeReKernel::getDebugger(), NumeReKernel::getInstance(), and sCurrentProcedureName.

Here is the call graph for this function:

◆ getInlined()

vector< string > Procedure::getInlined ( const std::string &  sProc,
const std::string &  sArgumentList,
const std::string &  sFileName,
size_t  nProcedures 
)
private

◆ getProcedureFlags()

◆ getReturnType()

int Procedure::getReturnType ( ) const
inline

Definition at line 116 of file procedure.hpp.

References FlowCtrl::nReturnType.

Referenced by NumeReKernel::evaluateProcedureCalls().

◆ handleIncludeSyntax()

int Procedure::handleIncludeSyntax ( std::string &  sProcCommandLine,
std::ifstream &  fInclude,
bool  bReadingFromInclude 
)
private

This member function handles the script include syntax, which one may use in other procedures.

Parameters
sProcCommandLinestring&
fIncludeifstream&
bReadingFromIncludebool
Returns
int

The included file is indicated with an "@" and its file name afterwards. This function will decode this syntax and open the corresponding file stream.

Definition at line 2834 of file procedure.cpp.

References SyntaxError::invalid_position, SyntaxError::SCRIPT_NOT_EXIST, sProcCommandLine, StripSpaces(), and FileSystem::ValidFileName().

Here is the call graph for this function:

◆ handleVariableDefinitions()

bool Procedure::handleVariableDefinitions ( std::string &  sProcCommandLine,
const std::string &  sCommand 
)
private

This method handles the definitions of local variables.

Parameters
sProcCommandLinestring&
sCommandconst string&
Returns
bool

It will return true, if a definition occured, otherwise false. The return value will be used to create a corresponding byte code.

Definition at line 2776 of file procedure.cpp.

References _varFactory, ProcedureVarFactory::createLocalClusters(), ProcedureVarFactory::createLocalStrings(), ProcedureVarFactory::createLocalTables(), ProcedureVarFactory::createLocalVars(), and sProcCommandLine.

Referenced by execute().

Here is the call graph for this function:

◆ init()

void Procedure::init ( )
private

Private initializing member function. Sets all variables to a reasonable default value.

Returns
void

Definition at line 98 of file procedure.cpp.

References _varFactory, bProcSupressAnswer, bWritingTofile, nCurrentLine, nFlags, nthBlock, and sCallingNameSpace.

Referenced by Procedure().

◆ is_writing()

◆ isInline()

int Procedure::isInline ( const std::string &  sProc)
overridevirtual

This virtual member function checks, whether the procedures in the current line are declared as inline and whether they are inlinable.

Parameters
sProcconst string&
Returns
int one of ProcedureCommendLine::Inlineable values

Reimplemented from FlowCtrl.

Definition at line 1958 of file procedure.cpp.

References extractProcedureInformation(), ProcedureCommandLine::INLINING_IMPOSSIBLE, ProcedureCommandLine::INLINING_POSSIBLE, isInlineable(), isInQuotes(), and max.

Here is the call graph for this function:

◆ isInlineable()

int Procedure::isInlineable ( const std::string &  sProc,
const std::string &  sFileName,
int *  nInlineFlag = nullptr 
)
private

This private member function evaluates, whether the current procedure is inlineable, i.e. whether it fulfills the internal inlining rules.

Parameters
sProcconst string&
sFileNameconst string&
nInlineFlagint*
Returns
int one of ProcedureCommendLine::Inlineable values

Definition at line 2109 of file procedure.cpp.

References applyInliningRuleset(), findCommand(), ProcedureCommandLine::FLAG_INLINE, ProcedureElement::getCurrentLine(), ProcedureElement::getNextLine(), ProcedureLibrary::getProcedureContents(), ProcedureElement::gotoProcedure(), ProcedureCommandLine::INLINING_IMPOSSIBLE, ProcedureCommandLine::INLINING_UNKNOWN, SyntaxError::invalid_position, ProcedureElement::isLastLine(), SyntaxError::PROCEDURE_NOT_FOUND, NumeReKernel::ProcLibrary, Match::sString, and ProcedureCommandLine::TYPE_PROCEDURE_FOOT.

Referenced by expandInlineProcedures(), and isInline().

Here is the call graph for this function:

◆ mangleName()

std::string Procedure::mangleName ( std::string  sProcedureName)
static

Mangles a procedure name to be used as a usual variable.

Parameters
sProcedureNamestd::string
Returns
std::string

Definition at line 2414 of file procedure.cpp.

Referenced by NumeReKernel::evaluateProcedureCalls(), execute(), and procedureInterface().

◆ ProcCalc()

Returnvalue Procedure::ProcCalc ( std::string  sLine,
std::string  sCurrentCommand,
int &  nByteCode,
mu::Parser _parser,
FunctionDefinitionManager _functions,
MemoryManager _data,
Settings _option,
Output _out,
PlotData _pData,
Script _script 
)
private

This member function does the evaluation stuff regarding strings and numerical expressions for the current procedure.

Parameters
sLinestring
sCurrentCommandstring
nByteCodeint&
_parserParser&
_functionsDefine&
_dataDatafile&
_optionSettings&
_outOutput&
_pDataPlotData&
_scriptScript&
Returns
Returnvalue

Definition at line 130 of file procedure.cpp.

References _assertionHandler, mu::ParserBase::ActiveLoopMode(), NumeRe::Cluster::assignResults(), bProcSupressAnswer, NumeReKernel::bSupressAnswer, ProcedureCommandLine::BYTECODE_ASSERT, ProcedureCommandLine::BYTECODE_COMMAND, ProcedureCommandLine::BYTECODE_DATAACCESS, ProcedureCommandLine::BYTECODE_FLOWCTRLSTATEMENT, ProcedureCommandLine::BYTECODE_NOT_PARSED, ProcedureCommandLine::BYTECODE_PROMPT, ProcedureCommandLine::BYTECODE_RECURSIVEEXPRESSION, ProcedureCommandLine::BYTECODE_STRING, ProcedureCommandLine::BYTECODE_THROWCOMMAND, ProcedureCommandLine::BYTECODE_TOCOMMAND, FunctionDefinitionManager::call(), Assertion::checkAssertion(), Returnvalue::clear(), mu::ParserBase::ClearVectorVars(), Indices::col, COMMAND_HAS_RETURNVALUE, COMMAND_PROCESSED, commandHandler(), MemoryManager::containsTablesOrClusters(), Assertion::enable(), mu::ParserBase::Eval(), NumeRe::StringParser::evalAndFormat(), evalRecursiveExpressions(), findCommand(), ProcedureCommandLine::FLAG_INLINE, ProcedureCommandLine::FLAG_TEMPLATE, NumeReKernel::formatResultOutput(), SyntaxError::FUNCTION_ERROR, NumeReKernel::getAns(), NumeReKernel::GetAsyncCancelState(), NumeRe::ClusterManager::getCluster(), FlowCtrl::getCurrentBlockDepth(), getDataElements(), getIndices(), NumeReKernel::getInstance(), getMatchingParenthesis(), getStringArgument(), NumeReKernel::getStringParser(), NumeRe::StringVarFactory::getStringValues(), SyntaxError::INVALID_INDEX, SyntaxError::invalid_position, mu::ParserBase::IsAlreadyParsed(), isClusterCandidate(), FlowCtrl::isFlowCtrlStatement(), isInQuotes(), mu::ParserBase::IsLockedPause(), VectorIndex::isOpenEnd(), NumeRe::StringParser::isStringExpression(), isValidIndexSet(), nCurrentLine, nFlags, NO_COMMAND, SyntaxError::NO_MATRIX, NumeReKernel::print(), SyntaxError::PROCEDURE_THROW, procedureInterface(), SyntaxError::PROCESS_ABORTED_BY_USER, promptForUserInput(), NumeRe::StringVarFactory::removeTempStringVectorVars(), FlowCtrl::replaceLocalVars(), Indices::row, sErrorToken, FlowCtrl::setCommand(), NumeRe::Cluster::setDoubleArray(), mu::ParserBase::SetExpr(), Match::sString, NumeRe::StringParser::STRING_SUCCESS, StripSpaces(), NumeRe::Cluster::to_string(), VectorIndex::to_string(), SyntaxError::UNMATCHED_PARENTHESIS, vAns, Returnvalue::vNumVal, Returnvalue::vStringVal, and MemoryManager::writeToTable().

Referenced by execute().

Here is the call graph for this function:

◆ procedureCmdInterface()

int Procedure::procedureCmdInterface ( std::string &  sLine)
overrideprivatevirtual

Virtual member function allowing to identify and evaluate some special procedure commands. Currently it is only used for the namespace command.

Parameters
sLinestring&
Returns
int

The commands "var", "str", "tab" and "cst" are recognized but not evaluated.

Reimplemented from FlowCtrl.

Definition at line 1494 of file procedure.cpp.

References findCommand(), sNameSpace, Match::sString, sThisNameSpace, and StripSpaces().

Here is the call graph for this function:

◆ procedureInterface()

FlowCtrl::ProcedureInterfaceRetVal Procedure::procedureInterface ( std::string &  sLine,
mu::Parser _parser,
FunctionDefinitionManager _functions,
MemoryManager _data,
Output _out,
PlotData _pData,
Script _script,
Settings _option,
int  nth_command = 0 
)
overridevirtual

This member function handles the calls for procedures and plugins, resolves them and executes the called procedures by constructing a new instance of this class on the heap.

Parameters
sLinestring&
_parserParser&
_functionsDefine&
_dataDatafile&
_outOutput&
_pDataPlotData&
_scriptScript&
_optionSettings&
nth_commandint
Returns
FlowCtrl::ProcedureInterfaceRetVal

Reimplemented from FlowCtrl.

Definition at line 1250 of file procedure.cpp.

References FlowCtrl::bReturnSignal, MemoryManager::copyTable(), mu::ParserBase::CreateTempVectorVar(), Returnvalue::delayDelete, MemoryManager::deleteTable(), Settings::enableSystemPrints(), findCommand(), ProcedureCommandLine::FLAG_EXPLICIT, ProcedureCommandLine::FLAG_INLINE, ProcedureCommandLine::FLAG_MASK, MemoryManager::getCols(), MemoryManager::getLines(), getMatchingParenthesis(), SyntaxError::INLINE_PROCEDURE_IS_NOT_INLINE, FlowCtrl::INTERFACE_EMPTY, FlowCtrl::INTERFACE_ERROR, FlowCtrl::INTERFACE_NONE, FlowCtrl::INTERFACE_VALUE, SyntaxError::invalid_position, MemoryManager::isEmpty(), isInQuotes(), MemoryManager::isTable(), mangleName(), FlowCtrl::mVarMap, mu::ParserBase::mVarMapPntr, nFlags, Match::nPos, FlowCtrl::nReturnType, FlowCtrl::nthRecursion, Procedure(), MemoryManager::renameTable(), replaceReturnVal(), FlowCtrl::ReturnVal, mu::ParserBase::SetVectorVar(), sNameSpace, Returnvalue::sReturnedTable, Match::sString, sThisNameSpace, StripSpaces(), MemoryManager::swapTables(), Settings::systemPrints(), toString(), SyntaxError::UNMATCHED_PARENTHESIS, FlowCtrl::updateTestStats(), Returnvalue::vNumVal, and Returnvalue::vStringVal.

Referenced by ProcedureVarFactory::createLocalClusters(), ProcedureVarFactory::createLocalStrings(), ProcedureVarFactory::createLocalTables(), ProcedureVarFactory::createLocalVars(), ProcedureVarFactory::evaluateProcedureArguments(), execute(), and ProcCalc().

Here is the call graph for this function:

◆ replaceReturnVal()

size_t Procedure::replaceReturnVal ( std::string &  sLine,
mu::Parser _parser,
const Returnvalue _return,
unsigned int  nPos,
unsigned int  nPos2,
const std::string &  sReplaceName 
)

This member function replaces the procedure occurence between the both passed positions using akronymed version of the called procedure. It also declares the numerical return value as a vector to the parser.

Parameters
sLinestring&
_parserParser&
_returnconst Returnvalue&
nPosunsigned int
nPos2unsigned int
sReplaceNameconst string&
Returns
size_t

Definition at line 2591 of file procedure.cpp.

References FlowCtrl::bReturnSignal, MemoryManager::copyTable(), NumeRe::StringVarFactory::createTempStringVectorVar(), mu::ParserBase::CreateTempVectorVar(), Returnvalue::delayDelete, MemoryManager::deleteTable(), findCommand(), MemoryManager::getCols(), NumeReKernel::getInstance(), MemoryManager::getLines(), NumeReKernel::getMemoryManager(), NumeReKernel::getStringParser(), MemoryManager::isEmpty(), Returnvalue::isNumeric(), Returnvalue::isString(), MemoryManager::isTable(), Match::nPos, MemoryManager::renameTable(), FlowCtrl::ReturnVal, mu::ParserBase::SetVectorVar(), Returnvalue::sReturnedTable, Match::sString, StripSpaces(), MemoryManager::swapTables(), Returnvalue::vNumVal, and Returnvalue::vStringVal.

Referenced by NumeReKernel::evaluateProcedureCalls(), and procedureInterface().

Here is the call graph for this function:

◆ resetProcedure()

void Procedure::resetProcedure ( mu::Parser _parser,
bool  bSupressAnswer 
)
private

This member function sets the current procedure object to its original state. It will be called at the end of the executed procedure.

Parameters
_parserParser&
bSupressAnswerbool
Returns
void

Definition at line 2686 of file procedure.cpp.

References _localDef, _varFactory, NumeReKernel::bSupressAnswer, NumeReKernel::getDebugger(), NumeReKernel::getInstance(), FlowCtrl::mVarMap, mu::ParserBase::mVarMapPntr, FlowCtrl::nDebuggerCode, nFlags, FlowCtrl::nthRecursion, NumeReDebugger::popStackItem(), FunctionDefinitionManager::reset(), sCallingNameSpace, sNameSpace, sProcNames, FlowCtrl::sTestClusterName, and sThisNameSpace.

Referenced by catchExceptionForTest(), and execute().

Here is the call graph for this function:

◆ setPredefinedFuncs()

void Procedure::setPredefinedFuncs ( const std::string &  sPredefined)
inline

Definition at line 109 of file procedure.hpp.

References _localDef, and FunctionDefinitionManager::setPredefinedFuncs().

Referenced by NumeReKernel::StartUp().

Here is the call graph for this function:

◆ setProcName()

bool Procedure::setProcName ( const std::string &  sProc,
bool  bInstallFileName = false 
)
private

This member function is used to obtain the procedure file name from the selected procedure. It handles the "thisfile" namespace directly.

Parameters
sProcconst string&
bInstallFileNamebool
Returns
bool

Definition at line 547 of file procedure.cpp.

References sCurrentProcedureName, sLastWrittenProcedureFile, sProcNames, and FileSystem::ValidFileName().

Referenced by execute(), and writeProcedure().

Here is the call graph for this function:

◆ writeProcedure()

bool Procedure::writeProcedure ( std::string  sProcedureLine)

This member function handles the procedure installation process by governing the file stream and passing the corresponding procedure linewards to the stream.

Parameters
sProcedureLinestring
Returns
bool

Definition at line 1547 of file procedure.cpp.

References _lang, bWritingTofile, findCommand(), fProcedure, Language::get(), getMatchingParenthesis(), getTimeStamp(), SyntaxError::IF_OR_LOOP_SEEMS_NOT_TO_BE_CLOSED, SyntaxError::invalid_position, isInQuotes(), nthBlock, sCurrentProcedureName, FileSystem::setPath(), setProcName(), sLastWrittenProcedureFile, FileSystem::sTokens, StripSpaces(), toUpperCase(), date::detail::trunc(), and writeProcedure().

Referenced by NumeReKernel::handleProcedureWrite(), Script::writeProcedure(), and writeProcedure().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ NumeReDebugger

friend class NumeReDebugger
friend

Definition at line 58 of file procedure.hpp.

◆ ProcedureVarFactory

friend class ProcedureVarFactory
friend

Definition at line 59 of file procedure.hpp.

Referenced by execute().

Member Data Documentation

◆ _localDef

FunctionDefinitionManager Procedure::_localDef
private

Definition at line 76 of file procedure.hpp.

Referenced by execute(), Procedure(), resetProcedure(), and setPredefinedFuncs().

◆ _varFactory

◆ bProcSupressAnswer

bool Procedure::bProcSupressAnswer
private

Definition at line 70 of file procedure.hpp.

Referenced by execute(), init(), and ProcCalc().

◆ bWritingTofile

bool Procedure::bWritingTofile
private

Definition at line 71 of file procedure.hpp.

Referenced by init(), is_writing(), and writeProcedure().

◆ fProcedure

std::fstream Procedure::fProcedure
private

Definition at line 61 of file procedure.hpp.

Referenced by writeProcedure(), and ~Procedure().

◆ nCurrentLine

int Procedure::nCurrentLine
private

Definition at line 64 of file procedure.hpp.

Referenced by execute(), GetCurrentLine(), init(), and ProcCalc().

◆ nFlags

int Procedure::nFlags
private

◆ nthBlock

int Procedure::nthBlock
private

Definition at line 73 of file procedure.hpp.

Referenced by init(), and writeProcedure().

◆ sCallingNameSpace

std::string Procedure::sCallingNameSpace
private

Definition at line 66 of file procedure.hpp.

Referenced by execute(), extractCurrentNamespace(), init(), Procedure(), and resetProcedure().

◆ sCurrentProcedureName

◆ sLastWrittenProcedureFile

std::string Procedure::sLastWrittenProcedureFile
private

Definition at line 68 of file procedure.hpp.

Referenced by setProcName(), and writeProcedure().

◆ sNameSpace

std::string Procedure::sNameSpace
private

◆ sProcCommandLine

std::string Procedure::sProcCommandLine
private

◆ sProcNames

std::string Procedure::sProcNames
private

Definition at line 62 of file procedure.hpp.

Referenced by extractProcedureInformation(), Procedure(), resetProcedure(), and setProcName().

◆ sThisNameSpace

std::string Procedure::sThisNameSpace
private

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