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

Side by Side Diff: samples/shell.cc

Issue 7860035: Merge bleeding edge up to 9192 into the GC branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 3 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 | « include/v8.h ('k') | src/SConscript » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return 0; 243 return 0;
244 } 244 }
245 245
246 246
247 // The read-eval-execute loop of the shell. 247 // The read-eval-execute loop of the shell.
248 void RunShell(v8::Handle<v8::Context> context) { 248 void RunShell(v8::Handle<v8::Context> context) {
249 printf("V8 version %s [sample shell]\n", v8::V8::GetVersion()); 249 printf("V8 version %s [sample shell]\n", v8::V8::GetVersion());
250 static const int kBufferSize = 256; 250 static const int kBufferSize = 256;
251 // Enter the execution environment before evaluating any code. 251 // Enter the execution environment before evaluating any code.
252 v8::Context::Scope context_scope(context); 252 v8::Context::Scope context_scope(context);
253 v8::Local<v8::String> name(v8::String::New("(shell)"));
253 while (true) { 254 while (true) {
254 char buffer[kBufferSize]; 255 char buffer[kBufferSize];
255 printf("> "); 256 printf("> ");
256 char* str = fgets(buffer, kBufferSize, stdin); 257 char* str = fgets(buffer, kBufferSize, stdin);
257 if (str == NULL) break; 258 if (str == NULL) break;
258 v8::HandleScope handle_scope; 259 v8::HandleScope handle_scope;
259 ExecuteString(v8::String::New(str), 260 ExecuteString(v8::String::New(str), name, true, true);
260 v8::String::New("(shell)"),
261 true,
262 true);
263 } 261 }
264 printf("\n"); 262 printf("\n");
265 } 263 }
266 264
267 265
268 // Executes a string within the current v8 context. 266 // Executes a string within the current v8 context.
269 bool ExecuteString(v8::Handle<v8::String> source, 267 bool ExecuteString(v8::Handle<v8::String> source,
270 v8::Handle<v8::Value> name, 268 v8::Handle<v8::Value> name,
271 bool print_result, 269 bool print_result,
272 bool report_exceptions) { 270 bool report_exceptions) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 printf("^"); 328 printf("^");
331 } 329 }
332 printf("\n"); 330 printf("\n");
333 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 331 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
334 if (stack_trace.length() > 0) { 332 if (stack_trace.length() > 0) {
335 const char* stack_trace_string = ToCString(stack_trace); 333 const char* stack_trace_string = ToCString(stack_trace);
336 printf("%s\n", stack_trace_string); 334 printf("%s\n", stack_trace_string);
337 } 335 }
338 } 336 }
339 } 337 }
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698