| 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 "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 const Instance& instance = Instance::CheckedHandle(arguments.ArgAt(0)); | 558 const Instance& instance = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 559 const AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(1)); | 559 const AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(1)); |
| 560 const Instance& instantiator = Instance::CheckedHandle(arguments.ArgAt(2)); | 560 const Instance& instantiator = Instance::CheckedHandle(arguments.ArgAt(2)); |
| 561 const AbstractTypeArguments& instantiator_type_arguments = | 561 const AbstractTypeArguments& instantiator_type_arguments = |
| 562 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3)); | 562 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3)); |
| 563 const SubtypeTestCache& cache = | 563 const SubtypeTestCache& cache = |
| 564 SubtypeTestCache::CheckedHandle(arguments.ArgAt(4)); | 564 SubtypeTestCache::CheckedHandle(arguments.ArgAt(4)); |
| 565 ASSERT(type.IsFinalized()); | 565 ASSERT(type.IsFinalized()); |
| 566 Error& malformed_error = Error::Handle(); | 566 Error& malformed_error = Error::Handle(); |
| 567 const Bool& result = | 567 const Bool& result = |
| 568 instance.IsInstanceOf(type, | 568 Bool::Get(instance.IsInstanceOf(type, |
| 569 instantiator_type_arguments, | 569 instantiator_type_arguments, |
| 570 &malformed_error) ? Bool::True() : Bool::False(); | 570 &malformed_error)); |
| 571 if (FLAG_trace_type_checks) { | 571 if (FLAG_trace_type_checks) { |
| 572 PrintTypeCheck("InstanceOf", | 572 PrintTypeCheck("InstanceOf", |
| 573 instance, type, instantiator_type_arguments, result); | 573 instance, type, instantiator_type_arguments, result); |
| 574 } | 574 } |
| 575 if (!result.value() && !malformed_error.IsNull()) { | 575 if (!result.value() && !malformed_error.IsNull()) { |
| 576 // Throw a dynamic type error only if the instanceof test fails. | 576 // Throw a dynamic type error only if the instanceof test fails. |
| 577 const intptr_t location = GetCallerLocation(); | 577 const intptr_t location = GetCallerLocation(); |
| 578 String& malformed_error_message = String::Handle( | 578 String& malformed_error_message = String::Handle( |
| 579 String::New(malformed_error.ToErrorCString())); | 579 String::New(malformed_error.ToErrorCString())); |
| 580 Exceptions::CreateAndThrowTypeError( | 580 Exceptions::CreateAndThrowTypeError( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 ASSERT(!dst_type.IsMalbounded()); // Already checked in code generator. | 614 ASSERT(!dst_type.IsMalbounded()); // Already checked in code generator. |
| 615 ASSERT(!src_instance.IsNull()); // Already checked in inlined code. | 615 ASSERT(!src_instance.IsNull()); // Already checked in inlined code. |
| 616 | 616 |
| 617 Error& malformed_error = Error::Handle(); | 617 Error& malformed_error = Error::Handle(); |
| 618 const bool is_instance_of = src_instance.IsInstanceOf( | 618 const bool is_instance_of = src_instance.IsInstanceOf( |
| 619 dst_type, instantiator_type_arguments, &malformed_error); | 619 dst_type, instantiator_type_arguments, &malformed_error); |
| 620 | 620 |
| 621 if (FLAG_trace_type_checks) { | 621 if (FLAG_trace_type_checks) { |
| 622 PrintTypeCheck("TypeCheck", | 622 PrintTypeCheck("TypeCheck", |
| 623 src_instance, dst_type, instantiator_type_arguments, | 623 src_instance, dst_type, instantiator_type_arguments, |
| 624 is_instance_of ? Bool::True() : Bool::False()); | 624 Bool::Get(is_instance_of)); |
| 625 } | 625 } |
| 626 if (!is_instance_of) { | 626 if (!is_instance_of) { |
| 627 // Throw a dynamic type error. | 627 // Throw a dynamic type error. |
| 628 const intptr_t location = GetCallerLocation(); | 628 const intptr_t location = GetCallerLocation(); |
| 629 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType()); | 629 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType()); |
| 630 const String& src_type_name = String::Handle(src_type.UserVisibleName()); | 630 const String& src_type_name = String::Handle(src_type.UserVisibleName()); |
| 631 String& dst_type_name = String::Handle(); | 631 String& dst_type_name = String::Handle(); |
| 632 if (!dst_type.IsInstantiated()) { | 632 if (!dst_type.IsInstantiated()) { |
| 633 // Instantiate dst_type before reporting the error. | 633 // Instantiate dst_type before reporting the error. |
| 634 const AbstractType& instantiated_dst_type = AbstractType::Handle( | 634 const AbstractType& instantiated_dst_type = AbstractType::Handle( |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 field.UpdateCid(cid); | 1891 field.UpdateCid(cid); |
| 1892 intptr_t list_length = Field::kNoFixedLength; | 1892 intptr_t list_length = Field::kNoFixedLength; |
| 1893 if ((field.guarded_cid() != kDynamicCid) && | 1893 if ((field.guarded_cid() != kDynamicCid) && |
| 1894 field.is_final() && RawObject::IsBuiltinListClassId(cid)) { | 1894 field.is_final() && RawObject::IsBuiltinListClassId(cid)) { |
| 1895 list_length = GetListLength(value); | 1895 list_length = GetListLength(value); |
| 1896 } | 1896 } |
| 1897 field.UpdateLength(list_length); | 1897 field.UpdateLength(list_length); |
| 1898 } | 1898 } |
| 1899 | 1899 |
| 1900 } // namespace dart | 1900 } // namespace dart |
| OLD | NEW |