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

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: Comments addressed, landing 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 0f63d0bad5ee2191fd621eab98598f4192b597e6..dde2c7aff97c86c812e7d5b46c55e4af438f585e 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -4143,6 +4143,32 @@ void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) {
}
+Statement* Parser::BuildAssertIsCoercible(Variable* var) {
+ // if (var === null || var === undefined)
+ // throw /* type error kNonCoercible) */;
+
+ 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);
+ Expression* throw_type_error = this->NewThrowTypeError(
+ MessageTemplate::kNonCoercible, ast_value_factory()->empty_string(),
+ RelocInfo::kNoPosition);
+ IfStatement* if_statement = factory()->NewIfStatement(
+ condition, factory()->NewExpressionStatement(throw_type_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) {

Powered by Google App Engine
This is Rietveld 408576698