OLD | NEW |
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 4125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4136 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError), | 4136 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError), |
4137 arguments, pos); | 4137 arguments, pos); |
4138 IfStatement* if_statement = factory()->NewIfStatement( | 4138 IfStatement* if_statement = factory()->NewIfStatement( |
4139 factory()->NewUnaryOperation(Token::NOT, construct_check, pos), | 4139 factory()->NewUnaryOperation(Token::NOT, construct_check, pos), |
4140 factory()->NewReturnStatement(non_callable_error, pos), | 4140 factory()->NewReturnStatement(non_callable_error, pos), |
4141 factory()->NewEmptyStatement(pos), pos); | 4141 factory()->NewEmptyStatement(pos), pos); |
4142 body->Add(if_statement, zone()); | 4142 body->Add(if_statement, zone()); |
4143 } | 4143 } |
4144 | 4144 |
4145 | 4145 |
| 4146 Statement* Parser::BuildAssertIsCoercible(Variable* var) { |
| 4147 // if (var === null || var === undefined) |
| 4148 // throw /* type error kNonCoercible) */; |
| 4149 |
| 4150 Expression* condition = factory()->NewBinaryOperation( |
| 4151 Token::OR, factory()->NewCompareOperation( |
| 4152 Token::EQ_STRICT, factory()->NewVariableProxy(var), |
| 4153 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), |
| 4154 RelocInfo::kNoPosition), |
| 4155 factory()->NewCompareOperation( |
| 4156 Token::EQ_STRICT, factory()->NewVariableProxy(var), |
| 4157 factory()->NewNullLiteral(RelocInfo::kNoPosition), |
| 4158 RelocInfo::kNoPosition), |
| 4159 RelocInfo::kNoPosition); |
| 4160 Expression* throw_type_error = this->NewThrowTypeError( |
| 4161 MessageTemplate::kNonCoercible, ast_value_factory()->empty_string(), |
| 4162 RelocInfo::kNoPosition); |
| 4163 IfStatement* if_statement = factory()->NewIfStatement( |
| 4164 condition, factory()->NewExpressionStatement(throw_type_error, |
| 4165 RelocInfo::kNoPosition), |
| 4166 factory()->NewEmptyStatement(RelocInfo::kNoPosition), |
| 4167 RelocInfo::kNoPosition); |
| 4168 return if_statement; |
| 4169 } |
| 4170 |
| 4171 |
4146 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4172 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4147 const AstRawString* function_name, int pos, Variable* fvar, | 4173 const AstRawString* function_name, int pos, Variable* fvar, |
4148 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 4174 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
4149 // Everything inside an eagerly parsed function will be parsed eagerly | 4175 // Everything inside an eagerly parsed function will be parsed eagerly |
4150 // (see comment above). | 4176 // (see comment above). |
4151 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4177 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4152 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8, zone()); | 4178 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8, zone()); |
4153 if (fvar != NULL) { | 4179 if (fvar != NULL) { |
4154 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name); | 4180 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name); |
4155 fproxy->BindTo(fvar); | 4181 fproxy->BindTo(fvar); |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5762 | 5788 |
5763 Expression* Parser::SpreadCallNew(Expression* function, | 5789 Expression* Parser::SpreadCallNew(Expression* function, |
5764 ZoneList<v8::internal::Expression*>* args, | 5790 ZoneList<v8::internal::Expression*>* args, |
5765 int pos) { | 5791 int pos) { |
5766 args->InsertAt(0, function, zone()); | 5792 args->InsertAt(0, function, zone()); |
5767 | 5793 |
5768 return factory()->NewCallRuntime( | 5794 return factory()->NewCallRuntime( |
5769 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5795 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5770 } | 5796 } |
5771 } } // namespace v8::internal | 5797 } } // namespace v8::internal |
OLD | NEW |