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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 return factory->NewVariableProxy(scope->receiver(), pos); | 639 return factory->NewVariableProxy(scope->receiver(), pos); |
640 } | 640 } |
641 | 641 |
642 Expression* ParserTraits::SuperReference( | 642 Expression* ParserTraits::SuperReference( |
643 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { | 643 Scope* scope, AstNodeFactory<AstConstructionVisitor>* factory, int pos) { |
644 return factory->NewSuperReference( | 644 return factory->NewSuperReference( |
645 ThisExpression(scope, factory, pos)->AsVariableProxy(), | 645 ThisExpression(scope, factory, pos)->AsVariableProxy(), |
646 pos); | 646 pos); |
647 } | 647 } |
648 | 648 |
649 Expression* ParserTraits::ClassLiteral( | 649 Expression* ParserTraits::ClassExpression( |
650 const AstRawString* name, Expression* extends, Expression* constructor, | 650 const AstRawString* name, Expression* extends, Expression* constructor, |
651 ZoneList<ObjectLiteral::Property*>* properties, int pos, | 651 ZoneList<ObjectLiteral::Property*>* properties, int pos, |
652 AstNodeFactory<AstConstructionVisitor>* factory) { | 652 AstNodeFactory<AstConstructionVisitor>* factory) { |
653 return factory->NewClassLiteral(name, extends, constructor, properties, pos); | 653 return factory->NewClassLiteral(name, extends, constructor, properties, pos); |
654 } | 654 } |
655 | 655 |
656 Literal* ParserTraits::ExpressionFromLiteral( | 656 Literal* ParserTraits::ExpressionFromLiteral( |
657 Token::Value token, int pos, | 657 Token::Value token, int pos, |
658 Scanner* scanner, | 658 Scanner* scanner, |
659 AstNodeFactory<AstConstructionVisitor>* factory) { | 659 AstNodeFactory<AstConstructionVisitor>* factory) { |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 // so rewrite it as such. | 1949 // so rewrite it as such. |
1950 | 1950 |
1951 Expect(Token::CLASS, CHECK_OK); | 1951 Expect(Token::CLASS, CHECK_OK); |
1952 int pos = position(); | 1952 int pos = position(); |
1953 bool is_strict_reserved = false; | 1953 bool is_strict_reserved = false; |
1954 const AstRawString* name = | 1954 const AstRawString* name = |
1955 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 1955 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
1956 Expression* value = ParseClassLiteral(name, scanner()->location(), | 1956 Expression* value = ParseClassLiteral(name, scanner()->location(), |
1957 is_strict_reserved, pos, CHECK_OK); | 1957 is_strict_reserved, pos, CHECK_OK); |
1958 | 1958 |
1959 Block* block = factory()->NewBlock(NULL, 1, true, pos); | 1959 VariableProxy* proxy = NewUnresolved(name, LET, Interface::NewValue()); |
1960 VariableMode mode = LET; | |
1961 VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue()); | |
1962 Declaration* declaration = | 1960 Declaration* declaration = |
1963 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); | 1961 factory()->NewVariableDeclaration(proxy, LET, scope_, pos); |
1964 Declare(declaration, true, CHECK_OK); | 1962 Declare(declaration, true, CHECK_OK); |
| 1963 proxy->var()->set_initializer_position(pos); |
1965 | 1964 |
1966 Token::Value init_op = Token::INIT_LET; | 1965 Token::Value init_op = Token::INIT_LET; |
1967 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); | 1966 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); |
1968 block->AddStatement( | 1967 Statement* assignment_statement = |
1969 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 1968 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
1970 zone()); | |
1971 | |
1972 if (names) names->Add(name, zone()); | 1969 if (names) names->Add(name, zone()); |
1973 return block; | 1970 return assignment_statement; |
1974 } | 1971 } |
1975 | 1972 |
1976 | 1973 |
1977 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { | 1974 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
1978 if (allow_harmony_scoping() && strict_mode() == STRICT) { | 1975 if (allow_harmony_scoping() && strict_mode() == STRICT) { |
1979 return ParseScopedBlock(labels, ok); | 1976 return ParseScopedBlock(labels, ok); |
1980 } | 1977 } |
1981 | 1978 |
1982 // Block :: | 1979 // Block :: |
1983 // '{' Statement* '}' | 1980 // '{' Statement* '}' |
(...skipping 2965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4949 | 4946 |
4950 // We cannot internalize on a background thread; a foreground task will take | 4947 // We cannot internalize on a background thread; a foreground task will take |
4951 // care of calling Parser::Internalize just before compilation. | 4948 // care of calling Parser::Internalize just before compilation. |
4952 | 4949 |
4953 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 4950 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
4954 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 4951 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
4955 log_ = NULL; | 4952 log_ = NULL; |
4956 } | 4953 } |
4957 } | 4954 } |
4958 } } // namespace v8::internal | 4955 } } // namespace v8::internal |
OLD | NEW |