| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 } | 641 } |
| 642 | 642 |
| 643 Expression* ParserTraits::ClassExpression( | 643 Expression* ParserTraits::ClassExpression( |
| 644 const AstRawString* name, Expression* extends, Expression* constructor, | 644 const AstRawString* name, Expression* extends, Expression* constructor, |
| 645 ZoneList<ObjectLiteral::Property*>* properties, int start_position, | 645 ZoneList<ObjectLiteral::Property*>* properties, int start_position, |
| 646 int end_position, AstNodeFactory<AstConstructionVisitor>* factory) { | 646 int end_position, AstNodeFactory<AstConstructionVisitor>* factory) { |
| 647 return factory->NewClassLiteral(name, extends, constructor, properties, | 647 return factory->NewClassLiteral(name, extends, constructor, properties, |
| 648 start_position, end_position); | 648 start_position, end_position); |
| 649 } | 649 } |
| 650 | 650 |
| 651 |
| 652 Expression* ParserTraits::DefaultConstructor( |
| 653 bool call_super, Scope* scope, |
| 654 AstNodeFactory<AstConstructionVisitor>* factory) { |
| 655 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE); |
| 656 // Set position and force eager compilation since lazy parsing tries to |
| 657 // parse the content which does not exist. |
| 658 function_scope->set_start_position(0); |
| 659 function_scope->set_end_position(0); |
| 660 // function_scope->SetScopeName(name); |
| 661 function_scope->ForceEagerCompilation(); |
| 662 |
| 663 int pos = RelocInfo::kNoPosition; |
| 664 |
| 665 Zone* zone = parser_->zone(); |
| 666 ZoneList<Statement*>* body = new (zone) ZoneList<Statement*>(1, zone); |
| 667 if (call_super) { |
| 668 Expression* prop = SuperReference(function_scope, factory, pos); |
| 669 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(0, zone); |
| 670 Expression* call_expression = factory->NewCall(prop, args, pos); |
| 671 body->Add(factory->NewExpressionStatement(call_expression, pos), zone); |
| 672 } |
| 673 |
| 674 int materialized_literal_count = 0; |
| 675 int expected_property_count = 0; |
| 676 int handler_count = 0; |
| 677 int parameter_count = 0; |
| 678 |
| 679 const AstRawString* name = ast_value_factory()->empty_string(); |
| 680 |
| 681 return factory->NewFunctionLiteral( |
| 682 name, ast_value_factory(), function_scope, body, |
| 683 materialized_literal_count, expected_property_count, handler_count, |
| 684 parameter_count, FunctionLiteral::kNoDuplicateParameters, |
| 685 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 686 FunctionLiteral::kNotParenthesized, FunctionKind::kNormalFunction, pos); |
| 687 } |
| 688 |
| 689 |
| 651 Literal* ParserTraits::ExpressionFromLiteral( | 690 Literal* ParserTraits::ExpressionFromLiteral( |
| 652 Token::Value token, int pos, | 691 Token::Value token, int pos, |
| 653 Scanner* scanner, | 692 Scanner* scanner, |
| 654 AstNodeFactory<AstConstructionVisitor>* factory) { | 693 AstNodeFactory<AstConstructionVisitor>* factory) { |
| 655 switch (token) { | 694 switch (token) { |
| 656 case Token::NULL_LITERAL: | 695 case Token::NULL_LITERAL: |
| 657 return factory->NewNullLiteral(pos); | 696 return factory->NewNullLiteral(pos); |
| 658 case Token::TRUE_LITERAL: | 697 case Token::TRUE_LITERAL: |
| 659 return factory->NewBooleanLiteral(true, pos); | 698 return factory->NewBooleanLiteral(true, pos); |
| 660 case Token::FALSE_LITERAL: | 699 case Token::FALSE_LITERAL: |
| (...skipping 4299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4960 | 4999 |
| 4961 // We cannot internalize on a background thread; a foreground task will take | 5000 // We cannot internalize on a background thread; a foreground task will take |
| 4962 // care of calling Parser::Internalize just before compilation. | 5001 // care of calling Parser::Internalize just before compilation. |
| 4963 | 5002 |
| 4964 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 5003 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
| 4965 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 5004 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
| 4966 log_ = NULL; | 5005 log_ = NULL; |
| 4967 } | 5006 } |
| 4968 } | 5007 } |
| 4969 } } // namespace v8::internal | 5008 } } // namespace v8::internal |
| OLD | NEW |