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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/d8.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } else { 207 } else {
208 Handle<Value> result = script->Run(); 208 Handle<Value> result = script->Run();
209 if (result.IsEmpty()) { 209 if (result.IsEmpty()) {
210 ASSERT(try_catch.HasCaught()); 210 ASSERT(try_catch.HasCaught());
211 // Print errors that happened during execution. 211 // Print errors that happened during execution.
212 if (report_exceptions && !FLAG_debugger) 212 if (report_exceptions && !FLAG_debugger)
213 ReportException(isolate, &try_catch); 213 ReportException(isolate, &try_catch);
214 return false; 214 return false;
215 } else { 215 } else {
216 ASSERT(!try_catch.HasCaught()); 216 ASSERT(!try_catch.HasCaught());
217 if (print_result && !result->IsUndefined()) { 217 if (print_result) {
218 // If all went well and the result wasn't undefined then print 218 if (options.test_shell) {
219 // the returned value. 219 if (!result->IsUndefined()) {
220 v8::String::Utf8Value str(result); 220 // If all went well and the result wasn't undefined then print
221 size_t count = fwrite(*str, sizeof(**str), str.length(), stdout); 221 // the returned value.
222 (void) count; // Silence GCC-4.5.x "unused result" warning. 222 v8::String::Utf8Value str(result);
223 printf("\n"); 223 fwrite(*str, sizeof(**str), str.length(), stdout);
224 printf("\n");
225 }
226 } else {
227 Context::Scope context_scope(utility_context_);
228 Handle<Object> global = utility_context_->Global();
229 Handle<Value> fun = global->Get(String::New("Stringify"));
230 Handle<Value> argv[1] = { result };
231 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv);
232 v8::String::Utf8Value str(s);
233 fwrite(*str, sizeof(**str), str.length(), stdout);
234 printf("\n");
235 }
224 } 236 }
225 return true; 237 return true;
226 } 238 }
227 } 239 }
228 } 240 }
229 241
230 242
231 Handle<Value> Shell::Print(const Arguments& args) { 243 Handle<Value> Shell::Print(const Arguments& args) {
232 Handle<Value> val = Write(args); 244 Handle<Value> val = Write(args);
233 printf("\n"); 245 printf("\n");
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 } 1981 }
1970 1982
1971 } // namespace v8 1983 } // namespace v8
1972 1984
1973 1985
1974 #ifndef GOOGLE3 1986 #ifndef GOOGLE3
1975 int main(int argc, char* argv[]) { 1987 int main(int argc, char* argv[]) {
1976 return v8::Shell::Main(argc, argv); 1988 return v8::Shell::Main(argc, argv);
1977 } 1989 }
1978 #endif 1990 #endif
OLDNEW
« 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