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.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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 | 537 |
538 bool Declaration::IsInlineable() const { | 538 bool Declaration::IsInlineable() const { |
539 return proxy()->var()->IsStackAllocated(); | 539 return proxy()->var()->IsStackAllocated(); |
540 } | 540 } |
541 | 541 |
542 bool FunctionDeclaration::IsInlineable() const { | 542 bool FunctionDeclaration::IsInlineable() const { |
543 return false; | 543 return false; |
544 } | 544 } |
545 | 545 |
546 | 546 |
| 547 SpreadOperation::SpreadOperation(Zone* zone, AstNodeFactory* factory, |
| 548 AstValueFactory* value_factory, Scope* scope, |
| 549 Expression* expression, int pos) : |
| 550 Expression(zone, pos), expression_(expression) { |
| 551 Variable* iterator = scope->DeclarationScope()->NewTemporary( |
| 552 value_factory->dot_iterator_string()); |
| 553 Variable* result = scope->DeclarationScope()->NewTemporary( |
| 554 value_factory->dot_result_string()); |
| 555 |
| 556 // var iterator = subject[Symbol.iterator](); |
| 557 assign_iterator_ = factory->NewAssignment( |
| 558 Token::ASSIGN, factory->NewVariableProxy(iterator), |
| 559 factory->GetIterator(expression), pos); |
| 560 |
| 561 // var result = iterator.next(); |
| 562 { |
| 563 Expression* iterator_proxy = factory->NewVariableProxy(iterator); |
| 564 Expression* next_literal = factory->NewStringLiteral( |
| 565 value_factory->next_string(), RelocInfo::kNoPosition); |
| 566 Expression* next_property = factory->NewProperty( |
| 567 iterator_proxy, next_literal, RelocInfo::kNoPosition); |
| 568 ZoneList<Expression*>* next_arguments = |
| 569 new(zone) ZoneList<Expression*>(0, zone); |
| 570 Expression* next_call = factory->NewCall(next_property, next_arguments, |
| 571 pos); |
| 572 Expression* result_proxy = factory->NewVariableProxy(result); |
| 573 next_result_ = factory->NewAssignment(Token::ASSIGN, result_proxy, |
| 574 next_call, pos); |
| 575 } |
| 576 |
| 577 // result.done |
| 578 { |
| 579 Expression* done_literal = factory->NewStringLiteral( |
| 580 value_factory->done_string(), RelocInfo::kNoPosition); |
| 581 Expression* result_proxy = factory->NewVariableProxy(result); |
| 582 result_done_ = factory->NewProperty( |
| 583 result_proxy, done_literal, RelocInfo::kNoPosition); |
| 584 } |
| 585 |
| 586 // result.value |
| 587 { |
| 588 Expression* value_literal = factory->NewStringLiteral( |
| 589 value_factory->value_string(), RelocInfo::kNoPosition); |
| 590 Expression* result_proxy = factory->NewVariableProxy(result); |
| 591 result_value_ = factory->NewProperty(result_proxy, value_literal, |
| 592 RelocInfo::kNoPosition); |
| 593 } |
| 594 } |
| 595 |
| 596 |
547 // ---------------------------------------------------------------------------- | 597 // ---------------------------------------------------------------------------- |
548 // Recording of type feedback | 598 // Recording of type feedback |
549 | 599 |
550 // TODO(rossberg): all RecordTypeFeedback functions should disappear | 600 // TODO(rossberg): all RecordTypeFeedback functions should disappear |
551 // once we use the common type field in the AST consistently. | 601 // once we use the common type field in the AST consistently. |
552 | 602 |
553 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 603 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
554 set_to_boolean_types(oracle->ToBooleanTypes(test_id())); | 604 set_to_boolean_types(oracle->ToBooleanTypes(test_id())); |
555 } | 605 } |
556 | 606 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 // static | 1069 // static |
1020 bool Literal::Match(void* literal1, void* literal2) { | 1070 bool Literal::Match(void* literal1, void* literal2) { |
1021 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1071 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1022 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1072 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1023 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1073 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
1024 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1074 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1025 } | 1075 } |
1026 | 1076 |
1027 | 1077 |
1028 } } // namespace v8::internal | 1078 } } // namespace v8::internal |
OLD | NEW |