Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/parser.cc

Issue 1139773005: [destructuring] More tests for object literal pattern (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed undetectable check Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4126 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError), 4126 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError),
4127 arguments, pos); 4127 arguments, pos);
4128 IfStatement* if_statement = factory()->NewIfStatement( 4128 IfStatement* if_statement = factory()->NewIfStatement(
4129 factory()->NewUnaryOperation(Token::NOT, construct_check, pos), 4129 factory()->NewUnaryOperation(Token::NOT, construct_check, pos),
4130 factory()->NewReturnStatement(non_callable_error, pos), 4130 factory()->NewReturnStatement(non_callable_error, pos),
4131 factory()->NewEmptyStatement(pos), pos); 4131 factory()->NewEmptyStatement(pos), pos);
4132 body->Add(if_statement, zone()); 4132 body->Add(if_statement, zone());
4133 } 4133 }
4134 4134
4135 4135
4136 Statement* Parser::BuildAssertIsCoercible(Variable* var) {
4137 // if (var === null || var === undefined)
4138 // return %ThrowNonCoercible(var);
arv (Not doing code reviews) 2015/05/18 14:00:27 Instead of creating a new runtime function you can
Dmitry Lomov (no reviews) 2015/05/18 14:25:56 Done.
4139
4140 ZoneList<Expression*>* is_undetectable_arguments =
4141 new (zone()) ZoneList<Expression*>(1, zone());
4142 is_undetectable_arguments->Add(factory()->NewVariableProxy(var), zone());
4143 Expression* condition = factory()->NewBinaryOperation(
4144 Token::OR, factory()->NewCompareOperation(
4145 Token::EQ_STRICT, factory()->NewVariableProxy(var),
4146 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
4147 RelocInfo::kNoPosition),
4148 factory()->NewCompareOperation(
4149 Token::EQ_STRICT, factory()->NewVariableProxy(var),
4150 factory()->NewNullLiteral(RelocInfo::kNoPosition),
4151 RelocInfo::kNoPosition),
4152 RelocInfo::kNoPosition);
4153 CallRuntime* non_callable_error = factory()->NewCallRuntime(
4154 ast_value_factory()->empty_string(),
4155 Runtime::FunctionForId(Runtime::kThrowNonCoercible),
4156 non_coercible_arguments, RelocInfo::kNoPosition);
4157 IfStatement* if_statement = factory()->NewIfStatement(
4158 condition,
4159 factory()->NewReturnStatement(non_callable_error, RelocInfo::kNoPosition),
4160 factory()->NewEmptyStatement(RelocInfo::kNoPosition),
4161 RelocInfo::kNoPosition);
4162 return if_statement;
4163 }
4164
4165
4136 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( 4166 ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
4137 const AstRawString* function_name, int pos, Variable* fvar, 4167 const AstRawString* function_name, int pos, Variable* fvar,
4138 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { 4168 Token::Value fvar_init_op, FunctionKind kind, bool* ok) {
4139 // Everything inside an eagerly parsed function will be parsed eagerly 4169 // Everything inside an eagerly parsed function will be parsed eagerly
4140 // (see comment above). 4170 // (see comment above).
4141 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 4171 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
4142 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8, zone()); 4172 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8, zone());
4143 if (fvar != NULL) { 4173 if (fvar != NULL) {
4144 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name); 4174 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name);
4145 fproxy->BindTo(fvar); 4175 fproxy->BindTo(fvar);
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
5748 5778
5749 Expression* Parser::SpreadCallNew(Expression* function, 5779 Expression* Parser::SpreadCallNew(Expression* function,
5750 ZoneList<v8::internal::Expression*>* args, 5780 ZoneList<v8::internal::Expression*>* args,
5751 int pos) { 5781 int pos) {
5752 args->InsertAt(0, function, zone()); 5782 args->InsertAt(0, function, zone());
5753 5783
5754 return factory()->NewCallRuntime( 5784 return factory()->NewCallRuntime(
5755 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5785 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5756 } 5786 }
5757 } } // namespace v8::internal 5787 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | test/mjsunit/harmony/destructuring.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698