X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/aa926c8bd4e2bdc41f7370c3e6cf1f1d00aef8d9..c252950279eadefe8cd5ceb41f0eaa0d20153a56:/Console.cpp diff --git a/Console.cpp b/Console.cpp index b7a4533..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_; @@ -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) {