#include <ExecutionEnvironment.h>
Public Types | |
typedef vector< const CallFrame * > | CallStack |
Public Member Functions | |
ExecutionEnvironment () | |
~ExecutionEnvironment () | |
int | linenumber () const |
void | setLinenumber (int line) |
const string | filename () const |
void | setFilename (const string &filename) |
YStatementPtr | statement () const |
void | setStatement (YStatementPtr s) |
bool | endlessRecursion () |
void | pushframe (string called_function) |
void | popframe () |
void | backtrace (loglevel_t level, uint skip=0) const |
CallStack | callstack () const |
Private Attributes | |
int | m_linenumber |
string | m_filename |
bool | m_forced_filename |
YStatementPtr | m_statement |
CallStack | m_backtrace |
size_t | m_recursion_limit |
Class to track current execution environment. Typically used for logging and debugging.
m_forced_filename is a way to enforce a given filename until another block is entered (or the current one is left). Used for include statements, where top level block does not exist.
typedef vector<const CallFrame*> ExecutionEnvironment::CallStack |
ExecutionEnvironment::ExecutionEnvironment | ( | ) |
References m_backtrace, m_recursion_limit, WARN_RECURSION, and Y2RECURSIONLIMIT.
ExecutionEnvironment::~ExecutionEnvironment | ( | ) | [inline] |
void ExecutionEnvironment::backtrace | ( | loglevel_t | level, | |
uint | skip = 0 | |||
) | const |
Report the current backtrace to log.
skip | number of the top call frames to be omitted from the backtrace |
References m_backtrace, y2logger, and ycp2log.
Referenced by Y2FDebug(), Y2FError(), Y2FInternal(), Y2FMilestone(), Y2FSecurity(), and Y2FWarning().
ExecutionEnvironment::CallStack ExecutionEnvironment::callstack | ( | ) | const |
Returns a copy of the call stack for debugging etc.
The stack itself may safely be modified. The pointers it contains, however, may not.
References m_backtrace.
bool ExecutionEnvironment::endlessRecursion | ( | ) |
Report error if there are too many stack frames
References m_backtrace, m_recursion_limit, y2error, and Y2RECURSIONLIMIT.
Referenced by YEFunction::evaluate().
const string ExecutionEnvironment::filename | ( | ) | const |
Get the current file name.
References m_filename.
Referenced by YEBuiltin::attachSymVariable(), Y2WFMComponent::CallFunction(), YEFunctionPointer::evaluate(), YEFunction::evaluate(), YBlock::evaluate(), Y2YCPFunction::evaluateCall(), YBlock::evaluateFrom(), pushframe(), signal_handler(), ScriptingAgent::Sweep(), Y2Log(), YCPIntegerRep::YCPIntegerRep(), and YEPropagate::YEPropagate().
int ExecutionEnvironment::linenumber | ( | ) | const |
Get the current line number.
References m_linenumber.
Referenced by YEBuiltin::attachSymVariable(), Y2WFMComponent::CallFunction(), YEFunctionPointer::evaluate(), YEFunction::evaluate(), Y2YCPFunction::evaluateCall(), pushframe(), signal_handler(), ScriptingAgent::Sweep(), Y2Log(), YCPIntegerRep::YCPIntegerRep(), and YEPropagate::YEPropagate().
void ExecutionEnvironment::popframe | ( | ) |
Pop the top call frame from the backtrace stack.
References m_backtrace, and y2debug.
Referenced by YEFunction::evaluate().
void ExecutionEnvironment::pushframe | ( | string | called_function | ) |
Push another call frame to the backtrace stack according to the current information.
called_function | name of the function to be called at this point |
References filename(), linenumber(), m_backtrace, and y2debug.
Referenced by YEFunction::evaluate().
void ExecutionEnvironment::setFilename | ( | const string & | filename | ) |
Set the current file name for error outputs.
References m_filename, and m_forced_filename.
Referenced by Y2WFMComponent::CallFunction(), YSFilename::evaluate(), YSInclude::evaluate(), YEFunctionPointer::evaluate(), YEFunction::evaluate(), YBlock::evaluate(), Y2YCPFunction::evaluateCall(), YBlock::evaluateFrom(), main(), and parsefile().
void ExecutionEnvironment::setLinenumber | ( | int | line | ) |
Set the current line number.
References m_linenumber.
Referenced by Y2WFMComponent::CallFunction(), YEFunctionPointer::evaluate(), YEFunction::evaluate(), Y2YCPFunction::evaluateCall(), and parsefile().
void ExecutionEnvironment::setStatement | ( | YStatementPtr | s | ) |
Set the currently evaluated statement.
References m_linenumber, and m_statement.
Referenced by YBlock::evaluate(), and YBlock::evaluateFrom().
YStatementPtr ExecutionEnvironment::statement | ( | ) | const |
Return the currently evaluated statement.
References m_statement.
CallStack ExecutionEnvironment::m_backtrace [private] |
Referenced by backtrace(), callstack(), endlessRecursion(), ExecutionEnvironment(), popframe(), and pushframe().
string ExecutionEnvironment::m_filename [private] |
Referenced by filename(), and setFilename().
bool ExecutionEnvironment::m_forced_filename [private] |
Referenced by setFilename().
int ExecutionEnvironment::m_linenumber [private] |
Referenced by linenumber(), setLinenumber(), and setStatement().
size_t ExecutionEnvironment::m_recursion_limit [private] |
There is a limit of 1001 call frames (overridable by Y2RECURSIONLIMIT in the environment). After that, a call is skipped and nil is returned instead.
Referenced by endlessRecursion(), and ExecutionEnvironment().
YStatementPtr ExecutionEnvironment::m_statement [private] |
Referenced by setStatement(), and statement().