Various cleanups
This commit is contained in:
@@ -499,7 +499,7 @@ namespace chaiscript
|
||||
struct Return_Value {
|
||||
Boxed_Value retval;
|
||||
|
||||
Return_Value(const Boxed_Value &t_return_value) : retval(t_return_value) { }
|
||||
Return_Value(Boxed_Value t_return_value) : retval(std::move(t_return_value)) { }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace chaiscript
|
||||
try {
|
||||
return t_node->eval(t_ss);
|
||||
} catch (detail::Return_Value &rv) {
|
||||
return rv.retval;
|
||||
return std::move(rv.retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -707,13 +707,14 @@ namespace chaiscript
|
||||
|
||||
fpp.save_params(params);
|
||||
|
||||
std::string fun_name;
|
||||
if ((this->children[i]->identifier == AST_Node_Type::Fun_Call) || (this->children[i]->identifier == AST_Node_Type::Array_Call)) {
|
||||
fun_name = this->children[i]->children[0]->text;
|
||||
}
|
||||
else {
|
||||
fun_name = this->children[i]->text;
|
||||
}
|
||||
std::string fun_name = [&](){
|
||||
if ((this->children[i]->identifier == AST_Node_Type::Fun_Call) || (this->children[i]->identifier == AST_Node_Type::Array_Call)) {
|
||||
return this->children[i]->children[0]->text;
|
||||
}
|
||||
else {
|
||||
return this->children[i]->text;
|
||||
}
|
||||
}();
|
||||
|
||||
try {
|
||||
chaiscript::eval::detail::Stack_Push_Pop spp(t_ss);
|
||||
@@ -728,7 +729,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
catch(detail::Return_Value &rv) {
|
||||
retval = rv.retval;
|
||||
retval = std::move(rv.retval);
|
||||
}
|
||||
|
||||
if (this->children[i]->identifier == AST_Node_Type::Array_Call) {
|
||||
@@ -1171,14 +1172,11 @@ namespace chaiscript
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::File, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { }
|
||||
virtual ~File_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
const size_t size = this->children.size();
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
Boxed_Value retval(this->children[i]->eval(t_ss));
|
||||
if (i + 1 == size) {
|
||||
return retval;
|
||||
}
|
||||
const auto num_children = children.size();
|
||||
for (size_t i = 0; i < num_children-1; ++i) {
|
||||
children[i]->eval(t_ss);
|
||||
}
|
||||
return Boxed_Value();
|
||||
return children.back()->eval(t_ss);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1118,8 +1118,8 @@ namespace chaiscript
|
||||
const auto prev_col = m_col;
|
||||
const auto prev_line = m_line;
|
||||
if (Char_(t_c)) {
|
||||
std::string match(start, m_input_pos);
|
||||
m_match_stack.push_back(std::make_shared<eval::Char_AST_Node>(std::move(match), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
m_match_stack.push_back(
|
||||
std::make_shared<eval::Char_AST_Node>(std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -1163,8 +1163,8 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
if ( t_capture && retval ) {
|
||||
std::string match(start, m_input_pos);
|
||||
m_match_stack.push_back(std::make_shared<eval::Str_AST_Node>(std::move(match), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
m_match_stack.push_back(std::make_shared<eval::Str_AST_Node>(
|
||||
std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -1206,8 +1206,8 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
if ( t_capture && retval ) {
|
||||
std::string match(start, m_input_pos);
|
||||
m_match_stack.push_back(std::make_shared<eval::Str_AST_Node>(std::move(match), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
m_match_stack.push_back(std::make_shared<eval::Str_AST_Node>(
|
||||
std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -1239,8 +1239,8 @@ namespace chaiscript
|
||||
const auto prev_col = m_col;
|
||||
const auto prev_line = m_line;
|
||||
if (Eol_()) {
|
||||
std::string match(start, m_input_pos);
|
||||
m_match_stack.push_back(std::make_shared<eval::Eol_AST_Node>(std::move(match), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
m_match_stack.push_back(std::make_shared<eval::Eol_AST_Node>(
|
||||
std::string(start, m_input_pos), m_filename, prev_line, prev_col, m_line, m_col));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user