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

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: moar code reviews 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
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) kind = WithObjectLiteralBit(kind);
2152
2151 value = this->ParseFunctionLiteral( 2153 value = this->ParseFunctionLiteral(
2152 name, scanner()->location(), 2154 name, scanner()->location(),
2153 false, // reserved words are allowed here 2155 false, // reserved words are allowed here
2154 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, 2156 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
2155 FunctionLiteral::NORMAL_ARITY, 2157 FunctionLiteral::NORMAL_ARITY,
2156 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2158 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2157 2159
2158 return factory()->NewObjectLiteralProperty(name_expression, value, 2160 return factory()->NewObjectLiteralProperty(name_expression, value,
2159 ObjectLiteralProperty::COMPUTED, 2161 ObjectLiteralProperty::COMPUTED,
2160 is_static, *is_computed_name); 2162 is_static, *is_computed_name);
(...skipping 11 matching lines...) Expand all
2172 name_expression = ParsePropertyName( 2174 name_expression = ParsePropertyName(
2173 &name, &dont_care, &dont_care, &dont_care, is_computed_name, 2175 &name, &dont_care, &dont_care, &dont_care, is_computed_name,
2174 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2176 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2175 2177
2176 if (!*is_computed_name) { 2178 if (!*is_computed_name) {
2177 checker->CheckProperty(name_token, kAccessorProperty, is_static, 2179 checker->CheckProperty(name_token, kAccessorProperty, is_static,
2178 is_generator, 2180 is_generator,
2179 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2181 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2180 } 2182 }
2181 2183
2184 FunctionKind kind = FunctionKind::kAccessorFunction;
2185 if (!in_class) kind = WithObjectLiteralBit(kind);
arv (Not doing code reviews) 2015/03/10 16:49:06 It is not clear to me that we need this extra bit.
marja 2015/03/10 17:08:13 Scope-wise, a method (or an accessor) of an object
2182 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( 2186 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
2183 name, scanner()->location(), 2187 name, scanner()->location(),
2184 false, // reserved words are allowed here 2188 false, // reserved words are allowed here
2185 FunctionKind::kAccessorFunction, RelocInfo::kNoPosition, 2189 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
2186 FunctionLiteral::ANONYMOUS_EXPRESSION,
2187 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY, 2190 is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
2188 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2191 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2189 2192
2190 // Make sure the name expression is a string since we need a Name for 2193 // Make sure the name expression is a string since we need a Name for
2191 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this 2194 // Runtime_DefineAccessorPropertyUnchecked and since we can determine this
2192 // statically we can skip the extra runtime check. 2195 // statically we can skip the extra runtime check.
2193 if (!*is_computed_name) { 2196 if (!*is_computed_name) {
2194 name_expression = 2197 name_expression =
2195 factory()->NewStringLiteral(name, name_expression->position()); 2198 factory()->NewStringLiteral(name, name_expression->position());
2196 } 2199 }
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 *ok = false; 3119 *ok = false;
3117 return; 3120 return;
3118 } 3121 }
3119 has_seen_constructor_ = true; 3122 has_seen_constructor_ = true;
3120 return; 3123 return;
3121 } 3124 }
3122 } 3125 }
3123 } } // v8::internal 3126 } } // v8::internal
3124 3127
3125 #endif // V8_PREPARSER_H 3128 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698