new source file for formula debugger
This commit is contained in:
parent
0525d76b79
commit
cf0c168e1c
8 changed files with 118 additions and 0 deletions
|
@ -185,6 +185,8 @@
|
|||
<Unit filename="..\..\src\formatter.hpp" />
|
||||
<Unit filename="..\..\src\formula.cpp" />
|
||||
<Unit filename="..\..\src\formula.hpp" />
|
||||
<Unit filename="..\..\src\formula_debugger.cpp" />
|
||||
<Unit filename="..\..\src\formula_debugger.hpp" />
|
||||
<Unit filename="..\..\src\formula_callable.hpp" />
|
||||
<Unit filename="..\..\src\formula_function.cpp" />
|
||||
<Unit filename="..\..\src\formula_function.hpp" />
|
||||
|
|
|
@ -214,6 +214,8 @@
|
|||
<Unit filename="..\..\src\formatter.hpp" />
|
||||
<Unit filename="..\..\src\formula.cpp" />
|
||||
<Unit filename="..\..\src\formula.hpp" />
|
||||
<Unit filename="..\..\src\formula_debugger.cpp" />
|
||||
<Unit filename="..\..\src\formula_debugger.hpp" />
|
||||
<Unit filename="..\..\src\formula_callable.hpp" />
|
||||
<Unit filename="..\..\src\formula_function.cpp" />
|
||||
<Unit filename="..\..\src\formula_function.hpp" />
|
||||
|
|
|
@ -353,6 +353,10 @@
|
|||
RelativePath="..\..\src\formula.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\formula_debugger.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\formula_function.cpp"
|
||||
>
|
||||
|
@ -4728,6 +4732,10 @@
|
|||
RelativePath="..\..\src\formula_callable.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\formula_debugger.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\formula_function.hpp"
|
||||
>
|
||||
|
|
|
@ -262,6 +262,7 @@ SET(wesnoth-main_SRC
|
|||
dialogs.cpp
|
||||
floating_textbox.cpp
|
||||
formula.cpp
|
||||
formula_debugger.cpp
|
||||
formula_function.cpp
|
||||
formula_tokenizer.cpp
|
||||
formula_string_utils.cpp
|
||||
|
|
|
@ -85,6 +85,7 @@ wesnoth_source = \
|
|||
dialogs.cpp \
|
||||
floating_textbox.cpp \
|
||||
formula.cpp \
|
||||
formula_debugger.cpp \
|
||||
formula_function.cpp \
|
||||
formula_tokenizer.cpp \
|
||||
formula_string_utils.cpp \
|
||||
|
|
|
@ -190,6 +190,7 @@ wesnoth_sources = Split("""
|
|||
dialogs.cpp
|
||||
floating_textbox.cpp
|
||||
formula.cpp
|
||||
formula_debugger.cpp
|
||||
formula_function.cpp
|
||||
formula_tokenizer.cpp
|
||||
formula_string_utils.cpp
|
||||
|
|
56
src/formula_debugger.cpp
Normal file
56
src/formula_debugger.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Yurii Chernyi <terraninfo@terraninfo.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file formula_debugger.cpp
|
||||
* Formula debugger - implementation
|
||||
* */
|
||||
|
||||
|
||||
#include "formula_debugger.hpp"
|
||||
#include "formula.hpp"
|
||||
#include "formula_function.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
static lg::log_domain log_formula_debugger("ai/debug/formula");
|
||||
#define DBG_FDB LOG_STREAM(debug, log_formula_debugger)
|
||||
#define LOG_FDB LOG_STREAM(info, log_formula_debugger)
|
||||
#define WRN_FDB LOG_STREAM(warn, log_formula_debugger)
|
||||
#define ERR_FDB LOG_STREAM(err, log_formula_debugger)
|
||||
|
||||
namespace game_logic {
|
||||
|
||||
formula_debugger::formula_debugger()
|
||||
: counter_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
formula_debugger::~formula_debugger()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
variant formula_debugger::evaluate_arg_callback(formula_expression &/*expression*/, const formula_callable &/*variables*/)
|
||||
{
|
||||
int counter = counter_++;
|
||||
DBG_FDB << "#"<< counter <<": evaluating \"" << /*expression.to_debug_string() << */ "\"" <<std::endl;
|
||||
variant v; //= expression.evaluate(variables,this); //work-in-progress
|
||||
DBG_FDB << "#"<< counter <<": evaluated \"" << /*expression.to_debug_string() << */ "\" to " << v.to_debug_string(NULL,true) << std::endl;
|
||||
return v;
|
||||
}
|
||||
|
||||
} // end of namespace game_logic
|
47
src/formula_debugger.hpp
Normal file
47
src/formula_debugger.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Yurii Chernyi <terraninfo@terraninfo.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file formula_debugger.hpp
|
||||
* Formula AI debugger
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FORMULA_DEBUGGER_HPP_INCLUDED
|
||||
#define FORMULA_DEBUGGER_HPP_INCLUDED
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "variant.hpp"
|
||||
|
||||
namespace game_logic {
|
||||
|
||||
class formula_expression;
|
||||
class formula_callable;
|
||||
|
||||
class formula_debugger {
|
||||
public:
|
||||
formula_debugger();
|
||||
|
||||
virtual ~formula_debugger();
|
||||
|
||||
virtual variant evaluate_arg_callback(formula_expression &expression, const formula_callable &variables);
|
||||
private:
|
||||
int counter_;
|
||||
};
|
||||
|
||||
} // end of namespace game_logic
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue