Merge remote-tracking branch 'ry/v0.8'

Conflicts:
	ChangeLog
	deps/uv/src/unix/sunos.c
	deps/uv/test/test-tcp-unexpected-read.c
	src/node_version.h
This commit is contained in:
isaacs
2012-08-03 16:23:14 -07:00
586 changed files with 5638 additions and 59111 deletions

View File

@@ -1187,8 +1187,15 @@ ssize_t DecodeWrite(char *buf,
return buflen;
}
void DisplayExceptionLine (TryCatch &try_catch) {
// Prevent re-entry into this function. For example, if there is
// a throw from a program in vm.runInThisContext(code, filename, true),
// then we want to show the original failure, not the secondary one.
static bool displayed_error = false;
if (displayed_error) return;
displayed_error = true;
HandleScope scope;
Handle<Message> message = try_catch.Message();
@@ -1207,33 +1214,37 @@ void DisplayExceptionLine (TryCatch &try_catch) {
String::Utf8Value sourceline(message->GetSourceLine());
const char* sourceline_string = *sourceline;
// HACK HACK HACK
//
// FIXME
//
// Because of how CommonJS modules work, all scripts are wrapped with a
// "function (function (exports, __filename, ...) {"
// Because of how node modules work, all scripts are wrapped with a
// "function (module, exports, __filename, ...) {"
// to provide script local variables.
//
// When reporting errors on the first line of a script, this wrapper
// function is leaked to the user. This HACK is to remove it. The length
// of the wrapper is 62. That wrapper is defined in src/node.js
// function is leaked to the user. There used to be a hack here to
// truncate off the first 62 characters, but it caused numerous other
// problems when vm.runIn*Context() methods were used for non-module
// code.
//
// If that wrapper is ever changed, then this number also has to be
// updated. Or - someone could clean this up so that the two peices
// don't need to be changed.
// If we ever decide to re-instate such a hack, the following steps
// must be taken:
//
// Even better would be to get support into V8 for wrappers that
// shouldn't be reported to users.
int offset = linenum == 1 ? 62 : 0;
// 1. Pass a flag around to say "this code was wrapped"
// 2. Update the stack frame output so that it is also correct.
//
// It would probably be simpler to add a line rather than add some
// number of characters to the first line, since V8 truncates the
// sourceline to 78 characters, and we end up not providing very much
// useful debugging info to the user if we remove 62 characters.
fprintf(stderr, "%s\n", sourceline_string + offset);
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = offset; i < start; i++) {
int end = message->GetEndColumn();
// fprintf(stderr, "---\nsourceline:%s\noffset:%d\nstart:%d\nend:%d\n---\n", sourceline_string, start, end);
fprintf(stderr, "%s\n", sourceline_string);
// Print wavy underline (GetUnderline is deprecated).
for (int i = 0; i < start; i++) {
fputc((sourceline_string[i] == '\t') ? '\t' : ' ', stderr);
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
fputc('^', stderr);
}