- std::string command(command_ + line);
-
- driver.data_ = command.c_str();
- driver.size_ = command.size();
-
- driver.auto_ = true;
-
- if (parser.parse() != 0 || !driver.errors_.empty())
- return NULL;
-
- if (driver.mode_ == CYDriver::AutoNone)
- return NULL;
-
- CYExpression *expression;
-
- CYOptions options;
- CYContext context(driver.pool_, options);
-
- std::ostringstream prefix;
-
- switch (driver.mode_) {
- case CYDriver::AutoPrimary:
- expression = $ CYThis();
- break;
-
- case CYDriver::AutoDirect:
- expression = driver.context_;
- break;
-
- case CYDriver::AutoIndirect:
- expression = $ CYIndirect(driver.context_);
- break;
-
- case CYDriver::AutoMessage: {
- CYDriver::Context &thing(driver.contexts_.back());
- expression = $M($M($ CYIndirect(thing.context_), $S("isa")), $S("messages"));
- for (CYDriver::Context::Words::const_iterator part(thing.words_.begin()); part != thing.words_.end(); ++part)
- prefix << (*part)->word_ << ':';
- } break;
-
- default:
- _assert(false);
- }
-
- std::string begin(prefix.str() + word);
-
- driver.program_ = $ CYProgram($ CYExpress($C2(ParseExpression(pool,
- " function(object, prefix) {\n"
- " var names = [];\n"
- " var pattern = '^' + prefix;\n"
- " for (name in object)\n"
- " if (name.match(pattern) != null)\n"
- " names.push(name);\n"
- " return names;\n"
- " }\n"
- ), expression, $S(begin.c_str()))));
-
- driver.program_->Replace(context);
-
- std::ostringstream str;
- CYOutput out(str, options);
- out << *driver.program_;
-
- std::string code(str.str());
- CYUTF8String json(Run(pool, client_, code));
-
- CYExpression *result(ParseExpression(pool, json));
- CYArray *array(dynamic_cast<CYArray *>(result));