diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b01aff..3b6ccd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ endif() if (CMAKE_COMPILER_2005) # vs2005 is a bit too loud about possible loss of data warnings - ADD_DEFINITIONS(/wd4244) +# ADD_DEFINITIONS(/wd4244) endif() include_directories(${Boost_INCLUDE_DIRS}) diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 01a4938..c1182ae 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -16,7 +16,6 @@ #include "dispatchkit.hpp" #include "register_function.hpp" - namespace chaiscript { namespace bootstrap @@ -522,4 +521,5 @@ namespace detail { } } + #endif diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 0702bd9..1c132c2 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -586,7 +586,6 @@ namespace chaiscript engine.add(fun(static_cast(&ChaiScript_System::load_module), this), "load_module"); engine.add(fun(static_cast(&ChaiScript_System::load_module), this), "load_module"); - add(vector_type >("Vector")); add(string_type("string")); add(map_type >("Map")); diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 2496cd1..e0f1836 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -630,7 +630,7 @@ namespace chaiscript guard = boost::shared_ptr (new Dynamic_Proxy_Function(boost::bind(&eval_function, boost::ref(ss), guardnode, - param_names, _1), numparams)); + param_names, _1), static_cast(numparams))); } try { @@ -639,7 +639,7 @@ namespace chaiscript ss.add(Proxy_Function (new Dynamic_Proxy_Function(boost::bind(&eval_function, boost::ref(ss), this->children.back(), - param_names, _1), numparams, + param_names, _1), static_cast(numparams), annotation, guard)), function_name); } 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) { } virtual ~File_AST_Node() {} virtual Boxed_Value eval(Dispatch_Engine &ss) { - const unsigned int size = this->children.size(); - for (unsigned int i = 0; i < size; ++i) { + const size_t size = this->children.size(); + for (size_t i = 0; i < size; ++i) { try { const Boxed_Value &retval = this->children[i]->eval(ss); if (i + 1 == size) { @@ -1082,8 +1082,9 @@ namespace chaiscript catch (const std::exception &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) { + assert(end_point > 0); end_point = this->children.size() - 1; } for (unsigned int i = 1; i < end_point; ++i) { @@ -1330,7 +1331,7 @@ namespace chaiscript guard = boost::shared_ptr (new Dynamic_Proxy_Function(boost::bind(&eval_function, boost::ref(ss), guardnode, - param_names, _1), numparams)); + param_names, _1), static_cast(numparams))); } try { @@ -1342,7 +1343,7 @@ namespace chaiscript (new Dynamic_Object_Constructor(class_name, Proxy_Function (new Dynamic_Proxy_Function(boost::bind(&eval_function, boost::ref(ss), this->children.back(), - param_names, _1), numparams, + param_names, _1), static_cast(numparams), annotation, guard)))), function_name); } @@ -1357,7 +1358,7 @@ namespace chaiscript (new Dynamic_Object_Function(class_name, Proxy_Function (new Dynamic_Proxy_Function(boost::bind(&eval_function, boost::ref(ss), this->children.back(), - param_names, _1), numparams, + param_names, _1), static_cast(numparams), annotation, guard)), ti)), function_name); } diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 1ee80eb..1c16e2d 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -7,7 +7,6 @@ #ifndef CHAISCRIPT_PARSER_HPP_ #define CHAISCRIPT_PARSER_HPP_ -#include #include #include @@ -43,61 +42,68 @@ namespace chaiscript ChaiScript_Parser &operator=(const ChaiScript_Parser &); // explicitly unimplemented assignment operator void setup_operators() { - using namespace boost::assign; operators.push_back(AST_Node_Type::Logical_Or); std::vector logical_or; - logical_or += "||"; + logical_or.push_back("||"); operator_matches.push_back(logical_or); operators.push_back(AST_Node_Type::Logical_And); std::vector logical_and; - logical_and += "&&"; + logical_and.push_back("&&"); operator_matches.push_back(logical_and); operators.push_back(AST_Node_Type::Bitwise_Or); std::vector bitwise_or; - bitwise_or += "|"; + bitwise_or.push_back("|"); operator_matches.push_back(bitwise_or); operators.push_back(AST_Node_Type::Bitwise_Xor); std::vector bitwise_xor; - bitwise_xor += "^"; + bitwise_xor.push_back("^"); operator_matches.push_back(bitwise_xor); operators.push_back(AST_Node_Type::Bitwise_And); std::vector bitwise_and; - bitwise_and += "&"; + bitwise_and.push_back("&"); operator_matches.push_back(bitwise_and); operators.push_back(AST_Node_Type::Equality); std::vector equality; - equality += "==", "!="; + equality.push_back("=="); + equality.push_back("!="); operator_matches.push_back(equality); operators.push_back(AST_Node_Type::Comparison); std::vector comparison; - comparison += "<", "<=", ">", ">="; + comparison.push_back("<"); + comparison.push_back("<="); + comparison.push_back(">"); + comparison.push_back(">="); operator_matches.push_back(comparison); operators.push_back(AST_Node_Type::Shift); std::vector shift; - shift += "<<", ">>"; + shift.push_back("<<"); + shift.push_back(">>"); operator_matches.push_back(shift); operators.push_back(AST_Node_Type::Additive); std::vector additive; - additive += "+", "-"; + additive.push_back("+"); + additive.push_back("-"); operator_matches.push_back(additive); operators.push_back(AST_Node_Type::Multiplicative); std::vector multiplicative; - multiplicative += "*", "/", "%"; + multiplicative.push_back("*"); + multiplicative.push_back("/"); + multiplicative.push_back("%"); operator_matches.push_back(multiplicative); operators.push_back(AST_Node_Type::Dot_Access); std::vector dot_access; - dot_access += "."; + dot_access.push_back("."); 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 */ - 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 is_deep = false; //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_col_start = match_stack[match_start]->start.column; pos_line_stop = line; @@ -165,8 +171,8 @@ namespace chaiscript t->end.column = pos_col_stop; if (is_deep) { - t->children.assign(match_stack.begin() + (match_start), match_stack.end()); - match_stack.erase(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.push_back(t); } else { @@ -591,7 +597,7 @@ namespace chaiscript bool is_escaped = false; bool is_interpolated = 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) { std::string::const_iterator s = start + 1, end = input_pos - 1; @@ -633,17 +639,17 @@ namespace chaiscript is_interpolated = true; ++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)); 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)); 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)); match_stack.push_back(t); @@ -858,11 +864,11 @@ namespace chaiscript */ bool Keyword_(const char *s) { bool retval = false; - int len = strlen(s); + int len = static_cast(strlen(s)); if ((input_end - input_pos) >= len) { 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]) { return false; } @@ -931,7 +937,7 @@ namespace chaiscript */ bool Symbol_(const char *s) { bool retval = false; - int len = strlen(s); + int len = static_cast(strlen(s)); if ((input_end - input_pos) >= len) { std::string::const_iterator tmp = input_pos; @@ -1054,7 +1060,7 @@ namespace chaiscript bool Arg_List() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Equation()) { retval = true; @@ -1079,7 +1085,7 @@ namespace chaiscript bool Container_Arg_List() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Value_Range()) { retval = true; @@ -1122,7 +1128,7 @@ namespace chaiscript bool Lambda() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("fun")) { retval = true; @@ -1162,7 +1168,7 @@ namespace chaiscript is_annotated = true; } - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("def")) { retval = true; @@ -1221,7 +1227,7 @@ namespace chaiscript bool Try() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("try")) { retval = true; @@ -1237,7 +1243,7 @@ namespace chaiscript while (Eol()) {} has_matches = false; if (Keyword("catch", false)) { - int catch_stack_top = match_stack.size(); + size_t catch_stack_top = match_stack.size(); if (Char('(')) { if (!(Id(true) && Char(')'))) { throw Eval_Error("Incomplete 'catch' expression", File_Position(line, col), filename); @@ -1260,7 +1266,7 @@ namespace chaiscript } while (Eol()) {} if (Keyword("finally", false)) { - int finally_stack_top = match_stack.size(); + size_t finally_stack_top = match_stack.size(); while (Eol()) {} @@ -1282,7 +1288,7 @@ namespace chaiscript bool If() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("if")) { retval = true; @@ -1346,7 +1352,7 @@ namespace chaiscript bool While() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("while")) { retval = true; @@ -1391,7 +1397,7 @@ namespace chaiscript bool For() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("for")) { retval = true; @@ -1422,7 +1428,7 @@ namespace chaiscript bool Block() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Char('{')) { retval = true; @@ -1444,7 +1450,7 @@ namespace chaiscript bool Return() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("return")) { retval = true; @@ -1462,7 +1468,7 @@ namespace chaiscript bool Break() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("break")) { retval = true; @@ -1480,7 +1486,7 @@ namespace chaiscript bool retval = false; 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)) { retval = true; bool has_more = true; @@ -1519,7 +1525,7 @@ namespace chaiscript bool Var_Decl() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Keyword("var")) { retval = true; @@ -1574,7 +1580,7 @@ namespace chaiscript bool Inline_Container() { bool retval = false; - unsigned int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Char('[')) { retval = true; @@ -1607,7 +1613,7 @@ namespace chaiscript bool Prefix() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Symbol("++", true)) { retval = true; @@ -1680,8 +1686,8 @@ namespace chaiscript } } - bool Operator_Helper(int precedence) { - for (unsigned int i = 0; i < operator_matches[precedence].size(); ++i) { + bool Operator_Helper(size_t precedence) { + for (size_t i = 0; i < operator_matches[precedence].size(); ++i) { if (Symbol(operator_matches[precedence][i].c_str(), true)) { return true; } @@ -1689,10 +1695,10 @@ namespace chaiscript return false; } - bool Operator(unsigned int precedence = 0) { + bool Operator(size_t precedence = 0) { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (precedence < operators.size()) { if (Operator(precedence+1)) { @@ -1789,7 +1795,7 @@ namespace chaiscript bool Value_Range() { 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; int prev_col = col; @@ -1820,7 +1826,7 @@ namespace chaiscript bool Equation() { bool retval = false; - int prev_stack_top = match_stack.size(); + size_t prev_stack_top = match_stack.size(); if (Operator()) { retval = true;