LGTM!

source codeb -> source code.

I would put curly braces around the for-loop bodies.

On Tue, Sep 9, 2008 at 8:59 PM, <[EMAIL PROTECTED]> wrote:
>
> I'd like you to do a code review.  To review this change, run
>
>  gvn review --project https://v8.googlecode.com/svn [EMAIL PROTECTED]/[EMAIL 
> PROTECTED]
>
> Alternatively, to review the latest snapshot of this change
> branch, run
>
>  gvn --project https://v8.googlecode.com/svn review [EMAIL 
> PROTECTED]/better-shell-error-messages
>
> to review the following change:
>
> [EMAIL PROTECTED]/[EMAIL PROTECTED] | [EMAIL PROTECTED] | 2008-09-09 19:58:54 
> +-100 (Tue, 09 Sep 2008)
>
> Description:
>
> Changed the shell to print source position with error messages.
> Added debug flags to gcc when compiling samples in debug mode.
>
>
>
>
> Affected Paths:
>   M //branches/bleeding_edge/SConstruct
>   M //branches/bleeding_edge/samples/shell.cc
>
>
> This is a semiautomated message from "gvn mail".  See
> <http://code.google.com/p/gvn/> to learn more.
>
> Index: SConstruct
> ===================================================================
> --- SConstruct  (^/branches/bleeding_edge/[EMAIL PROTECTED])
> +++ SConstruct  (^/changes/[EMAIL 
> PROTECTED]/better-shell-error-messages/bleeding_edge/[EMAIL PROTECTED])
> @@ -190,6 +190,9 @@ SAMPLE_FLAGS = {
>       'CCFLAGS':      ['-m32'],
>       'LINKFLAGS':    ['-m32']
>     },
> +    'mode:debug': {
> +      'CCFLAGS':      ['-g', '-O0']
> +    }
>   },
>   'msvc': {
>     'all': {
> Index: samples/shell.cc
> ===================================================================
> --- samples/shell.cc    (^/branches/bleeding_edge/samples/[EMAIL PROTECTED])
> +++ samples/shell.cc    (^/changes/[EMAIL 
> PROTECTED]/better-shell-error-messages/bleeding_edge/samples/[EMAIL 
> PROTECTED])
> @@ -40,6 +40,7 @@ v8::Handle<v8::Value> Load(const v8::Arguments& ar
>  v8::Handle<v8::Value> Quit(const v8::Arguments& args);
>  v8::Handle<v8::Value> Version(const v8::Arguments& args);
>  v8::Handle<v8::String> ReadFile(const char* name);
> +void ReportException(v8::TryCatch* handler);
>
>
>  int main(int argc, char* argv[]) {
> @@ -174,7 +175,7 @@ void RunShell(v8::Handle<v8::Context> context) {
>     char* str = fgets(buffer, kBufferSize, stdin);
>     if (str == NULL) break;
>     v8::HandleScope handle_scope;
> -    ExecuteString(v8::String::New(str), v8::Undefined(), true);
> +    ExecuteString(v8::String::New(str), v8::String::New("(shell)"), true);
>   }
>   printf("\n");
>  }
> @@ -189,15 +190,13 @@ bool ExecuteString(v8::Handle<v8::String> source,
>   v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
>   if (script.IsEmpty()) {
>     // Print errors that happened during compilation.
> -    v8::String::AsciiValue error(try_catch.Exception());
> -    printf("%s\n", *error);
> +    ReportException(&try_catch);
>     return false;
>   } else {
>     v8::Handle<v8::Value> result = script->Run();
>     if (result.IsEmpty()) {
>       // Print errors that happened during execution.
> -      v8::String::AsciiValue error(try_catch.Exception());
> -      printf("%s\n", *error);
> +      ReportException(&try_catch);
>       return false;
>     } else {
>       if (print_result && !result->IsUndefined()) {
> @@ -210,3 +209,31 @@ bool ExecuteString(v8::Handle<v8::String> source,
>     }
>   }
>  }
> +
> +
> +void ReportException(v8::TryCatch* try_catch) {
> +  v8::HandleScope handle_scope;
> +  v8::String::AsciiValue exception(try_catch->Exception());
> +  v8::Handle<v8::Message> message = try_catch->Message();
> +  if (message.IsEmpty()) {
> +    // V8 didn't provide any extra information about this error; just
> +    // print the exception.
> +    printf("%s\n", *exception);
> +  } else {
> +    // Print (filename):(line number): (message)b
> +    v8::String::AsciiValue filename(message->GetScriptResourceName());
> +    int linenum = message->GetLineNumber();
> +    printf("%s:%i: %s\n", *filename, linenum, *exception);
> +    // Print line of source codeb
> +    v8::String::AsciiValue sourceline(message->GetSourceLine());
> +    printf("%s\n", *sourceline);
> +    // Print wavy underline (GetUnderline is deprecated).
> +    int start = message->GetStartColumn();
> +    int end = message->GetEndColumn();
> +    for (int i = 0; i < start; i++)
> +      printf(" ");
> +    for (int i = start; i < end; i++)
> +      printf("^");
> +    printf("\n");
> +  }
> +}
>
>
> >

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to