OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_BUILTINS_BUILTINS_UTILS_H_ | 5 #ifndef V8_BUILTINS_BUILTINS_UTILS_H_ |
6 #define V8_BUILTINS_BUILTINS_UTILS_H_ | 6 #define V8_BUILTINS_BUILTINS_UTILS_H_ |
7 | 7 |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/base/logging.h" | 9 #include "src/base/logging.h" |
10 #include "src/builtins/builtins.h" | 10 #include "src/builtins/builtins.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ | 138 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ |
139 isolate->factory()->NewStringFromAsciiChecked(method), \ | 139 isolate->factory()->NewStringFromAsciiChecked(method), \ |
140 args.receiver())); \ | 140 args.receiver())); \ |
141 } \ | 141 } \ |
142 Handle<Type> name = Handle<Type>::cast(args.receiver()) | 142 Handle<Type> name = Handle<Type>::cast(args.receiver()) |
143 | 143 |
144 // Throws a TypeError for {method} if the receiver is not coercible to Object, | 144 // Throws a TypeError for {method} if the receiver is not coercible to Object, |
145 // or converts the receiver to a String otherwise and assigns it to a new var | 145 // or converts the receiver to a String otherwise and assigns it to a new var |
146 // with the given {name}. | 146 // with the given {name}. |
147 #define TO_THIS_STRING(name, method) \ | 147 #define TO_THIS_STRING(name, method) \ |
148 if (args.receiver()->IsNull(isolate) || \ | 148 if (args.receiver()->IsNullOrUndefined(isolate)) { \ |
149 args.receiver()->IsUndefined(isolate)) { \ | |
150 THROW_NEW_ERROR_RETURN_FAILURE( \ | 149 THROW_NEW_ERROR_RETURN_FAILURE( \ |
151 isolate, \ | 150 isolate, \ |
152 NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, \ | 151 NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, \ |
153 isolate->factory()->NewStringFromAsciiChecked(method))); \ | 152 isolate->factory()->NewStringFromAsciiChecked(method))); \ |
154 } \ | 153 } \ |
155 Handle<String> name; \ | 154 Handle<String> name; \ |
156 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \ | 155 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \ |
157 isolate, name, Object::ToString(isolate, args.receiver())) | 156 isolate, name, Object::ToString(isolate, args.receiver())) |
158 | 157 |
159 } // namespace internal | 158 } // namespace internal |
160 } // namespace v8 | 159 } // namespace v8 |
161 | 160 |
162 #endif // V8_BUILTINS_BUILTINS_UTILS_H_ | 161 #endif // V8_BUILTINS_BUILTINS_UTILS_H_ |
OLD | NEW |