Remove := operator and fix & usage.
This commit is contained in:
@@ -406,7 +406,7 @@ namespace chaiscript
|
||||
m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs");
|
||||
m->add(fun(&dispatch::Dynamic_Object::get_attr), "get_attr");
|
||||
|
||||
m->eval("def Dynamic_Object::clone() { auto new_o := Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
|
||||
m->eval("def Dynamic_Object::clone() { auto &new_o = Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
|
||||
|
||||
m->add(fun(&has_guard), "has_guard");
|
||||
m->add(fun(&get_guard), "get_guard");
|
||||
|
@@ -335,7 +335,6 @@ namespace chaiscript
|
||||
m_engine.add_reserved_word("&&");
|
||||
m_engine.add_reserved_word("||");
|
||||
m_engine.add_reserved_word(",");
|
||||
m_engine.add_reserved_word(":=");
|
||||
m_engine.add_reserved_word("auto");
|
||||
m_engine.add_reserved_word("return");
|
||||
m_engine.add_reserved_word("break");
|
||||
|
@@ -302,11 +302,12 @@ namespace chaiscript
|
||||
/// \todo This does not handle the case of an unassigned reference variable
|
||||
/// being assigned outside of its declaration
|
||||
lhs.assign(retval);
|
||||
return retval;
|
||||
} else {
|
||||
retval = t_ss.call_function("clone", retval);
|
||||
}
|
||||
retval.clear_dependencies();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
retval = t_ss.call_function(this->children[1]->text, lhs, retval);
|
||||
@@ -319,13 +320,6 @@ namespace chaiscript
|
||||
throw exception::eval_error("Can not clone right hand side of equation");
|
||||
}
|
||||
}
|
||||
else if (this->children[1]->text == ":=") {
|
||||
if (lhs.is_undef() || type_match(lhs, retval)) {
|
||||
lhs.assign(retval);
|
||||
} else {
|
||||
throw exception::eval_error("Mismatched types in equation");
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
retval = t_ss.call_function(this->children[1]->text, lhs, retval);
|
||||
|
@@ -1889,7 +1889,7 @@ namespace chaiscript
|
||||
|
||||
if (Operator()) {
|
||||
retval = true;
|
||||
if (Symbol("=", true, true) || Symbol(":=", true, true) || Symbol("+=", true, true) ||
|
||||
if (Symbol("=", true, true) || Symbol("+=", true, true) ||
|
||||
Symbol("-=", true, true) || Symbol("*=", true, true) || Symbol("/=", true, true) ||
|
||||
Symbol("%=", true, true) || Symbol("<<=", true, true) || Symbol(">>=", true, true) ||
|
||||
Symbol("&=", true, true) || Symbol("^=", true, true) || Symbol("|=", true, true)) {
|
||||
|
@@ -1,5 +0,0 @@
|
||||
auto i = 3
|
||||
auto j := i
|
||||
j = 4
|
||||
|
||||
assert_equal(4, i)
|
@@ -1,14 +1,14 @@
|
||||
load_module("reflection")
|
||||
auto parser := ChaiScript_Parser()
|
||||
auto& parser = ChaiScript_Parser()
|
||||
auto parse_success = parser.parse("3 + 4", "INPUT")
|
||||
auto a := parser.ast()
|
||||
auto& a = parser.ast()
|
||||
|
||||
assert_equal(eval(a), 7)
|
||||
|
||||
auto childs := a.children.front().children
|
||||
auto node := childs[0]
|
||||
auto& childs = a.children.front().children
|
||||
auto& node = childs[0]
|
||||
|
||||
auto parser2 := ChaiScript_Parser()
|
||||
auto& parser2 = ChaiScript_Parser()
|
||||
parser2.parse("9", "INPUT")
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ assert_equal(false, `+`.has_parse_tree());
|
||||
|
||||
assert_throws("Function does not have a parse tree", fun() { `+`.get_parse_tree(); } );
|
||||
|
||||
auto parsetree := my_fun.get_parse_tree();
|
||||
auto& parsetree = my_fun.get_parse_tree();
|
||||
|
||||
assert_equal(1, eval(parsetree));
|
||||
|
||||
|
Reference in New Issue
Block a user