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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); | 143 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); |
144 const Class& list_class = | 144 const Class& list_class = |
145 Class::Handle(zone, core_lib.LookupClass(Symbols::List())); | 145 Class::Handle(zone, core_lib.LookupClass(Symbols::List())); |
146 ASSERT(!list_class.IsNull()); | 146 ASSERT(!list_class.IsNull()); |
147 const Instance& instance = Instance::Cast(obj); | 147 const Instance& instance = Instance::Cast(obj); |
148 const Class& obj_class = Class::Handle(zone, obj.clazz()); | 148 const Class& obj_class = Class::Handle(zone, obj.clazz()); |
149 Error& malformed_type_error = Error::Handle(zone); | 149 Error& malformed_type_error = Error::Handle(zone); |
150 if (obj_class.IsSubtypeOf(Object::null_type_arguments(), | 150 if (obj_class.IsSubtypeOf(Object::null_type_arguments(), |
151 list_class, | 151 list_class, |
152 Object::null_type_arguments(), | 152 Object::null_type_arguments(), |
153 &malformed_type_error)) { | 153 &malformed_type_error, |
| 154 NULL, |
| 155 Heap::kNew)) { |
154 ASSERT(malformed_type_error.IsNull()); // Type is a raw List. | 156 ASSERT(malformed_type_error.IsNull()); // Type is a raw List. |
155 return instance.raw(); | 157 return instance.raw(); |
156 } | 158 } |
157 } | 159 } |
158 return Instance::null(); | 160 return Instance::null(); |
159 } | 161 } |
160 | 162 |
161 static RawInstance* GetMapInstance(Zone* zone, const Object& obj) { | 163 static RawInstance* GetMapInstance(Zone* zone, const Object& obj) { |
162 if (obj.IsInstance()) { | 164 if (obj.IsInstance()) { |
163 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); | 165 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); |
164 const Class& map_class = | 166 const Class& map_class = |
165 Class::Handle(core_lib.LookupClass(Symbols::Map())); | 167 Class::Handle(core_lib.LookupClass(Symbols::Map())); |
166 ASSERT(!map_class.IsNull()); | 168 ASSERT(!map_class.IsNull()); |
167 const Instance& instance = Instance::Cast(obj); | 169 const Instance& instance = Instance::Cast(obj); |
168 const Class& obj_class = Class::Handle(zone, obj.clazz()); | 170 const Class& obj_class = Class::Handle(zone, obj.clazz()); |
169 Error& malformed_type_error = Error::Handle(zone); | 171 Error& malformed_type_error = Error::Handle(zone); |
170 if (obj_class.IsSubtypeOf(Object::null_type_arguments(), | 172 if (obj_class.IsSubtypeOf(Object::null_type_arguments(), |
171 map_class, | 173 map_class, |
172 Object::null_type_arguments(), | 174 Object::null_type_arguments(), |
173 &malformed_type_error)) { | 175 &malformed_type_error, |
| 176 NULL, |
| 177 Heap::kNew)) { |
174 ASSERT(malformed_type_error.IsNull()); // Type is a raw Map. | 178 ASSERT(malformed_type_error.IsNull()); // Type is a raw Map. |
175 return instance.raw(); | 179 return instance.raw(); |
176 } | 180 } |
177 } | 181 } |
178 return Instance::null(); | 182 return Instance::null(); |
179 } | 183 } |
180 | 184 |
181 | 185 |
182 static bool GetNativeStringArgument(NativeArguments* arguments, | 186 static bool GetNativeStringArgument(NativeArguments* arguments, |
183 int arg_index, | 187 int arg_index, |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); | 2013 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); |
2010 if (obj.IsInstance()) { | 2014 if (obj.IsInstance()) { |
2011 const Class& future_class = | 2015 const Class& future_class = |
2012 Class::Handle(I->object_store()->future_class()); | 2016 Class::Handle(I->object_store()->future_class()); |
2013 ASSERT(!future_class.IsNull()); | 2017 ASSERT(!future_class.IsNull()); |
2014 const Class& obj_class = Class::Handle(Z, obj.clazz()); | 2018 const Class& obj_class = Class::Handle(Z, obj.clazz()); |
2015 Error& malformed_type_error = Error::Handle(Z); | 2019 Error& malformed_type_error = Error::Handle(Z); |
2016 bool is_future = obj_class.IsSubtypeOf(Object::null_type_arguments(), | 2020 bool is_future = obj_class.IsSubtypeOf(Object::null_type_arguments(), |
2017 future_class, | 2021 future_class, |
2018 Object::null_type_arguments(), | 2022 Object::null_type_arguments(), |
2019 &malformed_type_error); | 2023 &malformed_type_error, |
| 2024 NULL, |
| 2025 Heap::kNew); |
2020 ASSERT(malformed_type_error.IsNull()); // Type is a raw Future. | 2026 ASSERT(malformed_type_error.IsNull()); // Type is a raw Future. |
2021 return is_future; | 2027 return is_future; |
2022 } | 2028 } |
2023 return false; | 2029 return false; |
2024 } | 2030 } |
2025 | 2031 |
2026 | 2032 |
2027 // --- Instances ---- | 2033 // --- Instances ---- |
2028 | 2034 |
2029 DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance) { | 2035 DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance) { |
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 if (constructor.IsNull()) { | 3797 if (constructor.IsNull()) { |
3792 ASSERT(redirect_type.IsMalformed()); | 3798 ASSERT(redirect_type.IsMalformed()); |
3793 return Api::NewHandle(T, redirect_type.error()); | 3799 return Api::NewHandle(T, redirect_type.error()); |
3794 } | 3800 } |
3795 | 3801 |
3796 if (!redirect_type.IsInstantiated()) { | 3802 if (!redirect_type.IsInstantiated()) { |
3797 // The type arguments of the redirection type are instantiated from the | 3803 // The type arguments of the redirection type are instantiated from the |
3798 // type arguments of the type argument. | 3804 // type arguments of the type argument. |
3799 Error& bound_error = Error::Handle(); | 3805 Error& bound_error = Error::Handle(); |
3800 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, | 3806 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, |
3801 &bound_error); | 3807 &bound_error, |
| 3808 NULL, NULL, Heap::kNew); |
3802 if (!bound_error.IsNull()) { | 3809 if (!bound_error.IsNull()) { |
3803 return Api::NewHandle(T, bound_error.raw()); | 3810 return Api::NewHandle(T, bound_error.raw()); |
3804 } | 3811 } |
3805 redirect_type ^= redirect_type.Canonicalize(); | 3812 redirect_type ^= redirect_type.Canonicalize(); |
3806 } | 3813 } |
3807 | 3814 |
3808 type_obj = redirect_type.raw(); | 3815 type_obj = redirect_type.raw(); |
3809 type_arguments = redirect_type.arguments(); | 3816 type_arguments = redirect_type.arguments(); |
3810 | 3817 |
3811 cls = type_obj.type_class(); | 3818 cls = type_obj.type_class(); |
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6161 return Api::Success(); | 6168 return Api::Success(); |
6162 } | 6169 } |
6163 #endif // DART_PRECOMPILER | 6170 #endif // DART_PRECOMPILER |
6164 | 6171 |
6165 | 6172 |
6166 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6173 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
6167 return Dart::IsRunningPrecompiledCode(); | 6174 return Dart::IsRunningPrecompiledCode(); |
6168 } | 6175 } |
6169 | 6176 |
6170 } // namespace dart | 6177 } // namespace dart |
OLD | NEW |