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

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: 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') | src/d8.js » ('J')
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } else { 206 } else {
207 Handle<Value> result = script->Run(); 207 Handle<Value> result = script->Run();
208 if (result.IsEmpty()) { 208 if (result.IsEmpty()) {
209 ASSERT(try_catch.HasCaught()); 209 ASSERT(try_catch.HasCaught());
210 // Print errors that happened during execution. 210 // Print errors that happened during execution.
211 if (report_exceptions && !FLAG_debugger) 211 if (report_exceptions && !FLAG_debugger)
212 ReportException(&try_catch); 212 ReportException(&try_catch);
213 return false; 213 return false;
214 } else { 214 } else {
215 ASSERT(!try_catch.HasCaught()); 215 ASSERT(!try_catch.HasCaught());
216 if (print_result && !result->IsUndefined()) { 216 if (print_result) {
217 // If all went well and the result wasn't undefined then print 217 if (options.test_shell) {
218 // the returned value. 218 if (!result->IsUndefined()) {
219 v8::String::Utf8Value str(result); 219 // If all went well and the result wasn't undefined then print
220 size_t count = fwrite(*str, sizeof(**str), str.length(), stdout); 220 // the returned value.
221 (void) count; // Silence GCC-4.5.x "unused result" warning. 221 v8::String::Utf8Value str(result);
222 printf("\n"); 222 fwrite(*str, sizeof(**str), str.length(), stdout);
223 printf("\n");
224 }
225 } else {
226 Context::Scope context_scope(utility_context_);
227 Handle<Object> global = utility_context_->Global();
228 Handle<Value> fun = global->Get(String::New("Stringify"));
229 Handle<Value> argv[1] = { result };
230 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv);
231 v8::String::Utf8Value str(s);
232 fwrite(*str, sizeof(**str), str.length(), stdout);
233 printf("\n");
234 }
223 } 235 }
224 return true; 236 return true;
225 } 237 }
226 } 238 }
227 } 239 }
228 240
229 241
230 Handle<Value> Shell::Print(const Arguments& args) { 242 Handle<Value> Shell::Print(const Arguments& args) {
231 Handle<Value> val = Write(args); 243 Handle<Value> val = Write(args);
232 printf("\n"); 244 printf("\n");
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 } 1974 }
1963 1975
1964 } // namespace v8 1976 } // namespace v8
1965 1977
1966 1978
1967 #ifndef GOOGLE3 1979 #ifndef GOOGLE3
1968 int main(int argc, char* argv[]) { 1980 int main(int argc, char* argv[]) {
1969 return v8::Shell::Main(argc, argv); 1981 return v8::Shell::Main(argc, argv);
1970 } 1982 }
1971 #endif 1983 #endif
OLDNEW
« no previous file with comments | « no previous file | src/d8.js » ('j') | src/d8.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698