formula_debugger.hpp

Go to the documentation of this file.
00001 /* $Id: formula_debugger.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2009 - 2012 by Yurii Chernyi <terraninfo@terraninfo.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 /**
00017  * @file
00018  * Formula AI debugger
00019  *
00020  */
00021 
00022 #ifndef FORMULA_DEBUGGER_HPP_INCLUDED
00023 #define FORMULA_DEBUGGER_HPP_INCLUDED
00024 
00025 #include "global.hpp"
00026 
00027 #include "variant.hpp"
00028 #include "formula_debugger_fwd.hpp"
00029 #include <deque>
00030 
00031 namespace game_logic {
00032 
00033 class formula_expression;
00034 class formula_callable;
00035 class formula;
00036 class formula_debugger;
00037 
00038 class debug_info {
00039 public:
00040     debug_info(int arg_number, int counter, int level, const std::string &name, const std::string &str, const variant &value, bool evaluated);
00041     virtual ~debug_info();
00042     int counter() const;
00043     int level() const;
00044     const std::string& name() const;
00045     const std::string& str() const;
00046     const variant& value() const;
00047     const std::string& value_str() const;
00048     bool evaluated() const;
00049     void set_evaluated(bool evaluated);
00050     void set_value(const variant &value);
00051 private:
00052     int arg_number_;
00053     int counter_;
00054     int level_;
00055     std::string name_;
00056     std::string str_;
00057     variant value_;
00058     bool evaluated_;
00059 
00060 };
00061 
00062 class base_breakpoint {
00063 public:
00064     base_breakpoint(formula_debugger &fdb, const std::string &name, bool one_time_only);
00065     virtual ~base_breakpoint();
00066     virtual bool is_break_now() const = 0;
00067     bool is_one_time_only() const;
00068     const std::string &name() const;
00069 protected:
00070     formula_debugger &fdb_;
00071     std::string name_;
00072     bool one_time_only_;
00073 
00074 };
00075 
00076 
00077 class formula_debugger {
00078 public:
00079     formula_debugger();
00080 
00081 
00082     virtual ~formula_debugger();
00083 
00084 
00085     void add_debug_info(int arg_number, const char *f_name);
00086 
00087 
00088     void call_stack_push(const std::string &str);
00089 
00090 
00091     void call_stack_pop();
00092 
00093 
00094     void call_stack_set_evaluated(bool evaluated);
00095 
00096 
00097     void call_stack_set_value(const variant &v);
00098 
00099 
00100     void check_breakpoints();
00101 
00102 
00103     const std::deque<debug_info>& get_call_stack() const;
00104 
00105 
00106     const breakpoint_ptr get_current_breakpoint() const;
00107 
00108 
00109     const std::deque<debug_info>& get_execution_trace() const;
00110 
00111 
00112     variant evaluate_arg_callback(const formula_expression &expression, const formula_callable &variables);
00113 
00114 
00115     variant evaluate_formula_callback(const formula &f, const formula_callable &variables);
00116 
00117 
00118     variant evaluate_formula_callback(const formula &f);
00119 
00120 
00121     void show_gui();
00122 
00123 
00124     void add_breakpoint_continue_to_end();
00125 
00126 
00127     void add_breakpoint_step_into();
00128 
00129 
00130     void add_breakpoint_step_out();
00131 
00132 
00133     void add_breakpoint_next();
00134 
00135 
00136     //static functions
00137 
00138     static formula_debugger* add_debug_info(formula_debugger *fdb, int arg_number, const char *f_name)
00139     {
00140         if (fdb==NULL) {
00141             return NULL;
00142         }
00143         fdb->add_debug_info(arg_number,f_name);
00144         return fdb;
00145     }
00146 
00147 private:
00148     std::deque<debug_info> call_stack_;
00149     int counter_;
00150     breakpoint_ptr current_breakpoint_;
00151     std::deque< breakpoint_ptr > breakpoints_;
00152     std::deque<debug_info> execution_trace_;
00153     int arg_number_extra_debug_info;
00154     const char *f_name_extra_debug_info;
00155 
00156 
00157 };
00158 
00159 
00160 
00161 } // end of namespace game_logic
00162 
00163 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:36 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs