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...) 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 HandleSourceURLComments(); |
| 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 2955 matching lines...) Loading... |
3859 // Register that a break target found at the given stop in the | 3862 // Register that a break target found at the given stop in the |
3860 // target stack has been used from the top of the target stack. Add | 3863 // target stack has been used from the top of the target stack. Add |
3861 // the break target to any TargetCollectors passed on the stack. | 3864 // the break target to any TargetCollectors passed on the stack. |
3862 for (Target* t = target_stack_; t != stop; t = t->previous()) { | 3865 for (Target* t = target_stack_; t != stop; t = t->previous()) { |
3863 TargetCollector* collector = t->node()->AsTargetCollector(); | 3866 TargetCollector* collector = t->node()->AsTargetCollector(); |
3864 if (collector != NULL) collector->AddTarget(target, zone()); | 3867 if (collector != NULL) collector->AddTarget(target, zone()); |
3865 } | 3868 } |
3866 } | 3869 } |
3867 | 3870 |
3868 | 3871 |
| 3872 void Parser::HandleSourceURLComments() { |
| 3873 if (scanner_.source_url()->length() > 0) { |
| 3874 info_->script()->set_source_url( |
| 3875 *scanner_.source_url()->Internalize(isolate())); |
| 3876 } |
| 3877 if (scanner_.source_mapping_url()->length() > 0) { |
| 3878 info_->script()->set_source_mapping_url( |
| 3879 *scanner_.source_mapping_url()->Internalize(isolate())); |
| 3880 } |
| 3881 } |
| 3882 |
| 3883 |
3869 void Parser::ThrowPendingError() { | 3884 void Parser::ThrowPendingError() { |
3870 if (has_pending_error_) { | 3885 if (has_pending_error_) { |
3871 MessageLocation location(script_, | 3886 MessageLocation location(script_, |
3872 pending_error_location_.beg_pos, | 3887 pending_error_location_.beg_pos, |
3873 pending_error_location_.end_pos); | 3888 pending_error_location_.end_pos); |
3874 Factory* factory = isolate()->factory(); | 3889 Factory* factory = isolate()->factory(); |
3875 bool has_arg = | 3890 bool has_arg = |
3876 !pending_error_arg_.is_null() || pending_error_char_arg_ != NULL; | 3891 !pending_error_arg_.is_null() || pending_error_char_arg_ != NULL; |
3877 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); | 3892 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); |
3878 if (!pending_error_arg_.is_null()) { | 3893 if (!pending_error_arg_.is_null()) { |
(...skipping 933 matching lines...) Loading... |
4812 ASSERT(info()->isolate()->has_pending_exception()); | 4827 ASSERT(info()->isolate()->has_pending_exception()); |
4813 } else { | 4828 } else { |
4814 result = ParseProgram(); | 4829 result = ParseProgram(); |
4815 } | 4830 } |
4816 } | 4831 } |
4817 info()->SetFunction(result); | 4832 info()->SetFunction(result); |
4818 return (result != NULL); | 4833 return (result != NULL); |
4819 } | 4834 } |
4820 | 4835 |
4821 } } // namespace v8::internal | 4836 } } // namespace v8::internal |
OLD | NEW |