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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 5be6d82b67d582b11601b227c0f7b9d739ba2480..7a7a87a0bc6e08fe65ddac14e5e9651fedf0effc 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -4133,6 +4133,36 @@ void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) {
}
+Statement* Parser::BuildAssertIsCoercible(Variable* var) {
+ // if (var === null || var === undefined)
+ // 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.
+
+ ZoneList<Expression*>* is_undetectable_arguments =
+ new (zone()) ZoneList<Expression*>(1, zone());
+ is_undetectable_arguments->Add(factory()->NewVariableProxy(var), zone());
+ Expression* condition = factory()->NewBinaryOperation(
+ Token::OR, factory()->NewCompareOperation(
+ Token::EQ_STRICT, factory()->NewVariableProxy(var),
+ factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
+ RelocInfo::kNoPosition),
+ factory()->NewCompareOperation(
+ Token::EQ_STRICT, factory()->NewVariableProxy(var),
+ factory()->NewNullLiteral(RelocInfo::kNoPosition),
+ RelocInfo::kNoPosition),
+ RelocInfo::kNoPosition);
+ CallRuntime* non_callable_error = factory()->NewCallRuntime(
+ ast_value_factory()->empty_string(),
+ Runtime::FunctionForId(Runtime::kThrowNonCoercible),
+ non_coercible_arguments, RelocInfo::kNoPosition);
+ IfStatement* if_statement = factory()->NewIfStatement(
+ condition,
+ factory()->NewReturnStatement(non_callable_error, RelocInfo::kNoPosition),
+ factory()->NewEmptyStatement(RelocInfo::kNoPosition),
+ RelocInfo::kNoPosition);
+ return if_statement;
+}
+
+
ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
const AstRawString* function_name, int pos, Variable* fvar,
Token::Value fvar_init_op, FunctionKind kind, bool* ok) {
« 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