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

Side by Side Diff: src/ast.cc

Issue 1307223002: [es6] fix nested object literals with computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | test/mjsunit/es6/computed-property-names.js » ('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 #include "src/ast.h" 5 #include "src/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 #include "src/builtins.h" 8 #include "src/builtins.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/contexts.h" 10 #include "src/contexts.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { 427 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
428 if (!constant_properties_.is_null()) return; 428 if (!constant_properties_.is_null()) return;
429 429
430 // Allocate a fixed array to hold all the constant properties. 430 // Allocate a fixed array to hold all the constant properties.
431 Handle<FixedArray> constant_properties = isolate->factory()->NewFixedArray( 431 Handle<FixedArray> constant_properties = isolate->factory()->NewFixedArray(
432 boilerplate_properties_ * 2, TENURED); 432 boilerplate_properties_ * 2, TENURED);
433 433
434 int position = 0; 434 int position = 0;
435 // Accumulate the value in local variables and store it at the end. 435 // Accumulate the value in local variables and store it at the end.
436 bool is_simple = true; 436 // If computed properties are used, the literal is never simple.
437 bool is_simple = boilerplate_properties_ != 0 || properties()->length() == 0;
wingo 2015/08/24 16:04:40 I am missing a bit of context. Is boilerplate_pro
caitp (gmail) 2015/08/24 16:08:27 yeah, it can be organized that way for sure. I'm n
437 int depth_acc = 1; 438 int depth_acc = 1;
438 uint32_t max_element_index = 0; 439 uint32_t max_element_index = 0;
439 uint32_t elements = 0; 440 uint32_t elements = 0;
440 for (int i = 0; i < properties()->length(); i++) { 441 for (int i = 0; i < properties()->length(); i++) {
441 ObjectLiteral::Property* property = properties()->at(i); 442 ObjectLiteral::Property* property = properties()->at(i);
442 if (!IsBoilerplateProperty(property)) { 443 if (!IsBoilerplateProperty(property)) {
443 is_simple = false; 444 is_simple = false;
444 continue; 445 continue;
445 } 446 }
446 447
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 bool Literal::Match(void* literal1, void* literal2) { 1151 bool Literal::Match(void* literal1, void* literal2) {
1151 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1152 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1152 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1153 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1153 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 1154 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
1154 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1155 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1155 } 1156 }
1156 1157
1157 1158
1158 } // namespace internal 1159 } // namespace internal
1159 } // namespace v8 1160 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/computed-property-names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698