Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: src/d8.cc

Issue 12653003: More useful result pretty printing for d8 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments; minor fixes Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/d8.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index eaebd900effb7d2145c958fc33fb89324b5a1c14..00b23fb9b3f736e62b37b2a0f12ddd2c8829dee4 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -214,13 +214,25 @@ bool Shell::ExecuteString(Isolate* isolate,
return false;
} else {
ASSERT(!try_catch.HasCaught());
- if (print_result && !result->IsUndefined()) {
- // If all went well and the result wasn't undefined then print
- // the returned value.
- v8::String::Utf8Value str(result);
- size_t count = fwrite(*str, sizeof(**str), str.length(), stdout);
- (void) count; // Silence GCC-4.5.x "unused result" warning.
- printf("\n");
+ if (print_result) {
+ if (options.test_shell) {
+ if (!result->IsUndefined()) {
+ // If all went well and the result wasn't undefined then print
+ // the returned value.
+ v8::String::Utf8Value str(result);
+ fwrite(*str, sizeof(**str), str.length(), stdout);
+ printf("\n");
+ }
+ } else {
+ Context::Scope context_scope(utility_context_);
+ Handle<Object> global = utility_context_->Global();
+ Handle<Value> fun = global->Get(String::New("Stringify"));
+ Handle<Value> argv[1] = { result };
+ Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv);
+ v8::String::Utf8Value str(s);
+ fwrite(*str, sizeof(**str), str.length(), stdout);
+ printf("\n");
+ }
}
return true;
}
« no previous file with comments | « no previous file | src/d8.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698