Fix clang build errors
This commit is contained in:
@@ -809,7 +809,7 @@ namespace chaiscript
|
|||||||
std::transform(tis.begin() + 1, tis.end(),
|
std::transform(tis.begin() + 1, tis.end(),
|
||||||
plist.begin(),
|
plist.begin(),
|
||||||
std::back_inserter(newplist),
|
std::back_inserter(newplist),
|
||||||
[](const Type_Info &ti, const Boxed_Value ¶m) {
|
[](const Type_Info &ti, const Boxed_Value ¶m) -> Boxed_Value {
|
||||||
if (ti.is_arithmetic() && param.get_type_info().is_arithmetic()) {
|
if (ti.is_arithmetic() && param.get_type_info().is_arithmetic()) {
|
||||||
return Boxed_Number(param).get_as(ti).bv;
|
return Boxed_Number(param).get_as(ti).bv;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -282,29 +282,6 @@ namespace chaiscript
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Fun_Lookup_AST_Node : public AST_Node {
|
|
||||||
public:
|
|
||||||
Fun_Lookup_AST_Node(const std::string &t_fun_name)
|
|
||||||
: AST_Node(t_fun_name, 0, Parse_Location("<EVAL>"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~Fun_Lookup_AST_Node() {}
|
|
||||||
|
|
||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE {
|
|
||||||
try {
|
|
||||||
Boxed_Value bv = t_ss.get_object(text);
|
|
||||||
t_ss.add_object(text, bv);
|
|
||||||
std::cout << " Saved fun lookup: " << text << '\n';
|
|
||||||
return bv;
|
|
||||||
} catch (...) {
|
|
||||||
return Boxed_Value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Used in the context of in-string ${} evals, so that no new scope is created
|
/// Used in the context of in-string ${} evals, so that no new scope is created
|
||||||
|
@@ -216,28 +216,6 @@ namespace chaiscript
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void optimize_fun_lookups(AST_NodePtr &p)
|
|
||||||
{
|
|
||||||
for (auto &c : p->children)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (c->identifier == AST_Node_Type::Def
|
|
||||||
|| c->identifier == AST_Node_Type::Method
|
|
||||||
|| c->identifier == AST_Node_Type::Lambda) {
|
|
||||||
std::vector<AST_NodePtr> children_to_add;
|
|
||||||
auto counts = count_fun_calls(c, false);
|
|
||||||
for (const auto &count : counts) {
|
|
||||||
// std::cout << " Fun Call Count: " << count.first << " " << count.second << '\n';
|
|
||||||
if (count.second > 1) {
|
|
||||||
children_to_add.push_back(chaiscript::make_shared<AST_Node, eval::Fun_Lookup_AST_Node>(count.first));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c->children.back()->children.insert(c->children.back()->children.begin(), children_to_add.begin(), children_to_add.end());
|
|
||||||
}
|
|
||||||
optimize_fun_lookups(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void optimize_blocks(AST_NodePtr &p)
|
static void optimize_blocks(AST_NodePtr &p)
|
||||||
{
|
{
|
||||||
@@ -282,12 +260,11 @@ namespace chaiscript
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_NodePtr optimized_ast(bool t_optimize_blocks = false, bool t_optimize_returns = true, bool t_optimize_fun_lookups = false) {
|
AST_NodePtr optimized_ast(bool t_optimize_blocks = false, bool t_optimize_returns = true) {
|
||||||
AST_NodePtr p = m_match_stack.front();
|
AST_NodePtr p = m_match_stack.front();
|
||||||
//Note, optimize_blocks is currently broken; it breaks stack management
|
//Note, optimize_blocks is currently broken; it breaks stack management
|
||||||
if (t_optimize_blocks) { optimize_blocks(p); }
|
if (t_optimize_blocks) { optimize_blocks(p); }
|
||||||
if (t_optimize_returns) { optimize_returns(p); }
|
if (t_optimize_returns) { optimize_returns(p); }
|
||||||
if (t_optimize_fun_lookups) { optimize_fun_lookups(p); }
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user