X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/51b6165e0dd24e4d40ff80e504922f705ddd7b62..8f41509fd52c574f447fe0e40555530de3fda431:/Console.cpp?ds=sidebyside diff --git a/Console.cpp b/Console.cpp index f7c6a0a..9d3d65a 100644 --- a/Console.cpp +++ b/Console.cpp @@ -227,11 +227,14 @@ static CYExpression *ParseExpression(CYUTF8String code) { CYOptions options; CYContext context(options); - // XXX: this could be replaced with a CYStatement::Primitive() - if (CYExpress *express = dynamic_cast(driver.program_->statements_)) - return express->expression_->Primitive(context); + CYStatement *statement(driver.program_->statements_); + _assert(statement != NULL); + _assert(statement->next_ == NULL); - return NULL; + CYExpress *express(dynamic_cast(driver.program_->statements_)); + _assert(express != NULL); + + return express->expression_; } static int client_; @@ -295,7 +298,7 @@ static char **Complete(const char *word, int start, int end) { " var before = prefix.length;\n" " prefix += word;\n" " var entire = prefix.length;\n" - " for (name in object)\n" + " for (var name in object)\n" " if (name.substring(0, entire) == prefix)\n" " names.push(name.substr(before));\n" " return names;\n" @@ -316,8 +319,7 @@ static char **Complete(const char *word, int start, int end) { if (result == NULL) return NULL; - CYArray *array(dynamic_cast(result)); - + CYArray *array(dynamic_cast(result->Primitive(context))); if (array == NULL) { *out_ << '\n'; Output(false, json, out_); @@ -500,7 +502,11 @@ static void Console(CYOptions &options) { } else if (data == "destroy") { CYDestroyContext(); } else if (data == "gc") { + *out_ << "collecting... " << std::flush; CYGarbageCollect(CYGetJSContext()); + *out_ << "done." << std::endl; + } else if (data == "exit") { + return; } else if (data == "expand") { expand = !expand; *out_ << "expand == " << (expand ? "true" : "false") << std::endl;