From e06e5ee1f12b9b79b34570e65c1f5e9c12b9b8c3 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 7 Jun 2012 16:20:47 -0700 Subject: [PATCH] Peel away CYCompound layers to fix tab completion. --- Console.cpp | 11 ++++++++--- Parser.hpp | 2 ++ Replace.cpp | 9 +++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Console.cpp b/Console.cpp index 09298a1..d669e67 100644 --- a/Console.cpp +++ b/Console.cpp @@ -213,9 +213,14 @@ static CYExpression *ParseExpression(CYUTF8String code) { if (parser.parse() != 0 || !driver.errors_.empty()) return NULL; - CYExpress *express(dynamic_cast(driver.program_->statements_)); - _assert(express != NULL); - return express->expression_; + 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); + + return NULL; } static int client_; diff --git a/Parser.hpp b/Parser.hpp index 47d80ec..7197428 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -627,6 +627,8 @@ struct CYCompound : virtual CYExpression *Replace(CYContext &context); void Output(CYOutput &out, CYFlags flags) const; + + virtual CYExpression *Primitive(CYContext &context); }; struct CYDeclaration; diff --git a/Replace.cpp b/Replace.cpp index c141e4f..d40c8f3 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -155,6 +155,15 @@ CYExpression *CYCompound::Replace(CYContext &context) { return this; } +CYExpression *CYCompound::Primitive(CYContext &context) { + CYExpression *expression(expressions_); + if (expression == NULL) + return NULL; + while (expression->next_ != NULL) + expression = expression->next_; + return expression->Primitive(context); +} + CYFunctionParameter *CYComprehension::Parameters(CYContext &context) const { $T(NULL) CYFunctionParameter *next(next_->Parameters(context)); if (CYFunctionParameter *parameter = Parameter(context)) { -- 2.45.2