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

Unified Diff: src/preparser.cc

Issue 722793005: Classes: Implement correct name binding (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 7ab9814bb41722de1be126ffd96313e523346379..1a2ddb61c560fa942bddf53381013be754d2a4bf 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -132,6 +132,14 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
}
+PreParserExpression PreParserTraits::ParseClassLiteral(
+ PreParserIdentifier name, Scanner::Location class_name_location,
+ bool name_is_strict_reserved, int pos, bool* ok) {
+ return pre_parser_->ParseClassLiteral(name, class_name_location,
+ name_is_strict_reserved, pos, ok);
+}
+
+
// Preparsing checks a JavaScript program and emits preparse-data that helps
// a later parsing to be faster.
// See preparser-data.h for the data.
@@ -928,6 +936,47 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
}
+PreParserExpression PreParser::ParseClassLiteral(
+ PreParserIdentifier name, Scanner::Location class_name_location,
+ bool name_is_strict_reserved, int pos, bool* ok) {
+ // All parts of a ClassDeclaration and ClassExpression are strict code.
+ if (name_is_strict_reserved) {
+ ReportMessageAt(class_name_location, "unexpected_strict_reserved");
+ *ok = false;
+ return EmptyExpression();
+ }
+ if (IsEvalOrArguments(name)) {
+ ReportMessageAt(class_name_location, "strict_eval_arguments");
+ *ok = false;
+ return EmptyExpression();
+ }
+
+ PreParserScope scope = NewScope(scope_, BLOCK_SCOPE);
+ BlockState block_state(&scope_, &scope);
+ scope_->SetStrictMode(STRICT);
+ scope_->SetScopeName(name);
+
+ if (Check(Token::EXTENDS)) {
+ ParseLeftHandSideExpression(CHECK_OK);
+ }
+
+ bool has_seen_constructor = false;
+
+ Expect(Token::LBRACE, CHECK_OK);
+ while (peek() != Token::RBRACE) {
+ if (Check(Token::SEMICOLON)) continue;
+ const bool in_class = true;
+ const bool is_static = false;
+ ParsePropertyDefinition(NULL, in_class, is_static, &has_seen_constructor,
+ CHECK_OK);
+ }
+
+ Expect(Token::RBRACE, CHECK_OK);
+
+ return Expression::Default();
+}
+
+
PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
// CallRuntime ::
// '%' Identifier Arguments
« src/parser.cc ('K') | « src/preparser.h ('k') | test/mjsunit/harmony/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698