Get return_value_handling fully working
This commit is contained in:
@@ -232,9 +232,9 @@ namespace chaiscript
|
|||||||
if (t_oper > Operators::boolean_flag && t_oper < Operators::non_const_flag)
|
if (t_oper > Operators::boolean_flag && t_oper < Operators::non_const_flag)
|
||||||
{
|
{
|
||||||
return boolean::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return boolean::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
} else if (t_oper > Operators::non_const_flag && t_oper < Operators::non_const_int_flag && !t_lhs.is_const()) {
|
} else if (t_oper > Operators::non_const_flag && t_oper < Operators::non_const_int_flag && !t_lhs.is_const() && !t_lhs.is_return_value()) {
|
||||||
return binary::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return binary::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
} else if (t_oper > Operators::non_const_int_flag && t_oper < Operators::const_int_flag && !t_lhs.is_const()) {
|
} else if (t_oper > Operators::non_const_int_flag && t_oper < Operators::const_int_flag && !t_lhs.is_const() && !t_lhs.is_return_value()) {
|
||||||
return binary_int::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return binary_int::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
} else if (t_oper > Operators::const_int_flag && t_oper < Operators::const_flag) {
|
} else if (t_oper > Operators::const_int_flag && t_oper < Operators::const_flag) {
|
||||||
return const_binary_int::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return const_binary_int::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
@@ -254,7 +254,7 @@ namespace chaiscript
|
|||||||
if (t_oper > Operators::boolean_flag && t_oper < Operators::non_const_flag)
|
if (t_oper > Operators::boolean_flag && t_oper < Operators::non_const_flag)
|
||||||
{
|
{
|
||||||
return boolean::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return boolean::go<LHS, RHS>(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
} else if (t_oper > Operators::non_const_flag && t_oper < Operators::non_const_int_flag && !t_lhs.is_const()) {
|
} else if (t_oper > Operators::non_const_flag && t_oper < Operators::non_const_int_flag && !t_lhs.is_const() && !t_lhs.is_return_value()) {
|
||||||
return binary::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
return binary::go<LHS, RHS>(t_oper, *static_cast<LHS *>(t_lhs.get_ptr()), *static_cast<const RHS *>(t_rhs.get_const_ptr()), t_lhs);
|
||||||
} else if (t_oper > Operators::non_const_int_flag && t_oper < Operators::const_int_flag) {
|
} else if (t_oper > Operators::non_const_int_flag && t_oper < Operators::const_int_flag) {
|
||||||
throw chaiscript::detail::exception::bad_any_cast();
|
throw chaiscript::detail::exception::bad_any_cast();
|
||||||
|
@@ -795,7 +795,12 @@ namespace chaiscript
|
|||||||
|
|
||||||
Boxed_Value call_function(const std::string &t_name, const std::vector<Boxed_Value> ¶ms) const
|
Boxed_Value call_function(const std::string &t_name, const std::vector<Boxed_Value> ¶ms) const
|
||||||
{
|
{
|
||||||
return dispatch::dispatch(get_function(t_name), params, m_conversions);
|
Boxed_Value bv = dispatch::dispatch(get_function(t_name), params, m_conversions);
|
||||||
|
// the result of a clone is never to be marked as a return_value
|
||||||
|
if (t_name == "clone") {
|
||||||
|
bv.reset_return_value();
|
||||||
|
}
|
||||||
|
return bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxed_Value call_function(const std::string &t_name) const
|
Boxed_Value call_function(const std::string &t_name) const
|
||||||
|
@@ -558,6 +558,10 @@ namespace chaiscript
|
|||||||
throw exception::eval_error("Error with unsupported arithmetic assignment operation");
|
throw exception::eval_error("Error with unsupported arithmetic assignment operation");
|
||||||
}
|
}
|
||||||
} else if (m_oper == Operators::assign) {
|
} else if (m_oper == Operators::assign) {
|
||||||
|
if (lhs.is_return_value()) {
|
||||||
|
throw exception::eval_error("Error, cannot assign to temporary value.");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (lhs.is_undef()) {
|
if (lhs.is_undef()) {
|
||||||
if (!this->children.empty() &&
|
if (!this->children.empty() &&
|
||||||
@@ -567,14 +571,14 @@ namespace chaiscript
|
|||||||
/// \todo This does not handle the case of an unassigned reference variable
|
/// \todo This does not handle the case of an unassigned reference variable
|
||||||
/// being assigned outside of its declaration
|
/// being assigned outside of its declaration
|
||||||
lhs.assign(rhs);
|
lhs.assign(rhs);
|
||||||
|
lhs.reset_return_value();
|
||||||
return rhs;
|
return rhs;
|
||||||
} else {
|
} else {
|
||||||
if (!rhs.is_return_value())
|
if (!rhs.is_return_value())
|
||||||
{
|
{
|
||||||
rhs = t_ss.call_function("clone", rhs);
|
rhs = t_ss.call_function("clone", rhs);
|
||||||
} else {
|
|
||||||
rhs.reset_return_value();
|
|
||||||
}
|
}
|
||||||
|
rhs.reset_return_value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user