Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: src/parser.cc

Issue 316173002: Handle "//# sourceURL" comments in the Parser instead of the JS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: yet another trivial rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 888
889 // Enters 'scope'. 889 // Enters 'scope'.
890 FunctionState function_state(&function_state_, &scope_, scope, zone(), 890 FunctionState function_state(&function_state_, &scope_, scope, zone(),
891 ast_value_factory_); 891 ast_value_factory_);
892 892
893 scope_->SetStrictMode(info->strict_mode()); 893 scope_->SetStrictMode(info->strict_mode());
894 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 894 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
895 bool ok = true; 895 bool ok = true;
896 int beg_pos = scanner()->location().beg_pos; 896 int beg_pos = scanner()->location().beg_pos;
897 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); 897 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
898
899 HandleSourceURLComments();
900
898 if (ok && strict_mode() == STRICT) { 901 if (ok && strict_mode() == STRICT) {
899 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 902 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
900 } 903 }
901 904
902 if (ok && allow_harmony_scoping() && strict_mode() == STRICT) { 905 if (ok && allow_harmony_scoping() && strict_mode() == STRICT) {
903 CheckConflictingVarDeclarations(scope_, &ok); 906 CheckConflictingVarDeclarations(scope_, &ok);
904 } 907 }
905 908
906 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 909 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
907 if (body->length() != 1 || 910 if (body->length() != 1 ||
(...skipping 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 // Register that a break target found at the given stop in the 3878 // Register that a break target found at the given stop in the
3876 // target stack has been used from the top of the target stack. Add 3879 // target stack has been used from the top of the target stack. Add
3877 // the break target to any TargetCollectors passed on the stack. 3880 // the break target to any TargetCollectors passed on the stack.
3878 for (Target* t = target_stack_; t != stop; t = t->previous()) { 3881 for (Target* t = target_stack_; t != stop; t = t->previous()) {
3879 TargetCollector* collector = t->node()->AsTargetCollector(); 3882 TargetCollector* collector = t->node()->AsTargetCollector();
3880 if (collector != NULL) collector->AddTarget(target, zone()); 3883 if (collector != NULL) collector->AddTarget(target, zone());
3881 } 3884 }
3882 } 3885 }
3883 3886
3884 3887
3888 void Parser::HandleSourceURLComments() {
3889 if (scanner_.source_url()->length() > 0) {
3890 info_->script()->set_source_url(
3891 *scanner_.source_url()->Internalize(isolate()));
3892 }
3893 if (scanner_.source_mapping_url()->length() > 0) {
3894 info_->script()->set_source_mapping_url(
3895 *scanner_.source_mapping_url()->Internalize(isolate()));
3896 }
3897 }
3898
3899
3885 void Parser::ThrowPendingError() { 3900 void Parser::ThrowPendingError() {
3886 ASSERT(ast_value_factory_->IsInternalized()); 3901 ASSERT(ast_value_factory_->IsInternalized());
3887 if (has_pending_error_) { 3902 if (has_pending_error_) {
3888 MessageLocation location(script_, 3903 MessageLocation location(script_,
3889 pending_error_location_.beg_pos, 3904 pending_error_location_.beg_pos,
3890 pending_error_location_.end_pos); 3905 pending_error_location_.end_pos);
3891 Factory* factory = isolate()->factory(); 3906 Factory* factory = isolate()->factory();
3892 bool has_arg = 3907 bool has_arg =
3893 pending_error_arg_ != NULL || pending_error_char_arg_ != NULL; 3908 pending_error_arg_ != NULL || pending_error_char_arg_ != NULL;
3894 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); 3909 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0);
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
4863 info()->SetAstValueFactory(ast_value_factory_); 4878 info()->SetAstValueFactory(ast_value_factory_);
4864 } 4879 }
4865 ast_value_factory_ = NULL; 4880 ast_value_factory_ = NULL;
4866 4881
4867 InternalizeUseCounts(); 4882 InternalizeUseCounts();
4868 4883
4869 return (result != NULL); 4884 return (result != NULL);
4870 } 4885 }
4871 4886
4872 } } // namespace v8::internal 4887 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698