Wrap up of clean up of warnings in 64bit visual studio

This commit is contained in:
Jason Turner 2010-11-05 04:05:02 +00:00
parent 6e18aa3dcd
commit e1e48d732f
5 changed files with 64 additions and 58 deletions

View File

@ -89,7 +89,7 @@ endif()
if (CMAKE_COMPILER_2005) if (CMAKE_COMPILER_2005)
# vs2005 is a bit too loud about possible loss of data warnings # vs2005 is a bit too loud about possible loss of data warnings
ADD_DEFINITIONS(/wd4244) # ADD_DEFINITIONS(/wd4244)
endif() endif()
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})

View File

@ -16,7 +16,6 @@
#include "dispatchkit.hpp" #include "dispatchkit.hpp"
#include "register_function.hpp" #include "register_function.hpp"
namespace chaiscript namespace chaiscript
{ {
namespace bootstrap namespace bootstrap
@ -522,4 +521,5 @@ namespace detail {
} }
} }
#endif #endif

View File

@ -586,7 +586,6 @@ namespace chaiscript
engine.add(fun(static_cast<load_mod_1>(&ChaiScript_System<Eval_Engine>::load_module), this), "load_module"); engine.add(fun(static_cast<load_mod_1>(&ChaiScript_System<Eval_Engine>::load_module), this), "load_module");
engine.add(fun(static_cast<load_mod_2>(&ChaiScript_System<Eval_Engine>::load_module), this), "load_module"); engine.add(fun(static_cast<load_mod_2>(&ChaiScript_System<Eval_Engine>::load_module), this), "load_module");
add(vector_type<std::vector<Boxed_Value> >("Vector")); add(vector_type<std::vector<Boxed_Value> >("Vector"));
add(string_type<std::string>("string")); add(string_type<std::string>("string"));
add(map_type<std::map<std::string, Boxed_Value> >("Map")); add(map_type<std::map<std::string, Boxed_Value> >("Map"));

View File

@ -630,7 +630,7 @@ namespace chaiscript
guard = boost::shared_ptr<Dynamic_Proxy_Function> guard = boost::shared_ptr<Dynamic_Proxy_Function>
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(ss), guardnode, boost::ref(ss), guardnode,
param_names, _1), numparams)); param_names, _1), static_cast<int>(numparams)));
} }
try { try {
@ -639,7 +639,7 @@ namespace chaiscript
ss.add(Proxy_Function ss.add(Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(ss), this->children.back(), boost::ref(ss), this->children.back(),
param_names, _1), numparams, param_names, _1), static_cast<int>(numparams),
annotation, guard)), function_name); annotation, guard)), function_name);
} }
catch (reserved_word_error &e) { catch (reserved_word_error &e) {
@ -966,8 +966,8 @@ namespace chaiscript
AST_Node(ast_node_text, id, fname, start_line, start_col, end_line, end_col) { } AST_Node(ast_node_text, id, fname, start_line, start_col, end_line, end_col) { }
virtual ~File_AST_Node() {} virtual ~File_AST_Node() {}
virtual Boxed_Value eval(Dispatch_Engine &ss) { virtual Boxed_Value eval(Dispatch_Engine &ss) {
const unsigned int size = this->children.size(); const size_t size = this->children.size();
for (unsigned int i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
try { try {
const Boxed_Value &retval = this->children[i]->eval(ss); const Boxed_Value &retval = this->children[i]->eval(ss);
if (i + 1 == size) { if (i + 1 == size) {
@ -1082,8 +1082,9 @@ namespace chaiscript
catch (const std::exception &e) { catch (const std::exception &e) {
Boxed_Value except = Boxed_Value(boost::ref(e)); Boxed_Value except = Boxed_Value(boost::ref(e));
unsigned int end_point = this->children.size(); size_t end_point = this->children.size();
if (this->children.back()->identifier == AST_Node_Type::Finally) { if (this->children.back()->identifier == AST_Node_Type::Finally) {
assert(end_point > 0);
end_point = this->children.size() - 1; end_point = this->children.size() - 1;
} }
for (unsigned int i = 1; i < end_point; ++i) { for (unsigned int i = 1; i < end_point; ++i) {
@ -1330,7 +1331,7 @@ namespace chaiscript
guard = boost::shared_ptr<Dynamic_Proxy_Function> guard = boost::shared_ptr<Dynamic_Proxy_Function>
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(ss), guardnode, boost::ref(ss), guardnode,
param_names, _1), numparams)); param_names, _1), static_cast<int>(numparams)));
} }
try { try {
@ -1342,7 +1343,7 @@ namespace chaiscript
(new Dynamic_Object_Constructor(class_name, Proxy_Function (new Dynamic_Object_Constructor(class_name, Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(ss), this->children.back(), boost::ref(ss), this->children.back(),
param_names, _1), numparams, param_names, _1), static_cast<int>(numparams),
annotation, guard)))), function_name); annotation, guard)))), function_name);
} }
@ -1357,7 +1358,7 @@ namespace chaiscript
(new Dynamic_Object_Function(class_name, Proxy_Function (new Dynamic_Object_Function(class_name, Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(ss), this->children.back(), boost::ref(ss), this->children.back(),
param_names, _1), numparams, param_names, _1), static_cast<int>(numparams),
annotation, guard)), ti)), function_name); annotation, guard)), ti)), function_name);
} }

View File

@ -7,7 +7,6 @@
#ifndef CHAISCRIPT_PARSER_HPP_ #ifndef CHAISCRIPT_PARSER_HPP_
#define CHAISCRIPT_PARSER_HPP_ #define CHAISCRIPT_PARSER_HPP_
#include <boost/assign/std/vector.hpp>
#include <exception> #include <exception>
#include <fstream> #include <fstream>
@ -43,61 +42,68 @@ namespace chaiscript
ChaiScript_Parser &operator=(const ChaiScript_Parser &); // explicitly unimplemented assignment operator ChaiScript_Parser &operator=(const ChaiScript_Parser &); // explicitly unimplemented assignment operator
void setup_operators() { void setup_operators() {
using namespace boost::assign;
operators.push_back(AST_Node_Type::Logical_Or); operators.push_back(AST_Node_Type::Logical_Or);
std::vector<std::string> logical_or; std::vector<std::string> logical_or;
logical_or += "||"; logical_or.push_back("||");
operator_matches.push_back(logical_or); operator_matches.push_back(logical_or);
operators.push_back(AST_Node_Type::Logical_And); operators.push_back(AST_Node_Type::Logical_And);
std::vector<std::string> logical_and; std::vector<std::string> logical_and;
logical_and += "&&"; logical_and.push_back("&&");
operator_matches.push_back(logical_and); operator_matches.push_back(logical_and);
operators.push_back(AST_Node_Type::Bitwise_Or); operators.push_back(AST_Node_Type::Bitwise_Or);
std::vector<std::string> bitwise_or; std::vector<std::string> bitwise_or;
bitwise_or += "|"; bitwise_or.push_back("|");
operator_matches.push_back(bitwise_or); operator_matches.push_back(bitwise_or);
operators.push_back(AST_Node_Type::Bitwise_Xor); operators.push_back(AST_Node_Type::Bitwise_Xor);
std::vector<std::string> bitwise_xor; std::vector<std::string> bitwise_xor;
bitwise_xor += "^"; bitwise_xor.push_back("^");
operator_matches.push_back(bitwise_xor); operator_matches.push_back(bitwise_xor);
operators.push_back(AST_Node_Type::Bitwise_And); operators.push_back(AST_Node_Type::Bitwise_And);
std::vector<std::string> bitwise_and; std::vector<std::string> bitwise_and;
bitwise_and += "&"; bitwise_and.push_back("&");
operator_matches.push_back(bitwise_and); operator_matches.push_back(bitwise_and);
operators.push_back(AST_Node_Type::Equality); operators.push_back(AST_Node_Type::Equality);
std::vector<std::string> equality; std::vector<std::string> equality;
equality += "==", "!="; equality.push_back("==");
equality.push_back("!=");
operator_matches.push_back(equality); operator_matches.push_back(equality);
operators.push_back(AST_Node_Type::Comparison); operators.push_back(AST_Node_Type::Comparison);
std::vector<std::string> comparison; std::vector<std::string> comparison;
comparison += "<", "<=", ">", ">="; comparison.push_back("<");
comparison.push_back("<=");
comparison.push_back(">");
comparison.push_back(">=");
operator_matches.push_back(comparison); operator_matches.push_back(comparison);
operators.push_back(AST_Node_Type::Shift); operators.push_back(AST_Node_Type::Shift);
std::vector<std::string> shift; std::vector<std::string> shift;
shift += "<<", ">>"; shift.push_back("<<");
shift.push_back(">>");
operator_matches.push_back(shift); operator_matches.push_back(shift);
operators.push_back(AST_Node_Type::Additive); operators.push_back(AST_Node_Type::Additive);
std::vector<std::string> additive; std::vector<std::string> additive;
additive += "+", "-"; additive.push_back("+");
additive.push_back("-");
operator_matches.push_back(additive); operator_matches.push_back(additive);
operators.push_back(AST_Node_Type::Multiplicative); operators.push_back(AST_Node_Type::Multiplicative);
std::vector<std::string> multiplicative; std::vector<std::string> multiplicative;
multiplicative += "*", "/", "%"; multiplicative.push_back("*");
multiplicative.push_back("/");
multiplicative.push_back("%");
operator_matches.push_back(multiplicative); operator_matches.push_back(multiplicative);
operators.push_back(AST_Node_Type::Dot_Access); operators.push_back(AST_Node_Type::Dot_Access);
std::vector<std::string> dot_access; std::vector<std::string> dot_access;
dot_access += "."; dot_access.push_back(".");
operator_matches.push_back(dot_access); operator_matches.push_back(dot_access);
} }
/** /**
@ -139,12 +145,12 @@ namespace chaiscript
/** /**
* Helper function that collects ast_nodes from a starting position to the top of the stack into a new AST node * Helper function that collects ast_nodes from a starting position to the top of the stack into a new AST node
*/ */
void build_match(AST_NodePtr t, int match_start) { void build_match(AST_NodePtr t, size_t match_start) {
int pos_line_start, pos_col_start, pos_line_stop, pos_col_stop; int pos_line_start, pos_col_start, pos_line_stop, pos_col_stop;
int is_deep = false; int is_deep = false;
//so we want to take everything to the right of this and make them children //so we want to take everything to the right of this and make them children
if (match_start != int(match_stack.size())) { if (match_start != match_stack.size()) {
pos_line_start = match_stack[match_start]->start.line; pos_line_start = match_stack[match_start]->start.line;
pos_col_start = match_stack[match_start]->start.column; pos_col_start = match_stack[match_start]->start.column;
pos_line_stop = line; pos_line_stop = line;
@ -165,8 +171,8 @@ namespace chaiscript
t->end.column = pos_col_stop; t->end.column = pos_col_stop;
if (is_deep) { if (is_deep) {
t->children.assign(match_stack.begin() + (match_start), match_stack.end()); t->children.assign(match_stack.begin() + match_start, match_stack.end());
match_stack.erase(match_stack.begin() + (match_start), match_stack.end()); match_stack.erase(match_stack.begin() + match_start, match_stack.end());
match_stack.push_back(t); match_stack.push_back(t);
} }
else { else {
@ -591,7 +597,7 @@ namespace chaiscript
bool is_escaped = false; bool is_escaped = false;
bool is_interpolated = false; bool is_interpolated = false;
bool saw_interpolation_marker = false; bool saw_interpolation_marker = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
//for (std::string::iterator s = start + 1, end = input_pos - 1; s != end; ++s) { //for (std::string::iterator s = start + 1, end = input_pos - 1; s != end; ++s) {
std::string::const_iterator s = start + 1, end = input_pos - 1; std::string::const_iterator s = start + 1, end = input_pos - 1;
@ -633,17 +639,17 @@ namespace chaiscript
is_interpolated = true; is_interpolated = true;
++s; ++s;
int tostr_stack_top = match_stack.size(); size_t tostr_stack_top = match_stack.size();
AST_NodePtr tostr(new Id_AST_Node("to_string", AST_Node_Type::Id, filename, prev_line, prev_col, line, col)); AST_NodePtr tostr(new Id_AST_Node("to_string", AST_Node_Type::Id, filename, prev_line, prev_col, line, col));
match_stack.push_back(tostr); match_stack.push_back(tostr);
int ev_stack_top = match_stack.size(); size_t ev_stack_top = match_stack.size();
AST_NodePtr ev(new Id_AST_Node("eval", AST_Node_Type::Id, filename, prev_line, prev_col, line, col)); AST_NodePtr ev(new Id_AST_Node("eval", AST_Node_Type::Id, filename, prev_line, prev_col, line, col));
match_stack.push_back(ev); match_stack.push_back(ev);
int arg_stack_top = match_stack.size(); size_t arg_stack_top = match_stack.size();
AST_NodePtr t(new Quoted_String_AST_Node(eval_match, AST_Node_Type::Quoted_String, filename, prev_line, prev_col, line, col)); AST_NodePtr t(new Quoted_String_AST_Node(eval_match, AST_Node_Type::Quoted_String, filename, prev_line, prev_col, line, col));
match_stack.push_back(t); match_stack.push_back(t);
@ -858,11 +864,11 @@ namespace chaiscript
*/ */
bool Keyword_(const char *s) { bool Keyword_(const char *s) {
bool retval = false; bool retval = false;
int len = strlen(s); int len = static_cast<int>(strlen(s));
if ((input_end - input_pos) >= len) { if ((input_end - input_pos) >= len) {
std::string::const_iterator tmp = input_pos; std::string::const_iterator tmp = input_pos;
for (int i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
if (*tmp != s[i]) { if (*tmp != s[i]) {
return false; return false;
} }
@ -931,7 +937,7 @@ namespace chaiscript
*/ */
bool Symbol_(const char *s) { bool Symbol_(const char *s) {
bool retval = false; bool retval = false;
int len = strlen(s); int len = static_cast<int>(strlen(s));
if ((input_end - input_pos) >= len) { if ((input_end - input_pos) >= len) {
std::string::const_iterator tmp = input_pos; std::string::const_iterator tmp = input_pos;
@ -1054,7 +1060,7 @@ namespace chaiscript
bool Arg_List() { bool Arg_List() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Equation()) { if (Equation()) {
retval = true; retval = true;
@ -1079,7 +1085,7 @@ namespace chaiscript
bool Container_Arg_List() { bool Container_Arg_List() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Value_Range()) { if (Value_Range()) {
retval = true; retval = true;
@ -1122,7 +1128,7 @@ namespace chaiscript
bool Lambda() { bool Lambda() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("fun")) { if (Keyword("fun")) {
retval = true; retval = true;
@ -1162,7 +1168,7 @@ namespace chaiscript
is_annotated = true; is_annotated = true;
} }
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("def")) { if (Keyword("def")) {
retval = true; retval = true;
@ -1221,7 +1227,7 @@ namespace chaiscript
bool Try() { bool Try() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("try")) { if (Keyword("try")) {
retval = true; retval = true;
@ -1237,7 +1243,7 @@ namespace chaiscript
while (Eol()) {} while (Eol()) {}
has_matches = false; has_matches = false;
if (Keyword("catch", false)) { if (Keyword("catch", false)) {
int catch_stack_top = match_stack.size(); size_t catch_stack_top = match_stack.size();
if (Char('(')) { if (Char('(')) {
if (!(Id(true) && Char(')'))) { if (!(Id(true) && Char(')'))) {
throw Eval_Error("Incomplete 'catch' expression", File_Position(line, col), filename); throw Eval_Error("Incomplete 'catch' expression", File_Position(line, col), filename);
@ -1260,7 +1266,7 @@ namespace chaiscript
} }
while (Eol()) {} while (Eol()) {}
if (Keyword("finally", false)) { if (Keyword("finally", false)) {
int finally_stack_top = match_stack.size(); size_t finally_stack_top = match_stack.size();
while (Eol()) {} while (Eol()) {}
@ -1282,7 +1288,7 @@ namespace chaiscript
bool If() { bool If() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("if")) { if (Keyword("if")) {
retval = true; retval = true;
@ -1346,7 +1352,7 @@ namespace chaiscript
bool While() { bool While() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("while")) { if (Keyword("while")) {
retval = true; retval = true;
@ -1391,7 +1397,7 @@ namespace chaiscript
bool For() { bool For() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("for")) { if (Keyword("for")) {
retval = true; retval = true;
@ -1422,7 +1428,7 @@ namespace chaiscript
bool Block() { bool Block() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Char('{')) { if (Char('{')) {
retval = true; retval = true;
@ -1444,7 +1450,7 @@ namespace chaiscript
bool Return() { bool Return() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("return")) { if (Keyword("return")) {
retval = true; retval = true;
@ -1462,7 +1468,7 @@ namespace chaiscript
bool Break() { bool Break() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("break")) { if (Keyword("break")) {
retval = true; retval = true;
@ -1480,7 +1486,7 @@ namespace chaiscript
bool retval = false; bool retval = false;
std::string::const_iterator prev_pos = input_pos; std::string::const_iterator prev_pos = input_pos;
unsigned int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Id(true)) { if (Id(true)) {
retval = true; retval = true;
bool has_more = true; bool has_more = true;
@ -1519,7 +1525,7 @@ namespace chaiscript
bool Var_Decl() { bool Var_Decl() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Keyword("var")) { if (Keyword("var")) {
retval = true; retval = true;
@ -1574,7 +1580,7 @@ namespace chaiscript
bool Inline_Container() { bool Inline_Container() {
bool retval = false; bool retval = false;
unsigned int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Char('[')) { if (Char('[')) {
retval = true; retval = true;
@ -1607,7 +1613,7 @@ namespace chaiscript
bool Prefix() { bool Prefix() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Symbol("++", true)) { if (Symbol("++", true)) {
retval = true; retval = true;
@ -1680,8 +1686,8 @@ namespace chaiscript
} }
} }
bool Operator_Helper(int precedence) { bool Operator_Helper(size_t precedence) {
for (unsigned int i = 0; i < operator_matches[precedence].size(); ++i) { for (size_t i = 0; i < operator_matches[precedence].size(); ++i) {
if (Symbol(operator_matches[precedence][i].c_str(), true)) { if (Symbol(operator_matches[precedence][i].c_str(), true)) {
return true; return true;
} }
@ -1689,10 +1695,10 @@ namespace chaiscript
return false; return false;
} }
bool Operator(unsigned int precedence = 0) { bool Operator(size_t precedence = 0) {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (precedence < operators.size()) { if (precedence < operators.size()) {
if (Operator(precedence+1)) { if (Operator(precedence+1)) {
@ -1789,7 +1795,7 @@ namespace chaiscript
bool Value_Range() { bool Value_Range() {
bool retval = false; bool retval = false;
unsigned int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
std::string::const_iterator prev_pos = input_pos; std::string::const_iterator prev_pos = input_pos;
int prev_col = col; int prev_col = col;
@ -1820,7 +1826,7 @@ namespace chaiscript
bool Equation() { bool Equation() {
bool retval = false; bool retval = false;
int prev_stack_top = match_stack.size(); size_t prev_stack_top = match_stack.size();
if (Operator()) { if (Operator()) {
retval = true; retval = true;