| 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 6567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6578 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 6578 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 6579 type_arguments ^= *FieldAddrAtOffset(field_offset); | 6579 type_arguments ^= *FieldAddrAtOffset(field_offset); |
| 6580 return type_arguments.raw(); | 6580 return type_arguments.raw(); |
| 6581 } | 6581 } |
| 6582 | 6582 |
| 6583 | 6583 |
| 6584 void Instance::SetTypeArguments(const AbstractTypeArguments& value) const { | 6584 void Instance::SetTypeArguments(const AbstractTypeArguments& value) const { |
| 6585 const Class& cls = Class::Handle(clazz()); | 6585 const Class& cls = Class::Handle(clazz()); |
| 6586 intptr_t field_offset = cls.type_arguments_instance_field_offset(); | 6586 intptr_t field_offset = cls.type_arguments_instance_field_offset(); |
| 6587 ASSERT(field_offset != Class::kNoTypeArguments); | 6587 ASSERT(field_offset != Class::kNoTypeArguments); |
| 6588 *FieldAddrAtOffset(field_offset) = value.Canonicalize(); | 6588 *FieldAddrAtOffset(field_offset) = value.raw(); |
| 6589 } | 6589 } |
| 6590 | 6590 |
| 6591 | 6591 |
| 6592 bool Instance::IsInstanceOf(const AbstractType& other, | 6592 bool Instance::IsInstanceOf(const AbstractType& other, |
| 6593 const AbstractTypeArguments& other_instantiator, | 6593 const AbstractTypeArguments& other_instantiator, |
| 6594 Error* malformed_error) const { | 6594 Error* malformed_error) const { |
| 6595 ASSERT(other.IsFinalized()); | 6595 ASSERT(other.IsFinalized()); |
| 6596 ASSERT(!other.IsDynamicType()); | 6596 ASSERT(!other.IsDynamicType()); |
| 6597 ASSERT(!other.IsVoidType()); | 6597 ASSERT(!other.IsVoidType()); |
| 6598 ASSERT(!other.IsMalformed()); | 6598 ASSERT(!other.IsMalformed()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6612 return other_class.IsObjectClass() || other_class.IsDynamicClass(); | 6612 return other_class.IsObjectClass() || other_class.IsDynamicClass(); |
| 6613 } | 6613 } |
| 6614 const Class& cls = Class::Handle(clazz()); | 6614 const Class& cls = Class::Handle(clazz()); |
| 6615 // We must not encounter Object::sentinel() or Object::transition_sentinel(), | 6615 // We must not encounter Object::sentinel() or Object::transition_sentinel(), |
| 6616 // both instances of class NullClass, but not instance Object::null(). | 6616 // both instances of class NullClass, but not instance Object::null(). |
| 6617 ASSERT(!cls.IsNullClass()); | 6617 ASSERT(!cls.IsNullClass()); |
| 6618 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 6618 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 6619 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 6619 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
| 6620 if (num_type_arguments > 0) { | 6620 if (num_type_arguments > 0) { |
| 6621 type_arguments = GetTypeArguments(); | 6621 type_arguments = GetTypeArguments(); |
| 6622 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { |
| 6623 type_arguments = type_arguments.Canonicalize(); |
| 6624 SetTypeArguments(type_arguments); |
| 6625 } |
| 6622 // Verify that the number of type arguments in the instance matches the | 6626 // Verify that the number of type arguments in the instance matches the |
| 6623 // number of type arguments expected by the instance class. | 6627 // number of type arguments expected by the instance class. |
| 6624 // A discrepancy is allowed for closures, which borrow the type argument | 6628 // A discrepancy is allowed for closures, which borrow the type argument |
| 6625 // vector of their instantiator, which may be of a super class of the class | 6629 // vector of their instantiator, which may be of a super class of the class |
| 6626 // defining the closure. Truncating the vector to the correct length on | 6630 // defining the closure. Truncating the vector to the correct length on |
| 6627 // instantiation is unnecessary. The vector may therefore be longer. | 6631 // instantiation is unnecessary. The vector may therefore be longer. |
| 6628 ASSERT(type_arguments.IsNull() || | 6632 ASSERT(type_arguments.IsNull() || |
| 6629 (type_arguments.Length() == num_type_arguments) || | 6633 (type_arguments.Length() == num_type_arguments) || |
| 6630 (cls.IsSignatureClass() && | 6634 (cls.IsSignatureClass() && |
| 6631 (type_arguments.Length() > num_type_arguments))); | 6635 (type_arguments.Length() > num_type_arguments))); |
| (...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9233 const String& str = String::Handle(pattern()); | 9237 const String& str = String::Handle(pattern()); |
| 9234 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9238 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9235 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9239 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9236 char* chars = reinterpret_cast<char*>( | 9240 char* chars = reinterpret_cast<char*>( |
| 9237 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9241 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9238 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9242 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9239 return chars; | 9243 return chars; |
| 9240 } | 9244 } |
| 9241 | 9245 |
| 9242 } // namespace dart | 9246 } // namespace dart |
| OLD | NEW |