X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/e46761272105b911e12186212afa6e9373ff9641..e06e5ee1f12b9b79b34570e65c1f5e9c12b9b8c3:/Console.cpp diff --git a/Console.cpp b/Console.cpp index c680947..d669e67 100644 --- a/Console.cpp +++ b/Console.cpp @@ -1,5 +1,5 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2010 Jay Freeman (saurik) + * Copyright (C) 2009-2012 Jay Freeman (saurik) */ /* GNU Lesser General Public License, Version 3 {{{ */ @@ -211,11 +211,16 @@ static CYExpression *ParseExpression(CYUTF8String code) { Setup(driver, parser); if (parser.parse() != 0 || !driver.errors_.empty()) - _assert(false); + return NULL; + + CYOptions options; + CYContext context(options); - CYExpress *express(dynamic_cast(driver.program_->statements_)); - _assert(express != NULL); - return express->expression_; + // XXX: this could be replaced with a CYStatement::Primitive() + if (CYExpress *express = dynamic_cast(driver.program_->statements_)) + return express->expression_->Primitive(context); + + return NULL; } static int client_; @@ -264,7 +269,7 @@ static char **Complete(const char *word, int start, int end) { case CYDriver::AutoMessage: { CYDriver::Context &thing(driver.contexts_.back()); - expression = $M($M($ CYIndirect(thing.context_), $S("isa")), $S("messages")); + expression = $M($C1($V("object_getClass"), thing.context_), $S("messages")); for (CYDriver::Context::Words::const_iterator part(thing.words_.begin()); part != thing.words_.end(); ++part) prefix << (*part)->word_ << ':'; } break; @@ -297,6 +302,9 @@ static char **Complete(const char *word, int start, int end) { CYUTF8String json(Run(pool, client_, code)); CYExpression *result(ParseExpression(json)); + if (result == NULL) + return NULL; + CYArray *array(dynamic_cast(result)); if (array == NULL) { @@ -491,7 +499,7 @@ static void Console(CYOptions &options) { } std::cerr << "...."; - for (size_t i(0); i != begin.column - 1; ++i) + for (size_t i(0); i != begin.column; ++i) std::cerr << '.'; if (begin.line != end.line || begin.column == end.column) std::cerr << '^';