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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 } | 733 } |
734 | 734 |
735 | 735 |
736 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { | 736 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { |
737 return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); | 737 return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, | 741 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, |
742 int pos) { | 742 int pos) { |
743 return factory->NewVariableProxy(scope->receiver(), pos); | 743 return scope->NewUnresolved(factory, |
744 parser_->ast_value_factory()->this_string(), pos, | |
745 pos + 4, Variable::THIS); | |
arv (Not doing code reviews)
2015/05/05 14:59:10
I still want you to change the order of these para
wingo
2015/05/05 15:49:29
Sorry I forgot about this! Done. Had to add Vari
| |
744 } | 746 } |
745 | 747 |
746 Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory, | 748 Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory, |
747 int pos) { | 749 int pos) { |
748 return factory->NewSuperReference( | 750 return factory->NewSuperReference( |
749 ThisExpression(scope, factory, pos)->AsVariableProxy(), | 751 ThisExpression(scope, factory, pos)->AsVariableProxy(), |
750 pos); | 752 pos); |
751 } | 753 } |
752 | 754 |
753 | 755 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
959 // background thread. We should not access anything Isolate / heap dependent | 961 // background thread. We should not access anything Isolate / heap dependent |
960 // via ParseInfo, and also not pass it forward. | 962 // via ParseInfo, and also not pass it forward. |
961 DCHECK(scope_ == NULL); | 963 DCHECK(scope_ == NULL); |
962 DCHECK(target_stack_ == NULL); | 964 DCHECK(target_stack_ == NULL); |
963 | 965 |
964 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; | 966 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; |
965 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; | 967 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; |
966 | 968 |
967 FunctionLiteral* result = NULL; | 969 FunctionLiteral* result = NULL; |
968 { | 970 { |
971 // TODO(wingo): Add an outer GLOBAL_SCOPE corresponding to the native | |
972 // context, which will have the "this" binding for script scopes. | |
arv (Not doing code reviews)
2015/05/05 14:59:10
Might make sense. Also for module scopes there is
| |
969 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); | 973 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); |
970 info->set_script_scope(scope); | 974 info->set_script_scope(scope); |
971 if (!info->context().is_null() && !info->context()->IsNativeContext()) { | 975 if (!info->context().is_null() && !info->context()->IsNativeContext()) { |
972 scope = Scope::DeserializeScopeChain(info->isolate(), zone(), | 976 scope = Scope::DeserializeScopeChain(info->isolate(), zone(), |
973 *info->context(), scope); | 977 *info->context(), scope); |
974 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this | 978 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this |
975 // means the Parser cannot operate independent of the V8 heap. Tell the | 979 // means the Parser cannot operate independent of the V8 heap. Tell the |
976 // string table to internalize strings and values right after they're | 980 // string table to internalize strings and values right after they're |
977 // created. This kind of parsing can only be done in the main thread. | 981 // created. This kind of parsing can only be done in the main thread. |
978 DCHECK(parsing_on_main_thread_); | 982 DCHECK(parsing_on_main_thread_); |
(...skipping 4843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5822 | 5826 |
5823 Expression* Parser::SpreadCallNew(Expression* function, | 5827 Expression* Parser::SpreadCallNew(Expression* function, |
5824 ZoneList<v8::internal::Expression*>* args, | 5828 ZoneList<v8::internal::Expression*>* args, |
5825 int pos) { | 5829 int pos) { |
5826 args->InsertAt(0, function, zone()); | 5830 args->InsertAt(0, function, zone()); |
5827 | 5831 |
5828 return factory()->NewCallRuntime( | 5832 return factory()->NewCallRuntime( |
5829 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5833 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5830 } | 5834 } |
5831 } } // namespace v8::internal | 5835 } } // namespace v8::internal |
OLD | NEW |