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

Side by Side Diff: src/preparser.cc

Issue 1083193005: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 PreParser::PreParseResult PreParser::PreParseLazyFunction( 101 PreParser::PreParseResult PreParser::PreParseLazyFunction(
102 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) { 102 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) {
103 log_ = log; 103 log_ = log;
104 // Lazy functions always have trivial outer scopes (no with/catch scopes). 104 // Lazy functions always have trivial outer scopes (no with/catch scopes).
105 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); 105 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
106 PreParserFactory top_factory(NULL); 106 PreParserFactory top_factory(NULL);
107 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, 107 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction,
108 &top_factory); 108 &top_factory);
109 scope_->SetLanguageMode(language_mode); 109 scope_->SetLanguageMode(language_mode);
110 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); 110 Scope* function_scope =
111 NewScope(scope_, IsArrowFunction(kind) ? ARROW_SCOPE : FUNCTION_SCOPE);
111 PreParserFactory function_factory(NULL); 112 PreParserFactory function_factory(NULL);
112 FunctionState function_state(&function_state_, &scope_, function_scope, kind, 113 FunctionState function_state(&function_state_, &scope_, function_scope, kind,
113 &function_factory); 114 &function_factory);
114 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 115 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
115 bool ok = true; 116 bool ok = true;
116 int start_position = peek_position(); 117 int start_position = peek_position();
117 ParseLazyFunctionLiteralBody(&ok); 118 ParseLazyFunctionLiteralBody(&ok);
118 if (stack_overflow()) return kPreParseStackOverflow; 119 if (stack_overflow()) return kPreParseStackOverflow;
119 if (!ok) { 120 if (!ok) {
120 ReportUnexpectedToken(scanner()->current_token()); 121 ReportUnexpectedToken(scanner()->current_token());
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 int body_start = position(); 989 int body_start = position();
989 ParseStatementList(Token::RBRACE, ok); 990 ParseStatementList(Token::RBRACE, ok);
990 if (!*ok) return; 991 if (!*ok) return;
991 992
992 // Position right after terminal '}'. 993 // Position right after terminal '}'.
993 DCHECK_EQ(Token::RBRACE, scanner()->peek()); 994 DCHECK_EQ(Token::RBRACE, scanner()->peek());
994 int body_end = scanner()->peek_location().end_pos; 995 int body_end = scanner()->peek_location().end_pos;
995 log_->LogFunction(body_start, body_end, 996 log_->LogFunction(body_start, body_end,
996 function_state_->materialized_literal_count(), 997 function_state_->materialized_literal_count(),
997 function_state_->expected_property_count(), language_mode(), 998 function_state_->expected_property_count(), language_mode(),
998 scope_->uses_super_property()); 999 scope_->uses_super_property(), scope_->uses_new_target());
999 } 1000 }
1000 1001
1001 1002
1002 PreParserExpression PreParser::ParseClassLiteral( 1003 PreParserExpression PreParser::ParseClassLiteral(
1003 PreParserIdentifier name, Scanner::Location class_name_location, 1004 PreParserIdentifier name, Scanner::Location class_name_location,
1004 bool name_is_strict_reserved, int pos, bool* ok) { 1005 bool name_is_strict_reserved, int pos, bool* ok) {
1005 // All parts of a ClassDeclaration and ClassExpression are strict code. 1006 // All parts of a ClassDeclaration and ClassExpression are strict code.
1006 if (name_is_strict_reserved) { 1007 if (name_is_strict_reserved) {
1007 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); 1008 ReportMessageAt(class_name_location, "unexpected_strict_reserved");
1008 *ok = false; 1009 *ok = false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 1068
1068 DCHECK(!spread_pos.IsValid()); 1069 DCHECK(!spread_pos.IsValid());
1069 1070
1070 return Expression::Default(); 1071 return Expression::Default();
1071 } 1072 }
1072 1073
1073 #undef CHECK_OK 1074 #undef CHECK_OK
1074 1075
1075 1076
1076 } } // v8::internal 1077 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/runtime/runtime.h » ('j') | src/runtime/runtime-classes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698