| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 2118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 DARTSCOPE(Thread::Current()); | 2129 DARTSCOPE(Thread::Current()); |
| 2130 Isolate* I = T->isolate(); | 2130 Isolate* I = T->isolate(); |
| 2131 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(instance)); | 2131 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(instance)); |
| 2132 if (obj.IsNull()) { | 2132 if (obj.IsNull()) { |
| 2133 return Api::NewHandle(T, I->object_store()->null_type()); | 2133 return Api::NewHandle(T, I->object_store()->null_type()); |
| 2134 } | 2134 } |
| 2135 if (!obj.IsInstance()) { | 2135 if (!obj.IsInstance()) { |
| 2136 RETURN_TYPE_ERROR(Z, instance, Instance); | 2136 RETURN_TYPE_ERROR(Z, instance, Instance); |
| 2137 } | 2137 } |
| 2138 const AbstractType& type = | 2138 const AbstractType& type = |
| 2139 AbstractType::Handle(Instance::Cast(obj).GetType()); | 2139 AbstractType::Handle(Instance::Cast(obj).GetType(Heap::kNew)); |
| 2140 return Api::NewHandle(T, type.Canonicalize()); | 2140 return Api::NewHandle(T, type.Canonicalize()); |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 | 2143 |
| 2144 // --- Numbers, Integers and Doubles ---- | 2144 // --- Numbers, Integers and Doubles ---- |
| 2145 | 2145 |
| 2146 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, | 2146 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, |
| 2147 bool* fits) { | 2147 bool* fits) { |
| 2148 API_TIMELINE_DURATION; | 2148 API_TIMELINE_DURATION; |
| 2149 // Fast path for Smis and Mints. | 2149 // Fast path for Smis and Mints. |
| (...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4067 RETURN_TYPE_ERROR(Z, object, Instance); | 4067 RETURN_TYPE_ERROR(Z, object, Instance); |
| 4068 } | 4068 } |
| 4069 | 4069 |
| 4070 // Since we have allocated an object it would mean that the type | 4070 // Since we have allocated an object it would mean that the type |
| 4071 // is finalized. | 4071 // is finalized. |
| 4072 // TODO(asiva): How do we ensure that a constructor is not called more than | 4072 // TODO(asiva): How do we ensure that a constructor is not called more than |
| 4073 // once for the same object. | 4073 // once for the same object. |
| 4074 | 4074 |
| 4075 // Construct name of the constructor to invoke. | 4075 // Construct name of the constructor to invoke. |
| 4076 const String& constructor_name = Api::UnwrapStringHandle(Z, name); | 4076 const String& constructor_name = Api::UnwrapStringHandle(Z, name); |
| 4077 const AbstractType& type_obj = AbstractType::Handle(Z, instance.GetType()); | 4077 const AbstractType& type_obj = |
| 4078 AbstractType::Handle(Z, instance.GetType(Heap::kNew)); |
| 4078 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 4079 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
| 4079 const String& class_name = String::Handle(Z, cls.Name()); | 4080 const String& class_name = String::Handle(Z, cls.Name()); |
| 4080 const Array& strings = Array::Handle(Z, Array::New(3)); | 4081 const Array& strings = Array::Handle(Z, Array::New(3)); |
| 4081 strings.SetAt(0, class_name); | 4082 strings.SetAt(0, class_name); |
| 4082 strings.SetAt(1, Symbols::Dot()); | 4083 strings.SetAt(1, Symbols::Dot()); |
| 4083 if (constructor_name.IsNull()) { | 4084 if (constructor_name.IsNull()) { |
| 4084 strings.SetAt(2, Symbols::Empty()); | 4085 strings.SetAt(2, Symbols::Empty()); |
| 4085 } else { | 4086 } else { |
| 4086 strings.SetAt(2, constructor_name); | 4087 strings.SetAt(2, constructor_name); |
| 4087 } | 4088 } |
| (...skipping 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6596 | 6597 |
| 6597 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6598 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6598 #if defined(DART_PRECOMPILED_RUNTIME) | 6599 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6599 return true; | 6600 return true; |
| 6600 #else | 6601 #else |
| 6601 return false; | 6602 return false; |
| 6602 #endif | 6603 #endif |
| 6603 } | 6604 } |
| 6604 | 6605 |
| 6605 } // namespace dart | 6606 } // namespace dart |
| OLD | NEW |