| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 bool AbstractType::IsListInterface() const { | 2149 bool AbstractType::IsListInterface() const { |
| 2150 return HasResolvedTypeClass() && | 2150 return HasResolvedTypeClass() && |
| 2151 (type_class() == Type::Handle(Type::ListInterface()).type_class()); | 2151 (type_class() == Type::Handle(Type::ListInterface()).type_class()); |
| 2152 } | 2152 } |
| 2153 | 2153 |
| 2154 | 2154 |
| 2155 bool AbstractType::IsSubtypeOf(const AbstractType& other, | 2155 bool AbstractType::IsSubtypeOf(const AbstractType& other, |
| 2156 Error* malformed_error) const { | 2156 Error* malformed_error) const { |
| 2157 ASSERT(IsFinalized()); | 2157 ASSERT(IsFinalized()); |
| 2158 ASSERT(other.IsFinalized()); | 2158 ASSERT(other.IsFinalized()); |
| 2159 // In case the type checked in a type test is malformed, the code generator |
| 2160 // may compile a throw instead of a run time call performing the type check. |
| 2161 // However, in checked mode, a function type may include malformed result type |
| 2162 // and/or malformed parameter types, which will then be encountered here at |
| 2163 // run time. |
| 2164 if (IsMalformed()) { |
| 2165 ASSERT(FLAG_enable_type_checks); |
| 2166 if (malformed_error->IsNull()) { |
| 2167 *malformed_error = this->malformed_error(); |
| 2168 } |
| 2169 return false; |
| 2170 } |
| 2171 if (other.IsMalformed()) { |
| 2172 ASSERT(FLAG_enable_type_checks); |
| 2173 if (malformed_error->IsNull()) { |
| 2174 *malformed_error = other.malformed_error(); |
| 2175 } |
| 2176 return false; |
| 2177 } |
| 2159 // AbstractType parameters cannot be handled by Class::IsSubtypeOf(). | 2178 // AbstractType parameters cannot be handled by Class::IsSubtypeOf(). |
| 2160 if (IsTypeParameter() || other.IsTypeParameter()) { | 2179 if (IsTypeParameter() || other.IsTypeParameter()) { |
| 2161 // An uninstantiated type parameter is equivalent to Dynamic. | 2180 // An uninstantiated type parameter is equivalent to Dynamic. |
| 2162 return true; | 2181 return true; |
| 2163 } | 2182 } |
| 2164 const Class& cls = Class::Handle(type_class()); | 2183 const Class& cls = Class::Handle(type_class()); |
| 2165 return cls.IsSubtypeOf(AbstractTypeArguments::Handle(arguments()), | 2184 return cls.IsSubtypeOf(AbstractTypeArguments::Handle(arguments()), |
| 2166 Class::Handle(other.type_class()), | 2185 Class::Handle(other.type_class()), |
| 2167 AbstractTypeArguments::Handle(other.arguments()), | 2186 AbstractTypeArguments::Handle(other.arguments()), |
| 2168 malformed_error); | 2187 malformed_error); |
| (...skipping 4387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6556 *FieldAddrAtOffset(field_offset) = value.Canonicalize(); | 6575 *FieldAddrAtOffset(field_offset) = value.Canonicalize(); |
| 6557 } | 6576 } |
| 6558 | 6577 |
| 6559 | 6578 |
| 6560 bool Instance::IsInstanceOf(const AbstractType& other, | 6579 bool Instance::IsInstanceOf(const AbstractType& other, |
| 6561 const AbstractTypeArguments& other_instantiator, | 6580 const AbstractTypeArguments& other_instantiator, |
| 6562 Error* malformed_error) const { | 6581 Error* malformed_error) const { |
| 6563 ASSERT(other.IsFinalized()); | 6582 ASSERT(other.IsFinalized()); |
| 6564 ASSERT(!other.IsDynamicType()); | 6583 ASSERT(!other.IsDynamicType()); |
| 6565 ASSERT(!other.IsVoidType()); | 6584 ASSERT(!other.IsVoidType()); |
| 6585 ASSERT(!other.IsMalformed()); |
| 6566 if (IsNull()) { | 6586 if (IsNull()) { |
| 6567 Class& other_class = Class::Handle(); | 6587 Class& other_class = Class::Handle(); |
| 6568 if (other.IsTypeParameter()) { | 6588 if (other.IsTypeParameter()) { |
| 6569 if (other_instantiator.IsNull()) { | 6589 if (other_instantiator.IsNull()) { |
| 6570 return true; // Other type is uninstantiated, i.e. Dynamic. | 6590 return true; // Other type is uninstantiated, i.e. Dynamic. |
| 6571 } | 6591 } |
| 6572 const AbstractType& instantiated_other = | 6592 const AbstractType& instantiated_other = |
| 6573 AbstractType::Handle(other_instantiator.TypeAt(other.Index())); | 6593 AbstractType::Handle(other_instantiator.TypeAt(other.Index())); |
| 6574 ASSERT(instantiated_other.IsInstantiated()); | 6594 ASSERT(instantiated_other.IsInstantiated()); |
| 6575 other_class = instantiated_other.type_class(); | 6595 other_class = instantiated_other.type_class(); |
| (...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9190 const String& str = String::Handle(pattern()); | 9210 const String& str = String::Handle(pattern()); |
| 9191 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9211 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9192 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9212 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9193 char* chars = reinterpret_cast<char*>( | 9213 char* chars = reinterpret_cast<char*>( |
| 9194 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9214 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9195 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9215 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9196 return chars; | 9216 return chars; |
| 9197 } | 9217 } |
| 9198 | 9218 |
| 9199 } // namespace dart | 9219 } // namespace dart |
| OLD | NEW |