|
yast2-core
|
00001 /* 00002 * YaST2: Core system 00003 * 00004 * Description: 00005 * YaST2 execution environment, i.e. processing context. 00006 * Contains reference to the current block, the current statement, 00007 * the current file name and backtrace. 00008 * This information can be used for logging, debugger etc. 00009 * 00010 * Authors: 00011 * Stanislav Visnovsky <visnov@suse.cz> 00012 * 00013 */ 00014 00015 #ifndef _execution_environment_h 00016 #define _execution_environment_h 00017 00018 #include <stack> 00019 #include <string> 00020 00021 #include "y2log.h" 00022 #include "ycp/YStatement.h" 00023 #include "ycp/YExpression.h" 00024 00025 #include <ycp/YCPValue.h> 00026 00027 using namespace std; 00028 00030 struct CallFrame { 00031 YECallPtr function; 00032 string filename; 00033 int linenumber; 00034 YCPValue* params; 00035 00036 CallFrame (string f, int l, YECallPtr func, YCPValue* p): 00037 function (func), 00038 filename (f), 00039 linenumber (l) 00040 { 00041 params = p; 00042 } 00043 }; 00044 00053 class ExecutionEnvironment { 00054 00055 public: 00056 typedef vector<const CallFrame*> CallStack; 00057 00058 private: 00059 int m_linenumber; 00060 string m_filename; 00061 bool m_forced_filename; 00062 YStatementPtr m_statement; 00063 CallStack m_backtrace; 00069 size_t m_recursion_limit; 00070 00071 public: 00072 ExecutionEnvironment (); 00073 ~ExecutionEnvironment() {}; 00074 00078 int linenumber () const; 00079 00083 void setLinenumber (int line); 00084 00088 const string filename () const; 00089 00093 void setFilename (const string & filename); 00094 00098 YStatementPtr statement () const; 00099 00103 void setStatement (YStatementPtr s); 00104 00108 bool endlessRecursion (); 00109 00116 void pushframe (YECallPtr called_function, YCPValue params[]); 00117 00121 void popframe (); 00122 00129 void backtrace (loglevel_t level, uint skip = 0) const; 00130 00137 CallStack callstack() const; 00138 }; 00139 00140 #endif /* _execution_environment_h */
1.7.5.1