Minor speed improvements
This commit is contained in:
@@ -738,25 +738,14 @@ namespace chaiscript
|
|||||||
virtual ~Block_AST_Node() {}
|
virtual ~Block_AST_Node() {}
|
||||||
|
|
||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||||
const auto num_children = this->children.size();
|
|
||||||
|
|
||||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
const auto num_children = children.size();
|
||||||
try {
|
for (size_t i = 0; i < num_children-1; ++i) {
|
||||||
if (i + 1 < num_children)
|
children[i]->eval(t_ss);
|
||||||
{
|
|
||||||
this->children[i]->eval(t_ss);
|
|
||||||
} else {
|
|
||||||
return this->children[i]->eval(t_ss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const chaiscript::eval::detail::Return_Value &) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return children.back()->eval(t_ss);
|
||||||
|
|
||||||
return Boxed_Value();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -889,8 +878,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
if (get_bool_condition(this->children[0]->eval(t_ss))) {
|
if (get_bool_condition(this->children[0]->eval(t_ss))) {
|
||||||
return this->children[1]->eval(t_ss);
|
return this->children[1]->eval(t_ss);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (this->children.size() > 2) {
|
if (this->children.size() > 2) {
|
||||||
size_t i = 2;
|
size_t i = 2;
|
||||||
bool cond = false;
|
bool cond = false;
|
||||||
@@ -923,26 +911,22 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
// initial expression
|
|
||||||
this->children[0]->eval(t_ss);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// while condition evals to true
|
for (
|
||||||
while (get_bool_condition(this->children[1]->eval(t_ss))) {
|
children[0]->eval(t_ss);
|
||||||
|
get_bool_condition(children[1]->eval(t_ss));
|
||||||
|
children[2]->eval(t_ss)
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
// Body of Loop
|
// Body of Loop
|
||||||
this->children[3]->eval(t_ss);
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop expression
|
|
||||||
this->children[2]->eval(t_ss);
|
|
||||||
}
|
}
|
||||||
}
|
} catch (detail::Break_Loop &) {
|
||||||
catch (detail::Break_Loop &) {
|
|
||||||
// loop broken
|
// loop broken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1687,6 +1687,10 @@ namespace chaiscript
|
|||||||
throw exception::eval_error("Incomplete class block", File_Position(m_line, m_col), *m_filename);
|
throw exception::eval_error("Incomplete class block", File_Position(m_line, m_col), *m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_match_stack.size() == prev_stack_top) {
|
||||||
|
m_match_stack.push_back(std::make_shared<eval::Noop_AST_Node>());
|
||||||
|
}
|
||||||
|
|
||||||
build_match(std::make_shared<eval::Block_AST_Node>(), prev_stack_top);
|
build_match(std::make_shared<eval::Block_AST_Node>(), prev_stack_top);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1707,6 +1711,10 @@ namespace chaiscript
|
|||||||
throw exception::eval_error("Incomplete block", File_Position(m_line, m_col), *m_filename);
|
throw exception::eval_error("Incomplete block", File_Position(m_line, m_col), *m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_match_stack.size() == prev_stack_top) {
|
||||||
|
m_match_stack.push_back(std::make_shared<eval::Noop_AST_Node>());
|
||||||
|
}
|
||||||
|
|
||||||
build_match(std::make_shared<eval::Block_AST_Node>(), prev_stack_top);
|
build_match(std::make_shared<eval::Block_AST_Node>(), prev_stack_top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user