I think we can solve the problem with trying to get line numbers more elegantly,
without going to V8::TryCatch. I think I didn't properly understood your use
case when you asked me one or two weeks ago about this.

If you take a look at Runtime_CompileString... it implements javascript's eval
and basically has to solve the same problem. Running the script
try {
  eval("syntax_error");
} catch (e) {
  print(e.stack);
}

we can still get the line numbers of the syntax error.

If I'm not mistaken, the GatherCompileInfo javascript function calls into
Runtime_LiveEditGatherCompileInfo, eventually calling
LiveEdit::GatherCompileInfo.

What you could do here is just leaving this as is, and at the call site of
GatherCompileInfo catch the potential syntax error, and read the line numbers
from the stack trace.

To get the line numbers as integers without having to tediously parse the
'stack' property, you could define your own formatting function. See
http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

Short story is: if you override Error.prepareStackTrace with your own function,
you can define what ends up in the 'stack' property of the error object. You
could have it return an object that contains the line numbers you need. I admit that there is probably no easy way to find out end position of the syntax error
though, only the start position.

Would that be something you could work with?

Also, a test would be really nice :)


https://codereview.chromium.org/11421100/diff/2001/src/liveedit-debugger.js
File src/liveedit-debugger.js (right):

https://codereview.chromium.org/11421100/diff/2001/src/liveedit-debugger.js#newcode86
src/liveedit-debugger.js:86: failure.details = details;
I'd put this after the following if, even though this doesn't really
make a difference.

https://codereview.chromium.org/11421100/

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

Reply via email to