Remove := operator and fix & usage.

This commit is contained in:
Jason Turner
2011-09-24 15:06:31 -06:00
parent a28dfd8695
commit 52d9e1e871
6 changed files with 10 additions and 22 deletions

View File

@@ -406,7 +406,7 @@ namespace chaiscript
m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs"); m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs");
m->add(fun(&dispatch::Dynamic_Object::get_attr), "get_attr"); 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(&has_guard), "has_guard");
m->add(fun(&get_guard), "get_guard"); m->add(fun(&get_guard), "get_guard");

View File

@@ -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(","); m_engine.add_reserved_word(",");
m_engine.add_reserved_word(":=");
m_engine.add_reserved_word("auto"); m_engine.add_reserved_word("auto");
m_engine.add_reserved_word("return"); m_engine.add_reserved_word("return");
m_engine.add_reserved_word("break"); m_engine.add_reserved_word("break");

View File

@@ -302,10 +302,11 @@ 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(retval); lhs.assign(retval);
return retval;
} else { } else {
retval = t_ss.call_function("clone", retval); retval = t_ss.call_function("clone", retval);
retval.clear_dependencies();
} }
retval.clear_dependencies();
} }
try { try {
@@ -319,13 +320,6 @@ namespace chaiscript
throw exception::eval_error("Can not clone right hand side of equation"); 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 { else {
try { try {
retval = t_ss.call_function(this->children[1]->text, lhs, retval); retval = t_ss.call_function(this->children[1]->text, lhs, retval);

View File

@@ -1889,7 +1889,7 @@ namespace chaiscript
if (Operator()) { if (Operator()) {
retval = true; 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) || 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)) {

View File

@@ -1,5 +0,0 @@
auto i = 3
auto j := i
j = 4
assert_equal(4, i)

View File

@@ -1,14 +1,14 @@
load_module("reflection") load_module("reflection")
auto parser := ChaiScript_Parser() auto& parser = ChaiScript_Parser()
auto parse_success = parser.parse("3 + 4", "INPUT") auto parse_success = parser.parse("3 + 4", "INPUT")
auto a := parser.ast() auto& a = parser.ast()
assert_equal(eval(a), 7) assert_equal(eval(a), 7)
auto childs := a.children.front().children auto& childs = a.children.front().children
auto node := childs[0] auto& node = childs[0]
auto parser2 := ChaiScript_Parser() auto& parser2 = ChaiScript_Parser()
parser2.parse("9", "INPUT") 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(); } ); 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)); assert_equal(1, eval(parsetree));