| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index c73b6d841cdb41a5d8d0fcf1db725d9997db0c5d..c6c30b6d9d0febfb91970646c30e3bf0996655d7 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -349,6 +349,9 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
|
| // Set start and end position to the same value
|
| function_scope->set_start_position(pos);
|
| function_scope->set_end_position(pos);
|
| + if (call_super) {
|
| + function_scope->RecordNewTargetUsage();
|
| + }
|
| ZoneList<Statement*>* body = NULL;
|
|
|
| {
|
| @@ -742,6 +745,17 @@ Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
|
| return factory->NewVariableProxy(scope->receiver(), pos);
|
| }
|
|
|
| +
|
| +Expression* ParserTraits::NewTargetExpression(Scope* scope,
|
| + AstNodeFactory* factory,
|
| + int start_position,
|
| + int end_position) {
|
| + return scope->NewUnresolved(
|
| + factory, parser_->ast_value_factory()->new_target_string(),
|
| + Variable::NEW_TARGET, start_position, end_position);
|
| +}
|
| +
|
| +
|
| Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory,
|
| int pos) {
|
| return factory->NewSuperReference(
|
| @@ -787,7 +801,8 @@ Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name,
|
| Scope* scope,
|
| AstNodeFactory* factory) {
|
| if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name);
|
| - return scope->NewUnresolved(factory, name, start_position, end_position);
|
| + return scope->NewUnresolved(factory, name, Variable::NORMAL, start_position,
|
| + end_position);
|
| }
|
|
|
|
|
| @@ -870,6 +885,7 @@ Parser::Parser(ParseInfo* info)
|
| set_allow_harmony_computed_property_names(
|
| FLAG_harmony_computed_property_names);
|
| set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
|
| + set_allow_harmony_new_target(FLAG_harmony_new_target);
|
| set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls);
|
| set_allow_strong_mode(FLAG_strong_mode);
|
| for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
|
| @@ -1912,9 +1928,9 @@ VariableProxy* Parser::NewUnresolved(const AstRawString* name,
|
| // scope.
|
| // Let/const variables in harmony mode are always added to the immediately
|
| // enclosing scope.
|
| - return DeclarationScope(mode)->NewUnresolved(factory(), name,
|
| - scanner()->location().beg_pos,
|
| - scanner()->location().end_pos);
|
| + return DeclarationScope(mode)->NewUnresolved(
|
| + factory(), name, Variable::NORMAL, scanner()->location().beg_pos,
|
| + scanner()->location().end_pos);
|
| }
|
|
|
|
|
| @@ -3454,8 +3470,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
|
| Expression* enumerable = ParseExpression(true, CHECK_OK);
|
| Expect(Token::RPAREN, CHECK_OK);
|
|
|
| - VariableProxy* each =
|
| - scope_->NewUnresolved(factory(), name, each_beg_pos, each_end_pos);
|
| + VariableProxy* each = scope_->NewUnresolved(
|
| + factory(), name, Variable::NORMAL, each_beg_pos, each_end_pos);
|
| Statement* body = ParseSubStatement(NULL, CHECK_OK);
|
| InitializeForEachStatement(loop, each, enumerable, body);
|
| Block* result =
|
| @@ -3536,8 +3552,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
|
| scope_ = for_scope;
|
| Expect(Token::RPAREN, CHECK_OK);
|
|
|
| - VariableProxy* each =
|
| - scope_->NewUnresolved(factory(), name, each_beg_pos, each_end_pos);
|
| + VariableProxy* each = scope_->NewUnresolved(
|
| + factory(), name, Variable::NORMAL, each_beg_pos, each_end_pos);
|
| Statement* body = ParseSubStatement(NULL, CHECK_OK);
|
| Block* body_block =
|
| factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition);
|
| @@ -4122,13 +4138,17 @@ void Parser::SkipLazyFunctionBody(const AstRawString* function_name,
|
| if (logger.scope_uses_super_property()) {
|
| scope_->RecordSuperPropertyUsage();
|
| }
|
| + if (logger.scope_uses_new_target()) {
|
| + fprintf(stderr, "SkipLazyFunctionBody uses new target\n");
|
| + scope_->RecordNewTargetUsage();
|
| + }
|
| if (produce_cached_parse_data()) {
|
| DCHECK(log_);
|
| // Position right after terminal '}'.
|
| int body_end = scanner()->location().end_pos;
|
| log_->LogFunction(function_block_pos, body_end, *materialized_literal_count,
|
| *expected_property_count, scope_->language_mode(),
|
| - scope_->uses_super_property());
|
| + scope_->uses_super_property(), scope_->uses_new_target());
|
| }
|
| }
|
|
|
| @@ -4250,6 +4270,8 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
|
| allow_harmony_computed_property_names());
|
| reusable_preparser_->set_allow_harmony_rest_params(
|
| allow_harmony_rest_params());
|
| + reusable_preparser_->set_allow_harmony_new_target(
|
| + allow_harmony_new_target());
|
| reusable_preparser_->set_allow_harmony_spreadcalls(
|
| allow_harmony_spreadcalls());
|
| reusable_preparser_->set_allow_strong_mode(allow_strong_mode());
|
|
|