OLD | NEW |
---|---|
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 125 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
126 if (scope_->strict_mode() == STRICT) { | 126 if (scope_->strict_mode() == STRICT) { |
127 int end_pos = scanner()->location().end_pos; | 127 int end_pos = scanner()->location().end_pos; |
128 CheckOctalLiteral(start_position, end_pos, &ok); | 128 CheckOctalLiteral(start_position, end_pos, &ok); |
129 } | 129 } |
130 } | 130 } |
131 return kPreParseSuccess; | 131 return kPreParseSuccess; |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 PreParserExpression PreParserTraits::ParseClassLiteral( | |
136 PreParserIdentifier name, Scanner::Location class_name_location, | |
137 bool name_is_strict_reserved, int pos, bool* ok) { | |
138 return pre_parser_->ParseClassLiteral(name, class_name_location, | |
139 name_is_strict_reserved, pos, ok); | |
140 } | |
141 | |
142 | |
135 // Preparsing checks a JavaScript program and emits preparse-data that helps | 143 // Preparsing checks a JavaScript program and emits preparse-data that helps |
136 // a later parsing to be faster. | 144 // a later parsing to be faster. |
137 // See preparser-data.h for the data. | 145 // See preparser-data.h for the data. |
138 | 146 |
139 // The PreParser checks that the syntax follows the grammar for JavaScript, | 147 // The PreParser checks that the syntax follows the grammar for JavaScript, |
140 // and collects some information about the program along the way. | 148 // and collects some information about the program along the way. |
141 // The grammar check is only performed in order to understand the program | 149 // The grammar check is only performed in order to understand the program |
142 // sufficiently to deduce some information about it, that can be used | 150 // sufficiently to deduce some information about it, that can be used |
143 // to speed up later parsing. Finding errors is not the goal of pre-parsing, | 151 // to speed up later parsing. Finding errors is not the goal of pre-parsing, |
144 // rather it is to speed up properly written and correct programs. | 152 // rather it is to speed up properly written and correct programs. |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
921 // Position right after terminal '}'. | 929 // Position right after terminal '}'. |
922 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 930 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
923 int body_end = scanner()->peek_location().end_pos; | 931 int body_end = scanner()->peek_location().end_pos; |
924 log_->LogFunction(body_start, body_end, | 932 log_->LogFunction(body_start, body_end, |
925 function_state_->materialized_literal_count(), | 933 function_state_->materialized_literal_count(), |
926 function_state_->expected_property_count(), | 934 function_state_->expected_property_count(), |
927 strict_mode()); | 935 strict_mode()); |
928 } | 936 } |
929 | 937 |
930 | 938 |
939 PreParserExpression PreParser::ParseClassLiteral( | |
940 PreParserIdentifier name, Scanner::Location class_name_location, | |
941 bool name_is_strict_reserved, int pos, bool* ok) { | |
942 // All parts of a ClassDeclaration and ClassExpression are strict code. | |
943 if (name_is_strict_reserved) { | |
944 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); | |
945 *ok = false; | |
946 return this->EmptyExpression(); | |
adamk
2014/11/13 01:45:44
"this->" unnecessary here and below, as well.
arv (Not doing code reviews)
2014/11/13 20:47:50
Done.
| |
947 } | |
948 if (this->IsEvalOrArguments(name)) { | |
949 ReportMessageAt(class_name_location, "strict_eval_arguments"); | |
950 *ok = false; | |
951 return this->EmptyExpression(); | |
952 } | |
953 | |
954 PreParserScope scope = this->NewScope(scope_, BLOCK_SCOPE); | |
955 BlockState block_state(&scope_, &scope); | |
956 scope_->SetStrictMode(STRICT); | |
957 scope_->SetScopeName(name); | |
958 | |
959 if (Check(Token::EXTENDS)) { | |
960 this->ParseLeftHandSideExpression(CHECK_OK); | |
961 } | |
962 | |
963 bool has_seen_constructor = false; | |
964 | |
965 Expect(Token::LBRACE, CHECK_OK); | |
966 while (peek() != Token::RBRACE) { | |
967 if (Check(Token::SEMICOLON)) continue; | |
968 const bool in_class = true; | |
969 const bool is_static = false; | |
970 this->ParsePropertyDefinition(NULL, in_class, is_static, | |
971 &has_seen_constructor, CHECK_OK); | |
972 } | |
973 | |
974 Expect(Token::RBRACE, CHECK_OK); | |
975 | |
976 return Expression::Default(); | |
977 } | |
978 | |
979 | |
931 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { | 980 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { |
932 // CallRuntime :: | 981 // CallRuntime :: |
933 // '%' Identifier Arguments | 982 // '%' Identifier Arguments |
934 Expect(Token::MOD, CHECK_OK); | 983 Expect(Token::MOD, CHECK_OK); |
935 if (!allow_natives_syntax()) { | 984 if (!allow_natives_syntax()) { |
936 *ok = false; | 985 *ok = false; |
937 return Expression::Default(); | 986 return Expression::Default(); |
938 } | 987 } |
939 // Allow "eval" or "arguments" for backward compatibility. | 988 // Allow "eval" or "arguments" for backward compatibility. |
940 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 989 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
941 ParseArguments(ok); | 990 ParseArguments(ok); |
942 | 991 |
943 return Expression::Default(); | 992 return Expression::Default(); |
944 } | 993 } |
945 | 994 |
946 #undef CHECK_OK | 995 #undef CHECK_OK |
947 | 996 |
948 | 997 |
949 } } // v8::internal | 998 } } // v8::internal |
OLD | NEW |