Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 ParsingModeScope parsing_mode(this, mode); | 884 ParsingModeScope parsing_mode(this, mode); |
| 885 | 885 |
| 886 // Enters 'scope'. | 886 // Enters 'scope'. |
| 887 FunctionState function_state(&function_state_, &scope_, scope, zone()); | 887 FunctionState function_state(&function_state_, &scope_, scope, zone()); |
| 888 | 888 |
| 889 scope_->SetStrictMode(info->strict_mode()); | 889 scope_->SetStrictMode(info->strict_mode()); |
| 890 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 890 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 891 bool ok = true; | 891 bool ok = true; |
| 892 int beg_pos = scanner()->location().beg_pos; | 892 int beg_pos = scanner()->location().beg_pos; |
| 893 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); | 893 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); |
| 894 | |
| 895 if (scanner()->HasSourceMapComment()) ParseSourceMapComment(); | |
| 896 | |
| 894 if (ok && strict_mode() == STRICT) { | 897 if (ok && strict_mode() == STRICT) { |
| 895 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); | 898 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); |
| 896 } | 899 } |
| 897 | 900 |
| 898 if (ok && allow_harmony_scoping() && strict_mode() == STRICT) { | 901 if (ok && allow_harmony_scoping() && strict_mode() == STRICT) { |
| 899 CheckConflictingVarDeclarations(scope_, &ok); | 902 CheckConflictingVarDeclarations(scope_, &ok); |
| 900 } | 903 } |
| 901 | 904 |
| 902 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { | 905 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { |
| 903 if (body->length() != 1 || | 906 if (body->length() != 1 || |
| (...skipping 2924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3828 // Register that a break target found at the given stop in the | 3831 // Register that a break target found at the given stop in the |
| 3829 // target stack has been used from the top of the target stack. Add | 3832 // target stack has been used from the top of the target stack. Add |
| 3830 // the break target to any TargetCollectors passed on the stack. | 3833 // the break target to any TargetCollectors passed on the stack. |
| 3831 for (Target* t = target_stack_; t != stop; t = t->previous()) { | 3834 for (Target* t = target_stack_; t != stop; t = t->previous()) { |
| 3832 TargetCollector* collector = t->node()->AsTargetCollector(); | 3835 TargetCollector* collector = t->node()->AsTargetCollector(); |
| 3833 if (collector != NULL) collector->AddTarget(target, zone()); | 3836 if (collector != NULL) collector->AddTarget(target, zone()); |
| 3834 } | 3837 } |
| 3835 } | 3838 } |
| 3836 | 3839 |
| 3837 | 3840 |
| 3841 void Parser::ParseSourceMapComment() { | |
| 3842 Handle<String> source_map_comment = | |
| 3843 scanner()->AllocateInternalizedSourceMapComment(isolate()); | |
| 3844 int value_start = 0, value_end = 0; | |
| 3845 { | |
| 3846 DisallowHeapAllocation no_gc; // flat_data needs to stay alive. | |
| 3847 String::FlatContent flat_data = source_map_comment->GetFlatContent(); | |
| 3848 if (!flat_data.IsAscii()) | |
| 3849 return; | |
| 3850 Vector<const uint8_t> data = flat_data.ToOneByteVector(); | |
| 3851 // Parse the following: \s*name\s*=\s*value\s*.* | |
| 3852 int name_start = 0; | |
| 3853 while (name_start < data.length() && data[name_start] == ' ') { | |
|
yurys
2014/06/05 13:55:21
This won't work for \tname=. Also the original pat
| |
| 3854 ++name_start; | |
| 3855 } | |
| 3856 int name_end = name_start; | |
| 3857 while (name_end < data.length() && data[name_end] != ' ' && | |
| 3858 data[name_end] != '=') { | |
| 3859 ++name_end; | |
| 3860 } | |
| 3861 value_start = name_end; | |
| 3862 while (value_start < data.length() && data[value_start] == ' ') { | |
|
yurys
2014/06/05 13:55:21
Same here, the original pattern was [\040\t]source
| |
| 3863 ++value_start; | |
| 3864 } | |
| 3865 if (value_start >= data.length() || data[value_start] != '=') { | |
| 3866 return; | |
| 3867 } | |
| 3868 ++value_start; // Skip '=' | |
| 3869 while (value_start < data.length() && data[value_start] == ' ') { | |
| 3870 ++value_start; | |
| 3871 } | |
| 3872 value_end = value_start; | |
| 3873 while (value_end < data.length() && data[value_end] != ' ') { | |
| 3874 ++value_end; | |
| 3875 } | |
| 3876 Vector<const uint8_t> name = data.SubVector(name_start, name_end); | |
| 3877 if (!name.IsEqualTo(STATIC_ASCII_VECTOR("sourceURL"))) { | |
| 3878 return; | |
| 3879 } | |
| 3880 } | |
| 3881 info_->script()->set_source_url(*(isolate()->factory()->NewSubString( | |
| 3882 source_map_comment, value_start, value_end))); | |
| 3883 } | |
| 3884 | |
| 3885 | |
| 3838 void Parser::ThrowPendingError() { | 3886 void Parser::ThrowPendingError() { |
| 3839 if (has_pending_error_) { | 3887 if (has_pending_error_) { |
| 3840 MessageLocation location(script_, | 3888 MessageLocation location(script_, |
| 3841 pending_error_location_.beg_pos, | 3889 pending_error_location_.beg_pos, |
| 3842 pending_error_location_.end_pos); | 3890 pending_error_location_.end_pos); |
| 3843 Factory* factory = isolate()->factory(); | 3891 Factory* factory = isolate()->factory(); |
| 3844 bool has_arg = | 3892 bool has_arg = |
| 3845 !pending_error_arg_.is_null() || pending_error_char_arg_ != NULL; | 3893 !pending_error_arg_.is_null() || pending_error_char_arg_ != NULL; |
| 3846 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); | 3894 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); |
| 3847 if (!pending_error_arg_.is_null()) { | 3895 if (!pending_error_arg_.is_null()) { |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4781 ASSERT(info()->isolate()->has_pending_exception()); | 4829 ASSERT(info()->isolate()->has_pending_exception()); |
| 4782 } else { | 4830 } else { |
| 4783 result = ParseProgram(); | 4831 result = ParseProgram(); |
| 4784 } | 4832 } |
| 4785 } | 4833 } |
| 4786 info()->SetFunction(result); | 4834 info()->SetFunction(result); |
| 4787 return (result != NULL); | 4835 return (result != NULL); |
| 4788 } | 4836 } |
| 4789 | 4837 |
| 4790 } } // namespace v8::internal | 4838 } } // namespace v8::internal |
| OLD | NEW |