remove trailing spaces

This commit is contained in:
Bernd Amend 2021-05-22 15:51:01 +02:00
parent 32723fcbc0
commit 39f7aa0900
2 changed files with 31 additions and 32 deletions

View File

@ -56,7 +56,7 @@ namespace chaiscript
const Boxed_Value *thisobj = [&]() -> const Boxed_Value *{ const Boxed_Value *thisobj = [&]() -> const Boxed_Value *{
if (auto &stack = t_ss.get_stack_data(state.stack_holder()).back(); if (auto &stack = t_ss.get_stack_data(state.stack_holder()).back();
!stack.empty() && stack.back().first == "__this") !stack.empty() && stack.back().first == "__this")
{ {
return &stack.back().second; return &stack.back().second;
} else if (!t_vals.empty()) { } else if (!t_vals.empty()) {
@ -85,7 +85,7 @@ namespace chaiscript
return t_node.eval(state); return t_node.eval(state);
} catch (detail::Return_Value &rv) { } catch (detail::Return_Value &rv) {
return std::move(rv.retval); return std::move(rv.retval);
} }
} }
inline Boxed_Value clone_if_necessary(Boxed_Value incoming, std::atomic_uint_fast32_t &t_loc, const chaiscript::detail::Dispatch_State &t_ss) inline Boxed_Value clone_if_necessary(Boxed_Value incoming, std::atomic_uint_fast32_t &t_loc, const chaiscript::detail::Dispatch_State &t_ss)
@ -110,9 +110,9 @@ namespace chaiscript
} }
template<typename T> template<typename T>
struct AST_Node_Impl : AST_Node struct AST_Node_Impl : AST_Node
{ {
AST_Node_Impl(std::string t_ast_node_text, AST_Node_Type t_id, Parse_Location t_loc, AST_Node_Impl(std::string t_ast_node_text, AST_Node_Type t_id, Parse_Location t_loc,
std::vector<AST_Node_Impl_Ptr<T>> t_children = std::vector<AST_Node_Impl_Ptr<T>>()) std::vector<AST_Node_Impl_Ptr<T>> t_children = std::vector<AST_Node_Impl_Ptr<T>>())
: AST_Node(std::move(t_ast_node_text), t_id, std::move(t_loc)), : AST_Node(std::move(t_ast_node_text), t_id, std::move(t_loc)),
children(std::move(t_children)) children(std::move(t_children))
@ -187,7 +187,7 @@ namespace chaiscript
} }
protected: protected:
Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss, Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss,
const std::string &t_oper_string, const Boxed_Value &t_lhs) const const std::string &t_oper_string, const Boxed_Value &t_lhs) const
{ {
try { try {
@ -234,7 +234,7 @@ namespace chaiscript
} }
protected: protected:
Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss, Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss,
Operators::Opers t_oper, const std::string &t_oper_string, const Boxed_Value &t_lhs, const Boxed_Value &t_rhs) const Operators::Opers t_oper, const std::string &t_oper_string, const Boxed_Value &t_lhs, const Boxed_Value &t_rhs) const
{ {
try { try {
@ -309,7 +309,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct Fun_Call_AST_Node : AST_Node_Impl<T> { struct Fun_Call_AST_Node : AST_Node_Impl<T> {
Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) { AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) {
assert(!this->children.empty()); assert(!this->children.empty());
} }
@ -416,7 +416,7 @@ namespace chaiscript
return retval; return retval;
} }
static std::pair<std::string, Type_Info> get_arg_type(const AST_Node_Impl<T> &t_node, const chaiscript::detail::Dispatch_State &t_ss) static std::pair<std::string, Type_Info> get_arg_type(const AST_Node_Impl<T> &t_node, const chaiscript::detail::Dispatch_State &t_ss)
{ {
if (t_node.children.size() < 2) if (t_node.children.size() < 2)
{ {
@ -441,7 +441,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct Equation_AST_Node final : AST_Node_Impl<T> { struct Equation_AST_Node final : AST_Node_Impl<T> {
Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)), AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)),
m_oper(Operators::to_operator(this->text)) m_oper(Operators::to_operator(this->text))
{ assert(this->children.size() == 2); } { assert(this->children.size() == 2); }
@ -681,10 +681,10 @@ namespace chaiscript
template<typename T> template<typename T>
struct Lambda_AST_Node final : AST_Node_Impl<T> { struct Lambda_AST_Node final : AST_Node_Impl<T> {
Lambda_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Lambda_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(t_ast_node_text, AST_Node_Impl<T>(t_ast_node_text,
AST_Node_Type::Lambda, AST_Node_Type::Lambda,
std::move(t_loc), std::move(t_loc),
std::vector<AST_Node_Impl_Ptr<T>>(std::make_move_iterator(t_children.begin()), std::vector<AST_Node_Impl_Ptr<T>>(std::make_move_iterator(t_children.begin()),
std::make_move_iterator(std::prev(t_children.end()))) std::make_move_iterator(std::prev(t_children.end())))
), ),
m_param_names(Arg_List_AST_Node<T>::get_arg_names(*this->children[1])), m_param_names(Arg_List_AST_Node<T>::get_arg_names(*this->children[1])),
@ -709,7 +709,7 @@ namespace chaiscript
return Boxed_Value( return Boxed_Value(
dispatch::make_dynamic_proxy_function( dispatch::make_dynamic_proxy_function(
[engine, lambda_node = this->m_lambda_node, param_names = this->m_param_names, captures, [engine, lambda_node = this->m_lambda_node, param_names = this->m_param_names, captures,
this_capture = this->m_this_capture] (const Function_Params &t_params) this_capture = this->m_this_capture] (const Function_Params &t_params)
{ {
return detail::eval_function(engine, *lambda_node, param_names, t_params, &captures, this_capture); return detail::eval_function(engine, *lambda_node, param_names, t_params, &captures, this_capture);
@ -770,8 +770,8 @@ namespace chaiscript
std::shared_ptr<AST_Node_Impl<T>> m_guard_node; std::shared_ptr<AST_Node_Impl<T>> m_guard_node;
Def_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Def_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc), AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc),
std::vector<AST_Node_Impl_Ptr<T>>(std::make_move_iterator(t_children.begin()), std::vector<AST_Node_Impl_Ptr<T>>(std::make_move_iterator(t_children.begin()),
std::make_move_iterator(std::prev(t_children.end(), has_guard(t_children, 1)?2:1))) std::make_move_iterator(std::prev(t_children.end(), has_guard(t_children, 1)?2:1)))
), ),
// This apparent use after move is safe because we are only moving out the specific elements we need // This apparent use after move is safe because we are only moving out the specific elements we need
@ -864,11 +864,11 @@ namespace chaiscript
try { try {
this->children[1]->eval(t_ss); this->children[1]->eval(t_ss);
} catch (detail::Continue_Loop &) { } catch (detail::Continue_Loop &) {
// we got a continue exception, which means all of the remaining // we got a continue exception, which means all of the remaining
// loop implementation is skipped and we just need to continue to // loop implementation is skipped and we just need to continue to
// the next condition test // the next condition test
} }
} }
} catch (detail::Break_Loop &) { } catch (detail::Break_Loop &) {
// loop was broken intentionally // loop was broken intentionally
} }
@ -899,8 +899,8 @@ namespace chaiscript
template<typename T> template<typename T>
struct If_AST_Node final : AST_Node_Impl<T> { struct If_AST_Node final : AST_Node_Impl<T> {
If_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : If_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children)) AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children))
{ {
assert(this->children.size() == 3); assert(this->children.size() == 3);
} }
@ -1000,7 +1000,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct For_AST_Node final : AST_Node_Impl<T> { struct For_AST_Node final : AST_Node_Impl<T> {
For_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : For_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::For, std::move(t_loc), std::move(t_children)) AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::For, std::move(t_loc), std::move(t_children))
{ assert(this->children.size() == 4); } { assert(this->children.size() == 4); }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{ Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
@ -1016,7 +1016,7 @@ namespace chaiscript
// Body of Loop // Body of Loop
this->children[3]->eval(t_ss); this->children[3]->eval(t_ss);
} catch (detail::Continue_Loop &) { } catch (detail::Continue_Loop &) {
// we got a continue exception, which means all of the remaining // we got a continue exception, which means all of the remaining
// loop implementation is skipped and we just need to continue to // loop implementation is skipped and we just need to continue to
// the next iteration step // the next iteration step
} }
@ -1078,7 +1078,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct Case_AST_Node final : AST_Node_Impl<T> { struct Case_AST_Node final : AST_Node_Impl<T> {
Case_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Case_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Case, std::move(t_loc), std::move(t_children)) AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Case, std::move(t_loc), std::move(t_children))
{ assert(this->children.size() == 2); /* how many children does it have? */ } { assert(this->children.size() == 2); /* how many children does it have? */ }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
@ -1089,7 +1089,7 @@ namespace chaiscript
return void_var(); return void_var();
} }
}; };
template<typename T> template<typename T>
struct Default_AST_Node final : AST_Node_Impl<T> { struct Default_AST_Node final : AST_Node_Impl<T> {
Default_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Default_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
@ -1142,7 +1142,7 @@ namespace chaiscript
std::map<std::string, Boxed_Value> retval; std::map<std::string, Boxed_Value> retval;
for (const auto &child : this->children[0]->children) { for (const auto &child : this->children[0]->children) {
retval.insert(std::make_pair(t_ss->boxed_cast<std::string>(child->children[0]->eval(t_ss)), retval.insert(std::make_pair(t_ss->boxed_cast<std::string>(child->children[0]->eval(t_ss)),
detail::clone_if_necessary(child->children[1]->eval(t_ss), m_loc, t_ss))); detail::clone_if_necessary(child->children[1]->eval(t_ss), m_loc, t_ss)));
} }
@ -1440,7 +1440,7 @@ namespace chaiscript
std::vector<std::string> t_param_names{"this"}; std::vector<std::string> t_param_names{"this"};
dispatch::Param_Types param_types; dispatch::Param_Types param_types;
if ((this->children.size() > 2) if ((this->children.size() > 2)
&& (this->children[2]->identifier == AST_Node_Type::Arg_List)) { && (this->children[2]->identifier == AST_Node_Type::Arg_List)) {
auto args = Arg_List_AST_Node<T>::get_arg_names(*this->children[2]); auto args = Arg_List_AST_Node<T>::get_arg_names(*this->children[2]);
t_param_names.insert(t_param_names.end(), args.begin(), args.end()); t_param_names.insert(t_param_names.end(), args.begin(), args.end());
@ -1455,7 +1455,7 @@ namespace chaiscript
guard = dispatch::make_dynamic_proxy_function( guard = dispatch::make_dynamic_proxy_function(
[engine, t_param_names, guardnode = m_guard_node](const Function_Params &t_params) { [engine, t_param_names, guardnode = m_guard_node](const Function_Params &t_params) {
return chaiscript::eval::detail::eval_function(engine, *guardnode, t_param_names, t_params); return chaiscript::eval::detail::eval_function(engine, *guardnode, t_param_names, t_params);
}, },
static_cast<int>(numparams), m_guard_node); static_cast<int>(numparams), m_guard_node);
} }
@ -1488,7 +1488,7 @@ namespace chaiscript
[engine, t_param_names, node = m_body_node](const Function_Params &t_params) { [engine, t_param_names, node = m_body_node](const Function_Params &t_params) {
return chaiscript::eval::detail::eval_function(engine, *node, t_param_names, t_params); return chaiscript::eval::detail::eval_function(engine, *node, t_param_names, t_params);
}, },
static_cast<int>(numparams), m_body_node, param_types, guard), type), static_cast<int>(numparams), m_body_node, param_types, guard), type),
function_name); function_name);
} }
} catch (const exception::name_conflict_error &e) { } catch (const exception::name_conflict_error &e) {
@ -1504,7 +1504,7 @@ namespace chaiscript
Attr_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Attr_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Attr_Decl, std::move(t_loc), std::move(t_children)) { } AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Attr_Decl, std::move(t_loc), std::move(t_children)) { }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override
{ {
std::string class_name = this->children[0]->text; std::string class_name = this->children[0]->text;
@ -1532,7 +1532,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct Logical_And_AST_Node final : AST_Node_Impl<T> { struct Logical_And_AST_Node final : AST_Node_Impl<T> {
Logical_And_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Logical_And_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Logical_And, std::move(t_loc), std::move(t_children)) AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Logical_And, std::move(t_loc), std::move(t_children))
{ assert(this->children.size() == 2); } { assert(this->children.size() == 2); }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override
@ -1546,7 +1546,7 @@ namespace chaiscript
template<typename T> template<typename T>
struct Logical_Or_AST_Node final : AST_Node_Impl<T> { struct Logical_Or_AST_Node final : AST_Node_Impl<T> {
Logical_Or_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) : Logical_Or_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Logical_Or, std::move(t_loc), std::move(t_children)) AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Logical_Or, std::move(t_loc), std::move(t_children))
{ assert(this->children.size() == 2); } { assert(this->children.size() == 2); }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override

View File

@ -811,7 +811,6 @@ namespace chaiscript
} else if (!unsigned_ && !longlong_ && u >= std::numeric_limits<long>::min() && u <= std::numeric_limits<long>::max()) { } else if (!unsigned_ && !longlong_ && u >= std::numeric_limits<long>::min() && u <= std::numeric_limits<long>::max()) {
return const_var(static_cast<long>(u)); return const_var(static_cast<long>(u));
} else if ((unsigned_ || base != 10) && !longlong_ } else if ((unsigned_ || base != 10) && !longlong_
&& u >= std::numeric_limits<unsigned long>::min() && u >= std::numeric_limits<unsigned long>::min()
&& u <= std::numeric_limits<unsigned long>::max()) { && u <= std::numeric_limits<unsigned long>::max()) {
return const_var(static_cast<unsigned long>(u)); return const_var(static_cast<unsigned long>(u));