Revision: 2666 Author: [email protected] Date: Wed Aug 12 04:52:22 2009 Log: Add a write() command to d8. This is the same as the print() command, with the exception that it does not add a new-line to the end. This half of what is required to make the Debian Language Shootout code work correctly: http://code.google.com/p/v8/issues/detail?id=354
BUG=354 http://code.google.com/p/v8/source/detail?r=2666 Modified: /branches/bleeding_edge/src/d8.cc /branches/bleeding_edge/src/d8.h ======================================= --- /branches/bleeding_edge/src/d8.cc Mon Jun 8 23:53:15 2009 +++ /branches/bleeding_edge/src/d8.cc Wed Aug 12 04:52:22 2009 @@ -146,19 +146,22 @@ Handle<Value> Shell::Print(const Arguments& args) { - bool first = true; + Handle<Value> val = Write(args); + printf("\n"); + return val; +} + + +Handle<Value> Shell::Write(const Arguments& args) { for (int i = 0; i < args.Length(); i++) { HandleScope handle_scope; - if (first) { - first = false; - } else { + if (i != 0) { printf(" "); } v8::String::Utf8Value str(args[i]); const char* cstr = ToCString(str); printf("%s", cstr); } - printf("\n"); return Undefined(); } @@ -399,6 +402,7 @@ HandleScope scope; Handle<ObjectTemplate> global_template = ObjectTemplate::New(); global_template->Set(String::New("print"), FunctionTemplate::New(Print)); + global_template->Set(String::New("write"), FunctionTemplate::New(Write)); global_template->Set(String::New("read"), FunctionTemplate::New(Read)); global_template->Set(String::New("load"), FunctionTemplate::New(Load)); global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); @@ -588,6 +592,8 @@ Handle<ObjectTemplate> global_template = ObjectTemplate::New(); global_template->Set(String::New("print"), FunctionTemplate::New(Shell::Print)); + global_template->Set(String::New("write"), + FunctionTemplate::New(Shell::Write)); global_template->Set(String::New("read"), FunctionTemplate::New(Shell::Read)); global_template->Set(String::New("load"), ======================================= --- /branches/bleeding_edge/src/d8.h Mon Apr 20 09:36:13 2009 +++ /branches/bleeding_edge/src/d8.h Wed Aug 12 04:52:22 2009 @@ -138,6 +138,7 @@ #endif static Handle<Value> Print(const Arguments& args); + static Handle<Value> Write(const Arguments& args); static Handle<Value> Yield(const Arguments& args); static Handle<Value> Quit(const Arguments& args); static Handle<Value> Version(const Arguments& args); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
