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

Side by Side Diff: src/preparser.h

Issue 994043003: [strong] More scoping related errors: object literal methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: code review (dslomov@) + some more tests Created 5 years, 9 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
« no previous file with comments | « src/objects.h ('k') | src/scopes.cc » ('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 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 2141
2142 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod 2142 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod
2143 : FunctionKind::kConciseMethod; 2143 : FunctionKind::kConciseMethod;
2144 2144
2145 if (in_class && !is_static && this->IsConstructor(name)) { 2145 if (in_class && !is_static && this->IsConstructor(name)) {
2146 *has_seen_constructor = true; 2146 *has_seen_constructor = true;
2147 kind = has_extends ? FunctionKind::kSubclassConstructor 2147 kind = has_extends ? FunctionKind::kSubclassConstructor
2148 : FunctionKind::kBaseConstructor; 2148 : FunctionKind::kBaseConstructor;
2149 } 2149 }
2150 2150
2151 if (!in_class) {
2152 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral);
Dmitry Lomov (no reviews) 2015/03/10 16:06:01 Add function: FunctionKind WithObjectLiteralBit(
marja 2015/03/10 16:17:38 Done.
2153 }
2154
2151 value = this->ParseFunctionLiteral( 2155 value = this->ParseFunctionLiteral(
2152 name, scanner()->location(), 2156 name, scanner()->location(),
2153 false, // reserved words are allowed here 2157 false, // reserved words are allowed here
2154 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, 2158 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
2155 FunctionLiteral::NORMAL_ARITY, 2159 FunctionLiteral::NORMAL_ARITY,
2156 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2160 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2157 2161
2158 return factory()->NewObjectLiteralProperty(name_expression, value, 2162 return factory()->NewObjectLiteralProperty(name_expression, value,
2159 ObjectLiteralProperty::COMPUTED, 2163 ObjectLiteralProperty::COMPUTED,
2160 is_static, *is_computed_name); 2164 is_static, *is_computed_name);
(...skipping 11 matching lines...) Expand all
2172 name_expression = ParsePropertyName( 2176 name_expression = ParsePropertyName(
2173 &name, &dont_care, &dont_care, &dont_care, is_computed_name, 2177 &name, &dont_care, &dont_care, &dont_care, is_computed_name,
2174 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2178 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2175 2179
2176 if (!*is_computed_name) { 2180 if (!*is_computed_name) {
2177 checker->CheckProperty(name_token, kAccessorProperty, is_static, 2181 checker->CheckProperty(name_token, kAccessorProperty, is_static,
2178 is_generator, 2182 is_generator,
2179 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2183 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2180 } 2184 }
2181 2185
2186 FunctionKind kind = FunctionKind::kAccessorFunction;
2187 if (!in_class) {
2188 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral);
Dmitry Lomov (no reviews) 2015/03/10 16:06:01 Ditto.
marja 2015/03/10 16:17:38 Done.
2189 }
2182 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( 2190 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
2183 name, scanner()->location(), 2191 name, scanner()->location(),
2184 false, // reserved words are allowed here 2192 false, // reserved words are allowed here
2185 FunctionKind::kAccessorFunction, RelocInfo::kNoPosition, 2193 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
2186 FunctionLiteral::ANONYMOUS_EXPRESSION,
2187 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY, 2194 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
2188 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2195 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2189 2196
2190 // Make sure the name expression is a string since we need a Name for 2197 // Make sure the name expression is a string since we need a Name for
2191 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this 2198 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this
2192 // statically we can skip the extra runtime check. 2199 // statically we can skip the extra runtime check.
2193 if (!*is_computed_name) { 2200 if (!*is_computed_name) {
2194 name_expression = 2201 name_expression =
2195 factory()->NewStringLiteral(name, name_expression->position()); 2202 factory()->NewStringLiteral(name, name_expression->position());
2196 } 2203 }
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 *ok = false; 3123 *ok = false;
3117 return; 3124 return;
3118 } 3125 }
3119 has_seen_constructor_ = true; 3126 has_seen_constructor_ = true;
3120 return; 3127 return;
3121 } 3128 }
3122 } 3129 }
3123 } } // v8::internal 3130 } } // v8::internal
3124 3131
3125 #endif // V8_PREPARSER_H 3132 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698