OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_RUNTIME_RUNTIME_UTILS_H_ | 5 #ifndef V8_RUNTIME_RUNTIME_UTILS_H_ |
6 #define V8_RUNTIME_RUNTIME_UTILS_H_ | 6 #define V8_RUNTIME_RUNTIME_UTILS_H_ |
7 | 7 |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 RUNTIME_ASSERT(args[index]->IsSmi()); \ | 47 RUNTIME_ASSERT(args[index]->IsSmi()); \ |
48 int name = args.smi_at(index); | 48 int name = args.smi_at(index); |
49 | 49 |
50 // Cast the given argument to a double and store it in a variable with | 50 // Cast the given argument to a double and store it in a variable with |
51 // the given name. If the argument is not a number (as opposed to | 51 // the given name. If the argument is not a number (as opposed to |
52 // the number not-a-number) call IllegalOperation and return. | 52 // the number not-a-number) call IllegalOperation and return. |
53 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ | 53 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ |
54 RUNTIME_ASSERT(args[index]->IsNumber()); \ | 54 RUNTIME_ASSERT(args[index]->IsNumber()); \ |
55 double name = args.number_at(index); | 55 double name = args.number_at(index); |
56 | 56 |
| 57 |
| 58 // Cast the given argument to a size_t and store its value in a variable with |
| 59 // the given name. If the argument is not a size_t call IllegalOperation and |
| 60 // return. |
| 61 #define CONVERT_SIZE_ARG_CHECKED(name, index) \ |
| 62 RUNTIME_ASSERT(args[index]->IsNumber()); \ |
| 63 Handle<Object> name##_object = args.at<Object>(index); \ |
| 64 size_t name = 0; \ |
| 65 RUNTIME_ASSERT(TryNumberToSize(isolate, *name##_object, &name)); |
| 66 |
| 67 |
57 // Call the specified converter on the object *comand store the result in | 68 // Call the specified converter on the object *comand store the result in |
58 // a variable of the specified type with the given name. If the | 69 // a variable of the specified type with the given name. If the |
59 // object is not a Number call IllegalOperation and return. | 70 // object is not a Number call IllegalOperation and return. |
60 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ | 71 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ |
61 RUNTIME_ASSERT(obj->IsNumber()); \ | 72 RUNTIME_ASSERT(obj->IsNumber()); \ |
62 type name = NumberTo##Type(obj); | 73 type name = NumberTo##Type(obj); |
63 | 74 |
64 | 75 |
65 // Cast the given argument to PropertyDetails and store its value in a | 76 // Cast the given argument to PropertyDetails and store its value in a |
66 // variable with the given name. If the argument is not a Smi call | 77 // variable with the given name. If the argument is not a Smi call |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #else | 158 #else |
148 #error Unknown endianness | 159 #error Unknown endianness |
149 #endif | 160 #endif |
150 } | 161 } |
151 #endif | 162 #endif |
152 | 163 |
153 } | 164 } |
154 } // namespace v8::internal | 165 } // namespace v8::internal |
155 | 166 |
156 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 167 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
OLD | NEW |