OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_DART_API_IMPL_H_ | 5 #ifndef VM_DART_API_IMPL_H_ |
6 #define VM_DART_API_IMPL_H_ | 6 #define VM_DART_API_IMPL_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/native_arguments.h" | 9 #include "vm/native_arguments.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. | 155 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
156 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); | 156 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); |
157 return !raw->IsHeapObject(); | 157 return !raw->IsHeapObject(); |
158 } | 158 } |
159 | 159 |
160 // Returns true if the handle holds a Dart Instance. | 160 // Returns true if the handle holds a Dart Instance. |
161 static bool IsInstance(Dart_Handle handle) { | 161 static bool IsInstance(Dart_Handle handle) { |
162 return (ClassId(handle) >= kInstanceCid); | 162 return (ClassId(handle) >= kInstanceCid); |
163 } | 163 } |
164 | 164 |
| 165 // Returns true if the handle holds an Error. |
| 166 static bool IsError(Dart_Handle handle) { |
| 167 return RawObject::IsErrorClassId(ClassId(handle)); |
| 168 } |
| 169 |
165 // Returns the value of a Smi. | 170 // Returns the value of a Smi. |
166 static intptr_t SmiValue(Dart_Handle handle) { | 171 static intptr_t SmiValue(Dart_Handle handle) { |
167 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. | 172 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
168 uword value = *(reinterpret_cast<uword*>(handle)); | 173 uword value = *(reinterpret_cast<uword*>(handle)); |
169 return Smi::ValueFromRaw(value); | 174 return Smi::ValueFromRaw(value); |
170 } | 175 } |
171 | 176 |
172 static intptr_t ClassId(Dart_Handle handle) { | 177 static intptr_t ClassId(Dart_Handle handle) { |
173 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. | 178 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
174 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); | 179 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return Api::NewError("%s: Cannot load after Dart_Precompile", \ | 296 return Api::NewError("%s: Cannot load after Dart_Precompile", \ |
292 CURRENT_FUNC); \ | 297 CURRENT_FUNC); \ |
293 } \ | 298 } \ |
294 | 299 |
295 #define ASSERT_CALLBACK_STATE(thread) \ | 300 #define ASSERT_CALLBACK_STATE(thread) \ |
296 ASSERT(thread->no_callback_scope_depth() == 0) | 301 ASSERT(thread->no_callback_scope_depth() == 0) |
297 | 302 |
298 } // namespace dart. | 303 } // namespace dart. |
299 | 304 |
300 #endif // VM_DART_API_IMPL_H_ | 305 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |