OLD | NEW |
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/ast.h" | 5 #include "src/ast/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 | 8 |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 void ArrayLiteral::BuildConstantElements(Isolate* isolate) { | 496 void ArrayLiteral::BuildConstantElements(Isolate* isolate) { |
497 DCHECK_LT(first_spread_index_, 0); | 497 DCHECK_LT(first_spread_index_, 0); |
498 | 498 |
499 if (!constant_elements_.is_null()) return; | 499 if (!constant_elements_.is_null()) return; |
500 | 500 |
501 int constants_length = values()->length(); | 501 int constants_length = values()->length(); |
502 | 502 |
503 // Allocate a fixed array to hold all the object literals. | 503 // Allocate a fixed array to hold all the object literals. |
504 Handle<JSArray> array = isolate->factory()->NewJSArray( | 504 Handle<JSArray> array = isolate->factory()->NewJSArray( |
505 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, | 505 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, |
506 Strength::WEAK, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 506 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
507 | 507 |
508 // Fill in the literals. | 508 // Fill in the literals. |
509 bool is_simple = true; | 509 bool is_simple = true; |
510 int depth_acc = 1; | 510 int depth_acc = 1; |
511 bool is_holey = false; | 511 bool is_holey = false; |
512 int array_index = 0; | 512 int array_index = 0; |
513 for (; array_index < constants_length; array_index++) { | 513 for (; array_index < constants_length; array_index++) { |
514 Expression* element = values()->at(array_index); | 514 Expression* element = values()->at(array_index); |
515 DCHECK(!element->IsSpread()); | 515 DCHECK(!element->IsSpread()); |
516 MaterializedLiteral* m_literal = element->AsMaterializedLiteral(); | 516 MaterializedLiteral* m_literal = element->AsMaterializedLiteral(); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 bool Literal::Match(void* literal1, void* literal2) { | 834 bool Literal::Match(void* literal1, void* literal2) { |
835 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 835 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
836 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 836 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
837 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 837 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
838 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 838 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
839 } | 839 } |
840 | 840 |
841 | 841 |
842 } // namespace internal | 842 } // namespace internal |
843 } // namespace v8 | 843 } // namespace v8 |
OLD | NEW |