| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index 369a451f350c543e3c193a5a332eb8c9e8fef0f0..c65766df77fb88a2afa9d626142697299dcff9a8 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -891,6 +891,9 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
|
| bool ok = true;
|
| int beg_pos = scanner()->location().beg_pos;
|
| ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
|
| +
|
| + if (scanner()->HasSourceMapComment()) ParseSourceMapComment();
|
| +
|
| if (ok && strict_mode() == STRICT) {
|
| CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
|
| }
|
| @@ -3835,6 +3838,51 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) {
|
| }
|
|
|
|
|
| +void Parser::ParseSourceMapComment() {
|
| + Handle<String> source_map_comment =
|
| + scanner()->AllocateInternalizedSourceMapComment(isolate());
|
| + int value_start = 0, value_end = 0;
|
| + {
|
| + DisallowHeapAllocation no_gc; // flat_data needs to stay alive.
|
| + String::FlatContent flat_data = source_map_comment->GetFlatContent();
|
| + if (!flat_data.IsAscii())
|
| + return;
|
| + Vector<const uint8_t> data = flat_data.ToOneByteVector();
|
| + // Parse the following: \s*name\s*=\s*value\s*.*
|
| + int name_start = 0;
|
| + while (name_start < data.length() && data[name_start] == ' ') {
|
| + ++name_start;
|
| + }
|
| + int name_end = name_start;
|
| + while (name_end < data.length() && data[name_end] != ' ' &&
|
| + data[name_end] != '=') {
|
| + ++name_end;
|
| + }
|
| + value_start = name_end;
|
| + while (value_start < data.length() && data[value_start] == ' ') {
|
| + ++value_start;
|
| + }
|
| + if (value_start >= data.length() || data[value_start] != '=') {
|
| + return;
|
| + }
|
| + ++value_start; // Skip '='
|
| + while (value_start < data.length() && data[value_start] == ' ') {
|
| + ++value_start;
|
| + }
|
| + value_end = value_start;
|
| + while (value_end < data.length() && data[value_end] != ' ') {
|
| + ++value_end;
|
| + }
|
| + Vector<const uint8_t> name = data.SubVector(name_start, name_end);
|
| + if (!name.IsEqualTo(STATIC_ASCII_VECTOR("sourceURL"))) {
|
| + return;
|
| + }
|
| + }
|
| + info_->script()->set_source_url(*(isolate()->factory()->NewSubString(
|
| + source_map_comment, value_start, value_end)));
|
| +}
|
| +
|
| +
|
| void Parser::ThrowPendingError() {
|
| if (has_pending_error_) {
|
| MessageLocation location(script_,
|
|
|