Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 5be6d82b67d582b11601b227c0f7b9d739ba2480..017eafbab4dccd97ad59be3851882a1494dc6e61 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -4133,6 +4133,45 @@ void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) { |
} |
+Statement* Parser::BuildAssertIsCoercible(Variable* var) { |
+ // if (var === null || var === undefined || %_IsUndetectableObject(var)) |
arv (Not doing code reviews)
2015/05/18 13:12:53
Is this right? Why can I not do?
let {someId} = d
Dmitry Lomov (no reviews)
2015/05/18 13:41:46
The truth is, I have just copied logic from CHECK_
|
+ // return %ThrowNonCoercible(var); |
+ |
+ ZoneList<Expression*>* non_coercible_arguments = |
+ new (zone()) ZoneList<Expression*>(0, zone()); |
+ 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()->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), |
+ factory()->NewCallRuntime( |
+ ast_value_factory()->empty_string(), |
+ Runtime::FunctionForId(Runtime::kInlineIsUndetectableObject), |
+ is_undetectable_arguments, 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) { |