Modified CommandObjectExpression::EvaluateExpression() so that it takes an

additional (ComandReturnObject *) result parameter (default to NULL) and does
the right thing in setting the result status.

Also removed used variable ast_context.

llvm-svn: 110992
This commit is contained in:
Johnny Chen 2010-08-13 00:42:30 +00:00
parent 2df195eea1
commit fcd43b719b
2 changed files with 28 additions and 17 deletions

View File

@ -189,10 +189,11 @@ CommandObjectExpression::MultiLineExpressionCallback
} }
bool bool
CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream) CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream,
CommandReturnObject *result)
{ {
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
//////////////////////////////////// ////////////////////////////////////
// Set up the target and compiler // Set up the target and compiler
// //
@ -251,7 +252,6 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream
bool success; bool success;
bool canInterpret = false; bool canInterpret = false;
clang::ASTContext *ast_context = clang_expr.GetASTContext ();
ClangPersistentVariable *expr_result = 0; ClangPersistentVariable *expr_result = 0;
Error expr_error; Error expr_error;
@ -382,21 +382,27 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream
{ {
StreamString ss; StreamString ss;
Error err = expr_result->Print (ss, Error rc = expr_result->Print (ss,
m_exe_ctx, m_exe_ctx,
m_options.format, m_options.format,
m_options.show_types, m_options.show_types,
m_options.show_summary, m_options.show_summary,
m_options.debug); m_options.debug);
if (err.Success()) if (rc.Fail()) {
output_stream.PutCString(ss.GetString().c_str()); error_stream.Printf ("Couldn't print result : %s\n", rc.AsCString());
else return false;
error_stream.Printf ("Couldn't print result : %s\n", err.AsCString("unknown error")); }
output_stream.PutCString(ss.GetString().c_str());
if (result)
result->SetStatus (eReturnStatusSuccessFinishResult);
} }
else else
{ {
error_stream.Printf ("Expression produced no result\n"); error_stream.Printf ("Expression produced no result\n");
if (result)
result->SetStatus (eReturnStatusSuccessFinishNoResult);
} }
return true; return true;
@ -482,7 +488,11 @@ CommandObjectExpression::ExecuteRawCommandString
if (expr == NULL) if (expr == NULL)
expr = command; expr = command;
return EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream()); if (EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream(), &result))
return true;
result.SetStatus (eReturnStatusFailed);
return false;
} }
lldb::OptionDefinition lldb::OptionDefinition

View File

@ -87,10 +87,11 @@ protected:
size_t bytes_len); size_t bytes_len);
bool bool
EvaluateExpression (const char *expr, EvaluateExpression (const char *expr,
bool bare, bool bare,
Stream &output_stream, Stream &output_stream,
Stream &error_stream); Stream &error_stream,
CommandReturnObject *result = NULL);
CommandOptions m_options; CommandOptions m_options;
ExecutionContext m_exe_ctx; ExecutionContext m_exe_ctx;